Package org.cipres.treebase.domain.taxon

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


      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

      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

    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

  /**
   *
   * @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

    }

    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

      }
      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

      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

    String buttonName = request.getParameter("taxonResultsaction");
    if (buttonName.equals("addCheckedToResults")) {
//      Map<String,String> parameterMap = request.getParameterMap();
      Collection<Taxon> newTaxa = new HashSet<Taxon> ();
      for (String taxonIdString : request.getParameterValues("selection")) {
        Taxon tx;
        try {
          tx = getTaxonLabelService().findTaxonByIDString(taxonIdString);
        } catch (MalformedTreebaseIDString e) {
          // This can only occur if the ID numbers in our web form are
          // malformed, so it represents a programming error.  20090312 MJD
View Full Code Here

        LOGGER.debug("Going to search for TreeBASE IDs")
        if (null != index && ! index.endsWith(".tb1") ) {
          TreebaseIDString idstr;
          try {
            idstr = new TreebaseIDString(identifier, Taxon.class, true);
            Taxon match = getTaxonHome().findPersistedObjectByID(idstr.getTBClass(), idstr.getId());
            if ( match != null ) {
              taxaFound.add(match);
            }         
          } catch (MalformedTreebaseIDString e) {
            addMessage(request, "Ignoring malformed taxon ID string '" + identifier + "'; try 'Tx####' or just a number");
          }
        }
        // looking up by legacy IDs, which we might have for Taxon and TaxonVariant
        else {
          LOGGER.debug("Searching for legacy " + index);
          Integer tb1LegacyId = null;
          try {
            tb1LegacyId = Integer.parseInt(identifier);
          } catch ( NumberFormatException e ) {
            addMessage(request, "Ignoring malformed TreeBASE1 ID string '" + identifier + "', because: " + e.getMessage());
            LOGGER.error("Couldn't parse legacy ID: "+e.getMessage());
          }
          if ( null != tb1LegacyId && null != index && index.matches(".*taxonVariant.*") ) {
            TaxonVariant tv = getTaxonHome().findVariantByTB1LegacyId(tb1LegacyId);
            LOGGER.debug("Found taxon variant: " + tv.getId());
            if ( null != tv.getTaxon() ) {
              taxaFound.add(tv.getTaxon());
            }
          }
          else if ( null != tb1LegacyId ){
            Taxon taxon = getTaxonHome().findByTB1LegacyId(tb1LegacyId);
            LOGGER.debug("Found taxon: " + taxon.getId());
            if ( null != taxon ) {
              taxaFound.add(taxon);
            }
          }         
        }
        break;
      case NCBI :
        LOGGER.debug("Going to search for NCBI taxon ids")
        Taxon match = getTaxonHome().findByNcbiTaxId(Integer.parseInt(identifier));
        if ( match != null ) {
          taxaFound.add(match);
        }
        break;
      case UBIO :
        LOGGER.debug("Going to search for uBio nameBankIDs");
        Taxon match1 = getTaxonHome().findByUBIOTaxId(Long.parseLong(identifier));
        if ( match1 != null ) {
          taxaFound.add(match1);
        }
        break;
    }
View Full Code Here

TOP

Related Classes of org.cipres.treebase.domain.taxon.Taxon

Copyright © 2018 www.massapicom. 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.