## org.biojava.bio.symbol
Class DoubleAlphabet.SubDoubleAlphabet

    java.lang.Object
      org.biojava.utils.Unchangeable
          org.biojava.bio.symbol.DoubleAlphabet.SubDoubleAlphabet

All Implemented Interfaces:
  Alphabet, Annotatable, Changeable, java.io.Serializable

Enclosing class:
  DoubleAlphabet

public static class DoubleAlphabet.SubDoubleAlphabet
extends Unchangeable
implements Alphabet, java.io.Serializable

A class to represent a contiguous range of double symbols.

Author:
  Matthew Pocock
See Also:
  Serialized Form

Nested Class Summary

Nested classes inherited from class org.biojava.bio.Annotatable
`Annotatable.AnnotationForwarder`

Field Summary

Fields inherited from interface org.biojava.bio.symbol.Alphabet
`EMPTY_ALPHABET, PARSERS, SYMBOLS`

Fields inherited from interface org.biojava.bio.Annotatable
`ANNOTATION`

Method Summary
`boolean` `contains(Symbol s)` Returns whether or not this Alphabet contains the symbol.
`java.util.List` `getAlphabets()` Return an ordered List of the alphabets which make up a compound alphabet.
`Symbol` `getAmbiguity(java.util.Set syms)` Get a symbol that represents the set of symbols in syms.
`Annotation` `getAnnotation()` Should return the associated annotation object.
`Symbol` `getGapSymbol()` Get the 'gap' ambiguity symbol that is most appropriate for this alphabet.
`java.lang.String` `getName()` Get the name of the alphabet.
`DoubleAlphabet.DoubleSymbol` `getSymbol(double val)`
`Symbol` `getSymbol(java.util.List rl)` Get a symbol from the Alphabet which corresponds to the specified ordered list of symbols.
`SymbolTokenization` `getTokenization(java.lang.String name)` Get a SymbolTokenization by name.
`protected java.lang.Object` `readResolve()` To prevent duplication of a what should be a single instance of an existing alphabet.
`void` `validate(Symbol sym)` Throws a precanned IllegalSymbolException if the symbol is not contained within this Alphabet.

Methods inherited from class org.biojava.utils.Unchangeable
`addChangeListener, addChangeListener, addForwarder, getForwarders, getListeners, isUnchanging, removeChangeListener, removeChangeListener, removeForwarder`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface org.biojava.utils.Changeable
`addChangeListener, addChangeListener, isUnchanging, removeChangeListener, removeChangeListener`

Method Detail

### readResolve

    protected java.lang.Object readResolve()
                                    throws java.io.ObjectStreamException

  To prevent duplication of a what should be a single instance of an existing alphabet. This method was written as protected so that subclasses even from other packages will inherit it. It should only be overridden with care.

  Throws:
    `java.io.ObjectStreamException`

### getName

    public java.lang.String getName()

  Description copied from interface: `Alphabet`
  Get the name of the alphabet.

  Specified by:
    `getName` in interface `Alphabet`
  Returns:
    the name as a string.

### getAnnotation

    public Annotation getAnnotation()

  Description copied from interface: `Annotatable`
  Should return the associated annotation object.

  Specified by:
    `getAnnotation` in interface `Annotatable`
  Returns:
    an Annotation object, never null

### getAlphabets

    public java.util.List getAlphabets()

  Description copied from interface: `Alphabet`
  Return an ordered List of the alphabets which make up a compound alphabet. For simple alphabets, this will return a singleton list of itself. The returned list should be immutable.

  Specified by:
    `getAlphabets` in interface `Alphabet`
  Returns:
    a List of alphabets

### getSymbol

    public Symbol getSymbol(java.util.List rl)
                     throws IllegalSymbolException

  Description copied from interface: `Alphabet`

  Get a symbol from the Alphabet which corresponds to the specified ordered list of symbols.

  The symbol at i in the list must be a member of the i'th alphabet in getAlphabets. If all of the symbols in rl are atomic, then the resulting symbol will also be atomic. If any one of them is an ambiguity symbol then the resulting symbol will be the appropriate ambiguity symbol.

  Specified by:
    `getSymbol` in interface `Alphabet`
  Parameters:
    `rl` - A list of Symbol instances
  Throws:
    `IllegalSymbolException` - if the members of rl are not Symbols over the alphabets returned from `getAlphabets`

### getSymbol

    public DoubleAlphabet.DoubleSymbol getSymbol(double val)
                                          throws IllegalSymbolException

  Throws:
    `IllegalSymbolException`

### getAmbiguity

    public Symbol getAmbiguity(java.util.Set syms)

  Description copied from interface: `Alphabet`

  Get a symbol that represents the set of symbols in syms.

  Syms must be a set of Symbol instances each of which is contained within this alphabet. This method is used to retrieve ambiguity symbols.

  Specified by:
    `getAmbiguity` in interface `Alphabet`
  Parameters:
    `syms` - the Set of Symbols that will be found in getMatches of the returned symbol
  Returns:
    a Symbol (possibly fly-weighted) for the Set of symbols in syms

### getGapSymbol

    public Symbol getGapSymbol()

  Description copied from interface: `Alphabet`

  Get the 'gap' ambiguity symbol that is most appropriate for this alphabet.

  In general, this will be a BasisSymbol that represents a list of AlphabetManager.getGapSymbol() the same length as the getAlphabets list.

  Specified by:
    `getGapSymbol` in interface `Alphabet`
  Returns:
    the appropriate gap Symbol instance

### contains

    public boolean contains(Symbol s)

  Description copied from interface: `Alphabet`

  Returns whether or not this Alphabet contains the symbol.

  An alphabet contains an ambiguity symbol iff the ambiguity symbol's getMatches() returns an alphabet that is a proper sub-set of this alphabet. That means that every one of the symbols that could match the ambiguity symbol is also a member of this alphabet.

  Specified by:
    `contains` in interface `Alphabet`
  Parameters:
    `s` - the Symbol to check
  Returns:
    boolean true if the Alphabet contains the symbol and false otherwise

### validate

    public void validate(Symbol sym)
                  throws IllegalSymbolException

  Description copied from interface: `Alphabet`

  Throws a precanned IllegalSymbolException if the symbol is not contained within this Alphabet.

  This function is used all over the code to validate symbols as they enter a method. Also, the code is littered with catches for IllegalSymbolException. There is a preferred style of handling this, which should be covererd in the package documentation.

  Specified by:
    `validate` in interface `Alphabet`
  Parameters:
    `sym` - the Symbol to validate
  Throws:
    `IllegalSymbolException` - if r is not contained in this alphabet

### getTokenization

    public SymbolTokenization getTokenization(java.lang.String name)
                                       throws BioException

  Description copied from interface: `Alphabet`

  Get a SymbolTokenization by name.

  The parser returned is guaranteed to return Symbols and SymbolLists that conform to this alphabet.

  Every alphabet should have a SymbolTokenzation under the name 'token' that uses the symbol token characters to translate a string into a SymbolList. Likewise, there should be a SymbolTokenization under the name 'name' that uses symbol names to identify symbols. Any other names may also be defined, but the behaviour of the returned SymbolTokenization is not defined here.

  Specified by:
    `getTokenization` in interface `Alphabet`
  Parameters:
    `name` - the name of the parser
  Returns:
    a parser for that name
  Throws:
    `BioException` - if for any reason the tokenization could not be built