use of com.github.jmchilton.blend4j.galaxy.LibrariesClient in project irida by phac-nml.
the class AnalysisWorkspaceServiceGalaxyIT method setup.
/**
* Sets up variables for testing.
*
* @throws URISyntaxException
* @throws IOException
* @throws IridaWorkflowLoadException
*/
@Before
public void setup() throws URISyntaxException, IOException, IridaWorkflowLoadException {
Assume.assumeFalse(WindowsPlatformCondition.isWindows());
Path sequenceFilePathReal = Paths.get(DatabaseSetupGalaxyITService.class.getResource("testData1.fastq").toURI());
Path referenceFilePathReal = Paths.get(DatabaseSetupGalaxyITService.class.getResource("testReference.fasta").toURI());
Path tempDir = Files.createTempDirectory(rootTempDirectory, "workspaceServiceGalaxyTest");
sequenceFilePathA = tempDir.resolve("testDataA_R1_001.fastq");
Files.copy(sequenceFilePathReal, sequenceFilePathA, StandardCopyOption.REPLACE_EXISTING);
sequenceFilePath2A = tempDir.resolve("testDataA_R2_001.fastq");
Files.copy(sequenceFilePathReal, sequenceFilePath2A, StandardCopyOption.REPLACE_EXISTING);
sequenceFilePathB = tempDir.resolve("testDataB_R1_001.fastq");
Files.copy(sequenceFilePathReal, sequenceFilePathB, StandardCopyOption.REPLACE_EXISTING);
sequenceFilePath2B = tempDir.resolve("testDataB_R2_001.fastq");
Files.copy(sequenceFilePathReal, sequenceFilePath2B, StandardCopyOption.REPLACE_EXISTING);
sequenceFilePath3 = tempDir.resolve("testData3_R1_001.fastq");
Files.copy(sequenceFilePathReal, sequenceFilePath3, StandardCopyOption.REPLACE_EXISTING);
referenceFilePath = Files.createTempFile("testReference", ".fasta");
Files.delete(referenceFilePath);
Files.copy(referenceFilePathReal, referenceFilePath);
singleFileSet = Sets.newHashSet(new SingleEndSequenceFile(new SequenceFile(sequenceFilePathA)));
GalaxyInstance galaxyInstanceAdmin = localGalaxy.getGalaxyInstanceAdmin();
HistoriesClient historiesClient = galaxyInstanceAdmin.getHistoriesClient();
ToolsClient toolsClient = galaxyInstanceAdmin.getToolsClient();
LibrariesClient librariesClient = galaxyInstanceAdmin.getLibrariesClient();
GalaxyLibrariesService galaxyLibrariesService = new GalaxyLibrariesService(librariesClient, LIBRARY_POLLING_TIME, LIBRARY_TIMEOUT, 1);
galaxyHistoriesService = new GalaxyHistoriesService(historiesClient, toolsClient, galaxyLibrariesService);
pairSequenceFiles1A = new ArrayList<>();
pairSequenceFiles1A.add(sequenceFilePathA);
pairSequenceFiles2A = new ArrayList<>();
pairSequenceFiles2A.add(sequenceFilePath2A);
pairSequenceFiles1AB = new ArrayList<>();
pairSequenceFiles1AB.add(sequenceFilePathA);
pairSequenceFiles1AB.add(sequenceFilePathB);
pairSequenceFiles2AB = new ArrayList<>();
pairSequenceFiles2AB.add(sequenceFilePath2A);
pairSequenceFiles2AB.add(sequenceFilePath2B);
}
use of com.github.jmchilton.blend4j.galaxy.LibrariesClient in project irida by phac-nml.
the class AnalysisWorkspaceServiceGalaxyIT method testPrepareAnalysisFilesPairSuccess.
/**
* Tests out successfully preparing paired workflow input files for
* execution.
*
* @throws InterruptedException
* @throws ExecutionManagerException
* @throws IOException
* @throws IridaWorkflowException
*/
@Test
@WithMockUser(username = "aaron", roles = "ADMIN")
public void testPrepareAnalysisFilesPairSuccess() throws InterruptedException, ExecutionManagerException, IOException, IridaWorkflowException {
History history = new History();
history.setName("testPrepareAnalysisFilesPairSuccess");
HistoriesClient historiesClient = localGalaxy.getGalaxyInstanceAdmin().getHistoriesClient();
WorkflowsClient workflowsClient = localGalaxy.getGalaxyInstanceAdmin().getWorkflowsClient();
LibrariesClient librariesClient = localGalaxy.getGalaxyInstanceAdmin().getLibrariesClient();
History createdHistory = historiesClient.create(history);
IridaWorkflow iridaWorkflow = iridaWorkflowsService.getIridaWorkflow(validWorkflowIdPaired);
Path workflowPath = iridaWorkflow.getWorkflowStructure().getWorkflowFile();
String workflowString = new String(Files.readAllBytes(workflowPath), StandardCharsets.UTF_8);
Workflow galaxyWorkflow = workflowsClient.importWorkflow(workflowString);
AnalysisSubmission analysisSubmission = analysisExecutionGalaxyITService.setupPairSubmissionInDatabase(1L, pairSequenceFiles1A, pairSequenceFiles2A, referenceFilePath, validWorkflowIdPaired, false);
analysisSubmission.setRemoteAnalysisId(createdHistory.getId());
analysisSubmission.setRemoteWorkflowId(galaxyWorkflow.getId());
PreparedWorkflowGalaxy preparedWorkflow = analysisWorkspaceService.prepareAnalysisFiles(analysisSubmission);
assertEquals("the response history id should match the input history id", createdHistory.getId(), preparedWorkflow.getRemoteAnalysisId());
WorkflowInputsGalaxy workflowInputsGalaxy = preparedWorkflow.getWorkflowInputs();
assertNotNull("the returned workflow inputs should not be null", workflowInputsGalaxy);
assertNotNull("the returned library id should not be null", preparedWorkflow.getRemoteDataId());
// verify correct library is created
List<LibraryContent> libraryContents = librariesClient.getLibraryContents(preparedWorkflow.getRemoteDataId());
Map<String, List<LibraryContent>> libraryContentsMap = libraryContents.stream().collect(Collectors.groupingBy(LibraryContent::getName));
assertFalse("the returned library should exist in Galaxy", libraryContentsMap.isEmpty());
String sequenceFile1ALibraryName = "/" + sequenceFilePathA.getFileName().toString();
String sequenceFile2ALibraryName = "/" + sequenceFilePath2A.getFileName().toString();
assertEquals("the returned library does not contain the correct number of elements", 3, libraryContentsMap.size());
assertTrue("the returned library does not contain a root folder", libraryContentsMap.containsKey("/"));
assertTrue("the returned library does not contain the correct sequence file", libraryContentsMap.containsKey(sequenceFile1ALibraryName));
assertEquals("the returned library does not contain the correct sequence file", 1, libraryContentsMap.get(sequenceFile1ALibraryName).size());
assertTrue("the returned library does not contain the correct sequence file", libraryContentsMap.containsKey(sequenceFile2ALibraryName));
assertEquals("the returned library does not contain the correct sequence file", 1, libraryContentsMap.get(sequenceFile2ALibraryName).size());
// verify correct files have been uploaded
List<HistoryContents> historyContents = historiesClient.showHistoryContents(createdHistory.getId());
assertEquals("the created history has an invalid number of elements", 4, historyContents.size());
Map<String, HistoryContents> contentsMap = historyContentsAsMap(historyContents);
assertTrue("the created history should contain the file " + sequenceFilePathA.toFile().getName(), contentsMap.containsKey(sequenceFilePathA.toFile().getName()));
assertTrue("the created history should contain the file " + sequenceFilePath2A.toFile().getName(), contentsMap.containsKey(sequenceFilePath2A.toFile().getName()));
assertTrue("the created history should contain the file " + referenceFilePath.toFile().getName(), contentsMap.containsKey(referenceFilePath.toFile().getName()));
assertTrue("the created history should contain the collection with name " + INPUTS_PAIRED_NAME, contentsMap.containsKey(INPUTS_PAIRED_NAME));
// make sure workflow inputs contains correct information
Map<String, WorkflowInput> workflowInputsMap = preparedWorkflow.getWorkflowInputs().getInputsObject().getInputs();
assertEquals("the created workflow inputs has an invalid number of elements", 2, workflowInputsMap.size());
}
use of com.github.jmchilton.blend4j.galaxy.LibrariesClient in project irida by phac-nml.
the class AnalysisWorkspaceServiceGalaxyIT method testPrepareAnalysisFilesSingleSuccess.
/**
* Tests out successfully preparing single workflow input files for
* execution.
*
* @throws InterruptedException
* @throws ExecutionManagerException
* @throws IOException
* @throws IridaWorkflowException
*/
@Test
@WithMockUser(username = "aaron", roles = "ADMIN")
public void testPrepareAnalysisFilesSingleSuccess() throws InterruptedException, ExecutionManagerException, IOException, IridaWorkflowException {
History history = new History();
history.setName("testPrepareAnalysisFilesSingleSuccess");
HistoriesClient historiesClient = localGalaxy.getGalaxyInstanceAdmin().getHistoriesClient();
WorkflowsClient workflowsClient = localGalaxy.getGalaxyInstanceAdmin().getWorkflowsClient();
LibrariesClient librariesClient = localGalaxy.getGalaxyInstanceAdmin().getLibrariesClient();
History createdHistory = historiesClient.create(history);
IridaWorkflow iridaWorkflow = iridaWorkflowsService.getIridaWorkflow(validWorkflowIdSingle);
Path workflowPath = iridaWorkflow.getWorkflowStructure().getWorkflowFile();
String workflowString = new String(Files.readAllBytes(workflowPath), StandardCharsets.UTF_8);
Workflow galaxyWorkflow = workflowsClient.importWorkflow(workflowString);
AnalysisSubmission analysisSubmission = analysisExecutionGalaxyITService.setupSubmissionInDatabase(1L, sequenceFilePathA, referenceFilePath, validWorkflowIdSingle, false);
analysisSubmission.setRemoteAnalysisId(createdHistory.getId());
analysisSubmission.setRemoteWorkflowId(galaxyWorkflow.getId());
PreparedWorkflowGalaxy preparedWorkflow = analysisWorkspaceService.prepareAnalysisFiles(analysisSubmission);
assertEquals("the response history id should match the input history id", createdHistory.getId(), preparedWorkflow.getRemoteAnalysisId());
assertNotNull("the returned workflow inputs should not be null", preparedWorkflow.getWorkflowInputs());
assertNotNull("the returned library id should not be null", preparedWorkflow.getRemoteDataId());
// verify correct library is created
List<LibraryContent> libraryContents = librariesClient.getLibraryContents(preparedWorkflow.getRemoteDataId());
Map<String, List<LibraryContent>> libraryContentsMap = libraryContents.stream().collect(Collectors.groupingBy(LibraryContent::getName));
assertFalse("the returned library should exist in Galaxy", libraryContentsMap.isEmpty());
String sequenceFileALibraryName = "/" + sequenceFilePathA.getFileName().toString();
assertEquals("the returned library does not contain the correct number of elements", 2, libraryContentsMap.size());
assertTrue("the returned library does not contain a root folder", libraryContentsMap.containsKey("/"));
assertTrue("the returned library does not contain the correct sequence file", libraryContentsMap.containsKey(sequenceFileALibraryName));
assertEquals("the returned library does not contain the correct sequence file", 1, libraryContentsMap.get(sequenceFileALibraryName).size());
// verify correct files have been uploaded
List<HistoryContents> historyContents = historiesClient.showHistoryContents(createdHistory.getId());
assertEquals("the created history should contain 3 entries", 3, historyContents.size());
Map<String, HistoryContents> contentsMap = historyContentsAsMap(historyContents);
assertTrue("the created history should contain the file " + sequenceFilePathA.toFile().getName(), contentsMap.containsKey(sequenceFilePathA.toFile().getName()));
assertTrue("the created history should contain the file " + referenceFilePath.toFile().getName(), contentsMap.containsKey(referenceFilePath.toFile().getName()));
assertTrue("the created history should contain the collection with name " + INPUTS_SINGLE_NAME, contentsMap.containsKey(INPUTS_SINGLE_NAME));
// make sure workflow inputs contains correct information
Map<String, WorkflowInput> workflowInputsMap = preparedWorkflow.getWorkflowInputs().getInputsObject().getInputs();
assertEquals("the created workflow inputs has an invalid number of elements", 2, workflowInputsMap.size());
}
Aggregations