Search in sources :

Example 26 with History

use of com.github.jmchilton.blend4j.galaxy.beans.History in project irida by phac-nml.

the class AnalysisWorkspaceServiceGalaxy method prepareAnalysisWorkspace.

/**
 * {@inheritDoc}
 */
@Override
public String prepareAnalysisWorkspace(AnalysisSubmission analysisSubmission) throws ExecutionManagerException {
    checkNotNull(analysisSubmission, "analysisSubmission is null");
    checkArgument(analysisSubmission.getRemoteAnalysisId() == null, "analysis id should be null");
    History workflowHistory = galaxyHistoriesService.newHistoryForWorkflow();
    return workflowHistory.getId();
}
Also used : History(com.github.jmchilton.blend4j.galaxy.beans.History)

Example 27 with History

use of com.github.jmchilton.blend4j.galaxy.beans.History 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)

Example 28 with History

use of com.github.jmchilton.blend4j.galaxy.beans.History in project irida by phac-nml.

the class GalaxyHistoriesService method newHistoryForWorkflow.

/**
 * Creates a new History for running a workflow.
 * @return  A new History for running a workflow.
 */
public History newHistoryForWorkflow() {
    History history = new History();
    history.setName(UUID.randomUUID().toString());
    return historiesClient.create(history);
}
Also used : History(com.github.jmchilton.blend4j.galaxy.beans.History)

Example 29 with History

use of com.github.jmchilton.blend4j.galaxy.beans.History in project irida by phac-nml.

the class GalaxyHistoriesServiceIT method testFilesToLibraryToHistoryRemoteSuccess.

/**
 * Tests successful upload of a file to a Galaxy history through a Library (where files are remote files).
 *
 * @throws UploadException
 * @throws GalaxyDatasetException
 */
@Test
public void testFilesToLibraryToHistoryRemoteSuccess() throws UploadException, GalaxyDatasetException {
    History history = galaxyHistory.newHistoryForWorkflow();
    Library library = buildEmptyLibrary("testFilesToLibraryToHistorySuccess");
    Map<Path, String> datasetsMap = galaxyHistory.filesToLibraryToHistory(Sets.newHashSet(dataFile, dataFile2), FILE_TYPE, history, library, DataStorage.REMOTE);
    assertNotNull(datasetsMap);
    assertEquals(2, datasetsMap.size());
    String datasetId1 = datasetsMap.get(dataFile);
    String datasetId2 = datasetsMap.get(dataFile2);
    Dataset actualDataset1 = localGalaxy.getGalaxyInstanceAdmin().getHistoriesClient().showDataset(history.getId(), datasetId1);
    assertNotNull(actualDataset1);
    Dataset actualDataset2 = localGalaxy.getGalaxyInstanceAdmin().getHistoriesClient().showDataset(history.getId(), datasetId2);
    assertNotNull(actualDataset2);
}
Also used : Path(java.nio.file.Path) Dataset(com.github.jmchilton.blend4j.galaxy.beans.Dataset) Library(com.github.jmchilton.blend4j.galaxy.beans.Library) History(com.github.jmchilton.blend4j.galaxy.beans.History) Test(org.junit.Test)

Example 30 with History

use of com.github.jmchilton.blend4j.galaxy.beans.History in project irida by phac-nml.

the class GalaxyHistoriesServiceIT method testFileToHistory.

/**
 * Tests direct upload of a file to a Galaxy history.
 * @throws UploadException
 * @throws GalaxyDatasetException
 */
@Test
public void testFileToHistory() throws UploadException, GalaxyDatasetException {
    History history = galaxyHistory.newHistoryForWorkflow();
    String filename = dataFile.toFile().getName();
    Dataset actualDataset = galaxyHistory.fileToHistory(dataFile, FILE_TYPE, history);
    assertNotNull(actualDataset);
    String dataId = Util.getIdForFileInHistory(filename, history.getId(), localGalaxy.getGalaxyInstanceAdmin());
    assertEquals(dataId, actualDataset.getId());
}
Also used : Dataset(com.github.jmchilton.blend4j.galaxy.beans.Dataset) History(com.github.jmchilton.blend4j.galaxy.beans.History) Test(org.junit.Test)

Aggregations

History (com.github.jmchilton.blend4j.galaxy.beans.History)61 Test (org.junit.Test)54 Path (java.nio.file.Path)25 HistoriesClient (com.github.jmchilton.blend4j.galaxy.HistoriesClient)24 WithMockUser (org.springframework.security.test.context.support.WithMockUser)22 IridaWorkflow (ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow)19 AnalysisSubmission (ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission)19 WorkflowsClient (com.github.jmchilton.blend4j.galaxy.WorkflowsClient)18 Workflow (com.github.jmchilton.blend4j.galaxy.beans.Workflow)18 Dataset (com.github.jmchilton.blend4j.galaxy.beans.Dataset)17 HistoryContents (com.github.jmchilton.blend4j.galaxy.beans.HistoryContents)11 Library (com.github.jmchilton.blend4j.galaxy.beans.Library)10 ToolsClient (com.github.jmchilton.blend4j.galaxy.ToolsClient)9 SequenceFilePair (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair)8 SingleEndSequenceFile (ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile)8 Analysis (ca.corefacility.bioinformatics.irida.model.workflow.analysis.Analysis)7 PreparedWorkflowGalaxy (ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.PreparedWorkflowGalaxy)7 CollectionResponse (com.github.jmchilton.blend4j.galaxy.beans.collection.response.CollectionResponse)7 WorkflowInputsGalaxy (ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.WorkflowInputsGalaxy)6 WorkflowInputs (com.github.jmchilton.blend4j.galaxy.beans.WorkflowInputs)6