Search in sources :

Example 1 with GalaxyDatasetException

use of ca.corefacility.bioinformatics.irida.exceptions.galaxy.GalaxyDatasetException in project irida by phac-nml.

the class AnalysisWorkspaceServiceGalaxyTest method testGetAnalysisResultsFail.

/**
 * Tests failure to get analysis results from Galaxy due to failure to get a
 * dataset
 *
 * @throws IridaWorkflowNotFoundException
 * @throws IOException
 * @throws ExecutionManagerException
 * @throws IridaWorkflowAnalysisTypeException
 */
@Test(expected = GalaxyDatasetException.class)
public void testGetAnalysisResultsFail() throws IridaWorkflowNotFoundException, IridaWorkflowAnalysisTypeException, ExecutionManagerException, IOException {
    submission = AnalysisSubmission.builder(workflowId).name("my analysis").inputFiles(singleInputFiles).referenceFile(referenceFile).build();
    submission.setRemoteWorkflowId(WORKFLOW_ID);
    submission.setRemoteAnalysisId(HISTORY_ID);
    when(iridaWorkflowsService.getIridaWorkflow(workflowId)).thenReturn(iridaWorkflowSingle);
    when(galaxyHistoriesService.getDatasetForFileInHistory(output1Filename, HISTORY_ID)).thenThrow(new GalaxyDatasetException());
    workflowPreparation.getAnalysisResults(submission);
}
Also used : GalaxyDatasetException(ca.corefacility.bioinformatics.irida.exceptions.galaxy.GalaxyDatasetException) Test(org.junit.Test)

Example 2 with GalaxyDatasetException

use of ca.corefacility.bioinformatics.irida.exceptions.galaxy.GalaxyDatasetException 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);
}
Also used : UniformInterfaceException(com.sun.jersey.api.client.UniformInterfaceException) GalaxyWorkflowStatus(ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.GalaxyWorkflowStatus) ExecutionManagerException(ca.corefacility.bioinformatics.irida.exceptions.ExecutionManagerException) HistoryContents(com.github.jmchilton.blend4j.galaxy.beans.HistoryContents) DeleteGalaxyObjectFailedException(ca.corefacility.bioinformatics.irida.exceptions.galaxy.DeleteGalaxyObjectFailedException) ClientResponse(com.sun.jersey.api.client.ClientResponse) LoggerFactory(org.slf4j.LoggerFactory) UploadException(ca.corefacility.bioinformatics.irida.exceptions.UploadException) HashMap(java.util.HashMap) HistoryDeleteResponse(com.github.jmchilton.blend4j.galaxy.beans.HistoryDeleteResponse) NoGalaxyHistoryException(ca.corefacility.bioinformatics.irida.exceptions.galaxy.NoGalaxyHistoryException) Dataset(com.github.jmchilton.blend4j.galaxy.beans.Dataset) GalaxyDatasetException(ca.corefacility.bioinformatics.irida.exceptions.galaxy.GalaxyDatasetException) Map(java.util.Map) HistoriesClient(com.github.jmchilton.blend4j.galaxy.HistoriesClient) Source(com.github.jmchilton.blend4j.galaxy.beans.HistoryDataset.Source) ExecutionManagerDownloadException(ca.corefacility.bioinformatics.irida.exceptions.ExecutionManagerDownloadException) Path(java.nio.file.Path) DataStorage(ca.corefacility.bioinformatics.irida.pipeline.upload.DataStorage) Logger(org.slf4j.Logger) HistoryDataset(com.github.jmchilton.blend4j.galaxy.beans.HistoryDataset) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) Set(java.util.Set) IOException(java.io.IOException) FileUploadRequest(com.github.jmchilton.blend4j.galaxy.ToolsClient.FileUploadRequest) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) InputFileType(ca.corefacility.bioinformatics.irida.model.workflow.execution.InputFileType) File(java.io.File) CollectionResponse(com.github.jmchilton.blend4j.galaxy.beans.collection.response.CollectionResponse) Preconditions.checkState(com.google.common.base.Preconditions.checkState) WorkflowException(ca.corefacility.bioinformatics.irida.exceptions.WorkflowException) GalaxyDatasetNotFoundException(ca.corefacility.bioinformatics.irida.exceptions.galaxy.GalaxyDatasetNotFoundException) Library(com.github.jmchilton.blend4j.galaxy.beans.Library) List(java.util.List) ToolsClient(com.github.jmchilton.blend4j.galaxy.ToolsClient) History(com.github.jmchilton.blend4j.galaxy.beans.History) CollectionDescription(com.github.jmchilton.blend4j.galaxy.beans.collection.request.CollectionDescription) HistoryDetails(com.github.jmchilton.blend4j.galaxy.beans.HistoryDetails) ClientHandlerException(com.sun.jersey.api.client.ClientHandlerException) Optional(java.util.Optional) ExecutionManagerObjectNotFoundException(ca.corefacility.bioinformatics.irida.exceptions.ExecutionManagerObjectNotFoundException) HistoryContentsProvenance(com.github.jmchilton.blend4j.galaxy.beans.HistoryContentsProvenance) GalaxyDatasetException(ca.corefacility.bioinformatics.irida.exceptions.galaxy.GalaxyDatasetException) HistoryContents(com.github.jmchilton.blend4j.galaxy.beans.HistoryContents) Dataset(com.github.jmchilton.blend4j.galaxy.beans.Dataset) HistoryDataset(com.github.jmchilton.blend4j.galaxy.beans.HistoryDataset) GalaxyDatasetNotFoundException(ca.corefacility.bioinformatics.irida.exceptions.galaxy.GalaxyDatasetNotFoundException)

