Examples of Taxon


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

    Map<String,Taxon> knownTaxon = new HashMap<String, Taxon> ();
    Map<String,Set<Taxon>> duplicateTaxa = new HashMap<String, Set<Taxon>> ();

    warn("Building knownTaxon cache...");
    for (TBPersistable tX : taxonHome.findAll(Taxon.class)) {
      Taxon t = (Taxon) tX;
      Integer legacyID = t.getTB1LegacyId();
      Integer ncbiID = t.getNcbiTaxId();
      String name = t.getName();
      if (ncbiID != null || name != null) {
        String uniqueKey = name + "," + ncbiID;
        if (knownTaxon.containsKey(uniqueKey)) {
          warn("Duplicate taxa with key '" + uniqueKey + "': " + idListString(t.getId(), knownTaxon.get(uniqueKey).getId()));
          if (mergeDuplicates) {
            if (! duplicateTaxa.containsKey(uniqueKey))
              duplicateTaxa.put(uniqueKey, new HashSet<Taxon>());
            duplicateTaxa.get(uniqueKey).add(t);
            duplicateTaxa.get(uniqueKey).add(knownTaxon.get(uniqueKey));
View Full Code Here

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

      String tvFullName = rec.get("fullNameString");
      String nameBankID = rec.get("uBIO");

      TaxonVariant tv = knownTaxonVariant.get(oldID);

      Taxon t = taxon.get(rec.get("tID"));
      if (t == null) {
        warn("taxonVariant " + oldID + " calls for unknown taxon " +
            rec.get("tID") + "; skipping");
        continue;
      }

      if (tv == null) {
        Long uBioID = TreebaseUtil.parseLong(rec.get("uBIO"), null);

        tv = new TaxonVariant(
            uBioID,
            rec.get("nameString"),
            rec.get("fullNameString"),
            rec.get("lexQual")
        );

        tv.setTaxon(t);
        tv.setTB1LegacyId(oldIDInteger);
        sess.save(tv);
        knownTaxonVariant.put(oldID, tv);
        uncommittedTaxonVariants++;
        warn("Made new TV '" + tvFullName + "'");
      }

      if (tv.getTaxon() == null || tv.getTaxon().equals(t)) {
        Long oldId = tv.getTaxon() == null ? null : tv.getTaxon().getId();
        warn("Mapping TaxonVariant " + tvFullName + " to Taxon " + t.getId() + "; was " + oldId);
        tv.setTaxon(t);
        sess.update(tv);
        uncommittedTaxonVariants++;
      }
View Full Code Here

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

      String tvFullName = rec.get("fullNameString")
      String nameBankID = rec.get("uBIO");

      String oldTaxonID = rec.get("tID");

      Taxon t = taxon.get(oldTaxonID);

      TaxonVariant tv = knownTaxonVariant.get(oldID);
      if (tv == null) {
        warn("File calls for missing taxonVariant with TB1id=" + oldID + ", oldID " + oldID);
        continue;
      }

      if (oldTaxonID == null) {
        if (tv.getTaxon() != null)
          warn("TB1id=" + oldID + ", Tv" + tv.getId() + " should have no taxon, but does");
      } else {
        if (t == null) {
          if (tv.getTaxon() != null)
            warn("TaxonVariant " + oldID + " calls for taxon " + rec.get("tID") + " which is missing from the DB");
        } else {
          if (tv.getTaxon() == null)
            warn("TaxonVariant " + oldID + " should link to taxon " + rec.get("tID") + " (T" + t.getId() + ") but links to none");
          else if (! tv.getTaxon().getId().equals(t.getId()))
            warn("TaxonVariant " + oldID + " should link to taxon " + rec.get("tID") + " (T" + t.getId() + ") but links to T" + tv.getTaxon().getId() + " instead");
        }
      }

      {
        String nameString = rec.get("nameString");
View Full Code Here

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

      if (tv.getLexicalQualifier().equals("(trash)")) continue; // XXX
      String legacyID = tv.getTB1LegacyId() == null ? "null" : tv.getTB1LegacyId().toString();
      String fullName = tv.getFullName();
      Long nameBankID = tv.getNamebankID();
      String nameBankIDString = nameBankID == null ? "" : nameBankID.toString();
      Taxon t = tv.getTaxon();
      if (fullName != null || nameBankIDString != null) {
        String uniqueKey = fullName + "," + nameBankIDString;
        if (t != null) uniqueKey += "," + t.getName() + "," + t.getNcbiTaxId() ;
        else uniqueKey = null;

        if (uniqueKey != null && keyCheck.containsKey(uniqueKey))
          warn("Very similar taxonvariants with key '" + uniqueKey + "': " + idListString(tv.getId(), keyCheck.get(uniqueKey).getId()));
View Full Code Here

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

      if (taxonName == null && ncbiTaxID == null)
        die("Taxon " + oldID + " has neither name nor NCBI id");

      String key = taxonName + "," + ncbiTaxID;
      Taxon t = knownTaxon.get(key);
      if (t == null) {
        warn("File calls for missing taxon with TB1id=" + oldID);
        continue;
      }

      t.setTB1LegacyId(oldIDInteger);
      if (fh.recNumber % 100 == 0) {
        warn("T " + fh.recNumber + " : " + taxonName);
      }
    }
  }
View Full Code Here

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

    String name = args[0];
    String fullName = args[1];
    String lexicalQualifier = args[2].equals("") ? null : args[2];
    Long ubio = args[3].equals("") ? null : Long.decode(args[3]);

    Taxon t = null;
    if (args.length == 5) {
      Long taxonId = Long.decode(args[4]);
      t = taxonHome.findPersistedObjectByID(Taxon.class, taxonId);
      if (t == null) {
        throw new Error("No taxon found with ID " + taxonId);
View Full Code Here

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

  /**
   *
   * @see org.cipres.treebase.domain.taxon.TaxonHome#findByName(java.lang.String)
   */
  public Taxon findByName(String pTaxonName) {
    Taxon returnVal = null;

    if (!TreebaseUtil.isEmpty(pTaxonName)) {
      Criteria c = getSession().createCriteria(Taxon.class);
      c.add(Expression.eq("name", pTaxonName));

View Full Code Here

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

    }

    Collection<Taxon> taxa = getTaxonHome().findTaxaByName(preferredVariant);
    if (taxa.size() == 0) {
      // now save to database: Taxon preferredVariant , taxonVariantList ubioDataList, update TaxonLabel
      Taxon taxon = new Taxon();
      taxon.setName(preferredVariant);
      if (ncbiID != null) {
        taxon.setNcbiTaxId(Integer.parseInt(ncbiID));
      }
      if (lph.getNameBankIDForTaxa() > 0L) { // it means
        taxon.setUBioNamebankId(lph.getNameBankIDForTaxa());
      }

      // save the new taxon and associated taxon variants.
      for (TaxonVariant taxonVariant : ubioDataList) {
        taxonVariant.setTaxon(taxon);
      }
      getTaxonHome().store(taxon);
      getTaxonHome().storeAll(ubioDataList);
    }
    else {
      // Important: firstVariant needs to be merged too.
      Taxon taxon = taxa.iterator().next();
      firstVariant = combineVariants(taxon, ubioDataList, firstVariant);
      update(taxon);
      if ( taxa.size() > 1 ) {
        LOGGER.warn("Homonyms found!");
      }
View Full Code Here

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

      }
      String taxonName = rec.get("nameString");

      Transaction trans = sess.getTransaction();

      Taxon t;
      t = knownTaxon.get(oldID);
      if (t == null) {
        warn("Creating new taxon with oldID=" + oldID + " NCBI=" + ncbiTaxid + " uBIO=" + uBioId);
        t = new Taxon();
        t.setUBioNamebankId(uBioId);
        t.setNcbiTaxId(ncbiTaxid);
        t.setTB1LegacyId(oldIDInteger);
        sess.save(t);
        knownTaxon.put(oldID, t);
        updateThisTaxon = true;
      }

      if (t.getName() == null) {
        warn("Setting name to " + taxonName);
        t.setName(taxonName);
      } else if (! t.getName().equals(taxonName)) {
        warn("taxon " + oldID + " found in DB as " + t.getId() +
            " with mismatched name " + taxonName + " / " + t.getName() +
        "; correcting");
        updateThisTaxon = true;
        t.setName(taxonName);
      }


      if (updateThisTaxon) {
        sess.update(t);
View Full Code Here

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

      String taxonName = rec.get("nameString");

      if (taxonName == null && ncbiTaxID == null)
        die("Taxon " + oldID + " has neither name nor NCBI id");

      Taxon t = knownTaxon.get(oldID);
      if (t == null) {
        warn("File calls for missing taxon with TB1id=" + oldID);
        continue;
      }

      // TODO: reduce duplication in the next three blocks of code
      if (uBioId == null && t.getUBioNamebankId() != null)
        warn("TB1id=" + oldID + " should have no uBio id, but T" + t.getId() + " has " + t.getUBioNamebankId());
      else if (uBioId != null && t.getUBioNamebankId() == null)
        warn("TB1id=" + oldID + " should have uBio id " + uBioId + " but T" + t.getId() + " has none");
      else if (uBioId != null && t.getUBioNamebankId() != null)
        if (! uBioId.equals(t.getUBioNamebankId()))
          warn("File says TB1id=" + oldID + " T" + t.getId() + " should have ubio id " + uBioId + " but it has " + t.getUBioNamebankId());

      if (ncbiTaxID == null && t.getNcbiTaxId() != null)
        warn("TB1id=" + oldID + " should have no NCBI id, but T" + t.getId() + " has " + t.getNcbiTaxId());
      else if (ncbiTaxID != null && t.getNcbiTaxId() == null)
        warn("TB1id=" + oldID + " should have NCBI id " + ncbiTaxID + " but T" + t.getId() + " has none");
      else if (ncbiTaxID != null && t.getNcbiTaxId() != null)
        if (! ncbiTaxID.equals(t.getNcbiTaxId()))
          warn("File says TB1id=" + oldID + " T" + t.getId() + " should have NCBI id " + ncbiTaxID + " but it has " + t.getNcbiTaxId());

      if (taxonName == null && t.getName() != null)
        warn("TB1id=" + oldID + " should have no name, but T" + t.getId() + " has " + t.getName());
      else if (taxonName != null && t.getName() == null)
        warn("TB1id=" + oldID + " should have name " + taxonName + " but T" + t.getId() + " has none");
      else if (taxonName != null && t.getName() != null)
        if (! taxonName.equals(t.getName()))
          warn("File says TB1id=" + oldID + " T" + t.getId() + " should have name " + taxonName + " but it has " + t.getName());

      taxon.put(oldID, t);
      knownTaxon.remove(oldID);

//      if (fh.recNumber % 100 == 0) {
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.