use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile in project irida by phac-nml.
the class DatabaseSetupGalaxyITService method setupSampleSequenceFileInDatabase.
/**
* Attaches the given sequence file paths as pairs (using parallel lists) to
* a particular sample id.
*
* @param sampleId
* The id of the sample to attach a sequence file to.
* @param sequenceFiles1
* A list of the first part of each pairs to setup.
* @param sequenceFiles2
* A list of the second part of each pairs to setup.
* @return A {@link List} of {@link SequenceFilePair} objects with the given
* sequence file paths attached and saved in the database.
*/
public List<SequenceFilePair> setupSampleSequenceFileInDatabase(long sampleId, List<Path> sequenceFiles1, List<Path> sequenceFiles2) {
checkArgument(sequenceFiles1.size() == sequenceFiles2.size(), "sequenceFiles lists are unequal");
Sample sample = sampleService.read(sampleId);
List<SequenceFilePair> returnedSequenceFilePairs = new ArrayList<>();
for (int i = 0; i < sequenceFiles1.size(); i++) {
SequenceFile sf1 = new SequenceFile(sequenceFiles1.get(i));
SequenceFile sf2 = new SequenceFile(sequenceFiles2.get(i));
SequenceFilePair pair = new SequenceFilePair(sf1, sf2);
sequencingObjectService.createSequencingObjectInSample(pair, sample);
waitForFilesToSettle(pair);
returnedSequenceFilePairs.add((SequenceFilePair) sequencingObjectService.read(pair.getId()));
}
return returnedSequenceFilePairs;
}
use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile 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.SequenceFile 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.SequenceFile 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.SequenceFile 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