edu.rit.compbio.phyl
Class DnaSequence
- java.lang.Object
-
- edu.rit.compbio.phyl.DnaSequence
-
public class DnaSequence extends java.lang.ObjectClass DnaSequence encapsulates a DNA sequence. The DNA sequence consists of a sequence of sites. Each site has a state, which is a set of bases. The four bases are adenine, cytosine, guanine, and thymine. For textual I/O, each state is represented by a single character as follows:Char. Meaning Set A Adenine (A) C Cytosine (C) G Guanine (G) T Thymine (T) Y pYrimidine (C or T) R puRine (A or G) W "Weak" (A or T) S "Strong" (C or G) K "Keto" (G or T) M "aMino" (A or C) B not A (C or G or T) D not C (A or G or T) H not G (A or C or T) V not T (A or C or G) X unknown (A or C or G or T) - deletion () The DNA sequence has an associated score, an integer. The score can be set to anything and later retrieved.
The DNA sequence has a name, a string. The name can be set to anything and later retrieved.
-
-
Constructor Summary
Constructors Constructor and Description DnaSequence()Construct a new zero-length DNA sequence.DnaSequence(DnaSequence seq)Construct a new DNA sequence that is a copy of the given DNA sequence.DnaSequence(int N)Construct a new DNA sequence with the given length.DnaSequence(int N, int score)Construct a new DNA sequence with the given length and score.DnaSequence(int N, int score, java.lang.String name)Construct a new DNA sequence with the given length, score, and name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidcopySites(DnaSequence seq)Make this DNA sequence's sites be the same as the given DNA sequence.doubledistance(DnaSequence seq)Compute the distance between this DNA sequence and the given DNA sequence.intlength()Get this DNA sequence's length.java.lang.Stringname()Get this DNA sequence's name.voidname(java.lang.String name)Set this DNA sequence's name.intscore()Get this DNA sequence's score.voidscore(int score)Set this DNA sequence's score.voidsetFitchAncestor(DnaSequence seq1, DnaSequence seq2)Make this DNA sequence be the ancestor of the two given DNA sequences in the Fitch parsimony score algorithm.java.lang.StringtoString()Returns a string version of this DNA sequence.
-
-
-
Constructor Detail
-
DnaSequence
public DnaSequence()
Construct a new zero-length DNA sequence. The score is initially 0. The name is initially null.
-
DnaSequence
public DnaSequence(int N)
Construct a new DNA sequence with the given length. The score is initially 0. The name is initially null.- Parameters:
N- Length (number of sites).- Throws:
java.lang.IllegalArgumentException- (unchecked exception) Thrown if N < 0.
-
DnaSequence
public DnaSequence(int N, int score)Construct a new DNA sequence with the given length and score. The name is initially null.- Parameters:
N- Length (number of sites).score- Score.- Throws:
java.lang.IllegalArgumentException- (unchecked exception) Thrown if N < 0.
-
DnaSequence
public DnaSequence(int N, int score, java.lang.String name)Construct a new DNA sequence with the given length, score, and name.- Parameters:
N- Length (number of sites).score- Score.name- Name. May be null.- Throws:
java.lang.IllegalArgumentException- (unchecked exception) Thrown if N < 0.
-
DnaSequence
public DnaSequence(DnaSequence seq)
Construct a new DNA sequence that is a copy of the given DNA sequence.- Parameters:
seq- DNA sequence to copy.- Throws:
java.lang.NullPointerException- (unchecked exception) Thrown if seq is null.
-
-
Method Detail
-
length
public int length()
Get this DNA sequence's length.- Returns:
- Length (number of sites).
-
score
public int score()
Get this DNA sequence's score.- Returns:
- Score.
-
score
public void score(int score)
Set this DNA sequence's score.- Parameters:
score- Score.
-
name
public java.lang.String name()
Get this DNA sequence's name.- Returns:
- Name. May be null.
-
name
public void name(java.lang.String name)
Set this DNA sequence's name.- Parameters:
name- Name. May be null.
-
copySites
public void copySites(DnaSequence seq)
Make this DNA sequence's sites be the same as the given DNA sequence. It is assumed that this DNA sequence and the given DNA sequence are the same length. This DNA sequence's score and name are unchanged.- Parameters:
seq- DNA sequence to copy.- Throws:
java.lang.NullPointerException- (unchecked exception) Thrown if seq is null.
-
distance
public double distance(DnaSequence seq)
Compute the distance between this DNA sequence and the given DNA sequence. It is assumed that this DNA sequence and the given DNA sequence are the same length. The distance is the number of differing sites between the two sequences (the Hamming distance).- Parameters:
seq- DNA sequence.- Returns:
- Distance.
-
setFitchAncestor
public void setFitchAncestor(DnaSequence seq1, DnaSequence seq2)
Make this DNA sequence be the ancestor of the two given DNA sequences in the Fitch parsimony score algorithm. This DNA sequence's sites are set based on seq1's and seq2's sites. It is assumed that this DNA sequence and the given DNA sequences are the same length. This DNA sequence's score is set to the sum of seq1's score, seq2's score, and the number of state changes at the ancestor. This DNA sequence's name is unchanged.- Parameters:
seq1- First child DNA sequence.seq2- Second child DNA sequence.
-
toString
public java.lang.String toString()
Returns a string version of this DNA sequence. The string consists of just the sequence of states (the score and name are not included).- Overrides:
toStringin classjava.lang.Object
-
-
DMelt 3.0 © DataMelt by jWork.ORG