Search in sources :

Example 21 with AnalysisOutputFile

use of ca.corefacility.bioinformatics.irida.model.workflow.analysis.AnalysisOutputFile in project irida by phac-nml.

the class AnalysisExecutionServiceGalaxyIT method testTransferAnalysisResultsSuccessAssemblyAnnotation.

/**
 * Tests out getting analysis results successfully for assembly and annotation pipeline (test version).
 *
 * @throws Exception
 */
@Test
@WithMockUser(username = "aaron", roles = "ADMIN")
public void testTransferAnalysisResultsSuccessAssemblyAnnotation() throws Exception {
    AnalysisSubmission analysisSubmission = analysisExecutionGalaxyITService.setupPairSubmissionInDatabase(1L, pairedPaths1, pairedPaths2, iridaAssemblyAnnotationWorkflowId);
    Future<AnalysisSubmission> analysisSubmittedFuture = analysisExecutionService.prepareSubmission(analysisSubmission);
    AnalysisSubmission analysisSubmitted = analysisSubmittedFuture.get();
    Future<AnalysisSubmission> analysisExecutionFuture = analysisExecutionService.executeAnalysis(analysisSubmitted);
    AnalysisSubmission analysisExecuted = analysisExecutionFuture.get();
    analysisExecutionGalaxyITService.waitUntilSubmissionComplete(analysisExecuted);
    analysisExecuted.setAnalysisState(AnalysisState.FINISHED_RUNNING);
    Future<AnalysisSubmission> analysisSubmissionCompletedFuture = analysisExecutionService.transferAnalysisResults(analysisExecuted);
    AnalysisSubmission analysisSubmissionCompleted = analysisSubmissionCompletedFuture.get();
    AnalysisSubmission analysisSubmissionCompletedDatabase = analysisSubmissionService.read(analysisSubmission.getId());
    assertEquals("analysis state is not completed", AnalysisState.COMPLETED, analysisSubmissionCompletedDatabase.getAnalysisState());
    assertEquals("analysis state is not completed", AnalysisState.COMPLETED, analysisSubmissionCompleted.getAnalysisState());
    Analysis analysisResults = analysisSubmissionCompleted.getAnalysis();
    Analysis analysisResultsDatabase = analysisSubmissionCompletedDatabase.getAnalysis();
    assertEquals("analysis results in returned submission and from database should be the same", analysisResults.getId(), analysisResultsDatabase.getId());
    String analysisId = analysisExecuted.getRemoteAnalysisId();
    assertEquals("id should be set properly for analysis", analysisId, analysisResultsDatabase.getExecutionManagerAnalysisId());
    assertEquals("invalid number of output files", 3, analysisResultsDatabase.getAnalysisOutputFiles().size());
    AnalysisOutputFile contigs = analysisResultsDatabase.getAnalysisOutputFile("contigs");
    AnalysisOutputFile annotations = analysisResultsDatabase.getAnalysisOutputFile("annotations-genbank");
    AnalysisOutputFile prokkaLog = analysisResultsDatabase.getAnalysisOutputFile("annotations-log");
    assertTrue("contigs should be equal", com.google.common.io.Files.equal(expectedContigs.toFile(), contigs.getFile().toFile()));
    assertEquals("invalid file name for contigs", expectedContigs.getFileName(), contigs.getFile().getFileName());
    assertTrue("annotations should be correct", com.google.common.io.Files.equal(expectedAnnotations.toFile(), annotations.getFile().toFile()));
    assertEquals("invalid file name for annotations", expectedAnnotations.getFileName(), annotations.getFile().getFileName());
    assertTrue("annotations log should be correct", com.google.common.io.Files.equal(expectedAnnotationsLog.toFile(), prokkaLog.getFile().toFile()));
    assertEquals("invalid file name for annotations log", expectedAnnotationsLog.getFileName(), prokkaLog.getFile().getFileName());
}
Also used : Analysis(ca.corefacility.bioinformatics.irida.model.workflow.analysis.Analysis) AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission) AnalysisOutputFile(ca.corefacility.bioinformatics.irida.model.workflow.analysis.AnalysisOutputFile) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Example 22 with AnalysisOutputFile

use of ca.corefacility.bioinformatics.irida.model.workflow.analysis.AnalysisOutputFile in project irida by phac-nml.

the class AnalysisExecutionServiceGalaxyIT method testTransferAnalysisResultsSuccessPhylogenomics.

/**
 * Tests out getting analysis results successfully.
 *
 * @throws Exception
 */
