Package org.biojava.bio.symbol
Class AbstractManyToOneTranslationTable
java.lang.Object
org.biojava.bio.symbol.AbstractManyToOneTranslationTable
- All Implemented Interfaces:
ManyToOneTranslationTable
,TranslationTable
- Direct Known Subclasses:
SimpleManyToOneTranslationTable
public abstract class AbstractManyToOneTranslationTable
extends Object
implements ManyToOneTranslationTable
an abstract class implementing basic functionality
of a translation table that translates Symbols from
one Alphabet to another.
The mapping between the alphabets can be either one-to-one or many-to one.
- Author:
- David Huen
-
Field Summary
Fields inherited from interface org.biojava.bio.symbol.TranslationTable
ALT_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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract Symbol
doTranslate
(Symbol sym) this method is expected to translate any symbol in the source alphabet.protected abstract Set
doUntranslate
(Symbol sym) this method is expected to reverse-translate any symbol in the source alphabet.abstract Alphabet
The alphabet of Symbols that can be translated.abstract Alphabet
The alphabet of Symbols that will be produced.Translate a single symbol from source alphabet to the target alphabet.untranslate
(Symbol sym) returns a Set of Atomic Symbols that are the reverse translation of the specified Symbol in the target alphabet.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.biojava.bio.symbol.TranslationTable
translate
-
Constructor Details
-
AbstractManyToOneTranslationTable
public AbstractManyToOneTranslationTable()
-
-
Method Details
-
getSourceAlphabet
Description copied from interface:TranslationTable
The alphabet of Symbols that can be translated.- Specified by:
getSourceAlphabet
in interfaceTranslationTable
- Returns:
- the source Alphabet
-
getTargetAlphabet
Description copied from interface:TranslationTable
The alphabet of Symbols that will be produced.- Specified by:
getTargetAlphabet
in interfaceTranslationTable
- Returns:
- the target Alphabet
-
doUntranslate
this 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.
- Throws:
IllegalSymbolException
-
untranslate
returns a Set of Atomic Symbols that are the reverse translation of the specified Symbol in the target alphabet.- Specified by:
untranslate
in interfaceManyToOneTranslationTable
- Parameters:
sym
- the Symbol to reverse-translate (member of target alphabet)- Returns:
- a Set containing symbols that translate to the specified Symbol.
- Throws:
IllegalSymbolException
- if sym is not a member of the target alphabet
-
doTranslate
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.
- Throws:
IllegalSymbolException
-
translate
Description copied from interface:TranslationTable
Translate a single symbol from source alphabet to the target alphabet.- Specified by:
translate
in interfaceTranslationTable
- 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
-