Package org.biojava.bio.symbol
Class SimpleReversibleTranslationTable
- java.lang.Object
- 
- org.biojava.bio.symbol.AbstractReversibleTranslationTable
- 
- org.biojava.bio.symbol.SimpleReversibleTranslationTable
 
 
- 
- All Implemented Interfaces:
- Serializable,- ReversibleTranslationTable,- TranslationTable
 
 public class SimpleReversibleTranslationTable extends AbstractReversibleTranslationTable implements Serializable A no-frills implementation of TranslationTable that uses a Map to map from symbols in a finite source alphabet into a target alphabet.- Author:
- Matthew Pocock, David Huen (refactoring)
- See Also:
- Serialized Form
 
- 
- 
Field Summary- 
Fields inherited from interface org.biojava.bio.symbol.TranslationTableALT_YEAST_NUC, ASCID_MITO, BACTERIAL, BLEPH_MNUC, CHLORO_MITO, CILIATE_NUC, ECHIN_MITO, EUPL_NUC, FWORM_MITO, INVERT_MITO, MOLD_MITO, SCENE_MITO, TREMA_MITO, UNIVERSAL, VERT_MITO, YEAST_MITO
 
- 
 - 
Constructor SummaryConstructors Constructor Description SimpleReversibleTranslationTable(FiniteAlphabet source, FiniteAlphabet target)Construct a new translation table.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description protected SymboldoTranslate(Symbol sym)this method is expected to translate any symbol in the source alphabet.protected SymboldoUntranslate(Symbol sym)this method is expected to reverse-translate any symbol in the source alphabet.AlphabetgetSourceAlphabet()The alphabet of Symbols that can be translated.AlphabetgetTargetAlphabet()The alphabet of Symbols that will be produced.voidsetTranslation(AtomicSymbol from, AtomicSymbol to)Alter the translation mapping.Symboltranslate(Symbol sym)Translate a single symbol from source alphabet to the target alphabet.- 
Methods inherited from class org.biojava.bio.symbol.AbstractReversibleTranslationTableuntranslate
 - 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface org.biojava.bio.symbol.TranslationTabletranslate
 
- 
 
- 
- 
- 
Constructor Detail- 
SimpleReversibleTranslationTablepublic SimpleReversibleTranslationTable(FiniteAlphabet source, FiniteAlphabet target) throws IllegalAlphabetException Construct a new translation table.- Parameters:
- source- the source FiniteAlphabet
- target- the target FiniteAlphabet
- Throws:
- IllegalAlphabetException- if the alphabets are of different sizes
 
 
- 
 - 
Method Detail- 
getSourceAlphabetpublic Alphabet getSourceAlphabet() Description copied from interface:TranslationTableThe alphabet of Symbols that can be translated.- Specified by:
- getSourceAlphabetin interface- TranslationTable
- Specified by:
- getSourceAlphabetin class- AbstractReversibleTranslationTable
- Returns:
- the source Alphabet
 
 - 
getTargetAlphabetpublic Alphabet getTargetAlphabet() Description copied from interface:TranslationTableThe alphabet of Symbols that will be produced.- Specified by:
- getTargetAlphabetin interface- TranslationTable
- Specified by:
- getTargetAlphabetin class- AbstractReversibleTranslationTable
- Returns:
- the target Alphabet
 
 - 
doTranslateprotected Symbol doTranslate(Symbol sym) this method is expected to translate any symbol in the source alphabet. Failure can be indicated by returning a null if, for example, your method only handles AtomicSymbols and you want BasisSymbols to be taken apart. If you are sure the symbol is illegal, you can throw the IllegalSymbolException immediately to bypass further processing.As an optimisation, if your method is capable of immediately translating an ambiguity Symbol, just return it and the alternate route of establishing the translation through doing an ambiguity lookup will be avoided. 
 - 
doUntranslateprotected Symbol doUntranslate(Symbol sym) Description copied from class:AbstractReversibleTranslationTablethis method is expected to reverse-translate any symbol in the source alphabet. Failure can be indicated by returning a null if, for example, your method only handles AtomicSymbols and you want BasisSymbols to be taken apart. If you are sure the symbol is illegal, you can throw the IllegalSymbolException immediately to bypass further processing.As an optimisation, if your method is capable of immediately translating an ambiguity Symbol, just return it and the alternate route of establishing the translation through doing an ambiguity lookup will be avoided. - Specified by:
- doUntranslatein class- AbstractReversibleTranslationTable
 
 - 
setTranslationpublic void setTranslation(AtomicSymbol from, AtomicSymbol to) throws IllegalSymbolException Alter the translation mapping.- Parameters:
- from- source AtomicSymbol
- to- target AtomicSymbol to be returned by translate(from)
- Throws:
- IllegalSymbolException- if either from is not in the source alphabet or to is not in the target alphabet
 
 - 
translatepublic Symbol translate(Symbol sym) throws IllegalSymbolException Description copied from interface:TranslationTableTranslate a single symbol from source alphabet to the target alphabet.- Specified by:
- translatein interface- TranslationTable
- Parameters:
- sym- the Symbol to translate (member of source alphabet)
- Returns:
- the translated version of sym (member of target alphabet)
- Throws:
- IllegalSymbolException- if sym is not a member of the source alphabet
 
 
- 
 
-