edu.rit.compbio.phyl
Class MaximumParsimonyResults

java.lang.Object
  extended by edu.rit.compbio.phyl.MaximumParsimonyResults
All Implemented Interfaces:
Externalizable, Serializable, Iterable<int[]>

public class MaximumParsimonyResults
extends Object
implements Iterable<int[]>, Externalizable

Class MaximumParsimonyResults contains the results of a maximum parsimony phylogenetic tree construction algorithm. The results include:

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
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
 void add(int[] tree, int score)
          Add the given tree with the given parsimony score to this maximum parsimony results object.
 void addAll(MaximumParsimonyResults results)
          Add all the trees in the given maximum parsimony results object to this maximum parsimony results object.
 int capacity()
          Returns the capacity of this maximum parsimony results object.
 void clear()
          Clear this maximum parsimony results object.
 Iterator<int[]> iterator()
          Get an iterator for the trees in this maximum parsimony results object.
 void readExternal(ObjectInput in)
          Read this maximum parsimony results object from the given object input stream.
 void reduceScore(int score)
          Reduce this maximum parsimony results object's score to the given score.
 int score()
          Returns the parsimony score of this maximum parsimony results object.
 void score(int score)
          Sets the parsimony score of this maximum parsimony results object.
 int size()
          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.
 void writeExternal(ObjectOutput out)
          Write this maximum parsimony results object to the given object output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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:
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 ≤ isize()-1.
Returns:
Tree signature at index i.
Throws:
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 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:
iterator in interface Iterable<int[]>
Returns:
Iterator.

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Write this maximum parsimony results 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 maximum parsimony results 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.