de.unibi.techfak.jpredictor.operator
Class DefaultCommunicator

java.lang.Object
  extended by de.unibi.techfak.jpredictor.operator.States
      extended by de.unibi.techfak.jpredictor.operator.DefaultCommunicator
All Implemented Interfaces:
ICommunicator

public class DefaultCommunicator
extends States
implements ICommunicator

Class for controlling the functionality of motifs on sequences, for using the communicator as parameter deliverer and as output receiver.


Nested Class Summary
 
Nested classes/interfaces inherited from class de.unibi.techfak.jpredictor.operator.States
States.SequenceStore
 
Field Summary
protected  int flag
          The flag buffer.
protected  java.util.Vector queue
          The list of result elements.
private  int timesThreadSlept
          THIS VARIABLE MAY ONLY BE USED IN METHOD RECEIVErESULTS.
 
Fields inherited from class de.unibi.techfak.jpredictor.operator.States
allowThreadRunning, distanceMode, err, fixedCutoff, fixedCutoffDefault, globalBackground, globalCharacterDistributionDefault, graphicalOutput, motifList, motifOccurrenceVector, out, rand, scorePlotVector, seed, sequenceLengthNormalization, sequenceLengthNormalizationDefault, sequenceStore, STORE_NEGATIVE_TRAINING_SET, STORE_POSITIVE_TRAINING_SET, STORE_SEQUENCE, ver, windowShift, windowShiftDefault, windowWidth, windowWidthDefault
 
Fields inherited from interface de.unibi.techfak.jpredictor.operator.ICommunicator
DISTANCE_ADJACENT, DISTANCE_ADJACENT73, DISTANCE_ANYSPACE, DISTANCE_BELOW220, DISTANCE_ONETURN, DISTANCE_SINGLE, DISTANCE_TWOTURNS, FLAG_B, FLAG_F, FLAG_M, OBJECT_FASTA_MODIFIER, OBJECT_FILENAME, OBJECT_FILENAME_FASTA, OBJECT_NOTYPE, OBJECT_READER, OBJECT_READER_FASTA, OBJECT_SEQUENCE, OBJECT_STRING, OBJECT_STRING_FASTA
 
