Search in sources :

Example 16 with SequenceFile

use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile in project irida by phac-nml.

the class SampleServiceImplTest method testGetTotalBasesForSampleSuccessOne.

/**
 * Tests out successfully getting the total bases from a sample with one
 * sequence file.
 *
 * @throws SequenceFileAnalysisException
 * @throws AnalysisAlreadySetException
 */
@Test
public void testGetTotalBasesForSampleSuccessOne() throws SequenceFileAnalysisException, AnalysisAlreadySetException {
    Sample s1 = new Sample();
    s1.setId(1L);
    SequenceFile sf1 = new SequenceFile();
    sf1.setId(2222L);
    SampleSequencingObjectJoin join = new SampleSequencingObjectJoin(s1, new SingleEndSequenceFile(sf1));
    AnalysisFastQC analysisFastQC1 = AnalysisFastQC.sloppyBuilder().executionManagerAnalysisId("id").totalBases(1000L).build();
    sf1.setFastQCAnalysis(analysisFastQC1);
    when(ssoRepository.getSequencesForSample(s1)).thenReturn(Arrays.asList(join));
    when(analysisRepository.findFastqcAnalysisForSequenceFile(sf1)).thenReturn(analysisFastQC1);
    long actualBases = sampleService.getTotalBasesForSample(s1);
    assertEquals(1000, actualBases);
}
Also used : SequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) Sample(ca.corefacility.bioinformatics.irida.model.sample.Sample) SampleSequencingObjectJoin(ca.corefacility.bioinformatics.irida.model.sample.SampleSequencingObjectJoin) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) AnalysisFastQC(ca.corefacility.bioinformatics.irida.model.workflow.analysis.AnalysisFastQC) Test(org.junit.Test)

Example 17 with SequenceFile

use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile in project irida by phac-nml.

the class SingleEndSequenceFileRemoteServiceImplTest method testGetSequenceFilesForSample.

@Test
public void testGetSequenceFilesForSample() {
    String seqFilesHref = "http://somewhere/projects/1/samples/2/sequencefiles";
    RemoteAPI api = new RemoteAPI();
    Sample sample = new Sample();
    sample.add(new Link(seqFilesHref, SingleEndSequenceFileRemoteServiceImpl.SAMPLE_SEQENCE_FILE_UNPAIRED_REL));
    sample.setRemoteStatus(new RemoteStatus("http://nowhere", api));
    List<SingleEndSequenceFile> filesList = Lists.newArrayList(new SingleEndSequenceFile(new SequenceFile()));
    when(apiRepo.getRemoteAPIForUrl(seqFilesHref)).thenReturn(api);
    when(repository.list(seqFilesHref, api)).thenReturn(filesList);
    List<SingleEndSequenceFile> sequenceFilesForSample = service.getUnpairedFilesForSample(sample);
    assertEquals(filesList, sequenceFilesForSample);
    verify(repository).list(seqFilesHref, api);
}
Also used : RemoteAPI(ca.corefacility.bioinformatics.irida.model.RemoteAPI) SequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) Sample(ca.corefacility.bioinformatics.irida.model.sample.Sample) RemoteStatus(ca.corefacility.bioinformatics.irida.model.remote.RemoteStatus) Link(org.springframework.hateoas.Link) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) Test(org.junit.Test)

Example 18 with SequenceFile

use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile in project irida by phac-nml.

the class IridaSequenceFilePair method getReverseSequenceFile.

/**
 * Get the reverse oriented {@link SequenceFile}
 *
 * @return reverse {@link SequenceFile}
 */
@JsonIgnore
public default IridaSequenceFile getReverseSequenceFile() {
    IridaSequenceFile[] pair = getFiles().toArray(new IridaSequenceFile[getFiles().size()]);
    String[] filenames = { pair[0].getFile().getFileName().toString(), pair[1].getFile().getFileName().toString() };
    int index = StringUtils.indexOfDifference(filenames[0], filenames[1]);
    if (Stream.of(reverseMatches).anyMatch(x -> String.valueOf(filenames[0].charAt(index)).equals(x))) {
        return pair[0];
    } else if (Stream.of(reverseMatches).anyMatch(x -> String.valueOf(filenames[1].charAt(index)).equals(x))) {
        return pair[1];
    } else {
        throw new NoSuchElementException();
    }
}
Also used : Stream(java.util.stream.Stream) JsonIgnore(com.fasterxml.jackson.annotation.JsonIgnore) Set(java.util.Set) NoSuchElementException(java.util.NoSuchElementException) StringUtils(org.apache.commons.lang3.StringUtils) SequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile) NoSuchElementException(java.util.NoSuchElementException) JsonIgnore(com.fasterxml.jackson.annotation.JsonIgnore)

Example 19 with SequenceFile

use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile in project irida by phac-nml.

the class SequenceFilePairTest method setup.

/**
 * Sets up files for tests.
 *
 * @throws IOException
 */
@Before
public void setup() throws IOException {
    Path tempDir = Paths.get("/tmp");
    forwardPathGood = tempDir.resolve("Test_R1_001.fastq");
    forwardPathBad = tempDir.resolve("Test_A.fastq");
    reversePathGood = tempDir.resolve("Test_R2_001.fastq");
    reversePathBad = tempDir.resolve("Test_B.fastq");
    sequenceFileForwardGood = new SequenceFile(forwardPathGood);
    sequenceFileForwardBad = new SequenceFile(forwardPathBad);
    sequenceFileReverseGood = new SequenceFile(reversePathGood);
    sequenceFileReverseBad = new SequenceFile(reversePathBad);
    sequenceFilePairGood = new SequenceFilePair(sequenceFileForwardGood, sequenceFileReverseGood);
    sequenceFilePairBad = new SequenceFilePair(sequenceFileForwardBad, sequenceFileReverseBad);
}
Also used : Path(java.nio.file.Path) SequenceFilePair(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair) SequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile) Before(org.junit.Before)

Example 20 with SequenceFile

use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile in project irida by phac-nml.

the class SequenceFilePairConcatenatorTest method createSequenceFile.

private SequenceFile createSequenceFile(String name) throws IOException {
    Path sequenceFile = Files.createTempFile(name, ".fastq");
    Files.write(sequenceFile, FASTQ_FILE_CONTENTS);
    return new SequenceFile(sequenceFile);
}
Also used : Path(java.nio.file.Path) SequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile)

Aggregations

SequenceFile (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile)111 SingleEndSequenceFile (ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile)84 Test (org.junit.Test)61 Path (java.nio.file.Path)50 Sample (ca.corefacility.bioinformatics.irida.model.sample.Sample)39 SampleSequencingObjectJoin (ca.corefacility.bioinformatics.irida.model.sample.SampleSequencingObjectJoin)31 SequencingObject (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject)25 SequenceFilePair (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair)20 Project (ca.corefacility.bioinformatics.irida.model.project.Project)15 AnalysisFastQC (ca.corefacility.bioinformatics.irida.model.workflow.analysis.AnalysisFastQC)15 WithMockUser (org.springframework.security.test.context.support.WithMockUser)13 IOException (java.io.IOException)11 SequencingRun (ca.corefacility.bioinformatics.irida.model.run.SequencingRun)9 ArrayList (java.util.ArrayList)9 ProjectSampleJoin (ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectSampleJoin)8 GZIPOutputStream (java.util.zip.GZIPOutputStream)8 Link (org.springframework.hateoas.Link)8 AnalysisSubmission (ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission)7 OutputStream (java.io.OutputStream)7 Before (org.junit.Before)7