Search in sources :

Example 21 with SingleEndSequenceFile

use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile in project irida by phac-nml.

the class AnalysisExecutionServiceGalaxyTest method setup.

/**
 * Setup variables for tests.
 *
 * @throws IridaWorkflowNotFoundException
 * @throws IOException
 * @throws ExecutionManagerException
 * @throws NoSuchValueException
 * @throws IridaWorkflowAnalysisTypeException
 */
@Before
public void setup() throws IridaWorkflowNotFoundException, IOException, ExecutionManagerException, NoSuchValueException, IridaWorkflowAnalysisTypeException, AnalysisAlreadySetException {
    MockitoAnnotations.initMocks(this);
    String submissionName = "name";
    Set<SequencingObject> submissionInputFiles = Sets.newHashSet(new SingleEndSequenceFile(new SequenceFile()));
    analysisSubmission = AnalysisSubmission.builder(WORKFLOW_ID).name(submissionName + "intial").inputFiles(submissionInputFiles).build();
    analysisPreparing = AnalysisSubmission.builder(WORKFLOW_ID).name(submissionName + "preparing").inputFiles(submissionInputFiles).build();
    analysisPrepared = AnalysisSubmission.builder(WORKFLOW_ID).name(submissionName + "prepared").inputFiles(submissionInputFiles).build();
    analysisSubmitting = AnalysisSubmission.builder(WORKFLOW_ID).name(submissionName + "submitting").inputFiles(submissionInputFiles).build();
    analysisRunning = AnalysisSubmission.builder(WORKFLOW_ID).name(submissionName + "running").inputFiles(submissionInputFiles).build();
    analysisFinishedRunning = AnalysisSubmission.builder(WORKFLOW_ID).name(submissionName + "finishedrunning").inputFiles(submissionInputFiles).build();
    analysisCompleting = AnalysisSubmission.builder(WORKFLOW_ID).name(submissionName + "completing").inputFiles(submissionInputFiles).build();
    analysisCompleted = AnalysisSubmission.builder(WORKFLOW_ID).name(submissionName + "completed").inputFiles(submissionInputFiles).build();
    analysisCompletedCleaning = AnalysisSubmission.builder(WORKFLOW_ID).name(submissionName + "cleaning").inputFiles(submissionInputFiles).build();
    analysisCompletedCleaned = AnalysisSubmission.builder(WORKFLOW_ID).name(submissionName + "cleaned").inputFiles(submissionInputFiles).build();
    analysisError = AnalysisSubmission.builder(WORKFLOW_ID).name(submissionName + "error").inputFiles(submissionInputFiles).build();
    analysisErrorCleaning = AnalysisSubmission.builder(WORKFLOW_ID).name(submissionName + "errorcleaning").inputFiles(submissionInputFiles).build();
    analysisErrorCleaned = AnalysisSubmission.builder(WORKFLOW_ID).name(submissionName + "errorcleaned").inputFiles(submissionInputFiles).build();
    AnalysisExecutionServiceGalaxyAsync workflowManagementAsync = new AnalysisExecutionServiceGalaxyAsync(analysisSubmissionService, analysisService, galaxyWorkflowService, analysisWorkspaceService, iridaWorkflowsService, analysisSubmissionSampleProcessor);
    AnalysisExecutionServiceGalaxyCleanupAsync analysisExecutionServiceGalaxyCleanupAsync = new AnalysisExecutionServiceGalaxyCleanupAsync(analysisSubmissionService, galaxyWorkflowService, galaxyHistoriesService, galaxyLibrariesService);
    workflowManagement = new AnalysisExecutionServiceGalaxy(analysisSubmissionService, galaxyHistoriesService, workflowManagementAsync, analysisExecutionServiceGalaxyCleanupAsync);
    when(iridaWorkflowsService.getIridaWorkflow(WORKFLOW_ID)).thenReturn(iridaWorkflow);
    when(iridaWorkflow.getWorkflowStructure()).thenReturn(iridaWorkflowStructure);
    when(iridaWorkflowStructure.getWorkflowFile()).thenReturn(workflowFile);
    when(analysisSubmissionService.create(analysisSubmission)).thenReturn(analysisSubmission);
    when(analysisSubmissionService.read(INTERNAL_ANALYSIS_ID)).thenReturn(analysisSubmission);
    analysisSubmission.setId(INTERNAL_ANALYSIS_ID);
    analysisPreparing.setId(INTERNAL_ANALYSIS_ID);
    analysisPreparing.setAnalysisState(AnalysisState.PREPARING);
    when(analysisWorkspaceService.prepareAnalysisWorkspace(analysisPreparing)).thenReturn(ANALYSIS_ID);
    analysisPrepared.setId(INTERNAL_ANALYSIS_ID);
    analysisPrepared.setAnalysisState(AnalysisState.PREPARED);
    analysisPrepared.setRemoteWorkflowId(REMOTE_WORKFLOW_ID);
    analysisPrepared.setRemoteAnalysisId(ANALYSIS_ID);
    analysisSubmitting.setId(INTERNAL_ANALYSIS_ID);
    analysisSubmitting.setAnalysisState(AnalysisState.SUBMITTING);
    analysisSubmitting.setRemoteWorkflowId(REMOTE_WORKFLOW_ID);
    analysisSubmitting.setRemoteAnalysisId(ANALYSIS_ID);
    analysisRunning.setId(INTERNAL_ANALYSIS_ID);
    analysisRunning.setAnalysisState(AnalysisState.RUNNING);
    analysisRunning.setRemoteWorkflowId(REMOTE_WORKFLOW_ID);
    analysisRunning.setRemoteAnalysisId(ANALYSIS_ID);
    analysisRunning.setRemoteInputDataId(LIBRARY_ID);
    analysisFinishedRunning.setId(INTERNAL_ANALYSIS_ID);
    analysisFinishedRunning.setAnalysisState(AnalysisState.FINISHED_RUNNING);
    analysisFinishedRunning.setRemoteWorkflowId(REMOTE_WORKFLOW_ID);
    analysisFinishedRunning.setRemoteAnalysisId(ANALYSIS_ID);
    analysisFinishedRunning.setRemoteInputDataId(LIBRARY_ID);
    analysisCompleting.setId(INTERNAL_ANALYSIS_ID);
    analysisCompleting.setAnalysisState(AnalysisState.COMPLETING);
    analysisCompleting.setRemoteWorkflowId(REMOTE_WORKFLOW_ID);
    analysisCompleting.setRemoteAnalysisId(ANALYSIS_ID);
    analysisCompleting.setRemoteInputDataId(LIBRARY_ID);
    when(analysisWorkspaceService.getAnalysisResults(analysisCompleting)).thenReturn(analysisResults);
    when(analysisService.create(analysisResults)).thenReturn(analysisResults);
    analysisCompleted.setId(INTERNAL_ANALYSIS_ID);
    analysisCompleted.setAnalysisState(AnalysisState.COMPLETED);
    analysisCompleted.setRemoteWorkflowId(REMOTE_WORKFLOW_ID);
    analysisCompleted.setRemoteAnalysisId(ANALYSIS_ID);
    analysisCompleted.setAnalysisCleanedState(AnalysisCleanedState.NOT_CLEANED);
    analysisCompleted.setAnalysis(analysisResults);
    analysisCompleted.setRemoteInputDataId(LIBRARY_ID);
    analysisCompleted.setUpdateSamples(true);
    analysisCompletedCleaning.setId(INTERNAL_ANALYSIS_ID);
    analysisCompletedCleaning.setAnalysisState(AnalysisState.COMPLETED);
    analysisCompletedCleaning.setRemoteWorkflowId(REMOTE_WORKFLOW_ID);
    analysisCompletedCleaning.setRemoteAnalysisId(ANALYSIS_ID);
    analysisCompletedCleaning.setAnalysisCleanedState(AnalysisCleanedState.CLEANING);
    analysisCompletedCleaning.setAnalysis(analysisResults);
    analysisCompletedCleaning.setRemoteInputDataId(LIBRARY_ID);
    analysisCompletedCleaned.setId(INTERNAL_ANALYSIS_ID);
    analysisCompletedCleaned.setAnalysisState(AnalysisState.COMPLETED);
    analysisCompletedCleaned.setRemoteWorkflowId(REMOTE_WORKFLOW_ID);
    analysisCompletedCleaned.setRemoteAnalysisId(ANALYSIS_ID);
    analysisCompletedCleaned.setAnalysisCleanedState(AnalysisCleanedState.CLEANED);
    analysisCompletedCleaned.setAnalysis(analysisResults);
    analysisCompletedCleaned.setRemoteInputDataId(LIBRARY_ID);
    analysisError.setId(INTERNAL_ANALYSIS_ID);
    analysisError.setAnalysisState(AnalysisState.ERROR);
    analysisError.setRemoteWorkflowId(REMOTE_WORKFLOW_ID);
    analysisError.setAnalysisCleanedState(AnalysisCleanedState.NOT_CLEANED);
    analysisErrorCleaning.setId(INTERNAL_ANALYSIS_ID);
    analysisErrorCleaning.setAnalysisState(AnalysisState.ERROR);
    analysisErrorCleaning.setRemoteWorkflowId(REMOTE_WORKFLOW_ID);
    analysisErrorCleaning.setAnalysisCleanedState(AnalysisCleanedState.CLEANING);
    analysisErrorCleaned.setId(INTERNAL_ANALYSIS_ID);
    analysisErrorCleaned.setAnalysisState(AnalysisState.ERROR);
    analysisErrorCleaned.setRemoteWorkflowId(REMOTE_WORKFLOW_ID);
    analysisErrorCleaned.setAnalysisCleanedState(AnalysisCleanedState.CLEANED);
    analysisPrepared.setRemoteAnalysisId(ANALYSIS_ID);
    preparedWorkflow = new PreparedWorkflowGalaxy(ANALYSIS_ID, LIBRARY_ID, workflowInputsGalaxy);
    when(galaxyWorkflowService.uploadGalaxyWorkflow(workflowFile)).thenReturn(REMOTE_WORKFLOW_ID);
    when(galaxyHistoriesService.deleteHistory(ANALYSIS_ID)).thenReturn(new HistoryDeleteResponse());
}
Also used : AnalysisExecutionServiceGalaxyAsync(ca.corefacility.bioinformatics.irida.service.analysis.execution.galaxy.AnalysisExecutionServiceGalaxyAsync) SequencingObject(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject) SequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) AnalysisExecutionServiceGalaxy(ca.corefacility.bioinformatics.irida.service.analysis.execution.galaxy.AnalysisExecutionServiceGalaxy) AnalysisExecutionServiceGalaxyCleanupAsync(ca.corefacility.bioinformatics.irida.service.analysis.execution.galaxy.AnalysisExecutionServiceGalaxyCleanupAsync) PreparedWorkflowGalaxy(ca.corefacility.bioinformatics.irida.model.workflow.execution.galaxy.PreparedWorkflowGalaxy) HistoryDeleteResponse(com.github.jmchilton.blend4j.galaxy.beans.HistoryDeleteResponse) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) Before(org.junit.Before)