@Test
@WithMockUser(username = "aaron", roles = "ADMIN")
public void testTransferAnalysisResultsSuccessPhylogenomics() throws Exception {
    AnalysisSubmission analysisSubmission = analysisExecutionGalaxyITService.setupSubmissionInDatabase(1L, sequenceFilePath, referenceFilePath, iridaPhylogenomicsWorkflowId, false);
    Future<AnalysisSubmission> analysisSubmittedFuture = analysisExecutionService.prepareSubmission(analysisSubmission);
    AnalysisSubmission analysisSubmitted = analysisSubmittedFuture.get();
    float percentComplete = analysisSubmissionService.getPercentCompleteForAnalysisSubmission(analysisSubmitted.getId());
    assertEquals("percent complete is incorrect", 11.0f, percentComplete, DELTA);
    Future<AnalysisSubmission> analysisExecutionFuture = analysisExecutionService.executeAnalysis(analysisSubmitted);
    AnalysisSubmission analysisExecuted = analysisExecutionFuture.get();
    assertNotNull("remoteInputDataId is null", analysisExecuted.getRemoteInputDataId());
    String remoteInputDataId = analysisExecuted.getRemoteInputDataId();
    percentComplete = analysisSubmissionService.getPercentCompleteForAnalysisSubmission(analysisSubmitted.getId());
    assertTrue("percent complete is incorrect", 10.0f <= percentComplete && percentComplete <= 90.0f);
    analysisExecutionGalaxyITService.waitUntilSubmissionComplete(analysisExecuted);
    percentComplete = analysisSubmissionService.getPercentCompleteForAnalysisSubmission(analysisSubmitted.getId());
    assertEquals("percent complete is incorrect", 90.0f, percentComplete, DELTA);
    analysisExecuted.setAnalysisState(AnalysisState.FINISHED_RUNNING);
    percentComplete = analysisSubmissionService.getPercentCompleteForAnalysisSubmission(analysisSubmitted.getId());
    assertEquals("percent complete is incorrect", 90.0f, percentComplete, DELTA);
    Future<AnalysisSubmission> analysisSubmissionCompletedFuture = analysisExecutionService.transferAnalysisResults(analysisExecuted);
    AnalysisSubmission analysisSubmissionCompleted = analysisSubmissionCompletedFuture.get();
    AnalysisSubmission analysisSubmissionCompletedDatabase = analysisSubmissionService.read(analysisSubmission.getId());
    assertEquals(AnalysisState.COMPLETED, analysisSubmissionCompletedDatabase.getAnalysisState());
    assertEquals(AnalysisState.COMPLETED, analysisSubmissionCompleted.getAnalysisState());
    assertEquals("remoteInputDataId should be unchanged in the completed analysis", remoteInputDataId, analysisSubmissionCompletedDatabase.getRemoteInputDataId());
    percentComplete = analysisSubmissionService.getPercentCompleteForAnalysisSubmission(analysisSubmitted.getId());
    assertEquals("percent complete is incorrect", 100.0f, percentComplete, DELTA);
    Analysis analysisResults = analysisSubmissionCompleted.getAnalysis();
    Analysis analysisResultsDatabase = analysisSubmissionCompletedDatabase.getAnalysis();
    assertEquals("analysis results in returned submission and from database should be the same", analysisResults.getId(), analysisResultsDatabase.getId());
    assertEquals(AnalysisType.PHYLOGENOMICS, analysisResults.getAnalysisType());
    String analysisId = analysisExecuted.getRemoteAnalysisId();
    assertEquals("id should be set properly for analysis", analysisId, analysisResultsDatabase.getExecutionManagerAnalysisId());
    assertEquals(3, analysisResultsDatabase.getAnalysisOutputFiles().size());
    AnalysisOutputFile phylogeneticTree = analysisResultsDatabase.getAnalysisOutputFile(TREE_KEY);
    AnalysisOutputFile snpMatrix = analysisResultsDatabase.getAnalysisOutputFile(MATRIX_KEY);
    AnalysisOutputFile snpTable = analysisResultsDatabase.getAnalysisOutputFile(TABLE_KEY);
    assertTrue("phylogenetic trees should be equal", com.google.common.io.Files.equal(expectedTree.toFile(), phylogeneticTree.getFile().toFile()));
    assertEquals(expectedTree.getFileName(), phylogeneticTree.getFile().getFileName());
    assertTrue("snp matrices should be correct", com.google.common.io.Files.equal(expectedSnpMatrix.toFile(), snpMatrix.getFile().toFile()));
    assertEquals(expectedSnpMatrix.getFileName(), snpMatrix.getFile().getFileName());
    assertTrue("snpTable should be correct", com.google.common.io.Files.equal(expectedSnpTable.toFile(), snpTable.getFile().toFile()));
    assertEquals(expectedSnpTable.getFileName(), snpTable.getFile().getFileName());
    AnalysisSubmission finalSubmission = analysisSubmissionRepository.findOne(analysisExecuted.getId());
    Analysis analysis = finalSubmission.getAnalysis();
    assertNotNull(analysis);
    Analysis savedAnalysisFromDatabase = analysisService.read(analysisResultsDatabase.getId());
    assertEquals(AnalysisType.PHYLOGENOMICS, savedAnalysisFromDatabase.getAnalysisType());
    assertEquals("Analysis from submission and from database should be the same", savedAnalysisFromDatabase.getId(), analysis.getId());
    assertEquals(analysisResultsDatabase.getId(), savedAnalysisFromDatabase.getId());
    assertEquals(analysisResultsDatabase.getAnalysisOutputFile(TREE_KEY).getFile(), savedAnalysisFromDatabase.getAnalysisOutputFile(TREE_KEY).getFile());
    assertEquals(analysisResultsDatabase.getAnalysisOutputFile(MATRIX_KEY).getFile(), savedAnalysisFromDatabase.getAnalysisOutputFile(MATRIX_KEY).getFile());
    assertEquals(analysisResultsDatabase.getAnalysisOutputFile(TABLE_KEY).getFile(), savedAnalysisFromDatabase.getAnalysisOutputFile(TABLE_KEY).getFile());
}
Also used : Analysis(ca.corefacility.bioinformatics.irida.model.workflow.analysis.Analysis) AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission) AnalysisOutputFile(ca.corefacility.bioinformatics.irida.model.workflow.analysis.AnalysisOutputFile) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Example 23 with AnalysisOutputFile

