Examples of TaxonLabelService


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

public class TreeQuery extends AbstractStandalone {
  public static void main(String[] args) {
    setupContext();
    PhyloTreeService treeServ = ContextManager.getPhyloTreeService();
    TaxonLabelService tlServ = ContextManager.getTaxonLabelService();
   
    Set<TaxonVariant>[] tvSet = new Set[3];
    for (int i=0; i<3; i++) {
      tvSet[i] = tlServ.findTaxonVariantByName(args[i]);
      warn(args[i] + " yields " + tvSet[i].size() + " matches");
    }
   
    TaxonVariant[] tv = new TaxonVariant[3];
    for (int i=0; i<3; i++) {
View Full Code Here

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

class RepatriateTaxonLabels extends AbstractStandalone {
 
  public static void main(String [] args) {
    RepatriateTaxonLabels rt = new RepatriateTaxonLabels();
    rt.setupContext();
    TaxonLabelService tlService = ContextManager.getTaxonLabelService();

    GetOpts<UnixOptions> go = new GetOpts<UnixOptions>(new UnixOptions ("tm"));
    UnixOptions opts = go.getOpts(args);


    if (! opts.getBoolOpt("m")) {
      for (TBPersistable tbM : ContextManager.getMatrixHome().findAll(Matrix.class)) {
        Transaction tr = rt.beginTransaction();
        Matrix m = (Matrix) tbM;
        Study s = m.getStudy();
        tlService.updateStudyForAllLabels(m, s);
        tr.commit();
        System.err.println("Repatriated labels of matrix " + m.getId());
      }
    }

    if (! opts.getBoolOpt("t")) {
      for (TBPersistable tbT : ContextManager.getPhyloTreeHome().findAll(PhyloTree.class)) {
        Transaction tr = rt.beginTransaction();
        PhyloTree t = (PhyloTree) tbT;
        Study s = t.getStudy();
        System.err.print("Repatriating labels of tree " + t.getId() + "...");
        tlService.updateStudyForAllLabels(t, s);
        tr.commit();
        System.err.println(" Done.");
      }
    }
  }
View Full Code Here

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

   * @param args
   */
  public static void main(String[] args) {
    RepatriateTreeTaxonLabels rt = new RepatriateTreeTaxonLabels();
    rt.setupContext();
    TaxonLabelService tlService = ContextManager.getTaxonLabelService();

    for (String arg : args) {
      Long id = Long.parseLong(arg);
      PhyloTree t = ContextManager.getPhyloTreeService().findByID(id);
      if (t == null) {
        System.err.println(id + ": no tree found");
      } else {
        Study s = t.getStudy();
        if (s == null) {
          System.err.println(id + ": no study");
        } else {
          tlService.updateStudyForAllLabels(t, s);
          System.err.println(id + ": done");
        }
      }
    }
  }
View Full Code Here

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

   */
  private Collection<Taxon> doTextSearch(String pattern, boolean caseSensitive, boolean exactMatch, SearchTable searchTable) {
    LOGGER.debug("Going to search for strings");
    LOGGER.debug("Case sensitive? " + caseSensitive);
    LOGGER.debug("Exact match? " + exactMatch);   
    TaxonLabelService tls = getTaxonLabelService();
    Collection<Taxon> taxaFound = new ArrayList<Taxon>();
    switch(searchTable) {
      case TAXONLABEL :
        LOGGER.debug("Will search taxon labels");
        Collection<TaxonLabel> labelsFound = exactMatch
          ? tls.findByExactString(pattern)
          : tls.findBySubstring(pattern, caseSensitive);
        for ( TaxonLabel label : labelsFound ) {
          if ( label.getTaxonVariant() != null && label.getTaxonVariant().getTaxon() != null ) {
            taxaFound.add(label.getTaxonVariant().getTaxon());
          }
        }
        break;
      case TAXONVARIANT :
        LOGGER.debug("Will search taxon variants");
        Collection<TaxonVariant> variantsFound = exactMatch
          ? tls.findTaxonVariantByFullName(pattern)
          : tls.findTaxonVariantWithSubstring(pattern, caseSensitive);
        for ( TaxonVariant variant : variantsFound ) {
          if ( variant.getTaxon() != null ) {
            taxaFound.add(variant.getTaxon());
          }
        }
        break;
      case TAXON :
        LOGGER.debug("Will search taxa");
        Collection<Taxon> tmpTaxaFound = exactMatch
          ? tls.findTaxaByName(pattern)
          : tls.findTaxaBySubstring(pattern, caseSensitive);
        taxaFound.addAll(tmpTaxaFound);
        break;
    }
    return taxaFound;
  }
View Full Code Here

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

        Collection<TaxonVariant> variants = getTaxonHome().findVariantsByTaxon(taxon);
        variant = variants.iterator().next();
      }
      else {
        // 2b
        TaxonLabelService taxonLabelService = getTaxonLabelService();
        Integer ncbiId = taxonLabelService.findNcbiTaxIdByUBIOTaxId(manualId)
        Taxon newTaxon = null;
        TaxonVariant newVariant = null;
        if ( null != ncbiId ) {
          String ncbiPreferredName = taxonLabelService.getNCBIPreferredName(ncbiId.toString());
          newTaxon = new Taxon(ncbiPreferredName,manualId,ncbiId);
          newVariant = new TaxonVariant(manualId,taxonLabel.getTaxonLabel(),ncbiPreferredName,"canonical form");         
        }       
        else {
          newTaxon = new Taxon();
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.