Example 22 with SingleEndSequenceFile

use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile in project irida by phac-nml.

the class AnalysisWorkspaceServiceGalaxyIT method testGetAnalysisResultsTestAnalysisSingleSingleSampleSuccess.

/**
 * Tests out successfully getting results for an analysis (TestAnalysis)
 * consisting only of single end sequence reads (for workflow accepting single sample).
 *
 * @throws InterruptedException
 * @throws ExecutionManagerException
 * @throws IridaWorkflowNotFoundException
 * @throws IOException
 * @throws IridaWorkflowAnalysisTypeException
 * @throws TimeoutException
 */
@Test
@WithMockUser(username = "aaron", roles = "ADMIN")
public void testGetAnalysisResultsTestAnalysisSingleSingleSampleSuccess() throws InterruptedException, ExecutionManagerException, IridaWorkflowNotFoundException, IOException, IridaWorkflowAnalysisTypeException, TimeoutException {
    History history = new History();
    history.setName("testGetAnalysisResultsTestAnalysisSingleSuccess");
    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);
    uploadFileToHistory(sequenceFilePathA, OUTPUT2_NAME, createdHistory.getId(), toolsClient);
    // wait for history
    Util.waitUntilHistoryComplete(createdHistory.getId(), galaxyHistoriesService, 60);
    IridaWorkflow iridaWorkflow = iridaWorkflowsService.getIridaWorkflow(validWorkflowIdSingleSingleSample);
    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, validWorkflowIdSingleSingleSample, false);
    Set<SingleEndSequenceFile> submittedSf = sequencingObjectService.getSequencingObjectsOfTypeForAnalysisSubmission(analysisSubmission, SingleEndSequenceFile.class);
    Set<SequenceFilePair> pairedFiles = sequencingObjectService.getSequencingObjectsOfTypeForAnalysisSubmission(analysisSubmission, SequenceFilePair.class);
    assertEquals("the created submission should have no paired input files", 0, pairedFiles.size());
    assertEquals("the created submission should have 1 single input file", 1, submittedSf.size());
    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", Analysis.class, analysis.getClass());
    assertEquals("the analysis results has an invalid number of output files", 2, analysis.getAnalysisOutputFiles().size());
    assertEquals("the analysis results output file has an invalid name", Paths.get(OUTPUT1_NAME), analysis.getAnalysisOutputFile(OUTPUT1_KEY).getFile().getFileName());
    assertEquals("the analysis results output file has an invalid label", SAMPLE1_NAME + '-' + OUTPUT1_NAME, analysis.getAnalysisOutputFile(OUTPUT1_KEY).getLabel());
    assertEquals("the analysis results output file has an invalid name", Paths.get(OUTPUT2_NAME), analysis.getAnalysisOutputFile(OUTPUT2_KEY).getFile().getFileName());
    assertEquals("the analysis results output file has an invalid label", SAMPLE1_NAME + '-' + OUTPUT2_NAME, analysis.getAnalysisOutputFile(OUTPUT2_KEY).getLabel());
}
Also used : Path(java.nio.file.Path) 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) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) SequenceFilePair(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair) WorkflowsClient(com.github.jmchilton.blend4j.galaxy.WorkflowsClient) ToolsClient(com.github.jmchilton.blend4j.galaxy.ToolsClient) Analysis(ca.corefacility.bioinformatics.irida.model.workflow.analysis.Analysis) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Example 23 with SingleEndSequenceFile

