org.jscience.biology.alignment
Class PairwiseAlignment

java.lang.Object
  extended by org.jscience.biology.alignment.PairwiseAlignment
All Implemented Interfaces:
java.io.Serializable

public class PairwiseAlignment
extends java.lang.Object
implements java.io.Serializable

This class is the product of a pairwise alignment, generated by one subclasses of PairwiseAlignmentAlgorithm. It contains the two sequences strings with gaps, a score tag line, and a score value. It is typically displayed in three rows as in the following example of an alignment between parts of two protein sequences:

 MDEIHQLEDMFTVDSETLRKVVKHFILPHD-----MRTTKHQEELWSFIAELDSLKDFMVEQE    // sequence 1
 M +I   E +FTV +ETL+ V KHFILP D     MRTT++ +ELW FIA  DSLK F+ EQ     // score tag line
 MQQIENFEKIFTVPTETLQAVTKHFILP-DATETLMRTTQNPDELWEFIA--DSLKAFIDEQF    // sequence 2
 

Each column has one character of each sequence and a score tag. The same character is displayed in all three rows when a column has an exact match (character of sequences 1 and 2 are equal). When a mismatch occurs (substitution of different characters), the score tag is left blank. A '+' in the score line signals a partial match (a substitution of similar characters). The difference between a partial match and a mismatch is that the score of a partial match is positive whereas the score of a mismatch is zero or negative (each case is determined by the scoring scheme).

Gaps are usually represented by dashes ('-') and have a blank score tag. Insertions have dashes in sequence 1 and the inserted character in sequence 2. Deletions, by contrast, have the deleted character in sequence 1 and dashes in sequence 2.

Each column carries a score value for the corresponding operation (as defined by the scoring scheme). The overall score of a pairwise alignment is the sum of all columns scores values.

When the scoring schemes does not support partial matches, a match is usually signaled by a '|' character.

Note that these special characters are defined by the PairwiseAlignmentAlgorithm class. Consult that class specification for the actual configuration. For instance, an alignment between two DNA fragmens may look like this:

 A--C--TAAAAAGCA--TT-AATAATAAA-A
 |  |  ||||  |||  || ||||| ||| |
 AAGCCCTAAACCGCAAGTTTAATAA-AAATA
 

This class is serializable, so it can be saved to a file (or any other output). It overrides the default equals method of the Object class to allow a proper comparsion of alignments produced by different algorithms or even different runs of the same algorithm. However, it does not override the hashCode method as it is generally the case to maintain the contract for the hashCode method (which states that equal objects must have equal hash codes). Hence, as it is, its use in a hash table is not supported.

See Also:
PairwiseAlignmentAlgorithm, PairwiseAlignmentAlgorithm.MATCH_TAG, PairwiseAlignmentAlgorithm.APPROXIMATE_MATCH_TAG, PairwiseAlignmentAlgorithm.MISMATCH_TAG, PairwiseAlignmentAlgorithm.GAP_TAG, PairwiseAlignmentAlgorithm.GAP_CHARACTER, ScoringScheme, ScoringScheme.isPartialMatchSupported(), Serialized Form

Field Summary
protected  java.lang.String gapped_seq1
          First gapped sequence.
protected  java.lang.String gapped_seq2
          Second gapped sequence.
protected  int score
          The overall score value for this alignment.
protected  java.lang.String score_tag_line
          The score tag line.
 
Constructor Summary
PairwiseAlignment(java.lang.String gapped_seq1, java.lang.String score_tag_line, java.lang.String gapped_seq2, int score)
          Creates a PairwiseAlignment instance with the specified gapped sequences, score tag line and score value.
 
Method Summary
 boolean equals(java.lang.Object obj)
          Compares this object to the specified object.
 java.lang.String getGappedSequence1()
          Returns the first gapped sequence.
 java.lang.String getGappedSequence2()
          Returns the second gapped sequence.
 int getScore()
          Returns the score for this alignment.
 java.lang.String getScoreTagLine()
          Returns the score tag line.
 java.lang.String toString()
          Returns a four-line String representation of this alignment in the following order: first gapped sequence, score tag line, second gapped sequence and the score value.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

gapped_seq1

protected java.lang.String gapped_seq1
First gapped sequence.


score_tag_line

protected java.lang.String score_tag_line
The score tag line.


gapped_seq2

protected java.lang.String gapped_seq2
Second gapped sequence.


score

protected int score
The overall score value for this alignment.

Constructor Detail

PairwiseAlignment

public PairwiseAlignment(java.lang.String gapped_seq1,
                         java.lang.String score_tag_line,
                         java.lang.String gapped_seq2,
                         int score)
Creates a PairwiseAlignment instance with the specified gapped sequences, score tag line and score value.

Parameters:
gapped_seq1 - the first gapped sequence
score_tag_line - the score tag line
gapped_seq2 - the second gapped sequence
score - the overall score value for this alignment
Method Detail

getGappedSequence1

public java.lang.String getGappedSequence1()
Returns the first gapped sequence.

Returns:
first gapped sequence

getScoreTagLine

public java.lang.String getScoreTagLine()
Returns the score tag line.

Returns:
score tag line

getGappedSequence2

public java.lang.String getGappedSequence2()
Returns the second gapped sequence.

Returns:
second gapped sequence

getScore

public int getScore()
Returns the score for this alignment.

Returns:
overall score for this alignment

toString

public java.lang.String toString()
Returns a four-line String representation of this alignment in the following order: first gapped sequence, score tag line, second gapped sequence and the score value.

Overrides:
toString in class java.lang.Object
Returns:
a String representation of this scoring matrix

equals

public boolean equals(java.lang.Object obj)
Compares this object to the specified object. The result is true if and only if the argument is not null and is an PairwiseAlignment object that contains the same values as this object, i.e. the same gapped sequences, the same score tag line and the same score.

Overrides:
equals in class java.lang.Object
Parameters:
obj - the object to compare with
Returns:
true if objects are the same, false otherwise