Class DoubleAlphabet
- java.lang.Object
- 
- org.biojava.utils.Unchangeable
- 
- org.biojava.bio.symbol.DoubleAlphabet
 
 
- 
- All Implemented Interfaces:
- Serializable,- Annotatable,- Alphabet,- Changeable
 
 public final class DoubleAlphabet extends Unchangeable implements Alphabet, Serializable An efficient implementation of an Alphabet over the infinite set of double values. This class can be used to represent lists of floating-point numbers as a SymbolList with the alphabet DoubleAlphabet. These lists can then be annotated with features, or fed into dynamic-programming algorithms, or processed as per any other SymbolList object. Object identity should be used to decide if two DoubleResidue objects are the same. DoubleAlphabet ensures that all DoubleAlphabet instances are canonicalized. - Author:
- Matthew Pocock, Thomas Down
- See Also:
- Serialized Form
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classDoubleAlphabet.DoubleRangeA range of double values.static classDoubleAlphabet.DoubleSymbolA single double value.static classDoubleAlphabet.SubDoubleAlphabetA class to represent a contiguous range of double symbols.- 
Nested classes/interfaces inherited from interface org.biojava.bio.AnnotatableAnnotatable.AnnotationForwarder
 
- 
 - 
Field SummaryFields Modifier and Type Field Description static DoubleAlphabetINSTANCE- 
Fields inherited from interface org.biojava.bio.symbol.AlphabetEMPTY_ALPHABET, PARSERS, SYMBOLS
 - 
Fields inherited from interface org.biojava.bio.AnnotatableANNOTATION
 
- 
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontains(Symbol s)Returns whether or not this Alphabet contains the symbol.static SymbolListfromArray(double[] dArray)Retrieve a SymbolList view of an array of doubles.ListgetAlphabets()Return an ordered List of the alphabets which make up a compound alphabet.SymbolgetAmbiguity(Set syms)Get a symbol that represents the set of symbols in syms.AnnotationgetAnnotation()Should return the associated annotation object.SymbolgetGapSymbol()Get the 'gap' ambiguity symbol that is most appropriate for this alphabet.static DoubleAlphabetgetInstance()Retrieve the single DoubleAlphabet instance.StringgetName()Get the name of the alphabet.static DoubleAlphabet.SubDoubleAlphabetgetSubAlphabet(double min, double max)DoubleAlphabet.DoubleSymbolgetSymbol(double val)Retrieve the Symbol for a double.DoubleAlphabet.DoubleRangegetSymbol(double minVal, double maxVal)Retrieve the symbol for a range of doubles.SymbolgetSymbol(List symList)Get a symbol from the Alphabet which corresponds to the specified ordered list of symbols.SymbolTokenizationgetTokenization(String name)Get a SymbolTokenization by name.voidvalidate(Symbol s)Throws a precanned IllegalSymbolException if the symbol is not contained within this Alphabet.- 
Methods inherited from class org.biojava.utils.UnchangeableaddChangeListener, addChangeListener, addForwarder, getForwarders, getListeners, isUnchanging, removeChangeListener, removeChangeListener, removeForwarder
 - 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface org.biojava.utils.ChangeableaddChangeListener, addChangeListener, isUnchanging, removeChangeListener, removeChangeListener
 
- 
 
- 
- 
- 
Field Detail- 
INSTANCEpublic static DoubleAlphabet INSTANCE 
 
- 
 - 
Method Detail- 
fromArraypublic static SymbolList fromArray(double[] dArray) Retrieve a SymbolList view of an array of doubles. The returned object is a view onto the underlying array, and does not copy it. Changes made to the original array will alter the resulting SymbolList. - Parameters:
- dArray- the array of doubles to view
- Returns:
- a SymbolList over the DoubleAlphabet that represent the values in dArray
 
 - 
getInstancepublic static DoubleAlphabet getInstance() Retrieve the single DoubleAlphabet instance.- Returns:
- the singleton DoubleAlphabet instance
 
 - 
getSymbolpublic DoubleAlphabet.DoubleSymbol getSymbol(double val) Retrieve the Symbol for a double.- Parameters:
- val- the double to view
- Returns:
- a DoubleSymbol embodying val
 
 - 
getSymbolpublic DoubleAlphabet.DoubleRange getSymbol(double minVal, double maxVal) Retrieve the symbol for a range of doubles.- Parameters:
- minVal- the minimum value
- maxVal- that maximum value
- Returns:
- a DoubleRange containing all doubles between min and max value.
 
 - 
getSubAlphabetpublic static DoubleAlphabet.SubDoubleAlphabet getSubAlphabet(double min, double max) 
 - 
getAnnotationpublic Annotation getAnnotation() Description copied from interface:AnnotatableShould return the associated annotation object.- Specified by:
- getAnnotationin interface- Annotatable
- Returns:
- an Annotation object, never null
 
 - 
containspublic boolean contains(Symbol s) Description copied from interface:AlphabetReturns 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. 
 - 
validatepublic void validate(Symbol s) throws IllegalSymbolException Description copied from interface:AlphabetThrows 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:
- validatein interface- Alphabet
- Parameters:
- s- the Symbol to validate
- Throws:
- IllegalSymbolException- if r is not contained in this alphabet
 
 - 
getAlphabetspublic List getAlphabets() Description copied from interface:AlphabetReturn 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:
- getAlphabetsin interface- Alphabet
- Returns:
- a List of alphabets
 
 - 
getGapSymbolpublic Symbol getGapSymbol() Description copied from interface:AlphabetGet 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:
- getGapSymbolin interface- Alphabet
- Returns:
- the appropriate gap Symbol instance
 
 - 
getAmbiguitypublic Symbol getAmbiguity(Set syms) throws IllegalSymbolException Description copied from interface:AlphabetGet 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:
- getAmbiguityin 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
- Throws:
- IllegalSymbolException
 
 - 
getSymbolpublic Symbol getSymbol(List symList) throws IllegalSymbolException Description copied from interface:AlphabetGet 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:
- getSymbolin interface- Alphabet
- Parameters:
- symList- A list of Symbol instances
- Throws:
- IllegalSymbolException- if the members of rl are not Symbols over the alphabets returned from- getAlphabets
 
 - 
getNamepublic String getName() Description copied from interface:AlphabetGet the name of the alphabet.
 - 
getTokenizationpublic SymbolTokenization getTokenization(String name) Description copied from interface:AlphabetGet 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 behavior of the returned SymbolTokenization is not defined here. A SymbolTokenization under the name 'default' should be defined for all sequences, that determines the behavior when printing out a sequence. Standard behavior is to define the 'token' SymbolTokenization as default if it exists, else to define the 'name' SymbolTokenization as the default, but others are possible. - Specified by:
- getTokenizationin interface- Alphabet
- Parameters:
- name- the name of the parser
- Returns:
- a parser for that name
 
 
- 
 
-