Examples of AnalysisStep


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

    return "AnalysisStep";
  }

  @Override
  protected String getFileContent(long analysisId, HttpServletRequest request) {
    AnalysisStep step = getAnalysisStepService().findByID(analysisId);
    StringBuilder stepContent = new StringBuilder();
    stepContent.append("#NEXUS\n");
   
    //header:
    TreebaseUtil.attachStudyHeader(step.getAnalysis().getStudy(), stepContent);
    stepContent.append("[ The following blocks are input data for analysis step " + analysisId + " ]\n");
    TaxonLabelSet inputLabelSet = step.getInputTaxonLabelSet();
    inputLabelSet.buildNexusBlockTaxa(stepContent, true, false);
    for ( AnalyzedData data : step.getDataSetReadOnly() ) {
      if ( data.isInputData() ) {
        PhyloTree tree = data.getTreeData();
        Matrix matrix  = data.getMatrixData();
        if ( tree != null ) {
          tree.getTreeBlock().setTaxonLabelSet(inputLabelSet);         
          tree.buildNexusBlock(stepContent);
        }
        if ( matrix != null ) {
          matrix.setTaxa(inputLabelSet);
          matrix.generateNexusBlock(stepContent);
        }       
      }
    }
   
    stepContent.append("[ The following blocks are output data for analysis step " + analysisId + " ]\n");
    TaxonLabelSet outputLabelSet = step.getOutputTaxonLabelSet();
    //outputLabelSet.buildNexusBlockTaxa(stepContent, true, false);
    for ( AnalyzedData data : step.getDataSetReadOnly() ) {
      if ( ! data.isInputData() ) {
        PhyloTree tree = data.getTreeData();
        Matrix matrix  = data.getMatrixData();
        if ( tree != null ) {
          tree.getTreeBlock().setTaxonLabelSet(outputLabelSet);
View Full Code Here

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

    return stepContent.toString();
  }

  @Override
  protected Study getStudy(long objectId, HttpServletRequest request) {
    AnalysisStep step = getAnalysisStepService().findByID(objectId);
    return step.getAnalysis().getStudy();
  }
View Full Code Here

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

      "analysis_step_id",
      null);

    request.getSession().setAttribute("ANALYSIS_STEP_ID_FROM_ANALYZED_DATA", analysis_step_id);

    AnalysisStep analysisStep = mAnalysisStepService.findByID(Long.parseLong(analysis_step_id));

    // process each check box user has selected -- add to AnalyzedData table
    String dataType = data.getDataType();
    Boolean input = (data.getInputOutputType().equals(Constants.INPUT_KEY)) ? (true) : (false);

    if (dataType.equals(Constants.MATRIX_KEY)) {
      List<EditFieldCommand> matrixList = data.getMatrixList();
      for (int i = 0; i < matrixList.size(); i++) {
        EditFieldCommand editFieldCommand = matrixList.get(i);
        // check if user update title
        Matrix matrix = mMatrixService.findByID(editFieldCommand.getMatrix().getId());
        matrix.setTitle(editFieldCommand.getMatrix().getTitle());
        mMatrixService.update(matrix);
        if (!editFieldCommand.getChecked()) continue; // skip current iteration if not
        // checked
        AnalyzedMatrix analyzedMatrix = new AnalyzedMatrix();
        analyzedMatrix.setInput(input);
        analyzedMatrix.setMatrix(matrix);
        analysisStep.addAnalyzedData(analyzedMatrix);
        mAnalysisStepService.update(analysisStep);
      }// end for
    } else if (dataType.equals(Constants.TREE_KEY)) {
      List<EditFieldCommand> treeList = data.getTreeList();
      for (int i = 0; i < treeList.size(); i++) {
        EditFieldCommand editFieldCommand = treeList.get(i);
        // check if user update title
        PhyloTree phyloTree = mPhyloTreeService.findByID(editFieldCommand
          .getPhyloTree().getId());
        phyloTree.setLabel(editFieldCommand.getPhyloTree().getLabel());
        mPhyloTreeService.update(phyloTree);
        if (!editFieldCommand.getChecked()) {
          continue; // skip current iteration if not
        }
        // checked
        AnalyzedTree analyzedTree = new AnalyzedTree();
        analyzedTree.setInput(input);
        analyzedTree.setTree(phyloTree);
        analysisStep.addAnalyzedData(analyzedTree);
        mAnalysisStepService.update(analysisStep);
      }
    } else if ( dataType.equals(Constants.TREE_LIST)) {
      List<EditFieldCommand> treeBlockList = data.getTreeBlockList();
      LOGGER.warn("Going to set tree block as analyzed data");
      for ( int i = 0; i < treeBlockList.size(); i++ ) {
        EditFieldCommand editFieldCommand = treeBlockList.get(i);
        if ( ! editFieldCommand.getChecked() ) {
          continue// skip current iteration if not checked
        }       
        TreeBlock treeBlock = mPhyloTreeService.findTreeBlockByID(editFieldCommand.getTreeBlock().getId());
        if ( treeBlock == null ) {
          LOGGER.warn("No treeblock!!!");
        }
        else {
          LOGGER.warn(treeBlock.getTitle());
          Iterator<PhyloTree> treeIterator = treeBlock.getTreeListIterator();
          while (treeIterator.hasNext()) {
            PhyloTree phyloTree = treeIterator.next();
            AnalyzedTree analyzedTree = new AnalyzedTree();
            analyzedTree.setInput(input);
            analyzedTree.setTree(phyloTree);
            analysisStep.addAnalyzedData(analyzedTree);
            mAnalysisStepService.update(analysisStep);
          }
          /*
          AnalyzedTreeBlock analyzedTreeBlock = new AnalyzedTreeBlock();
          analyzedTreeBlock.setInput(input);
View Full Code Here

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

    String analysis_step_id = ServletRequestUtils.getStringParameter(
      request,
      "analysis_step_id",
      null);

    AnalysisStep analysisStep = mAnalysisStepService.findByID(Long.parseLong(analysis_step_id));
    // add it to the drop down list
    steps.add(new LabelValue(analysisStep.getDisplayName(), analysis_step_id));
    dataMap.put("steps", steps);

    // determine input/output type
    List<LabelValue> inputOutputTypes = new ArrayList<LabelValue>();
    inputOutputTypes.add(new LabelValue("Input", Constants.INPUT_KEY));
View Full Code Here

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

      return command;
    }
    command.setStep(analysis_step_id);

    // retrieve list of matrix IDs user has previously selected and store in them for lookup
    AnalysisStep analysisStep = mAnalysisStepService.findByID(Long.parseLong(analysis_step_id));
    List<AnalyzedData> selectedData = analysisStep.getDataSetReadOnly();
    Map<Long, Boolean> selectedMatrices = new HashMap<Long, Boolean>();
    Map<Long, Boolean> selectedTrees = new HashMap<Long, Boolean>();
    Map<Long, Boolean> selectedTreeBlocks = new HashMap<Long,Boolean>();
    Map<Long, Boolean> incompleteTreeBlocks = new HashMap<Long,Boolean>();
View Full Code Here

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

      theAnalysis.setStudy(theStudy);
      theAnalysis.setName(an.getString("analysis_name"));
     
      // TODO: TB_ANALYSISID

      AnalysisStep theAnalysisStep = new AnalysisStep();
      theAnalysisStep.setAnalysis(theAnalysis);
      theAnalysis.addAnalysisStep(theAnalysisStep);
      ContextManager.getAnalysisService().save(theAnalysis);
      ContextManager.getAnalysisStepService().save(theAnalysisStep);
     
      Algorithm theAlgorithm;
      String tb1Algorithm = an.getString("algorithm");
      if (tb1Algorithm.equalsIgnoreCase("parsimony")) {
        theAlgorithm = new ParsimonyAlgorithm();
      } else if (tb1Algorithm.equalsIgnoreCase("bayesian")) {
        theAlgorithm = new BayesianAlgorithm();
      } else if (tb1Algorithm.equalsIgnoreCase("evolution")) {
        theAlgorithm = new EvolutionAlgorithm();
      } else if (tb1Algorithm.equalsIgnoreCase("joining")) {
        theAlgorithm = new JoiningAlgorithm();
      } else if (tb1Algorithm.equalsIgnoreCase("UPGMA")) {
        theAlgorithm = new UPGMAAlgorithm();
      } else if (tb1Algorithm.equalsIgnoreCase("likelihood")) {
        theAlgorithm = new LikelihoodAlgorithm();
      } else {
        theAlgorithm = new OtherAlgorithm()
      }
      theAlgorithm.setDescription(tb1Algorithm);
      ContextManager.getAlgorithmHome().save(theAlgorithm);
      theAnalysisStep.setAlgorithmInfo(theAlgorithm);
     
      { // handle INPUT_MATRIX and OUTPUT_TREE in each ANALYSIS section
        TreeBlock theTreeBlock = null;
        for (ValueSection ioSection : an.getIOSections()) {
          AnalyzedData theData;
          if (ioSection.label.equals("INPUT_MATRIX")) {
            AnalyzedMatrix theMatrix = new AnalyzedMatrix();
            theMatrix.setInput(true);
            String matrixID = ioSection.getsval("matrix_id");
           
            Matrix matrixData = matrices.get(matrixID);
                 
            if (matrixData == null) {
              warn("Matrix " + matrixID + "is used in analysis " + an.getString("analysis_id") + " but is not listed in any MATRIX section for its study");
              return new ValueNone();
            }

            matrixData.setStudy(theStudy);
            ContextManager.getTaxonLabelService().updateStudyForAllLabels(matrixData, theStudy);
            matrixData.setTB1MatrixID(matrixID);
            ContextManager.getMatrixService().save(matrixData);
            theSubmission.addMatrixIfNecessary(matrixData);
            ContextManager.getSubmissionService().save(theSubmission);
            theMatrix.setMatrix(matrixData);
            theData = theMatrix;
          } else if (ioSection.label.equals("OUTPUT_TREE")) {
         
            if (theTreeBlock == null) {
              theTreeBlock = new TreeBlock();
              ContextManager.getStudyService().save(theTreeBlock); // XXX should be some treeblock-specific service
              theSubmission.addPhyloTreeBlock(theTreeBlock);
              ContextManager.getSubmissionService().save(theSubmission);
            }     
           
            AnalyzedTree theTree = new AnalyzedTree();
            theTree.setInput(false);
            String treeID = ioSection.getsval("tree_id");
            PhyloTree treeData = trees.get(treeID);

            treeData.setStudy(theStudy);
            ContextManager.getTaxonLabelService().updateStudyForAllLabels(treeData, theStudy);
            treeData.setTB1TreeID(treeID);
            ContextManager.getPhyloTreeService().save(treeData);
            theTreeBlock.addPhyloTree(treeData);
            theSubmission.addPhyloTreeBlockIfNecessary(theTreeBlock);
            ContextManager.getSubmissionService().save(theSubmission);
            theTree.setTree(treeData);
            theData = theTree;
          } else {
            throw new Error("Unknown IO section '" + ioSection.label + "' in study " + aux.getString(null, "study_id"));
          }
          theData.setAnalysisStep(theAnalysisStep);
          ContextManager.getAnalyzedDataService().save(theData);
          theAnalysisStep.addAnalyzedData(theData);
          ContextManager.getAnalysisStepService().save(theAnalysisStep);
        }
      }
     
      // TODO: fix submission taxa list
             
      Software theSoftware = new Software();
      theSoftware.setName(an.getString("software"));
      ContextManager.getStudyService().save(theSoftware); // XXX should be SoftwareService
      theAnalysisStep.setSoftwareInfo(theSoftware);
         
      theAnalysisStep.setNotes("Imported from TB1");
      ContextManager.getAnalysisStepService().save(theAnalysisStep);
     
      theStudy.addAnalysis(theAnalysis);
      ContextManager.getStudyService().save(theStudy);
    }
View Full Code Here

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

    // 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);
    step1.addAnalyzedData(treeData);

    getFixture().store(tree);
    getFixture().store(tree2);
    getFixture().store(block);

    // force commit immediately, important:
    setComplete();
    endTransaction();
    logger.info("tree1 created: " + tree.getLabel() + "id = " + tree.getId());
    logger.info("tree2 created: " + tree2.getLabel() + "id = " + tree2.getId());
    logger.info("treeBlock created: " + block.getTitle() + "id = " + block.getId());
    logger.info("analysis step created: " + step1.getName() + "id = " + step1.getId()
      + " associated data count=" + step1.getDataSetReadOnly().size());
    // logger.info("treeBlock created: " + block.getTitle() + "id = " + block.getId());

    // 2. verify
    String treeSql = "select count(*) from phylotree where treeBlock_id=" + block.getId();
    String blockSql = "select count(*) from treeblock where treeBlock_id=" + block.getId();
    String analyzedDataSql = "select count(*) from analyzedData where analysisstep_id="
      + step1.getId();
    String a1Sql = "select count(*) from analysis where analysis_id=" + a1.getId();
    int count = jdbcTemplate.queryForInt(treeSql);
    assertTrue(count == 2);
    count = jdbcTemplate.queryForInt(blockSql);
    assertTrue(count == 1);
View Full Code Here

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

    if (pData == null) {
      return false;
    }

    // manage bi-directional relationships:
    AnalysisStep analysisStep = pData.getAnalysisStep();
    if (analysisStep != null) {
      analysisStep.removeAnalyzedData(pData);
    }

    // Do not cascade delete, needs to handle manually:
    // * matrix
    // * tree:
 
View Full Code Here

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

    if (request.getParameter(ACTION_SUBMIT) != null) {

      // TODO: persist the analysisStep first since we need the analysis step id later.
      // It is better to move the analysis step creation code to analysisStepService.create()
      // method and return the analysis step id.
      AnalysisStep analysisStep = new AnalysisStep();
      ModelAndView resultView = updateAnalysisStep(analysisStepCommand,analysisStep,request,response,myerrors);
      if ( resultView != null ) {
        return resultView;
      }

      // determine which analysis we are dealing with
      String analysis_id = ServletRequestUtils.getStringParameter(request,"analysis_id",null);
      Analysis analysis = mAnalysisService.findByID(Long.parseLong(analysis_id));
      analysis.addAnalysisStep(analysisStep);

      mAnalysisService.update(analysis);
      if ( redirectView == null ) {
        return new ModelAndView("redirect:/user/analyzedDataForm.html" + "?analysis_step_id="
          + analysisStep.getId().toString());
      }
      else {
        return new ModelAndView(redirectView);
      }
    } else if (request.getParameter(ACTION_UPDATE) != null) {
      AnalysisStep analysisStep = mAnalysisStepService.findByID(analysisStepCommand.getId());
      ModelAndView resultView = updateAnalysisStep(analysisStepCommand,analysisStep,request,response,myerrors);
      if ( resultView != null ) {
        return resultView;
      }
     
      mAnalysisStepService.update(analysisStep);

    } else if (request.getParameter(ACTION_DELETE) != null) {

      AnalysisStep analysisStep = mAnalysisStepService.findByID(analysisStepCommand.getId());
      mAnalysisStepService.deleteAnalysisStep(analysisStep);
      if ( redirectView == null ) {
        return new ModelAndView(getSuccessView());
      }
      else {
View Full Code Here

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

        LOGGER.info("setAuthorizationChecked(false)");
        setAuthorizationChecked(false);
        return null;
      }
    } else {
      AnalysisStep analysisStep = mAnalysisStepService.findByID(Long
        .parseLong(analysisStep_id));
      Long analysis_id = analysisStep.getAnalysis().getId();

      TBPermission perm2 = getAnalysisService().getPermission(username, analysis_id);
      if (perm2 == TBPermission.WRITE || perm2 == TBPermission.READ_ONLY
        || perm2 == TBPermission.SUBMITTED_WRITE) {

        BeanUtils.copyProperties(analysisStep, analysisStepCommand);
        Software software = analysisStep.getSoftwareInfo();
        analysisStepCommand.setSoftwareInfo(software);
        Algorithm algorithm = analysisStep.getAlgorithmInfo();
        if ( algorithm != null ) {
          analysisStepCommand.setAlgorithmType(algorithm.getAlgorithmType());
          analysisStepCommand.setAlgorithmMap(algorithm.getAlgorithmType(), algorithm);
        }
        List<AnalyzedDataCommand> analyzedDataCommandList = createAnalyzedDataCommandList(analysisStep);
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.