use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile in project irida by phac-nml.
the class DatabaseSetupGalaxyITService method setupSubmissionInDatabase.
/**
* Sets up an AnalysisSubmission and saves all dependencies in database.
* Saves with the given {@link AnalysisState}
*
* @param sampleId The id of the sample to associate with the given sequence
* file.
* @param sequenceFilePath The path to an input sequence file for this test.
* @param referenceFilePath The path to an input reference file for this test.
* @param iridaWorkflowId The id of an irida workflow.
* @param state {@link AnalysisState} of the workflow
* @param updateSamples whether to run the sampleUpdater for this analysis
* @return An {@link AnalysisSubmission} which has been saved to the
* database.
*/
public AnalysisSubmission setupSubmissionInDatabase(long sampleId, Path sequenceFilePath, Path referenceFilePath, UUID iridaWorkflowId, AnalysisState state, boolean updateSamples) {
SingleEndSequenceFile sequencingObject = (SingleEndSequenceFile) setupSequencingObjectInDatabase(sampleId, sequenceFilePath).get(0);
waitForFilesToSettle(sequencingObject);
sequencingObject = (SingleEndSequenceFile) sequencingObjectService.read(sequencingObject.getId());
ReferenceFile referenceFile = referenceFileRepository.save(new ReferenceFile(referenceFilePath));
AnalysisSubmission submission = AnalysisSubmission.builder(iridaWorkflowId).name("my analysis").inputFiles(Sets.newHashSet(sequencingObject)).referenceFile(referenceFile).updateSamples(updateSamples).build();
submission.setAnalysisState(state);
analysisSubmissionService.create(submission);
return analysisSubmissionRepository.findOne(submission.getId());
}
use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile in project irida by phac-nml.
the class SequencingRunControllerTest method testGetFilesPage.
@SuppressWarnings("rawtypes")
@Test
public void testGetFilesPage() throws IOException {
Long runId = 1L;
ExtendedModelMap model = new ExtendedModelMap();
SequencingRun sequencingRunEntity = new MiseqRun(SequencingRun.LayoutType.PAIRED_END, "");
ImmutableSet<SequencingObject> files = ImmutableSet.of(new SingleEndSequenceFile(new SequenceFile()));
when(sequencingRunService.read(runId)).thenReturn(sequencingRunEntity);
when(objectService.getSequencingObjectsForSequencingRun(sequencingRunEntity)).thenReturn(files);
String filesPage = controller.getFilesPage(runId, model);
assertEquals(SequencingRunController.FILES_VIEW, filesPage);
assertFalse(((Collection) model.get("sequencingObjects")).isEmpty());
assertEquals(sequencingRunEntity, model.get("run"));
assertTrue(model.containsKey("fileCount"));
verify(sequencingRunService).read(runId);
verify(objectService).getSequencingObjectsForSequencingRun(sequencingRunEntity);
}
use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile in project irida by phac-nml.
the class TestDataFactory method generateSequencingObjectsForSample.
public static List<SampleSequencingObjectJoin> generateSequencingObjectsForSample(Sample sample) {
List<SampleSequencingObjectJoin> join = new ArrayList<>();
for (long i = 0; i < 5; i++) {
Path path = Paths.get("/tmp/sequence-files/fake-file" + Math.random() + ".fast");
SequenceFile file = new SequenceFile(path);
file.setId(i);
SingleEndSequenceFile obj = new SingleEndSequenceFile(file);
obj.setId(i);
join.add(new SampleSequencingObjectJoin(sample, obj));
}
return join;
}
use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile in project irida by phac-nml.
the class SequencingObjectServiceImplIT method testCreateCorruptSequenceFileInSample.
@Test
@WithMockUser(username = "fbristow", roles = "SEQUENCER")
public void testCreateCorruptSequenceFileInSample() throws IOException, InterruptedException {
Sample s = sampleService.read(1L);
SequenceFile sf = new SequenceFile();
Path sequenceFile = Files.createTempFile("TEMPORARY-SEQUENCE-FILE", ".gz");
OutputStream gzOut = Files.newOutputStream(sequenceFile);
gzOut.write("not a file".getBytes());
gzOut.close();
sf.setFile(sequenceFile);
SingleEndSequenceFile so = new SingleEndSequenceFile(sf);
objectService.createSequencingObjectInSample(so, s);
// Wait 5 seconds. file processing should have failed by then.
Thread.sleep(5000);
Sample readSample = sampleService.read(s.getId());
List<QCEntry> qcEntries = sampleService.getQCEntriesForSample(readSample);
assertFalse("should be a qc entry", qcEntries.isEmpty());
QCEntry qc = qcEntries.iterator().next();
assertTrue("should be a FileProcessorErrorQCEntry", qc instanceof FileProcessorErrorQCEntry);
}
use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile in project irida by phac-nml.
the class SequencingObjectServiceImplIT method testConcatenateSequenceFiles.
@Test
@WithMockUser(username = "admin", roles = "ADMIN")
public void testConcatenateSequenceFiles() throws IOException, InterruptedException, ConcatenateException {
String newFileName = "newname";
Sample sample = sampleService.read(1L);
SequenceFile file1 = createSequenceFile("file1");
SequenceFile file2 = createSequenceFile("file2");
long originalLength = file1.getFile().toFile().length();
SequencingObject so1 = new SingleEndSequenceFile(file1);
SequencingObject so2 = new SingleEndSequenceFile(file2);
SampleSequencingObjectJoin join1 = objectService.createSequencingObjectInSample(so1, sample);
SampleSequencingObjectJoin join2 = objectService.createSequencingObjectInSample(so2, sample);
// Wait 5 seconds. file processing should have run by then.
Thread.sleep(5000);
// re-read the original files so file processing will be complete
so1 = objectService.read(join1.getObject().getId());
so2 = objectService.read(join2.getObject().getId());
Collection<SampleSequencingObjectJoin> originalSeqs = objectService.getSequencingObjectsForSample(sample);
List<SequencingObject> fileSet = Lists.newArrayList(so1, so2);
SampleSequencingObjectJoin concatenateSequences = objectService.concatenateSequences(fileSet, newFileName, sample, false);
// Wait 5 seconds. file processing should have run by then.
Thread.sleep(5000);
Collection<SampleSequencingObjectJoin> newSeqs = objectService.getSequencingObjectsForSample(sample);
// re-read the concatenated file so file processing will be complete
concatenateSequences = sampleService.getSampleForSequencingObject(concatenateSequences.getObject());
assertTrue("new seq collection should contain originals", newSeqs.containsAll(originalSeqs));
assertTrue("new seq collection should contain new object", newSeqs.contains(concatenateSequences));
assertEquals("new seq collection should have 1 more object", originalSeqs.size() + 1, newSeqs.size());
SequencingObject newSeqObject = concatenateSequences.getObject();
SequenceFile newFile = newSeqObject.getFiles().iterator().next();
assertTrue("new file should contain new name", newFile.getFileName().contains(newFileName));
long newFileSize = newFile.getFile().toFile().length();
assertEquals("new file should be 2x size of originals", originalLength * 2, newFileSize);
}
Aggregations