de.jstacs.data.sequences
Class ByteSequence

java.lang.Object
  extended by de.jstacs.data.Sequence
      extended by de.jstacs.data.sequences.DiscreteSequence
          extended by de.jstacs.data.sequences.ByteSequence
All Implemented Interfaces:
Comparable<Sequence>

public class ByteSequence
extends DiscreteSequence

This class can be used for discrete AlphabetContainer with alphabets that use only few symbols.

Author:
Jens Keilwagen

Nested Class Summary
 
Nested classes/interfaces inherited from class de.jstacs.data.Sequence
Sequence.CompositeSequence, Sequence.SubSequence
 
Field Summary
 
Fields inherited from class de.jstacs.data.Sequence
alphabetCon, annotation, rc
 
Constructor Summary
ByteSequence(AlphabetContainer alphabetContainer, byte[] content)
          This constructor is designed for the emitSample( int n ) of AbstractModel.
ByteSequence(AlphabetContainer alphabetContainer, SequenceAnnotation[] annotation, String sequence, String delim)
          Creates a new sequence from a string representation using the delimiter delim.
ByteSequence(AlphabetContainer alphabetContainer, SequenceAnnotation[] annotation, SymbolExtractor extractor)
          Creates a new sequence from a SymbolExctractor.
ByteSequence(AlphabetContainer alphabetContainer, String sequence)
          Creates a new sequence from a string representation using the default delimiter.
 
Method Summary
 int discreteVal(int pos)
          Returns the discrete value of position pos.
protected  Sequence flatCloneWithoutAnnotation()
          Works in analogy to Object.clone(), but does not clone the annotation.
 int getLength()
          Returns the length of the sequence
 
Methods inherited from class de.jstacs.data.sequences.DiscreteSequence
continuousVal
 
Methods inherited from class de.jstacs.data.Sequence
annotate, compareTo, complement, complement, create, create, create, equals, getAlphabetContainer, getAnnotation, getCompositeSequence, getCompositeSequence, getSubSequence, getSubSequence, getSubSequence, getSubSequence, hashCode, reverse, reverse, reverseComplement, reverseComplement, toDiscrete, toString, toString, toString, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ByteSequence

public ByteSequence(AlphabetContainer alphabetContainer,
                    byte[] content)
             throws WrongAlphabetException,
                    WrongSequenceTypeException
This constructor is designed for the emitSample( int n ) of AbstractModel.

Parameters:
alphabetContainer - the alphabet container for the sequence
content - an array containing the encoded symbols
Throws:
WrongAlphabetException - if the sequence is not defined over alphabetContainer
WrongSequenceTypeException - if the alphabetContainer contains alphabets that can not be encoded with bytes.
See Also:
AbstractModel.emitSample(int, int[])

ByteSequence

public ByteSequence(AlphabetContainer alphabetContainer,
                    String sequence)
             throws WrongAlphabetException,
                    WrongSequenceTypeException
Creates a new sequence from a string representation using the default delimiter.

Parameters:
alphabetContainer - the alphabet container for the sequence
sequence - a string representation of the sequence
Throws:
WrongAlphabetException - if the sequence is not defined over alphabetContainer
WrongSequenceTypeException - if the alphabetContainer contains alphabets that can not be encoded with bytes.

ByteSequence

public ByteSequence(AlphabetContainer alphabetContainer,
                    SequenceAnnotation[] annotation,
                    String sequence,
                    String delim)
             throws WrongAlphabetException,
                    WrongSequenceTypeException
Creates a new sequence from a string representation using the delimiter delim.

Parameters:
alphabetContainer - the alphabet container for the sequence
annotation - the annotation for this sequence
sequence - a string representation of the sequence
delim - the delimiter, a string that separates the symbols
Throws:
WrongAlphabetException - if the sequence is not defined over alphabetContainer
WrongSequenceTypeException - if the alphabetContainer contains alphabets that can not be encoded with bytes.

ByteSequence

public ByteSequence(AlphabetContainer alphabetContainer,
                    SequenceAnnotation[] annotation,
                    SymbolExtractor extractor)
             throws WrongAlphabetException,
                    WrongSequenceTypeException
Creates a new sequence from a SymbolExctractor.

Parameters:
alphabetContainer - the alphabet container for the sequence
annotation - the annotation for this sequence
extractor - the SymbolExtractor
Throws:
WrongAlphabetException - if the sequence is not defined over alphabetContainer
WrongSequenceTypeException - if the alphabetContainer contains alphabets that can not be encoded with bytes.
Method Detail

discreteVal

public int discreteVal(int pos)
Description copied from class: Sequence
Returns the discrete value of position pos.

Specified by:
discreteVal in class Sequence
Parameters:
pos - the position
Returns:
the discrete value of position pos

getLength

public int getLength()
Description copied from class: Sequence
Returns the length of the sequence

Specified by:
getLength in class Sequence
Returns:
the length

flatCloneWithoutAnnotation

protected Sequence flatCloneWithoutAnnotation()
Description copied from class: Sequence
Works in analogy to Object.clone(), but does not clone the annotation. This method is used in Sequence.annotate(boolean, SequenceAnnotation...).

Specified by:
flatCloneWithoutAnnotation in class Sequence
Returns:
the cloned Sequence.CompositeSequence without annotation