Examples of TreeBlock


Examples of mods.natura.blocks.trees.TreeBlock

        //Clouds
        cloud = new CloudBlock();
        GameRegistry.registerBlock(cloud, CloudItem.class, "Cloud");

        //Trees
        tree = new TreeBlock().setBlockName("natura.treeblock");
        redwood = new SimpleLog().setBlockName("natura.redwood");
        planks = new Planks().setBlockName("natura.planks");
        floraLeaves = (NLeaves) new NLeaves().setBlockName("natura.leaves");
        floraLeavesNoColor = (NLeaves) new NLeavesNocolor().setBlockName("natura.leavesnocolor");
        floraSapling = ((NSaplingBlock) new NSaplingBlock().setBlockName("natura.sapling"));
View Full Code Here

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

  }
 
  private void checkAnalyzed(Collection<TreeBlock> mylist, Study study) { 
    Iterator<TreeBlock> treeBlockIterator = mylist.iterator();
    while ( treeBlockIterator.hasNext() ) {
      TreeBlock treeBlock = treeBlockIterator.next();
      if ( study != null ) {
        Iterator<PhyloTree> analyzedTreeIterator = study.getTrees().iterator();
        ANALYZED: while ( analyzedTreeIterator.hasNext() ) {
          PhyloTree analyzedTree = analyzedTreeIterator.next();
          if ( analyzedTree.getTreeBlock().getId() == treeBlock.getId() ) {
            treeBlock.setAnalyzed(true);
            break ANALYZED;
          }
        }
      }
      else {
        treeBlock.setAnalyzed(false);
      }     
    }   
  } 
