AFLPcore
Class Bin

java.lang.Object
  |
  +--AFLPcore.Data
        |
        +--AFLPcore.SortableData
              |
              +--AFLPcore.Bin

public class Bin
extends SortableData

This class represents a bin, which is simply a region defined in a gel. It also contains a ScoreFunction. This is responsible for interpreting the data inside of the bin. The bin also contains the label assigned to each lane by the score function.

See Also:
ScoreFunction

Constructor Summary
Bin(double loc)
          Creates a new bin with the specified parameters.
Bin(double loc, double range)
          Creates a new bin with the specified parameters.
Bin(double loc, double range, ScoreFunction score)
          Creates a new bin with the specified parameters.
 
Method Summary
 void adjustLocation(double adjustment)
          Moves the bin to a new location based on it's present location.
 void adjustRange(double adjustment)
          Changes the range relative to the current value of the range.
 java.lang.Object clone()
          Produces a new bin identical to this one, except it has not been scored.
 double getLocation()
          Gives the position of this bin in the gel.
 java.lang.String getName()
          Gives the name of this bin.
 double getRange()
          Gives the range of the bin.
 java.lang.String getScore(Lane ln)
          Gives the string representing how the given lane was scored.
 java.lang.String[] getScoreInfo()
          Gives the overall score info for the bin.
 ScoreFunction getScoreMethod()
          Gives the method used to score a bin.
 double getSearchKey()
          Gives the value used to search/sort bins.
 boolean isScored()
          Used to tell whether or not the score method has been called on this bins current configuration.
 void read(java.io.DataInputStream in)
          Reads in the properties of this class from the specified input stream.
 void score(DataList lanes)
          Scores this bin using the scoring method set and the lanes specified.
 void scoreOverall(DataList lanes)
          Sets the overall scoring information for the bin.
 void setLocation(double location)
          Sets the position/location of this bin to the one specified.
 void setName(java.lang.String name)
          Sets the name of the bin to the specified value.
 void setRange(double range)
          Sets the range of the bin to the specified value.
 void setScore(boolean scored)
          Sets the bin so that the current scoring is either accepted as valid or invalidated.
 void setScore(Lane ln, java.lang.String value)
          Changes the scoring for the specified lane.
 void setScoreMethod(ScoreFunction scorer)
          Sets the scoring method to the one specified.
 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
 

Constructor Detail

Bin

public Bin(double loc)
Creates a new bin with the specified parameters.
Parameters:
loc - the location, in bp, of the bin on the gel.

Bin

public Bin(double loc,
           double range)
Creates a new bin with the specified parameters.
Parameters:
loc - the location, in bp, of the bin on the gel.
range - the range of the bin, agan in bp.

Bin

public Bin(double loc,
           double range,
           ScoreFunction score)
Creates a new bin with the specified parameters.
Parameters:
loc - the location, in bp, of the bin on the gel.
range - the range of the bin, agan in bp.
score - the method used to score the bin.
Method Detail

getSearchKey

public final double getSearchKey()
Gives the value used to search/sort bins.
Overrides:
getSearchKey in class SortableData
Returns:
the bins location

getScoreMethod

public ScoreFunction getScoreMethod()
Gives the method used to score a bin. That is to say, how the bin interprets the presense/absence/other of peaks in a bin. For example, one could call all those with a peak 'A' and those without 'B'. The score method could count and return the number of 'A's and the number of 'B's.
Returns:
The method used to score the bin.
See Also:
setScoreMethod(AFLPcore.ScoreFunction)

setScoreMethod

public void setScoreMethod(ScoreFunction scorer)
Sets the scoring method to the one specified.
Parameters:
scorer - The method to use on this bin.
See Also:
getScoreMethod()

score

public void score(DataList lanes)
Scores this bin using the scoring method set and the lanes specified.
Parameters:
lanes - the lanes to include in the bin.

scoreOverall

