S - corresponding type of sequencepublic abstract class Alphabet<S extends Sequence<S>> extends Object implements Serializable
Alphabet is responsible for
conversion between char representation of letters (e.g. 'A', 'T', 'G', 'C' in case of
NucleotideAlphabet) and their internal byte representation.
Alphabet also responsible for storing information about symbols wildcards.
All alphabets letters grouped in two sets: pure letters and wildcards. Pure letters has codes less
than basicSize(), wildcards has codes greater or equals to basicSize().
Implementation note: all alphabets should be singletons.
Sequence,
SequenceBuilder,
NucleotideAlphabet,
NucleotideSequence,
Serialized Form| Modifier and Type | Class and Description |
|---|---|
protected static class |
Alphabet.AlphabetSerialization |
| Modifier and Type | Method and Description |
|---|---|
int |
basicSize()
Gets number of letters in this alphabet without wildcard letters
|
char |
codeToSymbol(byte code)
Gets a char symbol for an alphabet code of the letter
|
Wildcard |
codeToWildcard(byte code)
Returns wildcard defined by specified code (letter).
|
abstract SequenceBuilder<S> |
createBuilder()
Returns a sequence builder for corresponding sequence type.
|
boolean |
equals(Object obj)
Checks that in is the same object (this points to the same address as
obj)
All Alphabet implementations must be singletons. |
List<Wildcard> |
getAllWildcards()
Returns a collection of all wildcards defined for this.
|
String |
getAlphabetName()
Returns the human readable name of this alphabet.
|
S |
getEmptySequence()
Returns empty sequence singleton
|
byte |
getId()
Returns byte id of this alphabet
|
Wildcard |
getWildcardForAnyLetter()
Returns wildcard for any letter (e.g.
|
int |
hashCode()
Returns "address in memory" (hash code as specified by
Object.hashCode(). |
boolean |
isWildcard(byte code)
Returns true if this code represents wildcard symbol
|
Wildcard |
maskToWildcard(long basicMask)
Converts wildcard basicMask to Wildcard object.
|
S |
parse(String string)
Parses string representation of sequence.
|
int |
size()
Gets number of letters in this alphabet including wildcard letters
|
byte |
symbolToCode(char symbol)
Gets the binary code representing given symbol (case insensitive) or -1 if there
is no such symbol in this alphabet
|
byte |
symbolToCodeWithException(char symbol)
Gets the binary code corresponding to given symbol (case insensitive) or throws
IllegalArgumentException
if there is no such symbol in this alphabet |
Wildcard |
symbolToWildcard(char symbol)
Returns a wildcard object for specified letter.
|
String |
toString()
Convert alphabet to a readable string.
|
protected Object |
writeReplace() |
public final int size()
public final int basicSize()
public final boolean isWildcard(byte code)
code - code of letterpublic final Wildcard codeToWildcard(byte code)
code - codepublic final Wildcard symbolToWildcard(char symbol)
symbol - symbolpublic final List<Wildcard> getAllWildcards()
public final Wildcard getWildcardForAnyLetter()
public Wildcard maskToWildcard(long basicMask)
basicMask - bit represenatation of wildcardpublic final char codeToSymbol(byte code)
code - alphabet code of segmentpublic byte symbolToCode(char symbol)
symbol - symbol to convertpublic final byte symbolToCodeWithException(char symbol)
IllegalArgumentException
if there is no such symbol in this alphabetsymbol - symbol to convertIllegalArgumentException - if there is no such symbol in the alphabetpublic abstract SequenceBuilder<S> createBuilder()
public S getEmptySequence()
public final String getAlphabetName()
This name can be then used to obtain the instance of this alphabet using Alphabets.getByName(String) method if it is registered (see Alphabets.register(Alphabet)).
public final byte getId()
This name can be then used to obtain the instance of this alphabet using Alphabets.getById(byte) method if it is registered (see Alphabets.register(Alphabet)).
public final S parse(String string)
string - string representation of sequencepublic final String toString()
public final int hashCode()
Object.hashCode(). All Alphabet implementations
must be singletons.public final boolean equals(Object obj)
obj)
All Alphabet implementations must be singletons.protected Object writeReplace() throws ObjectStreamException
ObjectStreamExceptionCopyright © 2018. All rights reserved.