* Array) must be no lower than 1
* @return array of rooted Trees with duplication vs. speciation assigned if
* return_trees is set to true, null otherwise
+ * @throws SDIException
*/
public Phylogeny[] infer( final Phylogeny gene_tree,
final Phylogeny species_tree,
boolean minimize_sum_of_dup,
final boolean minimize_height,
final boolean return_trees,
- int max_trees_to_return ) {
+ int max_trees_to_return ) throws SDIException {
init();
- SDIse sdise = null;
+ SDI sdise = null;
final ArrayList<Phylogeny> trees = new ArrayList<Phylogeny>();
Phylogeny[] tree_array = null;
List<PhylogenyBranch> branches = null;
final PhylogenyNode n = iter.next();
if ( n.isRoot() ) {
if ( ( n.getNumberOfDescendants() != 2 ) && ( n.getNumberOfDescendants() != 3 ) ) {
- throw new IllegalArgumentException( "attempt to run SDI on gene tree with "
- + n.getNumberOfDescendants() + " child nodes at its root" );
+ throw new SDIException( "gene tree has " + n.getNumberOfDescendants() + " descendents at its root" );
}
}
else if ( !n.isExternal() && ( n.getNumberOfDescendants() != 2 ) ) {
- throw new IllegalArgumentException( "attempt to run SDI on gene tree which is not completely binary [found node with "
- + n.getNumberOfDescendants() + " child nodes]" );
+ throw new SDIException( "gene tree is not completely binary" );
}
}
for( final PhylogenyNodeIterator iter = species_tree.iteratorPostorder(); iter.hasNext(); ) {
final PhylogenyNode n = iter.next();
if ( !n.isExternal() && ( n.getNumberOfDescendants() != 2 ) ) {
- throw new IllegalArgumentException( "attempt to run SDI with a species tree which is not completely binary (after stripping) [found node with "
- + n.getNumberOfDescendants() + " child nodes]" );
+ throw new SDIException( "species tree (after stripping) is not completely binary" );
}
}
g.reRoot( g.getFirstExternalNode() );
branches = SDIR.getBranchesInPreorder( g );
if ( minimize_mapping_cost || minimize_sum_of_dup ) {
- sdise = new SDIse( g, species_tree );
+ sdise = new SDI( g, species_tree );
duplications = sdise.getDuplicationsSum();
}
final Set<PhylogenyBranch> used_root_placements = new HashSet<PhylogenyBranch>();
height = height__diff[ 0 ];
diff = height__diff[ 1 ];
if ( Math.abs( diff ) < SDIR.ZERO_DIFF ) {
- sdise = new SDIse( g, species_tree );
+ sdise = new SDI( g, species_tree );
min_duplications = sdise.getDuplicationsSum();
min_height = height;
min_diff = Math.abs( diff );