Package org.cipres.treebase.domain.study

Examples of org.cipres.treebase.domain.study.Submission


  /**
   *
   * @see org.cipres.treebase.domain.study.SubmissionHome#findByMatrix(org.cipres.treebase.domain.matrix.Matrix)
   */
  public Submission findByMatrix(Matrix pMatrix) {
    Submission returnVal = null;

    if (pMatrix != null) {
      Long mID = pMatrix.getId();
      Query q = getSession()
        .createQuery(
View Full Code Here


  /**
   *
   * @see org.cipres.treebase.domain.study.SubmissionHome#findByTree(org.cipres.treebase.domain.tree.PhyloTree)
   */
  public Submission findByTree(PhyloTree pTree) {
    Submission returnVal = null;

    if (pTree != null) {
      Long mID = pTree.getId();
      Query q = getSession()
        .createQuery(
View Full Code Here

  /**
   *
   * @see org.cipres.treebase.domain.study.SubmissionHome#findByTreeBlock(org.cipres.treebase.domain.tree.TreeBlock)
   */
  public Submission findByTreeBlock(TreeBlock pBlock) {
    Submission returnVal = null;

    if (pBlock != null) {
      Long mID = pBlock.getId();
      Query q = getSession()
        .createQuery(
View Full Code Here

  }

  public Submission findByStudyID(Long pID) {
    // TODO Auto-generated method stub
    Submission returnVal = null;
      Query q = getSession()
        .createQuery(
          "select sub from Submission as sub where sub.study.id = :mID");

      q.setLong("mID", pID);
View Full Code Here

      .createQuery("select count(*) from MatrixRow mr where mr.taxonLabel = :tl");
      q.setParameter("tl", tl);
        count += ((Long)q.iterate().next()).intValue();
       
        if(count==0){
          Submission sub=tl.getSubmission();
          if(sub!=null)sub.removeTaxonLabel(tl);
          deletePersist(tl);
        }
    }
  }
View Full Code Here

    TaxonLabelHome tlHome = ContextManager.getTaxonLabelHome();
   
    // Map taxonlabels to the submissions that contain them
    Map<TaxonLabel,List<Submission>> submissions = new HashMap<TaxonLabel,List<Submission>> ();
    for (Object o : tlHome.findAll(Submission.class)) {
      Submission sub = (Submission) o;
      for (TaxonLabel tl : sub.getSubmittedTaxonLabelsReadOnly()) {
        if (! submissions.containsKey(tl)) {
          submissions.put(tl, new LinkedList<Submission> ());
        }
        submissions.get(tl).add(sub);
      }
    }

    for (Object o : tlHome.findAll(TaxonLabel.class)) {
      TaxonLabel tl = (TaxonLabel) o;
      Submission correctSub = tl.getSubmission();
      List<Submission> otherSubs = submissions.get(tl);

      warn("#" + tl.getId());
      if (otherSubs.size() == 1
          && otherSubs.iterator().next().equals(correctSub)) {
        warn("  already correct");
        continue;
      }

      Transaction trans = rt.beginTransaction();
           
      for (Submission otherSub : otherSubs) {
        if (otherSub == correctSub) continue;
   
        warn("  removing from " + otherSub.getId());
        otherSub.removeTaxonLabel(tl);
      }
      tlHome.flush();
      warn("  adding to " + correctSub.getId());
      correctSub.addTaxonLabel(tl);
     
      trans.commit();
      warn("  committed");
    }
  }
View Full Code Here

    assertTrue("Empty user table.", submitter != null);

    Study s = new Study();
    s.setName(newName);

    Submission sub = getSubmissionService().createSubmission(submitter, s);

    getPhyloTreeHome().store(sub);

    // force commit immediately, important:
    setComplete();
    endTransaction();

    logger.info("study created: " + s.getName() + "id = " + s.getId());
    logger.info("submission created: " + "id = " + sub.getId());

    onSetUp();

    // 2. add a nexus file:
    // String path = "/12Tx432C.nex"; Failure
    // String path = "/TestNexusFile.nex";
    // String path = "/M12c11.nex";
     String path = "/wtset.nex";
    //String path = "/multiTrees-label.nex";
    //String path = "/charset-taxset-partition.nex";
     //String path = "/49LBR.PDI-branch-length-continue.nex"; // continuous matrix, provided by
    // Peter M.
    File nexusFile = new File(getClass().getResource(path).toURI());
    Collection<File> files = new ArrayList<File>();
    files.add(nexusFile);

    long t1 = System.currentTimeMillis();
    getPhyloTreeHome().refresh(sub);
    // sub = (Submission) loadObject(Submission.class, sub.getId());
    s = sub.getStudy();
    assertTrue("Failed to refresh submission.", sub != null);

    getSubmissionService().addNexusFiles(sub, files, null);
    getStudyService().addNexusFiles(s, files);

    // force commit immediately, important:
    setComplete();
    endTransaction();

    long t2 = System.currentTimeMillis();

    logger.info("files added: " + s.getName() + "id = " + s.getId() + " Time =" + (t2 - t1));

    // 3. verify
    String studySQL = "select count(*) from Study where study_id=" + s.getId();
    String subSQL = "select count(*) from Submission where submission_id=" + sub.getId();
    int count = jdbcTemplate.queryForInt(studySQL);
    assertTrue(count == 1);

    count = jdbcTemplate.queryForInt(subSQL);
    assertTrue(count == 1);

    onSetUp();
   
    // 4. Test:
    Submission sub2 = (Submission) getPhyloTreeHome().merge(sub);
    for (PhyloTree tree : sub2.getAllSubmittedTrees()) {
      String oldNewick = tree.getNewickString();
     
      long t3 = System.currentTimeMillis();
      tree.updateNewickString();
      String newNewick = tree.getNewickString();
     
      long t4 = System.currentTimeMillis();
      logger.info("Tree Label:" + tree.getLabel() +" updateNewick time=" + (t4-t3));
      logger.info(" old newick=" + oldNewick);
      logger.info(" new newick=" + newNewick);
      //clobLength + "content = " + clobStr);
      assertTrue(newNewick.length() > 1);
     
     
    }

    // 5. delete: delete submission:
    // after add Nexus files, sub is outdated:

    //hibernateTemplate.setFlushMode(HibernateAccessor.FLUSH_COMMIT);

    Submission s2 = (Submission) hibernateTemplate.get(Submission.class, sub.getId());
    getSubmissionService().deleteSubmission(s2);
    // getStudyService().deleteStudy(s);
    setComplete();
    endTransaction();

View Full Code Here

      for (TaxonLabel tl : canonical.keySet()) {
        if (tl == null) continue;
        TaxonLabel tlCanonical = canonical.get(tl);
        if (tl == tlCanonical) continue;
       
        Submission newLabelSub = tlCanonical.getSubmission();
        Submission oldLabelSub = tl.getSubmission();
       
        // Remove old label from submission
        oldLabelSub.removeTaxonLabel(tl);
       
        // Transfer canonical label to new submission
        if (oldLabelSub.getId() != newLabelSub.getId()) {
          newLabelSub.removeTaxonLabel(tlCanonical);
          oldLabelSub.addTaxonLabel(tlCanonical);
        }
       
        taxonLabelHome.flush();
      }
    }
View Full Code Here

    assertTrue("Empty user table.", submitter != null);

    Study s = new Study();
    s.setName(newName);

    Submission sub = getFixture().createSubmission(submitter, s);

    getSubmissionHome().store(s);

    // force commit immediately, important:
    setComplete();
    endTransaction();

    logger.info("study created: " + s.getName() + "id = " + s.getId());
    logger.info("submission created: " + "id = " + sub.getId());

    onSetUp();

    // 2. verify
    String studySQL = "select count(*) from Study where study_id=" + s.getId();
    String subSQL = "select count(*) from Submission where submission_id=" + sub.getId();
    int count = jdbcTemplate.queryForInt(studySQL);
    assertTrue(count == 1);

    count = jdbcTemplate.queryForInt(subSQL);
    assertTrue(count == 1);
View Full Code Here

    assertTrue("Empty user table.", submitter != null);

    Study s = new Study();
    s.setName(newName);

    Submission sub = getFixture().createSubmission(submitter, s);

    getSubmissionHome().store(sub);

    // force commit immediately, important:
    setComplete();
    endTransaction();

    logger.info("study created: " + s.getName() + "id = " + s.getId());
    logger.info("submission created: " + "id = " + sub.getId());

    onSetUp();

    // 2. add a nexus file:
    // String fileName = "12Tx432C.nex"; Failure
    // String fileName = "TestNexusFile.nex";
    // String fileName = "M12c11.nex";
    // String fileName = "M1389.nex"; //17k
    // String fileName = "M1001"; //489k
    // String fileName = "M999.nx";
    // String fileName = "EF1 Spiders.nex";
    String fileName = "wtset.nex";
    // String fileName = "multiTrees-label.nex";
    // String fileName = "charset-taxset-partition.nex";
    // String fileName = "49LBR.PDI-branch-length-continue.nex"; // continuous matrix, provided by
    // Peter M.

    // String fileName = "A100c2x3x96c12c17c08.tre"; //only has a tree, no matrix.
    // String fileName = "M99c2x3x96c12c31c40.nex"; // only has a matrix, no tree.
    //String fileName = "avian-ovomucoids.nex";
    //String fileName = "Combined_Bayes_orig.nex";
   
    String path = "/" + fileName;
   
    File nexusFile = new File(getClass().getResource(path).toURI());
    Collection<File> files = new ArrayList<File>();
    files.add(nexusFile);

    long t1 = System.currentTimeMillis();
    getSubmissionHome().refresh(sub);
    // sub = (Submission) loadObject(Submission.class, sub.getId());
    s = sub.getStudy();
    assertTrue("Failed to refresh submission.", sub != null);

    getFixture().addNexusFilesJDBC(sub, files, null);
    // getStudyService().addNexusFiles(s, files);

    // force commit immediately, important:
    setComplete();
    endTransaction();

    long t2 = System.currentTimeMillis();

    logger.info("files added: " + s.getName() + "id = " + s.getId() + " Time =" + (t2 - t1));
    logger.info("mesquite logging =" + MesquiteConverter.getParsingLog(fileName));
   
    // 3. verify
    String studySQL = "select count(*) from Study where study_id=" + s.getId();
    String subSQL = "select count(*) from Submission where submission_id=" + sub.getId();
    int count = jdbcTemplate.queryForInt(studySQL);
    assertTrue(count == 1);

    count = jdbcTemplate.queryForInt(subSQL);
    assertTrue(count == 1);

    onSetUp();

    // 4. delete: delete submission:
    // after add Nexus files, sub is outdated:

    // hibernateTemplate.setFlushMode(HibernateAccessor.FLUSH_COMMIT);

    Submission s2 = (Submission) hibernateTemplate.get(Submission.class, sub.getId());
    t1 = System.currentTimeMillis();
    getFixture().deleteSubmission(s2);
    // getStudyService().deleteStudy(s);
    setComplete();
    endTransaction();
View Full Code Here

TOP

Related Classes of org.cipres.treebase.domain.study.Submission

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.