use of com.github.jmchilton.blend4j.galaxy.beans.collection.request.HistoryDatasetElement in project irida by phac-nml.
the class GalaxyHistoriesServiceTest method testConstructCollectionFail.
/**
* Tests failing to construct a dataset collection.
* @throws ExecutionManagerException
*/
@Test(expected = ExecutionManagerException.class)
public void testConstructCollectionFail() throws ExecutionManagerException {
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))).thenThrow(new RuntimeException());
galaxyHistory.constructCollection(description, history);
}
use of com.github.jmchilton.blend4j.galaxy.beans.collection.request.HistoryDatasetElement in project irida by phac-nml.
the class AnalysisCollectionServiceGalaxy method uploadSequenceFilesSingleEnd.
/**
* Uploads a list of single sequence files belonging to the given samples to
* Galaxy.
*
* @param sampleSequenceFiles
* A map between {@link Sample} and
* {@link IridaSingleEndSequenceFile}.
* @param workflowHistory
* The history to upload the sequence files into.
* @param workflowLibrary
* A temporary library to upload files into.
* @return A CollectionResponse for the dataset collection constructed from
* the given files.
* @throws ExecutionManagerException
* If there was an error uploading the files.
*/
public CollectionResponse uploadSequenceFilesSingleEnd(Map<Sample, ? extends IridaSingleEndSequenceFile> sampleSequenceFiles, History workflowHistory, Library workflowLibrary) throws ExecutionManagerException {
CollectionDescription description = new CollectionDescription();
description.setCollectionType(DatasetCollectionType.LIST.toString());
description.setName(COLLECTION_NAME_SINGLE);
Map<Path, Sample> samplesMap = new HashMap<>();
for (Sample sample : sampleSequenceFiles.keySet()) {
IridaSingleEndSequenceFile sequenceFile = sampleSequenceFiles.get(sample);
samplesMap.put(sequenceFile.getSequenceFile().getFile(), sample);
}
// upload files to library and then to a history
Set<Path> pathsToUpload = samplesMap.keySet();
Map<Path, String> pathHistoryDatasetId = galaxyHistoriesService.filesToLibraryToHistory(pathsToUpload, InputFileType.FASTQ_SANGER, workflowHistory, workflowLibrary, DataStorage.LOCAL);
for (Path sequenceFilePath : samplesMap.keySet()) {
if (!pathHistoryDatasetId.containsKey(sequenceFilePath)) {
throw new UploadException("Error, no corresponding history item found for " + sequenceFilePath);
}
Sample sample = samplesMap.get(sequenceFilePath);
String datasetHistoryId = pathHistoryDatasetId.get(sequenceFilePath);
HistoryDatasetElement datasetElement = new HistoryDatasetElement();
datasetElement.setId(datasetHistoryId);
datasetElement.setName(sample.getSampleName());
description.addDatasetElement(datasetElement);
}
return galaxyHistoriesService.constructCollection(description, workflowHistory);
}
Aggregations