edu.rit.compbio.seq
Class Alignment

java.lang.Object
  extended by edu.rit.compbio.seq.Alignment
All Implemented Interfaces:
Externalizable, Serializable, Comparable<Alignment>

public class Alignment
extends Object
implements Externalizable, Comparable<Alignment>

Class Alignment encapsulates the result of a sequence alignment between a query sequence and a subject sequence. Alignment objects are returned by the align() method of class ProteinLocalAlignment.

An alignment object does not record the actual query sequence and subject sequence that were aligned. The alignment object does record an ID associated with the query sequence and an ID associated with the subject sequence. For example, the ID could be the index of a sequence in a ProteinDatabase.

Class Alignment implements interface Comparable and so has a natural ordering. The comparison order depends on the alignment scores and the subject sequence IDs. An alignment with a higher score comes before an alignment with a lower score. If the scores are equal, an alignment with a lower subject sequence ID comes before an alignment with a higher subject sequence ID.

See Also:
Serialized Form

Field Summary
static int QUERY_ALIGNED_WITH_GAP
          State of an alignment position: character in query sequence aligned with gap in subject sequence.
static int QUERY_ALIGNED_WITH_SUBJECT
          State of an alignment position: character in query sequence aligned with character in subject sequence.
static int SUBJECT_ALIGNED_WITH_GAP
          State of an alignment position: character in subject sequence aligned with gap in query sequence.
 
Constructor Summary
Alignment()
          Construct a new, uninitialized alignment object.
 
Method Summary
 int compareTo(Alignment alignment)
          Compare this alignment object to the given alignment object.
 int getAlignment(int i)
          Get the state of the given position in the alignment.
 int getAlignmentLength()
          Get the number of positions in the alignment.
 int getQueryFinish()
          Get the index of the last aligned character in the query sequence.
 long getQueryId()
          Get the ID associated with the query sequence.
 int getQueryLength()
          Get the length of the query sequence.
 int getQueryStart()
          Get the index of the first aligned character in the query sequence.
 int getSubjectFinish()
          Get the index of the last aligned character in the subject sequence.
 long getSubjectId()
          Get the ID associated with the subject sequence.
 int getSubjectLength()
          Get the length of the subject sequence.
 int getSubjectStart()
          Get the index of the first aligned character in the subject sequence.
 void readExternal(ObjectInput in)
          Read this alignment object from the given object input stream.
 String toString()
          Returns a string version of this alignment object.
 void writeExternal(ObjectOutput out)
          Write this alignment object to the given object output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

QUERY_ALIGNED_WITH_SUBJECT

public static final int QUERY_ALIGNED_WITH_SUBJECT
State of an alignment position: character in query sequence aligned with character in subject sequence.

See Also:
Constant Field Values

QUERY_ALIGNED_WITH_GAP

public static final int QUERY_ALIGNED_WITH_GAP
State of an alignment position: character in query sequence aligned with gap in subject sequence.

See Also:
Constant Field Values

SUBJECT_ALIGNED_WITH_GAP

public static final int SUBJECT_ALIGNED_WITH_GAP
State of an alignment position: character in subject sequence aligned with gap in query sequence.

See Also:
Constant Field Values
Constructor Detail

Alignment

public Alignment()
Construct a new, uninitialized alignment object. This constructor is for use only by object deserialization.

Method Detail

getQueryId

public long getQueryId()
Get the ID associated with the query sequence. This is an arbitrary integer; for example, it could be the index of a sequence in a ProteinDatabase.

Returns:
Query sequence ID.

getSubjectId

public long getSubjectId()
Get the ID associated with the subject sequence. This is an arbitrary integer; for example, it could be the index of a sequence in a ProteinDatabase.

Returns:
Subject sequence ID.

getQueryLength

public int getQueryLength()
Get the length of the query sequence.

Returns:
Query sequence length.

getSubjectLength

public int getSubjectLength()
Get the length of the subject sequence.

Returns:
Subject sequence length.

getQueryStart

public int getQueryStart()
Get the index of the first aligned character in the query sequence. The index is in the range 1 .. M, where M is the length of the query sequence. If a local alignment was not found, 0 is returned.

Returns:
Query sequence start index.

getQueryFinish

public int getQueryFinish()
Get the index of the last aligned character in the query sequence. The index is in the range 1 .. M, where M is the length of the query sequence. If a local alignment was not found, 0 is returned.

Returns:
Query sequence finish index.

getSubjectStart

public int getSubjectStart()
Get the index of the first aligned character in the subject sequence. The index is in the range 1 .. N, where N is the length of the subject sequence. If a local alignment was not found, 0 is returned.

Returns:
Subject sequence start index.

getSubjectFinish

public int getSubjectFinish()
Get the index of the last aligned character in the subject sequence. The index is in the range 1 .. N, where N is the length of the subject sequence. If a local alignment was not found, 0 is returned.

Returns:
Subject sequence finish index.

getAlignmentLength

public int getAlignmentLength()
Get the number of positions in the alignment. If a local alignment was not found, 0 is returned.

Returns:
Alignment length.

getAlignment

public int getAlignment(int i)
Get the state of the given position in the alignment. The index i must be in the range 0 .. L−1, where L is the alignment length. The state of position i in the alignment is returned, one of the following:

Parameters:
i - Position in the alignment.
Returns:
State of position i in the alignment.

compareTo

public int compareTo(Alignment alignment)
Compare this alignment object to the given alignment object. The comparison order depends on the alignment scores and the subject sequence IDs. An alignment with a higher score comes before an alignment with a lower score. If the scores are equal, an alignment with a lower subject sequence ID comes before an alignment with a higher subject sequence ID.

Specified by:
compareTo in interface Comparable<Alignment>
Parameters:
alignment - Alignment to compare to.
Returns:
An integer less than, equal to, or greater than 0 if this alignment comes before, is the same as, or comes after the given alignment, respectively.

toString

public String toString()
Returns a string version of this alignment object.

Overrides:
toString in class Object
Returns:
String version.

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Write this alignment object to the given object output stream.

Specified by:
writeExternal in interface Externalizable
Parameters:
out - Object output stream.
Throws:
IOException - Thrown if an I/O error occurred.

readExternal

public void readExternal(ObjectInput in)
                  throws IOException
Read this alignment object from the given object input stream.

Specified by:
readExternal in interface Externalizable
Parameters:
in - Object input stream.
Throws:
IOException - Thrown if an I/O error occurred.


Copyright © 2005-2012 by Alan Kaminsky. All rights reserved. Send comments to ark­@­cs.rit.edu.