Search in sources :

Example 96 with SingleEndSequenceFile

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);
}
Also used : SequenceFilePair(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair) SequencingObject(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) Test(org.junit.Test)

Example 97 with SingleEndSequenceFile

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);
}
Also used : Path(java.nio.file.Path) SequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) Test(org.junit.Test)

Example 98 with SingleEndSequenceFile

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());
}
Also used : Path(java.nio.file.Path) Field(java.lang.reflect.Field) SequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) FileProcessorException(ca.corefacility.bioinformatics.irida.processing.FileProcessorException) IOException(java.io.IOException) AnalysisFastQC(ca.corefacility.bioinformatics.irida.model.workflow.analysis.AnalysisFastQC) OverrepresentedSequence(ca.corefacility.bioinformatics.irida.model.sequenceFile.OverrepresentedSequence) Test(org.junit.Test)

Example 99 with SingleEndSequenceFile

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));
}
Also used : Path(java.nio.file.Path) GzipFileProcessor(ca.corefacility.bioinformatics.irida.processing.impl.GzipFileProcessor) SequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) GZIPOutputStream(java.util.zip.GZIPOutputStream) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) 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