From: <car...@us...> - 2009-06-25 13:25:14
|
Revision: 2695 http://obo.svn.sourceforge.net/obo/?rev=2695&view=rev Author: cartik73 Date: 2009-06-25 13:25:07 +0000 (Thu, 25 Jun 2009) Log Message: ----------- Cleaned up some code and changed some parameter names Modified Paths: -------------- OBD-WS/trunk/src/org/obd/ws/util/TaxonTree.java Modified: OBD-WS/trunk/src/org/obd/ws/util/TaxonTree.java =================================================================== --- OBD-WS/trunk/src/org/obd/ws/util/TaxonTree.java 2009-06-24 23:07:35 UTC (rev 2694) +++ OBD-WS/trunk/src/org/obd/ws/util/TaxonTree.java 2009-06-25 13:25:07 UTC (rev 2695) @@ -4,13 +4,14 @@ import java.io.IOException; import java.util.HashMap; import java.util.HashSet; +import java.util.List; import java.util.Map; import java.util.Set; import org.obd.ws.util.dto.NodeDTO; /** - * This is a tree order for a group on taxa, with a root + * This is a tree order for a group of taxa, with a root * (the MRCA of all the taxa), branches and leaves. At each node * in the tree, the grouping of qualities exhibited by the taxa * at and below that node are stored. So are the numbers of @@ -21,13 +22,18 @@ public class TaxonTree { private NodeDTO root; - private Map<NodeDTO, Set<NodeDTO>> branchingPointsAndChildren; private Set<NodeDTO> leaves; + /** This structure keeps track of branching points and their children. + * NOTE: The root */ + private Map<NodeDTO, Set<NodeDTO>> parentToChildrenMap; + + /**This structure keeps track of all the EQs exhibited by a node and its descendants */ private Map<NodeDTO, Map<NodeDTO, Set<NodeDTO>>> nodeToEQMap; + /** This structure keeps track of annotation counts for the node and its descendants **/ private Map<NodeDTO, Integer> nodeToAnnotationCountMap; /** This has been added tp keep track of reif link ids - Cartik 061909*/ - private Map<NodeDTO, String[]> nodeToAnnotationMap; + private Map<NodeDTO, List<String>> nodeToReifIdsMap; /* * GETTERs and SETTERs @@ -40,14 +46,6 @@ this.root = root; } - public Map<NodeDTO, Set<NodeDTO>> getBranchingPointsAndChildren() { - return branchingPointsAndChildren; - } - public void setBranchingPointsAndChildren( - Map<NodeDTO, Set<NodeDTO>> branchingPointsAndChidren) { - this.branchingPointsAndChildren = branchingPointsAndChidren; - } - public Set<NodeDTO> getLeaves() { return leaves; } @@ -55,6 +53,15 @@ this.leaves = leaves; } + public Map<NodeDTO, Set<NodeDTO>> getParentToChildrenMap() { + return parentToChildrenMap; + } + public void setParentToChildrenMap( + Map<NodeDTO, Set<NodeDTO>> parentToChildrenMap) { + this.parentToChildrenMap = parentToChildrenMap; + } + + public Map<NodeDTO, Map<NodeDTO, Set<NodeDTO>>> getNodeToEQMap() { return nodeToEQMap; } @@ -71,20 +78,22 @@ this.nodeToAnnotationCountMap = nodeToAnnotationCountMap; } - public Map<NodeDTO, String[]> getNodeToAnnotationMap() { - return nodeToAnnotationMap; + public Map<NodeDTO, List<String>> getNodeToReifIdsMap() { + return nodeToReifIdsMap; } - public void setNodeToAnnotationMap(Map<NodeDTO, String[]> nodeToAnnotationMap) { - this.nodeToAnnotationMap = nodeToAnnotationMap; + public void setNodeToReifIdsMap(Map<NodeDTO, List<String>> nodeToReifIdsMap) { + this.nodeToReifIdsMap = nodeToReifIdsMap; } + /** * The constructor simply initializes the branches, the leaves, the qualities to node - * map and the node to annotation count map + * map, node to reif ids map and the node to annotation count map */ public TaxonTree(){ - branchingPointsAndChildren = new HashMap<NodeDTO, Set<NodeDTO>>(); + parentToChildrenMap = new HashMap<NodeDTO, Set<NodeDTO>>(); leaves = new HashSet<NodeDTO>(); nodeToEQMap = new HashMap<NodeDTO, Map<NodeDTO, Set<NodeDTO>>>(); + nodeToReifIdsMap = new HashMap<NodeDTO, List<String>>(); nodeToAnnotationCountMap = new HashMap<NodeDTO, Integer>(); } @@ -94,11 +103,11 @@ * @CAUTION Hardcoded file path for writing out the taxonomy * @param node - the node whose children are to printed along with the node * itself - * @param tabCt - the number of indents - * @param bw - buffered reader which contains a pointer to a text file + * @param tabCt - the number of indents. used for formatting the output text + * @param writer - buffered writer which contains a pointer to a text file * @throws IOException */ - public void printTaxonomy(NodeDTO node, int tabCt, BufferedWriter bw) + public void printTaxonomy(NodeDTO node, int tabCt, BufferedWriter writer) throws IOException{ String tabs = ""; @@ -106,22 +115,22 @@ tabs += " "; } if(!this.getLeaves().contains(node)){//this is not a leaf node - if(this.getBranchingPointsAndChildren().get(node) != null ){ - for(NodeDTO child : this.getBranchingPointsAndChildren().get(node)){ - bw.write(tabs + child.getId() + "\t" + child.getName() + "\n"); - bw.write(tabs + "Annotation Count: " + this.getNodeToAnnotationCountMap().get(child) + "\n"); + if(this.getParentToChildrenMap().get(node) != null ){ + for(NodeDTO child : this.getParentToChildrenMap().get(node)){ + writer.write(tabs + child.getId() + "\t" + child.getName() + "\n"); + writer.write(tabs + "Annotation Count: " + this.getNodeToAnnotationCountMap().get(child) + "\n"); if(this.getNodeToEQMap().containsKey(child)){ - Map<NodeDTO, Set<NodeDTO>> e2qMap = this.getNodeToEQMap().get(child); - for(NodeDTO e : e2qMap.keySet()){ - bw.write(tabs + "Exhibits " + e.getName() + " that are: "); - for(NodeDTO q : e2qMap.get(e)){ - bw.write(q.getName() + " "); + Map<NodeDTO, Set<NodeDTO>> eToQMap = this.getNodeToEQMap().get(child); + for(NodeDTO e : eToQMap.keySet()){ + writer.write(tabs + "Exhibits " + e.getName() + " that are: "); + for(NodeDTO q : eToQMap.get(e)){ + writer.write(q.getName() + " "); } - bw.write("\n"); + writer.write("\n"); } } - printTaxonomy(child, tabCt + 1, bw); + printTaxonomy(child, tabCt + 1, writer); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |