Search in sources :

Example 26 with AnalysisOutputFile

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

the class AnalysisExecutionServiceGalaxyIT method testTransferAnalysisResultsSuccessPhylogenomicsPairedMultiLeveledParameters.

/**
 * Tests out getting analysis results successfully for phylogenomics
 * pipeline (paired test version with multiple levels of parameters).
 *
 * @throws Exception
 */
@Test
@WithMockUser(username = "aaron", roles = "ADMIN")
public void testTransferAnalysisResultsSuccessPhylogenomicsPairedMultiLeveledParameters() 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";
    String validParameterValueFromProvenance = "20";
    Map<String, String> parameters = ImmutableMap.of("coverage", validCoverage);
    // I verify parameters were set
    String validTreeFile = "20 20 20 20";
    // correctly by checking output file
    // (where parameters were printed).
    AnalysisSubmission analysisSubmission = analysisExecutionGalaxyITService.setupPairSubmissionInDatabase(1L, pairedPaths1, pairedPaths2, referenceFilePath, parameters, iridaPhylogenomicsPairedMultiLeveledParametersWorkflowId);
    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);
    // 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_multi_level_parameters v0.1.0", "core_pipeline_outputs_paired_with_multi_level_parameters", phyTreeCoreInputs.getToolName());
    assertEquals("The first tool execution should be by core_pipeline_outputs_paired_with_multi_level_parameters v0.1.0", "0.1.0", phyTreeCoreInputs.getToolVersion());
    Map<String, String> phyTreeCoreParameters = phyTreeCoreInputs.getExecutionTimeParameters();
    assertEquals("incorrect number of non-file parameters", 6, phyTreeCoreParameters.size());
    assertEquals("parameter coverageMin set incorrectly", validCoverageFromProvenance, phyTreeCoreParameters.get("coverageMin"));
    assertEquals("parameter coverageMid set incorrectly", validMidCoverageFromProvenance, phyTreeCoreParameters.get("conditional.coverageMid"));
    assertEquals("parameter 'parameter' set incorrectly", validParameterValueFromProvenance, phyTreeCoreParameters.get("conditional.level2.parameter"));
    assertEquals("parameter coverageMax set incorrectly", validCoverageFromProvenance, phyTreeCoreParameters.get("coverageMax"));
    assertEquals("parameter conditional_select set incorrectly", "all", phyTreeCoreParameters.get("conditional.conditional_select"));
    assertEquals("parameter conditional_select set incorrectly", "all2", phyTreeCoreParameters.get("conditional.level2.level2_select"));
}
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 27 with AnalysisOutputFile

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

the class AnalysisExecutionServiceGalaxyIT method testTransferAnalysisResultsSuccessTestAnalysis.

/**
 * Tests out getting analysis results successfully.
 *
 * @throws Exception
 */
