[Biojava-dev] Phred symbol deserialization

Matthew Pocock matthew_pocock at yahoo.co.uk
Tue Apr 6 06:16:24 EDT 2004


Hi Eric,

This is a bug. Our resident serialization guru is on his Easter break, 
but I'll take a look.

Matthew

Eric Haugen wrote:

>I've found that when I deserialize a Phred symbol (SimpleAtomicSymbol from the Phred alphabet == (DNA x SubIntegerAlphabet[0..99]) ), I get a brand new SimpleAtomicSymbol instead of the one already contained in the Phred alphabet.  So PhredTools.getPhredAlphabet().contains( symbol ) returns false for that symbol.
>
>The following kludgy addition to SimpleAtomicSymbol.java makes it work:
>
>import org.biojava.bio.program.phred.PhredTools;
>...
>  static final long serialVersionUID = -8426550133605911655l;
>
>  protected Object readResolve() throws java.io.InvalidObjectException {
>      Object result = this;
>      if ((this.getSymbols().size() == 2)
>      && Annotation.EMPTY_ANNOTATION.equals( this.getAnnotation() )) {
>          try {
>              Symbol symbol = PhredTools.getPhredAlphabet().getSymbol( this.getSymbols() );
>              if (symbol != null) {
>                  result = symbol;
>              }
>          } catch (Exception ignored) {
>              // Must not be a Phred symbol
>          }
>      }
>      return result;
>  }
>
>This causes as a side effect the initialization of the 400-symbol phred alphabet whenever ANY SimpleAtomicSymbol is deserialized.   And SimpleAtomicSymbol shouldn't have to know about various alphabets...
>So, I'm hoping someone else has a better idea.  Should AlphabetManager keep track of all cross-product symbols that should be singletons?
>
>Thanks,
>
>Eric
>
>  
>



More information about the biojava-dev mailing list