de.jstacs.data.sequences
Class MultiDimensionalSequence<T>

java.lang.Object
  extended by de.jstacs.data.sequences.Sequence<T>
      extended by de.jstacs.data.sequences.MultiDimensionalSequence<T>
Type Parameters:
T - the type of this MultiDimensionalSequence
All Implemented Interfaces:
Comparable<Sequence<T>>
Direct Known Subclasses:
MultiDimensionalArbitrarySequence, MultiDimensionalDiscreteSequence

public abstract class MultiDimensionalSequence<T>
extends Sequence<T>

This class is for multidimensional sequences that can be used, for instance, for phylogenetic footprinting.

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
protected  Sequence[] content
          The internally used sequences.
 
Fields inherited from class de.jstacs.data.sequences.Sequence
alphabetCon, annotation, rc
 
Constructor Summary
MultiDimensionalSequence(SequenceAnnotation[] seqAn, Sequence... sequence)
          This constructor creates an MultiDimensionalSequence from a set of individual Sequences.
 
Method Summary
protected  void addToRepresentation(Object representation, int pos, String delim)
          This method adds the information of one position to the representation using the specified delimiter
 MultiDimensionalSequence<T> complement(int start, int end)
          This method returns a new instance of Sequence containing a part of the complementary current Sequence.
 double continuousVal(int pos)
          Returns the continuous value at position pos of the Sequence.
 int discreteVal(int pos)
          Returns the discrete value at position pos of the Sequence.
protected  MultiDimensionalSequence<T> flatCloneWithoutAnnotation()
          Works in analogy to Object.clone(), but does not clone the annotation.
 SequenceAnnotation[][] getAnnotations()
          This method returns the SequenceAnnotation[] for each dimension of this multidimensional sequence.
protected  Object getEmptyRepresentation()
          Returns an empty representation which is used to create the String representation of this instance in the method Sequence.toString(String, int, int).
protected abstract  MultiDimensionalSequence<T> getInstance(SequenceAnnotation[] seqAn, Sequence... seqs)
           
 int getLength()
          Returns the length of the Sequence.
 int getNumberOfSequences()
          This method returns the number of internal sequences.
 Sequence getSequence(int index)
          This method returns the internal sequence with index index.
protected  String getStringRepresentation(Object representation)
          This method creates a String representation from the given representation.
protected  int hashCodeForPos(int pos)
          This method is used in Sequence.hashCode() and the hash code for one specific position.
 boolean isMultiDimensional()
          The method returns true if the sequence is multidimensional, otherwise .
 MultiDimensionalSequence<T> 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
annotate, compareTo, compareTo, complement, create, create, create, equals, fillContainer, getAlphabetContainer, getAnnotation, getCompositeSequence, getCompositeSequence, getEmptyContainer, 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
 

Field Detail

content

protected Sequence[] content
The internally used sequences.

Constructor Detail

MultiDimensionalSequence

public MultiDimensionalSequence(SequenceAnnotation[] seqAn,
                                Sequence... sequence)
                         throws WrongLengthException,
                                WrongAlphabetException
This constructor creates an MultiDimensionalSequence from a set of individual Sequences.

Parameters:
seqAn - the annotations for the aligned sequences
sequence - the individual sequences that have been aligned
Throws:
WrongLengthException - if the sequences have different lengths
WrongAlphabetException - if the sequences have different AlphabetContainers
Method Detail

continuousVal

public double continuousVal(int pos)
Description copied from class: Sequence
Returns the continuous value at position pos of the Sequence.

Specified by:
continuousVal in class Sequence<T>
Parameters:
pos - the position of the Sequence
Returns:
the continuous value at position pos of the Sequence

discreteVal

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

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

getInstance

protected abstract MultiDimensionalSequence<T> getInstance(SequenceAnnotation[] seqAn,
                                                           Sequence... seqs)
                                                    throws WrongLengthException,
                                                           WrongAlphabetException
Throws:
WrongLengthException
WrongAlphabetException

flatCloneWithoutAnnotation

protected MultiDimensionalSequence<T> 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

getEmptyRepresentation

protected Object getEmptyRepresentation()
Description copied from class: Sequence
Returns an empty representation which is used to create the String representation of this instance in the method Sequence.toString(String, int, int).

Specified by:
getEmptyRepresentation in class Sequence<T>
Returns:
an empty representation which is used to create the String representation
See Also:
Sequence.toString(String, int, int)

addToRepresentation

protected void addToRepresentation(Object representation,
                                   int pos,
                                   String delim)
Description copied from class: Sequence
This method adds the information of one position to the representation using the specified delimiter

Specified by:
addToRepresentation in class Sequence<T>
Parameters:
representation - the representation
pos - the position
delim - the delimiter separating the information for different positions
See Also:
Sequence.getEmptyRepresentation(), Sequence.toString(String, int, int)

getStringRepresentation

protected String getStringRepresentation(Object representation)
Description copied from class: Sequence
This method creates a String representation from the given representation.

Specified by:
getStringRepresentation in class Sequence<T>
Parameters:
representation - the representation instance (which should be created by Sequence.getEmptyContainer() and filled by Sequence.addToRepresentation(Object, int, String))
Returns:
a String representation
See Also:
Sequence.getEmptyRepresentation(), Sequence.addToRepresentation(Object, int, String), Sequence.toString(String, int, int)

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

isMultiDimensional

public boolean isMultiDimensional()
Description copied from class: Sequence
The method returns true if the sequence is multidimensional, otherwise .

Specified by:
isMultiDimensional in class Sequence<T>
Returns:
true if the sequence is multidimensional, otherwise

complement

public MultiDimensionalSequence<T> complement(int start,
                                              int end)
                                       throws OperationNotSupportedException
Description copied from class: Sequence
This method returns a new instance of Sequence containing a part of the complementary current Sequence.
So invoking this method, for instance, on the sequence "TAATA" with an AlphabetContainer on DNAAlphabet returns "ATTAT".

Overrides:
complement 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 complementary Sequence of the part
Throws:
OperationNotSupportedException - if the current Sequence is not based on a ComplementableDiscreteAlphabet
See Also:
ComplementableDiscreteAlphabet

reverseComplement

public MultiDimensionalSequence<T> 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

hashCodeForPos

protected int hashCodeForPos(int pos)
Description copied from class: Sequence
This method is used in Sequence.hashCode() and the hash code for one specific position.

Specified by:
hashCodeForPos in class Sequence<T>
Parameters:
pos - the position
Returns:
the hash code for the position

getAnnotations

public SequenceAnnotation[][] getAnnotations()
This method returns the SequenceAnnotation[] for each dimension of this multidimensional sequence.

Returns:
the SequenceAnnotation array for each dimension of this multidimensional sequence
See Also:
Sequence.getAnnotation()

getNumberOfSequences

public int getNumberOfSequences()
This method returns the number of internal sequences.

Returns:
the number of internal sequences
See Also:
content

getSequence

public Sequence getSequence(int index)
This method returns the internal sequence with index index.

Parameters:
index - the index of the internal sequence
Returns:
the internal sequence with index index