Examples of PhyloTree


Examples of org.cipres.treebase.domain.tree.PhyloTree

    // Build the all taxon labels sets:
    for (AnalysisStep step : getAnalysisSteps()) {

      for (AnalyzedData analyzedData : step.getDataSetReadOnly()) {
        Matrix m = analyzedData.getMatrixData();
        PhyloTree tree = analyzedData.getTreeData();

        if (m != null) {
          if (matrixTaxonLabels.isEmpty()) {
            matrixTaxonLabels.addAll(m.getAllTaxonLabels());
          } else if (!matrixTaxonLabels.containsAll(m.getAllTaxonLabels())) {
            // all matrices must have the same set of taxon labels.
            result.addErrorMessage("Error: matrix(id " + m.getId()
              + "): all matrices must have the same set of taxon labels");
          }
        }

        if (tree != null) {
          allTrees.add(tree);
        }
      }
    }

    // tree taxon labels must be a subset of matrix taxon labels.
    for (PhyloTree tree : allTrees) {
      if (!matrixTaxonLabels.containsAll(tree.getAllTaxonLabels())) {
        result.addErrorMessage("Error: tree(id " + tree.getId()
          + ") taxon labels must be a subset of matrix taxon labels");
      }
    }

    setValidated(result.isSuccessful());
View Full Code Here

