public final class IntegerAlphabet extends Unchangeable implements Alphabet, Serializable
An efficient implementation of an Alphabet over the infinite set of integer values.
This class can be used to represent lists of integer numbers as a SymbolList with the alphabet IntegerAlphabet. 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 IntegerSymbol objects are the same. IntegerAlphabet ensures that all IntegerSymbol instances are canonicalized.
| Modifier and Type | Class and Description |
|---|---|
static class |
IntegerAlphabet.IntegerSymbol
A single int value.
|
static class |
IntegerAlphabet.SubIntegerAlphabet
A class to represent a finite contiguous subset of the infinite IntegerAlphabet
|
Annotatable.AnnotationForwarder| Modifier and Type | Field and Description |
|---|---|
static IntegerAlphabet |
INSTANCE
The singleton instance of the IntegerAlphabet class.
|
EMPTY_ALPHABET, PARSERS, SYMBOLSANNOTATION| Modifier and Type | Method and Description |
|---|---|
boolean |
contains(Symbol s)
Returns whether or not this Alphabet contains the symbol.
|
static SymbolList |
fromArray(int[] iArray)
Retrieve a SymbolList view of an array of integers.
|
List |
getAlphabets()
Return an ordered List of the alphabets which make up a
compound alphabet.
|
Symbol |
getAmbiguity(Set symSet)
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.
|
static IntegerAlphabet |
getInstance()
Retrieve the single IntegerAlphabet instance.
|
String |
getName()
Get the name of the alphabet.
|
static IntegerAlphabet.SubIntegerAlphabet |
getSubAlphabet(int min,
int max)
Construct a finite contiguous subset of the
IntegerAlphabet. |
IntegerAlphabet.IntegerSymbol |
getSymbol(int val)
Retrieve the Symbol for an int.
|
Symbol |
getSymbol(List symList)
Get a symbol from the Alphabet which corresponds
to the specified ordered list of symbols.
|
SymbolTokenization |
getTokenization(String name)
Creates a new parser (Mark Schreiber 3 May 2001).
|
void |
validate(Symbol s)
Throws a precanned IllegalSymbolException if the symbol is not contained
within this Alphabet.
|
addChangeListener, addChangeListener, addForwarder, getForwarders, getListeners, isUnchanging, removeChangeListener, removeChangeListener, removeForwarderclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddChangeListener, addChangeListener, isUnchanging, removeChangeListener, removeChangeListenerpublic static IntegerAlphabet INSTANCE
public static IntegerAlphabet.SubIntegerAlphabet getSubAlphabet(int min, int max) throws IllegalArgumentException
IntegerAlphabet.
Useful for making CrossProductAlphabets with other FiniteAlphabets.min - the lower bound of the Alphabetmax - the upper bound of the AlphabetIllegalArgumentException - if max < minpublic static SymbolList fromArray(int[] iArray)
The returned object is a view onto the underlying array, and does not copy it. Changes made to the original array will alter the symulting SymbolList.
iArray - the array of integers to viewpublic static IntegerAlphabet getInstance()
public IntegerAlphabet.IntegerSymbol getSymbol(int val)
val - the int to viewpublic Symbol getGapSymbol()
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.
getGapSymbol in interface Alphabetpublic Annotation getAnnotation()
AnnotatablegetAnnotation in interface Annotatablepublic List getAlphabets()
AlphabetgetAlphabets in interface Alphabetpublic Symbol getSymbol(List symList) throws IllegalSymbolException
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.
getSymbol in interface AlphabetsymList - A list of Symbol instancesIllegalSymbolException - if the members of rl are
not Symbols over the alphabets returned from
getAlphabetspublic Symbol getAmbiguity(Set symSet) throws IllegalSymbolException
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.
getAmbiguity in interface AlphabetsymSet - the Set of Symbols that will be found in getMatches of the
returned symbolIllegalSymbolExceptionpublic boolean contains(Symbol s)
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.
public void validate(Symbol s) throws IllegalSymbolException
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.
validate in interface Alphabets - the Symbol to validateIllegalSymbolException - if r is not contained in this alphabetpublic String getName()
Alphabetpublic SymbolTokenization getTokenization(String name)
getTokenization in interface Alphabetname - Currently only "token" is supported. You may also
use "default" as a synonym of "token"Copyright © 2020 BioJava. All rights reserved.