Package org.cipres.treebase.domain.study

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


    String newName = testName + " test " + Math.random();

    User submitter = (User) loadObject(User.class);
    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);
View Full Code Here


   
    // this study had mismatching taxon labels, according to @rdmpage
    long studyId = 2048
   
    // this is the full study as it is stored by the database
    Study tbStudy = (Study)loadObject(Study.class, studyId);

    // this becomes an object representation of a NeXML document
    Document nexDoc = DocumentFactory.safeCreateDocument();
   
    // the converter populates the NeXML document with the contents of the treebase study
    NexmlDocumentWriter ndc = new NexmlDocumentWriter(tbStudy,getTaxonLabelHome(),nexDoc);
    ndc.fromTreeBaseToXml(tbStudy); // here is where the conversion happens
       
    // these are the NeXML tree blocks that were created from the study     
    List<org.nexml.model.TreeBlock> nexTreeBlocks = nexDoc.getTreeBlockList();
   
    // there most be more than zero tree blocks in this study
    Assert.assertTrue(nexTreeBlocks.size() != 0 );
   
    // now we're going to match up the NeXML taxa in trees with their equivalent treebase ones
    for ( org.nexml.model.TreeBlock nexTreeBlock : nexTreeBlocks ) {
     
      // get the equivalent taxa block in treebase for the NeXML tree block's OTU set
      TaxonLabelSet tbTls = (TaxonLabelSet)findEquivalentObject(nexTreeBlock.getOTUs().getId(),"Tls",tbStudy.getTaxonLabelSets());
     
      // now iterate over all nodes in all trees in the focal tree block
      for ( Network<?> nexTree : nexTreeBlock ) {
        for ( Node nexNode : nexTree.getNodes() ) {
         
View Full Code Here

    String newName = testName + " test " + Math.random();

    User submitter = (User) loadObject(User.class);
    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);
View Full Code Here

     
    // check whether parsing is successful:
    if (returnVal.isSuccessful()) {
      List<RowSegment> newRS = new ArrayList<RowSegment>();
      List<RowSegment> updateRS = new ArrayList<RowSegment>();
      Study s = getDomainHome().loadPersistedObjectByID(Study.class, pStudyId);
      CharacterMatrix m = getDomainHome().loadPersistedObjectByID(CharacterMatrix.class, pMatrixId);
     
      mapToSegments(s, m, values, pMappedFields, newRS, updateRS, returnVal);

      // Save to database:
View Full Code Here

    String newName = testName + " test " + Math.random();

    User submitter = (User) loadObject(User.class);
    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);
View Full Code Here

    String newName = testName + " test " + Math.random();

    User submitter = (User) loadObject(User.class);
    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 path = "/12Tx432C.nex"; Failure
    // String path = "/TestNexusFile.nex";
    // String path = "/M12c11.nex";
    String path = "/M1389.nex"; // 17k
    // String path = "/M1001"; //489k
    // String path = "/M999.nx";
    // String path = "/EF1 Spiders.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();
    getSubmissionHome().refresh(sub);
    // sub = (Submission) loadObject(Submission.class, sub.getId());
    s = sub.getStudy();
    assertTrue("Failed to refresh submission.", sub != null);

    getFixture().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();

    // verify clob:
    // Notes: this is important: why?? there are two copies of s in the same session.
    // how???

    Study study2 = (Study) hibernateTemplate.load(Study.class, sub.getStudy().getId());

    // hibernateTemplate.refresh(sub);
    String nexusString = study2.getNexusFiles().values().iterator().next();
    int nexusStringLength = (int) nexusString.length();
    logger.info("test clob: length=" + nexusStringLength + "content = " + nexusString);
    assertTrue(nexusStringLength > 0);

    // 4. delete: delete submission:
View Full Code Here

    long studyId = jdbcTemplate.queryForLong(studyStr);
    logger.info("study id: " + studyId);
    assertTrue(studyId > 0);

    // 2. query
    Study s = (Study) loadObject(Study.class, studyId);
    assertTrue(s != null);

    List<Study> studyList = new ArrayList<Study>();
    studyList.add(s);

    Collection<PhyloTree> trees = getFixture().findByStudies(studyList);
    assertTrue(trees != null && !trees.isEmpty());

    if (logger.isInfoEnabled()) {
      logger.info(" tree count= " + trees.size());
    }

    // 3. verify
    for (PhyloTree phyloTree : trees) {

      long treeId = phyloTree.getId();
      String treeCountStr = "select count(tree.phylotree_id) from phylotree tree "
        + " where tree.study_ID = " + s.getId() + " and tree.PHYLOTREE_ID = " + treeId;
      int count = jdbcTemplate.queryForInt(treeCountStr);
      assertTrue(count > 0);
    }

    if (logger.isInfoEnabled()) {
View Full Code Here

    String testName = "testAddNexusToExistingStudy";
    if (logger.isInfoEnabled()) {
      logger.info("\n\t\tRunning Test: " + testName);
    }

    Study s = getTestStudy();
    Submission sub = s.getSubmission();

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

    logger.info("study found: " + s.getName() + "id = " + s.getId());
    logger.info("submission found: " + "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 = "/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();
    getSubmissionHome().refresh(sub);
    // sub = (Submission) loadObject(Submission.class, sub.getId());
    s = sub.getStudy();
    assertTrue("Failed to refresh submission.", sub != null);

    getFixture().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));

    onSetUp();

    // 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);
View Full Code Here

    long studyId = jdbcTemplate.queryForLong(studyStr);
    logger.info("study id: " + studyId);
    assertTrue(studyId > 0);

    // 2. query
    Study s = (Study) loadObject(Study.class, studyId);
    assertTrue(s != null);
    //this the table phyloTree and study may evaluate "published" differently
    //assertTrue(s.isPublished() == false);

    int count = getFixture().updatePublishedFlagByStudy(s, true);
    logger.debug("update Count = " + count);
    assertTrue(count > 0);

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

    // 3. verify
    String treeCountStr = "select count(tree.phylotree_id) from phylotree tree "
      + " where tree.study_ID = " + s.getId() + " and tree.published is true";
    int countVeri = jdbcTemplate.queryForInt(treeCountStr);
    logger.debug("verify Count = " + countVeri);
    assertTrue(countVeri == count);

    //4. change it back:
View Full Code Here

    block.addPhyloTree(tree);
    block.addPhyloTree(tree2);

    // Create an analysis step and associate w/ tree.
    Study s = getTestStudy();
    Analysis a1 = new Analysis();
    a1.setName("1 " + newName);
    AnalysisStep step1 = new AnalysisStep();
    step1.setName("step1 " + newName);
    s.addAnalysis(a1);
    a1.addAnalysisStep(step1);

    AnalyzedTree treeData = new AnalyzedTree();
    treeData.setTree(tree);
    treeData.setInput(Boolean.FALSE);
View Full Code Here

TOP

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

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.