[Biojava-l] Gapping Sequence problems

Richard HOLLAND hollandr at gis.a-star.edu.sg
Wed Dec 21 04:22:09 EST 2005


I think you could try swapping the use of == for equals() when testing
for equivalence to the gap symbol. It _should_ be the same literal
object, but maybe not. equals() will work in both cases but == will not.

cheers,
Richard

Richard Holland
Bioinformatics Specialist
GIS extension 8199
---------------------------------------------
This email is confidential and may be privileged. If you are not the
intended recipient, please delete it and notify us immediately. Please
do not copy or use it for any purpose, or disclose its content to any
other person. Thank you.
---------------------------------------------


> -----Original Message-----
> From: biojava-l-bounces at portal.open-bio.org 
> [mailto:biojava-l-bounces at portal.open-bio.org] On Behalf Of Dan Cardin
> Sent: Wednesday, December 21, 2005 4:16 PM
> To: biojava-l at biojava.org
> Subject: [Biojava-l] Gapping Sequence problems
> 
> 
> Hello all, I am hung up on SimpleGappedSymbolList problem. I 
> want to add
> gaps to DNA sequences that are loaded in from file that 
> contain gaps and
> remove the gaps. I just load the sequences into an instance of type
> Sequence. Here is snippet ,
> 
> private void finalizeAddGapEdit(){
>    SimpleGappedSymbolList list = new
> SimpleGappedSymbolList(node.getSequence());
> 
>    try {
>       list.addGapsInSource(startX+1,counter);
> 
>       Sequence newSequence =
> DNATools.createDNASequence(list.seqString(),node.getSequence()
> .getName());
> 
>       node.setSequence(newSequence);
> 
>       gvc.repaint();
> 
> } catch (IllegalSymbolException e) {
>    // TODO Auto-generated catch block
>    e.printStackTrace();
> }
> 
> }
> 
> My code to draw out the gapped symbols looks like this
> 
> public void paint(Graphics g)
> {
> double leftX;
> Symbol gap;
> double scale_factor;
> boolean inGapState;
> max = 0;
> for(int i=0;i<seq.length;i++){
> 
>   gap = seq[i].getAlphabet().getGapSymbol();
>   leftX = 0;
>   scale_factor = (double) getWidth()/seq[i].length();
>   inGapState = true;
> 
>   for(int j=1;j<=seq[i].length();j++){
> 
>    if(!inGapState && seq[i].symbolAt(j) == gap){
>      g.drawLine((int) (leftX*scale_factor), i*pixels_bw_lines, (int)
>      ((j-1)*scale_factor) , i*pixels_bw_lines);
>      inGapState = true;
>    }
>    else if(inGapState && seq[i].symbolAt(j) != gap){
>    leftX = j-1;
>    inGapState = false;
>    }
>   }
>    //draw the last line
>    g.drawLine((int) (leftX*scale_factor), i*pixels_bw_lines, (int)
>    (seq[i].length()*scale_factor) , i*pixels_bw_lines);
> 
>    if(seq[i].length() > max)
>       max = seq[i].length();
> }
> }
> 
> My sequences load from file and display correctly , but when 
> I add gaps
> they don't show up. I am confused because I believe that the 
> gap symbols
> used in the underlying sequences are the same. The gaps are 
> added and I
> know this from printing out the string of the sequence. Does 
> anyone know
> how to fix this issue or have any suggestions on a better approach?
> 
> -dc
> _______________________________________________
> Biojava-l mailing list  -  Biojava-l at biojava.org
> http://biojava.org/mailman/listinfo/biojava-l
> 



More information about the Biojava-l mailing list