use of org.icgc.dcc.song.server.utils.AnalysisGenerator 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);
}
Aggregations