Aggregations

GalaxyDatasetException (ca.corefacility.bioinformatics.irida.exceptions.galaxy.GalaxyDatasetException)2 ExecutionManagerDownloadException (ca.corefacility.bioinformatics.irida.exceptions.ExecutionManagerDownloadException)1 ExecutionManagerException (ca.corefacility.bioinformatics.irida.exceptions.ExecutionManagerException)1 ExecutionManagerObjectNotFoundException (ca.corefacility.bioinformatics.irida.exceptions.ExecutionManagerObjectNotFoundException)1 UploadException (ca.corefacility.bioinformatics.irida.exceptions.UploadException)1 WorkflowException (ca.corefacility.bioinformatics.irida.exceptions.WorkflowException)1 DeleteGalaxyObjectFailedException (ca.corefacility.bioinformatics.irida.exceptions.galaxy.DeleteGalaxyObjectFailedException)1 GalaxyDatasetNotFoundException (ca.corefacility.bioinformatics.irida.exceptions.galaxy.GalaxyDatasetNotFoundException)1 NoGalaxyHistoryException (ca.corefacility.bioinformatics.irida.exceptions.galaxy.NoGalaxyHistoryException)1 InputFileType (ca.corefacility.bioinformatics.irida.model.workflow.execution.InputFileType)1 GalaxyWorkflowStatus (ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.GalaxyWorkflowStatus)1 DataStorage (ca.corefacility.bioinformatics.irida.pipeline.upload.DataStorage)1 HistoriesClient (com.github.jmchilton.blend4j.galaxy.HistoriesClient)1 ToolsClient (com.github.jmchilton.blend4j.galaxy.ToolsClient)1 FileUploadRequest (com.github.jmchilton.blend4j.galaxy.ToolsClient.FileUploadRequest)1 Dataset (com.github.jmchilton.blend4j.galaxy.beans.Dataset)1 History (com.github.jmchilton.blend4j.galaxy.beans.History)1 HistoryContents (com.github.jmchilton.blend4j.galaxy.beans.HistoryContents)1 HistoryContentsProvenance (com.github.jmchilton.blend4j.galaxy.beans.HistoryContentsProvenance)1 HistoryDataset (com.github.jmchilton.blend4j.galaxy.beans.HistoryDataset)1