use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile in project irida by phac-nml.
the class SequencingObjectConcatenatorFactoryTest method testGetConcatenatorMixedError.
@Test(expected = IllegalArgumentException.class)
public void testGetConcatenatorMixedError() {
Set<SequencingObject> fileSet = Sets.newHashSet(new SequenceFilePair(), new SingleEndSequenceFile(null));
SequencingObjectConcatenatorFactory.getConcatenator(fileSet);
}
use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile in project irida by phac-nml.
the class FastqcFileProcessorTest method testHandleFastaFile.
@Test(expected = FileProcessorException.class)
public void testHandleFastaFile() throws IOException {
// fastqc fails to handle fasta files (there's no quality scores,
// dummy), but that's A-OK.
Path fasta = Files.createTempFile(null, null);
Files.write(fasta, FASTA_FILE_CONTENTS.getBytes());
SequenceFile sf = new SequenceFile(fasta);
sf.setId(1L);
Runtime.getRuntime().addShutdownHook(new DeleteFileOnExit(fasta));
SingleEndSequenceFile so = new SingleEndSequenceFile(sf);
fileProcessor.process(so);
}
use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile in project irida by phac-nml.
the class FastqcFileProcessorTest method testHandleFastqFile.
@Test
public void testHandleFastqFile() throws IOException, IllegalArgumentException, IllegalAccessException {
// fastqc shouldn't barf on a fastq file.
Path fastq = Files.createTempFile(null, null);
Files.write(fastq, FASTQ_FILE_CONTENTS.getBytes());
Runtime.getRuntime().addShutdownHook(new DeleteFileOnExit(fastq));
ArgumentCaptor<SequenceFile> argument = ArgumentCaptor.forClass(SequenceFile.class);
SequenceFile sf = new SequenceFile(fastq);
sf.setId(1L);
SingleEndSequenceFile so = new SingleEndSequenceFile(sf);
try {
fileProcessor.process(so);
} catch (Exception e) {
e.printStackTrace();
fail();
}
verify(sequenceFileRepository).saveMetadata(argument.capture());
SequenceFile updatedFile = argument.getValue();
final Field fastqcAnalysis = ReflectionUtils.findField(SequenceFile.class, "fastqcAnalysis");
ReflectionUtils.makeAccessible(fastqcAnalysis);
AnalysisFastQC updated = (AnalysisFastQC) fastqcAnalysis.get(updatedFile);
assertEquals("GC Content was not set correctly.", Short.valueOf((short) 50), updated.getGcContent());
assertEquals("Filtered sequences was not 0.", Integer.valueOf(0), updated.getFilteredSequences());
assertEquals("File type was not correct.", "Conventional base calls", updated.getFileType());
assertEquals("Max length was not correct.", Integer.valueOf(SEQUENCE.length()), updated.getMaxLength());
assertEquals("Min length was not correct.", Integer.valueOf(SEQUENCE.length()), updated.getMinLength());
assertEquals("Total sequences was not correct.", Integer.valueOf(2), updated.getTotalSequences());
assertEquals("Encoding was not correct.", "Illumina <1.3", updated.getEncoding());
assertEquals("Total number of bases was not correct.", Long.valueOf(SEQUENCE.length() * 2), updated.getTotalBases());
assertNotNull("Per-base quality score chart was not created.", updated.getPerBaseQualityScoreChart());
assertTrue("Per-base quality score chart was created, but was empty.", ((byte[]) updated.getPerBaseQualityScoreChart()).length > 0);
assertNotNull("Per-sequence quality score chart was not created.", updated.getPerSequenceQualityScoreChart());
assertTrue("Per-sequence quality score chart was created, but was empty.", ((byte[]) updated.getPerSequenceQualityScoreChart()).length > 0);
assertNotNull("Duplication level chart was not created.", updated.getDuplicationLevelChart());
assertTrue("Duplication level chart was not created.", ((byte[]) updated.getDuplicationLevelChart()).length > 0);
Iterator<OverrepresentedSequence> ovrs = updated.getOverrepresentedSequences().iterator();
assertTrue("No overrepresented sequences added to analysis.", ovrs.hasNext());
OverrepresentedSequence overrepresentedSequence = updated.getOverrepresentedSequences().iterator().next();
assertEquals("Sequence was not the correct sequence.", SEQUENCE, overrepresentedSequence.getSequence());
assertEquals("The count was not correct.", 2, overrepresentedSequence.getOverrepresentedSequenceCount());
assertEquals("The percent was not correct.", BigDecimal.valueOf(100.), overrepresentedSequence.getPercentage());
}
use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile in project irida by phac-nml.
the class GzipFileProcessorTest method testDeleteOriginalFile.
@Test
public void testDeleteOriginalFile() throws IOException {
fileProcessor = new GzipFileProcessor(sequenceFileRepository, Boolean.TRUE);
final SequenceFile sf = constructSequenceFile();
// compress the file, update the sequence file reference
Path uncompressed = sf.getFile();
Path compressed = Files.createTempFile(null, ".gz");
GZIPOutputStream out = new GZIPOutputStream(Files.newOutputStream(compressed));
Files.copy(uncompressed, out);
out.close();
sf.setFile(compressed);
SingleEndSequenceFile so = new SingleEndSequenceFile(sf);
fileProcessor.process(so);
verify(sequenceFileRepository, times(1)).save(any(SequenceFile.class));
assertFalse("The original file should have been deleted.", Files.exists(compressed));
}
Aggregations