[Biojava-l] Bug in FastaFormat.java

Simon Foote simon.foote@nrc.ca
Thu, 13 Dec 2001 11:51:15 -0500


There appears to be a bug in the writeSequence(Sequence seq, PrintStream os)
method of FastaFormat.java

If you have a sequence whose length is exactly divisable by the 
lineWidth (60), then you get an IndexOutOfBounds exception when writing 
it out.

The problem occurs at line 207:

for(int pos = 1; pos <= seq.length() + 1; pos += lineWidth) {

- removing the "+ 1" or making it "<" only  eliminates the error

for example, seq length = 30000
    last 2 times through the for loop for outputting gives:
    start: 29941    end:30000  
    start: 30001    end:30000    

Cheers,
Simon Foote

-- 
Bioinformatics Specialist
Institute for Biological Sciences
National Research Council of Canada
[T] 613-991-4342  [F] 613-952-9092