org.biojava3.alignment.template
Class AbstractMatrixAligner<S extends Sequence<C>,C extends Compound>

java.lang.Object
  extended by org.biojava3.alignment.template.AbstractScorer
      extended by org.biojava3.alignment.template.AbstractMatrixAligner<S,C>
Type Parameters:
S - each element of the alignment Profile is of type S
C - each element of an AlignedSequence is a Compound of type C
All Implemented Interfaces:
Aligner<S,C>, MatrixAligner<S,C>, Scorer
Direct Known Subclasses:
AbstractPairwiseSequenceAligner, AbstractProfileProfileAligner

public abstract class AbstractMatrixAligner<S extends Sequence<C>,C extends Compound>
extends AbstractScorer
implements MatrixAligner<S,C>

Implements common code for an Aligner which builds a score matrix during computation.

Author:
Mark Chapman

Field Summary
protected  int[] anchors
           
protected  int cutsPerSection
           
protected  GapPenalty gapPenalty
           
protected  short max
           
protected  short min
           
protected  Profile<S,C> profile
           
protected  short score
           
protected  short[][][] scores
           
protected  long time
           
protected  int[] xyMax
           
protected  int[] xyStart
           
 
Constructor Summary
protected AbstractMatrixAligner()
          Before running an alignment, data must be sent in via calls to setGapPenalty(GapPenalty) and setSubstitutionMatrix(SubstitutionMatrix).
protected AbstractMatrixAligner(GapPenalty gapPenalty, SubstitutionMatrix<C> subMatrix)
          Prepares for an alignment.
protected AbstractMatrixAligner(GapPenalty gapPenalty, SubstitutionMatrix<C> subMatrix, boolean local)
          Prepares for an alignment.
 
Method Summary
protected  void align()
           
protected abstract  CompoundSet<C> getCompoundSet()
           
protected abstract  List<C> getCompoundsOfQuery()
           
protected abstract  List<C> getCompoundsOfTarget()
           
 long getComputationTime()
          Returns the computation time needed for an alignment computed in nanoseconds.
 GapPenalty getGapPenalty()
          Returns the gap penalties.
 int getMaxScore()
          Returns maximum possible score.
 int getMinScore()
          Returns minimum possible score.
 Profile<S,C> getProfile()
          Returns the alignment Profile produced by this alignment algorithm.
 int getScore()
          Returns score resulting from algorithm.
 short[][][] getScoreMatrix()
          Returns the entire score matrix built during alignment.
 String getScoreMatrixAsString()
          Returns a depiction of the score matrix as a String.
protected abstract  int[] getScoreMatrixDimensions()
           
 SubstitutionMatrix<C> getSubstitutionMatrix()
          Returns the substitution matrix.
protected abstract  short getSubstitutionScore(int queryColumn, int targetColumn)
           
protected  short[] getSubstitutionScoreVector(int queryColumn)
           
protected  short[] getSubstitutionScoreVector(int queryColumn, int[] subproblem)
           
 boolean isLocal()
          Returns whether alignment finds a region of similarity rather than aligning every compound.
protected abstract  boolean isReady()
           
 boolean isStoringScoreMatrix()
          Returns choice to cache the score matrix or to save memory by deleting score matrix after alignment.
protected  void reset()
           
protected  void resetAnchors()
           
 void setGapPenalty(GapPenalty gapPenalty)
          Sets the gap penalties.
protected abstract  void setProfile(List<AlignedSequence.Step> sx, List<AlignedSequence.Step> sy)
           
 void setStoringScoreMatrix(boolean storingScoreMatrix)
          Sets choice to cache the score matrix or to save memory by deleting score matrix after alignment.
 void setSubstitutionMatrix(SubstitutionMatrix<C> subMatrix)
          Sets the substitution matrix.
 
Methods inherited from class org.biojava3.alignment.template.AbstractScorer
getDistance, getDistance, getSimilarity, getSimilarity
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.biojava3.alignment.template.Scorer
getDistance, getDistance, getSimilarity, getSimilarity
 

Field Detail

gapPenalty

protected GapPenalty gapPenalty

anchors

protected int[] anchors

cutsPerSection

protected int cutsPerSection

profile

protected Profile<S extends Sequence<C>,C extends Compound> profile

xyMax

protected int[] xyMax

xyStart

protected int[] xyStart

max

protected short max

min

protected short min

score

protected short score

scores

protected short[][][] scores

time

protected long time
Constructor Detail

AbstractMatrixAligner

protected AbstractMatrixAligner()
Before running an alignment, data must be sent in via calls to setGapPenalty(GapPenalty) and setSubstitutionMatrix(SubstitutionMatrix).


AbstractMatrixAligner

protected AbstractMatrixAligner(GapPenalty gapPenalty,
                                SubstitutionMatrix<C> subMatrix)
Prepares for an alignment.

