use of ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.WorkflowInputsGalaxy in project irida by phac-nml.
the class AnalysisParameterServiceGalaxyTest method testPrepareParametersIgnoreDefaultSuccess.
/**
* Tests preparing workflow parameters and ignoring the default value successfully.
*
* @throws IridaWorkflowParameterException
*/
@Test
public void testPrepareParametersIgnoreDefaultSuccess() throws IridaWorkflowParameterException {
Map<String, String> parameters = Maps.newHashMap();
parameters.put("parameter1", IridaWorkflowParameter.IGNORE_DEFAULT_VALUE);
WorkflowInputsGalaxy workflowInputsGalaxy = analysisParameterService.prepareAnalysisParameters(parameters, iridaWorkflow);
assertNotNull("workflowInputsGalaxy is null", workflowInputsGalaxy);
WorkflowInputs workflowInputs = workflowInputsGalaxy.getInputsObject();
Map<Object, Map<String, Object>> workflowParameters = workflowInputs.getParameters();
assertNull("should be no parameter set for galaxy-tool1", workflowParameters.get("galaxy-tool1"));
}
use of ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.WorkflowInputsGalaxy in project irida by phac-nml.
the class AnalysisWorkspaceServiceGalaxyTest method testPrepareAnalysisFilesSinglePairedSuccess.
/**
* Tests out successfully to preparing an analysis with both single and
* paired files
*
* @throws ExecutionManagerException
* @throws IridaWorkflowException
*/
@SuppressWarnings("unchecked")
@Test
public void testPrepareAnalysisFilesSinglePairedSuccess() throws ExecutionManagerException, IridaWorkflowException {
Set<SingleEndSequenceFile> singleFiles = Sets.newHashSet(sampleSingleSequenceFileMap.values());
Set<SequenceFilePair> pairedFiles = Sets.newHashSet(sampleSequenceFilePairMap.values());
Set<SequencingObject> joinedInput = Sets.newHashSet(singleFiles);
joinedInput.addAll(pairedFiles);
submission = AnalysisSubmission.builder(workflowId).name("my analysis").inputFiles(joinedInput).referenceFile(referenceFile).build();
submission.setRemoteAnalysisId(HISTORY_ID);
submission.setRemoteWorkflowId(WORKFLOW_ID);
when(sequencingObjectService.getSequencingObjectsOfTypeForAnalysisSubmission(submission, SingleEndSequenceFile.class)).thenReturn(singleFiles);
when(sequencingObjectService.getSequencingObjectsOfTypeForAnalysisSubmission(submission, SequenceFilePair.class)).thenReturn(pairedFiles);
when(iridaWorkflowsService.getIridaWorkflow(workflowId)).thenReturn(iridaWorkflowSinglePaired);
when(galaxyHistoriesService.findById(HISTORY_ID)).thenReturn(workflowHistory);
when(galaxyLibrariesService.buildEmptyLibrary(any(GalaxyProjectName.class))).thenReturn(workflowLibrary);
when(sequencingObjectService.getUniqueSamplesForSequencingObjects(singleFiles)).thenReturn(sampleSingleSequenceFileMap);
when(sequencingObjectService.getUniqueSamplesForSequencingObjects(pairedFiles)).thenReturn(sampleSequenceFilePairMap);
when(galaxyHistoriesService.fileToHistory(refFile, InputFileType.FASTA, workflowHistory)).thenReturn(refDataset);
when(galaxyWorkflowService.getWorkflowDetails(WORKFLOW_ID)).thenReturn(workflowDetails);
when(analysisParameterServiceGalaxy.prepareAnalysisParameters(any(Map.class), any(IridaWorkflow.class))).thenReturn(new WorkflowInputsGalaxy(new WorkflowInputs()));
when(galaxyWorkflowService.getWorkflowInputId(workflowDetails, SEQUENCE_FILE_SINGLE_LABEL)).thenReturn(SEQUENCE_FILE_SINGLE_ID);
when(galaxyWorkflowService.getWorkflowInputId(workflowDetails, SEQUENCE_FILE_PAIRED_LABEL)).thenReturn(SEQUENCE_FILE_PAIRED_ID);
when(galaxyWorkflowService.getWorkflowInputId(workflowDetails, REFERENCE_FILE_LABEL)).thenReturn(REFERENCE_FILE_ID);
when(analysisCollectionServiceGalaxy.uploadSequenceFilesSingleEnd(any(Map.class), eq(workflowHistory), eq(workflowLibrary))).thenReturn(collectionResponseSingle);
when(analysisCollectionServiceGalaxy.uploadSequenceFilesPaired(any(Map.class), eq(workflowHistory), eq(workflowLibrary))).thenReturn(collectionResponsePaired);
PreparedWorkflowGalaxy preparedWorkflow = workflowPreparation.prepareAnalysisFiles(submission);
assertEquals("preparedWorflow history id not equal to " + HISTORY_ID, HISTORY_ID, preparedWorkflow.getRemoteAnalysisId());
assertEquals("preparedWorkflow library is invalid", LIBRARY_ID, preparedWorkflow.getRemoteDataId());
assertNotNull("workflowInputs in preparedWorkflow is null", preparedWorkflow.getWorkflowInputs());
Map<String, WorkflowInput> workflowInputsMap = preparedWorkflow.getWorkflowInputs().getInputsObject().getInputs();
assertEquals("invalid number of workflow inputs", 3, workflowInputsMap.size());
assertTrue("workflow inputs should contain reference entry", workflowInputsMap.containsKey(REFERENCE_FILE_ID));
assertTrue("workflow inputs should contain sequence file single entry", workflowInputsMap.containsKey(SEQUENCE_FILE_SINGLE_ID));
assertTrue("workflow inputs should contain sequence file paired entry", workflowInputsMap.containsKey(SEQUENCE_FILE_PAIRED_ID));
verify(analysisCollectionServiceGalaxy).uploadSequenceFilesSingleEnd(any(Map.class), any(History.class), any(Library.class));
verify(analysisCollectionServiceGalaxy).uploadSequenceFilesPaired(any(Map.class), any(History.class), any(Library.class));
}
use of ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.WorkflowInputsGalaxy in project irida by phac-nml.
the class AnalysisWorkspaceServiceGalaxyTest method testPrepareAnalysisFilesPairedSuccess.
/**
* Tests out successfully to preparing an analysis with paired files
*
* @throws ExecutionManagerException
* @throws IridaWorkflowException
*/
@SuppressWarnings("unchecked")
@Test
public void testPrepareAnalysisFilesPairedSuccess() throws ExecutionManagerException, IridaWorkflowException {
Set<SequenceFilePair> pairedFiles = Sets.newHashSet(sampleSequenceFilePairMap.values());
submission = AnalysisSubmission.builder(workflowId).name("my analysis").inputFiles(Sets.newHashSet(pairedFiles)).referenceFile(referenceFile).build();
submission.setRemoteAnalysisId(HISTORY_ID);
submission.setRemoteWorkflowId(WORKFLOW_ID);
when(sequencingObjectService.getSequencingObjectsOfTypeForAnalysisSubmission(submission, SequenceFilePair.class)).thenReturn(pairedFiles);
when(iridaWorkflowsService.getIridaWorkflow(workflowId)).thenReturn(iridaWorkflowPaired);
when(galaxyHistoriesService.findById(HISTORY_ID)).thenReturn(workflowHistory);
when(galaxyLibrariesService.buildEmptyLibrary(any(GalaxyProjectName.class))).thenReturn(workflowLibrary);
when(sequencingObjectService.getUniqueSamplesForSequencingObjects(pairedFiles)).thenReturn(sampleSequenceFilePairMap);
when(galaxyHistoriesService.fileToHistory(refFile, InputFileType.FASTA, workflowHistory)).thenReturn(refDataset);
when(galaxyWorkflowService.getWorkflowDetails(WORKFLOW_ID)).thenReturn(workflowDetails);
when(analysisParameterServiceGalaxy.prepareAnalysisParameters(any(Map.class), any(IridaWorkflow.class))).thenReturn(new WorkflowInputsGalaxy(new WorkflowInputs()));
when(galaxyWorkflowService.getWorkflowInputId(workflowDetails, SEQUENCE_FILE_PAIRED_LABEL)).thenReturn(SEQUENCE_FILE_PAIRED_ID);
when(galaxyWorkflowService.getWorkflowInputId(workflowDetails, REFERENCE_FILE_LABEL)).thenReturn(REFERENCE_FILE_ID);
when(analysisCollectionServiceGalaxy.uploadSequenceFilesPaired(any(Map.class), eq(workflowHistory), eq(workflowLibrary))).thenReturn(collectionResponsePaired);
PreparedWorkflowGalaxy preparedWorkflow = workflowPreparation.prepareAnalysisFiles(submission);
assertEquals("preparedWorflow history id not equal to " + HISTORY_ID, HISTORY_ID, preparedWorkflow.getRemoteAnalysisId());
assertEquals("preparedWorkflow library is invalid", LIBRARY_ID, preparedWorkflow.getRemoteDataId());
assertNotNull("workflowInputs in preparedWorkflow is null", preparedWorkflow.getWorkflowInputs());
Map<String, WorkflowInput> workflowInputsMap = preparedWorkflow.getWorkflowInputs().getInputsObject().getInputs();
assertEquals("workflow inputs has invalid size", 2, workflowInputsMap.size());
assertTrue("workflow inputs should contain reference file entry", workflowInputsMap.containsKey(REFERENCE_FILE_ID));
assertTrue("workflow inputs should contain sequence file paired entry", workflowInputsMap.containsKey(SEQUENCE_FILE_PAIRED_ID));
verify(analysisCollectionServiceGalaxy, never()).uploadSequenceFilesSingleEnd(any(Map.class), any(History.class), any(Library.class));
verify(analysisCollectionServiceGalaxy).uploadSequenceFilesPaired(any(Map.class), any(History.class), any(Library.class));
}
use of ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.WorkflowInputsGalaxy in project irida by phac-nml.
the class AnalysisWorkspaceServiceGalaxy method prepareAnalysisFiles.
/**
* {@inheritDoc}
*/
@Override
public PreparedWorkflowGalaxy prepareAnalysisFiles(AnalysisSubmission analysisSubmission) throws ExecutionManagerException, IridaWorkflowException {
checkNotNull(analysisSubmission, "analysisSubmission is null");
checkNotNull(analysisSubmission.getRemoteAnalysisId(), "analysisId is null");
checkNotNull(analysisSubmission.getWorkflowId(), "workflowId is null");
checkNotNull(analysisSubmission.getRemoteWorkflowId(), "remoteWorkflowId is null");
IridaWorkflow iridaWorkflow = iridaWorkflowsService.getIridaWorkflow(analysisSubmission.getWorkflowId());
IridaWorkflowInput workflowInput = iridaWorkflow.getWorkflowDescription().getInputs();
Set<SingleEndSequenceFile> singleEndFiles = sequencingObjectService.getSequencingObjectsOfTypeForAnalysisSubmission(analysisSubmission, SingleEndSequenceFile.class);
Set<SequenceFilePair> pairedEndFiles = sequencingObjectService.getSequencingObjectsOfTypeForAnalysisSubmission(analysisSubmission, SequenceFilePair.class);
if (iridaWorkflow.getWorkflowDescription().requiresReference()) {
checkArgument(analysisSubmission.getReferenceFile().isPresent(), "workflow requires reference but none defined in submission");
} else {
checkArgument(!analysisSubmission.getReferenceFile().isPresent(), "workflow does not require a reference and a reference file is set in the submission");
}
if (!iridaWorkflow.getWorkflowDescription().acceptsSingleSequenceFiles()) {
checkArgument(singleEndFiles.isEmpty(), "workflow does not accept single sequence files, but single sequence files are passed as input to " + analysisSubmission);
}
if (!iridaWorkflow.getWorkflowDescription().acceptsPairedSequenceFiles()) {
checkArgument(pairedEndFiles.isEmpty(), "workflow does not accept paired sequence files, but paired sequence files are passed as input to " + analysisSubmission);
}
String temporaryLibraryName = AnalysisSubmission.class.getSimpleName() + "-" + UUID.randomUUID().toString();
History workflowHistory = galaxyHistoriesService.findById(analysisSubmission.getRemoteAnalysisId());
Library workflowLibrary = galaxyLibrariesService.buildEmptyLibrary(new GalaxyProjectName(temporaryLibraryName));
// get unique files for pairs and single files
Map<Sample, SingleEndSequenceFile> singleFiles = sequencingObjectService.getUniqueSamplesForSequencingObjects(singleEndFiles);
Map<Sample, SequenceFilePair> pairedFiles = sequencingObjectService.getUniqueSamplesForSequencingObjects(pairedEndFiles);
// check that there aren't common sample names between single and paired
if (samplesInCommon(singleFiles, pairedFiles)) {
throw new SampleAnalysisDuplicateException("Single and paired input files share a common sample for submission " + analysisSubmission);
}
String workflowId = analysisSubmission.getRemoteWorkflowId();
WorkflowDetails workflowDetails = galaxyWorkflowService.getWorkflowDetails(workflowId);
WorkflowInputsGalaxy workflowInputsGalaxy = analysisParameterServiceGalaxy.prepareAnalysisParameters(analysisSubmission.getInputParameters(), iridaWorkflow);
WorkflowInputs inputs = workflowInputsGalaxy.getInputsObject();
inputs.setDestination(new WorkflowInputs.ExistingHistory(workflowHistory.getId()));
inputs.setWorkflowId(workflowDetails.getId());
if (!singleFiles.isEmpty()) {
String sequenceFilesLabelSingle = workflowInput.getSequenceReadsSingle().get();
String workflowSequenceFileSingleInputId = galaxyWorkflowService.getWorkflowInputId(workflowDetails, sequenceFilesLabelSingle);
CollectionResponse collectionResponseSingle = analysisCollectionServiceGalaxy.uploadSequenceFilesSingleEnd(singleFiles, workflowHistory, workflowLibrary);
inputs.setInput(workflowSequenceFileSingleInputId, new WorkflowInputs.WorkflowInput(collectionResponseSingle.getId(), WorkflowInputs.InputSourceType.HDCA));
}
if (!pairedFiles.isEmpty()) {
String sequenceFilesLabelPaired = workflowInput.getSequenceReadsPaired().get();
String workflowSequenceFilePairedInputId = galaxyWorkflowService.getWorkflowInputId(workflowDetails, sequenceFilesLabelPaired);
CollectionResponse collectionResponsePaired = analysisCollectionServiceGalaxy.uploadSequenceFilesPaired(pairedFiles, workflowHistory, workflowLibrary);
inputs.setInput(workflowSequenceFilePairedInputId, new WorkflowInputs.WorkflowInput(collectionResponsePaired.getId(), WorkflowInputs.InputSourceType.HDCA));
}
String analysisId = workflowHistory.getId();
if (iridaWorkflow.getWorkflowDescription().requiresReference()) {
String referenceFileLabel = workflowInput.getReference().get();
prepareReferenceFile(analysisSubmission.getReferenceFile().get(), workflowHistory, referenceFileLabel, workflowDetails, inputs);
}
return new PreparedWorkflowGalaxy(analysisId, workflowLibrary.getId(), new WorkflowInputsGalaxy(inputs));
}
Aggregations