Search in sources :

Example 6 with CollectionDescription

use of com.github.jmchilton.blend4j.galaxy.beans.collection.request.CollectionDescription 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);
}
Also used : CollectionDescription(com.github.jmchilton.blend4j.galaxy.beans.collection.request.CollectionDescription) HistoryDatasetElement(com.github.jmchilton.blend4j.galaxy.beans.collection.request.HistoryDatasetElement) History(com.github.jmchilton.blend4j.galaxy.beans.History) Test(org.junit.Test)

Example 7 with CollectionDescription

use of com.github.jmchilton.blend4j.galaxy.beans.collection.request.CollectionDescription 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);
}
Also used : Path(java.nio.file.Path) HashMap(java.util.HashMap) Sample(ca.corefacility.bioinformatics.irida.model.sample.Sample) UploadException(ca.corefacility.bioinformatics.irida.exceptions.UploadException) CollectionDescription(com.github.jmchilton.blend4j.galaxy.beans.collection.request.CollectionDescription) IridaSingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.irida.IridaSingleEndSequenceFile) HistoryDatasetElement(com.github.jmchilton.blend4j.galaxy.beans.collection.request.HistoryDatasetElement)

Aggregations

CollectionDescription (com.github.jmchilton.blend4j.galaxy.beans.collection.request.CollectionDescription)7 HistoryDatasetElement (com.github.jmchilton.blend4j.galaxy.beans.collection.request.HistoryDatasetElement)7 History (com.github.jmchilton.blend4j.galaxy.beans.History)4 Test (org.junit.Test)4 Dataset (com.github.jmchilton.blend4j.galaxy.beans.Dataset)3 UploadException (ca.corefacility.bioinformatics.irida.exceptions.UploadException)2 Sample (ca.corefacility.bioinformatics.irida.model.sample.Sample)2 CollectionElement (com.github.jmchilton.blend4j.galaxy.beans.collection.request.CollectionElement)2 CollectionResponse (com.github.jmchilton.blend4j.galaxy.beans.collection.response.CollectionResponse)2 Path (java.nio.file.Path)2 HashMap (java.util.HashMap)2 ExecutionManagerException (ca.corefacility.bioinformatics.irida.exceptions.ExecutionManagerException)1 IridaSequenceFile (ca.corefacility.bioinformatics.irida.model.irida.IridaSequenceFile)1 IridaSequenceFilePair (ca.corefacility.bioinformatics.irida.model.irida.IridaSequenceFilePair)1 IridaSingleEndSequenceFile (ca.corefacility.bioinformatics.irida.model.irida.IridaSingleEndSequenceFile)1 HashSet (java.util.HashSet)1