|
NeoBio API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--neobio.alignment.PairwiseAlignmentAlgorithm
This abstract class is the superclass of all classes implementing pairwise sequence alignment algorithms. Subclasses are required to provide methods to build a high scoring alignment between two sequences and compute its score with a given scoring scheme.
Clients are required to set a scoring scheme and load two sequences before requesting an alignment or the computation of its score. They typically make the following sequence of method calls:
// prepare
PairwiseAlignmentAlgorithm algorithm = new SomePairwiseAlignmentAlgorith ();
algorithm.setScoringScheme (some_scoring_scheme);
algorithm.loadSequences (sequence1, sequence2);
// now compute the alignment
PairwiseAlignment alignment = algorithm.getPairwiseAlignment();
int score = algorithm.getScore();
PairwiseAlignment
Field Summary | |
protected PairwiseAlignment |
alignment
Stores the product of the last pairwise alignment performed. |
protected static char |
APPROXIMATE_MATCH_TAG
Tag character that signals an approximate match in the score tag line of an alignment. |
protected static char |
GAP_CHARACTER
Character that signals a gap in sequence. |
protected static char |
GAP_TAG
Character that signals a gap in the score tag line of an alignment. |
protected static char |
MATCH_TAG
Tag character that signals a match in the score tag line of an alignment. |
protected static char |
MISMATCH_TAG
Character that signals a mismatch in the score tag line of an alignment. |
protected int |
score
This field stores just the score of the last pairwise alignment performed (if the score_computed flag is set to true). |
protected boolean |
score_computed
Flags whether the score of the alignment between the last two loaded sequences has already been computed. |
protected ScoringScheme |
scoring
The scoring scheme used to compute a pairwise sequence alignment. |
protected boolean |
sequences_loaded
Flags whether sequences have been loaded. |
protected boolean |
use_match_tag
Indicates if the MATCH_TAG tag should be used or not. |
Constructor Summary | |
PairwiseAlignmentAlgorithm()
|
Method Summary | |
protected abstract PairwiseAlignment |
computePairwiseAlignment()
Subclasses must implement this method to compute an alignment between the loaded sequences using the scoring scheme previously set. |
protected abstract int |
computeScore()
Subclasses must implement this method to compute the score of the alignment between the loaded sequences using the scoring scheme previously set. |
PairwiseAlignment |
getPairwiseAlignment()
Return the last pairwise alignment computed (if any) or request subclasses to compute one and return the result by calling the computePairwiseAlignment method. |
int |
getScore()
Returns the score of the last alignment computed (if any) or request subclasses to compute one and return the result by calling the computeScore method.
|
void |
loadSequences(java.io.Reader input1,
java.io.Reader input2)
Request subclasses to load the sequences according to their own needs. |
protected abstract void |
loadSequencesInternal(java.io.Reader input1,
java.io.Reader input2)
Subclasses must implement this method to load sequences according to their own needs and throw an exception in case of any failure. |
protected int |
max(int v1,
int v2)
Helper method to compute the the greater of two values. |
protected int |
max(int v1,
int v2,
int v3)
Helper method to compute the the greater of three values. |
protected int |
max(int v1,
int v2,
int v3,
int v4)
Helper method to compute the the greater of four values. |
protected int |
scoreDeletion(char a)
Helper method to invoke the scoreDeletion method of the scoring scheme
set to this algorithm. |
protected int |
scoreInsertion(char a)
Helper method to invoke the scoreInsertion method of the scoring
scheme set to this algorithm. |
protected int |
scoreSubstitution(char a,
char b)
Helper method to invoke the scoreSubstitution method of the scoring
scheme set to this algorithm. |
void |
setScoringScheme(ScoringScheme scoring)
Sets the scoring scheme to be used for the next alignments. |
void |
unloadSequences()
Frees pointer to loaded sequences and computed alignments (if any) so that their data can be garbage collected. |
protected abstract void |
unloadSequencesInternal()
Subclasses must implement this method to unload sequences according to their own storage, freeing pointers to sequences and any intermediate data so that they can be garbage collected. |
protected boolean |
useMatchTag()
Tells wether the MATCH_TAG tag should be used or not. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static final char MATCH_TAG
use_match_tag
flag.
use_match_tag
,
useMatchTag()
,
Constant Field Valuesprotected static final char APPROXIMATE_MATCH_TAG
protected static final char MISMATCH_TAG
protected static final char GAP_TAG
protected static final char GAP_CHARACTER
protected boolean use_match_tag
MATCH_TAG
tag should be used or not. If it is
true
, the alignment algorithm should write the MATCH_TAG
tag in the score tag line of the alignment whenever a match occurs between
characters of the two sequences. If it is false
the matching character
should be written instead. This flag is updated whenever a scoring scheme is set to
this PairwiseAlignmentAlgorithm
by the setScoringScheme
method.
MATCH_TAG
,
useMatchTag()
,
setScoringScheme(neobio.alignment.ScoringScheme)
protected ScoringScheme scoring
protected PairwiseAlignment alignment
computePairwiseAlignment
method that subclasses must implement. It is
set to null if new sequences are loaded or a new scoring scheme is set.
protected int score
score_computed flag
is set to true). It is useful when just the score
is needed (and not the alignment itselft). Its value is set after a successful
execution of both computePairwiseAlignment
or
computeScore
methods that subclasses must implement. If new sequences
are loaded or a new scoring scheme is set, the score_computed
flag is
set to false, and this field's value becomes undefined.
protected boolean score_computed
computePairwiseAlignment
or computeScore
methods that
subclasses must implement. It is set to falsef if new sequences are loaded or a new
scoring scheme is set.
protected boolean sequences_loaded
Constructor Detail |
public PairwiseAlignmentAlgorithm()
Method Detail |
public void setScoringScheme(ScoringScheme scoring)
PairwiseAlignmentAlgorithm
is set not to use the
MATCH_TAG
tag because in this case the score tag line be confusing.
If the scoring scheme does not support partial matches, then the use of the
MATCH_TAG
tag is enabled.
scoring
- Scoring scheme to be usedMATCH_TAG
,
ScoringScheme.isPartialMatchSupported()
protected boolean useMatchTag()
MATCH_TAG
tag should be used or not. If it returns
true
, the alignment algorithm should write the MATCH_TAG
tag in the score tag line of the alignment produced whenever a match occurs between
characters of the two sequences. If it returns false
the matching
character should be written instead. The value returned is conditioned by the
use_match_tag
flag, which is updated whenever a scoring scheme is set
to this PairwiseAlignmentAlgorithm
by the
setScoringScheme
method.
true
MATCH_TAG tag should be used,
false
otherwiseMATCH_TAG
,
use_match_tag
,
setScoringScheme(neobio.alignment.ScoringScheme)
public void loadSequences(java.io.Reader input1, java.io.Reader input2) throws java.io.IOException, InvalidSequenceException
input1
- First sequenceinput2
- Second sequence
java.io.IOException
- If an I/O error occurs when reading the sequences
InvalidSequenceException
- If the sequences are not validpublic void unloadSequences()
public PairwiseAlignment getPairwiseAlignment() throws IncompatibleScoringSchemeException
computePairwiseAlignment
method. The sequences must already be loaded
and a scoring scheme must already be set.
IncompatibleScoringSchemeException
- If the scoring scheme
is not compatible with the loaded sequencescomputePairwiseAlignment()
public int getScore() throws IncompatibleScoringSchemeException
computeScore
method.
The sequences must already be loaded and a scoring scheme must already be set.
IncompatibleScoringSchemeException
- If the scoring scheme
is not compatible with the loaded sequencescomputeScore()
protected abstract void loadSequencesInternal(java.io.Reader input1, java.io.Reader input2) throws java.io.IOException, InvalidSequenceException
input1
- First sequenceinput2
- Second sequence
java.io.IOException
- If an I/O error occurs when reading the sequences
InvalidSequenceException
- If the sequences are not validloadSequences(java.io.Reader, java.io.Reader)
,
CharSequence
,
FactorSequence
protected abstract void unloadSequencesInternal()
unloadSequences
method.
unloadSequences()
protected abstract PairwiseAlignment computePairwiseAlignment() throws IncompatibleScoringSchemeException
getPairwiseAlignment
method when needed.
IncompatibleScoringSchemeException
- If the scoring scheme
is not compatible with the loaded sequencesgetPairwiseAlignment()
protected abstract int computeScore() throws IncompatibleScoringSchemeException
getScore
method when needed.
IncompatibleScoringSchemeException
- If the scoring scheme
is not compatible with the loaded sequencesgetScore()
protected final int scoreSubstitution(char a, char b) throws IncompatibleScoringSchemeException
scoreSubstitution
method of the scoring
scheme set to this algorithm.
a
- first characterb
- second character
a
for b
IncompatibleScoringSchemeException
- if the scoring scheme is not compatible
with the sequences being alignedScoringScheme.scoreSubstitution(char, char)
protected final int scoreInsertion(char a) throws IncompatibleScoringSchemeException
scoreInsertion
method of the scoring
scheme set to this algorithm.
a
- the character to be inserted
a
IncompatibleScoringSchemeException
- if the scoring scheme is not compatible
with the sequences being alignedScoringScheme.scoreInsertion(char)
protected final int scoreDeletion(char a) throws IncompatibleScoringSchemeException
scoreDeletion
method of the scoring scheme
set to this algorithm.
a
- the character to be deleted
a
IncompatibleScoringSchemeException
- if the scoring scheme is not compatible
with the sequences being alignedScoringScheme.scoreDeletion(char)
protected final int max(int v1, int v2)
v1
- first valuev2
- second value
v1
and v2
protected final int max(int v1, int v2, int v3)
v1
- first valuev2
- second valuev3
- third value
v1
, v2
and v3
protected final int max(int v1, int v2, int v3, int v4)
v1
- first valuev2
- second valuev3
- third valuev4
- fourth value
v1
, v2
v3
and
v4
|
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |