Examples of TaxonVariant


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

      do{ c = nodes.someElement();}
      while (c.getTaxonLabel()==null);     
     
      searchResult = false;
      if (c.haveABCTopology(a, b)) {
        TaxonVariant as = a.getTaxonLabel().getTaxonVariant();
        TaxonVariant bs = b.getTaxonLabel().getTaxonVariant();
        TaxonVariant cs = c.getTaxonLabel().getTaxonVariant();

        logger.debug("Searching for trees with a=" + as + ", b=" + bs + ", c=" + cs);

        Collection<PhyloTree> trees =
          getFixture().findByTopology3(as, bs, cs);
View Full Code Here

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

    //pretty much a dummy test.
    String desc = "Durinskia baltica";
    TaxonLabel aLabel = new TaxonLabel();
    aLabel.setTaxonLabel(desc);
   
    TaxonVariant variant = getFixture().createFromUBIOService(aLabel);
    logger.info("variant full name =" + variant.getFullName());
   
    assertTrue("variant.", variant != null);
   

    // 3. verify
View Full Code Here

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

      }
    }
    assertTrue(tlsOneEolphus.size()>=1);
    TaxonLabel tlEolphus = tlsOneEolphus.iterator().next();

    TaxonVariant tvEolphus = getFixture().findTaxonVariant(tlEolphus);
    assertNotNull(tvEolphus);

    // I expect a whole bunch of equivalent TVs
    Set<TaxonVariant> expansion = getFixture().expandTaxonVariant(tvEolphus);
    assertNotNull(expansion);
    assertEquals(8, expansion.size());
   
    // And each one of those TVs should refer to the same taxon
    for (TaxonVariant tv : expansion) {
      assertEquals(tvEolphus.getTaxon(), tv.getTaxon());
    }
  }
View Full Code Here

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

      }
    }
    assertTrue(tlsOneCacatua.size()>=1);
    TaxonLabel tlCacatua = tlsOneCacatua.iterator().next();

    TaxonVariant tvEolphus = getFixture().findTaxonVariant(tlEolphus);
    assertNotNull(tvEolphus);
    TaxonVariant tvCacatua = getFixture().findTaxonVariant(tlCacatua);
    assertNotNull(tvCacatua);
   
    Set<TaxonVariant> tvs = new HashSet<TaxonVariant>();
    tvs.add(tvEolphus);
    tvs.add(tvCacatua);

    // I expect a two bunches of equivalent TVs
    Set<TaxonVariant> expansion = getFixture().expandTaxonVariantSet(tvs);
    assertNotNull(expansion);
    assertEquals(14, expansion.size());
 
    // And each one of those TVs should refer to the same taxon
    for (TaxonVariant tv : expansion) {
      Taxon t = tv.getTaxon();
      assertTrue(t == tvEolphus.getTaxon() || t == tvCacatua.getTaxon());
   
   
    // And moreover the call should be idempotent
    // That is, the expansion of the expansion should be the same as
    // the original expansion
View Full Code Here

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

    }
  }
 
  public void doMergeTaxonVariantClass(Set<TaxonVariant> taxonVariantClass) {
    Iterator<TaxonVariant> it = taxonVariantClass.iterator();
    TaxonVariant canonicalTaxonVariant = it.next();
       
    // Find the taxonVariant in the set with the lowest ID number
    while (it.hasNext()) {
      TaxonVariant t = it.next();
      if (t.getId() < canonicalTaxonVariant.getId()) canonicalTaxonVariant = t;
    }
   
    {
      StringBuilder s = new StringBuilder ("Merging taxonVariant class : ");
      for (TaxonVariant t : taxonVariantClass) s.append(t.getId()).append(" ");
      s.append("\n");
      warn(s.toString());
    }
    warn("  Canonical taxonVariant for this set is T" + canonicalTaxonVariant.getId());
   
View Full Code Here

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

      String oldID = rec.get("tvID");
      Integer oldIDInteger = Integer.decode(oldID);
      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++;
      }

      if (uncommittedTaxonVariants >= maxUncomittedTaxonVariants) {
View Full Code Here

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

      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");
        if (nameString == null && tv.getName() != null)
          warn("TB1id=" + oldID + " should have no name, but Tv" + tv.getId() + " has " + tv.getName());
        else if (nameString != null && tv.getName() == null)
          warn("TB1id=" + oldID + " should have name " + nameString + " but Tv" + tv.getId() + " has none");
        else if (nameString != null && tv.getName() != null)
          if (! nameString.equals(tv.getName()))
            warn("File says TB1id=" + oldID + " Tv" + tv.getId() + " should have name " + nameString + " but it has " + tv.getName());
      }

      {
        String lexQualF = rec.get("lexQual"), lexQualDB = tv.getLexicalQualifier();
        if (lexQualDB.equals("")) lexQualDB = null;
        if (lexQualF.equals("")) lexQualF = null;

        if (lexQualF == null && lexQualDB != null)
          warn("TB1id=" + oldID + " should have no LQ, but Tv" + tv.getId() + " has " + lexQualDB);
        else if (lexQualF != null && lexQualDB == null)
          warn("TB1id=" + oldID + " should have LQ " + lexQualF + " but Tv" + tv.getId() + " has none");
        else if (lexQualF != null && lexQualDB != null)
          if (! lexQualF.equals(lexQualDB))
            warn("File says TB1id=" + oldID + " Tv" + tv.getId() + " should have LQ " + lexQualF + " but it has " + lexQualDB);
      }


      {
        Long uBioId;
        {
          String uBioIdString = rec.get("uBIO");
          uBioId = uBioIdString.equals("") ? null : Long.decode(uBioIdString);
        }

        if (uBioId == null && tv.getNamebankID() != null)
          warn("TB1id=" + oldID + " should have no name, but Tv" + tv.getId() + " has " + tv.getNamebankID());
        else if (uBioId != null && tv.getNamebankID() == null)
          warn("TB1id=" + oldID + " should have name " + uBioId + " but Tv" + tv.getId() + " has none");
        else if (uBioId != null && tv.getNamebankID() != null)
          if (! uBioId.equals(tv.getNamebankID()))
            warn("File says TB1id=" + oldID + " Tv" + tv.getId() + " should have name " + uBioId + " but it has " + tv.getNamebankID());
      }

      taxonVariant.put(oldID, tv);
      knownTaxonVariant.remove(oldID);
    }
