// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
//
// Contact: phylosoft @ gmail . com
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
//
// Contact: phylosoft @ gmail . com
* <li>Mapping cost L <li>Phylogeny height - which is the largest distance from
* root to external node (minimizing of which is the same as "midpoint rooting")
* </ul>
* <li>Mapping cost L <li>Phylogeny height - which is the largest distance from
* root to external node (minimizing of which is the same as "midpoint rooting")
* </ul>
/**
* Returns the number of differently rooted trees which minimize the
* (rooting) "criterion" - as determined by method "infer".
/**
* Returns the number of differently rooted trees which minimize the
* (rooting) "criterion" - as determined by method "infer".
* @see #infer(Phylogeny,Phylogeny,boolean,boolean,boolean,boolean,int,boolean)
* @return number of differently rooted trees which minimized the criterion
*/
* @see #infer(Phylogeny,Phylogeny,boolean,boolean,boolean,boolean,int,boolean)
* @return number of differently rooted trees which minimized the criterion
*/
* @see #infer(Phylogeny,Phylogeny,boolean,boolean,boolean,boolean,int,boolean)
* @return the minimal difference in tree heights -- IF calculated by
* "infer"
* @see #infer(Phylogeny,Phylogeny,boolean,boolean,boolean,boolean,int,boolean)
* @return the minimal difference in tree heights -- IF calculated by
* "infer"
* <B>IMPORTANT </B>: If the tree is not rooted by minimizing the sum of
* duplications or the mapping cost L, then this number is NOT NECESSARILY
* the MINIMAL number of duplications.
* <B>IMPORTANT </B>: If the tree is not rooted by minimizing the sum of
* duplications or the mapping cost L, then this number is NOT NECESSARILY
* the MINIMAL number of duplications.
* @see #infer(Phylogeny,Phylogeny,boolean,boolean,boolean,boolean,int,boolean)
* @return (minimal) number of duplications
*/
* @see #infer(Phylogeny,Phylogeny,boolean,boolean,boolean,boolean,int,boolean)
* @return (minimal) number of duplications
*/
* @see #infer(Phylogeny,Phylogeny,boolean,boolean,boolean,boolean,int,boolean)
* @return the minimal mapping cost "L" -- IF calculated by "infer"
*/
* @see #infer(Phylogeny,Phylogeny,boolean,boolean,boolean,boolean,int,boolean)
* @return the minimal mapping cost "L" -- IF calculated by "infer"
*/
* @see #infer(Phylogeny,Phylogeny,boolean,boolean,boolean,boolean,int,boolean)
* @return the minimal tree height -- IF calculated by "infer"
*/
* @see #infer(Phylogeny,Phylogeny,boolean,boolean,boolean,boolean,int,boolean)
* @return the minimal tree height -- IF calculated by "infer"
*/
/**
* Returns the sum of times (in ms) needed to run method infer of class SDI.
* Final variable TIME needs to be set to true.
/**
* Returns the sum of times (in ms) needed to run method infer of class SDI.
* Final variable TIME needs to be set to true.
* 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
* 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
*/
public Phylogeny[] infer( final Phylogeny gene_tree,
final Phylogeny species_tree,
*/
public Phylogeny[] infer( final Phylogeny gene_tree,
final Phylogeny species_tree,
boolean minimize_sum_of_dup,
final boolean minimize_height,
final boolean return_trees,
boolean minimize_sum_of_dup,
final boolean minimize_height,
final boolean return_trees,
final ArrayList<Phylogeny> trees = new ArrayList<Phylogeny>();
Phylogeny[] tree_array = null;
List<PhylogenyBranch> branches = 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 ) ) {
final PhylogenyNode n = iter.next();
if ( n.isRoot() ) {
if ( ( n.getNumberOfDescendants() != 2 ) && ( n.getNumberOfDescendants() != 3 ) ) {
}
}
for( final PhylogenyNodeIterator iter = species_tree.iteratorPostorder(); iter.hasNext(); ) {
final PhylogenyNode n = iter.next();
if ( !n.isExternal() && ( n.getNumberOfDescendants() != 2 ) ) {
}
}
for( final PhylogenyNodeIterator iter = species_tree.iteratorPostorder(); iter.hasNext(); ) {
final PhylogenyNode n = iter.next();
if ( !n.isExternal() && ( n.getNumberOfDescendants() != 2 ) ) {
}
}
g.reRoot( g.getFirstExternalNode() );
branches = SDIR.getBranchesInPreorder( g );
if ( minimize_mapping_cost || minimize_sum_of_dup ) {
}
}
g.reRoot( g.getFirstExternalNode() );
branches = SDIR.getBranchesInPreorder( g );
if ( minimize_mapping_cost || minimize_sum_of_dup ) {
duplications = sdise.getDuplicationsSum();
}
final Set<PhylogenyBranch> used_root_placements = new HashSet<PhylogenyBranch>();
duplications = sdise.getDuplicationsSum();
}
final Set<PhylogenyBranch> used_root_placements = new HashSet<PhylogenyBranch>();
prev_root_c2 = prev_root.getChildNode2();
prev_root_was_dup = prev_root.isDuplication();
final PhylogenyBranch current_branch = branches.get( j );
prev_root_c2 = prev_root.getChildNode2();
prev_root_was_dup = prev_root.isDuplication();
final PhylogenyBranch current_branch = branches.get( j );
if ( minimize_mapping_cost || minimize_sum_of_dup ) {
duplications = sdise.updateM( prev_root_was_dup, prev_root_c1, prev_root_c2 );
}
if ( minimize_mapping_cost || minimize_sum_of_dup ) {
duplications = sdise.updateM( prev_root_was_dup, prev_root_c1, prev_root_c2 );
}
height = height__diff[ 0 ];
diff = height__diff[ 1 ];
if ( Math.abs( diff ) < SDIR.ZERO_DIFF ) {
height = height__diff[ 0 ];
diff = height__diff[ 1 ];
if ( Math.abs( diff ) < SDIR.ZERO_DIFF ) {
PhylogenyNode node = t.getRoot();
while ( !node.isRoot() || !two.contains( node.getId() ) ) {
if ( !node.isExternal() && !two.contains( node.getId() ) ) {
PhylogenyNode node = t.getRoot();
while ( !node.isRoot() || !two.contains( node.getId() ) ) {
if ( !node.isExternal() && !two.contains( node.getId() ) ) {