Examples of org.cipres.treebase.domain.tree.PhyloTree

   */
  @Transient
  public Set<PhyloTree> getTrees() {
    Set<PhyloTree> trees = new HashSet<PhyloTree> ();
    for (AnalyzedData ad : getAnalyzedData()) {
      PhyloTree t = ad.getTreeData();
      if (t != null) {
        trees.add(t);
      }
    }
    return trees;
View Full Code Here

Examples of org.cipres.treebase.domain.tree.PhyloTree

          for (AnalyzedData ad : as.getDataSetReadOnly()) {
            if (tr == null) {
              tr = rt.beginTransaction();
            }
            Matrix m = ad.getMatrixData();
            PhyloTree t = ad.getTreeData();
            if (m != null) {
              System.err.println("  Repatriating matrix " + m.getId()
                  + " to study " + s.getId() + " submission " + sub.getId());
             
              if (m.getStudy() != s) {
                String nexusFileName = m.getNexusFileName();
                Map<String,String> nexusMap = m.getStudy().getNexusFiles();
                String nexusFile = nexusMap.remove(nexusFileName);
                s.getNexusFiles().put(nexusFileName, nexusFile);
                m.setStudy(s);
              }
             
              if (! ms.contains(m)) {
                Submission oldSub = sh.findByMatrix(m);
                if (oldSub != null) {
                  oldSub.removeMatrix(m);
                  sh.flush();
                }
                sub.addMatrix(m);
              }
            } else if (t != null) {
              System.err.println("  Repatriating tree " + t.getId()
                  + " to study " + s.getId() + " submission " + sub.getId());
              if (t.getStudy() != s) {
                String nexusFileName = t.getNexusFileName();
                Map<String,String> nexusMap = t.getStudy().getNexusFiles();
                String nexusFile = nexusMap.remove(nexusFileName);
                s.getNexusFiles().put(nexusFileName, nexusFile);
                t.setStudy(s);
              }
              TreeBlock tb = t.getTreeBlock();
              if (tb == null) {
                System.err.println("  No tree block!");
              } else if (! tbs.contains(tb)) {
                Submission oldSub = sh.findByTreeBlock(tb);
                if (oldSub != null) {
View Full Code Here

Examples of org.cipres.treebase.domain.tree.PhyloTree

    }
     
  }

  public int setTreeNChar(PhyloTree tDetached) {
    PhyloTree t = treeService.findByID(tDetached.getId());
    int nTax = 0;
    for (PhyloTreeNode n : t.getTreeNodesReadOnly())
      if (n.isLeaf()) nTax++;
    t.setnTax(nTax);
    return nTax;
  }
View Full Code Here

Examples of org.cipres.treebase.domain.tree.PhyloTree

  public void setTreeService(PhyloTreeService treeService) {
    this.treeService = treeService;
  }

  public void annotateTree(Long treeId) {
    PhyloTree t = getTreeService().findByID(treeId);
    if (t == null) {
      getErrorStream().println("Tree " + treeId + ": No such tree");
      System.exit(1);
    }
    t = getTreeService().resurrect(t);
   
    getErrorStream().println("Got tree " + t.getId() + " '" + t.getTitle() + "'");

      PhyloTreeNode root = t.getRootNode();
      long left = root.getLeftNode(), right = 0;
      if (left != 0) { right = root.getRightNode(); }
     
      if (left == 0 || right == 0) {
        t.updateSubtreeBounds();
        getErrorStream().println("Finished with tree " + treeId + ".");
      } else {
        getErrorStream().println("Tree " + treeId + " already annotated");
      }
  }
View Full Code Here

Examples of org.cipres.treebase.domain.tree.PhyloTree

    long treeId = jdbcTemplate.queryForLong(treeStr);
    logger.info("tree id: " + treeId);
    assertTrue(treeId > 0);

    // 2. query
    PhyloTree m = (PhyloTree) loadObject(PhyloTree.class, treeId);
    assertTrue(m != null);

    Collection<AnalyzedData> data = getFixture().findByTree(m);
    assertTrue(data != null && !data.isEmpty());

    // 3. verify
    long dataId = data.iterator().next().getId();
    String sqlStr = "select count(*) from analyzedData where AnalyzedData_id = " + dataId
      + " and phylotree_id = " + m.getId();
    int count = jdbcTemplate.queryForInt(sqlStr);
    assertTrue(count > 0);

    if (logger.isInfoEnabled()) {
      logger.info(testName + " verified.");
View Full Code Here

Examples of org.cipres.treebase.domain.tree.PhyloTree

  private class FakeTreeService extends MockPhyloTreeService {
    @Override
    public Set<PhyloTree> findTreesByLabel(String label) {
      Set<PhyloTree> results = new HashSet<PhyloTree>();
      if (label.equals(TID)) {
        results.add(new PhyloTree());
      }
      return results;
    }
View Full Code Here

Examples of org.cipres.treebase.domain.tree.PhyloTree

    long treeId = jdbcTemplate.queryForLong(treeStr);
    logger.info("tree id: " + treeId);
    assertTrue(treeId > 0);

    // 2. query
    PhyloTree tree = (PhyloTree) loadObject(PhyloTree.class, treeId);
    assertTrue(tree != null);

    Submission s = getFixture().findByTree(tree);
    assertTrue(s != null);

    // 3. verify
    String sqlStr = "select count(*) from sub_treeblock st, phylotree t where st.submission_id = " + s.getId()
      + " and st.treeblock_id = t.treeblock_id and t.phylotree_id = " + tree.getId();
    int count = jdbcTemplate.queryForInt(sqlStr);
    assertTrue(count == 1);

    if (logger.isInfoEnabled()) {
      logger.info(testName + " verified.");
View Full Code Here

Examples of org.cipres.treebase.domain.tree.PhyloTree

    }
    Iterator<Network<?>> xmlNetworkIterator = xmlTreeBlock.iterator();
    while ( xmlNetworkIterator.hasNext() ) {
      Network<?> xmlNetwork = xmlNetworkIterator.next();
      if ( xmlNetwork instanceof Tree ) {
        PhyloTree tbPhyloTree = fromXmlToTreeBase((Tree<?>) xmlNetwork);
        tbPhyloTree.setStudy(getStudy());
        tbTreeBlock.addPhyloTree(tbPhyloTree);
      }       
    }   
    return tbTreeBlock;
  }
View Full Code Here

Examples of org.cipres.treebase.domain.tree.PhyloTree

   *
   * @param xmlTree
   * @return
   */
  private PhyloTree fromXmlToTreeBase(Tree<?> xmlTree) {
    PhyloTree tbPhyloTree = new PhyloTree();
    tbPhyloTree.setLabel(xmlTree.getLabel());
    tbPhyloTree.setPublished(false);
    tbPhyloTree.setRootedTree(((Node)xmlTree.getRoot()).isRoot());
    copyXmlTree(xmlTree, tbPhyloTree);   
    tbPhyloTree.updateSubtreeBounds();   
    return tbPhyloTree;   
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.