Constructor Summary
DefaultCommunicator()
           
 
Method Summary
 void allowRunning()
          Sets a flag that signals all running threads started by the operator that they are allowed to run.
 java.io.PrintStream err()
          Returns the output stream to which error messages should be sent.
 boolean flag(int flags)
          Using this method you can test various settings, whether they occured or not.
 double getCutoff()
          Gets the cutoff.
 java.lang.String getDistanceMode()
          Gets the previously set distance mode.
 double[] getGlobalBackground()
          Gives the background distribution over a character set.
 boolean getGraphicalOutput()
           
 MotifList getMotifList()
          Gets the previoulsy set MotifList.
 java.util.Vector getMotifOccurrenceVector()
          If the graphical output is activated, the operator stores information of found motifs in this vector.
 java.lang.Object getNegativeTrainingSequence()
          Gets the sequence object meant as negative training set.
 int getNegativeTrainingSequenceType()
           
 java.lang.Object getNextResult()
          The user interface requests for the next results.
 java.lang.Object getPositiveTrainingSequence()
          Gets the sequence object meant as positive training set.
 int getPositiveTrainingSequenceType()
           
 java.util.Vector getScorePlotVector()
          If the graphical output is activated, the operator stores information for the score plot in this vector.
 long getSeed()
          The seed, the random number generator was initialized with is returned.
 java.lang.Object getSequence()
          Gets the sequence object.
 SequenceEnumeration getSequenceEnumeration(java.lang.Object o, int type)
          Checks for the type and builds a SequenceEnumerator from the object given.
 boolean getSequenceLengthNormalization()
           
 int getSequenceType()
           
 int getSequenceWindowShift()
           
 int getSequenceWindowWidth()
           
 boolean hasNextResult()
          The user interface asks whether the result queue has elements to fetch.
 boolean isRunningAllowed()
          Returns the flag for search and score threads of the operator whether they are allow to proceed or must stop on next occasion.
 java.io.PrintStream out()
          Returns the output stream to which normal output should be sent.
 boolean outputForScoreSequence(IOperator op, boolean best)
           Scores sequences using weighted motifs and generates and prints the appropriate output.
 boolean outputForSearchMotifs(IOperator op, boolean count)
           Searches motifs on sequences and generates and prints the appropriate output.
 boolean outputForWeightMotifs(IOperator op)
           Weights motifs and generates and prints the appropriate output.
 java.util.Random rand()
          Returns the random number generator which is initialized when the communicator object was created.
 double random()
          Returns a double random number generated with the intern random number generator.
 int receiveResults(java.lang.Object o)
          The communicator receives the next result, which is to be stored in a queue-like structure until the user interface requests for the next result by calling getNextResult().
 void setCutoff(double cutoff)
          Sets a cutoff.
 boolean setDistanceMode(java.lang.String distance)
          Sets the distance mode.
 void setErrorStream(java.io.PrintStream ps)
          This method sets a PrintStream as new error message output stream.
 void setGlobalBackground(double[] newBackground)
           Sets the new character occurrence distribution.
 void setGraphicalOutput(boolean graphout)
           The graphical output is activated or deactivated.
 void setMotifList(MotifList ml)
          Sets a MotifList.
 void setNegativeTrainingSequence(java.lang.Object sequ, int type)
          Sets a sequence object (CharSequence, filename or stream) meant as negative training set.
 void setOutputStream(java.io.PrintStream ps)
          This method sets a PrintStream as new output stream.
 void setPositiveTrainingSequence(java.lang.Object sequ, int type)
          Sets a sequence object (CharSequence, filename or stream) meant as positive training set.
 void setSeed(long seed)
          Sets a new seed for the random number generator.
 void setSequence(java.lang.Object sequ, int type)
          Sets a sequence (CharSequence, filename or stream) to perform searching and scoring on.
 void setSequenceLengthNormalization(boolean norm)
          Sets, whether the occurrences on the positive and negativ training set, respectively, are normalized by the sequence length of the set.
 void setSequenceWindowShift(int shift)
          Sets the sequence window's shift.
 void setSequenceWindowWidth(int width)
          Sets the sequence window width.
 void setVerboseStream(java.io.PrintStream ps)
          This method sets a PrintStream as new verbose message output stream.
 void stopRunning()
          Sets a flag that signals all running threads started by the operator to stop as soon as possible.
protected  void testForSequenceClass(java.lang.Object sequ, int type)
          Tests for the type of the object, whether it is equal to the type type says.
 java.io.PrintStream ver()
          Returns the output stream to which verbose messages should be sent.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

queue

protected java.util.Vector queue
The list of result elements. This field is used by the method receiveResults to store the results and by the method getNextResult the deliver the results to the user interface on request. Note, that if it is overwritten, it must be a synchronized object.

See Also:
ICommunicator.receiveResults(Object), ICommunicator.getNextResult()

timesThreadSlept

private int timesThreadSlept
THIS VARIABLE MAY ONLY BE USED IN METHOD RECEIVErESULTS. If an OutOfMemoryError occurs in the method receiveResults the calling thread is sent to sleep for a short while to ensure that the wrapping thread empties the queue.


flag

protected int flag
The flag buffer.

Constructor Detail

DefaultCommunicator

public DefaultCommunicator()
Method Detail

testForSequenceClass

protected void testForSequenceClass(java.lang.Object sequ,
                                    int type)
                             throws java.lang.IllegalArgumentException
Tests for the type of the object, whether it is equal to the type type says. Valid values for type are OBJECT_FILENAME, OBJECT_READER or OBJECT_SEQUENCE. As filename sequ must be a string, as reader it must be any Reader and as sequence it must be either a sequences.Sequence or a sequences.MappedCharSequence.

