Packing (BioJava-1.5-beta API)
Keywords: org.biojava.bio.symbol.Packing interface

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
Interface Packing

All Known Implementing Classes:
  DNAAmbPack, DNANoAmbPack

    public interface Packing

An encapsulation of the way symbols map to bit-patterns.

A packing will encapsulate the process of converting between symbols and bit-patterns. For example, in DNA you could use 00, 01, 10 and 11 to represent the four bases (a, g, c, t). Many applications may require a specific packing. You may need to store full ambiguity information, or perhaps you can discard this capability to reduce stoorage space. You may care about the bit-pattern produced because you need interoperability or an algorithm needs to be fed correctly, or you may not care about the packing at all. This interface is here to allow you to chose the most appropreate packing for your task.

Author:
  Matthew Pocock

Method Summary
`FiniteAlphabet` | `getAlphabet()` The FiniteAlphabet this packing is for.
`boolean` | `handlesAmbiguity()` Flag to state if ambiguities are stored.
`byte` | `pack(Symbol sym)` Return a byte representing the packing of a symbol.
`Symbol` | `unpack(byte packed)` Return the symbol for a packing.
`byte` | `wordSize()` The number of bits required to pack a symbol.

Method Detail

### getAlphabet

    FiniteAlphabet getAlphabet()

  The FiniteAlphabet this packing is for.

  Returns:
    the FiniteAlphabet that we can pack

### pack

    byte pack(Symbol sym)
              throws IllegalSymbolException

  Return a byte representing the packing of a symbol. The bits will be from 1 >> 0 through to 1 >> (wordSize - 1).

  Parameters:
    `sym` - the Symbol to pack
  Returns:
    a byte containing the packed symbol
  Throws:
    `IllegalSymbolException` - if sym is not in getAlphabet().

### unpack

    Symbol unpack(byte packed)
                  throws IllegalSymbolException

  Return the symbol for a packing.

  Parameters:
    `packed` - the byte pattern for a Symbol
  Returns:
    the Symbol that was packed
  Throws:
    `IllegalSymbolException` - if the packing doesn't represent a valid Symbol

### wordSize

    byte wordSize()

  The number of bits required to pack a symbol.

  Returns:
    the word size as a byte

### handlesAmbiguity

    boolean handlesAmbiguity()

  Flag to state if ambiguities are stored.

  Packings are free to either store ambiguity information or to discard it (presumably converting all ambiguities to a standard AtomicSymbol and then packing that). You can check wether ambiguities are handled by calling this method.

  Returns:
    true if ambiguities are stored, false otherwise

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