Search in sources :

Example 6 with ToolsClient

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

the class AnalysisProvenanceServiceGalaxyTest method setUp.

@Before
public void setUp() {
    this.galaxyHistoriesService = mock(GalaxyHistoriesService.class);
    this.toolsClient = mock(ToolsClient.class);
    this.jobsClient = mock(JobsClient.class);
    this.provenanceService = new AnalysisProvenanceServiceGalaxy(galaxyHistoriesService, toolsClient, jobsClient);
}
Also used : GalaxyHistoriesService(ca.corefacility.bioinformatics.irida.pipeline.upload.galaxy.GalaxyHistoriesService) AnalysisProvenanceServiceGalaxy(ca.corefacility.bioinformatics.irida.service.analysis.workspace.galaxy.AnalysisProvenanceServiceGalaxy) ToolsClient(com.github.jmchilton.blend4j.galaxy.ToolsClient) JobsClient(com.github.jmchilton.blend4j.galaxy.JobsClient) Before(org.junit.Before)

Example 7 with ToolsClient

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

the class AnalysisExecutionServiceTestConfig method analysisProvenanceServiceGalaxy.

@Lazy
@Bean
public AnalysisProvenanceServiceGalaxy analysisProvenanceServiceGalaxy() {
    final ToolsClient toolsClient = localGalaxy.getGalaxyInstanceAdmin().getToolsClient();
    final JobsClient jobsClient = localGalaxy.getGalaxyInstanceAdmin().getJobsClient();
    return new AnalysisProvenanceServiceGalaxy(galaxyHistoriesService, toolsClient, jobsClient);
}
Also used : AnalysisProvenanceServiceGalaxy(ca.corefacility.bioinformatics.irida.service.analysis.workspace.galaxy.AnalysisProvenanceServiceGalaxy) ToolsClient(com.github.jmchilton.blend4j.galaxy.ToolsClient) JobsClient(com.github.jmchilton.blend4j.galaxy.JobsClient) Lazy(org.springframework.context.annotation.Lazy) Bean(org.springframework.context.annotation.Bean)

Example 8 with ToolsClient

use of com.github.jmchilton.blend4j.galaxy.ToolsClient 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);
}
Also used : Path(java.nio.file.Path) GalaxyHistoriesService(ca.corefacility.bioinformatics.irida.pipeline.upload.galaxy.GalaxyHistoriesService) SequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) ToolsClient(com.github.jmchilton.blend4j.galaxy.ToolsClient) LibrariesClient(com.github.jmchilton.blend4j.galaxy.LibrariesClient) GalaxyInstance(com.github.jmchilton.blend4j.galaxy.GalaxyInstance) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) HistoriesClient(com.github.jmchilton.blend4j.galaxy.HistoriesClient) GalaxyLibrariesService(ca.corefacility.bioinformatics.irida.pipeline.upload.galaxy.GalaxyLibrariesService) Before(org.junit.Before)

Example 9 with ToolsClient

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

the class AnalysisWorkspaceServiceGalaxyIT method testGetAnalysisResultsPhylogenomicsSuccess.

/**
 * Tests out successfully getting results for an analysis (phylogenomics).
 *
 * @throws InterruptedException
 * @throws ExecutionManagerException
 * @throws IridaWorkflowNotFoundException
 * @throws IOException
 * @throws IridaWorkflowAnalysisTypeException
 * @throws TimeoutException
 */
@Test
@WithMockUser(username = "aaron", roles = "ADMIN")
public void testGetAnalysisResultsPhylogenomicsSuccess() throws InterruptedException, ExecutionManagerException, IridaWorkflowNotFoundException, IOException, IridaWorkflowAnalysisTypeException, TimeoutException {
    History history = new History();
    history.setName("testGetAnalysisResultsPhylogenomicsSuccess");
    HistoriesClient historiesClient = localGalaxy.getGalaxyInstanceAdmin().getHistoriesClient();
    WorkflowsClient workflowsClient = localGalaxy.getGalaxyInstanceAdmin().getWorkflowsClient();
    ToolsClient toolsClient = localGalaxy.getGalaxyInstanceAdmin().getToolsClient();
    History createdHistory = historiesClient.create(history);
    // upload test outputs
    uploadFileToHistory(sequenceFilePathA, TABLE_NAME, createdHistory.getId(), toolsClient);
    uploadFileToHistory(sequenceFilePathA, MATRIX_NAME, createdHistory.getId(), toolsClient);
    uploadFileToHistory(sequenceFilePathA, TREE_NAME, createdHistory.getId(), toolsClient);
    // wait for history
    Util.waitUntilHistoryComplete(createdHistory.getId(), galaxyHistoriesService, 60);
    IridaWorkflow iridaWorkflow = iridaWorkflowsService.getIridaWorkflow(phylogenomicsWorkflowId);
    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, phylogenomicsWorkflowId, false);
    analysisSubmission.setRemoteAnalysisId(createdHistory.getId());
    analysisSubmission.setRemoteWorkflowId(galaxyWorkflow.getId());
    analysisSubmission.setAnalysisState(AnalysisState.COMPLETING);
    analysisSubmissionRepository.save(analysisSubmission);
    Analysis analysis = analysisWorkspaceService.getAnalysisResults(analysisSubmission);
    assertNotNull("the analysis results were not properly created", analysis);
    assertEquals("the Analysis results class is invalid", AnalysisType.PHYLOGENOMICS, analysis.getAnalysisType());
    assertEquals("the analysis results has an invalid number of output files", 3, analysis.getAnalysisOutputFiles().size());
    assertEquals("the analysis results output file has an invalid name", Paths.get(TABLE_NAME), analysis.getAnalysisOutputFile(TABLE_KEY).getFile().getFileName());
    assertEquals("the analysis results output file has an invalid label", TABLE_NAME, analysis.getAnalysisOutputFile(TABLE_KEY).getLabel());
    assertEquals("the analysis results output file has an invalid name", Paths.get(MATRIX_NAME), analysis.getAnalysisOutputFile(MATRIX_KEY).getFile().getFileName());
    assertEquals("the analysis results output file has an invalid label", MATRIX_NAME, analysis.getAnalysisOutputFile(MATRIX_KEY).getLabel());
    assertEquals("the analysis results output file has an invalid name", Paths.get(TREE_NAME), analysis.getAnalysisOutputFile(TREE_KEY).getFile().getFileName());
    assertEquals("the analysis results output file has an invalid label", TREE_NAME, analysis.getAnalysisOutputFile(TREE_KEY).getLabel());
}
Also used : Path(java.nio.file.Path) WorkflowsClient(com.github.jmchilton.blend4j.galaxy.WorkflowsClient) ToolsClient(com.github.jmchilton.blend4j.galaxy.ToolsClient) IridaWorkflow(ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow) Analysis(ca.corefacility.bioinformatics.irida.model.workflow.analysis.Analysis) AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission) Workflow(com.github.jmchilton.blend4j.galaxy.beans.Workflow) IridaWorkflow(ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow) History(com.github.jmchilton.blend4j.galaxy.beans.History) HistoriesClient(com.github.jmchilton.blend4j.galaxy.HistoriesClient) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Example 10 with ToolsClient

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