Parameters:
sequ - The sequence object.
type - The type of the sequence object.
Throws:
java.lang.IllegalArgumentException - If type does not correctly specify the type of the object.

getSequenceEnumeration

public SequenceEnumeration getSequenceEnumeration(java.lang.Object o,
                                                  int type)
Description copied from interface: ICommunicator
Checks for the type and builds a SequenceEnumerator from the object given. Example call: getSequenceEnumeration( ICommunicator.getSequence(), ICommunicator.getSequenceType()).

Specified by:
getSequenceEnumeration in interface ICommunicator
Parameters:
o - The sequence (CharSequence, Reader or Sequence).
type - The type of sequence, get it from the ICommunicator.
Returns:
null in case of any error, otherwise an enumerator over all possible sequences.
See Also:
SequenceEnumerator, SequenceEnumeration

setSequence

public void setSequence(java.lang.Object sequ,
                        int type)
                 throws java.lang.IllegalArgumentException
Description copied from interface: ICommunicator
Sets a sequence (CharSequence, filename or stream) to perform searching and scoring on. Valid values for type are the OBJECT_-variables of this class. Recommended to give are either a filename or a Sequence-Object.
By this method the flag FLAG_F is set. But if you give null as the object's value, any previously set sequence and the FLAG_F are cleared.

Specified by:
setSequence in interface ICommunicator
Parameters:
sequ - The sequence object, either a String, a Reader or a Sequence from package sequences.
type - The type definition for the object.
Throws:
java.lang.IllegalArgumentException - If the object's type is inequal to what type suggests.
See Also:
ICommunicator.FLAG_F, ICommunicator.OBJECT_FILENAME, ICommunicator.OBJECT_FILENAME_FASTA, ICommunicator.OBJECT_NOTYPE, ICommunicator.OBJECT_READER, ICommunicator.OBJECT_READER_FASTA, ICommunicator.OBJECT_SEQUENCE, ICommunicator.OBJECT_STRING, ICommunicator.OBJECT_STRING_FASTA

getSequence

public java.lang.Object getSequence()
Description copied from interface: ICommunicator
Gets the sequence object.

Specified by:
getSequence in interface ICommunicator
Returns:
The sequence object or null if it was not set.
See Also:
ICommunicator.setSequence(Object, int), ICommunicator.getSequenceEnumeration(Object, int)

getSequenceType

public int getSequenceType()
Specified by:
getSequenceType in interface ICommunicator
Returns:
The sequence object's type, or OBJECT_NOTYPE if it was not set.
See Also:
ICommunicator.setSequence(Object, int), ICommunicator.getSequenceEnumeration(Object, int)

setPositiveTrainingSequence

public void setPositiveTrainingSequence(java.lang.Object sequ,
                                        int type)
                                 throws java.lang.IllegalArgumentException
Description copied from interface: ICommunicator
Sets a sequence object (CharSequence, filename or stream) meant as positive training set. Such set consists of one or more sequences with an above-average number of motif occurrences. For PRE-finding it consist of all sequences already confirmed to be true sequences with PRE-functionality.
See setSequence(Object, int) for the parameter's meaning.
By this method the flag FLAG_M is set. But if you give null as the object's value, any previously set sequence and the FLAG_M is cleared.

Specified by:
setPositiveTrainingSequence in interface ICommunicator
Parameters:
sequ - The sequence object.
type - The type definition for the object.
Throws:
java.lang.IllegalArgumentException - If the object's type is inequal to what type suggests.
See Also:
ICommunicator.FLAG_M, ICommunicator.setSequence(Object, int), ICommunicator.getSequenceEnumeration(Object, int)

getPositiveTrainingSequence

public java.lang.Object getPositiveTrainingSequence()
Description copied from interface: ICommunicator
Gets the sequence object meant as positive training set.

Specified by:
getPositiveTrainingSequence in interface ICommunicator
Returns:
The sequence object or null if it was not set.
See Also:
ICommunicator.setPositiveTrainingSequence(Object, int), ICommunicator.getSequenceEnumeration(Object, int)

