Пример #1
0
  /**
   * @param xmlTree
   * @param xmlNode
   * @param mesNode
   * @param mesTree
   */
  private void readTree(
      Network<?> xmlTree, Node xmlNode, MesquiteTree mesTree, int mesNode, Map otuLookup) {

    // store the ID of the OTU, if there is one. We do this
    // in a separate hash from whence we later retrieve only
    // those OTUs that are actually terminal in the topology.
    OTU xmlOTU = xmlNode.getOTU();
    if (xmlOTU != null) {
      Taxa mesTaxa = mesTree.getTaxa();
      int mesTaxon = mesTaxa.findByUniqueID(xmlOTU.getId());
      otuLookup.put(mesNode, mesTaxon);
    }

    // copy the node label and the RDFa annotations
    mesTree.setNodeLabel(xmlNode.getLabel(), mesNode);
    readAnnotations(mesTree, xmlNode, mesNode, mesTree);

    // iterate over children
    for (Node xmlChild : xmlTree.getOutNodes(xmlNode)) {

      // make child, copy annotations
      int mesChild = mesTree.sproutDaughter(mesNode, false);

      // copy branch length, if any, and branch annotations
      Edge edge = xmlTree.getEdge(xmlNode, xmlChild);
      if (edge.getLength() != null) {
        mesTree.setBranchLength(mesChild, edge.getLength().doubleValue(), false);
      }
      readAnnotations(mesTree, edge, mesChild, mesTree);

      // traverse deeper
      readTree(xmlTree, xmlChild, mesTree, mesChild, otuLookup);
    }
  }