use of org.icgc.dcc.song.server.model.analysis.VariantCallAnalysis in project SONG by overture-stack.
the class AnalysisServiceTest method testReadVariantCall.
@Test
public void testReadVariantCall() {
val json = getJsonStringFromClasspath("documents/variantcall-read-test.json");
val analysisRaw = fromJson(json, VariantCallAnalysis.class);
val analysisId = service.create(DEFAULT_STUDY_ID, analysisRaw, false);
val a = (VariantCallAnalysis) service.read(analysisId);
// Asserting Analysis
assertThat(a.getAnalysisState()).isEqualTo("UNPUBLISHED");
assertThat(a.getAnalysisType()).isEqualTo("variantCall");
assertThat(a.getStudy()).isEqualTo(DEFAULT_STUDY_ID);
assertInfoKVPair(a, "description1", "description1 for this variantCall analysis an01");
assertInfoKVPair(a, "description2", "description2 for this variantCall analysis an01");
val experiment = a.getExperiment();
assertThat(experiment.getAnalysisId()).isEqualTo(analysisId);
assertThat(experiment.getVariantCallingTool()).isEqualTo("silver bullet ex01");
assertThat(experiment.getMatchedNormalSampleSubmitterId()).isEqualTo("sample x24-11a");
assertInfoKVPair(experiment, "extraExperimentInfo", "some more data for a variantCall experiment ex01");
// Asserting Sample
assertThat(a.getSample()).hasSize(2);
val sample0 = a.getSample().get(0);
assertThat(sample0.getSampleSubmitterId()).isEqualTo("internal_sample_98024759826836_fs01");
assertThat(sample0.getSampleType()).isEqualTo("Total RNA");
assertInfoKVPair(sample0, "extraSampleInfo", "some more data for a variantCall sample_fs01");
val donor00 = sample0.getDonor();
assertThat(donor00.getStudyId()).isEqualTo(DEFAULT_STUDY_ID);
assertThat(donor00.getDonorGender()).isEqualTo("male");
assertThat(donor00.getDonorSubmitterId()).isEqualTo("internal_donor_123456789-00_fs01");
assertInfoKVPair(donor00, "extraDonorInfo", "some more data for a variantCall donor_fs01");
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 variantCall specimen_fs01");
assertInfoKVPair(specimen00, "extraSpecimenInfo_1", "second data for a variantCall specimen_fs01");
val sample1 = a.getSample().get(1);
assertThat(sample1.getSampleSubmitterId()).isEqualTo("internal_sample_98024759826836_fs02");
assertThat(sample1.getSampleType()).isEqualTo("Total RNA");
assertInfoKVPair(sample1, "extraSampleInfo", "some more data for a variantCall sample_fs02");
val donor01 = sample1.getDonor();
assertThat(donor01.getStudyId()).isEqualTo(DEFAULT_STUDY_ID);
assertThat(donor01.getDonorGender()).isEqualTo("female");
assertThat(donor01.getDonorSubmitterId()).isEqualTo("internal_donor_123456789-00_fs02");
assertInfoKVPair(donor01, "extraDonorInfo_0", "first data for a variantCall donor_fs02");
assertInfoKVPair(donor01, "extraDonorInfo_1", "second data for a variantCall donor_fs02");
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 variantCall specimen_fs02");
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.somatic.snv_mnv.vcf.gz";
val fileName1 = "a3bc0998a-3521-43fd-fa10-a834f3874e46-fn2.MUSE_1-0rc-vcf.20170711.somatic.snv_mnv.vcf.gz";
val fileName2 = "a3bc0998a-3521-43fd-fa10-a834f3874e46-fn3.MUSE_1-0rc-vcf.20170711.somatic.snv_mnv.vcf.gz.idx";
for (val file : a.getFile()) {
if (file.getFileName().equals(fileName0)) {
assertThat(file.getFileName()).isEqualTo(fileName0);
assertThat(file.getFileSize()).isEqualTo(376953);
assertThat(file.getFileMd5sum()).isEqualTo("652b2e2b7133229a89650de27ad7fc41");
assertThat(file.getFileAccess()).isEqualTo("controlled");
assertThat(file.getFileType()).isEqualTo("VCF");
assertInfoKVPair(file, "extraFileInfo_0", "first data for variantCall file_fn1");
assertInfoKVPair(file, "extraFileInfo_1", "second data for variantCall file_fn1");
} else if (file.getFileName().equals(fileName1)) {
assertThat(file.getFileName()).isEqualTo(fileName1);
assertThat(file.getFileSize()).isEqualTo(983820);
assertThat(file.getFileMd5sum()).isEqualTo("b8b743a499e461922accad58fdbf25d2");
assertThat(file.getFileAccess()).isEqualTo("open");
assertThat(file.getFileType()).isEqualTo("VCF");
assertInfoKVPair(file, "extraFileInfo", "some more data for variantCall file_fn2");
} else if (file.getFileName().equals(fileName2)) {
assertThat(file.getFileName()).isEqualTo(fileName2);
assertThat(file.getFileSize()).isEqualTo(4840);
assertThat(file.getFileMd5sum()).isEqualTo("2b80298c2f312df7db482105053f889b");
assertThat(file.getFileAccess()).isEqualTo("open");
assertThat(file.getFileType()).isEqualTo("IDX");
assertInfoKVPair(file, "extraFileInfo", "some more data for variantCall file_fn3");
} else {
fail(format("the fileName %s is not recognized", file.getFileName()));
}
}
}
use of org.icgc.dcc.song.server.model.analysis.VariantCallAnalysis in project SONG by overture-stack.
the class AnalysisServiceTest method testCreateAndUpdateVariantCall.
@Test
public void testCreateAndUpdateVariantCall() {
val created = analysisGenerator.createRandomAnalysis(VariantCallAnalysis.class, "documents/variantcall-valid-1.json");
val analysisId = created.getAnalysisId();
assertThat(created.getAnalysisId()).isEqualTo(analysisId);
assertThat(created.getAnalysisState()).isEqualTo(UNPUBLISHED.toString());
assertThat(created.getAnalysisType()).isEqualTo("variantCall");
assertThat(created.getSample().size()).isEqualTo(1);
val sample = created.getSample().get(0);
val experiment = ((VariantCallAnalysis) created).getExperiment();
assertThat(experiment).isNotNull();
assertThat(experiment.getVariantCallingTool()).isEqualTo("silver bullet");
assertThat(experiment.getInfoAsString()).isEqualTo(JsonUtils.fromSingleQuoted("{\"extraInfo\":\"this is extra info\"}"));
// test update
val change = "GoldenHammer";
experiment.setVariantCallingTool(change);
service.updateAnalysis(DEFAULT_STUDY_ID, created);
val gotBack = service.read(analysisId);
val experiment2 = ((VariantCallAnalysis) gotBack).getExperiment();
assertThat(experiment2.getVariantCallingTool()).isEqualTo(change);
log.info(format("Created '%s'", toJson(created)));
}
use of org.icgc.dcc.song.server.model.analysis.VariantCallAnalysis in project SONG by overture-stack.
the class EntityTest method testVariantCallAnalysis.
@Test
public void testVariantCallAnalysis() {
val v1 = VariantCall.create("a1", "c1", "b1");
val v2 = VariantCall.create("a2", "c2", "b2");
val donor1 = Donor.create("myDonor1", "myDonorSubmitter1", DEFAULT_STUDY_ID, "male");
val donor2 = Donor.create("myDonor2", "myDonorSubmitter2", DEFAULT_STUDY_ID, "female");
val specimen1 = Specimen.create("mySpecimen1", "mySpecimenSubmitter1", "myDonor1", SPECIMEN_CLASSES.get(2), SPECIMEN_TYPES.get(2));
val specimen2 = Specimen.create("mySpecimen2", "mySpecimenSubmitter2", "myDonor2", SPECIMEN_CLASSES.get(1), SPECIMEN_TYPES.get(1));
val sample1 = Sample.create("mySample1", "mySubmitterSample1", "mySpecimen1", SAMPLE_TYPES.get(2));
val sample2 = Sample.create("mySample2", "mySubmitterSample2", "mySpecimen2", SAMPLE_TYPES.get(3));
val compositeEntity11 = CompositeEntity.create(sample1);
compositeEntity11.setDonor(donor1);
compositeEntity11.setSpecimen(specimen2);
val compositeEntity12 = CompositeEntity.create(sample1);
compositeEntity12.setDonor(donor2);
compositeEntity12.setSpecimen(specimen1);
val compositeGroup1 = newArrayList(compositeEntity11, compositeEntity12);
val compositeEntity21 = CompositeEntity.create(sample2);
compositeEntity21.setDonor(donor1);
compositeEntity21.setSpecimen(specimen2);
val compositeEntity22 = CompositeEntity.create(sample2);
compositeEntity22.setDonor(donor2);
compositeEntity22.setSpecimen(specimen1);
val compositeGroup2 = newArrayList(compositeEntity21, compositeEntity22);
val file11 = File.create("d11", "a11", "c11", "e11", 113L, FILE_TYPES.get(0), "b11", CONTROLLED);
val file12 = File.create("d12", "a12", "c12", "e12", 114L, FILE_TYPES.get(0), "b12", CONTROLLED);
val fileGroup1 = newArrayList(file11, file12);
val file21 = File.create("d21", "a21", "c21", "e21", 213L, FILE_TYPES.get(1), "b21", CONTROLLED);
val file22 = File.create("d22", "a22", "c22", "e22", 224L, FILE_TYPES.get(1), "b22", CONTROLLED);
val fileGroup2 = newArrayList(file21, file22);
val a1 = new VariantCallAnalysis();
a1.setAnalysisId("a1");
a1.setAnalysisState(PUBLISHED.toString());
a1.setStudy("b1");
val a1_same = new VariantCallAnalysis();
a1_same.setAnalysisId("a1");
a1_same.setAnalysisState(PUBLISHED.toString());
a1_same.setStudy("b1");
assertEntitiesEqual(a1, a1_same, true);
val a2 = new VariantCallAnalysis();
a2.setAnalysisId("a2");
a2.setAnalysisState(UNPUBLISHED.toString());
a2.setStudy("b2");
val a2_same = new VariantCallAnalysis();
a2_same.setAnalysisId("a2");
a2_same.setAnalysisState(UNPUBLISHED.toString());
a2_same.setStudy("b2");
assertEntitiesEqual(a2, a2_same, true);
// 0000 - matchingSamples=0, matchingFile=0, matchingExperiment=0, matchingSelf=0
a1.setExperiment(v1);
a1.setFile(fileGroup1);
a1.setSample(compositeGroup1);
a2.setExperiment(v2);
a2.setFile(fileGroup2);
a2.setSample(compositeGroup2);
assertEntitiesNotEqual(a1, a2);
// 0001 - matchingSamples=0, matchingFile=0, matchingExperiment=0, matchingSelf=1
a1.setExperiment(v1);
a1.setFile(fileGroup1);
a1.setSample(compositeGroup1);
a1_same.setExperiment(v2);
a1_same.setFile(fileGroup2);
a1_same.setSample(compositeGroup2);
assertEntitiesNotEqual(a1, a2);
// 0010 - matchingSamples=0, matchingFile=0, matchingExperiment=1, matchingSelf=0
a1.setExperiment(v1);
a1.setFile(fileGroup1);
a1.setSample(compositeGroup1);
a2.setExperiment(v1);
a2.setFile(fileGroup2);
a2.setSample(compositeGroup2);
assertEntitiesNotEqual(a1, a2);
// 0011 - matchingSamples=0, matchingFile=0, matchingExperiment=1, matchingSelf=1
a1.setExperiment(v1);
a1.setFile(fileGroup1);
a1.setSample(compositeGroup1);
a1_same.setExperiment(v1);
a1_same.setFile(fileGroup2);
a1_same.setSample(compositeGroup2);
assertEntitiesNotEqual(a1, a2);
// 0100 - matchingSamples=0, matchingFile=1, matchingExperiment=0, matchingSelf=0
a1.setExperiment(v1);
a1.setFile(fileGroup1);
a1.setSample(compositeGroup1);
a2.setExperiment(v2);
a2.setFile(fileGroup1);
a2.setSample(compositeGroup2);
assertEntitiesNotEqual(a1, a2);
// 0101 - matchingSamples=0, matchingFile=1, matchingExperiment=0, matchingSelf=1
a1.setExperiment(v1);
a1.setFile(fileGroup1);
a1.setSample(compositeGroup1);
a1_same.setExperiment(v2);
a1_same.setFile(fileGroup1);
a1_same.setSample(compositeGroup2);
assertEntitiesNotEqual(a1, a2);
// 0110 - matchingSamples=0, matchingFile=1, matchingExperiment=1, matchingSelf=0
a1.setExperiment(v1);
a1.setFile(fileGroup1);
a1.setSample(compositeGroup1);
a2.setExperiment(v1);
a2.setFile(fileGroup1);
a2.setSample(compositeGroup2);
assertEntitiesNotEqual(a1, a2);
// 0111 - matchingSamples=0, matchingFile=1, matchingExperiment=1, matchingSelf=1
a1.setExperiment(v1);
a1.setFile(fileGroup1);
a1.setSample(compositeGroup1);
a1_same.setExperiment(v1);
a1_same.setFile(fileGroup1);
a1_same.setSample(compositeGroup2);
assertEntitiesNotEqual(a1, a2);
// 1000 - matchingSamples=1, matchingFile=0, matchingExperiment=0, matchingSelf=0
a1.setExperiment(v1);
a1.setFile(fileGroup1);
a1.setSample(compositeGroup1);
a2.setExperiment(v2);
a2.setFile(fileGroup2);
a2.setSample(compositeGroup1);
assertEntitiesNotEqual(a1, a2);
// 1001 - matchingSamples=1, matchingFile=0, matchingExperiment=0, matchingSelf=1
a1.setExperiment(v1);
a1.setFile(fileGroup1);
a1.setSample(compositeGroup1);
a1_same.setExperiment(v2);
a1_same.setFile(fileGroup2);
a1_same.setSample(compositeGroup1);
assertEntitiesNotEqual(a1, a2);
// 1010 - matchingSamples=1, matchingFile=0, matchingExperiment=1, matchingSelf=0
a1.setExperiment(v1);
a1.setFile(fileGroup1);
a1.setSample(compositeGroup1);
a2.setExperiment(v1);
a2.setFile(fileGroup2);
a2.setSample(compositeGroup1);
assertEntitiesNotEqual(a1, a2);
// 1011 - matchingSamples=1, matchingFile=0, matchingExperiment=1, matchingSelf=1
a1.setExperiment(v1);
a1.setFile(fileGroup1);
a1.setSample(compositeGroup1);
a1_same.setExperiment(v1);
a1_same.setFile(fileGroup2);
a1_same.setSample(compositeGroup1);
assertEntitiesNotEqual(a1, a2);
// 1100 - matchingSamples=1, matchingFile=1, matchingExperiment=0, matchingSelf=0
a1.setExperiment(v1);
a1.setFile(fileGroup1);
a1.setSample(compositeGroup1);
a2.setExperiment(v2);
a2.setFile(fileGroup1);
a2.setSample(compositeGroup1);
assertEntitiesNotEqual(a1, a2);
// 1101 - matchingSamples=1, matchingFile=1, matchingExperiment=0, matchingSelf=1
a1.setExperiment(v1);
a1.setFile(fileGroup1);
a1.setSample(compositeGroup1);
a1_same.setExperiment(v2);
a1_same.setFile(fileGroup1);
a1_same.setSample(compositeGroup1);
assertEntitiesNotEqual(a1, a2);
// 1110 - matchingSamples=1, matchingFile=1, matchingExperiment=1, matchingSelf=0
a1.setExperiment(v1);
a1.setFile(fileGroup1);
a1.setSample(compositeGroup1);
a2.setExperiment(v1);
a2.setFile(fileGroup1);
a2.setSample(compositeGroup1);
assertEntitiesNotEqual(a1, a2);
// 1111 - matchingSamples=1, matchingFile=1, matchingExperiment=1, matchingSelf=1
a1.setExperiment(v1);
a1.setFile(fileGroup1);
a1.setSample(compositeGroup1);
a1_same.setExperiment(v1);
a1_same.setFile(fileGroup1);
a1_same.setSample(compositeGroup1);
assertEntitiesEqual(a1, a1_same, true);
a1.setInfo("key1", "f5c9381090a53c54358feb2ba5b7a3d7");
a1_same.setInfo("key2", "6329334b-dcd5-53c8-98fd-9812ac386d30");
assertEntitiesNotEqual(a1, a1_same);
}
use of org.icgc.dcc.song.server.model.analysis.VariantCallAnalysis in project SONG by overture-stack.
the class SerializationTest method testVariantCallAnalysisFromJson.
@Test
public void testVariantCallAnalysisFromJson() throws IOException {
val json = readFile(FILEPATH + "variantCall.json");
val analysis = JsonUtils.fromJson(json, Analysis.class);
System.out.printf("*** Analysis object='%s'\n", analysis);
assertThat(analysis.getAnalysisType()).isEqualTo("variantCall");
assertThat(analysis).isInstanceOf(VariantCallAnalysis.class);
VariantCallAnalysis v = (VariantCallAnalysis) analysis;
System.out.printf("VariantCall object='%s'\n", v);
assertThat(analysis.getFile().size()).isEqualTo(2);
assertThat(analysis.getSample().get(0).getDonor().getDonorSubmitterId()).isEqualTo("internal_donor_123456789-00");
}
use of org.icgc.dcc.song.server.model.analysis.VariantCallAnalysis in project SONG by overture-stack.
the class AnalysisService method create.
public String create(String studyId, Analysis a, boolean ignoreAnalysisIdCollisions) {
studyService.checkStudyExist(studyId);
val candidateAnalysisId = a.getAnalysisId();
val id = idService.resolveAnalysisId(candidateAnalysisId, ignoreAnalysisIdCollisions);
/**
* [Summary]: Guard from misleading response
* [Details]: If user attempts to save an uploadId a second time, an error is thrown.
* This restricts the user from doing updates to the uploadId after saving, and then
* re-saving. The following edge case explains why an error is thrown instead of returning
* the existing analysisId:
* - user does upload1 which defines the analysisId field as AN123
* - user does save for upload1 and gets analysisId AN123
* - user realizes a mistake, and corrects upload1 which has the analysisId AN123 as explicitly stated
* - user re-uploads upload1, returning the same uploadId since the analysisId has not changed
* - user re-saves upload1 and gets the existing analysisId AN123 back.
* - user thinks they updated the analysis with the re-upload.
*/
checkServer(!doesAnalysisIdExist(id), this.getClass(), DUPLICATE_ANALYSIS_ATTEMPT, "Attempted to create a duplicate analysis. Please " + "delete the analysis for analysisId '%s' and re-save", id);
a.setAnalysisId(id);
a.setStudy(studyId);
val status = repository.createAnalysis(a);
checkServer(status == 1, getClass(), ANALYSIS_REPOSITORY_CREATE_RECORD, "Unable to create analysis with analysisId '%s' to repository: %s", a.getAnalysisId(), a);
analysisInfoService.create(id, a.getInfoAsString());
saveCompositeEntities(studyId, id, a.getSample());
saveFiles(id, studyId, a.getFile());
if (a instanceof SequencingReadAnalysis) {
val experiment = ((SequencingReadAnalysis) a).getExperiment();
createSequencingRead(id, experiment);
} else if (a instanceof VariantCallAnalysis) {
val experiment = ((VariantCallAnalysis) a).getExperiment();
createVariantCall(id, experiment);
} else {
// shouldn't be possible if we validated our JSON first...
throw new IllegalArgumentException("Invalid analysis type");
}
sender.send(String.format("{\"analysis_id\": %s, \"state\": \"UNPUBLISHED\"}", id));
return id;
}
Aggregations