use of com.github.jmchilton.blend4j.galaxy.beans.Dataset in project irida by phac-nml.
the class GalaxyWorkflowsIT method testExecuteWorkflowChangeToolParameter.
/**
* Tests executing a single workflow in Galaxy and changing a single tool
* parameter.
*
* @throws ExecutionManagerException
*/
@Test
public void testExecuteWorkflowChangeToolParameter() throws ExecutionManagerException {
String toolId = "Grep1";
String workflowId = localGalaxy.getSingleInputWorkflowId();
String workflowInputLabel = localGalaxy.getSingleInputWorkflowLabel();
Map<String, ToolParameter> toolParameters = ImmutableMap.of(toolId, new ToolParameter("pattern", "^#"));
WorkflowOutputs workflowOutput = runSingleFileWorkflow(dataFile1, FILE_TYPE, workflowId, workflowInputLabel, toolParameters);
assertNotNull("workflowOutput should not be null", workflowOutput);
assertNotNull("workflowOutput history id should not be null", workflowOutput.getHistoryId());
// history should exist
HistoryDetails historyDetails = historiesClient.showHistory(workflowOutput.getHistoryId());
assertNotNull("historyDetails for the history for the workflow should not be null", historyDetails);
// outputs should exist
assertNotNull("outputIds for the workflow should not be null", workflowOutput.getOutputIds());
assertTrue("there should exist output dataset ids for the workflow", workflowOutput.getOutputIds().size() > 0);
// each output dataset should exist
for (String outputId : workflowOutput.getOutputIds()) {
Dataset dataset = historiesClient.showDataset(workflowOutput.getHistoryId(), outputId);
assertNotNull("the output dataset should exist", dataset);
HistoryContentsProvenance provenance = historiesClient.showProvenance(workflowOutput.getHistoryId(), dataset.getId());
if (toolId.equals(provenance.getToolId())) {
Map<String, Object> parametersMap = provenance.getParameters();
assertEquals("pattern parameter is correct", "\"^#\"", parametersMap.get("pattern"));
}
}
// test get workflow status
GalaxyWorkflowStatus workflowStatus = galaxyHistory.getStatusForHistory(workflowOutput.getHistoryId());
float proportionComplete = workflowStatus.getProportionComplete();
assertTrue("the workflow proportion complete should be between 0 and 1", 0.0f <= proportionComplete && proportionComplete <= 1.0f);
}
use of com.github.jmchilton.blend4j.galaxy.beans.Dataset in project irida by phac-nml.
the class GalaxyWorkflowsIT method runSingleCollectionWorkflow.
/**
* Starts the execution of a workflow with a list of fastq files and the given workflow id.
* @param inputFilesForward A list of forward read fastq files start the workflow.
* @param inputFilesReverse A list of reverse read fastq files start the workflow.
* @param inputFileType The file type of the input files.
* @param workflowId The id of the workflow to start.
* @param workflowInputLabel The label of a workflow input in Galaxy.
* @throws ExecutionManagerException If there was an error executing the workflow.
*/
private WorkflowOutputs runSingleCollectionWorkflow(List<Path> inputFilesForward, List<Path> inputFilesReverse, InputFileType inputFileType, String workflowId, String workflowInputLabel) throws ExecutionManagerException {
checkNotNull(inputFilesForward, "inputFilesForward is null");
checkNotNull(inputFilesReverse, "inputFilesReverse is null");
checkArgument(inputFilesForward.size() == inputFilesReverse.size(), "inputFiles have different number of elements");
checkNotNull(inputFileType, "inputFileType is null");
checkNotNull(workflowInputLabel, "workflowInputLabel is null");
for (Path file : inputFilesForward) {
checkArgument(Files.exists(file), "inputFileForward " + file + " does not exist");
}
for (Path file : inputFilesReverse) {
checkArgument(Files.exists(file), "inputFilesReverse " + file + " does not exist");
}
History workflowHistory = galaxyHistory.newHistoryForWorkflow();
WorkflowDetails workflowDetails = workflowsClient.showWorkflow(workflowId);
// upload dataset to history
List<Dataset> inputDatasetsForward = uploadFilesListToHistory(inputFilesForward, inputFileType, workflowHistory);
List<Dataset> inputDatasetsReverse = uploadFilesListToHistory(inputFilesReverse, inputFileType, workflowHistory);
assertEquals(inputFilesForward.size(), inputDatasetsForward.size());
assertEquals(inputDatasetsForward.size(), inputDatasetsReverse.size());
// construct list of datasets
CollectionResponse collection = constructPairedFileCollection(inputDatasetsForward, inputDatasetsReverse, workflowHistory);
logger.debug("Constructed dataset collection: id=" + collection.getId() + ", " + collection.getName());
String workflowInputId = galaxyWorkflowService.getWorkflowInputId(workflowDetails, workflowInputLabel);
WorkflowInputs inputs = new WorkflowInputs();
inputs.setDestination(new WorkflowInputs.ExistingHistory(workflowHistory.getId()));
inputs.setWorkflowId(workflowDetails.getId());
inputs.setInput(workflowInputId, new WorkflowInputs.WorkflowInput(collection.getId(), WorkflowInputs.InputSourceType.HDCA));
// execute workflow
WorkflowOutputs output = workflowsClient.runWorkflow(inputs);
logger.debug("Running workflow in history " + output.getHistoryId());
return output;
}
use of com.github.jmchilton.blend4j.galaxy.beans.Dataset in project irida by phac-nml.
the class GalaxyHistoriesServiceTest method setup.
/**
* Sets up objects for history tests.
* @throws URISyntaxException
*/
@Before
public void setup() throws URISyntaxException {
MockitoAnnotations.initMocks(this);
when(okayResponse.getClientResponseStatus()).thenReturn(ClientResponse.Status.OK);
when(invalidResponse.getClientResponseStatus()).thenReturn(ClientResponse.Status.FORBIDDEN);
galaxyHistory = new GalaxyHistoriesService(historiesClient, toolsClient, galaxyLibrariesService);
dataFile = Paths.get(this.getClass().getResource("testData1.fastq").toURI());
history = new History();
history.setId(HISTORY_ID);
datasetHistoryContents = buildHistoryContentsList(FILENAME, DATA_ID);
datasetForFile = new Dataset();
datasetForFile.setName(FILENAME);
datasetForFile.setId(DATA_ID);
datasetForFile.setUrl("datasets/" + DATA_ID + "/display");
datasetForFile.setGalaxyUrl("http://fakehost");
datasetForFile.setApiKey("1");
}
use of com.github.jmchilton.blend4j.galaxy.beans.Dataset in project irida by phac-nml.
the class AnalysisWorkspaceServiceGalaxy method getAnalysisResults.
/**
* {@inheritDoc}
*/
@Override
public Analysis getAnalysisResults(AnalysisSubmission analysisSubmission) throws ExecutionManagerException, IridaWorkflowNotFoundException, IOException, IridaWorkflowAnalysisTypeException {
checkNotNull(analysisSubmission, "analysisSubmission is null");
checkNotNull(analysisSubmission.getWorkflowId(), "workflowId is null");
checkNotNull(analysisSubmission.getRemoteWorkflowId(), "remoteWorkflowId is null");
Path outputDirectory = Files.createTempDirectory("analysis-output");
logger.trace("Created temporary directory " + outputDirectory + " for analysis output files");
IridaWorkflow iridaWorkflow = iridaWorkflowsService.getIridaWorkflow(analysisSubmission.getWorkflowId());
String analysisId = analysisSubmission.getRemoteAnalysisId();
Map<String, IridaWorkflowOutput> outputsMap = iridaWorkflow.getWorkflowDescription().getOutputsMap();
String labelPrefix = getLabelPrefix(analysisSubmission, iridaWorkflow);
Map<String, AnalysisOutputFile> analysisOutputFiles = Maps.newHashMap();
for (String analysisOutputName : outputsMap.keySet()) {
String outputFileName = outputsMap.get(analysisOutputName).getFileName();
Dataset outputDataset = galaxyHistoriesService.getDatasetForFileInHistory(outputFileName, analysisId);
AnalysisOutputFile analysisOutput = buildOutputFile(analysisId, labelPrefix, outputDataset, outputDirectory);
analysisOutputFiles.put(analysisOutputName, analysisOutput);
}
AnalysisType analysisType = iridaWorkflow.getWorkflowDescription().getAnalysisType();
return new Analysis(analysisId, analysisOutputFiles, analysisType);
}
use of com.github.jmchilton.blend4j.galaxy.beans.Dataset in project irida by phac-nml.
the class GalaxyHistoriesService method getDatasetForFileInHistory.
/**
* Gets a Dataset object for a file with the given name in the given history.
* @param filename The name of the file to get a Dataset object for.
* @param historyId The history id to look for the dataset.
* @return The corresponding dataset for the given file name.
* @throws GalaxyDatasetException If there was an issue when searching for a dataset.
*/
public Dataset getDatasetForFileInHistory(String filename, String historyId) throws GalaxyDatasetException {
checkNotNull(filename, "filename is null");
checkNotNull(historyId, "historyId is null");
List<HistoryContents> historyContentsList = historiesClient.showHistoryContents(historyId);
List<HistoryContents> matchingHistoryContents = historyContentsList.stream().filter((historyContents) -> filename.equals(historyContents.getName())).collect(Collectors.toList());
// if more than one matching history item
if (matchingHistoryContents.size() > 1) {
String historyIds = "[";
for (HistoryContents content : matchingHistoryContents) {
historyIds += content.getId() + ",";
}
historyIds += "]";
throw new GalaxyDatasetException("Found " + matchingHistoryContents.size() + " datasets for file " + filename + ": " + historyIds);
} else if (matchingHistoryContents.size() == 1) {
String dataId = matchingHistoryContents.get(0).getId();
if (dataId != null) {
Dataset dataset = historiesClient.showDataset(historyId, dataId);
if (dataset != null) {
return dataset;
}
}
}
throw new GalaxyDatasetNotFoundException("dataset for file " + filename + " not found in Galaxy history " + historyId);
}
Aggregations