de.unibi.techfak.jpredictor.operator
Class OptionFile

java.lang.Object
  extended by de.unibi.techfak.jpredictor.operator.OptionFile

public class OptionFile
extends java.lang.Object

The class for summoning the methods needed to evaluate an option file. Note, that for motif definition names must be unique.


Field Summary
private static ICommunicator comm
          The ICommunicator for this class.
(package private) static java.lang.String[] motifTypes
          The types of motifs within the section [Motif]
(package private) static int SECTION_COUNT
           
(package private) static int SECTION_MMLIST
           
(package private) static int SECTION_MOTIF
           
(package private) static int SECTION_MULTIMOTIF
           
(package private) static int SECTION_NONE
          Enumeration of section names for sections-in-file recognition.
(package private) static int SECTION_SEQUENCE
           
(package private) static java.lang.String[] sectionNames
          The names of the sections in the file
(package private) static java.lang.String[] sequenceParam
          The parameter in the section [Sequence].
 
Constructor Summary
OptionFile()
           
 
Method Summary
static boolean recognize(java.lang.String filename, ICommunicator comm, MotifList mls, MotifList mld)
          This method opens and recognizes the content of the option file.
private static void recognizeMotif(java.lang.String filecontent, MotifList mls, MotifList mld, int line)
          Trys to recognize a motif in the given string.
private static void recognizeMultiMotif(java.lang.String filecontent, MotifList mls, MotifList mld, int line)
          Trys to recognize a MultiMotif.
private static void recognizeMultiMotifList(java.lang.String filecontent, MotifList mls, MotifList mld, int line)
          Trys to recognize many MultiMotifs from a list definition.
private static void recognizeSequence(java.lang.String filecontent, ICommunicator comm, int line)
          Trys to recognize the [Sequence] section of an option file.
static void writeMotifList(java.io.PrintStream f, MotifList mlConst)
          This method writes the given MotifList to the stream in a way that it can be recognized again.
private static void writeMultiMotif(java.io.PrintStream f, MultiMotif m, boolean usable)
          Output all stats for a MultiMotif.
static void writeSettings(java.io.PrintStream f, ICommunicator comm)
          This method opens a file and writes the settings taken from the given communicator to a file.
private static void writeSingleMotif(java.io.PrintStream f, Motif m, boolean usable)
          Output all stats for a single motif.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

comm

private static ICommunicator comm
The ICommunicator for this class. It is set by the methods recognize(String, ICommunicator, MotifList, MotifList) and save(String, boolean, ICommunicator, MotifList) and used by every other method present to output things.


sectionNames

static java.lang.String[] sectionNames
The names of the sections in the file


SECTION_NONE

static final int SECTION_NONE
Enumeration of section names for sections-in-file recognition.

See Also:
Constant Field Values

SECTION_MOTIF

static final int SECTION_MOTIF
See Also:
Constant Field Values

SECTION_MULTIMOTIF

static final int SECTION_MULTIMOTIF
See Also:
Constant Field Values

SECTION_MMLIST

static final int SECTION_MMLIST
See Also:
Constant Field Values

SECTION_SEQUENCE

static final int SECTION_SEQUENCE
See Also:
Constant Field Values

SECTION_COUNT

static final int SECTION_COUNT
See Also:
Constant Field Values

sequenceParam

static java.lang.String[] sequenceParam
The parameter in the section [Sequence].


motifTypes

static java.lang.String[] motifTypes
The types of motifs within the section [Motif]

Constructor Detail

OptionFile

public OptionFile()
Method Detail

recognize

public static boolean recognize(java.lang.String filename,
                                ICommunicator comm,
                                MotifList mls,
                                MotifList mld)
This method opens and recognizes the content of the option file. See 'README' for instruction to write one.

Parameters:
filename - The name of the option file.
comm - The communicator which gets the settings.
mls - The list of motifs, to which the single motifs found are added.
mld - The list of motifs, to which the multi motifs found are added.
Returns:
false, if the file was not found, true otherwise.