public void scoreOverall(DataList lanes)
Sets the overall scoring information for the bin. The manner in which each lane was scored is given to the score method currently set. It also gives a list of all of the peaks of interest to the scoring method. "Of interest" is defined by the score function by marking certain peaks. For example, the score method could count the number of A's and B's as well as provide a mean for the peak location.
Parameters:
lanes - the lanes to include in the overall scoring of this bin
See Also:
getScoreInfo(), ScoreFunction, Peak.isMarked()

getScore

public java.lang.String getScore(Lane ln)
Gives the string representing how the given lane was scored.
Parameters:
ln - the lane to retrieve the score for
Returns:
the score found by the scoring method
See Also:
getScoreMethod(), setScoreMethod(AFLPcore.ScoreFunction)

setScore

public void setScore(Lane ln,
                     java.lang.String value)
Changes the scoring for the specified lane. Only the value in the table is changed by this method, so in future, it could be replaced if the table is changed and it will not affect any of the peaks. Appropriate values can be retrieved from the ScoreFuction set for this bin.
Parameters:
ln - the lane to change
value - the new score for the lane, which should be one of the choices offered by the current score method.
See Also:
getScoreMethod(), ScoreFunction.getChoices(int)

getScoreInfo

public java.lang.String[] getScoreInfo()
Gives the overall score info for the bin. The information is determined from from the peaks used to score the bin and the label assigned to each lane in the bin. Each entry in the array should be a separate line. The informatin could be as simple as the number of lanes, or it could be something like the mean location of all the peaks in the bin.
Returns:
an array containing information on the bin scoring.
See Also:
ScoreFunction, scoreOverall(AFLPcore.DataList)

isScored

public boolean isScored()
Used to tell whether or not the score method has been called on this bins current configuration. For example, if the bin is moved, it needs to be rescored.
Returns:
true if the bin still has a valid scoring.

setScore

public void setScore(boolean scored)
Sets the bin so that the current scoring is either accepted as valid or invalidated.
Parameters:
scored - true if the current scoring is to be valid.

getLocation

public double getLocation()
Gives the position of this bin in the gel.
Returns:
the location specified in bp.

setLocation

public void setLocation(double location)
Sets the position/location of this bin to the one specified.
Parameters:
location - the new position for the bin

adjustLocation

public void adjustLocation(double adjustment)
Moves the bin to a new location based on it's present location.
Parameters:
adjustment - the distance to move the bin, which may be either positive or negative.

getRange

public double getRange()
Gives the range of the bin. The range of the bin is the distance from the location to the edge of the bin. Therefore, the bin is 2*range bp wide.
Returns:
the range as described above

setRange

public void setRange(double range)
Sets the range of the bin to the specified value. The range of the bin is the distance from the location to the edge of the bin. Therefore, the bin is 2*range bp wide.
Parameters:
range - the new value for the range as described above

adjustRange

public void adjustRange(double adjustment)
Changes the range relative to the current value of the range. The range of the bin is the distance from the location to the edge of the bin. Therefore, the bin is 2*range bp wide.
Parameters:
adjustment - the value to increment the range by. This value can be either positive or negative.

setName

public void setName(java.lang.String name)
Sets the name of the bin to the specified value. By default, a bin has a name of "", the empty String.
Parameters:
name - the new name for the bin.

getName

public java.lang.String getName()
Gives the name of this bin. By default, a bin has a name of "", the empty String. In this case, the location of the bin is a much better identifier.
Returns:
the name of the bin.

clone

public java.lang.Object clone()
Produces a new bin identical to this one, except it has not been scored.
Overrides:
clone in class Data
Returns:
a new bin with the same properties as this one.

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.

Warning: this method cannot read in the scoring values because of the way that they are stored, specifically by lane. However, the lanes are not available to this method, so the information cannot be stored. A class calling this method should make provisions to take care of the rest of the data stream. The method setScore can be used to set the value, it takes a lane value pair and records it. The stream will be left at the start of the values. The first thing will be an integer giving the number of entries stored in the stream. It will be followed by pairs of laneIndexies and values. The laneIndexies are integers and the values are UTF-encoded Strings.

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.
See Also:
setScore(AFLPcore.Lane, java.lang.String)