de.unibi.techfak.jpredictor.motifs
Class Motif

java.lang.Object
  extended by de.unibi.techfak.jpredictor.motifs.MotifSearchAdapter
      extended by de.unibi.techfak.jpredictor.motifs.Motif
All Implemented Interfaces:
MotifSearcher, SequenceWindowScorer, Markable, java.lang.Cloneable, java.lang.Comparable
Direct Known Subclasses:
MultiMotif, PSPMotif, RegularExpressionMotif

public abstract class Motif
extends MotifSearchAdapter
implements SequenceWindowScorer, java.lang.Cloneable, Markable, java.lang.Comparable

Abstract superclass of all classes representing a motif. A motif is defined as a (short) nucleotide or amino-acid sequence pattern that is widespread and has, or is conjectured to have, a biological significance (WikiPedia). The single nucleotides or amino-acids are either represented by characters or by probabilities.

Subclasses must provide the methods print, createReversedComplement and clone. Furthermore, the class implements the interface Comparable and thus subclasses must override compareTo. The method equals returns true, if compareTo returns zero. Thus, the natural ordering is consistent with equals.

It is stronly recommended for subclasses to override the methods getConsensusSequence and getRegularExpression as well, as they will return null on any call.


Nested Class Summary
 
Nested classes/interfaces inherited from class de.unibi.techfak.jpredictor.motifs.MotifSearchAdapter
MotifSearchAdapter.SearchFields
 
Field Summary
private  java.lang.String description
          The motif's description
(package private) static java.lang.String DNA_DEGENERATED_CODE
          The degenerated code of DNA, expressed as a string for fast access while matching.
(package private) static char[] DNA_DEGENERATED_CODE_JOINING
          The degenerated code of DNA, expressed are the resulting Regular Expressions when joining two chars.
private  int mark
          The mark variable containing the markers set.
static int MARK_USABLE
          This mark means, that the corresponding motif, marked so, can be used for all operations like weighting or scoring.
private  java.lang.String name
          Name of the motif
private  double weight
          The weight of a motif.
 
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
protected Motif(java.lang.String motifName, java.lang.String description)
          Constructs a motif by setting a name and a description.
 
Method Summary
 void clearMark()
          The mark of the object is cleared, thus it is not marked anymore.
 void clearMark(int mark)
          Clears a special mark.
abstract  java.lang.Object clone()
           Clones the motif by creating the same motif again and copying all importent fields.
abstract  int compareTo(java.lang.Object o)
           Compares this motif with the specified object.
abstract  Motif createReversedComplement()
          Creates the reversed complementary motif.
 boolean equals(java.lang.Object o)
          Indicates whether some other motif is equal to this one.
 java.lang.String getConsensusSequence()
          Creates or calculates the consensus sequence from the motif, which is returned.
 java.lang.String getDescription()
           
 int getMark()
          Gets the complete mark for the object.
 java.lang.String getName()
           
 java.lang.String getRegularExpression()
          Represents the motif as a regular expression.
 double getWeight()
          Gets the previously set weight or Double.NaN.
 boolean isMarked()
          Tests, whether any mark is set.
 boolean isMarked(int mark)
          Tests a special mark, whether it is set.
 void print()
          Prints the motif to System.out.
abstract  void print(java.io.PrintStream out)
          Prints the motif to the given stream, e.g.
 double scoreSequenceWindow(int seqStart, int seqLength)
          Scores a sequence window.
 void setDescription(java.lang.String description)
          Sets the description of the motif
 void setMark(int mark)
          Sets a mark for the object.
 void setName(java.lang.String name)
          Sets the name of the motif
 void setWeight(double weight)
          Sets the weight for the motif.
 java.lang.String toString()
           
 
Methods inherited from class de.unibi.techfak.jpredictor.motifs.MotifSearchAdapter
getSearchMode, initSearch, length, searchAll, 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, initSearch, search, searchAll, setSearchMode
 

Field Detail

MARK_USABLE

public static final int MARK_USABLE
This mark means, that the corresponding motif, marked so, can be used for all operations like weighting or scoring.

See Also:
Constant Field Values

DNA_DEGENERATED_CODE

static final java.lang.String DNA_DEGENERATED_CODE
The degenerated code of DNA, expressed as a string for fast access while matching. Note: the positions are specific, do not change it

See Also:
RegularExpressionMotif.match(char, char), Constant Field Values

DNA_DEGENERATED_CODE_JOINING

static final char[] DNA_DEGENERATED_CODE_JOINING
The degenerated code of DNA, expressed are the resulting Regular Expressions when joining two chars. e.g. A joined with B is N. Note: the positions are specific, do not change it

See Also:
RegularExpressionMotif.getRegularExpressionChar(char, char)

name

private java.lang.String name
Name of the motif


description

private java.lang.String description
The motif's description


weight

private double weight
The weight of a motif. It is accounted for if the motif was found on a sequence. Double.NaN stands for default and to show, that no score is present.


mark

private int mark
The mark variable containing the markers set.