View Full Code Here

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

    Map<String,TaxonVariant> knownTaxonVariant = new HashMap<String, TaxonVariant>();
    Map<String,TaxonVariant> keyCheck = new HashMap<String, TaxonVariant>();

    warn("Building knownTaxonVariant cache...");
    for (TBPersistable tX : taxonHome.findAll(TaxonVariant.class)) {
      TaxonVariant tv = (TaxonVariant) tX;
      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()));

        if (knownTaxonVariant.containsKey(legacyID)) {
          warn("Duplicate taxonvariants with legacy ID '" + legacyID + "': " +
              idListString(tv.getId(),
                  knownTaxonVariant.get(legacyID).getId()));
        }

        knownTaxonVariant.put(legacyID, tv);
      }
View Full Code Here

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

    int maxUncommittedChanges = 1000;
    int uncomittedChanges = 0;

    for (Map<String,String> rec : tlFH) {
      String taxonLabelString = rec.get("taxonlabel");
      TaxonVariant tv = taxonVariant.get(rec.get("tvID"));

      if (tv == null) {
        warn("L Record " + rec.get("") + " asks for unknown TV id " + rec.get("tvID") + "; skipping");
        continue;
      }
View Full Code Here

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

      if (knownTaxonLabel.get(taxonLabelString) == null) {
        warn("File specifies mapping for nonexistent taxon label '" + taxonLabelString + "'");
        continue;
      }
     
      TaxonVariant tv = taxonVariant.get(rec.get("tvID"));
     
      if (tv == null) {
        warn("Dump file maps TL '" + taxonLabelString + "' to tv with unknownlegacy ID " + rec.get("tvID"));
        continue;
      }
     
      for (TaxonLabel tl : knownTaxonLabel.get(taxonLabelString)) {
        if (tl.getTaxonVariant() == null) {
          warn("Taxonlabel Tl" + tl.getId() + " is missing mapping to Tv" + tv.getId());
        } else if (! tl.getTaxonVariant().equals(tv)) {
          warn("Taxonlabel Tl" + tl.getId() + " points to Tv" + tl.getTaxonVariant().getId() +
              " but it should be Tv" + tv.getId());
        }
      }
    }
   
  }
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.