[Biojava-l] how to avoid duplicate codes

chen li chen_li3 at yahoo.com
Sat Jul 15 19:04:08 UTC 2006


Hi guys,

I am a newie in java and biojava. I just write a small
program for my study java purpose. What bother me
is that method do_revSeq() and do_revComSeq () look
like duplicate. I have problems to chain method
do_revSeq() and do_comSeq to get the revComSeq. Any
ideas on how to improve/correct it?

Thanks,

Li

public class SeqReader
{
    private String my_seq; 
    private String my_revSeq;
    private String my_comSeq;
    private String my_reComSeq;
                        
    public SeqReader()
     {
        my_seq="aatT  ccGG";         
    } 
    
    private String do_seq()
    { 
        return my_seq.replace(" ", "");//sequence
clean up      
    }
   
    public String do_revSeq()
         {
          my_revSeq=new
StringBuilder(do_seq()).reverse().toString().toUpperCase();
          return my_revSeq;        
            }
            
    public String do_comSeq()
         { 
          
my_comSeq=do_seq().toLowerCase().replace('a',
'T').replace('t', 'A').replace('c', 'G').replace('g',
'C');           
           return my_comSeq;                          
          
         }
          
   public String do_revComSeq ()
       {
           my_reComSeq=new
StringBuilder(do_comSeq()).reverse().toString().toUpperCase();
           return my_reComSeq;
      }

  public void print_results()
  {
    System.out.println(do_seq());
     System.out.println(do_revSeq());
      System.out.println( do_comSeq());
       System.out.println(do_revComSeq ());
   }
}  



__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



More information about the Biojava-l mailing list