Package org.biojava.bio.seq.io
Class AlternateTokenization
- java.lang.Object
-
- org.biojava.utils.Unchangeable
-
- org.biojava.bio.seq.io.AlternateTokenization
-
- All Implemented Interfaces:
Serializable,Annotatable,SymbolTokenization,Changeable
public class AlternateTokenization extends Unchangeable implements SymbolTokenization, Serializable
Implementation of SymbolTokenization which binds symbols to strings of characters. These tokenizations are intented to provide alternate way of writing sequences into Strings. Therefore they cannot be used for parsing files.
As this release, alternate tokenizations are available for the built-in DNA alphabet (write symbols as capital letter) and PROTEIN-TERM alphabet (write symbol as triplets of characters with the first one being a capital letter as in "Glu".
By convention, instances of AlternateTokenization should have an associated token starting by the word 'alternate'.
- Since:
- 1.5
- Author:
- George Waldon
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.biojava.bio.Annotatable
Annotatable.AnnotationForwarder
-
Nested classes/interfaces inherited from interface org.biojava.bio.seq.io.SymbolTokenization
SymbolTokenization.TokenType
-
-
Field Summary
-
Fields inherited from interface org.biojava.bio.Annotatable
ANNOTATION
-
Fields inherited from interface org.biojava.bio.seq.io.SymbolTokenization
CHARACTER, FIXEDWIDTH, SEPARATED, UNKNOWN
-
-
Constructor Summary
Constructors Constructor Description AlternateTokenization(Alphabet alpha, boolean caseSensitive)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbindSymbol(Symbol s, String str)Bind a Symbol to a string.AlphabetgetAlphabet()The alphabet to which this tokenization applies.AnnotationgetAnnotation()Should return the associated annotation object.SymbolTokenization.TokenTypegetTokenType()Tokens have fixed size.intgetWidth()Get the width of the tokens.StreamParserparseStream(SeqIOListener listener)Will throw an exception.SymbolparseToken(String token)Will throw an exception.StringtokenizeSymbol(Symbol s)Return a token representing a single symbol.StringtokenizeSymbolList(SymbolList sl)Return a string representation of a list of symbols.-
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
-
-
-
-
Constructor Detail
-
AlternateTokenization
public AlternateTokenization(Alphabet alpha, boolean caseSensitive)
-
-
Method Detail
-
getAlphabet
public Alphabet getAlphabet()
Description copied from interface:SymbolTokenizationThe alphabet to which this tokenization applies.- Specified by:
getAlphabetin interfaceSymbolTokenization
-
getTokenType
public SymbolTokenization.TokenType getTokenType()
Tokens have fixed size.- Specified by:
getTokenTypein interfaceSymbolTokenization
-
getAnnotation
public Annotation getAnnotation()
Description copied from interface:AnnotatableShould return the associated annotation object.- Specified by:
getAnnotationin interfaceAnnotatable- Returns:
- an Annotation object, never null
-
getWidth
public int getWidth()
Get the width of the tokens.
-
bindSymbol
public void bindSymbol(Symbol s, String str)
Bind a Symbol to a string.- Parameters:
s- the Symbol to bindstr- the string to bind it to
-
parseToken
public Symbol parseToken(String token) throws IllegalSymbolException
Will throw an exception.- Specified by:
parseTokenin interfaceSymbolTokenization- Parameters:
token- the token to retrieve a Symbol for- Returns:
- the Symbol for that token
- Throws:
IllegalSymbolException- if there is no Symbol for the token
-
tokenizeSymbol
public String tokenizeSymbol(Symbol s) throws IllegalSymbolException
Description copied from interface:SymbolTokenizationReturn a token representing a single symbol.- Specified by:
tokenizeSymbolin interfaceSymbolTokenization- Parameters:
s- The symbol- Throws:
IllegalSymbolException- if the symbol isn't recognized.
-
tokenizeSymbolList
public String tokenizeSymbolList(SymbolList sl) throws IllegalAlphabetException
Description copied from interface:SymbolTokenizationReturn a string representation of a list of symbols.- Specified by:
tokenizeSymbolListin interfaceSymbolTokenization- Parameters:
sl- A SymbolList- Throws:
IllegalAlphabetException- if alphabets don't match
-
parseStream
public StreamParser parseStream(SeqIOListener listener)
Will throw an exception.- Specified by:
parseStreamin interfaceSymbolTokenization- Parameters:
listener- The listener which gets notified of parsed symbols.
-
-