Examples of TaxonLabelSet


Examples of org.cipres.treebase.domain.taxon.TaxonLabelSet

    stepContent.append("#NEXUS\n");
   
    //header:
    TreebaseUtil.attachStudyHeader(step.getAnalysis().getStudy(), stepContent);
    stepContent.append("[ The following blocks are input data for analysis step " + analysisId + " ]\n");
    TaxonLabelSet inputLabelSet = step.getInputTaxonLabelSet();
    inputLabelSet.buildNexusBlockTaxa(stepContent, true, false);
    for ( AnalyzedData data : step.getDataSetReadOnly() ) {
      if ( data.isInputData() ) {
        PhyloTree tree = data.getTreeData();
        Matrix matrix  = data.getMatrixData();
        if ( tree != null ) {
          tree.getTreeBlock().setTaxonLabelSet(inputLabelSet);         
          tree.buildNexusBlock(stepContent);
        }
        if ( matrix != null ) {
          matrix.setTaxa(inputLabelSet);
          matrix.generateNexusBlock(stepContent);
        }       
      }
    }
   
    stepContent.append("[ The following blocks are output data for analysis step " + analysisId + " ]\n");
    TaxonLabelSet outputLabelSet = step.getOutputTaxonLabelSet();
    //outputLabelSet.buildNexusBlockTaxa(stepContent, true, false);
    for ( AnalyzedData data : step.getDataSetReadOnly() ) {
      if ( ! data.isInputData() ) {
        PhyloTree tree = data.getTreeData();
        Matrix matrix  = data.getMatrixData();
View Full Code Here

Examples of org.cipres.treebase.domain.taxon.TaxonLabelSet

  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();
      nds.getTaxonLabelSets().add(tls);
      TreeBlock treeBlock = new TreeBlock();
      treeBlock.setTaxonLabelSet(tls);
      treeBlock.addPhyloTree(tree);
      nds.getTreeBlocks().add(treeBlock);     
      return getRdfaService().serialize(nds,getDefaultProperties(request),tree.getStudy());     
    }  */ 
    else {
      StringBuilder builder = new StringBuilder();
      builder.append("#NEXUS\n\n");
 
      // header:
      TreebaseUtil.attachStudyHeader(study, builder);
 
      // taxa:
      // one taxon label per line, no line number.
      tls.buildNexusBlockTaxa(builder, true, false);
     
      //tree block:
      tree.buildNexusBlock(builder);
     
      return builder.toString();
View Full Code Here

Examples of org.cipres.treebase.domain.taxon.TaxonLabelSet

    Set<TaxonLabelSet> newSets = new HashSet<TaxonLabelSet> ();
    Set<TaxonLabelSet> oldSets = s.getTaxonLabelSets();
    Hibernate.initialize(oldSets);

    for (Analysis an : s.getAnalyses()) {
      TaxonLabelSet theSet = new TaxonLabelSet();
      theSet.setStudy(s);
      theSet.setTitle(an.getName());
      Collection<TreeBlock> treeBlocks = new LinkedList<TreeBlock> ();

      for (AnalysisStep as : an.getAnalysisStepsReadOnly()) {
        for (AnalyzedData ad : as.getDataSetReadOnly()) {
          Matrix m = ad.getMatrixData();
View Full Code Here

Examples of org.cipres.treebase.domain.taxon.TaxonLabelSet

   * @param pTaxaName
   * @return
   */
  public List<TaxonLabel> findTaxonLabels(Taxa pTaxa) {
    List<TaxonLabel> treeTaxonLabels = null;
    TaxonLabelSet taxonLabelSet = getTaxonLabelSet(pTaxa);
    if (taxonLabelSet != null) {
      treeTaxonLabels = taxonLabelSet.getTaxonLabelsReadOnly();
    }
    return treeTaxonLabels;
  }
View Full Code Here

Examples of org.cipres.treebase.domain.taxon.TaxonLabelSet

 
  public void testSerializeTree() {
    long treeId = 4816;
    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);
View Full Code Here

Examples of org.cipres.treebase.domain.taxon.TaxonLabelSet

      // One Taxa represents one TAXA block in a Nexus file.
      t = (Taxa) taxas.elementAt(i);
      if (!t.isDoomed()) {
        // a taxa is represented by a TaxonLabelSet
        // name is important:
        TaxonLabelSet labelSet = new TaxonLabelSet();
        labelSet.setStudy(pStudy);
        labelSet.setTitle(t.getName());
        labelSet.setTaxa(true);

        // TODO: make sure the name is not null
        if (LOGGER.isDebugEnabled()) {
          LOGGER.debug("taxa(" + i + ") name=" + t.getName()); //$NON-NLS-1$
        }

        // FIXME: instead of using a loop, use one query!
        long[] taxaIDs = t.getTaxaIDs();
        for (int j = 0; j < taxaIDs.length; j++) {
          Taxon taxon = t.getTaxon(j);

          String aLabel = taxon.getName();

          TaxonLabel taxonLabel = getTaxonLabelHome().getByDescriptionAndStudy(
            aLabel,
            pStudy);

          labelSet.addPhyloTaxonLabel(taxonLabel);
        }

        pDataSet.addTaxonLabelSet(t, labelSet);
      }
    }

    // matrix:
    MesquiteMatrixConverter.convertMatrices(
      project,
      pDataSet,
      pFile.getName(),
      getMatrixDataTypeHome(),
      getItemDefinitionHome());

    // tree:
    TreesManager treeManager = (TreesManager) project.ownerModule
      .findElementManager(TreeVector.class);
    ListableVector treeVectors = treeManager.getTreeBlockVector();
    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);
View Full Code Here

Examples of org.cipres.treebase.domain.taxon.TaxonLabelSet

   
    // now we're going to match up the NeXML taxa in trees with their equivalent treebase ones
    for ( org.nexml.model.TreeBlock nexTreeBlock : nexTreeBlocks ) {
     
      // get the equivalent taxa block in treebase for the NeXML tree block's OTU set
      TaxonLabelSet tbTls = (TaxonLabelSet)findEquivalentObject(nexTreeBlock.getOTUs().getId(),"Tls",tbStudy.getTaxonLabelSets());
     
      // now iterate over all nodes in all trees in the focal tree block
      for ( Network<?> nexTree : nexTreeBlock ) {
        for ( Node nexNode : nexTree.getNodes() ) {
         
          // check to see if there is a taxon; this may be null because we also visit internal nodes
          OTU nexOTU = nexNode.getOTU();
          if ( null != nexOTU ) {
           
            // populate a set to pass into findEquivalentObject()
            Set<TaxonLabel> tbTlset = new HashSet<TaxonLabel>();
            tbTlset.addAll(tbTls.getTaxonLabelsReadOnly());
           
            // this must not be null, though
            TaxonLabel tbTl = (TaxonLabel)findEquivalentObject(nexOTU.getId(),"Tl",tbTlset);
            Assert.assertNotNull("Have to find taxon "+nexNode.getId()+" for node "+nexNode.getId(), tbTl);
          }
View Full Code Here

Examples of org.cipres.treebase.domain.taxon.TaxonLabelSet

   *
   * @return boolean validated
   */
  @Transient
  public boolean getValidated() {
    TaxonLabelSet inputLabelSet = getInputTaxonLabelSet ();
    TaxonLabelSet outputLabelSet = getOutputTaxonLabelSet();
    if ( inputLabelSet.getTaxonLabelsReadOnly().size() == 0 || outputLabelSet.getTaxonLabelsReadOnly().size() == 0 ) {
      return false;
    }
    boolean valid = true;
    OUTPUTLABEL: for ( TaxonLabel outputLabel : outputLabelSet.getTaxonLabelsReadOnly() ) {
      for ( TaxonLabel inputLabel : inputLabelSet.getTaxonLabelsReadOnly() ) {
        if ( outputLabel.getId() == inputLabel.getId() ) {
          valid = true;
          continue OUTPUTLABEL;
        }
View Full Code Here

Examples of org.cipres.treebase.domain.taxon.TaxonLabelSet

   * Returns all unique taxon label objects associated with
   * all output data objects (i.e. trees and matrices)
   */
  @Transient
  public TaxonLabelSet getOutputTaxonLabelSet() {
    TaxonLabelSet outputLabelSet = new TaxonLabelSet();
    outputLabelSet.setTitle("OutputTaxaForAnalysisStep"+getId());
    Set<TaxonLabel> labelSet = new HashSet<TaxonLabel>();
    for ( AnalyzedData data : getDataSetReadOnly() ) {
      if ( ! data.isInputData() ) {
        if ( data.getDataType().equals("tree") ) {
          PhyloTree tree = data.getTreeData();
          labelSet.addAll(tree.getAllTaxonLabels());
        }
        if ( data.getDataType().equals("matrix") ) {
          Matrix matrix = data.getMatrixData();
          labelSet.addAll(matrix.getTaxa().getTaxonLabelsReadOnly());
        }                 
      }
    }
    for ( TaxonLabel label : labelSet ) {
      outputLabelSet.addPhyloTaxonLabel(label);
    }
    return outputLabelSet;
  }
View Full Code Here

Examples of org.cipres.treebase.domain.taxon.TaxonLabelSet

   * Returns all unique taxon label objects associated with
   * all input data objects (i.e. trees and matrices)
   */
  @Transient
  public TaxonLabelSet getInputTaxonLabelSet() {
    TaxonLabelSet inputLabelSet = new TaxonLabelSet();
    inputLabelSet.setTitle("InputTaxaForAnalysisStep"+getId());
    Set<TaxonLabel> labelSet = new HashSet<TaxonLabel>();
    for ( AnalyzedData data : getDataSetReadOnly() ) {
      if ( data.isInputData() ) {
        if ( data.getDataType().equals("tree") ) {
          PhyloTree tree = data.getTreeData();
          labelSet.addAll(tree.getAllTaxonLabels());
        }
        if ( data.getDataType().equals("matrix") ) {
          Matrix matrix = data.getMatrixData();
          labelSet.addAll(matrix.getTaxa().getTaxonLabelsReadOnly());
        }                 
      }
    }
    for ( TaxonLabel label : labelSet ) {
      inputLabelSet.addPhyloTaxonLabel(label);
    }
    return inputLabelSet;
  }
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.