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.
Modifier and Type | Method and Description |
---|---|
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.
|
FiniteAlphabet getAlphabet()
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).
sym
- the Symbol to packIllegalSymbolException
- if sym is not in getAlphabet().Symbol unpack(byte packed) throws IllegalSymbolException
Return the symbol for a packing.
packed
- the byte pattern for a SymbolIllegalSymbolException
- if the packing doesn't represent a valid
Symbolbyte wordSize()
The number of bits required to pack a symbol.
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.
Copyright © 2014 BioJava. All rights reserved.