edu.rit.compbio.phyl
Class MaximumParsimonyResults
- java.lang.Object
-
- edu.rit.compbio.phyl.MaximumParsimonyResults
-
- All Implemented Interfaces:
- java.io.Externalizable, java.io.Serializable, java.lang.Iterable<int[]>
public class MaximumParsimonyResults extends java.lang.Object implements java.lang.Iterable<int[]>, java.io.ExternalizableClass MaximumParsimonyResults contains the results of a maximum parsimony phylogenetic tree construction algorithm. The results include:- List of maximum parsimony phylogenetic trees. The list contains zero or more tree signatures representing the phylogenetic trees found during the search. If no tree with a score better than the initial bound was found, the list is empty. For further information about the tree signatures, see the toTree() method of class DnaSequenceList.
- Parsimony score. This contains the best (smallest) Fitch parsimony score found during the search. This is also the Fitch parsimony score of the phylogenetic trees in the tree list (if any).
Note: Class MaximumParsimonyResults is not multiple thread safe. It is intended to be used as a per-thread variable in a parallel program.
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description MaximumParsimonyResults()Construct a new uninitialized maximum parsimony results object.MaximumParsimonyResults(int capacity)Construct a new maximum parsimony results object.MaximumParsimonyResults(MaximumParsimonyResults results)Construct a new maximum parsimony results object that is a copy of the given maximum parsimony results object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidadd(int[] tree, int score)Add the given tree with the given parsimony score to this maximum parsimony results object.voidaddAll(MaximumParsimonyResults results)Add all the trees in the given maximum parsimony results object to this maximum parsimony results object.intcapacity()Returns the capacity of this maximum parsimony results object.voidclear()Clear this maximum parsimony results object.java.util.Iterator<int[]>iterator()Get an iterator for the trees in this maximum parsimony results object.voidreadExternal(java.io.ObjectInput in)Read this maximum parsimony results object from the given object input stream.voidreduceScore(int score)Reduce this maximum parsimony results object's score to the given score.intscore()Returns the parsimony score of this maximum parsimony results object.voidscore(int score)Sets the parsimony score of this maximum parsimony results object.intsize()Returns the size of this maximum parsimony results object.int[]tree(int i)Returns the tree at the given index in this maximum parsimony results object.voidwriteExternal(java.io.ObjectOutput out)Write this maximum parsimony results object to the given object output stream.
-
-
-
Constructor Detail
-
MaximumParsimonyResults
public MaximumParsimonyResults()
Construct a new uninitialized maximum parsimony results object. This constructor is for use only by object deserialization.
-
MaximumParsimonyResults
public MaximumParsimonyResults(int capacity)
Construct a new maximum parsimony results object. The tree list is initialized to an empty list with the given capacity. The parsimony score is initialized to Integer.MAX_VALUE.- Parameters:
capacity- Capacity.- Throws:
java.lang.IllegalArgumentException- (unchecked exception) Thrown if capacity ≤ 0.
-
MaximumParsimonyResults
public MaximumParsimonyResults(MaximumParsimonyResults results)
Construct a new maximum parsimony results object that is a copy of the given maximum parsimony results object.- Parameters:
results- Maximum parsimony results object to copy.
-
-
Method Detail
-
clear
public void clear()
Clear this maximum parsimony results object. Afterwards, the tree list is empty and the parsimony score is Integer.MAX_VALUE.
-
add
public void add(int[] tree, int score)Add the given tree with the given parsimony score to this maximum parsimony results object. The following invariant is maintained: This maximum parsimony results object contains only those trees with the smallest parsimony score seen so far; and only the first C such trees are stored, where C is the capacity.- Parameters:
tree- Tree signature.score- Tree's parsimony score.
-
addAll
public void addAll(MaximumParsimonyResults results)
Add all the trees in the given maximum parsimony results object to this maximum parsimony results object. The following invariant is maintained: This maximum parsimony results object contains only those trees with the smallest parsimony score seen so far; and only the first C such trees are stored, where C is the capacity.- Parameters:
results- Maximum parsimony results object containing trees to add.
-
size
public int size()
Returns the size of this maximum parsimony results object.- Returns:
- Size (number of trees stored).
-
capacity
public int capacity()
Returns the capacity of this maximum parsimony results object.- Returns:
- Capacity (maximum number of trees that can be stored).
-
tree
public int[] tree(int i)
Returns the tree at the given index in this maximum parsimony results object.- Parameters:
i- Index, 0 ≤ i ≤ size()-1.- Returns:
- Tree signature at index i.
- Throws:
java.lang.IndexOutOfBoundsException- (unchecked exception) Thrown if i is out of bounds.
-
score
public int score()
Returns the parsimony score of this maximum parsimony results object.- Returns:
- Parsimony score.
-
score
public void score(int score)
Sets the parsimony score of this maximum parsimony results object.- Parameters:
score- Parsimony score.
-
reduceScore
public void reduceScore(int score)
Reduce this maximum parsimony results object's score to the given score. If this object's score is less than or equal to score, this object is unchanged. If this object's score is greater than score, this object is cleared and its score is set to score.- Parameters:
score- Parsimony score.
-
iterator
public java.util.Iterator<int[]> iterator()
Get an iterator for the trees in this maximum parsimony results object. The iterator does not support removing elements. The iterator is a "fail-fast" iterator that throws a ConcurrentModificationException if one thread changes this maximum parsimony results object while another thread is iterating over the trees.- Specified by:
iteratorin interfacejava.lang.Iterable<int[]>- Returns:
- Iterator.
-
writeExternal
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOExceptionWrite this maximum parsimony results 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 maximum parsimony results 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