[Biojava-dev] Potential Enhancements, Defect

Michael McCormick mmccormi at fhcrc.org
Fri Oct 28 12:48:37 EDT 2005


Greetings,

Ruihan Wang and I are developing an application that uses biojava in  
a J2EE environment. We have made a few changes and would like to add  
them to the biojava code. All of the changes except for one class  
involve serialization issues. Here is a brief summary.

Please let me know if you are interested in adding these changes and  
how they should be submitted.

Thanks.
Mike

Michael McCormick
Systems Analyst
Fred Hutchinson Cancer Research Center


/org/biojava/bio/search/SeqSimilaritySearchHit should be Serializable
/org/biojava/bio/search/SeqSimilaritySearchResult should be Serializable
/org/biojava/bio/search/SeqSimilaritySearchSubHit should be Serializable
/org/biojava/bio/seq/FeatureHolder should be Serializable
/org/biojava/bio/seq/db/SequenceDB should be Serializable
/org/biojava/bio/symbol/Symbol should be Serializable
/org/biojava/bio/symbol/SymbolList should be Serializable

/org/biojava/bio/symbol/SimpleAtomicSymbol and
/org/biojava/bio/symbol/SimpleBasisSymbol do not serialize correctly,  
however the mailing list provided a work around by commenting out the  
defective code.

org/biojava/bio/program/abi/ABIFChromatogram.java has a few issues.
1. Should be Serializable.
2. We experienced file handle count resource exceptions since File  
access was not being closed! This still needs future refactoring  
since the new close does not occur within a finally block.
3. Modify class to use readFully(). In our environment, this change  
allowed us to parse chromats at least 10 times faster.

diff for org/biojava/bio/program/abi/ABIFChromatogram.java
27,28d26
< import java.io.RandomAccessFile;
< import java.io.Serializable;
57c55
< public class ABIFChromatogram extends AbstractChromatogram  
implements Serializable {
---
 > public class ABIFChromatogram extends AbstractChromatogram {
141d138
<
151a149
 >
153d150
<             ((RandomAccessFile)getDataAccess()).close();
164a162
 >
166,171c164,166
<                 byte[] shortArray = new byte[2 * count];
<                 getDataAccess().readFully(shortArray);
<                 int i = 0;
<                 for (int s = 0; s < shortArray.length; s += 2) {
<                     trace[i] =  ((short)((shortArray[s] << 8) |  
(shortArray[s + 1] & 0xff))) & 0xffff;
<                     max = Math.max(trace[i++], max);
---
 >                 for (int i = 0 ; i < count ; i++) {
 >                     trace[i] = getDataAccess().readShort() & 0xffff;
 >                     max = Math.max(trace[i], max);
175,178c170,171
<                 byte[] byteArray = new byte[count];
<                 getDataAccess().readFully(byteArray);
<                 for (int i = 0; i < byteArray.length; i++) {
<                     trace[i] = byteArray[i] & 0xff;
---
 >                 for (int i = 0 ; i < count ; i++) {
 >                     trace[i] = getDataAccess().readByte() & 0xff;
185c178
<
---
 >
212,216c205,206
<                 byte[] shortArray = new byte[2 * count];
<                 getDataAccess().readFully(shortArray);
<                 IntegerAlphabet integerAlphabet =  
IntegerAlphabet.getInstance();
<                 for (int s = 0; s < shortArray.length; s += 2) {
<                     offsets.add(integerAlphabet.getSymbol(((short) 
((shortArray[s] << 8) | (shortArray[s + 1] & 0xff))) & 0xffff));
---
 >                 for (int i = 0 ; i < offsetsPtr.numberOfElements ;  
i++) {
 >                     offsets.add(IntegerAlphabet.getInstance 
().getSymbol(getDataAccess().readShort() & 0xffff));
220,224c210,211
<                 byte[] byteArray = new byte[count];
<                 getDataAccess().readFully(byteArray);
<                 IntegerAlphabet integerAlphabet =  
IntegerAlphabet.getInstance();
<                 for (int i = 0 ; i < byteArray.length; i++) {
<                     offsets.add(integerAlphabet.getSymbol(byteArray 
[i] & 0xff));
---
 >                 for (int i = 0 ; i < offsetsPtr.numberOfElements ;  
i++) {
 >                     offsets.add(IntegerAlphabet.getInstance 
().getSymbol(getDataAccess().readByte() & 0xff));
234,237c221,224
<                 byte[] byteArray = new byte[(int)  
basesPtr.numberOfElements];
<                 getDataAccess().readFully(byteArray);
<                 for (int i = 0; i < byteArray.length; i++) {
<                     dna.add(ABIFParser.decodeDNAToken((char)  
byteArray[i]));
---
 >                 char token;
 >                 for (int i = 0 ; i < basesPtr.numberOfElements ; i+ 
+) {
 >                     token = (char) getDataAccess().readByte();
 >                     dna.add(ABIFParser.decodeDNAToken(token));






More information about the biojava-dev mailing list