Search in sources :

Example 1 with Dataset

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

the class GalaxyHistoriesServiceIT method testDownloadDatasetFailDatasetId.

/**
 * Tests failing to download a dataset (invalid dataset id)
 * @throws IOException
 * @throws InterruptedException
 * @throws ExecutionManagerException
 * @throws TimeoutException
 */
@Test(expected = ExecutionManagerDownloadException.class)
public void testDownloadDatasetFailDatasetId() throws IOException, TimeoutException, ExecutionManagerException, InterruptedException {
    History history = galaxyHistory.newHistoryForWorkflow();
    Dataset dataset = galaxyHistory.fileToHistory(dataFile, InputFileType.FASTQ_SANGER, history);
    Util.waitUntilHistoryComplete(history.getId(), galaxyHistory, 60);
    String invalidDatasetId = dataset.getId() + "a";
    Path datasetPath = Files.createTempFile("data", "fastq");
    galaxyHistory.downloadDatasetTo(history.getId(), invalidDatasetId, datasetPath);
}
Also used : Path(java.nio.file.Path) Dataset(com.github.jmchilton.blend4j.galaxy.beans.Dataset) History(com.github.jmchilton.blend4j.galaxy.beans.History) Test(org.junit.Test)

Example 2 with Dataset

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

the class GalaxyHistoriesServiceIT method testDownloadDatasetSuccess.

/**
 * Tests downloading a dataset successfully.
 * @throws IOException
 * @throws InterruptedException
 * @throws ExecutionManagerException
 * @throws TimeoutException
 */
@Test
public void testDownloadDatasetSuccess() throws IOException, TimeoutException, ExecutionManagerException, InterruptedException {
    History history = galaxyHistory.newHistoryForWorkflow();
    Dataset dataset = galaxyHistory.fileToHistory(dataFile, InputFileType.FASTQ_SANGER, history);
    Util.waitUntilHistoryComplete(history.getId(), galaxyHistory, 60);
    Path datasetPath = Files.createTempFile("data", "fastq");
    galaxyHistory.downloadDatasetTo(history.getId(), dataset.getId(), datasetPath);
    assertEquals("file lengths should be equals", Files.size(dataFile), Files.size(datasetPath));
    assertTrue("uploaded and downloaded dataset should be equal", com.google.common.io.Files.equal(dataFile.toFile(), datasetPath.toFile()));
}
Also used : Path(java.nio.file.Path) Dataset(com.github.jmchilton.blend4j.galaxy.beans.Dataset) History(com.github.jmchilton.blend4j.galaxy.beans.History) Test(org.junit.Test)

Example 3 with Dataset

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

the class GalaxyHistoriesServiceIT method testConstructCollectionSuccess.

/**
 * Tests out successfully constructing a collection of datasets.
 * @throws ExecutionManagerException
 */
@Test
public void testConstructCollectionSuccess() throws ExecutionManagerException {
    History history = galaxyHistory.newHistoryForWorkflow();
    Dataset dataset1 = galaxyHistory.fileToHistory(dataFile, FILE_TYPE, history);
    Dataset dataset2 = galaxyHistory.fileToHistory(dataFile2, FILE_TYPE, history);
    assertNotNull(dataset1);
    assertNotNull(dataset2);
    String collectionName = "collection";
    CollectionDescription description = new CollectionDescription();
    description.setName(collectionName);
    description.setCollectionType(DatasetCollectionType.LIST.toString());
    HistoryDatasetElement element1 = new HistoryDatasetElement();
    element1.setId(dataset1.getId());
    element1.setName(dataset1.getName());
    description.addDatasetElement(element1);
    HistoryDatasetElement element2 = new HistoryDatasetElement();
    element2.setId(dataset2.getId());
    element2.setName(dataset2.getName());
    description.addDatasetElement(element2);
    CollectionResponse collectionResponse = galaxyHistory.constructCollection(description, history);
    assertNotNull(collectionResponse);
    assertEquals(DatasetCollectionType.LIST.toString(), collectionResponse.getCollectionType());
    assertEquals(history.getId(), collectionResponse.getHistoryId());
    assertEquals(2, collectionResponse.getElements().size());
}
Also used : Dataset(com.github.jmchilton.blend4j.galaxy.beans.Dataset) CollectionResponse(com.github.jmchilton.blend4j.galaxy.beans.collection.response.CollectionResponse) 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 4 with Dataset

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

the class GalaxyHistoriesServiceIT method testFilesToLibraryToHistorySuccess.