View Full Code Here

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

    StringBuilder oversizerowsbldr = new StringBuilder("");
    Iterator<TreeBlock> treeblocks = mylist.iterator();

    int i = 0;
    while (treeblocks.hasNext()) {
      TreeBlock ablock = treeblocks.next();
      if (ablock.getTitle().trim().length() > permittedlength) {
        check = false;
        oversizerowsbldr.append(String.valueOf(i + 1));
        oversizerowsbldr.append(",");
      }
      i++;
View Full Code Here

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

      for ( int i = 0; i < treeBlockList.size(); i++ ) {
        EditFieldCommand editFieldCommand = treeBlockList.get(i);
        if ( ! editFieldCommand.getChecked() ) {
          continue// skip current iteration if not checked
        }       
        TreeBlock treeBlock = mPhyloTreeService.findTreeBlockByID(editFieldCommand.getTreeBlock().getId());
        if ( treeBlock == null ) {
          LOGGER.warn("No treeblock!!!");
        }
        else {
          LOGGER.warn(treeBlock.getTitle());
          Iterator<PhyloTree> treeIterator = treeBlock.getTreeListIterator();
          while (treeIterator.hasNext()) {
            PhyloTree phyloTree = treeIterator.next();
            AnalyzedTree analyzedTree = new AnalyzedTree();
            analyzedTree.setInput(input);
            analyzedTree.setTree(phyloTree);
View Full Code Here

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

        selectedMatrices.put(analyzedMatrix.getMatrix().getId(), analyzedMatrix
          .isInputData());
      } else if (data instanceof AnalyzedTree) {
        AnalyzedTree analyzedTree = (AnalyzedTree) data;
        selectedTrees.put(analyzedTree.getTree().getId(), analyzedTree.isInputData());
        TreeBlock treeBlock = analyzedTree.getTree().getTreeBlock();
        Long tbID = treeBlock.getId();
        if ( ! selectedTreeBlocks.containsKey(tbID) && ! incompleteTreeBlocks.containsKey(tbID) ) {
          int seen = 0;
          for ( AnalyzedData innerData : selectedData ) {
            if ( innerData instanceof AnalyzedTree ) {             
              Iterator<PhyloTree> treeIterator = treeBlock.getTreeListIterator();
              FIND: while (treeIterator.hasNext()) {
                PhyloTree treeInBlock = treeIterator.next();
                if ( treeInBlock.getId() == ((AnalyzedTree)innerData).getTree().getId() ) {
                  seen++;
                  break FIND;
                }
              }
            }
          }
          if ( seen == treeBlock.getTreeCount() ) {
            selectedTreeBlocks.put(tbID, true);
          }
          else {
            incompleteTreeBlocks.put(tbID, true);
          }
        }
      }
    }
    // get list of all the matrices and set check = true if it's already been selected
    List<EditFieldCommand> matrixList = new ArrayList<EditFieldCommand>();
    Collection<Matrix> matrices = submission.getSubmittedMatricesReadOnly();
    for (Matrix matrix : matrices) {
      Long id = matrix.getId();
      String selected = new String();
      if (selectedMatrices.containsKey(id)) {
        selected = selectedMatrices.get(id)
          ? (Constants.INPUT_KEY)
          : (Constants.OUTPUT_KEY);
      }
      EditFieldCommand editFieldCommand = new EditFieldCommand(matrix, selected);
      matrixList.add(editFieldCommand);
    }
    command.setMatrixList(matrixList);

    // do the same for trees
    // Iterator<PhyloTree> trees = submission.getTreeIterator();
    List<EditFieldCommand> treeList = new ArrayList<EditFieldCommand>();
    Collection<PhyloTree> trees = submission.getAllSubmittedTrees();
    for (PhyloTree tree : trees) {
      Long id = tree.getId();
      String selected = new String();
      if (selectedTrees.containsKey(id)) {
        selected = selectedTrees.get(id) ? (Constants.INPUT_KEY) : (Constants.OUTPUT_KEY);
      }
      EditFieldCommand editFieldCommand = new EditFieldCommand(tree, selected);
      treeList.add(editFieldCommand);
    }
    command.setTreeList(treeList);
   
    List<EditFieldCommand> treeBlockList = new ArrayList<EditFieldCommand>();
    Collection<TreeBlock> treeBlocks = submission.getSubmittedTreeBlocksReadOnly();
    for (TreeBlock treeBlock : treeBlocks) {
      Long id = treeBlock.getId();
      String selected = new String();
      if ( selectedTreeBlocks.containsKey(id)) {
        selected = selectedTreeBlocks.get(id) ? (Constants.INPUT_KEY) : (Constants.OUTPUT_KEY);
      }
      EditFieldCommand editFieldCommand = new EditFieldCommand(treeBlock,selected);
View Full Code Here

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

  @Override
  protected String getFileContent(long pTreeId, HttpServletRequest request) {
    Study study = ControllerUtil.findStudy(request, mStudyService);
    PhyloTree tree = getPhyloTreeService().findByID(pTreeId);
    tree = getPhyloTreeService().resurrect(tree);
    TreeBlock enclosingTreeBlock = getPhyloTreeService().resurrect(tree.getTreeBlock());
    TaxonLabelSet tls = getPhyloTreeService().resurrect(enclosingTreeBlock.getTaxonLabelSet());
    if ( getFormat(request) == FORMAT_NEXML || getFormat(request) == FORMAT_RDF ) {
      NexusDataSet nds = new NexusDataSet();
      nds.getTaxonLabelSets().add(tls);
      TreeBlock treeBlock = new TreeBlock();
      treeBlock.setTaxonLabelSet(tls);
      treeBlock.addPhyloTree(tree);
      nds.getTreeBlocks().add(treeBlock);
      return getNexmlService().serialize(nds,getDefaultProperties(request),tree.getStudy());
    }
    /*else if ( getFormat(request) == FORMAT_RDF ) {
      NexusDataSet nds = new NexusDataSet();
View Full Code Here

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

        }
        flush();
      }
      for (PhyloTree t : trees.values()) {
        // Detach this tree from the pseudosubmission it was temporarily attached to
        TreeBlock tb = t.getTreeBlock();
        if (tb != null) {
          warn("    Removing tree " + t.getId());
          tb.removePhyloTree(t);
          ContextManager.getPhyloTreeService().save(tb);
        }
        flush();
      }
//      t2.commit();
    }
   
//    Transaction t = getSession().beginTransaction();

    Study theStudy = aux.study(ContextManager.getStudyService());
    if (theStudy == null) {
      theStudy = new Study();
      ContextManager.getSubmissionService().createSubmission(null, theStudy);
    }
    theStudy.setTB1StudyID(study_id);
    theStudy.setAccessionNumber(study_id);
    theStudy.setStudyStatus(ContextManager.getStudyStatusHome().findStatusPublished());
    ContextManager.getStudyService().save(theStudy);
   
    Submission theSubmission = theStudy.getSubmission();
    ContextManager.getSubmissionService().save(theSubmission);

    Citation theCitation = theStudy.getCitation();
    if (theCitation == null) {
      theCitation = ContextManager.getCitationService().createCitation("TB1");
      theCitation.setStudy(theStudy);
      theStudy.setCitation(theCitation);
      ContextManager.getStudyService().save(theStudy);
    }
   
    { // Truncate extremely long abstracts
      String theAbstract = aux.getString(null, "abstract");
      if (theAbstract.length() > citationMaxLength - 4) {
        theAbstract = theAbstract.substring(0, citationMaxLength - 4) + "...";
      }
      theCitation.setAbstract(theAbstract);
    }
    // this next isn't quite right, because TB1 "citation" contains title, author, publisher, etc.
    // nothing to be done here, I think.  20080229 MJD
    // We can postprocess the citation data with Perl or something
    // to break it up into its component parts. 20080605 MJD
    // Piel says that Rod Page already did this. 20080702 MJD

    // Rutger has a program in util.CitationDataImporter that should do it 20090220 MJD
    {
      String citation = aux.getString(null, "citation");
      if (citation.length() > 250) {
        // It won't all fit into the "title" field of the database
        citation = citation.substring(0, 250); // XXX
      }
      theCitation.setTitle(citation); // XXX
   
    ContextManager.getCitationService().save(theCitation);
 
    // Create or link authors
    for (ValueSection a : aux.getSections("AUTHOR")) {
      Person theAuthor = new Person();
      theAuthor.setFirstName(a.getsval("first_name"));
      theAuthor.setLastName(a.getsval("last_name"));
      theAuthor.setMiddleName("");
//      ContextManager.getPersonService().save(theAuthor);
      // TB1 "author_id" ??
      Person oldAuthor = ContextManager.getPersonService().findByExactMatch(theAuthor);
      if (oldAuthor != null) {
        theAuthor = oldAuthor;
      } else {
        ContextManager.getPersonService().createPerson(theAuthor);
        theAuthor = ContextManager.getPersonService().findByExactMatch(theAuthor);
      }

      String oldEmail = theAuthor.getEmailAddressString();
      if (oldEmail == null || oldEmail.equals("")) {
        theAuthor.setEmailAddressString(a.getsval("email"));
     

      ContextManager.getPersonService().save(theAuthor);
      theCitation.addAuthor(theAuthor);
    }
    ContextManager.getCitationHome().flush();
    ContextManager.getCitationService().save(theCitation);

    // TODO: submission.setSubmitter
    theSubmission.setTest(isForTesting() ? 0 : 1);

    {
      Date creationDate = aux.getCreationDate();
      if (creationDate != null) {
        theSubmission.setCreateDate(creationDate);
      } else {
        warn("  Couldn't find creation date");
      }
    }

    for (ValueAnalysisSection an : aux.getAnalysisSections()) {
      Analysis theAnalysis = new Analysis();
      theAnalysis.setStudy(theStudy);
      theAnalysis.setName(an.getString("analysis_name"));
     
      // TODO: TB_ANALYSISID

      AnalysisStep theAnalysisStep = new AnalysisStep();
      theAnalysisStep.setAnalysis(theAnalysis);
      theAnalysis.addAnalysisStep(theAnalysisStep);
      ContextManager.getAnalysisService().save(theAnalysis);
      ContextManager.getAnalysisStepService().save(theAnalysisStep);
     
      Algorithm theAlgorithm;
      String tb1Algorithm = an.getString("algorithm");
      if (tb1Algorithm.equalsIgnoreCase("parsimony")) {
        theAlgorithm = new ParsimonyAlgorithm();
      } else if (tb1Algorithm.equalsIgnoreCase("bayesian")) {
        theAlgorithm = new BayesianAlgorithm();
      } else if (tb1Algorithm.equalsIgnoreCase("evolution")) {
        theAlgorithm = new EvolutionAlgorithm();
      } else if (tb1Algorithm.equalsIgnoreCase("joining")) {
        theAlgorithm = new JoiningAlgorithm();
      } else if (tb1Algorithm.equalsIgnoreCase("UPGMA")) {
        theAlgorithm = new UPGMAAlgorithm();
      } else if (tb1Algorithm.equalsIgnoreCase("likelihood")) {
        theAlgorithm = new LikelihoodAlgorithm();
      } else {
        theAlgorithm = new OtherAlgorithm()
      }
      theAlgorithm.setDescription(tb1Algorithm);
      ContextManager.getAlgorithmHome().save(theAlgorithm);
      theAnalysisStep.setAlgorithmInfo(theAlgorithm);
     
      { // handle INPUT_MATRIX and OUTPUT_TREE in each ANALYSIS section
        TreeBlock theTreeBlock = null;
        for (ValueSection ioSection : an.getIOSections()) {
          AnalyzedData theData;
          if (ioSection.label.equals("INPUT_MATRIX")) {
            AnalyzedMatrix theMatrix = new AnalyzedMatrix();
            theMatrix.setInput(true);
            String matrixID = ioSection.getsval("matrix_id");
           
            Matrix matrixData = matrices.get(matrixID);
                 
            if (matrixData == null) {
              warn("Matrix " + matrixID + "is used in analysis " + an.getString("analysis_id") + " but is not listed in any MATRIX section for its study");
              return new ValueNone();
            }

            matrixData.setStudy(theStudy);
            ContextManager.getTaxonLabelService().updateStudyForAllLabels(matrixData, theStudy);
            matrixData.setTB1MatrixID(matrixID);
            ContextManager.getMatrixService().save(matrixData);
            theSubmission.addMatrixIfNecessary(matrixData);
            ContextManager.getSubmissionService().save(theSubmission);
            theMatrix.setMatrix(matrixData);
            theData = theMatrix;
          } else if (ioSection.label.equals("OUTPUT_TREE")) {
         
            if (theTreeBlock == null) {
              theTreeBlock = new TreeBlock();
              ContextManager.getStudyService().save(theTreeBlock); // XXX should be some treeblock-specific service
              theSubmission.addPhyloTreeBlock(theTreeBlock);
              ContextManager.getSubmissionService().save(theSubmission);
            }     
           
            AnalyzedTree theTree = new AnalyzedTree();
            theTree.setInput(false);
            String treeID = ioSection.getsval("tree_id");
            PhyloTree treeData = trees.get(treeID);

            treeData.setStudy(theStudy);
            ContextManager.getTaxonLabelService().updateStudyForAllLabels(treeData, theStudy);
            treeData.setTB1TreeID(treeID);
            ContextManager.getPhyloTreeService().save(treeData);
            theTreeBlock.addPhyloTree(treeData);
            theSubmission.addPhyloTreeBlockIfNecessary(theTreeBlock);
            ContextManager.getSubmissionService().save(theSubmission);
            theTree.setTree(treeData);
            theData = theTree;
          } else {
View Full Code Here

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

    Document doc = DocumentFactory.safeCreateDocument();   
    PhyloTree tree = (PhyloTree)loadObject(PhyloTree.class,treeId);
    TaxonLabelSet tls = tree.getTreeBlock().getTaxonLabelSet();
    NexusDataSet nds = new NexusDataSet();
    nds.getTaxonLabelSets().add(tls);
    TreeBlock treeBlock = new TreeBlock();
    treeBlock.setTaxonLabelSet(tls);
    treeBlock.addPhyloTree(tree);
    nds.getTreeBlocks().add(treeBlock);
    NexmlDocumentWriter conv = new NexmlDocumentWriter(tree.getStudy(),getTaxonLabelHome(),doc);
    String xml = conv.fromTreeBaseToXml(nds).getXmlString();
    System.out.println(xml);
    Assert.assertNotNull(xml);
View Full Code Here

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

    for (int i = 0; i < treeVectors.size(); i++) {
      // One treeVector represents one tree block
      TreeVector treeVector = (TreeVector) treeVectors.elementAt(i);
      // System.out.println(" treeVector: " + i + " - " + treeVector.getName());

      TreeBlock treeblock = new TreeBlock();
      treeblock.setTitle(treeVector.getName());

      // first get the taxon list for the trees:
      Taxa treeTaxa = treeVector.getTaxa();
      // String taxaName = treeTaxa.getName();
      TaxonLabelSet tlSet = pDataSet.getTaxonLabelSet(treeTaxa);
      treeblock.setTaxonLabelSet(tlSet);

      List<TaxonLabel> treeTaxonLabels = null;
      if (tlSet != null) {
        treeTaxonLabels = tlSet.getTaxonLabelsReadOnly();
      }

      // To be used by the tree traversal methods.
      setCurrentTaxaList(treeTaxonLabels);
      setCurrentTreeTaxa(treeTaxa);

      Enumeration e = treeVector.elements();
      while (e.hasMoreElements()) {
        Tree mesqTree = (Tree) e.nextElement();
        String newick = mesqTree.writeTreeByNames(true);

        if (LOGGER.isDebugEnabled()) {
          LOGGER.debug(" tree=" + newick); //$NON-NLS-1$
        }

        // System.out.println(" tree: " + mesqTree.getName() + " " + newick);

        PhyloTree phyloTree = new PhyloTree();
        phyloTree.setLabel(mesqTree.getName());
        phyloTree.setNexusFileName(pFile.getName());
        phyloTree.setPublished(false);
        phyloTree.setRootedTree(mesqTree.getRooted());
        phyloTree.setNewickString(newick);
        phyloTree.setStudy(pStudy);
        // phyloTree.setBigTree(false); //TODO
        // phyloTree.setTreeType(treeType);
        // phyloTree.setTreeAttribute(pNewTreeAttribute);
        // phyloTree.setTreeQuality(pNewTreeQuality);

        int rootIndex = mesqTree.getRoot();
        PhyloTreeNode rootNode = createNode(mesqTree, null, rootIndex);
        phyloTree.addTreeNode(rootNode);
        phyloTree.setRootNode(rootNode);

        treeTraversal(mesqTree, rootIndex, rootNode);

        phyloTree.updateSubtreeBounds();

        treeblock.addPhyloTree(phyloTree);
        // pDataSet.getPhyloTrees().add(phyloTree);

        // verification
        if (LOGGER.isDebugEnabled()) {
          Set<PhyloTreeNode> nodes = phyloTree.getTreeNodesReadOnly();
View Full Code Here

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

    PhyloTreeNode node21 = new PhyloTreeNode();
    tree2.addTreeNode(node21);
    tree2.setRootNode(node21);

    // treeblock:
    TreeBlock block = new TreeBlock();
    block.setTitle(newName);

    block.addPhyloTree(tree);
    block.addPhyloTree(tree2);

    // Create an analysis step and associate w/ tree.
    Study s = getTestStudy();
    Analysis a1 = new Analysis();
    a1.setName("1 " + newName);
    AnalysisStep step1 = new AnalysisStep();
    step1.setName("step1 " + newName);
    s.addAnalysis(a1);
    a1.addAnalysisStep(step1);

    AnalyzedTree treeData = new AnalyzedTree();
    treeData.setTree(tree);
    treeData.setInput(Boolean.FALSE);
    step1.addAnalyzedData(treeData);

    getFixture().store(tree);
    getFixture().store(tree2);
    getFixture().store(block);

    // force commit immediately, important:
    setComplete();
    endTransaction();
    logger.info("tree1 created: " + tree.getLabel() + "id = " + tree.getId());
    logger.info("tree2 created: " + tree2.getLabel() + "id = " + tree2.getId());
    logger.info("treeBlock created: " + block.getTitle() + "id = " + block.getId());
    logger.info("analysis step created: " + step1.getName() + "id = " + step1.getId()
      + " associated data count=" + step1.getDataSetReadOnly().size());
    // logger.info("treeBlock created: " + block.getTitle() + "id = " + block.getId());

    // 2. verify
    String treeSql = "select count(*) from phylotree where treeBlock_id=" + block.getId();
    String blockSql = "select count(*) from treeblock where treeBlock_id=" + block.getId();
    String analyzedDataSql = "select count(*) from analyzedData where analysisstep_id="
      + step1.getId();
    String a1Sql = "select count(*) from analysis where analysis_id=" + a1.getId();
    int count = jdbcTemplate.queryForInt(treeSql);
    assertTrue(count == 2);
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.