edu.rit.compbio.seq
Class Alignment
- java.lang.Object
-
- edu.rit.compbio.seq.Alignment
-
- All Implemented Interfaces:
- java.io.Externalizable, java.io.Serializable, java.lang.Comparable<Alignment>
public class Alignment extends java.lang.Object implements java.io.Externalizable, java.lang.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
Fields Modifier and Type Field and Description static intQUERY_ALIGNED_WITH_GAPState of an alignment position: character in query sequence aligned with gap in subject sequence.static intQUERY_ALIGNED_WITH_SUBJECTState of an alignment position: character in query sequence aligned with character in subject sequence.static intSUBJECT_ALIGNED_WITH_GAPState of an alignment position: character in subject sequence aligned with gap in query sequence.
-
Constructor Summary
Constructors Constructor and Description Alignment()Construct a new, uninitialized alignment object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description intcompareTo(Alignment alignment)Compare this alignment object to the given alignment object.intgetAlignment(int i)Get the state of the given position in the alignment.intgetAlignmentLength()Get the number of positions in the alignment.intgetQueryFinish()Get the index of the last aligned character in the query sequence.longgetQueryId()Get the ID associated with the query sequence.intgetQueryLength()Get the length of the query sequence.intgetQueryStart()Get the index of the first aligned character in the query sequence.intgetSubjectFinish()Get the index of the last aligned character in the subject sequence.longgetSubjectId()Get the ID associated with the subject sequence.intgetSubjectLength()Get the length of the subject sequence.intgetSubjectStart()Get the index of the first aligned character in the subject sequence.voidreadExternal(java.io.ObjectInput in)Read this alignment object from the given object input stream.java.lang.StringtoString()Returns a string version of this alignment object.voidwriteExternal(java.io.ObjectOutput out)Write this alignment object to the given object output stream.
-
-
-
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:
compareToin interfacejava.lang.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 java.lang.String toString()
Returns a string version of this alignment object.- Overrides:
toStringin classjava.lang.Object- Returns:
- String version.
-
writeExternal
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOExceptionWrite this alignment object to the given object output stream.- Specified by:
writeExternalin interfacejava.io.Externalizable- Parameters:
out- Object output stream.- Throws:
java.io.IOException- Thrown if an I/O error occurred.
-
readExternal
public void readExternal(java.io.ObjectInput in) throws java.io.IOExceptionRead this alignment object from the given object input stream.- Specified by:
readExternalin interfacejava.io.Externalizable- Parameters:
in- Object input stream.- Throws:
java.io.IOException- Thrown if an I/O error occurred.
-
-
DMelt 3.0 © DataMelt by jWork.ORG