de.jstacs.data.sequences
Class MultiDimensionalDiscreteSequence

java.lang.Object
  extended by de.jstacs.data.Sequence<int[]>
      extended by de.jstacs.data.sequences.DiscreteSequence
          extended by de.jstacs.data.sequences.MultiDimensionalDiscreteSequence
All Implemented Interfaces:
Comparable<Sequence<int[]>>

public class MultiDimensionalDiscreteSequence
extends DiscreteSequence

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.Sequence
Sequence.CompositeSequence<T>, Sequence.RecursiveSequence<T>, Sequence.SubSequence<T>
 
Field Summary
 
Fields inherited from class de.jstacs.data.Sequence
alphabetCon, annotation, rc
 
Constructor Summary
MultiDimensionalDiscreteSequence(SequenceAnnotation[] seqAnnotations, SimpleDiscreteSequence... sequence)
          This constructor creates an MultiDimensionalDiscreteSequence from a set of individual SimpleDiscreteSequences.
 
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
 MultiDimensionalDiscreteSequence 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.
 void fillContainer(int[] container, int pos)
          The method fills the content of a specific position in to the container.
protected  Sequence<int[]> 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.
 int[] getEmptyContainer()
          The method returns a container that can be used for accessing the symbols for each position.
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).
 int getLength()
          Returns the length of the Sequence.
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 .
 MultiDimensionalDiscreteSequence 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.DiscreteSequence
compareTo
 
Methods inherited from class de.jstacs.data.Sequence
annotate, compareTo, 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

MultiDimensionalDiscreteSequence

public MultiDimensionalDiscreteSequence(SequenceAnnotation[] seqAnnotations,
                                        SimpleDiscreteSequence... sequence)
                                 throws WrongLengthException
This constructor creates an MultiDimensionalDiscreteSequence from a set of individual SimpleDiscreteSequences.

Parameters:
seqAnnotations - the annotations for the aligned sequences
sequence - the individual sequences that have been aligned
Throws:
WrongLengthException - if the sequence have different length
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<int[]>
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<int[]>
Parameters:
pos - the position of the Sequence
Returns:
the discrete value at position pos of the Sequence

fillContainer

public void fillContainer(int[] container,
                          int pos)
Description copied from class: Sequence
The method fills the content of a specific position in to the container. This is especially of interest for multidimensional sequences.

Specified by:
fillContainer in class Sequence<int[]>
Parameters:
container - the container which is used for filling the content.
pos - the position
See Also:
Sequence.getEmptyContainer(), Sequence.isMultiDimensional()

getEmptyContainer

public int[] getEmptyContainer()
Description copied from class: Sequence
The method returns a container that can be used for accessing the symbols for each position. This is especially of interest for multidimensional sequences.

Specified by:
getEmptyContainer in class Sequence<int[]>
Returns:
a container that can be used for accessing the symbols for each position
See Also:
Sequence.fillContainer(Object, int), Sequence.isMultiDimensional()

getLength

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

Specified by:
getLength in class Sequence<int[]>
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<int[]>
Returns:
true if the sequence is multidimensional, otherwise

flatCloneWithoutAnnotation

protected Sequence<int[]> 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<int[]>
Returns:
the cloned Sequence without annotation

complement

public MultiDimensionalDiscreteSequence 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<int[]>
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 MultiDimensionalDiscreteSequence 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<int[]>
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

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<int[]>
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<int[]>
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<int[]>
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)

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<int[]>
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()