use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile in project irida by phac-nml.

the class AnalysisWorkspaceServiceGalaxyIT method testGetAnalysisResultsTestAnalysisSingleSuccess.

/**
 * Tests out successfully getting results for an analysis (TestAnalysis)
 * consisting only of single end sequence reads.
 *
 * @throws InterruptedException
 * @throws ExecutionManagerException
 * @throws IridaWorkflowNotFoundException
 * @throws IOException
 * @throws IridaWorkflowAnalysisTypeException
 * @throws TimeoutException
 * @throws IridaWorkflowAnalysisLabelException
 */
@Test
@WithMockUser(username = "aaron", roles = "ADMIN")
public void testGetAnalysisResultsTestAnalysisSingleSuccess() throws InterruptedException, ExecutionManagerException, IridaWorkflowNotFoundException, IOException, IridaWorkflowAnalysisTypeException, TimeoutException {
    History history = new History();
    history.setName("testGetAnalysisResultsTestAnalysisSingleSuccess");
    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);
    uploadFileToHistory(sequenceFilePathA, OUTPUT2_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);
    Set<SingleEndSequenceFile> submittedSf = sequencingObjectService.getSequencingObjectsOfTypeForAnalysisSubmission(analysisSubmission, SingleEndSequenceFile.class);
    Set<SequenceFilePair> pairedFiles = sequencingObjectService.getSequencingObjectsOfTypeForAnalysisSubmission(analysisSubmission, SequenceFilePair.class);
    assertEquals("the created submission should have no paired input files", 0, pairedFiles.size());
    assertEquals("the created submission should have 1 single input file", 1, submittedSf.size());
    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", Analysis.class, analysis.getClass());
    assertEquals("the analysis results has an invalid number of output files", 2, analysis.getAnalysisOutputFiles().size());
    assertEquals("the analysis results output file has an invalid name", Paths.get(OUTPUT1_NAME), analysis.getAnalysisOutputFile(OUTPUT1_KEY).getFile().getFileName());
    assertEquals("the analysis results output file has an invalid label", OUTPUT1_NAME, analysis.getAnalysisOutputFile(OUTPUT1_KEY).getLabel());
    assertEquals("the analysis results output file has an invalid name", Paths.get(OUTPUT2_NAME), analysis.getAnalysisOutputFile(OUTPUT2_KEY).getFile().getFileName());
    assertEquals("the analysis results output file has an invalid label", OUTPUT2_NAME, analysis.getAnalysisOutputFile(OUTPUT2_KEY).getLabel());
}
Also used : Path(java.nio.file.Path) 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) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) SequenceFilePair(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair) WorkflowsClient(com.github.jmchilton.blend4j.galaxy.WorkflowsClient) ToolsClient(com.github.jmchilton.blend4j.galaxy.ToolsClient) Analysis(ca.corefacility.bioinformatics.irida.model.workflow.analysis.Analysis) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Example 24 with SingleEndSequenceFile