use of ca.corefacility.bioinformatics.irida.model.workflow.analysis.AnalysisOutputFile in project irida by phac-nml.

the class AnalysisExecutionServiceGalaxyIT method testTransferAnalysisResultsSuccessPhylogenomicsPairedParametersIgnoreDefaultValues.

/**
 * Tests out getting analysis results successfully for phylogenomics
 * pipeline (paired test version and ignoring default parameters).
 *
 * @throws Exception
 */
@Test
@WithMockUser(username = "aaron", roles = "ADMIN")
public void testTransferAnalysisResultsSuccessPhylogenomicsPairedParametersIgnoreDefaultValues() throws Exception {
    String validMinCoverageFromProvenance = "\"5\"";
    String validMidCoverageFromProvenance = "15";
    String validMaxCoverageFromProvenance = "\"20\"";
    Map<String, String> parameters = ImmutableMap.of("coverage", IridaWorkflowParameter.IGNORE_DEFAULT_VALUE);
    // I verify parameters were set
    String validTreeFile = "5 15 20";
    // correctly by checking output file
    // (where parameters were printed).
    AnalysisSubmission analysisSubmission = analysisExecutionGalaxyITService.setupPairSubmissionInDatabase(1L, pairedPaths1, pairedPaths2, referenceFilePath, parameters, iridaPhylogenomicsPairedParametersWorkflowId);
    Future<AnalysisSubmission> analysisSubmittedFuture = analysisExecutionService.prepareSubmission(analysisSubmission);
    AnalysisSubmission analysisSubmitted = analysisSubmittedFuture.get();
    Future<AnalysisSubmission> analysisExecutionFuture = analysisExecutionService.executeAnalysis(analysisSubmitted);
    AnalysisSubmission analysisExecuted = analysisExecutionFuture.get();
    analysisExecutionGalaxyITService.waitUntilSubmissionComplete(analysisExecuted);
    analysisExecuted.setAnalysisState(AnalysisState.FINISHED_RUNNING);
    Future<AnalysisSubmission> analysisSubmissionCompletedFuture = analysisExecutionService.transferAnalysisResults(analysisExecuted);
    analysisSubmissionCompletedFuture.get();
    AnalysisSubmission analysisSubmissionCompletedDatabase = analysisSubmissionService.read(analysisSubmission.getId());
    assertEquals("analysis state is not completed", AnalysisState.COMPLETED, analysisSubmissionCompletedDatabase.getAnalysisState());
    Analysis analysisResults = analysisSubmissionCompletedDatabase.getAnalysis();
    assertEquals("analysis results is an invalid class", AnalysisType.PHYLOGENOMICS, analysisResults.getAnalysisType());
    assertEquals("invalid number of output files", 3, analysisResults.getAnalysisOutputFiles().size());
    AnalysisOutputFile phylogeneticTree = analysisResults.getAnalysisOutputFile(TREE_KEY);
    AnalysisOutputFile snpMatrix = analysisResults.getAnalysisOutputFile(MATRIX_KEY);
    AnalysisOutputFile snpTable = analysisResults.getAnalysisOutputFile(TABLE_KEY);
    // verify parameters were set properly by checking contents of file
    @SuppressWarnings("resource") String treeContent = new Scanner(phylogeneticTree.getFile().toFile()).useDelimiter("\\Z").next();
    assertEquals("phylogenetic trees containing the parameters should be equal", validTreeFile, treeContent);
    // phy tree
    final ToolExecution phyTreeCoreInputs = phylogeneticTree.getCreatedByTool();
    assertEquals("The first tool execution should be by core_pipeline_outputs_paired_with_parameters v0.1.0", "core_pipeline_outputs_paired_with_parameters", phyTreeCoreInputs.getToolName());
    assertEquals("The first tool execution should be by core_pipeline_outputs_paired_with_parameters v0.1.0", "0.1.0", phyTreeCoreInputs.getToolVersion());
    Map<String, String> phyTreeCoreParameters = phyTreeCoreInputs.getExecutionTimeParameters();
    assertEquals("incorrect number of non-file parameters", 4, phyTreeCoreParameters.size());
    assertEquals("parameter coverageMin set incorrectly", validMinCoverageFromProvenance, phyTreeCoreParameters.get("coverageMin"));
    assertEquals("parameter coverageMid set incorrectly", validMidCoverageFromProvenance, phyTreeCoreParameters.get("conditional.coverageMid"));
    assertEquals("parameter coverageMax set incorrectly", validMaxCoverageFromProvenance, phyTreeCoreParameters.get("coverageMax"));
    assertEquals("parameter conditional_select set incorrectly", "all", phyTreeCoreParameters.get("conditional.conditional_select"));
    Set<ToolExecution> phyTreeCorePreviousSteps = phyTreeCoreInputs.getPreviousSteps();
    assertEquals("there should exist 2 previous steps", 2, phyTreeCorePreviousSteps.size());
    Set<String> uploadedFileTypesPhy = Sets.newHashSet();
    for (ToolExecution previousStep : phyTreeCorePreviousSteps) {
        assertTrue("previous steps should be input tools.", previousStep.isInputTool());
        uploadedFileTypesPhy.add(previousStep.getExecutionTimeParameters().get("file_type"));
    }
    assertEquals("uploaded files should have correct types", Sets.newHashSet("\"fastqsanger\"", "\"fasta\""), uploadedFileTypesPhy);
    // snp matrix
    final ToolExecution matrixCoreInputs = snpMatrix.getCreatedByTool();
    assertEquals("The first tool execution should be by core_pipeline_outputs_paired_with_parameters v0.1.0", "core_pipeline_outputs_paired_with_parameters", matrixCoreInputs.getToolName());
    assertEquals("The first tool execution should be by core_pipeline_outputs_paired_with_parameters v0.1.0", "0.1.0", matrixCoreInputs.getToolVersion());
    Map<String, String> matrixCoreParameters = matrixCoreInputs.getExecutionTimeParameters();
    assertEquals("incorrect number of non-file parameters", 4, matrixCoreParameters.size());
    assertEquals("parameter coverageMin set incorrectly", validMinCoverageFromProvenance, matrixCoreParameters.get("coverageMin"));
    assertEquals("parameter coverageMid set incorrectly", validMidCoverageFromProvenance, phyTreeCoreParameters.get("conditional.coverageMid"));
    assertEquals("parameter coverageMax set incorrectly", validMaxCoverageFromProvenance, matrixCoreParameters.get("coverageMax"));
    assertEquals("parameter conditional_select set incorrectly", "all", phyTreeCoreParameters.get("conditional.conditional_select"));
    Set<ToolExecution> matrixCorePreviousSteps = matrixCoreInputs.getPreviousSteps();
    assertEquals("there should exist 2 previous steps", 2, matrixCorePreviousSteps.size());
    Set<String> uploadedFileTypesMatrix = Sets.newHashSet();
    for (ToolExecution previousStep : matrixCorePreviousSteps) {
        assertTrue("previous steps should be input tools.", previousStep.isInputTool());
        uploadedFileTypesMatrix.add(previousStep.getExecutionTimeParameters().get("file_type"));
    }
    assertEquals("uploaded files should have correct types", Sets.newHashSet("\"fastqsanger\"", "\"fasta\""), uploadedFileTypesMatrix);
    // snp table
    final ToolExecution tableCoreInputs = snpTable.getCreatedByTool();
    assertEquals("The first tool execution should be by core_pipeline_outputs_paired_with_parameters v0.1.0", "core_pipeline_outputs_paired_with_parameters", tableCoreInputs.getToolName());
    assertEquals("The first tool execution should be by core_pipeline_outputs_paired_with_parameters v0.1.0", "0.1.0", tableCoreInputs.getToolVersion());
    Map<String, String> tableCoreParameters = tableCoreInputs.getExecutionTimeParameters();
    assertEquals("incorrect number of non-file parameters", 4, tableCoreParameters.size());
    assertEquals("parameter coverageMin set incorrectly", validMinCoverageFromProvenance, tableCoreParameters.get("coverageMin"));
    assertEquals("parameter coverageMid set incorrectly", validMidCoverageFromProvenance, phyTreeCoreParameters.get("conditional.coverageMid"));
    assertEquals("parameter coverageMax set incorrectly", validMaxCoverageFromProvenance, tableCoreParameters.get("coverageMax"));
    assertEquals("parameter conditional_select set incorrectly", "all", phyTreeCoreParameters.get("conditional.conditional_select"));
    Set<ToolExecution> tablePreviousSteps = tableCoreInputs.getPreviousSteps();
    assertEquals("there should exist 2 previous steps", 2, tablePreviousSteps.size());
    Set<String> uploadedFileTypesTable = Sets.newHashSet();
    for (ToolExecution previousStep : tablePreviousSteps) {
        assertTrue("previous steps should be input tools.", previousStep.isInputTool());
        uploadedFileTypesTable.add(previousStep.getExecutionTimeParameters().get("file_type"));
    }
    assertEquals("uploaded files should have correct types", Sets.newHashSet("\"fastqsanger\"", "\"fasta\""), uploadedFileTypesTable);
}
Also used : Scanner(java.util.Scanner) ToolExecution(ca.corefacility.bioinformatics.irida.model.workflow.analysis.ToolExecution) Analysis(ca.corefacility.bioinformatics.irida.model.workflow.analysis.Analysis) AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission) AnalysisOutputFile(ca.corefacility.bioinformatics.irida.model.workflow.analysis.AnalysisOutputFile) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Example 24 with AnalysisOutputFile

