de.jstacs.data
Class Sequence.SubSequence

java.lang.Object
  extended by de.jstacs.data.Sequence
      extended by de.jstacs.data.sequences.RecursiveSequence
          extended by de.jstacs.data.Sequence.SubSequence
All Implemented Interfaces:
Comparable<Sequence>
Enclosing class:
Sequence

protected static class Sequence.SubSequence
extends RecursiveSequence

This class handles subsequences. 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 SubSequences.

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.sequences.RecursiveSequence
content
 
Fields inherited from class de.jstacs.data.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 sample of subsequences of defined length.
Sequence.SubSequence(Sequence seq, int start, int length)
          This is an very efficient way to create a subsequence of defined length for sequences with a simple AlphabetContainer.
 
Method Summary
protected  Sequence flatCloneWithoutAnnotation()
          Works in analogy to Object.clone(), but does not clone the annotation.
protected  int getIndex(int pos)
          Return 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 sequence instance containing a part of the complementary current sequence.
 
Methods inherited from class de.jstacs.data.sequences.RecursiveSequence
continuousVal, discreteVal
 
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, 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 sample of subsequences of defined length. With this constructor you are enabled to create a Sample where every sequence has the same AlphabetContainer-instance.

Internally it is checked that the AlphabetContainer matches with the 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 an very efficient way to create a 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 sequence instance containing a part of the complementary current sequence. For more details see the methods reverse() and complement().

Overrides:
reverseComplement in class Sequence
Parameters:
start - the start position (inclusive) in the original sequence
end - the end position (exclusive) in the original sequence
Returns:
the reverse complementary sequence
Throws:
OperationNotSupportedException - if the current sequence is not discrete and simple
See Also:
Sequence.reverse(), Sequence.complement(), ComplementableDiscreteAlphabet

getIndex

protected int getIndex(int pos)
Description copied from class: RecursiveSequence
Return the index in the internal sequence

Specified by:
getIndex in class RecursiveSequence
Parameters:
pos - the index in the external sequence
Returns:
the index in the internal sequence

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