Class AbstractReversibleTranslationTable

java.lang.Object
org.biojava.bio.symbol.AbstractReversibleTranslationTable
All Implemented Interfaces:
ReversibleTranslationTable, TranslationTable
Direct Known Subclasses:
SimpleReversibleTranslationTable

an abstract class implementing basic functionality of a translation table that translates Symbols from one Alphabet to another.
Author:
Matthew Pocock, Keith James (docs), Thomas Down, Greg Cox, Mark Schreiber, David Huen (refactoring)
  • Constructor Details

  • Method Details

    • getSourceAlphabet

      public abstract Alphabet getSourceAlphabet()
      Description copied from interface: TranslationTable
      The alphabet of Symbols that can be translated.
      Specified by:
      getSourceAlphabet in interface TranslationTable
      Returns:
      the source Alphabet
    • getTargetAlphabet

      public abstract Alphabet getTargetAlphabet()
      Description copied from interface: TranslationTable
      The alphabet of Symbols that will be produced.
      Specified by:
      getTargetAlphabet in interface TranslationTable
      Returns:
      the target Alphabet
    • doUntranslate

      protected abstract Symbol doUntranslate(Symbol sym) throws IllegalSymbolException
      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

      Description copied from interface: ReversibleTranslationTable
      Translate a single symbol from target alphabet to the source alphabet.
      Specified by:
      untranslate in interface ReversibleTranslationTable
      Parameters:
      sym - the Symbol to translate (member of target alphabet)
      Returns:
      the translated version of sym (member of source alphabet)
      Throws:
      IllegalSymbolException - if sym is not a member of the target alphabet
    • doTranslate

      protected abstract Symbol doTranslate(Symbol sym) throws IllegalSymbolException
      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

      public Symbol translate(Symbol sym) throws IllegalSymbolException
      Description copied from interface: TranslationTable
      Translate a single symbol from source alphabet to the target alphabet.
      Specified by:
      translate in 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