SimpleTranslationTable (BioJava-1.5-beta API)
Keywords: org.biojava.bio.symbol.SimpleTranslationTable class

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.biojava.bio.symbol
Class SimpleTranslationTable

    java.lang.Object
      org.biojava.bio.symbol.SimpleTranslationTable

All Implemented Interfaces:
  Serializable, TranslationTable

    public class SimpleTranslationTable

extends Object
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.TranslationTable
`ALT_YEAST_NUC, ASCID_MITO, BLEPH_MNUC, CILIATE_NUC, ECHIN_MITO, EUPL_NUC, FWORM_MITO, INVERT_MITO, MOLD_MITO, UNIVERSAL, VERT_MITO, YEAST_MITO`

Constructor Summary
`SimpleTranslationTable(FiniteAlphabet source, Alphabet target)` Create a new translation table that will translate symbols from source to target.
`SimpleTranslationTable(FiniteAlphabet source, Alphabet target, Map transMap)` Create a new translation table that will translate symbols from source to target.

Method Summary
`Symbol` | `doTranslate(Symbol sym)` this method is expected to translate any symbol in the source alphabet.
`Alphabet` | `getSourceAlphabet()` The alphabet of Symbols that can be translated.
`Alphabet` | `getTargetAlphabet()` The alphabet of Symbols that will be produced.
`void` | `setTranslation(AtomicSymbol from, AtomicSymbol to)` Alter the translation mapping.
`Symbol` | `translate(Symbol sym)` Translate a single symbol from source alphabet to the target alphabet.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### SimpleTranslationTable

    public SimpleTranslationTable(FiniteAlphabet source,
                                  Alphabet target)

  Create a new translation table that will translate symbols from source to target.

  The source alphabet must be finite, as a Map object is used to associate a source Symbol with a target Symbol. The target alphabet need not be finite.

  Parameters:
    `source` - the FiniteAlphabet to translate from
    `target` - the Alphabet to translate into

### SimpleTranslationTable

    public SimpleTranslationTable(FiniteAlphabet source,
                                  Alphabet target,
                                  Map transMap)

  Create a new translation table that will translate symbols from source to target.

  The Map transMap should contain keys in the source alphabet with values in the target alphabet. However, this is not currently checked.

  The source alphabet must be finite, as a Map object is used to associate a source Symbol with a target Symbol. The target alphabet need not be finite.

  Parameters:
    `source` - the FiniteAlphabet to translate from
    `target` - the Alphabet to translate into

Method Detail

### getSourceAlphabet

    public 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 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

### doTranslate

    public 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.

### setTranslation

    public 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

### 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

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD