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();
}
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);
}
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);
}
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);
}
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());
}
Aggregations