use of com.github.jmchilton.blend4j.galaxy.beans.History 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.History 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.History in project irida by phac-nml.
the class GalaxyHistoriesServiceTest method testLibraryDatasetToHistory.
/**
* Tests moving a library dataset to a history.
*/
@Test
public void testLibraryDatasetToHistory() {
HistoryDetails historyDetails = new HistoryDetails();
History createdHistory = new History();
createdHistory.setId(HISTORY_ID);
when(historiesClient.createHistoryDataset(any(String.class), any(HistoryDataset.class))).thenReturn(historyDetails);
assertNotNull(galaxyHistory.libraryDatasetToHistory(libraryFileId, createdHistory));
}
use of com.github.jmchilton.blend4j.galaxy.beans.History in project irida by phac-nml.
the class GalaxyHistoriesServiceTest method testConstructCollectionSuccess.
/**
* Tests successfull construction of a dataset collection.
* @throws ExecutionManagerException
*/
@Test
public void testConstructCollectionSuccess() throws ExecutionManagerException {
CollectionResponse collectionResponse = new CollectionResponse();
History history = new History();
history.setId(HISTORY_ID);
HistoryDatasetElement datasetElement = new HistoryDatasetElement();
datasetElement.setId(DATA_ID);
CollectionDescription description = new CollectionDescription();
description.addDatasetElement(datasetElement);
when(historiesClient.createDatasetCollection(eq(HISTORY_ID), any(CollectionDescription.class))).thenReturn(collectionResponse);
assertEquals(collectionResponse, galaxyHistory.constructCollection(description, history));
}
use of com.github.jmchilton.blend4j.galaxy.beans.History in project irida by phac-nml.
the class AnalysisCollectionServiceGalaxyIT method testUploadSequenceFilesPairedFailForward.
/**
* Tests failing to upload a paired-end sequence file to Galaxy and
* constructing a collection due to no found forward file.
*
* @throws ExecutionManagerException
*/
@Test(expected = NoSuchElementException.class)
@WithMockUser(username = "aaron", roles = "ADMIN")
public void testUploadSequenceFilesPairedFailForward() throws ExecutionManagerException {
History history = new History();
history.setName("testUploadSequenceFilesPairedFailForward");
HistoriesClient historiesClient = localGalaxy.getGalaxyInstanceAdmin().getHistoriesClient();
LibrariesClient librariesClient = localGalaxy.getGalaxyInstanceAdmin().getLibrariesClient();
History createdHistory = historiesClient.create(history);
Library library = new Library();
library.setName("testUploadSequenceFilesPairedFailForward");
Library createdLibrary = librariesClient.createLibrary(library);
Set<SequenceFilePair> sequenceFiles = Sets.newHashSet(databaseSetupGalaxyITService.setupSampleSequenceFileInDatabase(1L, pairSequenceFiles1AInvalidName, pairSequenceFiles2A));
Map<Sample, IridaSequenceFilePair> sampleSequenceFilePairs = new HashMap<>(sequencingObjectService.getUniqueSamplesForSequencingObjects(sequenceFiles));
analysisCollectionServiceGalaxy.uploadSequenceFilesPaired(sampleSequenceFilePairs, createdHistory, createdLibrary);
}
Aggregations