+
+ private HashMap<Long, PhylogenyNode> getIdToNodeMap() {
+ return _id_to_node_map;
+ }
+
+ /**
+ * Return Node by TaxonomyId Olivier CHABROL :
+ * olivier.chabrol@univ-provence.fr
+ *
+ * @param taxonomyID
+ * search taxonomy identifier
+ * @param nodes
+ * sublist node to search
+ * @return List node with the same taxonomy identifier
+ */
+ private List<PhylogenyNode> getNodeByTaxonomyID( final String taxonomyID, final List<PhylogenyNode> nodes ) {
+ final List<PhylogenyNode> retour = new ArrayList<PhylogenyNode>();
+ for( final PhylogenyNode node : nodes ) {
+ if ( taxonomyID.equals( PhylogenyMethods.getTaxonomyIdentifier( node ) ) ) {
+ retour.add( node );
+ }
+ }
+ return retour;
+ }
+
+ /**
+ * List all species contains in all leaf under a node Olivier CHABROL :
+ * olivier.chabrol@univ-provence.fr
+ *
+ * @param node
+ * PhylogenyNode whose sub node species are returned
+ * @return species contains in all leaf under the param node
+ */
+ private List<String> getSubNodeTaxonomy( final PhylogenyNode node ) {
+ final List<String> taxonomyList = new ArrayList<String>();
+ final List<PhylogenyNode> childs = node.getAllExternalDescendants();
+ String speciesId = null;
+ for( final PhylogenyNode phylogenyNode : childs ) {
+ // taxId = new Long(phylogenyNode.getTaxonomyID());
+ speciesId = PhylogenyMethods.getTaxonomyIdentifier( phylogenyNode );
+ if ( !taxonomyList.contains( speciesId ) ) {
+ taxonomyList.add( speciesId );
+ }
+ }
+ return taxonomyList;
+ }
+
+ /**
+ * Create a map [<PhylogenyNode, List<String>], the list contains the
+ * species contains in all leaf under phylogeny node Olivier CHABROL :
+ * olivier.chabrol@univ-provence.fr
+ *
+ * @param node
+ * the tree root node
+ * @param map
+ * map to fill
+ */
+ private void getTaxonomyMap( final PhylogenyNode node, final Map<PhylogenyNode, List<String>> map ) {
+ // node is leaf
+ if ( node.isExternal() ) {
+ return;
+ }
+ map.put( node, getSubNodeTaxonomy( node ) );
+ getTaxonomyMap( node.getChildNode1(), map );
+ getTaxonomyMap( node.getChildNode2(), map );
+ }
+
+ private boolean isAllowMultipleParents() {
+ return _allow_multiple_parents;
+ }
+
+ /**
+ * Util method to check if all element of a list is contains in the
+ * rangeList. Olivier CHABROL : olivier.chabrol@univ-provence.fr
+ *
+ * @param list
+ * list to be check
+ * @param rangeList
+ * the range list to compare
+ * @return <code>true</code> if all param list element are contains in param
+ * rangeList, <code>false</code> otherwise.
+ */
+ private boolean isContains( final List<String> list, final List<String> rangeList ) {
+ if ( list.size() > rangeList.size() ) {
+ return false;
+ }
+ String l = null;
+ for( final Iterator<String> iterator = list.iterator(); iterator.hasNext(); ) {
+ l = iterator.next();
+ if ( !rangeList.contains( l ) ) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Hashes the ID number of each PhylogenyNode of this Phylogeny to its
+ * corresponding PhylogenyNode, in order to make method getNode( id ) run in
+ * constant time. Important: The user is responsible for calling this method
+ * (again) after this Phylogeny has been changed/created/renumbered.
+ */
+ private void reHashIdToNodeMap() {
+ if ( isEmpty() ) {
+ return;
+ }
+ setIdToNodeMap( new HashMap<Long, PhylogenyNode>() );
+ for( final PhylogenyNodeIterator iter = iteratorPreorder(); iter.hasNext(); ) {
+ final PhylogenyNode node = iter.next();
+ getIdToNodeMap().put( node.getId(), node );
+ }
+ }
+
+ private void setAllowMultipleParents( final boolean allow_multiple_parents ) {
+ _allow_multiple_parents = allow_multiple_parents;
+ }