use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile in project irida by phac-nml.

the class AnalysisWorkspaceServiceGalaxyIT method testGetAnalysisResultsTestAnalysisPairedSingleSampleSuccess.

/**
 * Tests out successfully getting results for an analysis (TestAnalysis)
 * consisting only of paired sequence reads.
 *
 * @throws InterruptedException
 * @throws ExecutionManagerException
 * @throws IridaWorkflowNotFoundException
 * @throws IOException
 * @throws IridaWorkflowAnalysisTypeException
 * @throws TimeoutException
 */
@Test
@WithMockUser(username = "aaron", roles = "ADMIN")
public void testGetAnalysisResultsTestAnalysisPairedSingleSampleSuccess() throws InterruptedException, ExecutionManagerException, IridaWorkflowNotFoundException, IOException, IridaWorkflowAnalysisTypeException, TimeoutException {
    History history = new History();
    history.setName("testGetAnalysisResultsTestAnalysisPairedSingleSampleSuccess");
    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);
    uploadFileToHistory(sequenceFilePathA, OUTPUT2_NAME, createdHistory.getId(), toolsClient);
    // wait for history
    Util.waitUntilHistoryComplete(createdHistory.getId(), galaxyHistoriesService, 60);
    IridaWorkflow iridaWorkflow = iridaWorkflowsService.getIridaWorkflow(validWorkflowIdPairedSingleSample);
    Path workflowPath = iridaWorkflow.getWorkflowStructure().getWorkflowFile();
    String workflowString = new String(Files.readAllBytes(workflowPath), StandardCharsets.UTF_8);
    Workflow galaxyWorkflow = workflowsClient.importWorkflow(workflowString);
    List<Path> paths1 = new ArrayList<>();
    paths1.add(sequenceFilePathA);
    List<Path> paths2 = new ArrayList<>();
    paths2.add(sequenceFilePath2A);
    AnalysisSubmission analysisSubmission = analysisExecutionGalaxyITService.setupPairSubmissionInDatabase(1L, paths1, paths2, referenceFilePath, validWorkflowIdPairedSingleSample, false);
    Set<SingleEndSequenceFile> submittedSingleFiles = sequencingObjectService.getSequencingObjectsOfTypeForAnalysisSubmission(analysisSubmission, SingleEndSequenceFile.class);
    Set<SequenceFilePair> pairedFiles = sequencingObjectService.getSequencingObjectsOfTypeForAnalysisSubmission(analysisSubmission, SequenceFilePair.class);
    assertEquals("the created submission should have no single input files", 0, submittedSingleFiles.size());
    assertEquals("the created submission has an invalid number of paired input files", 1, pairedFiles.size());
    SequenceFilePair submittedSp = pairedFiles.iterator().next();
    Set<SequenceFile> submittedSf = submittedSp.getFiles();
    assertEquals("the paired input should have 2 files", 2, submittedSf.size());
    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", Analysis.class, analysis.getClass());
    assertEquals("the analysis results has an invalid number of output files", 2, analysis.getAnalysisOutputFiles().size());
    assertEquals("the analysis results output file has an invalid name", Paths.get(OUTPUT1_NAME), analysis.getAnalysisOutputFile(OUTPUT1_KEY).getFile().getFileName());
    assertEquals("the analysis results output file has an invalid label", SAMPLE1_NAME + "-" + OUTPUT1_NAME, analysis.getAnalysisOutputFile(OUTPUT1_KEY).getLabel());
    assertEquals("the analysis results output file has an invalid name", Paths.get(OUTPUT2_NAME), analysis.getAnalysisOutputFile(OUTPUT2_KEY).getFile().getFileName());
    assertEquals("the analysis results output file has an invalid label", SAMPLE1_NAME + "-" + OUTPUT2_NAME, analysis.getAnalysisOutputFile(OUTPUT2_KEY).getLabel());
}
Also used : Path(java.nio.file.Path) IridaWorkflow(ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow) AnalysisSubmission(ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission) ArrayList(java.util.ArrayList) 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) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) SequenceFilePair(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair) WorkflowsClient(com.github.jmchilton.blend4j.galaxy.WorkflowsClient) ToolsClient(com.github.jmchilton.blend4j.galaxy.ToolsClient) SequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) Analysis(ca.corefacility.bioinformatics.irida.model.workflow.analysis.Analysis) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Example 25 with SingleEndSequenceFile

