de.unibi.techfak.jpredictor.operator
Class ScoringFactory

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

public class ScoringFactory
extends java.lang.Object

Class for working on scores, such as cutoff calculations, band summery and so on. The different init method decide how this factory works.


Field Summary
private static ScoreBand actBandAboveCutoff
          Stores the last band where at least the first and the last scores are above the cutoff.
private static ScoreBand actBandBelowCutoff
          Stores the last band with all scores actually below the cutoff.
private static java.util.Vector bands
          Stores all bands found so far.
private static int[] cccBandCounter
          For every possible cutoff the absolute number of bands is stored here.
private static int[] cccBandEndpos
          For every possible cutoff the mid-window positions of the last score exceeding the cutoff is stored here.
private static int cccStartScore
          The starting score for which the band count and band end position is stored at index zero in the appropriate arrays.
private static double cutoff
          Stores the maximum of all scores processed.
private static ScoredSequenceStruct max
          Stores the maximum of all scores processed.
private static ScoredSequenceStruct min
          Stores the minimum of all scores processed.
private static int task
          Does specify the tasks this factory is allowed to perform.
static int TASK_COMPRISE_SCORES
          This field can be given the init method to turn score comprising on.
static int TASK_CUTOFF_CALC
          This field can be given the init method to turn cutoff calculation on.
 
Constructor Summary
ScoringFactory()
           
 
Method Summary
static java.util.Vector getCutoffTable()
          Gives a table over all possible cutoffs together with the number of bands for every cutoff.
static ScoredSequenceStruct getMaxScore()
          Gives the maximum of all scores processed by this factory.
static ScoredSequenceStruct getMinScore()
          Gives the minimum of all scores processed by this factory.
static ScoreBand getScoreBand()
          Returns a band of scores above the cutoff.
static void init(int task, double cutoff)
           Tells the factory what tasks to perform and sets some parameters for the different tasks.
static void processScore(ScoredSequenceStruct found)
           Process a given score, that is, joins the score to the results of previous calculations.
static void reset()
          Instructs the factory to reset all static members but keeps the task and the cutoff.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TASK_CUTOFF_CALC

public static final int TASK_CUTOFF_CALC
This field can be given the init method to turn cutoff calculation on. A cutoff calculation yields as a results the number of bands for any possible cutoff.

See Also:
init(int, double), Constant Field Values

TASK_COMPRISE_SCORES

public static final int TASK_COMPRISE_SCORES
This field can be given the init method to turn score comprising on. The score comprising algorithm yields as a result for a given cutoff all comprised bands which have scores mainly above that cutoff.

See Also:
init(int, double), Constant Field Values

task

private static int task
Does specify the tasks this factory is allowed to perform. Per default this factory always keeps track of minimum and maximum score. All other tasks have to explicitely turned on by calling the appropriate init-method.


cutoff

private static double cutoff
Stores the maximum of all scores processed.


max

private static ScoredSequenceStruct max
Stores the maximum of all scores processed.


min

private static ScoredSequenceStruct min
Stores the minimum of all scores processed.


actBandAboveCutoff

private static ScoreBand actBandAboveCutoff
Stores the last band where at least the first and the last scores are above the cutoff.


actBandBelowCutoff

private static ScoreBand actBandBelowCutoff
Stores the last band with all scores actually below the cutoff.


bands

private static java.util.Vector bands
Stores all bands found so far.


cccBandCounter

private static int[] cccBandCounter
For every possible cutoff the absolute number of bands is stored here. Used for cutoff calculation.


cccBandEndpos

private static int[] cccBandEndpos
For every possible cutoff the mid-window positions of the last score exceeding the cutoff is stored here. Used for cutoff calculation.


cccStartScore

private static int cccStartScore
The starting score for which the band count and band end position is stored at index zero in the appropriate arrays. Used for cutoff calculation.

See Also:
cccBandCounter, cccBandEndpos
Constructor Detail

ScoringFactory

public ScoringFactory()
Method Detail

reset

public static void reset()
Instructs the factory to reset all static members but keeps the task and the cutoff. This method simple calls the init-method with the former task and cutoff settings used.

See Also:
init(int, double)

init

public static void init(int task,
                        double cutoff)

Tells the factory what tasks to perform and sets some parameters for the different tasks. The simplest task the factory does always perform is keeping track of minimum and maximum score. Additionally, the factory can be told to either do a cutoff calculation or to comprise scores above a certain cutoff to bands. A band consists of overlapping sequence windows which mainly exceed the given cutoff.

A call to this method resets all static members of this class. To instruct the factory what to do with the scores call this method in the first place. To reset the factory call the reset-method which does not clear the task and cutoff field.

Parameters:
task - Describes the tasks the factory is meant to perform on scores. Its a bit pattern, fill it using the constants from this class.
cutoff - Sets a cutoff for band calculation, give Double.NaN if band calculation is switched off.
See Also:
reset(), TASK_COMPRISE_SCORES, TASK_CUTOFF_CALC

processScore

public static void processScore(ScoredSequenceStruct found)

Process a given score, that is, joins the score to the results of previous calculations. Actually, the calculation methods performed with this call are: (1) keeping track of the minimum and (2) the maximum score, (3) comprising the scores to bands and (4) counting the number of bands for every cutoff possible. While the minimum and maximum calculations and the band counting do work for scores with different sequence numbers, the comprising (task 3) starts new bands every time the sequence number changes.

If found is null all calculations are forced to store their last results. For the calculation of comprised bands it would mean to terminate and store the last band. For the cutoff calculation it means to finish all bands, so that every new score delivered counts as new band for all possible cutoffs. Calling this method with null as parameter does not neccessarily mean a reset to the underlying variables in this factory. To peform a reset and make sure that every calculation starts from scratch call the reset-method.

Note, that if any calculation method needs to save the gotten struct it is cloned before it is stored.

Parameters:
found - The score on a sequence window to be processed.
See Also:
init(int, double), reset()

getScoreBand

public static ScoreBand getScoreBand()
Returns a band of scores above the cutoff. If score comprising is switched off (no cutoff was set in the init-methods) or if no band is currently available, null is returned.

Returns:
A band of scores above the cutoff or null.

getMaxScore

public static ScoredSequenceStruct getMaxScore()
Gives the maximum of all scores processed by this factory.

Returns:
The maximum of all scores processed or null if nothing was processed.

getMinScore

public static ScoredSequenceStruct getMinScore()
Gives the minimum of all scores processed by this factory.

Returns:
The minimum of all scores processed or null if nothing was processed.

getCutoffTable

public static java.util.Vector getCutoffTable()
Gives a table over all possible cutoffs together with the number of bands for every cutoff. All values in the returned vector are Integer. The table is of the form: cutoff1, #bands1, cutoff2, #bands2, cutoff3, ...

Returns:
A table filled with cutoff and corresponding number of bands or null if no valid score was processed yet.