use of org.icgc.dcc.song.server.model.analysis.SequencingReadAnalysis in project SONG by overture-stack.
the class AnalysisService method read.
public Analysis read(String id) {
val analysis = checkAnalysis(id);
analysis.setInfo(analysisInfoService.readNullableInfo(id));
analysis.setFile(readFiles(id));
analysis.setSample(readSamples(id));
if (analysis instanceof SequencingReadAnalysis) {
val experiment = readSequencingRead(id);
((SequencingReadAnalysis) analysis).setExperiment(experiment);
} else if (analysis instanceof VariantCallAnalysis) {
val experiment = readVariantCall(id);
((VariantCallAnalysis) analysis).setExperiment(experiment);
}
return analysis;
}
use of org.icgc.dcc.song.server.model.analysis.SequencingReadAnalysis in project SONG by overture-stack.
the class ExportService method convertToPayload.
@SneakyThrows
private static JsonNode convertToPayload(@NonNull Analysis a, boolean includeAnalysisId, boolean includeOtherIds) {
JsonNode output;
val analysisType = resolveAnalysisType(a.getAnalysisType());
if (analysisType == SEQUENCING_READ) {
val seqRead = (SequencingReadAnalysis) a;
output = readTree(toPrettyJson(seqRead));
} else if (analysisType == VARIANT_CALL) {
val varCall = (VariantCallAnalysis) a;
output = readTree(toPrettyJson(varCall));
} else {
throw new IllegalStateException(format("Should not be here, unsupported analysisType '%s'", a.getAnalysisType()));
}
val payloadConverter = createPayloadConverter(includeAnalysisId, includeOtherIds);
val payloadParser = createPayloadParser(output);
return payloadConverter.convert(payloadParser);
}
use of org.icgc.dcc.song.server.model.analysis.SequencingReadAnalysis in project SONG by overture-stack.
the class AnalysisServiceTest method testGetAnalysisAndIdSearch.
@Test
public void testGetAnalysisAndIdSearch() {
val studyGenerator = createStudyGenerator(studyService, randomGenerator);
val studyId = studyGenerator.createRandomStudy();
val analysisGenerator = createAnalysisGenerator(studyId, service, payloadGenerator);
val numAnalysis = 10;
val sraMap = Maps.<String, SequencingReadAnalysis>newHashMap();
val vcaMap = Maps.<String, VariantCallAnalysis>newHashMap();
val expectedAnalyses = Sets.<Analysis>newHashSet();
for (int i = 1; i <= numAnalysis; i++) {
if (i % 2 == 0) {
val sra = analysisGenerator.createDefaultRandomSequencingReadAnalysis();
assertThat(sraMap.containsKey(sra.getAnalysisId())).isFalse();
sraMap.put(sra.getAnalysisId(), sra);
expectedAnalyses.add(sra);
} else {
val vca = analysisGenerator.createDefaultRandomVariantCallAnalysis();
assertThat(sraMap.containsKey(vca.getAnalysisId())).isFalse();
vcaMap.put(vca.getAnalysisId(), vca);
expectedAnalyses.add(vca);
}
}
assertThat(expectedAnalyses).hasSize(numAnalysis);
assertThat(sraMap.keySet().size() + vcaMap.keySet().size()).isEqualTo(numAnalysis);
val expectedVCAs = newHashSet(vcaMap.values());
val expectedSRAs = newHashSet(sraMap.values());
assertThat(expectedSRAs).hasSize(sraMap.keySet().size());
assertThat(expectedVCAs).hasSize(vcaMap.keySet().size());
val actualAnalyses = service.getAnalysis(studyId);
val actualSRAs = actualAnalyses.stream().filter(x -> resolveAnalysisType(x.getAnalysisType()) == SEQUENCING_READ).collect(toSet());
val actualVCAs = actualAnalyses.stream().filter(x -> resolveAnalysisType(x.getAnalysisType()) == VARIANT_CALL).collect(toSet());
assertThat(actualSRAs).hasSize(sraMap.keySet().size());
assertThat(actualVCAs).hasSize(vcaMap.keySet().size());
assertThat(actualSRAs).containsAll(expectedSRAs);
assertThat(actualVCAs).containsAll(expectedVCAs);
// Do a study-wide idSearch and verify the response effectively has the same
// number of results as the getAnalysis method
val searchedAnalyses = service.idSearch(studyId, createIdSearchRequest(null, null, null, null));
assertThat(searchedAnalyses).hasSameSizeAs(expectedAnalyses);
assertThat(searchedAnalyses).containsOnlyElementsOf(expectedAnalyses);
}
use of org.icgc.dcc.song.server.model.analysis.SequencingReadAnalysis in project SONG by overture-stack.
the class AnalysisServiceTest method testReadSequencingRead.
@Test
public void testReadSequencingRead() {
val json = getJsonStringFromClasspath("documents/sequencingread-read-test.json");
val analysisRaw = fromJson(json, SequencingReadAnalysis.class);
val analysisId = service.create(DEFAULT_STUDY_ID, analysisRaw, false);
val a = (SequencingReadAnalysis) service.read(analysisId);
// Asserting Analysis
assertThat(a.getAnalysisState()).isEqualTo("UNPUBLISHED");
assertThat(a.getAnalysisType()).isEqualTo("sequencingRead");
assertThat(a.getStudy()).isEqualTo(DEFAULT_STUDY_ID);
assertInfoKVPair(a, "description1", "description1 for this sequencingRead analysis an01");
assertInfoKVPair(a, "description2", "description2 for this sequencingRead analysis an01");
val experiment = a.getExperiment();
assertThat(experiment.getAnalysisId()).isEqualTo(analysisId);
assertThat(experiment.getLibraryStrategy()).isEqualTo("WXS");
assertThat(experiment.getPairedEnd()).isFalse();
assertThat(experiment.getInsertSize()).isEqualTo(92736);
assertThat(experiment.getAligned()).isTrue();
assertThat(experiment.getAlignmentTool()).isEqualTo("myCool Sequence ReadingTool");
assertThat(experiment.getReferenceGenome()).isEqualTo("someSeq Genome");
assertInfoKVPair(experiment, "extraExperimentInfo", "some more data for a sequencingRead experiment ex02");
val sampleMap = Maps.<String, CompositeEntity>newHashMap();
// Asserting Sample
assertThat(a.getSample()).hasSize(2);
val sample0 = a.getSample().get(0);
sampleMap.put(sample0.getSampleId(), sample0);
assertThat(sample0.getSampleSubmitterId()).isEqualTo("internal_sample_98024759826836_fr01");
assertThat(sample0.getSampleType()).isEqualTo("Total RNA");
assertInfoKVPair(sample0, "extraSampleInfo", "some more data for a sequencingRead sample_fr01");
val donor00 = sample0.getDonor();
assertThat(donor00.getStudyId()).isEqualTo(DEFAULT_STUDY_ID);
assertThat(donor00.getDonorGender()).isEqualTo("male");
assertThat(donor00.getDonorSubmitterId()).isEqualTo("internal_donor_123456789-00_fr01");
assertInfoKVPair(donor00, "extraDonorInfo", "some more data for a sequencingRead donor_fr01");
val specimen00 = sample0.getSpecimen();
assertThat(specimen00.getDonorId()).isEqualTo(donor00.getDonorId());
assertThat(specimen00.getSpecimenClass()).isEqualTo("Tumour");
assertThat(specimen00.getSpecimenType()).isEqualTo("Primary tumour - other");
assertThat(sample0.getSpecimenId()).isEqualTo(specimen00.getSpecimenId());
assertInfoKVPair(specimen00, "extraSpecimenInfo_0", "first for a sequencingRead specimen_fr01");
assertInfoKVPair(specimen00, "extraSpecimenInfo_1", "second data for a sequencingRead specimen_fr01");
val sample1 = a.getSample().get(1);
sampleMap.put(sample1.getSampleId(), sample1);
assertThat(sample1.getSampleSubmitterId()).isEqualTo("internal_sample_98024759826836_fr02");
assertThat(sample1.getSampleType()).isEqualTo("Total RNA");
assertInfoKVPair(sample1, "extraSampleInfo", "some more data for a sequencingRead sample_fr02");
val donor01 = sample1.getDonor();
assertThat(donor01.getStudyId()).isEqualTo(DEFAULT_STUDY_ID);
assertThat(donor01.getDonorGender()).isEqualTo("female");
assertThat(donor01.getDonorSubmitterId()).isEqualTo("internal_donor_123456789-00_fr02");
assertInfoKVPair(donor01, "extraDonorInfo_0", "first data for a sequencingRead donor_fr02");
assertInfoKVPair(donor01, "extraDonorInfo_1", "second data for a sequencingRead donor_fr02");
val specimen01 = sample1.getSpecimen();
assertThat(specimen01.getDonorId()).isEqualTo(donor01.getDonorId());
assertThat(specimen01.getSpecimenClass()).isEqualTo("Tumour");
assertThat(specimen01.getSpecimenType()).isEqualTo("Primary tumour - other");
assertThat(sample1.getSpecimenId()).isEqualTo(specimen01.getSpecimenId());
assertInfoKVPair(specimen01, "extraSpecimenInfo", "some more data for a sequencingRead specimen_fr02");
assertThat(a.getFile()).hasSize(3);
val file0 = a.getFile().get(0);
val file1 = a.getFile().get(1);
val file2 = a.getFile().get(2);
assertThat(file0.getAnalysisId()).isEqualTo(analysisId);
assertThat(file1.getAnalysisId()).isEqualTo(analysisId);
assertThat(file2.getAnalysisId()).isEqualTo(analysisId);
assertThat(file0.getStudyId()).isEqualTo(DEFAULT_STUDY_ID);
assertThat(file1.getStudyId()).isEqualTo(DEFAULT_STUDY_ID);
assertThat(file2.getStudyId()).isEqualTo(DEFAULT_STUDY_ID);
val fileName0 = "a3bc0998a-3521-43fd-fa10-a834f3874e46-fn1.MUSE_1-0rc-vcf.20170711.bam";
val fileName1 = "a3bc0998a-3521-43fd-fa10-a834f3874e46-fn2.MUSE_1-0rc-vcf.20170711.bam";
val fileName2 = "a3bc0998a-3521-43fd-fa10-a834f3874e46-fn3.MUSE_1-0rc-vcf.20170711.bam.bai";
val fileMap = Maps.<String, File>newHashMap();
for (val file : a.getFile()) {
fileMap.put(file.getFileName(), file);
if (file.getFileName().equals(fileName0)) {
assertThat(file.getFileName()).isEqualTo(fileName0);
assertThat(file.getFileSize()).isEqualTo(1212121);
assertThat(file.getFileMd5sum()).isEqualTo("e2324667df8085eddfe95742047e153f");
assertThat(file.getFileAccess()).isEqualTo("controlled");
assertThat(file.getFileType()).isEqualTo("BAM");
assertInfoKVPair(file, "extraFileInfo_0", "first data for sequencingRead file_fn1");
assertInfoKVPair(file, "extraFileInfo_1", "second data for sequencingRead file_fn1");
} else if (file.getFileName().equals(fileName1)) {
assertThat(file.getFileName()).isEqualTo(fileName1);
assertThat(file.getFileSize()).isEqualTo(34343);
assertThat(file.getFileMd5sum()).isEqualTo("8b5379a29aac642d6fe1808826bd9e49");
assertThat(file.getFileAccess()).isEqualTo("open");
assertThat(file.getFileType()).isEqualTo("BAM");
assertInfoKVPair(file, "extraFileInfo", "some more data for sequencingRead file_fn2");
} else if (file.getFileName().equals(fileName2)) {
assertThat(file.getFileName()).isEqualTo(fileName2);
assertThat(file.getFileSize()).isEqualTo(4840);
assertThat(file.getFileMd5sum()).isEqualTo("61da923f32863a9c5fa3d2a0e19bdee3");
assertThat(file.getFileAccess()).isEqualTo("open");
assertThat(file.getFileType()).isEqualTo("BAI");
assertInfoKVPair(file, "extraFileInfo", "some more data for sequencingRead file_fn3");
} else {
fail(format("the fileName %s is not recognized", file.getFileName()));
}
}
// Test the readFiles method
for (val file : service.readFiles(analysisId)) {
assertThat(fileMap).containsKeys(file.getFileName());
assertThat(file).isEqualTo(fileMap.get(file.getFileName()));
}
// Test readSample method
for (val compositeEntity : service.readSamples(analysisId)) {
assertThat(sampleMap).containsKeys(compositeEntity.getSampleId());
assertThat(compositeEntity).isEqualTo(sampleMap.get(compositeEntity.getSampleId()));
}
assertThat(service.readSequencingRead(analysisId)).isEqualTo(experiment);
}
use of org.icgc.dcc.song.server.model.analysis.SequencingReadAnalysis in project SONG by overture-stack.
the class SerializationTest method testSequencingReadAnalysisFromJson.
@Test
public void testSequencingReadAnalysisFromJson() throws IOException {
val json = readFile(FILEPATH + "sequencingRead.json");
val analysis = JsonUtils.fromJson(json, Analysis.class);
System.out.printf("*** Analysis object='%s'\n", analysis);
assertThat(analysis.getAnalysisType()).isEqualTo("sequencingRead");
assertThat(analysis.getFile().size()).isEqualTo(2);
assertThat(analysis.getSample().get(0).getDonor().getDonorSubmitterId()).isEqualTo("internal_donor_123456789-00");
assertThat(analysis).isInstanceOf(SequencingReadAnalysis.class);
val r = ((SequencingReadAnalysis) analysis).getExperiment();
assertThat(r.getLibraryStrategy()).isEqualTo("WXS");
assertThat(r.getInsertSize()).isEqualTo(900);
assertThat(r.getAlignmentTool()).isEqualTo("MUSE variant call pipeline");
}
Aggregations