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);
}
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);
}
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();
}
}
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);
}
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);
}
Aggregations