@Test
@WithMockUser(username = "aaron", roles = "ADMIN")
public void testTransferAnalysisResultsSuccessTestAnalysis() throws Exception {
    AnalysisSubmission analysisSubmission = analysisExecutionGalaxyITService.setupSubmissionInDatabase(1L, sequenceFilePath, referenceFilePath, iridaTestAnalysisWorkflowId, 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(AnalysisState.COMPLETED, analysisSubmissionCompletedDatabase.getAnalysisState());
    assertEquals(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(Analysis.class, analysisResults.getClass());
    String analysisId = analysisExecuted.getRemoteAnalysisId();
    assertEquals("id should be set properly for analysis", analysisId, analysisResults.getExecutionManagerAnalysisId());
    assertEquals(2, analysisResults.getAnalysisOutputFiles().size());
    AnalysisOutputFile output1 = analysisResultsDatabase.getAnalysisOutputFile("output1");
    AnalysisOutputFile output2 = analysisResultsDatabase.getAnalysisOutputFile("output2");
    assertTrue("output files 1 should be equal", com.google.common.io.Files.equal(expectedOutputFile1.toFile(), output1.getFile().toFile()));
    assertEquals(expectedOutputFile1.getFileName(), output1.getFile().getFileName());
    assertTrue("output files 2 should be equal", com.google.common.io.Files.equal(expectedOutputFile2.toFile(), output2.getFile().toFile()));
    assertEquals(expectedOutputFile2.getFileName(), output2.getFile().getFileName());
    AnalysisSubmission finalSubmission = analysisSubmissionRepository.findOne(analysisExecuted.getId());
    Analysis analysis = finalSubmission.getAnalysis();
    assertNotNull(analysis);
    Analysis savedAnalysisFromDatabase = analysisService.read(analysisResults.getId());
    assertTrue(savedAnalysisFromDatabase instanceof Analysis);
    Analysis savedTest = (Analysis) savedAnalysisFromDatabase;
    assertEquals("Analysis from submission and from database should be the same", savedAnalysisFromDatabase.getId(), analysis.getId());
    assertEquals(analysisResults.getId(), savedTest.getId());
}
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 28 with AnalysisOutputFile

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

the class TestDataFactory method constructAnalysis.

public static Analysis constructAnalysis() {
    Map<String, AnalysisOutputFile> analysisOutputFiles = new ImmutableMap.Builder<String, AnalysisOutputFile>().put("tree", constructAnalysisOutputFile("snp_tree.tree", null)).put("matrix", constructAnalysisOutputFile("test_file_1.fastq", null)).put("table", constructAnalysisOutputFile("test_file_2.fastq", null)).put("contigs-with-repeats", constructAnalysisOutputFile("test_file.fasta", null)).put("refseq-masher-matches", constructAnalysisOutputFile("refseq-masher-matches.tsv", 9000L)).build();
    Analysis analysis = new Analysis(FAKE_EXECUTION_MANAGER_ID, analysisOutputFiles, AnalysisType.PHYLOGENOMICS);
    return analysis;
}
Also used : GenomeAssemblyFromAnalysis(ca.corefacility.bioinformatics.irida.model.assembly.GenomeAssemblyFromAnalysis) Analysis(ca.corefacility.bioinformatics.irida.model.workflow.analysis.Analysis) AnalysisOutputFile(ca.corefacility.bioinformatics.irida.model.workflow.analysis.AnalysisOutputFile)

Example 29 with AnalysisOutputFile

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

the class AnalysisServiceTest method testCreateAnalysisWithOneOutputFile.

@Test
public void testCreateAnalysisWithOneOutputFile() throws IOException {
    Path outputFile = Files.createTempFile(null, null);
    AnalysisOutputFile report = new AnalysisOutputFile(outputFile, "", "", null);
    AnalysisFastQC analysis = AnalysisFastQC.sloppyBuilder().description("something").fastQCReport(report).build();
    analysisService.create(analysis);
    verify(analysisOutputFileRepository).save(report);
    verify(analysisRepository).save(analysis);
}
Also used : Path(java.nio.file.Path) AnalysisOutputFile(ca.corefacility.bioinformatics.irida.model.workflow.analysis.AnalysisOutputFile) AnalysisFastQC(ca.corefacility.bioinformatics.irida.model.workflow.analysis.AnalysisFastQC) Test(org.junit.Test)

Example 30 with AnalysisOutputFile

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

the class AnalysisWorkspaceServiceGalaxy method buildOutputFile.

/**
 * Builds a new AnalysisOutputFile from the given file in Galaxy.
 *
 * @param analysisId
 *            The id of the analysis performed in Galaxy.
 * @param labelPrefix
 *            The prefix to add to the label of this file.
 * @param dataset
 *            The dataset containing the data for the AnalysisOutputFile.
 * @param outputDirectory
 *            A directory to download the resulting output files.
 * @return An AnalysisOutputFile storing a local copy of the Galaxy file.
 * @throws IOException
 *             If there was an issue creating a local file.
 * @throws ExecutionManagerDownloadException
 *             If there was an issue downloading the data from Galaxy.
 * @throws ExecutionManagerException
 *             If there was an issue extracting tool execution provenance
 *             from Galaxy.
 */
private AnalysisOutputFile buildOutputFile(String analysisId, String labelPrefix, Dataset dataset, Path outputDirectory) throws IOException, ExecutionManagerDownloadException, ExecutionManagerException {
    String datasetId = dataset.getId();
    String fileName = dataset.getName();
    Path outputFile = outputDirectory.resolve(fileName);
    galaxyHistoriesService.downloadDatasetTo(analysisId, datasetId, outputFile);
    final ToolExecution toolExecution = analysisProvenanceServiceGalaxy.buildToolExecutionForOutputFile(analysisId, fileName);
    AnalysisOutputFile analysisOutputFile = new AnalysisOutputFile(outputFile, labelPrefix, datasetId, toolExecution);
    return analysisOutputFile;
}
Also used : Path(java.nio.file.Path) ToolExecution(ca.corefacility.bioinformatics.irida.model.workflow.analysis.ToolExecution) AnalysisOutputFile(ca.corefacility.bioinformatics.irida.model.workflow.analysis.AnalysisOutputFile)

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