[Biojava-l] Gapping Sequence problems
Dan Cardin
ftdgc1 at uaf.edu
Wed Dec 21 03:16:27 EST 2005
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
More information about the Biojava-l
mailing list