Constructor Detail

Motif

protected Motif(java.lang.String motifName,
                java.lang.String description)
Constructs a motif by setting a name and a description. The search direction is set to all orientations and the motif's mark is set to usable (note, that single motifs should not be usable per default).

Parameters:
motifName - The motifs name (identifier).
description - A short description of the motif.
See Also:
MotifSearcher.SEARCH_ALL_ORIENTATIONS, MARK_USABLE
Method Detail

getName

public final java.lang.String getName()
Returns:
The name of the motif

setName

public final void setName(java.lang.String name)
Sets the name of the motif

Parameters:
name - The new name of the motif.

getDescription

public final java.lang.String getDescription()
Returns:
The description of the motif

setDescription

public final void setDescription(java.lang.String description)
Sets the description of the motif

Parameters:
description - The new description.

getConsensusSequence

public java.lang.String getConsensusSequence()
Creates or calculates the consensus sequence from the motif, which is returned.

Returns:
The consensus sequence, null in case no motif present

getRegularExpression

public java.lang.String getRegularExpression()
Represents the motif as a regular expression. The default is to return the same as getConsensusSequence().

Returns:
The motif as regular expression, null in case of no motif present

createReversedComplement

public abstract Motif createReversedComplement()
Creates the reversed complementary motif.

Returns:
The reversed and complemented motif.

print

public abstract void print(java.io.PrintStream out)
Prints the motif to the given stream, e.g. Motif.print( new PrintStream( new FileOutputStream ( name )))

Parameters:
out - The stream to print the motif to.

print

public void print()
Prints the motif to System.out.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:
The motifs name

getWeight

public double getWeight()
Description copied from interface: SequenceWindowScorer
Gets the previously set weight or Double.NaN.

Specified by:
getWeight in interface SequenceWindowScorer
Returns:
The weight of the motif or Double.NaN, if the weight was not set yet.

setWeight

public void setWeight(double weight)
Description copied from interface: SequenceWindowScorer
Sets the weight for the motif. The weight is not set, if the motif is not proper initialized, as it is the case for MultiMotifs.

Specified by:
setWeight in interface SequenceWindowScorer
Parameters:
weight - The new weight to set.

scoreSequenceWindow

public double scoreSequenceWindow(int seqStart,
                                  int seqLength)
Description copied from interface: SequenceWindowScorer
Scores a sequence window. First, the motif is searched and the number of findings is multiplied with the weight given for that motif.

Specified by:
scoreSequenceWindow in interface SequenceWindowScorer
Parameters:
seqStart - The start point on the CharSequence.
seqLength - The length of the window on the CharSequence.
Returns:
A number representing the score, or Double.NaN in case of error or if the score was not yet set.
See Also:
MotifSearcher.search(int, int), MotifSearcher.searchAll(int, int)

clone

public abstract java.lang.Object clone()

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.

Overrides:
clone in class java.lang.Object
Returns:
The Motif itself as a doubled copy.
See Also:
Object.clone()

setMark

public void setMark(int mark)
Description copied from interface: Markable
Sets a mark for the object. The mark is disjuncted (bitwise OR operation) to the existing mark.

Specified by:
setMark in interface Markable
Parameters:
mark - The mark to set.

getMark

public int getMark()
Description copied from interface: Markable
Gets the complete mark for the object.

Specified by:
getMark in interface Markable
Returns:
The complete mark.

clearMark

public void clearMark(int mark)
Description copied from interface: Markable
Clears a special mark. Its inversion is conjuncted (bitwise AND operation) to the existing mark.

Specified by:
clearMark in interface Markable
Parameters:
mark - The mark to be deleted.

clearMark

public void clearMark()
Description copied from interface: Markable
The mark of the object is cleared, thus it is not marked anymore. After this, every call to isMarked() and isMarked(int) should return false.

Specified by:
clearMark in interface Markable
See Also:
Markable.isMarked(), Markable.isMarked(int)

isMarked

public boolean isMarked()
Description copied from interface: Markable
Tests, whether any mark is set.

Specified by:
isMarked in interface Markable
Returns:
true iff a mark is set, false otherwise.

isMarked

public boolean isMarked(int mark)
Description copied from interface: Markable
Tests a special mark, whether it is set.

Specified by:
isMarked in interface Markable
Parameters:
mark - The mark to be tested.
Returns:
true iff the mark is set, false otherwise.

compareTo

public abstract int compareTo(java.lang.Object o)

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.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
o - The motif this method is compared to.
Returns:
Minus one, zero or one as this motif is less than, equal or greater than the specified motif.
Throws:
java.lang.ClassCastException - If the specified object is not a Motif or null

equals

public boolean equals(java.lang.Object o)
Indicates whether some other motif is equal to this one. The comparison is done via method compareTo(Object) and true is returned only iff compareTo yielded a zero.

Overrides:
equals in class java.lang.Object
Parameters:
o - The motif this method is compared to.
Returns:
true, iff this object equals the given one, false otherwise.
See Also:
compareTo(Object)