use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile in project irida by phac-nml.

the class AnalysisWorkspaceServiceGalaxyIT method testPrepareAnalysisFilesSingleFail.

/**
 * Tests out failing to prepare single workflow input files for execution
 * (duplicate samples).
 *
 * @throws InterruptedException
 * @throws ExecutionManagerException
 * @throws IOException
 * @throws IridaWorkflowException
 */
@Test(expected = DuplicateSampleException.class)
@WithMockUser(username = "aaron", roles = "ADMIN")
public void testPrepareAnalysisFilesSingleFail() throws InterruptedException, ExecutionManagerException, IOException, IridaWorkflowException {
    History history = new History();
    history.setName("testPrepareAnalysisFilesSingleFail");
    HistoriesClient historiesClient = localGalaxy.getGalaxyInstanceAdmin().getHistoriesClient();
    WorkflowsClient workflowsClient = localGalaxy.getGalaxyInstanceAdmin().getWorkflowsClient();
    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);
    List<SingleEndSequenceFile> sequenceFiles = analysisExecutionGalaxyITService.setupSequencingObjectInDatabase(1L, sequenceFilePathA, sequenceFilePath2A);
    AnalysisSubmission analysisSubmission = analysisExecutionGalaxyITService.setupSubmissionInDatabase(1L, Sets.newHashSet(sequenceFiles), referenceFilePath, validWorkflowIdSingle);
    analysisSubmission.setRemoteAnalysisId(createdHistory.getId());
    analysisSubmission.setRemoteWorkflowId(galaxyWorkflow.getId());
    analysisWorkspaceService.prepareAnalysisFiles(analysisSubmission);
}
Also used : Path(java.nio.file.Path) WorkflowsClient(com.github.jmchilton.blend4j.galaxy.WorkflowsClient) 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) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Aggregations

