[Biojava-l] how to avoid duplicate codes

Richard Holland richard.holland at ebi.ac.uk
Mon Jul 17 08:30:24 UTC 2006


There is nothing wrong with the way you are approaching the
bioinformatics part of the problem - the solution you have already is
just fine.

However, there are a few technical issues with the Java code you have
written, but that is for your Java tutor to solve, not us! :)

Good luck.

cheers,
Richard

On Sat, 2006-07-15 at 12:04 -0700, chen li wrote:
> 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 
> _______________________________________________
> Biojava-l mailing list  -  Biojava-l at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/biojava-l
-- 
Richard Holland (BioMart Team)
EMBL-EBI
Wellcome Trust Genome Campus
Hinxton
Cambridge CB10 1SD
UNITED KINGDOM
Tel: +44-(0)1223-494416




More information about the Biojava-l mailing list