org.aisb.bio.tools
Class Needleman

java.lang.Object
  extended byorg.aisb.bio.tools.SequenceAligner
      extended byorg.aisb.bio.tools.Needleman

public class Needleman
extends SequenceAligner

This implements the Needleman/Wunsch algorithm, with gap penalties, including end gap penalties. This version gets the gap penalties correct. Another recent change is in the traceback matrix. Now, instead of each cell holding "0" or "1", it essentially holds the number of alignments known as of that location in the matrix. Known problems: I did not have time to implement the options I wanted to for printing out the sequences alignments. They're all calculated, in the "traceback" matrix. Generating one string from that matrix is easy (and done); generating the full set turned out to take more time than I had allotted for this task.

Author:
Doug DeJulio

Constructor Summary
Needleman(MonomerComparator comparator, int gapCreationPenalty, int gapExtensionPenalty)
          This constructor is a little cleaner to use outside of contexts in which the command bean is really useful.
 
Method Summary
 void execute()
          Perform the operation.
 java.lang.String getAlignmentAsString(int n)
           
 java.lang.String getBestAlignmentAsString()
          Get the actual best alignment, in the form of a string consisting of tuples representing positions in the alignment.
 java.lang.Character[][] getBestAlignmentsAsMatrix()
          Get the set of best alignments, in the form of a matrix.
 java.lang.String[] getBestAlignmentsAsStrings()
          Get the set of best alignments, in the form of an array of strings consisting of tuples representing positions in the alignment.
 int getBestAlignmentScore()
          Get the best alignment score, as defined by this algorithm.
 MonomerComparator getComparator()
          Set the comparator to use to match each pair of elements.
 int getGapCreationPenalty()
           
 int getGapExtensionPenalty()
           
 int getNumberOfAlignments()
          Get the number of alignments that have the best score.
 void setComparator(MonomerComparator comparator)
          Returns the comparator currently in use.
 void setGapCreationPenalty(int gapCreationPenalty)
           
 void setGapExtensionPenalty(int gapExtensionPenalty)
           
 
Methods inherited from class org.aisb.bio.tools.SequenceAligner
getFirstSequence, getSecondSequence, setFirstSequence, setSecondSequence
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Needleman

public Needleman(MonomerComparator comparator,
                 int gapCreationPenalty,
                 int gapExtensionPenalty)
This constructor is a little cleaner to use outside of contexts in which the command bean is really useful.

Parameters:
comparator - The comparison function to use.
gapCreationPenalty - The penalty for creating a new gap.
gapExtensionPenalty - The penalty for extending an existing gap.
Method Detail

execute

public void execute()
Description copied from class: SequenceAligner
Perform the operation.

Specified by:
execute in class SequenceAligner

getNumberOfAlignments

public int getNumberOfAlignments()
Description copied from class: SequenceAligner
Get the number of alignments that have the best score.

Specified by:
getNumberOfAlignments in class SequenceAligner
Returns:
The number of alignments.

getComparator

public MonomerComparator getComparator()
Set the comparator to use to match each pair of elements.

Returns:
Returns the comparator.

setComparator

public void setComparator(MonomerComparator comparator)
Returns the comparator currently in use.

Parameters:
comparator - The comparator to set.

getGapCreationPenalty

public int getGapCreationPenalty()
Returns:
Returns the gapCreationPenalty.

setGapCreationPenalty

public void setGapCreationPenalty(int gapCreationPenalty)
Parameters:
gapCreationPenalty - The gapCreationPenalty to set.

getGapExtensionPenalty

public int getGapExtensionPenalty()
Returns:
Returns the gapExtensionPenalty.

setGapExtensionPenalty

public void setGapExtensionPenalty(int gapExtensionPenalty)
Parameters:
gapExtensionPenalty - The gapExtensionPenalty to set.

getBestAlignmentScore

public int getBestAlignmentScore()
Description copied from class: SequenceAligner
Get the best alignment score, as defined by this algorithm.

Specified by:
getBestAlignmentScore in class SequenceAligner
Returns:
The score.

getBestAlignmentAsString

public java.lang.String getBestAlignmentAsString()
Description copied from class: SequenceAligner
Get the actual best alignment, in the form of a string consisting of tuples representing positions in the alignment.

Specified by:
getBestAlignmentAsString in class SequenceAligner
Returns:
The best alignment.

getAlignmentAsString

public java.lang.String getAlignmentAsString(int n)

getBestAlignmentsAsStrings

public java.lang.String[] getBestAlignmentsAsStrings()
Description copied from class: SequenceAligner
Get the set of best alignments, in the form of an array of strings consisting of tuples representing positions in the alignment.

Specified by:
getBestAlignmentsAsStrings in class SequenceAligner
Returns:
The best alignments.

getBestAlignmentsAsMatrix

public java.lang.Character[][] getBestAlignmentsAsMatrix()
Description copied from class: SequenceAligner
Get the set of best alignments, in the form of a matrix.

Specified by:
getBestAlignmentsAsMatrix in class SequenceAligner
Returns:
The matrix showing the alignments.