AFLPcore
Class Cutoff

java.lang.Object
  |
  +--AFLPcore.Data
        |
        +--AFLPcore.SortableData
              |
              +--AFLPcore.Cutoff
All Implemented Interfaces:
java.lang.Cloneable

public class Cutoff
extends SortableData
implements java.lang.Cloneable

This class represents different cutoffs for a lane. This is used by ScoreFunction classes to determine how to score things. Each cutoff consists of a starting position (in bp) and a number of levels. Each level can be a different CutoffFunction. The levels must have an order. The smallest levels should be those with the smallest cutoff value. Since some functions are not linear, the ordering will be based at the cutoff value at the start position.

See Also:
ScoreFunction, CutoffFunction, Lane

Field Summary
static int AREA
           
static int HEIGHT
           
 
Constructor Summary
Cutoff(double startPos, int numLevels)
          Creates a new cutoff with the specified number of levels and starting at the specified position.
 
Method Summary
 void addFunction(CutoffFunction newFunction)
          Adds the specified function to this cutoff.
 java.lang.Object clone()
          Gives an object where all of the data is the same as this one.
 void deleteFunction(int level)
          Removes the specified level from this cutoff.
 double getCutoff(double size, int level)
          Gives the value for the height/area above which all peaks should be counted with a confidence relative to the level.
 CutoffFunction getCutoffFunction(int level)
          Gives the cutoff function for the specified level.
 int getMode()
          Gives the current cutoff mode, either height or area.
 int getNumLevels()
          Gives the number of different cutoff levels supported by this object.
 double getSearchKey()
          Gives the starting position for this cutoff.
 double getStartPos()
          Gives the starting position for this cutoff.
 void read(java.io.DataInputStream in)
          Reads in the properties of this class from the specified input stream.
 void setCutoffFunction(CutoffFunction func, int level)
          Sets the cutoff function for the specified level.
 void setMode(int modeSelector)
          Sets the cutoff so that it applies either to peak height or to peak area.
 void setStartPos(double newPosition)
          Adjusts the starting position.
 void write(java.io.DataOutputStream out)
          Writes all of the information this class needs to store in order to be recreated.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

AREA

public static final int AREA

HEIGHT

public static final int HEIGHT
Constructor Detail

Cutoff

public Cutoff(double startPos,
              int numLevels)
Creates a new cutoff with the specified number of levels and starting at the specified position.
Parameters:
startPos - the size in bp at which the cutoff first applies
numLevels - the number of different cutoff supported by this level
Method Detail

getSearchKey

public final double getSearchKey()
Gives the starting position for this cutoff.
Overrides:
getSearchKey in class SortableData
Returns:
the start size, in bp.

getStartPos

public final double getStartPos()
Gives the starting position for this cutoff.
Returns:
the start size, in bp.

setStartPos

public void setStartPos(double newPosition)
Adjusts the starting position. Warning: if this is in a sorted list, this must be used with caution since it could alter the order that the elements should be in, but does not rearrange any list.

getNumLevels

public int getNumLevels()
Gives the number of different cutoff levels supported by this object. Each level can be associated with different confidences. For example, something above the first cutoff level would most likely be a peak, but something over only the second cutoff level might be a peak.
Returns:
The maximum number of levels that can be supported.

setMode

public void setMode(int modeSelector)
Sets the cutoff so that it applies either to peak height or to peak area. The values for these are constants in this class.
Parameters:
modeSelector - either AREA or HEIGHT
Throws:
java.lang.IllegalArgumentException - occurs if modeSelector isn't one of the accepted values.

getMode

public int getMode()
Gives the current cutoff mode, either height or area.
Returns:
either AREA or HEIGHT

getCutoffFunction

public CutoffFunction getCutoffFunction(int level)
Gives the cutoff function for the specified level.
Parameters:
level - the confidence level, must be >= 0 and < numLevels.
Returns:
the function used at the given level.
Throws:
java.lang.IllegalArgumentException - occurs if level fails to meet the above.

setCutoffFunction

public void setCutoffFunction(CutoffFunction func,
                              int level)
Sets the cutoff function for the specified level.
Parameters:
func - the function used to determine the cutoff.
level - the confidence level, must be >= 0 and < numLevels.
Throws:
java.lang.IllegalArgumentException - occurs if level fails to meet the above.

getCutoff

public double getCutoff(double size,
                        int level)
Gives the value for the height/area above which all peaks should be counted with a confidence relative to the level.
Parameters:
size - the size in bp to determine the cutoff value for.
level - the confidence level, must be >= 0 and < numLevels.
Throws:
java.lang.IllegalArgumentException - occurs if level fails to meet the above.

addFunction

public void addFunction(CutoffFunction newFunction)
Adds the specified function to this cutoff. Therefore, the number of levels in the cutoff is increased accordingly. The new function is added at a level so that the level ordering, lower values are at lower levels, is maintained.
Parameters:
newFunction - the function to add to this cutoff, it's height should already be set to the desired value.

deleteFunction

public void deleteFunction(int level)
Removes the specified level from this cutoff. The number of levels in the cutoff is decreased accordingly.
Parameters:
level - the level to remove.

clone

public java.lang.Object clone()
Gives an object where all of the data is the same as this one.
Overrides:
clone in class Data
Returns:
a copy of this object.

write

public void write(java.io.DataOutputStream out)
           throws java.io.IOException
Writes all of the information this class needs to store in order to be recreated. This will be used for things like storing the class in a file. Therefore, the write should output enough information so that read can recreate the essential properties of this class.
Parameters:
out - the destination to write the data to.
Throws:
java.io.IOException - occurs when a problem is encountered when writing to the stream.

read

public void read(java.io.DataInputStream in)
          throws java.io.IOException
Reads in the properties of this class from the specified input stream. The stream data should have been created by write. This will retrieve this classes state from the input stream. All of the current data in this class will be replaced by the data from the stream.
Parameters:
in - the input stream with the data for the class.
Throws:
java.io.IOException - occurs when a problem is encountered when writing to the stream.