getPositiveTrainingSequenceType

public int getPositiveTrainingSequenceType()
Specified by:
getPositiveTrainingSequenceType in interface ICommunicator
Returns:
The positive trainings sequence object's type, or OBJECT_NOTYPE if it was not set.
See Also:
ICommunicator.setPositiveTrainingSequence(Object, int), ICommunicator.getSequenceEnumeration(Object, int)

setNegativeTrainingSequence

public void setNegativeTrainingSequence(java.lang.Object sequ,
                                        int type)
                                 throws java.lang.IllegalArgumentException
Description copied from interface: ICommunicator
Sets a sequence object (CharSequence, filename or stream) meant as negative training set. Such set consists of one or more sequences representing the background distribution of alphabet character occurrences. For PRE-finding it consist of a representing sequence with no or at least no PRE-functionality.
See setSequence(Object, int) for the parameter's meaning.
By this method the flag FLAG_B is set. But if you give null as the object's value, any previously set sequence and the FLAG_B is cleared.

Specified by:
setNegativeTrainingSequence in interface ICommunicator
Parameters:
sequ - The sequence object.
type - The type definition for the object.
Throws:
java.lang.IllegalArgumentException - If the object's type is inequal to what type suggests.
See Also:
ICommunicator.FLAG_B, ICommunicator.setSequence(Object, int), ICommunicator.getSequenceEnumeration(Object, int)

getNegativeTrainingSequence

public java.lang.Object getNegativeTrainingSequence()
Description copied from interface: ICommunicator
Gets the sequence object meant as negative training set.

Specified by:
getNegativeTrainingSequence in interface ICommunicator
Returns:
The sequence object or null if it was not set.
See Also:
ICommunicator.setNegativeTrainingSequence(Object, int), ICommunicator.getSequenceEnumeration(Object, int)

getNegativeTrainingSequenceType

public int getNegativeTrainingSequenceType()
Specified by:
getNegativeTrainingSequenceType in interface ICommunicator
Returns:
The negative trainings sequence object's type, or OBJECT_NOTYPE if it was not set.
See Also:
ICommunicator.setNegativeTrainingSequence(Object, int), ICommunicator.getSequenceEnumeration(Object, int)

setSequenceWindowWidth

public void setSequenceWindowWidth(int width)
Description copied from interface: ICommunicator
Sets the sequence window width. The sequence window is a section of the sequence actually considered to do searching or scoring in. E.g., the score is always calculated as sum of all found motif's scores over the whole sequence window.

Specified by:
setSequenceWindowWidth in interface ICommunicator
Parameters:
width - The width of the sequence window.

getSequenceWindowWidth

public int getSequenceWindowWidth()
Specified by:
getSequenceWindowWidth in interface ICommunicator
Returns:
The sequence window's width.
See Also:
ICommunicator.setSequenceWindowWidth(int)

setSequenceWindowShift

public void setSequenceWindowShift(int shift)
Description copied from interface: ICommunicator
Sets the sequence window's shift. The sequence window is a section of the sequence actually considered to do searching or scoring in. When the window is processed it is shifted on the sequence to process another part of the sequence. The shifting value may be less than the window width.

Specified by:
setSequenceWindowShift in interface ICommunicator
Parameters:
shift - The number of characters the sequence window is shifted by.

getSequenceWindowShift

public int getSequenceWindowShift()
Specified by:
getSequenceWindowShift in interface ICommunicator
Returns:
The number of characters the window is shifted on the sequence.
See Also:
ICommunicator.setSequenceWindowShift(int)

setMotifList

public void setMotifList(MotifList ml)
Description copied from interface: ICommunicator
Sets a MotifList. The motifs in the list are searched on a sequence and using the occurrences the motifs are weigthed or the sequence is scored.

Specified by:
setMotifList in interface ICommunicator
Parameters:
ml - A list of motifs as MotifList.

getMotifList