SingleEndSequenceFile (ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile)99 Test (org.junit.Test)72 SequenceFile (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile)61 Sample (ca.corefacility.bioinformatics.irida.model.sample.Sample)44 Path (java.nio.file.Path)33 SampleSequencingObjectJoin (ca.corefacility.bioinformatics.irida.model.sample.SampleSequencingObjectJoin)24 SequencingObject (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject)22 SequenceFilePair (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair)20 WithMockUser (org.springframework.security.test.context.support.WithMockUser)18 Project (ca.corefacility.bioinformatics.irida.model.project.Project)17 AnalysisSubmission (ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission)17 AnalysisFastQC (ca.corefacility.bioinformatics.irida.model.workflow.analysis.AnalysisFastQC)12 Analysis (ca.corefacility.bioinformatics.irida.model.workflow.analysis.Analysis)11 IridaWorkflow (ca.corefacility.bioinformatics.irida.model.workflow.IridaWorkflow)10 ArrayList (java.util.ArrayList)10 SequencingRun (ca.corefacility.bioinformatics.irida.model.run.SequencingRun)8 HistoriesClient (com.github.jmchilton.blend4j.galaxy.HistoriesClient)8 History (com.github.jmchilton.blend4j.galaxy.beans.History)8 GZIPOutputStream (java.util.zip.GZIPOutputStream)8 ModelMap (org.springframework.ui.ModelMap)8