|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectde.unibi.techfak.jpredictor.motifs.MotifSearchAdapter
de.unibi.techfak.jpredictor.motifs.Motif
de.unibi.techfak.jpredictor.motifs.MultiMotif
public class MultiMotif
Superclass of all classes representing a pattern made of more then one motif. For the task of defining motif patterns, there are two 'add'-methods:
add( Motif motif, int minDistance, int maxDistance )
add( Motif motif )
A DoubleMotif is declared like this:
MultiMotif d = new MultiMotif;
d.add( firstMotif, 0, 1000 );
d.add( secondMotif );
If 'secondMotif' can be found within a radius of 1000 bases of
'firstMotif', this MultiMotif was found in the sequence. A MultiMotif
is completed by giving the final motif without the distances.
When performing searches the MultiMotif has to be initialized by
calling initSearch(CharSequence). This is the same
procedure as initializing the single motifs. Doing so, there is no
need to call initSearch(CharSequence)-method for every
single motif.
All search initializations have to be done on a completed MultiMotif,
otherwise any single motif added later is not proper initialized.
This can be a source of error.
Another source of error is this scenario: imagine a single motif, like a PHO-motif (PSSMotif), which occurs in 2 MultiMotifs. If both MultiMotifs are initialized with the same CharSequence, all will be well. If you got two different sequences to search on and initialize the two MultiMotifs each with another CharSequence, then the PHO is sought only on the second sequence. The same applies for stand- alone single motifs: motifs, respectivly the submotifs in a MultiMotif, remember always only the last CharSequence given to initialize the search.
The procedure for searching without performance loses is like this:
SequenceMotif's,
RegularExpressionMotif's, PSPMotif's and
PSSMotif's CharSequence to search
on by calling their initSearch(CharSequence)-method.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class de.unibi.techfak.jpredictor.motifs.MotifSearchAdapter |
|---|
MotifSearchAdapter.SearchFields |
| Field Summary | |
|---|---|
protected int[] |
distances
The distances between the motifs. |
protected MotifList |
motifs
Vector for storage of all motifs within this class |
| Fields inherited from class de.unibi.techfak.jpredictor.motifs.Motif |
|---|
DNA_DEGENERATED_CODE, DNA_DEGENERATED_CODE_JOINING, MARK_USABLE |
| Fields inherited from class de.unibi.techfak.jpredictor.motifs.MotifSearchAdapter |
|---|
searchFields |
| Fields inherited from interface de.unibi.techfak.jpredictor.motifs.MotifSearcher |
|---|
SEARCH_ALL_ORIENTATIONS, SEARCH_DIRECTION_MAX, SEARCH_DIRECTION_MINUS, SEARCH_DIRECTION_PLUS |
| Fields inherited from interface de.unibi.techfak.misc.Markable |
|---|
MARK_BASIC, MARK_DELETED, MARK_EXP, MARK_MOVED, MARK_REPLACED, MARK_SELECTED, MARK_TOBEDELETED, MARK_TOBEMOVED, MARK_TOBEREPLACED |
| Constructor Summary | |
|---|---|
MultiMotif(java.lang.String name,
java.lang.String description)
Creates a MultiMotif with a name and a description. |
|
| Method Summary | |
|---|---|
int |
add(Motif motif)
Adds a motif to this MultiMotif. |
int |
add(Motif motif,
int minDistance,
int maxDistance)
Adds a motif and the distances to the next motif to this MultiMotif. |
boolean |
checkMultiMotif()
Checks for this MultiMotif to be complete. |
boolean |
checkMultiMotifForCycles()
Checks for this MultiMotif to contain a cycle. |
java.lang.Object |
clone()
Clones the motif by creating the same motif again and copying all importent fields. |
int |
compareTo(java.lang.Object o)
Compares this motif with the specified object. |
Motif |
createReversedComplement()
The structure of this MultiMotif is reversed and
also the motifs stored are reversed and complemented. |
int[] |
getDistances()
The distances are returned as an integer array. |
Motif |
getMotif(int index)
Returns a motif within this container. |
(package private) MotifList |
getMotifs()
Returns the motif list, the MultiMotif is built upon. |
java.lang.String |
getRegularExpression()
Generates the regular expression represented by the motif. |
int |
initSearch(java.lang.CharSequence sequ)
Inits the search on the underlying single motifs combined in this MultiMotif. |
int |
length()
Returns the number of motifs within this MultiMotif. |
void |
print(java.io.PrintStream out)
Prints this MultiMotif via a PrintStream. |
java.lang.String |
replaceMotif(Motif motif,
int index)
Replaces a motif in this MultiMotif with the given one. |
FoundMotifStruct |
search(int seqStart,
int seqWidth)
Runs through the sequence already given in the initialization method initSearch and matches the motif on this
CharSequence with respect to the search mode and the
search window determined by the two parameters seqStart
and seqWidth. |
java.util.LinkedList |
searchAll(int seqStart,
int seqWidth)
Searches this motif on a sequence. |
protected java.util.LinkedList |
searchChoose(int seqStart,
int seqWidth,
boolean all)
Searches this multi motif on a sequence. |
boolean |
testDist(int[] starts,
int[] ends,
int index)
Tests, whether the distance between motifs is in the min-max-range. |
boolean |
testDistRevComp(int[] starts,
int[] ends,
int index)
Tests, whether the distance between motifs is in the min-max-range, if this motif is read reversed/complementary. |
| Methods inherited from class de.unibi.techfak.jpredictor.motifs.Motif |
|---|
clearMark, clearMark, equals, getConsensusSequence, getDescription, getMark, getName, getWeight, isMarked, isMarked, print, scoreSequenceWindow, setDescription, setMark, setName, setWeight, toString |
| Methods inherited from class de.unibi.techfak.jpredictor.motifs.MotifSearchAdapter |
|---|
getSearchMode, setSearchMode |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface de.unibi.techfak.jpredictor.motifs.MotifSearcher |
|---|
getSearchMode, setSearchMode |
| Field Detail |
|---|
protected MotifList motifs
protected int[] distances
2*(this.motifs.size()-1)
| Constructor Detail |
|---|
public MultiMotif(java.lang.String name,
java.lang.String description)
MultiMotif with a name and a description.
All other intern variables are set to defaults. Now motifs can
be added using add(Motif, int, int) or
add(Motif).
name - The name of the multi motif.description - A short description of this motif.| Method Detail |
|---|
public java.lang.String getRegularExpression()
getRegularExpression in class Motifpublic boolean checkMultiMotif()
MultiMotif. A MultiMotif is
complete, if one more motif is present then distance pairs.
true if this motif is completed properly,
false otherwise (then single motifs can be added).public boolean checkMultiMotifForCycles()
true if this motif contains cycles,
false otherwise.
public int add(Motif motif,
int minDistance,
int maxDistance)
throws CycleInMultiMotifExeption
MultiMotif. If minDistance>maxDistance
both are exchanged. Sets a description of the new motif to
reflect this change.
motif - The motif to be added to this MultiMotif.minDistance - The minimal distance to the still not present
next motif.maxDistance - The maximal distance to the still not present
next motif.
motif==null), -2 if this MultiMotif
is already completed
CycleInMultiMotifExeption - If adding the motif would lead to
a cycle in the motif.
public int add(Motif motif)
throws CycleInMultiMotifExeption
MultiMotif. The added motif finishes
this MultiMotif. A new description of this motif is
generated to reflect the changes made.
motif - The last motif to be added.
motif==null, -2 if this method was already
succesfully called.
CycleInMultiMotifExeption - If adding the motif would lead to
a cycle in the motif.
public java.lang.String replaceMotif(Motif motif,
int index)
throws java.lang.NullPointerException,
java.lang.IndexOutOfBoundsException,
CycleInMultiMotifExeption
MultiMotif with the given one.
The method generates a new description but does not set it.
motif - The motif to be inserted.index - The position of the motif to be replaced.
java.lang.NullPointerException - If motif is
null.
java.lang.IndexOutOfBoundsException - If index is less than
zero and greater or equal than this.length().
CycleInMultiMotifExeption - If replacing the motif would lead to
a cycle in the motif.
public int initSearch(java.lang.CharSequence sequ)
throws MotifNotCompleteException
MultiMotif. For all stored single motifs their specific
initSearch() is called. Note, that this
MultiMotif should be fully assambled when calling this
method, otherwise an exception is thrown. In this case no initialization
is done.
initSearch in interface MotifSearcherinitSearch in class MotifSearchAdaptersequ - the sequence for all search methods to search on.
MotifNotCompleteException - If the MultiMotif is not fully
completed.MotifSearcher.initSearch(CharSequence)
public FoundMotifStruct search(int seqStart,
int seqWidth)
throws MissingCharSequenceException,
MissingMotifException
MotifSearcherinitSearch and matches the motif on this
CharSequence with respect to the search mode and the
search window determined by the two parameters seqStart
and seqWidth.
FoundMotifStruct with positions absolute to the
sequence window. Note, that this method verifies no previous
searches, instead it searches always new. If the motif was not
found, null is returned.
id of the returned struct is misused as a flag
determining the search direction (search mode) the found motif was
(any combination of SEARCH_DIRECTION_PLUS and
SEARCH_DIRECTION_MINUS). Note, that it is possible,
that a motif can occur more than once at the same position, e.g. the
regular expression motif CNGCCATNDNND and its reversed complemented
part HNNHNATGGCTG can both be matched on the sequence CGGCCATGGCTG.
In case both search direction occur, the motif start and end position
is always for plus direction. For a reversed complemented motif
end is less than start.
null is returned.
seqStart - Search starts with this index.seqWidth - The width of the subsequence to search on.
null if the motif could not be found on the sequence.
MissingCharSequenceException - If no sequence to search on was
set.
MissingMotifException - If no motif to search for was set.MotifSearcher.initSearch(CharSequence),
MotifSearcher.SEARCH_DIRECTION_PLUS,
MotifSearcher.SEARCH_DIRECTION_MINUS
public java.util.LinkedList searchAll(int seqStart,
int seqWidth)
throws MissingCharSequenceException,
MissingMotifException
searchChoose(int, int, true)>/code>.
- Specified by:
searchAll in interface MotifSearcher- Overrides:
searchAll in class MotifSearchAdapter
- Parameters:
seqStart - The search start index on the sequence.seqWidth - The width of the sequence window.
- Returns:
- A linked list of
FoundMotifStruct-objects.
- Throws:
MissingCharSequenceException - If one of the used single motifs
was not proper initialzed with a search sequence.
MissingMotifException - If the MultiMotif is of length 0 or if
one underlying single motif's search-method throws this.- See Also:
searchChoose(int, int, boolean)
protected java.util.LinkedList searchChoose(int seqStart,
int seqWidth,
boolean all)
throws MissingCharSequenceException,
MissingMotifException
initSearch(CharSequence).
search(int, int)-method is called, then the returned
occurrences are calculated to distances and matched with the minimal
and maximal distances set for this multi motif.
FoundMotifStruct-
objects, which for every hit hold the start and end-positions of all
single motifs.
seqStart - The search start index on the sequence.seqWidth - The width of the sequence window.all - Decides whether the method stores all hits in the list
befor returning (all==true) or if it returns right after
the first one.
FoundMotifStruct-objects.
MissingCharSequenceException - If one of the used single motifs
was not proper initialzed with a search sequence.
MissingMotifException - If the MultiMotif is of length 0 or if
one underlying single motif's search-method throws this.
public boolean testDist(int[] starts,
int[] ends,
int index)
throws java.lang.ArrayIndexOutOfBoundsException,
java.lang.NullPointerException
The distance is calculated from the indexed motif's start position to the end of the previous motif:
starts[index]-ends[index-1]-1. The order of the arrays is always assumed to be ascending.
The minimum and maximum are taken from this MultiMotif.
Again, index names the subsequent motif, and
index-1 names the preceding motif. The minimum and
maximum distance of these two motifs are compared against the
calculated distance.
starts - The start positions of the motifs.ends - The end positions of the motifs.index - The index of the motif which distance to the previous
motif is tested.
true, if the distance is greater or equal to the
minimum and less or equal than the maximum
java.lang.ArrayIndexOutOfBoundsException - If the arrays are accessed
with an index greater or equal its length and smaller than zero.
java.lang.NullPointerException - If one of the accessed arrays is
null.
public boolean testDistRevComp(int[] starts,
int[] ends,
int index)
throws java.lang.ArrayIndexOutOfBoundsException,
java.lang.NullPointerException
The distance is calculated from the indexed motif's start position to the end of the previous motif:
starts[index]-ends[index-1]-1. The order of the arrays is always assumed to be ascending.
The minimum and maximum are taken from this MultiMotif.
Here, len-index names the subsequent motif, and
len-index-1 names the preceding motif. The minimum and
maximum distance of these two motifs are compared against the
calculated distance.
starts - The start positions of the motifs.ends - The end positions of the motifs.index - The index of the motif which distance to the previous
motif is tested.
true, if the distance is greater or equal to the
minimum and less or equal than the maximum
java.lang.ArrayIndexOutOfBoundsException - If the arrays are accessed
with an index greater or equal its length and smaller than zero.
java.lang.NullPointerException - If one of the accessed arrays is
null.public int length()
MultiMotif.
This behavior differs from the meaning of length, but it is unclear,
whats the length for a multi motif is.
length in class MotifSearchAdapterpublic void print(java.io.PrintStream out)
MultiMotif via a PrintStream.
Each single motif is printed by calling their
print(out)-method, inbetween the minimal and maximal
distance in a new line.
print in class Motifout - The stream to print this motif to.public Motif createReversedComplement()
MultiMotif is reversed and
also the motifs stored are reversed and complemented. The normal
case looks like this:
befor: motif1 - distance1 - motif2 - distance2 - motif3 + score
after: motif3 - distance2 - motif2 - distance1 - motif1 + score
All other cases of motif order (if this motif is not completed
properly) are not computed and thus null is returned.
MultiMotif
by adding a 'c' as prefix to the name and a 'reversed ' as prefix
to the description.
createReversedComplement in class MotifMultiMotif, null
in case of errorMotif.createReversedComplement()public int[] getDistances()
[min_1, max_1, min_2, max_2, ..., min_N, max_N], where N is either
this.length(), if this MultiMotif
is not completed yet or this.length()-1.
Note, that the returned distances are also the ones this class works with, so do not change them.
public Motif getMotif(int index)
MultiMotif where
an instance of this motif is used.
MultiMotif. Returns null if an error
occured (e.g. index>=this.length()).MotifList getMotifs()
MultiMotif is built upon.
Its the same list this class works with, so do not change it unless
you know exactly what you do.
public java.lang.Object clone()
Motif
Clones the motif by creating the same motif again and copying all
importent fields. The result is at least of class Motif.
When cloning a MultiMotif the referred single motifs
are not cloned.
The fields that are copied are: Name, Description, the Motif itself,
errorNumberAllowedForMatch or Threshold, respectively, Weight and
searchMode (altogether 6 fields by now). What is not copied are the
fields of the MotifSearchAdapter.
Note, that any matrices are not cloned. Thus, if cloning a
PSPMotif or a PSSMotif the cloned motif does
contain a reference to the matrix of the old motif. This was done
to preserve memory.
clone in class MotifObject.clone()public int compareTo(java.lang.Object o)
Motif
Compares this motif with the specified object. The Object
given must be a Motif and must not be null,
otherwise a ClassCastException is thrown. If for this
motif or the given one, the motif representation was not set, a
ClassCastException is thrown as well.
Two motifs are compared for their representations, both plus and
minus depending on the search direction. Both motifs must be of the
same type, otherwise the following relation is considered:
SequenceMotif < PSPMotif < MultiMotif and returned
without further investigations. Note, that RegularExpressionMotif
s count as SequenceMotifs and that PSSMotif
s count as PSPMotifs. In case of comparing two
MultiMotifs, after comparing the comprised single motifs
the distance informations are taken into account: first minimum vs.
first minimum, then first maximum, second minimum, and so on. In the
last instance two sequence motifs are compared for their error number
allowed for match, whereas two position specific matrix motifs are
compared for their threshold.
More formaly, this motif is less than the specified one if this reg-exp string is less than the one from the specified motif.
compareTo in interface java.lang.ComparablecompareTo in class Motifo - The motif this method is compared to.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||