public MotifList getMotifList()
Description copied from interface: ICommunicator
Gets the previoulsy set MotifList.

Specified by:
getMotifList in interface ICommunicator
Returns:
A list of motifs or null, if no MotifList was set before.
See Also:
ICommunicator.setMotifList(MotifList)

setCutoff

public void setCutoff(double cutoff)
Description copied from interface: ICommunicator
Sets a cutoff. This value is used when a sequence is scored. If not Double.NaN is set as cutoff the scores are comprised to bands, for which the score is higher than the cutoff. Otherwise, for every sequence window the scores are output.

Specified by:
setCutoff in interface ICommunicator
Parameters:
cutoff - The new cutoff or Double.NaN to switch comprising off.
See Also:
States.fixedCutoffDefault

getCutoff

public double getCutoff()
Description copied from interface: ICommunicator
Gets the cutoff. The value of the cutoff decides whether comprising the scores is switched on (Double.isNaN(cutoff)==true) or off.

Specified by:
getCutoff in interface ICommunicator
Returns:
The actually set cutoff.
See Also:
ICommunicator.setCutoff(double)

setGlobalBackground

public void setGlobalBackground(double[] newBackground)
                         throws java.lang.NullPointerException,
                                java.lang.IllegalArgumentException
Description copied from interface: ICommunicator

Sets the new character occurrence distribution. For every assumed character a probability has to be given, which represents the occurrence frequency of that character in a sequence.

The given double array is cloned, and the cloned version is recalculated such that all values sum up to one (normalization). Thus, the given background is not changed in any way.

Specified by:
setGlobalBackground in interface ICommunicator
Parameters:
newBackground - The new background character distribution. Note, that it must not be null nor empty.
Throws:
java.lang.NullPointerException - If the given background is null.
java.lang.IllegalArgumentException - If the given background is empty or if at least one value is less than zero or if the sum over all probabilities (or counts) is zero.

getGlobalBackground

public double[] getGlobalBackground()
Description copied from interface: ICommunicator
Gives the background distribution over a character set.

Specified by:
getGlobalBackground in interface ICommunicator
Returns:
The distribution over a character set (background) is returned.
See Also:
ICommunicator.setGlobalBackground(double[])

receiveResults

public int receiveResults(java.lang.Object o)
                   throws java.lang.IllegalStateException
Description copied from interface: ICommunicator
The communicator receives the next result, which is to be stored in a queue-like structure until the user interface requests for the next result by calling getNextResult().
Note, that the user interface should not call this method.

Specified by:
receiveResults in interface ICommunicator
Parameters:
o - This object is to be stored as part of the result stream.
Returns:
The number of objects in the queue not yet sent to the user interface.
Throws:
java.lang.IllegalStateException - If the communicator was unable to store the object for any reason.
See Also:
ICommunicator.getNextResult()

getNextResult

public java.lang.Object getNextResult()
                               throws java.lang.IllegalStateException
Description copied from interface: ICommunicator
The user interface requests for the next results. From the stream of possible results the next one is returned. See the task-performing methods in the IOperator for a notion on what the Objects might be.

Specified by:
getNextResult in interface ICommunicator
Returns:
The next result object, or null if no results are available in the queue.
Throws:
java.lang.IllegalStateException - If the communicator was unable to read an object for any reason.
See Also:
ICommunicator.hasNextResult(), IOperator.searchMotifs(boolean), IOperator.weightMotifs(), IOperator.scoreSequence()

hasNextResult

public boolean hasNextResult()
Description copied from interface: ICommunicator
The user interface asks whether the result queue has elements to fetch.
Note, that even if this method returns false, a consecutive call to getNextResult() might return other than null because the task-performing thread may have send a result in the meanwhile. What can be assured of is, that in case of a returned true a call to getNextResult() will not return null.

Specified by:
hasNextResult in interface ICommunicator
Returns:
true if a result is in the queue and can be fetched by calling getNextresult(), false if actually no result is in the queue.
See Also:
ICommunicator.getNextResult()

