# Class FitchParsimony

java.lang.Object
jebl.evolution.parsimony.FitchParsimony

All Implemented Interfaces:
  `ParsimonyCriterion`

public class FitchParsimony extends Object implements ParsimonyCriterion
Class for reconstructing characters using Fitch parsimony. This is intended to be much faster than the static methods in the utility "Parsimony" class.

Version:
  $Id: FitchParsimony.java 604 2007-01-04 20:22:42Z msuchard $
Author:
  Andrew Rambaut, Alexei Drummond

## Constructor Summary

Constructors
Constructor
Description
`FitchParsimony(List<Pattern> patterns, boolean gapsAreStates)`
`FitchParsimony(Patterns patterns, boolean gapsAreStates)`

## Method Summary

Modifier and Type
Method
Description
`double`
`getScore(Tree tree)`
Calculates the minimum number of steps for the parsimony reconstruction for the given tree.
`double[]`
`getSiteScores(Tree tree)`
Calculates the minimum number of siteScores for the parsimony reconstruction of a a set of character patterns on a tree.
`State[]`
`getStates(Tree tree, Node node)`
Returns the reconstructed character states for a given node in the tree.

### Methods inherited from class Object

`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### FitchParsimony

public FitchParsimony(List<Pattern> patterns, boolean gapsAreStates)

### FitchParsimony

public FitchParsimony(Patterns patterns, boolean gapsAreStates)

## Method Details

### getSiteScores

public double[] getSiteScores(Tree tree)
Calculates the minimum number of siteScores for the parsimony reconstruction of a a set of character patterns on a tree. This only does the first pass of the Fitch algorithm so it does not store ancestral state reconstructions.

Specified by:
  `getSiteScores` in interface `ParsimonyCriterion`
Parameters:
  `tree` - a tree object to reconstruct the characters on
Returns:
  number of parsimony siteScores

### getScore

public double getScore(Tree tree)
Description copied from interface: `ParsimonyCriterion`
Calculates the minimum number of steps for the parsimony reconstruction for the given tree. It is expected that the implementation's constructor will be set up with the characters so that repeated calls can be made to this function to evaluate different trees.

Specified by:
  `getScore` in interface `ParsimonyCriterion`
Parameters:
  `tree` - a tree object to reconstruct the characters on
Returns:
  the total score

### getStates

public State[] getStates(Tree tree, Node node)
Returns the reconstructed character states for a given node in the tree. If this method is repeatedly called with the same tree and patterns then only the first call will reconstruct the states and each subsequent call will return the stored states.

Specified by:
  `getStates` in interface `ParsimonyCriterion`
Parameters:
  `tree` - a tree object to reconstruct the characters on
  `node` - the node of the tree
Returns:
  an array containing the reconstructed states for this node