use of ca.corefacility.bioinformatics.irida.model.workflow.analysis.AnalysisOutputFile in project irida by phac-nml.

the class AnalysisExecutionServiceGalaxyIT method testTransferAnalysisResultsSuccessPhylogenomicsPairedParameters.

/**
 * Tests out getting analysis results successfully for phylogenomics
 * pipeline (paired test version with parameters).
 *
 * @throws Exception
 */
@Test
@WithMockUser(username = "aaron", roles = "ADMIN")
public void testTransferAnalysisResultsSuccessPhylogenomicsPairedParameters() throws Exception {
    String validCoverage = "20";
    // coverage from
    String validCoverageFromProvenance = "\"20\"";
    // provenance has quotes
    // this value does not have quotes around it in final results.
    String validMidCoverageFromProvenance = "20";
    Map<String, String> parameters = ImmutableMap.of("coverage", validCoverage);
    // I verify parameters were set
    String validTreeFile = "20 20 20";
    // correctly by checking output file
    // (where parameters were printed).
    AnalysisSubmission analysisSubmission = analysisExecutionGalaxyITService.setupPairSubmissionInDatabase(1L, pairedPaths1, pairedPaths2, referenceFilePath, parameters, iridaPhylogenomicsPairedParametersWorkflowId);
    Future<AnalysisSubmission> analysisSubmittedFuture = analysisExecutionService.prepareSubmission(analysisSubmission);
    AnalysisSubmission analysisSubmitted = analysisSubmittedFuture.get();
    Future<AnalysisSubmission> analysisExecutionFuture = analysisExecutionService.executeAnalysis(analysisSubmitted);
    AnalysisSubmission analysisExecuted = analysisExecutionFuture.get();
    analysisExecutionGalaxyITService.waitUntilSubmissionComplete(analysisExecuted);
    analysisExecuted.setAnalysisState(AnalysisState.FINISHED_RUNNING);
    Future<AnalysisSubmission> analysisSubmissionCompletedFuture = analysisExecutionService.transferAnalysisResults(analysisExecuted);
    analysisSubmissionCompletedFuture.get();
    AnalysisSubmission analysisSubmissionCompletedDatabase = analysisSubmissionService.read(analysisSubmission.getId());
    assertEquals("analysis state is not completed", AnalysisState.COMPLETED, analysisSubmissionCompletedDatabase.getAnalysisState());
    Analysis analysisResults = analysisSubmissionCompletedDatabase.getAnalysis();
    assertEquals("analysis results is an invalid class", AnalysisType.PHYLOGENOMICS, analysisResults.getAnalysisType());
    assertEquals("invalid number of output files", 3, analysisResults.getAnalysisOutputFiles().size());
    AnalysisOutputFile phylogeneticTree = analysisResults.getAnalysisOutputFile(TREE_KEY);
    AnalysisOutputFile snpMatrix = analysisResults.getAnalysisOutputFile(MATRIX_KEY);
    AnalysisOutputFile snpTable = analysisResults.getAnalysisOutputFile(TABLE_KEY);
    // verify parameters were set properly by checking contents of file
    @SuppressWarnings("resource") String treeContent = new Scanner(phylogeneticTree.getFile().toFile()).useDelimiter("\\Z").next();
    assertEquals("phylogenetic trees containing the parameters should be equal", validTreeFile, treeContent);
    // phy tree
    final ToolExecution phyTreeCoreInputs = phylogeneticTree.getCreatedByTool();
    assertEquals("The first tool execution should be by core_pipeline_outputs_paired_with_parameters v0.1.0", "core_pipeline_outputs_paired_with_parameters", phyTreeCoreInputs.getToolName());
    assertEquals("The first tool execution should be by core_pipeline_outputs_paired_with_parameters v0.1.0", "0.1.0", phyTreeCoreInputs.getToolVersion());
    Map<String, String> phyTreeCoreParameters = phyTreeCoreInputs.getExecutionTimeParameters();
    assertEquals("incorrect number of non-file parameters", 4, phyTreeCoreParameters.size());
    assertEquals("parameter coverageMin set incorrectly", validCoverageFromProvenance, phyTreeCoreParameters.get("coverageMin"));
    assertEquals("parameter coverageMid set incorrectly", validMidCoverageFromProvenance, phyTreeCoreParameters.get("conditional.coverageMid"));
    assertEquals("parameter coverageMax set incorrectly", validCoverageFromProvenance, phyTreeCoreParameters.get("coverageMax"));
    assertEquals("parameter conditional_select set incorrectly", "all", phyTreeCoreParameters.get("conditional.conditional_select"));
    Set<ToolExecution> phyTreeCorePreviousSteps = phyTreeCoreInputs.getPreviousSteps();
    assertEquals("there should exist 2 previous steps", 2, phyTreeCorePreviousSteps.size());
    Set<String> uploadedFileTypesPhy = Sets.newHashSet();
    for (ToolExecution previousStep : phyTreeCorePreviousSteps) {
        assertTrue("previous steps should be input tools.", previousStep.isInputTool());
        uploadedFileTypesPhy.add(previousStep.getExecutionTimeParameters().get("file_type"));
    }
    assertEquals("uploaded files should have correct types", Sets.newHashSet("\"fastqsanger\"", "\"fasta\""), uploadedFileTypesPhy);
    // snp matrix
    final ToolExecution matrixCoreInputs = snpMatrix.getCreatedByTool();
    assertEquals("The first tool execution should be by core_pipeline_outputs_paired_with_parameters v0.1.0", "core_pipeline_outputs_paired_with_parameters", matrixCoreInputs.getToolName());
    assertEquals("The first tool execution should be by core_pipeline_outputs_paired_with_parameters v0.1.0", "0.1.0", matrixCoreInputs.getToolVersion());
    Map<String, String> matrixCoreParameters = matrixCoreInputs.getExecutionTimeParameters();
    assertEquals("incorrect number of non-file parameters", 4, matrixCoreParameters.size());
    assertEquals("parameter coverageMin set incorrectly", validCoverageFromProvenance, matrixCoreParameters.get("coverageMin"));
    assertEquals("parameter coverageMid set incorrectly", validMidCoverageFromProvenance, phyTreeCoreParameters.get("conditional.coverageMid"));
    assertEquals("parameter coverageMax set incorrectly", validCoverageFromProvenance, matrixCoreParameters.get("coverageMax"));
    assertEquals("parameter conditional_select set incorrectly", "all", phyTreeCoreParameters.get("conditional.conditional_select"));
    Set<ToolExecution> matrixCorePreviousSteps = matrixCoreInputs.getPreviousSteps();
    assertEquals("there should exist 2 previous steps", 2, matrixCorePreviousSteps.size());
    Set<String> uploadedFileTypesMatrix = Sets.newHashSet();
    for (ToolExecution previousStep : matrixCorePreviousSteps) {
        assertTrue("previous steps should be input tools.", previousStep.isInputTool());
        uploadedFileTypesMatrix.add(previousStep.getExecutionTimeParameters().get("file_type"));
    }
    assertEquals("uploaded files should have correct types", Sets.newHashSet("\"fastqsanger\"", "\"fasta\""), uploadedFileTypesMatrix);
    // snp table
    final ToolExecution tableCoreInputs = snpTable.getCreatedByTool();
    assertEquals("The first tool execution should be by core_pipeline_outputs_paired_with_parameters v0.1.0", "core_pipeline_outputs_paired_with_parameters", tableCoreInputs.getToolName());
    assertEquals("The first tool execution should be by core_pipeline_outputs_paired_with_parameters v0.1.0", "0.1.0", tableCoreInputs.getToolVersion());
    Map<String, String> tableCoreParameters = tableCoreInputs.getExecutionTimeParameters();
    assertEquals("incorrect number of non-file parameters", 4, tableCoreParameters.size());
    assertEquals("parameter coverageMin set incorrectly", validCoverageFromProvenance, tableCoreParameters.get("coverageMin"));
    assertEquals("parameter coverageMid set incorrectly", validMidCoverageFromProvenance, phyTreeCoreParameters.get("conditional.coverageMid"));
    assertEquals("parameter coverageMax set incorrectly", validCoverageFromProvenance, tableCoreParameters.get("coverageMax"));
    assertEquals("parameter conditional_select set incorrectly", "all", phyTreeCoreParameters.get("conditional.conditional_select"));
    Set<ToolExecution> tablePreviousSteps = tableCoreInputs.getPreviousSteps();
    assertEquals("there should exist 2 previous steps", 2, tablePreviousSteps.size());
    Set<String> uploadedFileTypesTable = Sets.newHashSet();
    for (ToolExecution previousStep : tablePreviousSteps) {
        assertTrue("previous steps should be input tools.", previousStep.isInputTool());
        uploadedFileTypesTable.add(previousStep.getExecutionTimeParameters().get("file_type"));
    }
    assertEquals("uploaded files should have correct types", Sets.newHashSet("\"fastqsanger\"", "\"fasta\""), uploadedFileTypesTable);
}
Also used : Scanner(java.util.Scanner) ToolExecution(ca.corefacility.bioinformatics.irida.model.workflow.analysis.ToolExecution) Analysis(ca.corefacility.bioinformatics.irida.model.workflow.analysis.Analysis) AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission) AnalysisOutputFile(ca.corefacility.bioinformatics.irida.model.workflow.analysis.AnalysisOutputFile) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Example 25 with AnalysisOutputFile