the class AnalysisWorkspaceServiceGalaxyIT method testGetAnalysisResultsTestAnalysisFail.

/**
 * Tests out failing to get results for an analysis (missing output file).
 *
 * @throws InterruptedException
 * @throws ExecutionManagerException
 * @throws IridaWorkflowNotFoundException
 * @throws IOException
 * @throws IridaWorkflowAnalysisTypeException
 * @throws TimeoutException
 */
@Test(expected = GalaxyDatasetNotFoundException.class)
@WithMockUser(username = "aaron", roles = "ADMIN")
public void testGetAnalysisResultsTestAnalysisFail() throws InterruptedException, ExecutionManagerException, IridaWorkflowNotFoundException, IOException, IridaWorkflowAnalysisTypeException, TimeoutException {
    History history = new History();
    history.setName("testGetAnalysisResultsTestAnalysisFail");
    HistoriesClient historiesClient = localGalaxy.getGalaxyInstanceAdmin().getHistoriesClient();
    WorkflowsClient workflowsClient = localGalaxy.getGalaxyInstanceAdmin().getWorkflowsClient();
    ToolsClient toolsClient = localGalaxy.getGalaxyInstanceAdmin().getToolsClient();
    History createdHistory = historiesClient.create(history);
    // upload test outputs
    uploadFileToHistory(sequenceFilePathA, OUTPUT1_NAME, createdHistory.getId(), toolsClient);
    // wait for history
    Util.waitUntilHistoryComplete(createdHistory.getId(), galaxyHistoriesService, 60);
    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());
    analysisSubmission.setAnalysisState(AnalysisState.COMPLETING);
    analysisSubmissionRepository.save(analysisSubmission);
    analysisWorkspaceService.getAnalysisResults(analysisSubmission);
}
Also used : Path(java.nio.file.Path) WorkflowsClient(com.github.jmchilton.blend4j.galaxy.WorkflowsClient) ToolsClient(com.github.jmchilton.blend4j.galaxy.ToolsClient) IridaWorkflow(ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow) AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission) Workflow(com.github.jmchilton.blend4j.galaxy.beans.Workflow) IridaWorkflow(ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow) History(com.github.jmchilton.blend4j.galaxy.beans.History) HistoriesClient(com.github.jmchilton.blend4j.galaxy.HistoriesClient) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Aggregations

ToolsClient (com.github.jmchilton.blend4j.galaxy.ToolsClient)12 HistoriesClient (com.github.jmchilton.blend4j.galaxy.HistoriesClient)10 Path (java.nio.file.Path)9 IridaWorkflow (ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow)8 AnalysisSubmission (ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission)8 WorkflowsClient (com.github.jmchilton.blend4j.galaxy.WorkflowsClient)8 History (com.github.jmchilton.blend4j.galaxy.beans.History)8 Workflow (com.github.jmchilton.blend4j.galaxy.beans.Workflow)8 Test (org.junit.Test)8 WithMockUser (org.springframework.security.test.context.support.WithMockUser)8 Analysis (ca.corefacility.bioinformatics.irida.model.workflow.analysis.Analysis)7 SingleEndSequenceFile (ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile)6 SequenceFilePair (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair)5 SequenceFile (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile)4 ArrayList (java.util.ArrayList)4 GalaxyHistoriesService (ca.corefacility.bioinformatics.irida.pipeline.upload.galaxy.GalaxyHistoriesService)3 Before (org.junit.Before)3 GalaxyLibrariesService (ca.corefacility.bioinformatics.irida.pipeline.upload.galaxy.GalaxyLibrariesService)2 AnalysisProvenanceServiceGalaxy (ca.corefacility.bioinformatics.irida.service.analysis.workspace.galaxy.AnalysisProvenanceServiceGalaxy)2 JobsClient (com.github.jmchilton.blend4j.galaxy.JobsClient)2