de.unibi.techfak.jpredictor.motifs
Class MotifSearchAdapter

java.lang.Object
  extended by de.unibi.techfak.jpredictor.motifs.MotifSearchAdapter
All Implemented Interfaces:
MotifSearcher
Direct Known Subclasses:
Motif

abstract class MotifSearchAdapter
extends java.lang.Object
implements MotifSearcher

An abstract adapter class for searching motifs on a sequence. This class implements the interface MotifSearcher and from extending classes only search(int, int) must be implemented.

See Also:
MotifSearcher

Nested Class Summary
protected  class MotifSearchAdapter.SearchFields
          Holds data structures and fields relevant for searching motifs.
 
Field Summary
protected  MotifSearchAdapter.SearchFields searchFields
          The instance of the class holding relavant search data.
 
Fields inherited from interface de.unibi.techfak.jpredictor.motifs.MotifSearcher
SEARCH_ALL_ORIENTATIONS, SEARCH_DIRECTION_MAX, SEARCH_DIRECTION_MINUS, SEARCH_DIRECTION_PLUS
 
Constructor Summary
MotifSearchAdapter()
           
 
Method Summary
 int getSearchMode()
          The returned bit field holds a set bit if the appropriate search mode is used or a zero otherwise.
 int initSearch(java.lang.CharSequence sequ)
          Inits the search by saving a reference on the search sequence.
abstract  int length()
          The length of the motif is to return.
 java.util.LinkedList searchAll(int seqStart, int seqWidth)
          Runs through the sequence already given in the initialization method initSearch and matches the motif on that CharSequence with respect to the search mode and the sequence window.
 void setSearchMode(int searchMode)
          Sets the mode how a motif is searched.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.unibi.techfak.jpredictor.motifs.MotifSearcher
search
 

Field Detail

searchFields

protected MotifSearchAdapter.SearchFields searchFields
The instance of the class holding relavant search data.

Constructor Detail

MotifSearchAdapter

MotifSearchAdapter()
Method Detail

length

public abstract int length()
The length of the motif is to return.

Returns:
The length of the motif; if no motif is present, -1 is returned

initSearch

public int initSearch(java.lang.CharSequence sequ)
Description copied from interface: MotifSearcher
Inits the search by saving a reference on the search sequence. Also, all search states are reset, that includes the result vectors of previously done searches, which is set to null and the search window, which is set to the maximum width.

Specified by:
initSearch in interface MotifSearcher
Parameters:
sequ - the sequence for all search methods to search on.
Returns:
Zero in case of no error, any other number in case of error
See Also:
MotifSearcher.search(int, int), MotifSearcher.searchAll(int, int)

getSearchMode

public int getSearchMode()
Description copied from interface: MotifSearcher
The returned bit field holds a set bit if the appropriate search mode is used or a zero otherwise. Known bits are SEARCH_DIRECTION_PLUS , SEARCH_DIRECTION_MINUS, or SEARCH_ALL_ORIENTATIONS. Use the IOTools.test(int,int) to test for various bits.

Specified by:
getSearchMode in interface MotifSearcher
Returns:
Returns the search mode.
See Also:
MotifSearcher.setSearchMode(int), MotifSearcher.SEARCH_DIRECTION_PLUS, MotifSearcher.SEARCH_DIRECTION_MINUS, MotifSearcher.SEARCH_ALL_ORIENTATIONS, IOTools.test(int, int)

setSearchMode

public void setSearchMode(int searchMode)
                   throws java.lang.IllegalArgumentException
Description copied from interface: MotifSearcher
Sets the mode how a motif is searched. Use the flags SEARCH_DIRECTION_PLUS, SEARCH_DIRECTION_MINUS or SEARCH_ALL_ORIENTATIONS as parameters.

Specified by:
setSearchMode in interface MotifSearcher
Parameters:
searchMode - The search mode.
Throws:
java.lang.IllegalArgumentException - If searchMode is unknown.
See Also:
MotifSearcher.SEARCH_DIRECTION_PLUS, MotifSearcher.SEARCH_DIRECTION_MINUS, MotifSearcher.SEARCH_ALL_ORIENTATIONS

searchAll

public java.util.LinkedList searchAll(int seqStart,
                                      int seqWidth)
                               throws MissingCharSequenceException,
                                      MissingMotifException
Description copied from interface: MotifSearcher
Runs through the sequence already given in the initialization method initSearch and matches the motif on that CharSequence with respect to the search mode and the sequence window. A LinkedList of all occurances found is generated and returned. That list is ordered. Every element in that list is of FoundMotifStruct
A re-search on the same sequence is not performed until a different sequence window is given. If you call this method again with an overlapping search window, it trys to keep some search results from the previous saved list and to not search the whole window again.
It is recommended that the list returned is not changed. If a re-search is done on the same sequence window that changed list is returned, because a local reference to the list was saved. On the other side, one might want to take advantage from that behavior. It is possible to clear the list and then search in an overlapping window. Thus it is garantied that no result is returned twice because the method will not search the whole window again, but only the not overlapping section.

Specified by:
searchAll in interface MotifSearcher
Parameters:
seqStart - Search starts with this index.
seqWidth - The width of the subsequence to search on.
Returns:
A list containing FoundMotifStruct's of all positions in the sequence' window, where the motif matches. If the motif is a MultiMotif there is one struct per whole match with the starting positions of all single motifs. The list is empty, if no match was found.
Throws:
MissingCharSequenceException - If no sequence to search on was set previously.
MissingMotifException - If no motif to search for is set.
See Also:
MotifSearcher.initSearch(CharSequence), MotifSearcher.search(int, int)