use of ca.corefacility.bioinformatics.irida.model.workflow.description.IridaWorkflowDescription in project irida by phac-nml.
the class IridaWorkflowLoaderServiceIT method testLoadWorkflowDescriptionRequiresSingleSample.
/**
* Tests loading up the workflow description file that requires a single sample.
*
* @throws IOException
* @throws IridaWorkflowLoadException
*/
@Test
public void testLoadWorkflowDescriptionRequiresSingleSample() throws IOException, IridaWorkflowLoadException {
IridaWorkflowDescription iridaWorkflowDescription = buildTestDescriptionRequiresSingleSample();
IridaWorkflowDescription iridaWorkflowFromFile = workflowLoaderService.loadWorkflowDescription(workflowRequiresSingleSampleXmlPath);
assertEquals("irida workflow description is invalid", iridaWorkflowFromFile, iridaWorkflowDescription);
}
use of ca.corefacility.bioinformatics.irida.model.workflow.description.IridaWorkflowDescription in project irida by phac-nml.
the class IridaWorkflowLoaderServiceIT method testLoadWorkflowDescriptionRequiresSingleSampleInvalid.
/**
* Tests loading up the workflow description file with an invalid string for requires single sample and setting to default.
*
* @throws IOException
* @throws IridaWorkflowLoadException
*/
@Test
public void testLoadWorkflowDescriptionRequiresSingleSampleInvalid() throws IOException, IridaWorkflowLoadException {
IridaWorkflowDescription iridaWorkflowDescription = buildTestDescriptionRequiresSingleSampleInvalid();
IridaWorkflowDescription iridaWorkflowFromFile = workflowLoaderService.loadWorkflowDescription(workflowInvalidRequiresSingleSampleXmlPath);
assertEquals("irida workflow description is invalid", iridaWorkflowFromFile, iridaWorkflowDescription);
}
use of ca.corefacility.bioinformatics.irida.model.workflow.description.IridaWorkflowDescription in project irida by phac-nml.
the class IridaWorkflowLoaderServiceTest method testLoadWorkflowDescriptionFail.
/**
* Tests failing to loading a workflow description.
*
* @throws IOException
* @throws XmlMappingException
* @throws IridaWorkflowLoadException
*/
@Test(expected = IridaWorkflowLoadException.class)
public void testLoadWorkflowDescriptionFail() throws XmlMappingException, IOException, IridaWorkflowLoadException {
IridaWorkflowDescription description = IridaWorkflowTestBuilder.buildTestDescription(iridaWorkflowId, "name", "version", null, IridaWorkflowTestBuilder.Input.SINGLE, "reference", true);
when(workflowDescriptionUnmarshellar.unmarshal(any(Source.class))).thenReturn(description);
iridaWorkflowLoaderService.loadWorkflowDescription(workflowDescriptionPath);
}
use of ca.corefacility.bioinformatics.irida.model.workflow.description.IridaWorkflowDescription in project irida by phac-nml.
the class IridaWorkflowLoaderService method loadIridaWorkflow.
/**
* Loads up an {@link IridaWorkflow} from the given information files.
*
* @param descriptionFile
* The description file for the workflow.
* @param structureFile
* The file describing the structure of a workflow.
* @return An IridaWorkflow object for this workflow.
* @throws IOException
* If there was an issue reading the passed file.
* @throws IridaWorkflowLoadException
* If there was an issue loading up the workflow.
*/
public IridaWorkflow loadIridaWorkflow(Path descriptionFile, Path structureFile) throws IOException, IridaWorkflowLoadException {
checkNotNull(descriptionFile, "descriptionFile is null");
checkNotNull(structureFile, "structureFile is null");
IridaWorkflowDescription worklowDescription = loadWorkflowDescription(descriptionFile);
IridaWorkflowStructure workflowStructure = loadWorkflowStructure(structureFile);
return new IridaWorkflow(worklowDescription, workflowStructure);
}
use of ca.corefacility.bioinformatics.irida.model.workflow.description.IridaWorkflowDescription in project irida by phac-nml.
the class PipelineController method ajaxStartPipeline.
// ************************************************************************************************
// AJAX
// ************************************************************************************************
/**
* Launch a pipeline
*
* @param locale the locale that the browser is using for the current request.
* @param parameters DTO of pipeline start parameters
* @return a JSON response with the status and any messages.
*/
@RequestMapping(value = "/ajax/start", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> ajaxStartPipeline(Locale locale, @RequestBody final PipelineStartParameters parameters) {
try {
IridaWorkflow flow = workflowsService.getIridaWorkflow(parameters.getWorkflowId());
IridaWorkflowDescription description = flow.getWorkflowDescription();
// The pipeline needs to have a name.
String name = parameters.getName();
if (Strings.isNullOrEmpty(name)) {
return ImmutableMap.of("error", messageSource.getMessage("workflow.no-name-provided", null, locale));
}
// Check to see if a reference file is required.
Long ref = parameters.getRef();
if (description.requiresReference() && ref == null) {
return ImmutableMap.of("error", messageSource.getMessage("pipeline.error.no-reference.pipeline-start", null, locale));
}
// Get a list of the files to submit
List<SingleEndSequenceFile> singleEndFiles = new ArrayList<>();
List<SequenceFilePair> sequenceFilePairs = new ArrayList<>();
List<Long> single = parameters.getSingle();
if (single != null) {
Iterable<SequencingObject> readMultiple = sequencingObjectService.readMultiple(single);
readMultiple.forEach(f -> {
if (!(f instanceof SingleEndSequenceFile)) {
throw new IllegalArgumentException("file " + f.getId() + " not a SingleEndSequenceFile");
}
singleEndFiles.add((SingleEndSequenceFile) f);
});
// Check the single files for duplicates in a sample, throws SampleAnalysisDuplicateException
sequencingObjectService.getUniqueSamplesForSequencingObjects(Sets.newHashSet(singleEndFiles));
}
List<Long> paired = parameters.getPaired();
if (paired != null) {
Iterable<SequencingObject> readMultiple = sequencingObjectService.readMultiple(paired);
readMultiple.forEach(f -> {
if (!(f instanceof SequenceFilePair)) {
throw new IllegalArgumentException("file " + f.getId() + " not a SequenceFilePair");
}
sequenceFilePairs.add((SequenceFilePair) f);
});
// Check the pair files for duplicates in a sample, throws SampleAnalysisDuplicateException
sequencingObjectService.getUniqueSamplesForSequencingObjects(Sets.newHashSet(sequenceFilePairs));
}
// Get the pipeline parameters
Map<String, String> params = new HashMap<>();
IridaWorkflowNamedParameters namedParameters = null;
Map<String, Object> selectedParameters = parameters.getSelectedParameters();
if (selectedParameters != null) {
try {
final String selectedParametersId = selectedParameters.get("id").toString();
if (!DEFAULT_WORKFLOW_PARAMETERS_ID.equals(selectedParametersId) && !CUSTOM_UNSAVED_WORKFLOW_PARAMETERS_ID.equals(selectedParametersId)) {
// this means that a named parameter set was selected
// and unmodified, so load up that named parameter set
// to pass along.
namedParameters = namedParameterService.read(Long.valueOf(selectedParametersId));
} else {
@SuppressWarnings("unchecked") final List<Map<String, String>> unnamedParameters = (List<Map<String, String>>) selectedParameters.get("parameters");
for (final Map<String, String> parameter : unnamedParameters) {
params.put(parameter.get("name"), parameter.get("value"));
}
}
} catch (Exception e) {
return ImmutableMap.of("parameterError", messageSource.getMessage("pipeline.parameters.error", null, locale));
}
}
List<Project> projectsToShare = new ArrayList<>();
List<Long> sharedProjects = parameters.getSharedProjects();
if (sharedProjects != null && !sharedProjects.isEmpty()) {
projectsToShare = Lists.newArrayList(projectService.readMultiple(sharedProjects));
}
String analysisDescription = parameters.getDescription();
Boolean writeResultsToSamples = parameters.getWriteResultsToSamples();
if (description.getInputs().requiresSingleSample()) {
analysisSubmissionService.createSingleSampleSubmission(flow, ref, singleEndFiles, sequenceFilePairs, params, namedParameters, name, analysisDescription, projectsToShare, writeResultsToSamples);
} else {
analysisSubmissionService.createMultipleSampleSubmission(flow, ref, singleEndFiles, sequenceFilePairs, params, namedParameters, name, analysisDescription, projectsToShare, writeResultsToSamples);
}
} catch (IridaWorkflowNotFoundException e) {
logger.error("Cannot find IridaWorkflow [" + parameters.getWorkflowId() + "]", e);
return ImmutableMap.of("pipelineError", messageSource.getMessage("pipeline.error.invalid-pipeline", null, locale));
} catch (DuplicateSampleException e) {
logger.error("Multiple files for Sample found", e);
return ImmutableMap.of("pipelineError", messageSource.getMessage("pipeline.error.duplicate-samples", null, locale));
}
return ImmutableMap.of("success", true);
}
Aggregations