use of ca.corefacility.bioinformatics.irida.model.workflow.analysis.AnalysisOutputFile in project irida by phac-nml.

the class AnalysisExecutionServiceGalaxyIT method testTransferAnalysisResultsSuccessPhylogenomicsPaired.

/**
 * Tests out getting analysis results successfully for phylogenomics
 * pipeline (paired test version).
 *
 * @throws Exception
 */
@Test
@WithMockUser(username = "aaron", roles = "ADMIN")
public void testTransferAnalysisResultsSuccessPhylogenomicsPaired() throws Exception {
    AnalysisSubmission analysisSubmission = analysisExecutionGalaxyITService.setupPairSubmissionInDatabase(1L, pairedPaths1, pairedPaths2, referenceFilePath, iridaPhylogenomicsPairedWorkflowId, false);
    Future<AnalysisSubmission> analysisSubmittedFuture = analysisExecutionService.prepareSubmission(analysisSubmission);
    AnalysisSubmission analysisSubmitted = analysisSubmittedFuture.get();
    Future<AnalysisSubmission> analysisExecutionFuture = analysisExecutionService.executeAnalysis(analysisSubmitted);
    AnalysisSubmission analysisExecuted = analysisExecutionFuture.get();
    analysisExecutionGalaxyITService.waitUntilSubmissionComplete(analysisExecuted);
    analysisExecuted.setAnalysisState(AnalysisState.FINISHED_RUNNING);
    Future<AnalysisSubmission> analysisSubmissionCompletedFuture = analysisExecutionService.transferAnalysisResults(analysisExecuted);
    AnalysisSubmission analysisSubmissionCompleted = analysisSubmissionCompletedFuture.get();
    AnalysisSubmission analysisSubmissionCompletedDatabase = analysisSubmissionService.read(analysisSubmission.getId());
    assertEquals("analysis state is not completed", AnalysisState.COMPLETED, analysisSubmissionCompletedDatabase.getAnalysisState());
    assertEquals("analysis state is not completed", AnalysisState.COMPLETED, analysisSubmissionCompleted.getAnalysisState());
    Analysis analysisResults = analysisSubmissionCompleted.getAnalysis();
    Analysis analysisResultsDatabase = analysisSubmissionCompletedDatabase.getAnalysis();
    assertEquals("analysis results in returned submission and from database should be the same", analysisResults.getId(), analysisResultsDatabase.getId());
    assertEquals(AnalysisType.PHYLOGENOMICS, analysisResults.getAnalysisType());
    String analysisId = analysisExecuted.getRemoteAnalysisId();
    assertEquals("id should be set properly for analysis", analysisId, analysisResultsDatabase.getExecutionManagerAnalysisId());
    assertEquals("invalid number of output files", 3, analysisResultsDatabase.getAnalysisOutputFiles().size());
    AnalysisOutputFile phylogeneticTree = analysisResultsDatabase.getAnalysisOutputFile(TREE_KEY);
    AnalysisOutputFile snpMatrix = analysisResultsDatabase.getAnalysisOutputFile(MATRIX_KEY);
    AnalysisOutputFile snpTable = analysisResultsDatabase.getAnalysisOutputFile(TABLE_KEY);
    assertTrue("phylogenetic trees should be equal", com.google.common.io.Files.equal(expectedTree.toFile(), phylogeneticTree.getFile().toFile()));
    assertEquals("invalid file name for snp tree", expectedTree.getFileName(), phylogeneticTree.getFile().getFileName());
    assertTrue("command line (" + phylogeneticTree.getCreatedByTool().getCommandLine() + ") should match the defined pattern (" + CMD_LINE_PATTERN + ") (phylogenetic tree).", phylogeneticTree.getCreatedByTool().getCommandLine().matches(CMD_LINE_PATTERN));
    final ToolExecution phyTreeCoreInputs = phylogeneticTree.getCreatedByTool();
    assertEquals("The first tool execution should be by core_pipeline_outputs_paired v0.1.0", "core_pipeline_outputs_paired", phyTreeCoreInputs.getToolName());
    assertEquals("The first tool execution should be by core_pipeline_outputs_paired v0.1.0", "0.1.0", phyTreeCoreInputs.getToolVersion());
    final ToolExecution phyTreeCoreUpload = phyTreeCoreInputs.getPreviousSteps().iterator().next();
    assertTrue("Second step should be input tool.", phyTreeCoreUpload.isInputTool());
    assertTrue("snp matrices should be correct", com.google.common.io.Files.equal(expectedSnpMatrix.toFile(), snpMatrix.getFile().toFile()));
    assertEquals("invalid file name for snp matrix", expectedSnpMatrix.getFileName(), snpMatrix.getFile().getFileName());
    assertTrue("command line (" + snpMatrix.getCreatedByTool().getCommandLine() + ") should match the defined pattern (" + CMD_LINE_PATTERN + ") (snp matrix).", snpMatrix.getCreatedByTool().getCommandLine().matches(CMD_LINE_PATTERN));
    final ToolExecution snpMatrixCoreInputs = snpMatrix.getCreatedByTool();
    assertEquals("The first tool execution should be by core_pipeline_outputs_paired v0.1.0", "core_pipeline_outputs_paired", snpMatrixCoreInputs.getToolName());
    assertEquals("The first tool execution should be by core_pipeline_outputs_paired v0.1.0", "0.1.0", snpMatrixCoreInputs.getToolVersion());
    final ToolExecution snpMatrixCoreUpload = snpMatrixCoreInputs.getPreviousSteps().iterator().next();
    assertTrue("Second step should be input tool.", snpMatrixCoreUpload.isInputTool());
    assertTrue("snpTable should be correct", com.google.common.io.Files.equal(expectedSnpTable.toFile(), snpTable.getFile().toFile()));
    assertEquals("invalid file name for snp table", expectedSnpTable.getFileName(), snpTable.getFile().getFileName());
    assertTrue("command line (" + snpTable.getCreatedByTool().getCommandLine() + ") should match the defined pattern (" + CMD_LINE_PATTERN + ") (snp table).", snpTable.getCreatedByTool().getCommandLine().matches(CMD_LINE_PATTERN));
    final ToolExecution snpTableCoreInputs = snpTable.getCreatedByTool();
    assertEquals("The first tool execution should be by core_pipeline_outputs_paired v0.1.0", "core_pipeline_outputs_paired", snpTableCoreInputs.getToolName());
    assertEquals("The first tool execution should be by core_pipeline_outputs_paired v0.1.0", "0.1.0", snpTableCoreInputs.getToolVersion());
    final ToolExecution snpTableCoreUpload = snpTableCoreInputs.getPreviousSteps().iterator().next();
    assertTrue("Second step should be input tool.", snpTableCoreUpload.isInputTool());
    AnalysisSubmission finalSubmission = analysisSubmissionRepository.findOne(analysisExecuted.getId());
    Analysis analysis = finalSubmission.getAnalysis();
    assertNotNull("analysis should not be null in submission", analysis);
    Analysis savedAnalysisFromDatabase = analysisService.read(analysisResultsDatabase.getId());
    assertEquals("saved analysis in submission is not correct class", AnalysisType.PHYLOGENOMICS, savedAnalysisFromDatabase.getAnalysisType());
    assertEquals("Analysis from submission and from database should be the same", savedAnalysisFromDatabase.getId(), analysis.getId());
    assertEquals("analysis results from database and from submission should have correct id", analysisResultsDatabase.getId(), savedAnalysisFromDatabase.getId());
    assertEquals("analysis results from database and from submission should have correct tree output file", analysisResultsDatabase.getAnalysisOutputFile(TREE_KEY).getFile(), savedAnalysisFromDatabase.getAnalysisOutputFile(TREE_KEY).getFile());
    assertEquals("analysis results from database and from submission should have correct matrix output file", analysisResultsDatabase.getAnalysisOutputFile(MATRIX_KEY).getFile(), savedAnalysisFromDatabase.getAnalysisOutputFile(MATRIX_KEY).getFile());
    assertEquals("analysis results from database and from submission should have correct table output file", analysisResultsDatabase.getAnalysisOutputFile(MATRIX_KEY).getFile(), savedAnalysisFromDatabase.getAnalysisOutputFile(MATRIX_KEY).getFile());
}
Also used : ToolExecution(ca.corefacility.bioinformatics.irida.model.workflow.analysis.ToolExecution) Analysis(ca.corefacility.bioinformatics.irida.model.workflow.analysis.Analysis) AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission) AnalysisOutputFile(ca.corefacility.bioinformatics.irida.model.workflow.analysis.AnalysisOutputFile) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Aggregations

