AFLPcore
Class LocalSouthern

java.lang.Object
  |
  +--AFLPcore.Operation
        |
        +--AFLPcore.SizeFunction
              |
              +--AFLPcore.LocalSouthern
All Implemented Interfaces:
java.lang.Cloneable

public class LocalSouthern
extends SizeFunction

This class implements the Local Southern sizing method described by E.M. Southern (Southern, E. M. "Measurement of DNA Length by Gel Electrophoresis." (1979) Analytical Biochemistry 100, 319-323.)

The equation

         c
  L = --------- + Lo
       m - Mo
 
is used, where L is the size of the unknown fragement, m is the mobility (scan number) of the fragment, and c, Mo, and Lo are constants. The constants are determined in the following manner. Fragments of known size (from the size standard) are used as known values for L and m. For every set of three standard points, a curve is defined. Let the point (xi, yi) denote a standard point, where xi is the mobility of the known fragement and yi is the size of the known fragement. These three points give us the following system of equations:
          c
  y1 = ------- + Lo         (1)
       x1 - Mo
 
          c
  y2 = ------- + Lo         (2)
       x2 - Mo
 
          c
  y3 = ------- + Lo         (3)
       x3 - Mo
 
Solving this system of equations yields:
       -(-x3 + x2) (-x3 + x1) (x1 - x2) (-y3 + y2) (y1 - y3) (-y2 + y1)
  c =  ----------------------------------------------------------------
                                                            2
            (-y1 x3 + y2 x3 - y2 x1 + x2 y1 - x2 y3 + x1 y3)
 
       - (-y1 x1 y3 + y1 y3 x3 - y2 x2 y1 + y2 x2 y3 - y2 y3 x3 + y2 y1 x1)
 Lo =  --------------------------------------------------------------------
            (-y1 x3 + y2 x3 - y2 x1 + x2 y1 - x2 y3 + x1 y3)
 
         (-y2 x2 x1 + y2 x2 x3 - y1 x1 x3 + x1 y3 x3 - x2 y3 x3 + x2 y1 x1)
 Mo =  --------------------------------------------------------------------
            (-y1 x3 + y2 x3 - y2 x1 + x2 y1 - x2 y3 + x1 y3)
 
However, a problem is encountered when all three of the standard points used are on a line. In this case, the denominator (which is the same for all three constants) becomes 0. When that happens, this class abandons the equation suggested by E.M. Southern and instead uses a line for the curve between those two points.

To size an unknown fragment, the following method is used. For most fragements, the average of two curves will be used to find the size. The first curve will be defined by two standard points below the unknown fragement and one above. The second curve will be defined by one standard point below and two above. (Above and below are determined by scan number.) Remember that one (or both) of these curves can be linear. In the case that the unknown fragement is near the beginning or the end of the size standard ranges, only one curve is used. For example, if the curve with only one size standard point below includes the first size standard point, the curve with two points below does not exists. For points smaller than the first size standard point, a line is used. The line is defined by the first size standard point and by assuming the size at scan number 0 is 0. For points greater than the largest size standard point, the curve for the last three points is simply extended. Note: This is not very accurate at all for points outside of the defined size standards! For those points inside, the sizing agrees with that of the ABI software and appears to be reliable. Therefore, it is recommended that only the points between defined size standards be used.

This class also allows one to convert from base pairs to scan numbers. This answer is not unique (see below). However, in almost every case, one of the answers is clearly out of bounds. The bounds are defined such that if a fragements size is between two standard points, it's scan number must also be between the two size standards. If the correct value cannot be determined, the class will print out an error message to the standard output and then take the smaller value.

The conversion back is broken down into three cases, a size derived from two curves, a line and a curve, and two lines. For two curves, the size s is defined as:

       c1/(m - m1) + L1 + c2/(m - m2) + L2
  s = -------------------------------------
                       2
 
solving for m yeilds:
                -c1m2 - c2m1             2
  m = f + sqrt(--------------  - m1m2 + f )
                2s - L1 - L2
 
or
                -c1m2 - c2m1             2
  m = f - sqrt(--------------  - m1m2 + f )
                2s - L1 - L2
 
where
       1            c1 + c2
  f =  - ( m1m2 + -----------)
       2          2s - L1 -L2
 
For a curve and a line, the size is determined by:
        c/(m -mo) + Lo + am + b
  s =  --------------------------
                   2
 
solving yields:
       g + sqrt(g^2 - 4a(mo*d + c))          g - sqrt(g^2 - 4a(mo*d + c))
  m = -----------------------------, or m = ------------------------------
                 2a                                    2a
 
where
  d = 2s - Lo - b          g = amo + d
 