setSequenceLengthNormalization

public void setSequenceLengthNormalization(boolean norm)
Description copied from interface: ICommunicator
Sets, whether the occurrences on the positive and negativ training set, respectively, are normalized by the sequence length of the set. That means, that befor calculating the score for one motif, the number of found occurrences on the positive training set is divided by the over-all-length of the sequences containing to that set. The same fits for the motif's occurrences on the sequences of the negative training set.

Specified by:
setSequenceLengthNormalization in interface ICommunicator
Parameters:
norm - true if normalization should be done, false otherwise.

getSequenceLengthNormalization

public boolean getSequenceLengthNormalization()
Specified by:
getSequenceLengthNormalization in interface ICommunicator
Returns:
true, if normalization is wished, false otherwise.
See Also:
ICommunicator.setSequenceLengthNormalization(boolean)

setDistanceMode

public boolean setDistanceMode(java.lang.String distance)
Description copied from interface: ICommunicator
Sets the distance mode. That can be for instance any String of the predefined distance modes, e.g. DISTANCE_BELOW220. It is also possible to give a string in the format "min,max". This directly sets the distance to other than the predefined value. But note, that no other string format is accepted.

Specified by:
setDistanceMode in interface ICommunicator
Parameters:
distance - The distance mode as String.
Returns:
true, if the distance mode could be recognized, false otherwise. If the distance mode was not recognized, it is not set.

getDistanceMode

public java.lang.String getDistanceMode()
Description copied from interface: ICommunicator
Gets the previously set distance mode.

Specified by:
getDistanceMode in interface ICommunicator
Returns:
The distance mode as String.
See Also:
ICommunicator.setDistanceMode(String)

flag

public boolean flag(int flags)
Description copied from interface: ICommunicator
Using this method you can test various settings, whether they occured or not. This method test, whether at least one of the given flags is set, e.g. imagine FLAG_B is set, than the call ICommunicator.flag( FLAG_B | FLAG_M ) would return true.

Specified by:
flag in interface ICommunicator
Parameters:
flags - The flag or flags to be tested.
Returns:
true, if at least one flag is set, false otherwise.

allowRunning

public void allowRunning()
Description copied from interface: ICommunicator
Sets a flag that signals all running threads started by the operator that they are allowed to run.
This method is called by the operator before any thread for searching and scoring is started.

Specified by:
allowRunning in interface ICommunicator

stopRunning

public void stopRunning()
Description copied from interface: ICommunicator
Sets a flag that signals all running threads started by the operator to stop as soon as possible.
When this method returns the affected threads might be still running for a while. So do not stop reading their output until the end-of-running (finishing) result was received.

Specified by:
stopRunning in interface ICommunicator

isRunningAllowed

public boolean isRunningAllowed()
Description copied from interface: ICommunicator
Returns the flag for search and score threads of the operator whether they are allow to proceed or must stop on next occasion.

Specified by:
isRunningAllowed in interface ICommunicator
Returns:
true, if the threads are allowed to run, false if they must stop as soon as possible.

setOutputStream

public void setOutputStream(java.io.PrintStream ps)
Description copied from interface: ICommunicator
This method sets a PrintStream as new output stream. For common access to that stream use the method out(). If ps=null the NilOutputStream is set.

Specified by:
setOutputStream in interface ICommunicator
Parameters:
ps - The new stream for directing the output to it.
See Also:
ICommunicator.out(), NilOutputStream

setErrorStream

public void setErrorStream(java.io.PrintStream ps)
Description copied from interface: ICommunicator
This method sets a PrintStream as new error message output stream. For common access to that stream use the method err(). If ps=null the NilOutputStream is set.

Specified by:
setErrorStream in interface ICommunicator
Parameters:
ps - The new stream for directing the output to it.
See Also:
ICommunicator.err(), NilOutputStream

setVerboseStream

