[Biojava-dev] Potential Enhancements, Defect

Michael McCormick mmccormi at fhcrc.org
Tue Nov 8 13:12:44 EST 2005


Hi,

Unfortunately, I don't have time to provide a standalone JUnit for  
these changes since our JUnits are more focused on our surrounding  
business logic.  However, they have been used for about 3 months now  
without problems.  As you suggested below, I am enclosing an updated  
copy of org/biojava/bio/program/abi/ABIFChromatogram.java. The  
changes close the opened file resource and speed up ABI chromat  
reading.  The only other changes that we recommended involve  
Serialization.

Thanks.
Mike

Michael McCormick
Systems Analyst
Fred Hutchinson Cancer Research Center


-------------- next part --------------
A non-text attachment was scrubbed...
Name: ABIFChromatogram.java
Type: application/octet-stream
Size: 11058 bytes
Desc: not available
Url : http://portal.open-bio.org/pipermail/biojava-dev/attachments/20051108/eb6b9cf1/ABIFChromatogram-0001.obj
-------------- next part --------------

On Nov 3, 2005, at 7:34 PM, mark.schreiber at novartis.com wrote:

Hello -

Good to know that someone is giving biojava a good work out in J2EE!  
There
are several possibilities to commit the code.

1) I could arrange for a cvs account for you.
2) Send me the files and I will commit them.
3) For the classes that only require "implements Serializable" I can do
this.
4) Send me CVS patch files.

It would also be really great if you could provide simple JUnit tests  
that
proove the serialization regenerates objects that are .equals() and ==
where appropriate. eg Singletons and Fly weight objects must be == on
deserialization.

Also if you are going to use the new biojavax I don't think we have  
marked
anything as serializable yet.

- Mark

Mark Schreiber
Research Investigator (Bioinformatics)

Novartis Institute for Tropical Diseases (NITD)
10 Biopolis Road
#05-01 Chromos
Singapore 138670
www.nitd.novartis.com

phone +65 6722 2973
fax  +65 6722 2910





Michael McCormick <mmccormi at fhcrc.org>
Sent by: biojava-dev-bounces at portal.open-bio.org
10/29/2005 12:48 AM


         To:     biojava-dev at biojava.org
         cc:     (bcc: Mark Schreiber/GP/Novartis)
         Subject:        [Biojava-dev] Potential Enhancements, Defect


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));
>




_______________________________________________
biojava-dev mailing list
biojava-dev at biojava.org
http://biojava.org/mailman/listinfo/biojava-dev







More information about the biojava-dev mailing list