Finally, for two lines, the solution is trivial and unique. This is because if points a, b, and c are on a line and points b, c, and d are on a line, then a and d must be on the same line.

Overall, this class performs the conversions between base pairs and scan numbers required by the program.

See Also:
Lane, SizeFunction, SizeMgr, FeatureList

Fields inherited from class AFLPcore.Operation
descript, helpFile, name, options
 
Constructor Summary
LocalSouthern()
           
 
Method Summary
 java.lang.String getDescription()
          Gives a brief description of this sizing function.
 java.lang.String getHelpFile()
          Gives the help file that describes the function in more detail
 java.lang.String getName()
          Gives the name describing this sizing function.
 Option[] getOptions()
          There are no options for this sizing function.
 int getScan(double size)
          Gives the scan number that will produce the specified size.
 double getSize(int scan)
          Gives the size in bp from the scan number, using the method described in the class description.
 void init(DataList standardPeaks)
          This takes a list of peaks with the location containing the size in base pairs, and the AREA must contain the scan number of that peak.
 void read(java.io.DataInputStream in)
          Reads in the properties of this class from the specified input stream.
 void setMaxScan(int max)
          Sets the maximum scan number to the specified value.
 void setOptions(Option[] opts)
          Since there are no options, this method doesn't do much.
 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 AFLPcore.SizeFunction
clone
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LocalSouthern

public LocalSouthern()
Method Detail

getName

public java.lang.String getName()
Gives the name describing this sizing function.
Overrides:
getName in class Operation
Returns:
the name

getDescription

public java.lang.String getDescription()
Gives a brief description of this sizing function.
Overrides:
getDescription in class Operation
Returns:
a one sentence explination.

getHelpFile

public java.lang.String getHelpFile()
Gives the help file that describes the function in more detail
Overrides:
getHelpFile in class Operation
Returns:
a plaintext of html help file.

getOptions

public Option[] getOptions()
There are no options for this sizing function.
Overrides:
getOptions in class Operation
Returns:
null

setOptions

public void setOptions(Option[] opts)
Since there are no options, this method doesn't do much. In fact, it does absolutely nothing, but it is required by the abstract class Operation, which this class is a child of.
Overrides:
setOptions in class Operation
Following copied from class: AFLPcore.Operation
Parameters:
opts - the values for the options that this operation understands.

init

public void init(DataList standardPeaks)
This takes a list of peaks with the location containing the size in base pairs, and the AREA must contain the scan number of that peak. This method must be called since it uses the data points to calculate the constants for the different curves. See the class description for an explination of the sizing function. Some parts of this method are not very efficient, but since it will not be run very often, it is not a big problem.
Overrides:
init in class SizeFunction
Parameters:
standardPeaks - a list of peaks with the area containing the scan number and the location having the size in bp.

setMaxScan

public void setMaxScan(int max)
Sets the maximum scan number to the specified value. This is useful to the class since it cannot always tell which possible answer for a scan number is correct.
Overrides:
setMaxScan in class SizeFunction
Parameters:
max - the largest possible scan number that should be returned by getScan(double).
See Also:
LocalSouthern

getSize

public final double getSize(int scan)
Gives the size in bp from the scan number, using the method described in the class description. This method will probably get a lot of use, so it needs to execute as quickly as possible.
Overrides:
getSize in class SizeFunction
Parameters:
scan - the scan number
Returns:
the size in bp.

getScan

public final int getScan(double size)
Gives the scan number that will produce the specified size. This method will perform the inverse operation compared to getSize. Remember that due to rounding errors, these two methods may not be exact inverses. Also, it is likely that this method will be called frequently, so it should be as fast as possible. The setMaxScan should be used to assist this method. It will tell the method what the largest possible value is, which will help it determine which possible scan number is the correct one.
Overrides:
getScan in class SizeFunction
Parameters:
size - the size in bp
Returns:
the scan number
Throws:
ScanCalcError - occurs when the method cannot determine the correct scan number. Since the size is determined by an average of two values, the scan number that produces it may not be unique. Most of the time one can be discarded, but if not this exception will occur. The class description contains more info. Currently, this exception is not thrown and output is dumped to standard out instead. The smaller of the two values is taken so that the program can continue.
See Also:
LocalSouthern

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 current data in the class will be replaced.
Overrides:
read in class SizeFunction
Parameters:
in - the input stream with the data for the class.
Throws:
java.io.IOException - occurs when a problem is encountered when reading from the stream.

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.
Overrides:
write in class SizeFunction
Parameters:
out - the destination to write the data to.
Throws:
java.io.IOException - occurs when a problem is encountered when writing to the stream.