public void setVerboseStream(java.io.PrintStream ps)
Description copied from interface: ICommunicator
This method sets a PrintStream as new verbose message output stream. For common access to that stream use the method ver(). If ps=null the NilOutputStream is set.

Specified by:
setVerboseStream in interface ICommunicator
Parameters:
ps - The new stream for directing the output to it.
See Also:
ICommunicator.ver(), NilOutputStream

out

public java.io.PrintStream out()
Description copied from interface: ICommunicator
Returns the output stream to which normal output should be sent. If the output stream is not set, the default output stream is returned, which is System.out.

Specified by:
out in interface ICommunicator
Returns:
The output stream all output should be directed to.
See Also:
ICommunicator.setOutputStream(PrintStream)

err

public java.io.PrintStream err()
Description copied from interface: ICommunicator
Returns the output stream to which error messages should be sent. If the error stream is not set, this method returns the stream System.err as default.

Specified by:
err in interface ICommunicator
Returns:
The output stream all error messages should be directed to.
See Also:
ICommunicator.setErrorStream(PrintStream)

ver

public java.io.PrintStream ver()
Description copied from interface: ICommunicator
Returns the output stream to which verbose messages should be sent. Verbose messages are verifying texts which explain what the program is actually doing. If the verbose stream is not set, this method returns the stream NilOutputStream as default.

Specified by:
ver in interface ICommunicator
Returns:
The output stream all verbose messages should be directed to.
See Also:
ICommunicator.setVerboseStream(PrintStream), NilOutputStream

outputForSearchMotifs

public boolean outputForSearchMotifs(IOperator op,
                                     boolean count)
Description copied from interface: ICommunicator

Searches motifs on sequences and generates and prints the appropriate output. This method uses the given IOperator to start the searchMotifs(boolean)-method, which will get its necessary informations from the ICommunicator the given operator was created with and the parameter count.

The output created and send to comm.out() is the following. First all motif names are printed, followed by a line with '//'. Every next line holds one sequence name followed by the number of occurrences of each motif on that sequence. if count is true, then the sequence' name is printed and then for any sequence section the motif's name with its occurrences within this section.

At the beginning and at the end, some messages are created for the verbose stream comm.ver(). This messages contains the time this output method has waited for the thread to finish. Also an error message is sent to comm.err() if the thread could not be started.

Specified by:
outputForSearchMotifs in interface ICommunicator
Parameters:
op - The IOperator to start the method searchMotifs(boolean) from.
count - The method searchMotifs(boolean) get this value as parameter and it is also used to slightly change the output sent to comm.out().
Returns:
false if an error occured and no motifs were searched, true otherwise.
See Also:
IOperator.searchMotifs(boolean)

outputForWeightMotifs

public boolean outputForWeightMotifs(IOperator op)
Description copied from interface: ICommunicator

Weights motifs and generates and prints the appropriate output. This method uses the given IOperator to call the weightMotifs()-method, which will get its necessary informations from the ICommunicator the given operator was created with.

The output created and sent to comm.out() is the following. First two matrices are output, one for the positive training set named 'Raw model fingerprints' and one for the negative training set named 'Raw background fingerprints'. Every line (row) stands for a sequence from the corresponding training set. Within the rows the values (column) correspond with the motifs and give the occurrences. After both matrices a block named 'Scores:' follows holding within every line the motifs name and its calculated weight/score.

At the beginning and at the end, some messages are created for the verbose stream comm.ver(). This messages contains the time this output method has waited for the thread to finish. Also an error message is sent to comm.err() if the thread could not be started.

Specified by:
outputForWeightMotifs in interface ICommunicator
Parameters:
op - The IOperator to start the method weightMotifs() from.
Returns:
false if an error occured and no motif was weighted, true otherwise.
See Also:
IOperator.weightMotifs()

outputForScoreSequence

public boolean outputForScoreSequence(IOperator op,
                                      boolean best)
Description copied from interface: ICommunicator

Scores sequences using weighted motifs and generates and prints the appropriate output. This method uses the given IOperator to start the scoreSequence()-method, which will get its necessary informations from the ICommunicator the given operator was created with.

