use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile in project irida by phac-nml.
the class SampleServiceImplTest method testGetTotalBasesForSampleSuccessTwo.
/**
* Tests out successfully getting the total bases from a sample with two
* sequence files.
*
* @throws SequenceFileAnalysisException
* @throws AnalysisAlreadySetException
*/
@Test
public void testGetTotalBasesForSampleSuccessTwo() throws SequenceFileAnalysisException, AnalysisAlreadySetException {
Sample s1 = new Sample();
s1.setId(1L);
SequenceFile sf1 = new SequenceFile();
sf1.setId(2222L);
SequenceFile sf2 = new SequenceFile();
sf1.setId(3333L);
SampleSequencingObjectJoin join1 = new SampleSequencingObjectJoin(s1, new SingleEndSequenceFile(sf1));
SampleSequencingObjectJoin join2 = new SampleSequencingObjectJoin(s1, new SingleEndSequenceFile(sf2));
AnalysisFastQC analysisFastQC1 = AnalysisFastQC.sloppyBuilder().executionManagerAnalysisId("id").totalBases(1000L).build();
sf1.setFastQCAnalysis(analysisFastQC1);
AnalysisFastQC analysisFastQC2 = AnalysisFastQC.sloppyBuilder().executionManagerAnalysisId("id2").totalBases(1000L).build();
sf2.setFastQCAnalysis(analysisFastQC2);
when(ssoRepository.getSequencesForSample(s1)).thenReturn(Arrays.asList(join1, join2));
when(analysisRepository.findFastqcAnalysisForSequenceFile(sf1)).thenReturn(analysisFastQC1);
when(analysisRepository.findFastqcAnalysisForSequenceFile(sf2)).thenReturn(analysisFastQC2);
long actualBases = sampleService.getTotalBasesForSample(s1);
assertEquals(2000, actualBases);
}
use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile in project irida by phac-nml.
the class AnalysisWorkspaceServiceGalaxyTest method testGetAnalysisResultsSuccessMultiSample.
/**
* Tests successfully getting analysis results from Galaxy where there's
* multiple samples but workflow should have only accepted single sample (no
* label on name).
*
* @throws IridaWorkflowNotFoundException
* @throws IOException
* @throws ExecutionManagerException
* @throws IridaWorkflowAnalysisTypeException
*/
@Test
public void testGetAnalysisResultsSuccessMultiSample() throws IridaWorkflowNotFoundException, IridaWorkflowAnalysisTypeException, ExecutionManagerException, IOException {
Set<SingleEndSequenceFile> singleFiles = Sets.newHashSet(sampleSingleSequenceFileMap.values());
Set<SequenceFilePair> pairedFiles = Sets.newHashSet(sampleSequenceFilePairMap.values());
submission = AnalysisSubmission.builder(workflowId).name("my analysis").inputFiles(pairedInputFiles).referenceFile(referenceFile).build();
submission.setRemoteWorkflowId(WORKFLOW_ID);
submission.setRemoteAnalysisId(HISTORY_ID);
when(sequencingObjectService.getSequencingObjectsOfTypeForAnalysisSubmission(submission, SingleEndSequenceFile.class)).thenReturn(singleFiles);
when(sequencingObjectService.getSequencingObjectsOfTypeForAnalysisSubmission(submission, SequenceFilePair.class)).thenReturn(pairedFiles);
when(iridaWorkflowsService.getIridaWorkflow(workflowId)).thenReturn(iridaWorkflowSingle);
when(galaxyHistoriesService.getDatasetForFileInHistory(output1Filename, HISTORY_ID)).thenReturn(output1Dataset);
when(galaxyHistoriesService.getDatasetForFileInHistory(output2Filename, HISTORY_ID)).thenReturn(output2Dataset);
when(sequencingObjectService.getUniqueSamplesForSequencingObjects(singleFiles)).thenReturn(sampleSingleSequenceFileMap);
when(sequencingObjectService.getUniqueSamplesForSequencingObjects(pairedFiles)).thenReturn(sampleSequenceFilePairMap);
Analysis analysis = workflowPreparation.getAnalysisResults(submission);
assertNotNull("analysis is not valid", analysis);
assertEquals("invalid number of output files", 2, analysis.getAnalysisOutputFiles().size());
assertEquals("missing output file for analysis", Paths.get("output1.txt"), analysis.getAnalysisOutputFile("output1").getFile().getFileName());
// labels should now not have sample associated with them.
assertEquals("missing label for analysis output file", "output1.txt", analysis.getAnalysisOutputFile("output1").getLabel());
assertEquals("missing output file for analysis", "output2.txt", analysis.getAnalysisOutputFile("output2").getLabel());
verify(galaxyHistoriesService).getDatasetForFileInHistory("output1.txt", HISTORY_ID);
verify(galaxyHistoriesService).getDatasetForFileInHistory("output2.txt", HISTORY_ID);
}
use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile in project irida by phac-nml.
the class AnalysisWorkspaceServiceGalaxyTest method testGetAnalysisResultsSuccessSinglePairedEnd.
/**
* Tests successfully getting analysis results from Galaxy with
* single/paired end input files.
*
* @throws IridaWorkflowNotFoundException
* @throws IOException
* @throws ExecutionManagerException
* @throws IridaWorkflowAnalysisTypeException
*/
@Test
public void testGetAnalysisResultsSuccessSinglePairedEnd() throws IridaWorkflowNotFoundException, IridaWorkflowAnalysisTypeException, ExecutionManagerException, IOException {
Set<SingleEndSequenceFile> singleFiles = Sets.newHashSet(sampleSingleSequenceFileMap.values());
Set<SequenceFilePair> pairedFiles = Sets.newHashSet(sampleSequenceFilePairMap.values());
Set<SequencingObject> joinedFiles = Sets.newHashSet(singleFiles);
joinedFiles.addAll(pairedFiles);
Map<Sample, SequencingObject> joinedMap = Maps.newHashMap(sampleSingleSequenceFileMap);
joinedMap.putAll(sampleSequenceFilePairMap);
submission = AnalysisSubmission.builder(workflowIdMultiSamples).name("my analysis").inputFiles(singleInputFiles).inputFiles(pairedInputFiles).referenceFile(referenceFile).build();
submission.setRemoteWorkflowId(WORKFLOW_ID);
submission.setRemoteAnalysisId(HISTORY_ID);
when(sequencingObjectService.getSequencingObjectsForAnalysisSubmission(submission)).thenReturn(joinedFiles);
when(iridaWorkflowsService.getIridaWorkflow(workflowIdMultiSamples)).thenReturn(iridaWorkflowSinglePairedMultipleSamples);
when(galaxyHistoriesService.getDatasetForFileInHistory(output1Filename, HISTORY_ID)).thenReturn(output1Dataset);
when(galaxyHistoriesService.getDatasetForFileInHistory(output2Filename, HISTORY_ID)).thenReturn(output2Dataset);
when(sequencingObjectService.getUniqueSamplesForSequencingObjects(joinedFiles)).thenReturn(joinedMap);
Analysis analysis = workflowPreparation.getAnalysisResults(submission);
assertNotNull("analysis is not valid", analysis);
assertEquals("invalid number of output files", 2, analysis.getAnalysisOutputFiles().size());
assertEquals("missing output file for analysis", Paths.get("output1.txt"), analysis.getAnalysisOutputFile("output1").getFile().getFileName());
// labels should now not have sample associated with them.
assertEquals("missing label for analysis output file", "output1.txt", analysis.getAnalysisOutputFile("output1").getLabel());
assertEquals("missing output file for analysis", "output2.txt", analysis.getAnalysisOutputFile("output2").getLabel());
verify(galaxyHistoriesService).getDatasetForFileInHistory("output1.txt", HISTORY_ID);
verify(galaxyHistoriesService).getDatasetForFileInHistory("output2.txt", HISTORY_ID);
}
use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile in project irida by phac-nml.
the class NcbiExportSubmissionServceTest method testCreate.
@Test
public void testCreate() {
SingleEndSequenceFile sequenceFile = new SingleEndSequenceFile(new SequenceFile());
NcbiBioSampleFiles ncbiBioSampleFiles = new NcbiBioSampleFiles("sample", Lists.newArrayList(sequenceFile), Lists.newArrayList(), null, "library_name", null, null, null, "library_construction_protocol", "namespace");
NcbiExportSubmission submission = new NcbiExportSubmission(null, null, "bioProjectId", "organization", "ncbiNamespace", new Date(), Lists.newArrayList(ncbiBioSampleFiles));
service.create(submission);
verify(repository).save(submission);
}
use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile in project irida by phac-nml.
the class TestDataFactory method constructSingleEndSequenceFile.
/**
* Construct a simple {@link SingleEndSequenceFile}
*
* @return a {@link SingleEndSequenceFile} with a {@link SequenceFile} and
* id
* @throws IOException
* if the temp file couldn't be created
*/
public static SingleEndSequenceFile constructSingleEndSequenceFile() throws IOException {
SequenceFile sf = constructSequenceFile();
SingleEndSequenceFile sesf = new SingleEndSequenceFile(sf);
sesf.setId(2L);
return sesf;
}
Aggregations