de.unibi.techfak.jpredictor.motifs
Class FoundMotifStruct

java.lang.Object
  extended by de.unibi.techfak.jpredictor.motifs.FoundMotifStruct
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Comparable

public class FoundMotifStruct
extends java.lang.Object
implements java.lang.Comparable, java.lang.Cloneable

Class for holding the results when searching through the operator.
If toString() is called, a String of the appearance "id:start[0]-end[0]:start[1]-end[1]:..." is returned.


Field Summary
 int[] end
          The end of the found motifs on the sequence.
 int id
          The id of the result, that is the motif number in the list.
 int[] start
          The start of the found motifs on the sequence.
 
Constructor Summary
FoundMotifStruct(int[] start)
          This constructor sets the id to zero and end to null.
FoundMotifStruct(int[] start, int[] end)
          This constructor sets the id to zero and calls this(0, start, end).
FoundMotifStruct(int id, int start)
          Give for a motif the id and its start.
FoundMotifStruct(int id, int[] startend)
          Give the id and occurrences of all motifs of a MultiMotif.
FoundMotifStruct(int id, int[] start, int[] end)
          Give the id and occurrences of all motifs of a MultiMotif.
FoundMotifStruct(int id, int start, int end)
          Give for a motif the id, its start and end on the sequence.
 
Method Summary
 java.lang.Object clone()
           
 int compareTo(java.lang.Object arg)
          Compares this class to another one of the same type.
 int end()
          Calculates the maximal end position of the motif.
 int getOccurrence(int index)
          Gets the occurrence of the motif with the given index.
 int length()
          Calculates the length of the motif.
 int start()
          Calculates the minimal start position of the motif.
 java.lang.String toString()
          Generates a representation of the occurrence.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

id

public int id
The id of the result, that is the motif number in the list.


start

public int[] start
The start of the found motifs on the sequence. If start>end the motif was found reversed complementary.


end

public int[] end
The end of the found motifs on the sequence. If end<start the motif was found reversed complementary.

Constructor Detail

FoundMotifStruct

public FoundMotifStruct(int id,
                        int start)
Give for a motif the id and its start.

Parameters:
id - The id of the motif whos found index is stored.
start - Start of the motif on the sequence.

FoundMotifStruct

public FoundMotifStruct(int id,
                        int start,
                        int end)
Give for a motif the id, its start and end on the sequence. If the id is irrelevant, set it to zero.

Parameters:
id - The id of the motif whos found index is stored.
start - Start of the motif on the sequence.
end - End of the motif on the sequence.

FoundMotifStruct

public FoundMotifStruct(int id,
                        int[] start,
                        int[] end)
                 throws java.lang.NullPointerException
Give the id and occurrences of all motifs of a MultiMotif. With this method all motifs comprised in a MultiMotif have their own start and end point which are stored.
The id is the one of the MultiMotif and not of the single motifs within. If it is irrelevant, set it to zero.
Both arrays are cloned and assumed to be ordered. end may be null, start must not. Both arrays need to have the same size, otherwise the lesser length is taken for cloning both arrays.

Parameters:
id - The id of the motif whos found index is stored.
start - Array of start points of all motifs on the sequence.
end - Array of end points of all motifs on the sequence.
Throws:
java.lang.NullPointerException - If start==null.

FoundMotifStruct

public FoundMotifStruct(int id,
                        int[] startend)
                 throws java.lang.NullPointerException
Give the id and occurrences of all motifs of a MultiMotif. The given array has all start and end positions of the motifs in it:
[ start1, end1, start2, end2, ..., start_N, end_N ]
. The total length must therefore be even, and greater zero. If the length is odd, the last index is ignored.

Parameters:
id - The id of the motif whos occurrence is to be stored.
startend - Array of start-end-occurrences of all motifs on the sequence.
Throws:
java.lang.NullPointerException - If startend==null.

FoundMotifStruct

public FoundMotifStruct(int[] start,
                        int[] end)
                 throws java.lang.NullPointerException
This constructor sets the id to zero and calls this(0, start, end).

Parameters:
start - Array of start points of all motifs on the sequence.
end - Array of end points of all motifs on the sequence.
Throws:
java.lang.NullPointerException - If start==null.

FoundMotifStruct

public FoundMotifStruct(int[] start)
                 throws java.lang.NullPointerException
This constructor sets the id to zero and end to null. It simply calls this(0, start, null).

Parameters:
start - Array of start-occurrences of all motifs on the sequence.
Throws:
java.lang.NullPointerException - If start==null.
Method Detail

compareTo

public int compareTo(java.lang.Object arg)
Compares this class to another one of the same type. Returns zero, iff all data types stored are of the same content, -1, iff this is less and 1 if this is greater than arg.
First, the occurrences are compared ignoring the direction, i.e. end can be less then start if the motif was rev/compl found. Second the number of occurrences are compared: if this contains more occurrences, 1 is returned; if args contains more, -1 is returned. Last the id's are compared. Only if they are equal, the two FoundMotifStruct's are equal.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
arg - Another FoundMotifStruct this one is compared to. Throws a ClassCastException, if arg is of the wrong type.
See Also:
Comparable.compareTo(java.lang.Object)

toString

public java.lang.String toString()
Generates a representation of the occurrence. The string contains first the id, and than the occurrences "start-end" all seperated by a colon. If this.end==null "-end" is left out.

Overrides:
toString in class java.lang.Object
See Also:
Object.toString()

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object

getOccurrence

public int getOccurrence(int index)
                  throws java.lang.ArrayIndexOutOfBoundsException
Gets the occurrence of the motif with the given index. If end is less than start for this motifs occurrence, than -end is returned, otherwise start.

Parameters:
index - The index within the arrays (in other words, the index of the motif within the MultiMotif).
Returns:
The start of a motif on the sequence, with a minus befor, if its direction is rev/comp.
Throws:
java.lang.ArrayIndexOutOfBoundsException - If index is not within the occurrency arrays.

length

public int length()
Calculates the length of the motif. Normally, the length is
end()-start()+1
. Thus, 1 is returned if only start was given while constructing this class.

Returns:
The length of the found motif.
See Also:
start(), end()

start

public int start()
Calculates the minimal start position of the motif. The first motif is assumed to be the one with the smallest occurrence position, thus the minimal start position is
Math.min( start[0], end[0] )
. If no end array was given during construction start[0] is returned.

Returns:
The start of the motif on the sequence.

end

public int end()
Calculates the maximal end position of the motif. The last motif is assumed to be the one with the highest occurrences position, thus the maximal end position is
Math.max(start[len-1], end[len-1])
. If no end array was given during construction start[len-1] is returned.

Returns:
The end of the motif on the sequence.