|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.jstacs.data.Sequence
public abstract class Sequence
This is the main class for all sequences. All sequences are immutable.
Nested Class Summary | |
---|---|
protected static class |
Sequence.CompositeSequence
The class handles composite Sequence s. |
protected static class |
Sequence.SubSequence
This class handles subsequences. |
Field Summary | |
---|---|
protected AlphabetContainer |
alphabetCon
The underlying alphabets. |
protected SequenceAnnotation[] |
annotation
The annotation of the Sequence.CompositeSequence . |
protected Sequence |
rc
The pointer to the reverse complement of the Sequence.CompositeSequence . |
Constructor Summary | |
---|---|
protected |
Sequence(AlphabetContainer container,
SequenceAnnotation[] annotation)
Creates a new Sequence.CompositeSequence with the given AlphabetContainer
and the given annotation, but without the content. |
Method Summary | |
---|---|
Sequence |
annotate(boolean add,
SequenceAnnotation... annotation)
This method allows to append annotation to a Sequence.CompositeSequence . |
int |
compareTo(Sequence s)
|
Sequence |
complement()
This method returns a new instance of Sequence.CompositeSequence containing the
complementary current Sequence.CompositeSequence . |
Sequence |
complement(int start,
int end)
This method returns a new instance of Sequence.CompositeSequence containing a part
of the complementary current Sequence.CompositeSequence . |
abstract double |
continuousVal(int pos)
Returns the continuous value at position pos of the
Sequence.CompositeSequence . |
static Sequence |
create(AlphabetContainer con,
SequenceAnnotation[] annotation,
String sequence,
String delim)
Creates a Sequence.CompositeSequence from a String based on the given
AlphabetContainer using the given delimiter delim
and some annotation for the Sequence.CompositeSequence . |
static Sequence |
create(AlphabetContainer con,
String sequence)
Creates a Sequence.CompositeSequence from a String based on the given
AlphabetContainer using the standard delimiter for this
AlphabetContainer . |
static Sequence |
create(AlphabetContainer con,
String sequence,
String delim)
Creates a Sequence.CompositeSequence from a String based on the given
AlphabetContainer using the given delimiter delim . |
abstract int |
discreteVal(int pos)
Returns the discrete value at position pos of the
Sequence.CompositeSequence . |
boolean |
equals(Object o)
|
protected abstract Sequence |
flatCloneWithoutAnnotation()
Works in analogy to Object.clone() , but does not clone the
annotation. |
AlphabetContainer |
getAlphabetContainer()
Return the alphabets, i.e. the AlphabetContainer , used in this
Sequence.CompositeSequence . |
SequenceAnnotation[] |
getAnnotation()
Returns the annotation of the Sequence.CompositeSequence . |
Sequence |
getCompositeSequence(AlphabetContainer abc,
int[] starts,
int[] lengths)
This method should be used if one wants to create a Sample of
Sequence.CompositeSequence s. |
Sequence |
getCompositeSequence(int[] starts,
int[] lengths)
This is a very efficient way to create a Sequence.CompositeSequence for
sequences with a simple AlphabetContainer . |
int |
getHammingDistance(Sequence seq)
This method returns the Hamming distance between the current Sequence.CompositeSequence and seq . |
abstract int |
getLength()
Returns the length of the Sequence.CompositeSequence . |
int |
getNumberOfSequenceAnnotationsByType(String type)
Returns the number of SequenceAnnotation s of type type for this Sequence.CompositeSequence . |
SequenceAnnotation |
getSequenceAnnotationByType(String type,
int idx)
Returns the SequenceAnnotation no. |
Sequence |
getSubSequence(AlphabetContainer abc,
int start)
This method should be used if one wants to create a Sample of
subsequences of defined length. |
Sequence |
getSubSequence(AlphabetContainer abc,
int start,
int length)
This method should be used if one wants to create a Sample of
subsequences of defined length. |
Sequence |
getSubSequence(int start)
This is a very efficient way to create a subsequence/suffix for Sequence.CompositeSequence s with a simple AlphabetContainer . |
Sequence |
getSubSequence(int start,
int length)
This is a very efficient way to create a subsequence of defined length for Sequence.CompositeSequence s with a simple AlphabetContainer . |
int |
hashCode()
|
Sequence |
reverse()
This method returns a new instance of Sequence.CompositeSequence containing the
reverse current Sequence.CompositeSequence . |
Sequence |
reverse(int start,
int end)
This method returns a new instance of Sequence.CompositeSequence containing a part
of the reverse current Sequence.CompositeSequence . |
Sequence |
reverseComplement()
This method returns a new instance of Sequence.CompositeSequence containing the
reverse complementary current Sequence.CompositeSequence . |
Sequence |
reverseComplement(int start,
int end)
This method returns a new instance of Sequence.CompositeSequence containing a
reverse part of the complementary current Sequence.CompositeSequence . |
protected int |
toDiscrete(int pos,
double content)
This method converts a continuous value at position pos of
the Sequence.CompositeSequence into a discrete one. |
String |
toString()
Returns a String representation of the Sequence.CompositeSequence (normally
the Sequence.CompositeSequence in its original Alphabet ). |
String |
toString(int start)
Returns a String representation of the Sequence.CompositeSequence (normally
the Sequence.CompositeSequence in its original Alphabet ) beginning at
position start with a default delimiter as separator. |
String |
toString(int start,
int end)
Returns a String representation of the Sequence.CompositeSequence (normally
the Sequence.CompositeSequence in its original Alphabet ) between
start and end with a default delimiter as
separator. |
String |
toString(String delim,
int start,
int end)
Returns a String representation of the Sequence.CompositeSequence (normally
the Sequence.CompositeSequence in its original alphabet) between start
and end with delim as separator. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected AlphabetContainer alphabetCon
protected Sequence rc
Sequence.CompositeSequence
.
protected SequenceAnnotation[] annotation
Sequence.CompositeSequence
.
Constructor Detail |
---|
protected Sequence(AlphabetContainer container, SequenceAnnotation[] annotation)
Sequence.CompositeSequence
with the given AlphabetContainer
and the given annotation, but without the content. The content has to be
set by the constructor of the extending class.
container
- the AlphabetContainer
of the Sequence.CompositeSequence
annotation
- the annotation of the Sequence.CompositeSequence
Method Detail |
---|
public abstract double continuousVal(int pos)
pos
of the
Sequence.CompositeSequence
.
pos
- the position of the Sequence.CompositeSequence
pos
of the
Sequence.CompositeSequence
public abstract int discreteVal(int pos)
pos
of the
Sequence.CompositeSequence
.
pos
- the position of the Sequence.CompositeSequence
pos
of the
Sequence.CompositeSequence
public boolean equals(Object o)
equals
in class Object
public final AlphabetContainer getAlphabetContainer()
AlphabetContainer
, used in this
Sequence.CompositeSequence
.
AlphabetContainer
, used in this
Sequence.CompositeSequence
public final SequenceAnnotation[] getAnnotation()
Sequence.CompositeSequence
.
Sequence.CompositeSequence
(can be null
)public SequenceAnnotation getSequenceAnnotationByType(String type, int idx)
SequenceAnnotation
no. idx
of this Sequence.CompositeSequence
that has type type
type
- the chosen type of a subset of SequenceAnnotation
sidx
- the index of the returned SequenceAnnotation
within this subset.
SequenceAnnotation
no. idx
with type type
public int getNumberOfSequenceAnnotationsByType(String type)
SequenceAnnotation
s of type type
for this Sequence.CompositeSequence
.
type
- the type
public Sequence getCompositeSequence(AlphabetContainer abc, int[] starts, int[] lengths)
Sample
of
Sequence.CompositeSequence
s. With this constructor you are enabled to
create a Sample
where every Sequence.CompositeSequence
has the same
AlphabetContainer
instance.
AlphabetContainer
matches with
the one of the Sequence.CompositeSequence
.
abc
- the new AlphabetContainer
starts
- the start positions of the junkslengths
- the length of each junk
Sequence.CompositeSequence
CompositeSequence#CompositeSequence(de.jstacs.data.AlphabetContainer,
de.jstacs.data.Sequence, int[], int[])
public Sequence getCompositeSequence(int[] starts, int[] lengths)
Sequence.CompositeSequence
for
sequences with a simple AlphabetContainer
.
starts
- the start positions of the junkslengths
- the length of each junk
Sequence.CompositeSequence
CompositeSequence#CompositeSequence(de.jstacs.data.Sequence, int[], int[])
public final Sequence getSubSequence(AlphabetContainer abc, int start)
Sample
of
subsequences of defined length. With this constructor you are enabled to
create a Sample
where every Sequence.CompositeSequence
has the same
AlphabetContainer
instance.
AlphabetContainer
matches with
the one of the subsequence.
abc
- the new AlphabetContainer
start
- the index of the start position
getSubSequence(de.jstacs.data.AlphabetContainer, int, int)
public Sequence getSubSequence(AlphabetContainer abc, int start, int length)
Sample
of
subsequences of defined length. With this constructor you are enabled to
create a Sample
where every Sequence.CompositeSequence
has the same
AlphabetContainer
instance.
AlphabetContainer
matches with
the one of the subsequence.
abc
- the new AlphabetContainer
start
- the index of the start positionlength
- the length of the new Sequence.CompositeSequence
SubSequence#SubSequence(de.jstacs.data.AlphabetContainer, de.jstacs.data.Sequence, int, int)
public final Sequence getSubSequence(int start)
Sequence.CompositeSequence
s with a simple AlphabetContainer
.
start
- the index of the start position
getSubSequence(int, int)
public Sequence getSubSequence(int start, int length)
Sequence.CompositeSequence
s with a simple AlphabetContainer
.
start
- the index of the start positionlength
- the length of the new Sequence.CompositeSequence
SubSequence#SubSequence(Sequence, int, int)
public Sequence annotate(boolean add, SequenceAnnotation... annotation)
Sequence.CompositeSequence
.
add
- indicates whether to add the new annotation to the existing or
notannotation
- the new annotation
Sequence.CompositeSequence
Sequence.CompositeSequence.flatCloneWithoutAnnotation()
protected abstract Sequence flatCloneWithoutAnnotation()
Object.clone()
, but does not clone the
annotation. This method is used in
annotate(boolean, SequenceAnnotation...)
.
Sequence.CompositeSequence
without annotationpublic abstract int getLength()
Sequence.CompositeSequence
.
Sequence.CompositeSequence
public String toString()
String
representation of the Sequence.CompositeSequence
(normally
the Sequence.CompositeSequence
in its original Alphabet
).
toString
in class Object
Sequence.CompositeSequence
as String
toString(String, int, int)
public String toString(int start)
String
representation of the Sequence.CompositeSequence
(normally
the Sequence.CompositeSequence
in its original Alphabet
) beginning at
position start
with a default delimiter as separator.
start
- the start index (inclusive)
Sequence.CompositeSequence
as String
toString(String, int, int)
public String toString(int start, int end)
String
representation of the Sequence.CompositeSequence
(normally
the Sequence.CompositeSequence
in its original Alphabet
) between
start
and end
with a default delimiter as
separator.
start
- the start index (inclusive)end
- the end index (exclusive)
Sequence.CompositeSequence
as String
toString(String, int, int)
public int compareTo(Sequence s)
compareTo
in interface Comparable<Sequence>
protected int toDiscrete(int pos, double content)
pos
of
the Sequence.CompositeSequence
into a discrete one.
pos
- the position of the Sequence.CompositeSequence
content
- the value at this position
AlphabetContainer.toDiscrete(int, double)
public String toString(String delim, int start, int end)
String
representation of the Sequence.CompositeSequence
(normally
the Sequence.CompositeSequence
in its original alphabet) between start
and end
with delim
as separator.
delim
- the delimiter/separatorstart
- the start index (inclusive)end
- the end index (exclusive)
Sequence.CompositeSequence
as String
public static Sequence create(AlphabetContainer con, String sequence) throws WrongAlphabetException, IllegalArgumentException
Sequence.CompositeSequence
from a String
based on the given
AlphabetContainer
using the standard delimiter for this
AlphabetContainer
.
con
- the AlphabetContainer
sequence
- the String
containing the Sequence.CompositeSequence
Sequence.CompositeSequence
instance
WrongAlphabetException
- if sequence
is not defined over con
IllegalArgumentException
- if the delimiter is empty and the AlphabetContainer
is not discretecreate(AlphabetContainer, String, String)
public static Sequence create(AlphabetContainer con, String sequence, String delim) throws WrongAlphabetException, IllegalArgumentException
Sequence.CompositeSequence
from a String
based on the given
AlphabetContainer
using the given delimiter delim
.
con
- the AlphabetContainer
sequence
- the String
containing the Sequence.CompositeSequence
delim
- the given delimiter
Sequence.CompositeSequence
instance
WrongAlphabetException
- if sequence
is not defined over con
IllegalArgumentException
- if the delimiter is empty and the AlphabetContainer
is not discretecreate(AlphabetContainer, SequenceAnnotation[], String,
String)
public static Sequence create(AlphabetContainer con, SequenceAnnotation[] annotation, String sequence, String delim) throws WrongAlphabetException, IllegalArgumentException
Sequence.CompositeSequence
from a String
based on the given
AlphabetContainer
using the given delimiter delim
and some annotation
for the Sequence.CompositeSequence
.
con
- the AlphabetContainer
annotation
- the annotation for the Sequence.CompositeSequence
sequence
- the String
containing the Sequence.CompositeSequence
delim
- the given delimiter
Sequence.CompositeSequence
instance
WrongAlphabetException
- if sequence
is not defined over con
IllegalArgumentException
- if the delimiter is empty and the AlphabetContainer
is not discretepublic final Sequence reverse() throws OperationNotSupportedException
Sequence.CompositeSequence
containing the
reverse current Sequence.CompositeSequence
.
Sequence.CompositeSequence
OperationNotSupportedException
- if the current Sequence.CompositeSequence
is based on an
AlphabetContainer
that is not simplereverse(int, int)
public Sequence reverse(int start, int end) throws OperationNotSupportedException
Sequence.CompositeSequence
containing a part
of the reverse current Sequence.CompositeSequence
.
start
- the start position (inclusive) in the original
Sequence.CompositeSequence
end
- the end position (exclusive) in the original Sequence.CompositeSequence
Sequence.CompositeSequence
of the part
OperationNotSupportedException
- if the current Sequence.CompositeSequence
is based on an
AlphabetContainer
that is not simplepublic Sequence complement() throws OperationNotSupportedException
Sequence.CompositeSequence
containing the
complementary current Sequence.CompositeSequence
.
AlphabetContainer
on
DNAAlphabet
returns "ATTAT".
Sequence.CompositeSequence
OperationNotSupportedException
- if the current Sequence.CompositeSequence
is not based on a
ComplementableDiscreteAlphabet
ComplementableDiscreteAlphabet
,
complement(int, int)
public Sequence complement(int start, int end) throws OperationNotSupportedException
Sequence.CompositeSequence
containing a part
of the complementary current Sequence.CompositeSequence
.
AlphabetContainer
on
DNAAlphabet
returns "ATTAT".
start
- the start position (inclusive) in the original
Sequence.CompositeSequence
end
- the end position (exclusive) in the original Sequence.CompositeSequence
Sequence.CompositeSequence
of the part
OperationNotSupportedException
- if the current Sequence.CompositeSequence
is not based on a
ComplementableDiscreteAlphabet
ComplementableDiscreteAlphabet
public Sequence reverseComplement() throws OperationNotSupportedException
Sequence.CompositeSequence
containing the
reverse complementary current Sequence.CompositeSequence
. For more details see the
methods reverse()
and complement()
.
Sequence.CompositeSequence
OperationNotSupportedException
- if the current Sequence.CompositeSequence
is not discrete and simple
(not based on a ComplementableDiscreteAlphabet
)reverse()
,
complement()
,
reverseComplement(int, int)
,
ComplementableDiscreteAlphabet
public Sequence reverseComplement(int start, int end) throws OperationNotSupportedException
Sequence.CompositeSequence
containing a
reverse part of the complementary current Sequence.CompositeSequence
. For more
details see the methods reverse()
and complement()
.
start
- the start position (inclusive) in the original
Sequence.CompositeSequence
end
- the end position (exclusive) in the original Sequence.CompositeSequence
Sequence.CompositeSequence
of the part
OperationNotSupportedException
- if the current Sequence.CompositeSequence
is not discrete and simple
((not based on a ComplementableDiscreteAlphabet
)reverse()
,
complement()
,
ComplementableDiscreteAlphabet
public int hashCode()
hashCode
in class Object
public int getHammingDistance(Sequence seq) throws WrongLengthException, WrongAlphabetException
Sequence.CompositeSequence
and seq
.
seq
- the sequence to be compared
WrongLengthException
- if the sequences have different length
WrongAlphabetException
- it the sequences have different AlphabetContainer
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |