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"));
}
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());
}
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;
}
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);
}
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;
}
Aggregations