\r
public class GSDIR implements GSDII {\r
\r
- private final int _min_duplications_sum;\r
- private final int _speciations_sum;\r
-\r
- @Override\r
- public int getSpeciationsSum() {\r
- return _speciations_sum;\r
- }\r
+ private final int _min_duplications_sum;\r
+ private final int _speciations_sum;\r
private final BasicDescriptiveStatistics _duplications_sum_stats;\r
- private final List<Phylogeny> _min_duplications_sum_gene_trees;\r
+ private Phylogeny _min_duplications_sum_gene_tree;\r
private final List<PhylogenyNode> _stripped_gene_tree_nodes;\r
private final List<PhylogenyNode> _stripped_species_tree_nodes;\r
private final Set<PhylogenyNode> _mapped_species_tree_nodes;\r
final boolean strip_species_tree ) throws SDIException {\r
final NodesLinkingResult nodes_linking_result = GSDI.linkNodesOfG( gene_tree,\r
species_tree,\r
- null,\r
strip_gene_tree,\r
strip_species_tree );\r
_stripped_gene_tree_nodes = nodes_linking_result.getStrippedGeneTreeNodes();\r
}\r
int min_duplications_sum = Integer.MAX_VALUE;\r
int speciations_sum = 0;\r
- _min_duplications_sum_gene_trees = new ArrayList<Phylogeny>();\r
_duplications_sum_stats = new BasicDescriptiveStatistics();\r
for( final PhylogenyBranch branch : gene_tree_branches_post_order ) {\r
gene_tree.reRoot( branch );\r
PhylogenyMethods.preOrderReId( species_tree );\r
//TEST, remove later\r
- // for( final PhylogenyNodeIterator it = _gene_tree.iteratorPostorder(); it.hasNext(); ) {\r
+ // for( final PhylogenyNodeIterator it = gene_tree.iteratorPostorder(); it.hasNext(); ) {\r
// final PhylogenyNode g = it.next();\r
// if ( g.isInternal() ) {\r
// g.setLink( null );\r
// }\r
// }\r
- final GSDIsummaryResult gsdi_result = GSDI.geneTreePostOrderTraversal( gene_tree, true );\r
+ final GSDIsummaryResult gsdi_result = GSDI.geneTreePostOrderTraversal( gene_tree,\r
+ true,\r
+ min_duplications_sum );\r
+ if ( gsdi_result == null ) {\r
+ continue;\r
+ }\r
if ( gsdi_result.getDuplicationsSum() < min_duplications_sum ) {\r
min_duplications_sum = gsdi_result.getDuplicationsSum();\r
speciations_sum = gsdi_result.getSpeciationsSum();\r
- _min_duplications_sum_gene_trees.clear();\r
- _min_duplications_sum_gene_trees.add( gene_tree.copy() );\r
- //_speciations_sum\r
+ _min_duplications_sum_gene_tree = gene_tree.copy();\r
}\r
else if ( gsdi_result.getDuplicationsSum() == min_duplications_sum ) {\r
- _min_duplications_sum_gene_trees.add( gene_tree.copy() );\r
+ final List<Phylogeny> l = new ArrayList<Phylogeny>();\r
+ l.add( _min_duplications_sum_gene_tree );\r
+ l.add( gene_tree );\r
+ final int index = getIndexesOfShortestTree( l ).get( 0 );\r
+ if ( index == 1 ) {\r
+ _min_duplications_sum_gene_tree = gene_tree.copy();\r
+ }\r
}\r
_duplications_sum_stats.addValue( gsdi_result.getDuplicationsSum() );\r
}\r
_speciations_sum = speciations_sum;\r
}\r
\r
- public int getMinDuplicationsSum() {\r
- return _min_duplications_sum;\r
- }\r
-\r
- public List<Phylogeny> getMinDuplicationsSumGeneTrees() {\r
- return _min_duplications_sum_gene_trees;\r
- }\r
-\r
public BasicDescriptiveStatistics getDuplicationsSumStats() {\r
return _duplications_sum_stats;\r
}\r
return _mapped_species_tree_nodes;\r
}\r
\r
+ public int getMinDuplicationsSum() {\r
+ return _min_duplications_sum;\r
+ }\r
+\r
+ public Phylogeny getMinDuplicationsSumGeneTree() {\r
+ return _min_duplications_sum_gene_tree;\r
+ }\r
+\r
@Override\r
public final SortedSet<String> getReMappedScientificNamesFromGeneTree() {\r
return _scientific_names_mapped_to_reduced_specificity;\r
}\r
\r
@Override\r
+ public int getSpeciationsSum() {\r
+ return _speciations_sum;\r
+ }\r
+\r
+ @Override\r
public List<PhylogenyNode> getStrippedExternalGeneTreeNodes() {\r
return _stripped_gene_tree_nodes;\r
}\r