AnalysisOutputFile (ca.corefacility.bioinformatics.irida.model.workflow.analysis.AnalysisOutputFile)30 Analysis (ca.corefacility.bioinformatics.irida.model.workflow.analysis.Analysis)20 AnalysisSubmission (ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission)17 Test (org.junit.Test)14 Path (java.nio.file.Path)13 ToolExecution (ca.corefacility.bioinformatics.irida.model.workflow.analysis.ToolExecution)11 WithMockUser (org.springframework.security.test.context.support.WithMockUser)7 Sample (ca.corefacility.bioinformatics.irida.model.sample.Sample)5 EntityNotFoundException (ca.corefacility.bioinformatics.irida.exceptions.EntityNotFoundException)4 MetadataTemplateField (ca.corefacility.bioinformatics.irida.model.sample.MetadataTemplateField)4 MetadataEntry (ca.corefacility.bioinformatics.irida.model.sample.metadata.MetadataEntry)4 ImmutableMap (com.google.common.collect.ImmutableMap)4 AnalysisType (ca.corefacility.bioinformatics.irida.model.enums.AnalysisType)3 SingleEndSequenceFile (ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile)3 IridaWorkflow (ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow)3 AnalysisOutputFileInfo (ca.corefacility.bioinformatics.irida.ria.web.analysis.dto.AnalysisOutputFileInfo)3 Scanner (java.util.Scanner)3 ExecutionManagerException (ca.corefacility.bioinformatics.irida.exceptions.ExecutionManagerException)2 IridaWorkflowNotFoundException (ca.corefacility.bioinformatics.irida.exceptions.IridaWorkflowNotFoundException)2 AnalysisState (ca.corefacility.bioinformatics.irida.model.enums.AnalysisState)2