de.jstacs.data.sequences
Class Sequence.SubSequence<T>

java.lang.Object
  extended by de.jstacs.data.sequences.Sequence<T>
      extended by de.jstacs.data.sequences.Sequence.RecursiveSequence<T>
          extended by de.jstacs.data.sequences.Sequence.SubSequence<T>
Type Parameters:
T - the type of each position
All Implemented Interfaces:
Comparable<Sequence<T>>
Enclosing class:
Sequence<T>

protected static class Sequence.SubSequence<T>
extends Sequence.RecursiveSequence<T>

This class handles subsequences. Sequence.SubSequences are often used to extract the Sequence of a sliding window on a long Sequence. The class is implemented in such a way that it avoids chains of Sequence.SubSequences.

Author:
Jens Keilwagen

Nested Class Summary
 
Nested classes/interfaces inherited from class de.jstacs.data.sequences.Sequence
Sequence.CompositeSequence<T>, Sequence.RecursiveSequence<T>, Sequence.SubSequence<T>
 
Field Summary
 
Fields inherited from class de.jstacs.data.sequences.Sequence.RecursiveSequence
content
 
Fields inherited from class de.jstacs.data.sequences.Sequence
alphabetCon, annotation, rc
 
Constructor Summary
Sequence.SubSequence(AlphabetContainer abc, Sequence seq, int start, int length)
          This constructor should be used if one wants to create a DataSet of Sequence.SubSequences of defined length.
Sequence.SubSequence(Sequence seq, int start, int length)
          This is a very efficient way to create a Sequence.SubSequence of defined length for Sequences with a simple AlphabetContainer.
 
Method Summary
 int discreteVal(int pos)
          Returns the discrete value at position pos of the Sequence.
protected  Sequence flatCloneWithoutAnnotation()
          Works in analogy to Object.clone(), but does not clone the annotation.
protected  int getIndex(int pos)
          Returns the index in the internal sequence.
 int getLength()
          Returns the length of the Sequence.
 Sequence reverseComplement(int start, int end)
          This method returns a new instance of Sequence containing a reverse part of the complementary current Sequence.
 
Methods inherited from class de.jstacs.data.sequences.Sequence.RecursiveSequence
addToRepresentation, compareTo, continuousVal, fillContainer, getEmptyContainer, getEmptyRepresentation, getStringRepresentation, hashCodeForPos, isMultiDimensional
 
Methods inherited from class de.jstacs.data.sequences.Sequence
annotate, compareTo, complement, complement, create, create, create, equals, getAlphabetContainer, getAnnotation, getCompositeSequence, getCompositeSequence, getHammingDistance, getNumberOfSequenceAnnotationsByType, getSequenceAnnotationByType, getSequenceAnnotationByTypeAndIdentifier, getSubSequence, getSubSequence, getSubSequence, getSubSequence, hashCode, matches, reverse, reverse, reverseComplement, toDiscrete, toString, toString, toString, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Sequence.SubSequence

public Sequence.SubSequence(AlphabetContainer abc,
                            Sequence seq,
                            int start,
                            int length)
This constructor should be used if one wants to create a DataSet of Sequence.SubSequences of defined length. With this constructor you are enabled to create a DataSet where every Sequence has the same AlphabetContainer instance.

Internally it is checked that the AlphabetContainer matches with the one of the Sequence.SubSequence.

Parameters:
abc - the new AlphabetContainer
seq - the original Sequence
start - the index of the start position
length - the length of the new sequence

Sequence.SubSequence

public Sequence.SubSequence(Sequence seq,
                            int start,
                            int length)
This is a very efficient way to create a Sequence.SubSequence of defined length for Sequences with a simple AlphabetContainer.

Parameters:
seq - the original Sequence
start - the index of the start position
length - the length of the new Sequence
Method Detail

reverseComplement

public Sequence reverseComplement(int start,
                                  int end)
                           throws OperationNotSupportedException
Description copied from class: Sequence
This method returns a new instance of Sequence containing a reverse part of the complementary current Sequence. For more details see the methods Sequence.reverse() and Sequence.complement().

Overrides:
reverseComplement in class Sequence<T>
Parameters:
start - the start position (inclusive) in the original Sequence
end - the end position (exclusive) in the original Sequence
Returns:
the reverse complementary Sequence of the part
Throws:
OperationNotSupportedException - if the current Sequence is not discrete and simple ((not based on a ComplementableDiscreteAlphabet)
See Also:
Sequence.reverse(), Sequence.complement(), ComplementableDiscreteAlphabet

getIndex

protected final int getIndex(int pos)
Description copied from class: Sequence.RecursiveSequence
Returns the index in the internal sequence.

Specified by:
getIndex in class Sequence.RecursiveSequence<T>
Parameters:
pos - the index in the external sequence
Returns:
the index in the internal sequence

discreteVal

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

Overrides:
discreteVal in class Sequence.RecursiveSequence<T>
Parameters:
pos - the position of the Sequence
Returns:
the discrete value at position pos of the Sequence

getLength

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

Specified by:
getLength in class Sequence<T>
Returns:
the length of the Sequence

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<T>
Returns:
the cloned Sequence without annotation