recognizeSequence

private static void recognizeSequence(java.lang.String filecontent,
                                      ICommunicator comm,
                                      int line)
Trys to recognize the [Sequence] section of an option file. That section is completely given as String filecontent, with '\n' as delimiter between lines. In every line special predefined parameters are searched, just like 'sequence_filename'. All informations found are add to the communicator.

Parameters:
filecontent - The line by line file content, separated by "\n".
comm - The ICommunicator to add the information found into.
line - The line where the filecontent starts.

recognizeMultiMotifList

private static void recognizeMultiMotifList(java.lang.String filecontent,
                                            MotifList mls,
                                            MotifList mld,
                                            int line)
Trys to recognize many MultiMotifs from a list definition. The string might come from a file and consists of lines sperated by '\n'. In every line special predefined parameters are searched, just like 'name', 'description' and others. All MultiMotifs recognized are added to the MotifList mld. The filecontent is not searched for comments, they should have been deleted befor.

Parameters:
filecontent - The line by line file content, separated by "\n".
mls - The list of motifs whos names are compared.
mld - The MotifList to add the motif to.
line - The line where the filecontent starts.

recognizeMultiMotif

private static void recognizeMultiMotif(java.lang.String filecontent,
                                        MotifList mls,
                                        MotifList mld,
                                        int line)
Trys to recognize a MultiMotif. The String 'filecontent' can come from a file and consists of lines seperated by new line. In every line special predefined parameters are searched, just like 'name', 'description' and others.
The string filecontent is not searched for comments, they must have been deleted befor. Note, that for correct recognition of line numbers the remaining empty lines should be part of the string.
Both given motif lists are searched for the motifs named to build this multi motif. If the multi motif should be used for searching it is stored to 'mld' (default), otherwise to 'mls'.

Parameters:
filecontent - The line by line file content, separated by "\n".
mls - List of motifs which are not used for searching.
mld - List of motifs which are used for searching later on.
line - The line where the filecontent starts.

recognizeMotif

private static void recognizeMotif(java.lang.String filecontent,
                                   MotifList mls,
                                   MotifList mld,
                                   int line)
Trys to recognize a motif in the given string. The string can come from a file and consists of lines. In every line special predefined parameters are searched, just like 'name', 'description' and others. The motif, if it is correctly recognized, is added to the MotifList.
The string filecontent is not searched for comments, they must have been deleted befor. Note, that for correct recognition of line numbers the remaining empty lines should be part of the string.

Parameters:
filecontent - The line by line file content, separated by "\n".
mls - List of motifs which are not used for searching.
mld - List of motifs which are used for searching later on.
line - The line where the filecontent starts.

writeMotifList

public static void writeMotifList(java.io.PrintStream f,
                                  MotifList mlConst)
This method writes the given MotifList to the stream in a way that it can be recognized again. Does nothing if either f or mlConst is null.

Parameters:
f - The PrintStream to write to.
mlConst - The list of motifs to get output.

writeSingleMotif

private static void writeSingleMotif(java.io.PrintStream f,
                                     Motif m,
                                     boolean usable)
Output all stats for a single motif. This method is not designed for writing MultiMotifs.

Parameters:
f - The stream to write the output to.
m - The single motif to output.
usable - Whether the motif should occur in the list or not.

writeMultiMotif

private static void writeMultiMotif(java.io.PrintStream f,
                                    MultiMotif m,
                                    boolean usable)
Output all stats for a MultiMotif. This method is not designed for writing single motifs.

Parameters:
f - The stream to write the output to.
m - The motif to output.
usable - Whether the motif should occur in the list or not.

writeSettings

public static void writeSettings(java.io.PrintStream f,
                                 ICommunicator comm)
This method opens a file and writes the settings taken from the given communicator to a file. For this, it starts a new [Sequence]-section in the file.

Parameters:
f - The PrintStream to write to.
comm - The communicator to which error messages are sent and from which the settings are taken