Search in sources :

Example 1 with StudyGenerator

use of org.icgc.dcc.song.server.utils.StudyGenerator in project SONG by overture-stack.

the class ExportServiceTest method generateData.

/**
 * Generate {@code numStudies} studies and for each study generate {@code numAnalysisPerStudy} analyses, and put
 * everything in a map, where the keys are studyIds and the values are all the analyses for that study
 */
private Map<String, List<? extends Analysis>> generateData(Class<? extends Analysis> analysisClass, int numStudies, int numAnalysesPerStudy, boolean includeAnalysisId, boolean includeOtherIds) {
    val studyGenerator = createStudyGenerator(studyService, randomGenerator);
    val map = Maps.<String, List<? extends Analysis>>newHashMap();
    for (int s = 0; s < numStudies; s++) {
        val studyId = studyGenerator.createRandomStudy();
        val analysisGenerator = createAnalysisGenerator(studyId, analysisService, randomGenerator);
        val analyses = range(0, numAnalysesPerStudy).boxed().map(x -> analysisGenerator.createDefaultRandomAnalysis(analysisClass)).peek(x -> massageAnalysisInplace(x, includeAnalysisId, includeOtherIds)).collect(toImmutableList());
        map.put(studyId, analyses);
    }
    return ImmutableMap.copyOf(map);
}
Also used : lombok.val(lombok.val) File(org.icgc.dcc.song.server.model.entity.File) SneakyThrows(lombok.SneakyThrows) IntStream.range(java.util.stream.IntStream.range) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Autowired(org.springframework.beans.factory.annotation.Autowired) SequencingReadAnalysis(org.icgc.dcc.song.server.model.analysis.SequencingReadAnalysis) ActiveProfiles(org.springframework.test.context.ActiveProfiles) TestFiles.assertSetsMatch(org.icgc.dcc.song.server.utils.TestFiles.assertSetsMatch) AnalysisTypes.resolveAnalysisType(org.icgc.dcc.song.server.model.enums.AnalysisTypes.resolveAnalysisType) TestExecutionListeners(org.springframework.test.context.TestExecutionListeners) VariantCallAnalysis(org.icgc.dcc.song.server.model.analysis.VariantCallAnalysis) Map(java.util.Map) JsonNode(com.fasterxml.jackson.databind.JsonNode) ExportService(org.icgc.dcc.song.server.service.export.ExportService) SpringRunner(org.springframework.test.context.junit4.SpringRunner) Collectors.toSet(java.util.stream.Collectors.toSet) RandomGenerator.createRandomGenerator(org.icgc.dcc.song.core.utils.RandomGenerator.createRandomGenerator) Reductions.groupUnique(org.icgc.dcc.song.core.utils.Reductions.groupUnique) ImmutableMap(com.google.common.collect.ImmutableMap) Specimen(org.icgc.dcc.song.server.model.entity.Specimen) Collection(java.util.Collection) Set(java.util.Set) JsonUtils(org.icgc.dcc.song.core.utils.JsonUtils) Slf4j(lombok.extern.slf4j.Slf4j) List(java.util.List) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) JsonUtils.fromJson(org.icgc.dcc.song.core.utils.JsonUtils.fromJson) RandomGenerator(org.icgc.dcc.song.core.utils.RandomGenerator) RunWith(org.junit.runner.RunWith) SEQUENCING_READ(org.icgc.dcc.song.server.model.enums.AnalysisTypes.SEQUENCING_READ) Analysis(org.icgc.dcc.song.server.model.analysis.Analysis) StudyGenerator(org.icgc.dcc.song.server.utils.StudyGenerator) AnalysisGenerator.createAnalysisGenerator(org.icgc.dcc.song.server.utils.AnalysisGenerator.createAnalysisGenerator) DependencyInjectionTestExecutionListener(org.springframework.test.context.support.DependencyInjectionTestExecutionListener) Before(org.junit.Before) Donor(org.icgc.dcc.song.server.model.entity.Donor) VARIANT_CALL(org.icgc.dcc.song.server.model.enums.AnalysisTypes.VARIANT_CALL) JsonUtils.toJson(org.icgc.dcc.song.core.utils.JsonUtils.toJson) lombok.val(lombok.val) Test(org.junit.Test) Maps(com.google.common.collect.Maps) CompositeEntity(org.icgc.dcc.song.server.model.entity.composites.CompositeEntity) UploadStates.resolveState(org.icgc.dcc.song.server.model.enums.UploadStates.resolveState) AnalysisRepository(org.icgc.dcc.song.server.repository.AnalysisRepository) EMPTY_STRING(org.icgc.dcc.song.server.utils.TestFiles.EMPTY_STRING) Collectors.toImmutableList(org.icgc.dcc.common.core.util.stream.Collectors.toImmutableList) StudyGenerator.createStudyGenerator(org.icgc.dcc.song.server.utils.StudyGenerator.createStudyGenerator) UploadStates(org.icgc.dcc.song.server.model.enums.UploadStates) ResponseEntity(org.springframework.http.ResponseEntity) Sample(org.icgc.dcc.song.server.model.entity.Sample) SequencingReadAnalysis(org.icgc.dcc.song.server.model.analysis.SequencingReadAnalysis) VariantCallAnalysis(org.icgc.dcc.song.server.model.analysis.VariantCallAnalysis) Analysis(org.icgc.dcc.song.server.model.analysis.Analysis) List(java.util.List) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) Collectors.toImmutableList(org.icgc.dcc.common.core.util.stream.Collectors.toImmutableList)

Aggregations

JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)1 Maps (com.google.common.collect.Maps)1 Collection (java.util.Collection)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 Collectors.toSet (java.util.stream.Collectors.toSet)1 IntStream.range (java.util.stream.IntStream.range)1 SneakyThrows (lombok.SneakyThrows)1 Slf4j (lombok.extern.slf4j.Slf4j)1 lombok.val (lombok.val)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Collectors.toImmutableList (org.icgc.dcc.common.core.util.stream.Collectors.toImmutableList)1 JsonUtils (org.icgc.dcc.song.core.utils.JsonUtils)1 JsonUtils.fromJson (org.icgc.dcc.song.core.utils.JsonUtils.fromJson)1 JsonUtils.toJson (org.icgc.dcc.song.core.utils.JsonUtils.toJson)1 RandomGenerator (org.icgc.dcc.song.core.utils.RandomGenerator)1 RandomGenerator.createRandomGenerator (org.icgc.dcc.song.core.utils.RandomGenerator.createRandomGenerator)1