Search in sources :

Example 41 with IridaWorkflow

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

the class IridaWorkflowLoaderServiceIT method testLoadWorkflowFromDirectory.

/**
 * Tests successfully loading up one version of a workflow from a directory.
 */
@Test
public void testLoadWorkflowFromDirectory() throws IOException, IridaWorkflowLoadException {
    IridaWorkflow iridaWorkflowFromFile = workflowLoaderService.loadIridaWorkflowFromDirectory(workflowVersionDirectoryPath);
    assertEquals("irida workflow is invalid", buildTestWorkflowSingle(), iridaWorkflowFromFile);
}
Also used : IridaWorkflow(ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow) Test(org.junit.Test)

Example 42 with IridaWorkflow

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

the class IridaWorkflowLoaderServiceIT method testLoadAllWorkflowImplementationsSuccess.

/**
 * Tests successfully loading up all implementations of a workflow from a
 * directory.
 */
@Test
public void testLoadAllWorkflowImplementationsSuccess() throws IOException, IridaWorkflowLoadException {
    Set<IridaWorkflow> iridaWorkflowsFromFile = workflowLoaderService.loadAllWorkflowImplementations(workflowDirectoryPath);
    Set<String> workflowNamesSet = new HashSet<>();
    Set<String> workflowVersionsSet = new HashSet<>();
    assertEquals(11, iridaWorkflowsFromFile.size());
    for (IridaWorkflow workflow : iridaWorkflowsFromFile) {
        workflowNamesSet.add(workflow.getWorkflowDescription().getName());
        workflowVersionsSet.add(workflow.getWorkflowDescription().getVersion());
    }
    assertEquals("irida workflow names are invalid", Sets.newHashSet("TestWorkflow"), workflowNamesSet);
    Set<String> validVersionNumbers = Sets.newHashSet("1.0", "2.0", "1.0-invalid", "2.0-missing-output", "1.0-paired", "1.0-single-paired", "1.0-requires-single-sample", "1.0-requires-single-sample-unset", "1.0-not-requires-single-sample", "1.0-invalid-requires-single-sample", "1.0-paired-end-single-sample");
    assertEquals("irida workflow versions are invalid", validVersionNumbers, workflowVersionsSet);
}
Also used : IridaWorkflow(ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 43 with IridaWorkflow

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

the class IridaWorkflowsServiceIT method testRegisterWorkflowNullTypeFail.

/**
 * Tests to make sure we fail to register a workflow with a null type.
 *
 * @throws IridaWorkflowException
 */
@Test(expected = NullPointerException.class)
public void testRegisterWorkflowNullTypeFail() throws IridaWorkflowException {
    IridaWorkflow workflowNullAnalysisType = IridaWorkflowTestBuilder.buildTestWorkflowNullAnalysisType();
    iridaWorkflowsService.registerWorkflow(workflowNullAnalysisType);
}
Also used : IridaWorkflow(ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow) Test(org.junit.Test)

Example 44 with IridaWorkflow

use of ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow 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));
}
Also used : IridaWorkflow(ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow) IridaWorkflowInput(ca.corefacility.bioinformatics.irida.model.workflow.description.IridaWorkflowInput) Sample(ca.corefacility.bioinformatics.irida.model.sample.Sample) CollectionResponse(com.github.jmchilton.blend4j.galaxy.beans.collection.response.CollectionResponse) WorkflowInputs(com.github.jmchilton.blend4j.galaxy.beans.WorkflowInputs) GalaxyProjectName(ca.corefacility.bioinformatics.irida.model.upload.galaxy.GalaxyProjectName) History(com.github.jmchilton.blend4j.galaxy.beans.History) WorkflowInputsGalaxy(ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.WorkflowInputsGalaxy) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) SequenceFilePair(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair) SampleAnalysisDuplicateException(ca.corefacility.bioinformatics.irida.exceptions.SampleAnalysisDuplicateException) WorkflowDetails(com.github.jmchilton.blend4j.galaxy.beans.WorkflowDetails) PreparedWorkflowGalaxy(ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.PreparedWorkflowGalaxy) Library(com.github.jmchilton.blend4j.galaxy.beans.Library)

Example 45 with IridaWorkflow

use of ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow 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);
}
Also used : IridaWorkflow(ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow) IridaWorkflowDescription(ca.corefacility.bioinformatics.irida.model.workflow.description.IridaWorkflowDescription) IridaWorkflowStructure(ca.corefacility.bioinformatics.irida.model.workflow.structure.IridaWorkflowStructure)

Aggregations

IridaWorkflow (ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow)50 AnalysisSubmission (ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission)27 Test (org.junit.Test)27 Path (java.nio.file.Path)25 History (com.github.jmchilton.blend4j.galaxy.beans.History)19 HistoriesClient (com.github.jmchilton.blend4j.galaxy.HistoriesClient)18 WorkflowsClient (com.github.jmchilton.blend4j.galaxy.WorkflowsClient)18 Workflow (com.github.jmchilton.blend4j.galaxy.beans.Workflow)18 WithMockUser (org.springframework.security.test.context.support.WithMockUser)18 AnalysisType (ca.corefacility.bioinformatics.irida.model.enums.AnalysisType)10 SequenceFilePair (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair)10 Analysis (ca.corefacility.bioinformatics.irida.model.workflow.analysis.Analysis)9 ArrayList (java.util.ArrayList)9 SingleEndSequenceFile (ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile)8 IridaWorkflowDescription (ca.corefacility.bioinformatics.irida.model.workflow.description.IridaWorkflowDescription)8 ToolsClient (com.github.jmchilton.blend4j.galaxy.ToolsClient)8 IridaWorkflowNotFoundException (ca.corefacility.bioinformatics.irida.exceptions.IridaWorkflowNotFoundException)7 PreparedWorkflowGalaxy (ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.PreparedWorkflowGalaxy)7 WorkflowInputsGalaxy (ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.WorkflowInputsGalaxy)6 HistoryContents (com.github.jmchilton.blend4j.galaxy.beans.HistoryContents)6