For every sequence scored the sequence name in FASTA format is output. For the sequence window scores itself their are two possible output mechanisms. If a cutoff other than Double.NaN was set with the given ICommunicator, the scores are comprised to bands where each band is maximal in width, does not overlap with other bands and has scores above the cutoff. For each found band the output is sequenceCounter: start-end: maximumScore; minimumScore; meanScore, e.g. 0:700210-701040: 191.3644; 126.2205; 173.7372. If no cutoff was set in the given ICommunicator or if Double.NaN was set, each line of the output contains the middle position of a sequence window together with its score.

At the beginning and at the end, some messages are created for the verbose stream comm.ver(). This messages contains the time this output method has waited for the thread to finish. Also an error message is sent to comm.err() if the thread could not be started.

Specified by:
outputForScoreSequence in interface ICommunicator
Parameters:
op - The IOperator to start the method weightMotifs() from.
best - If true, only the best score for every sequence is output. Cannot be mixed with a comprised output.
Returns:
false if an error occured and no sequence was scored, true otherwise.
See Also:
IOperator.scoreSequence()

setGraphicalOutput

public void setGraphicalOutput(boolean graphout)
Description copied from interface: ICommunicator

The graphical output is activated or deactivated. If it is activated, the result data are stored in several vectors, e.g. the one to hold score plot data can be obtained by calling getScorePlotVector.
What is stored in the respective vector relies on the methods of the operator filling it. Every call to this method sets back all vectors, either to the empty state, if the graphical output is activated or to null in case of deactivation.

Specified by:
setGraphicalOutput in interface ICommunicator
Parameters:
graphout - If true, the graphical output will be activated, otherwise deactivated.
See Also:
ICommunicator.getScorePlotVector(), ICommunicator.getMotifOccurrenceVector()

getGraphicalOutput

public boolean getGraphicalOutput()
Specified by:
getGraphicalOutput in interface ICommunicator
Returns:
true if the graphical output is wished, false otherwise.
See Also:
ICommunicator.setGraphicalOutput(boolean)

getScorePlotVector

public java.util.Vector getScorePlotVector()
Description copied from interface: ICommunicator

If the graphical output is activated, the operator stores information for the score plot in this vector. For every score on the sequence a Integer for the index and a Double for the score is stored. If the operator ends the scoring a -1 is stored.

Specified by:
getScorePlotVector in interface ICommunicator
Returns:
A Vector containing score plot data. Ends with a -1.
See Also:
ICommunicator.setGraphicalOutput(boolean), ScoredSequenceStruct

getMotifOccurrenceVector

public java.util.Vector getMotifOccurrenceVector()
Description copied from interface: ICommunicator

If the graphical output is activated, the operator stores information of found motifs in this vector. For every motif found an Integer for the index of the motif in the motif list and an Integer for its position on the sequence (negativ for rev/comp) is stored.

Specified by:
getMotifOccurrenceVector in interface ICommunicator
Returns:
A Vector containing data about found motifs.
See Also:
ICommunicator.setGraphicalOutput(boolean), FoundMotifStruct

rand

public java.util.Random rand()
Description copied from interface: ICommunicator
Returns the random number generator which is initialized when the communicator object was created.

Specified by:
rand in interface ICommunicator
Returns:
An instance of java.util.Random.

random

public double random()
Description copied from interface: ICommunicator
Returns a double random number generated with the intern random number generator. This method was introduced to reduce the method call overhead.

Specified by:
random in interface ICommunicator
Returns:
The next pseudo random double.

setSeed

public void setSeed(long seed)
Description copied from interface: ICommunicator
Sets a new seed for the random number generator.

Specified by:
setSeed in interface ICommunicator
See Also:
Random

getSeed

public long getSeed()
Description copied from interface: ICommunicator
The seed, the random number generator was initialized with is returned.

Specified by:
getSeed in interface ICommunicator
Returns:
The previous set seed for random number generator.