Parameters:
gapPenalty - the gap penalties used during alignment
subMatrix - the set of substitution scores used during alignment

AbstractMatrixAligner

protected AbstractMatrixAligner(GapPenalty gapPenalty,
                                SubstitutionMatrix<C> subMatrix,
                                boolean local)
Prepares for an alignment.

Parameters:
gapPenalty - the gap penalties used during alignment
subMatrix - the set of substitution scores used during alignment
local - if true, find a region of similarity rather than aligning every compound
Method Detail

getGapPenalty

public GapPenalty getGapPenalty()
Returns the gap penalties.

Returns:
the gap penalties used during alignment

getSubstitutionMatrix

public SubstitutionMatrix<C> getSubstitutionMatrix()
Returns the substitution matrix.

Returns:
the set of substitution scores used during alignment

isLocal

public boolean isLocal()
Returns whether alignment finds a region of similarity rather than aligning every compound.

Returns:
true if alignment finds a region of similarity rather than aligning every compound

isStoringScoreMatrix

public boolean isStoringScoreMatrix()
Returns choice to cache the score matrix or to save memory by deleting score matrix after alignment.

Returns:
choice to cache the score matrix

setGapPenalty

public void setGapPenalty(GapPenalty gapPenalty)
Sets the gap penalties.

Parameters:
gapPenalty - the gap penalties used during alignment

setSubstitutionMatrix

public void setSubstitutionMatrix(SubstitutionMatrix<C> subMatrix)
Sets the substitution matrix.

Parameters:
subMatrix - the set of substitution scores used during alignment

setStoringScoreMatrix

public void setStoringScoreMatrix(boolean storingScoreMatrix)
Sets choice to cache the score matrix or to save memory by deleting score matrix after alignment.

Parameters:
storingScoreMatrix - choice to cache the score matrix

getScoreMatrix

public short[][][] getScoreMatrix()
Description copied from interface: MatrixAligner
Returns the entire score matrix built during alignment. The first dimension has the length of the first (query) sequence + 1; the second has the length of the second (target) sequence + 1; the third has length equal to the number of scores stored per pairing of an element from each Sequence.

Specified by:
getScoreMatrix in interface MatrixAligner<S extends Sequence<C>,C extends Compound>
Returns:
the score matrix

getScoreMatrixAsString

public String getScoreMatrixAsString()
Description copied from interface: MatrixAligner
Returns a depiction of the score matrix as a String. This may include additional description such as labels for each dimension: element from query sequence, element from target sequence, and meaning of each score.

Specified by:
getScoreMatrixAsString in interface MatrixAligner<S extends Sequence<C>,C extends Compound>
Returns:
the score matrix as a character sequence

getComputationTime

public long getComputationTime()
Description copied from interface: Aligner
Returns the computation time needed for an alignment computed in nanoseconds.

Specified by:
getComputationTime in interface Aligner<S extends Sequence<C>,C extends Compound>
Returns:
the computation time in nanoseconds

getProfile

public Profile<S,C> getProfile()
Description copied from interface: Aligner
Returns the alignment Profile produced by this alignment algorithm.

Specified by:
getProfile in interface Aligner<S extends Sequence<C>,C extends Compound>
Returns:
the alignment profile

getMaxScore

public int getMaxScore()
Description copied from interface: Scorer
Returns maximum possible score.

Specified by:
getMaxScore in interface Scorer
Returns:
maximum possible score

getMinScore

public int getMinScore()
Description copied from interface: Scorer
Returns minimum possible score.

Specified by:
getMinScore in interface Scorer
Returns:
minimum possible score

getScore

public int getScore()
Description copied from interface: Scorer
Returns score resulting from algorithm. This should normalize between 0 and 1 by calculating (Scorer.getScore() - Scorer.getMinScore()) / (Scorer.getMaxScore() - Scorer.getMinScore()).

Specified by:
getScore in interface Scorer
Returns:
score resulting from algorithm

align

protected void align()

getSubstitutionScoreVector

protected short[] getSubstitutionScoreVector(int queryColumn)

getSubstitutionScoreVector

protected short[] getSubstitutionScoreVector(int queryColumn,
                                             int[] subproblem)

reset

protected void reset()

resetAnchors

protected void resetAnchors()

getCompoundSet

protected abstract CompoundSet<C> getCompoundSet()

getCompoundsOfQuery

protected abstract List<C> getCompoundsOfQuery()

getCompoundsOfTarget

protected abstract List<C> getCompoundsOfTarget()

getScoreMatrixDimensions

protected abstract int[] getScoreMatrixDimensions()

getSubstitutionScore

protected abstract short getSubstitutionScore(int queryColumn,
                                              int targetColumn)

isReady

protected abstract boolean isReady()

setProfile

protected abstract void setProfile(List<AlignedSequence.Step> sx,
                                   List<AlignedSequence.Step> sy)