/**
 * Tests successful upload of a file to a Galaxy history through a Library.
 *
 * @throws UploadException
 * @throws GalaxyDatasetException
 */
@Test
public void testFilesToLibraryToHistorySuccess() 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.LOCAL);
    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 5 with Dataset

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

the class GalaxyWorkflowsIT method testExecuteCollectionsPairedList.

/**
 * Tests executing a collections paired list workflow.
 * @throws ExecutionManagerException
 */
@Test
public void testExecuteCollectionsPairedList() throws ExecutionManagerException {
    String workflowId = localGalaxy.getWorklowCollectionListId();
    String workflowInputLabel = localGalaxy.getWorkflowCollectionListLabel();
    List<Path> dataFilesForward = new LinkedList<Path>();
    dataFilesForward.add(dataFile1);
    dataFilesForward.add(dataFile2);
    List<Path> dataFilesReverse = new LinkedList<Path>();
    dataFilesReverse.add(dataFile3);
    dataFilesReverse.add(dataFile4);
    WorkflowOutputs workflowOutput = runSingleCollectionWorkflow(dataFilesForward, dataFilesReverse, FILE_TYPE, workflowId, workflowInputLabel);
    assertNotNull(workflowOutput);
    assertNotNull(workflowOutput.getHistoryId());
    // history should exist
    HistoryDetails historyDetails = historiesClient.showHistory(workflowOutput.getHistoryId());
    assertNotNull(historyDetails);
    // outputs should exist
    assertNotNull(workflowOutput.getOutputIds());
    assertEquals(1, workflowOutput.getOutputIds().size());
    String outputId = workflowOutput.getOutputIds().get(0);
    // output dataset should exist
    Dataset outputDataset = historiesClient.showDataset(workflowOutput.getHistoryId(), outputId);
    assertNotNull(outputDataset);
    // test get workflow status
    GalaxyWorkflowStatus workflowStatus = galaxyHistory.getStatusForHistory(workflowOutput.getHistoryId());
    float percentComplete = workflowStatus.getProportionComplete();
    assertTrue(0.0f <= percentComplete && percentComplete <= 1.0f);
}
Also used : Path(java.nio.file.Path) WorkflowOutputs(com.github.jmchilton.blend4j.galaxy.beans.WorkflowOutputs) HistoryDetails(com.github.jmchilton.blend4j.galaxy.beans.HistoryDetails) Dataset(com.github.jmchilton.blend4j.galaxy.beans.Dataset) GalaxyWorkflowStatus(ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.GalaxyWorkflowStatus) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Aggregations

Dataset (com.github.jmchilton.blend4j.galaxy.beans.Dataset)26 History (com.github.jmchilton.blend4j.galaxy.beans.History)17 Test (org.junit.Test)17 Path (java.nio.file.Path)10 WorkflowOutputs (com.github.jmchilton.blend4j.galaxy.beans.WorkflowOutputs)6 GalaxyWorkflowStatus (ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.GalaxyWorkflowStatus)4 HistoryDataset (com.github.jmchilton.blend4j.galaxy.beans.HistoryDataset)4 HistoryDetails (com.github.jmchilton.blend4j.galaxy.beans.HistoryDetails)4 Library (com.github.jmchilton.blend4j.galaxy.beans.Library)4 WorkflowInputs (com.github.jmchilton.blend4j.galaxy.beans.WorkflowInputs)4 CollectionDescription (com.github.jmchilton.blend4j.galaxy.beans.collection.request.CollectionDescription)4 CollectionResponse (com.github.jmchilton.blend4j.galaxy.beans.collection.response.CollectionResponse)4 HistoryContents (com.github.jmchilton.blend4j.galaxy.beans.HistoryContents)3 WorkflowDetails (com.github.jmchilton.blend4j.galaxy.beans.WorkflowDetails)3 HistoryDatasetElement (com.github.jmchilton.blend4j.galaxy.beans.collection.request.HistoryDatasetElement)3 ExecutionManagerException (ca.corefacility.bioinformatics.irida.exceptions.ExecutionManagerException)2 HistoriesClient (com.github.jmchilton.blend4j.galaxy.HistoriesClient)2 FileUploadRequest (com.github.jmchilton.blend4j.galaxy.ToolsClient.FileUploadRequest)2 HistoryContentsProvenance (com.github.jmchilton.blend4j.galaxy.beans.HistoryContentsProvenance)2 ToolParameter (com.github.jmchilton.blend4j.galaxy.beans.ToolParameter)2