[Biojava-l] Gapping Sequence problems

mark.schreiber at novartis.com mark.schreiber at novartis.com
Wed Dec 21 08:57:16 EST 2005


You could try 

if(!inGapState && (seq[i].symbolAt(j) == gap || seq[i].symbolAt(j) == 
AlphabetManager.getGapSymbol()))

- Mark






"Dan Cardin" <ftdgc1 at uaf.edu>
Sent by: biojava-l-bounces at portal.open-bio.org
12/21/2005 04:16 PM

 
        To:     biojava-l at biojava.org
        cc:     (bcc: Mark Schreiber/GP/Novartis)
        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