[Biojava-dev] Phred symbol deserialization

Eric Haugen ehaugen at u.washington.edu
Mon Apr 5 22:28:43 EDT 2004


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

-- 
Eric Haugen
University of Washington Genome Center



More information about the biojava-dev mailing list