Search in sources :

Example 6 with VariantCallAnalysis

use of org.icgc.dcc.song.server.model.analysis.VariantCallAnalysis 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;
}
Also used : lombok.val(lombok.val) SequencingReadAnalysis(org.icgc.dcc.song.server.model.analysis.SequencingReadAnalysis) VariantCallAnalysis(org.icgc.dcc.song.server.model.analysis.VariantCallAnalysis)

Example 7 with VariantCallAnalysis

use of org.icgc.dcc.song.server.model.analysis.VariantCallAnalysis 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);
}
Also used : lombok.val(lombok.val) ANALYSIS_ID_NOT_FOUND(org.icgc.dcc.song.core.exceptions.ServerErrors.ANALYSIS_ID_NOT_FOUND) ExistenceService.createExistenceService(org.icgc.dcc.song.server.service.ExistenceService.createExistenceService) File(org.icgc.dcc.song.server.model.entity.File) 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) DUPLICATE_ANALYSIS_ATTEMPT(org.icgc.dcc.song.core.exceptions.ServerErrors.DUPLICATE_ANALYSIS_ATTEMPT) AnalysisTypes.resolveAnalysisType(org.icgc.dcc.song.server.model.enums.AnalysisTypes.resolveAnalysisType) TestExecutionListeners(org.springframework.test.context.TestExecutionListeners) Study(org.icgc.dcc.song.server.model.entity.Study) PayloadGenerator.createPayloadGenerator(org.icgc.dcc.song.server.utils.PayloadGenerator.createPayloadGenerator) VariantCallAnalysis(org.icgc.dcc.song.server.model.analysis.VariantCallAnalysis) Sets.newHashSet(com.google.common.collect.Sets.newHashSet) SpringRunner(org.springframework.test.context.junit4.SpringRunner) SongErrorAssertions.assertSongError(org.icgc.dcc.song.core.testing.SongErrorAssertions.assertSongError) Collectors.toSet(java.util.stream.Collectors.toSet) STUDY_ID_DOES_NOT_EXIST(org.icgc.dcc.song.core.exceptions.ServerErrors.STUDY_ID_DOES_NOT_EXIST) ANALYSIS_MISSING_FILES(org.icgc.dcc.song.core.exceptions.ServerErrors.ANALYSIS_MISSING_FILES) RandomGenerator.createRandomGenerator(org.icgc.dcc.song.core.utils.RandomGenerator.createRandomGenerator) WireMock.aResponse(com.github.tomakehurst.wiremock.client.WireMock.aResponse) TestFiles.assertInfoKVPair(org.icgc.dcc.song.server.utils.TestFiles.assertInfoKVPair) Sets(com.google.common.collect.Sets) String.format(java.lang.String.format) JsonUtils(org.icgc.dcc.song.core.utils.JsonUtils) Slf4j(lombok.extern.slf4j.Slf4j) Assertions.fail(org.assertj.core.api.Assertions.fail) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) ANALYSIS_MISSING_SAMPLES(org.icgc.dcc.song.core.exceptions.ServerErrors.ANALYSIS_MISSING_SAMPLES) JsonUtils.fromJson(org.icgc.dcc.song.core.utils.JsonUtils.fromJson) RandomGenerator(org.icgc.dcc.song.core.utils.RandomGenerator) IdSearchRequest.createIdSearchRequest(org.icgc.dcc.song.server.repository.search.IdSearchRequest.createIdSearchRequest) 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) ArrayList(java.util.ArrayList) WireMockRule(com.github.tomakehurst.wiremock.junit.WireMockRule) AnalysisGenerator.createAnalysisGenerator(org.icgc.dcc.song.server.utils.AnalysisGenerator.createAnalysisGenerator) AnalysisGenerator(org.icgc.dcc.song.server.utils.AnalysisGenerator) DependencyInjectionTestExecutionListener(org.springframework.test.context.support.DependencyInjectionTestExecutionListener) UNPUBLISHED_FILE_IDS(org.icgc.dcc.song.core.exceptions.ServerErrors.UNPUBLISHED_FILE_IDS) Before(org.junit.Before) WireMock.get(com.github.tomakehurst.wiremock.client.WireMock.get) 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) WireMockConfiguration.options(com.github.tomakehurst.wiremock.core.WireMockConfiguration.options) ReflectionTestUtils(org.springframework.test.util.ReflectionTestUtils) Test(org.junit.Test) Maps(com.google.common.collect.Maps) CompositeEntity(org.icgc.dcc.song.server.model.entity.composites.CompositeEntity) WireMock.urlMatching(com.github.tomakehurst.wiremock.client.WireMock.urlMatching) UNPUBLISHED(org.icgc.dcc.song.server.model.enums.AnalysisStates.UNPUBLISHED) TestFiles.getJsonStringFromClasspath(org.icgc.dcc.song.server.utils.TestFiles.getJsonStringFromClasspath) AnalysisRepository(org.icgc.dcc.song.server.repository.AnalysisRepository) SEQUENCING_READ_NOT_FOUND(org.icgc.dcc.song.core.exceptions.ServerErrors.SEQUENCING_READ_NOT_FOUND) PayloadGenerator(org.icgc.dcc.song.server.utils.PayloadGenerator) Rule(org.junit.Rule) Metadata(org.icgc.dcc.song.server.model.Metadata) SampleRepository(org.icgc.dcc.song.server.repository.SampleRepository) VARIANT_CALL_NOT_FOUND(org.icgc.dcc.song.core.exceptions.ServerErrors.VARIANT_CALL_NOT_FOUND) StudyGenerator.createStudyGenerator(org.icgc.dcc.song.server.utils.StudyGenerator.createStudyGenerator) RetryTemplate(org.springframework.retry.support.RetryTemplate) OK(org.springframework.http.HttpStatus.OK) Sample(org.icgc.dcc.song.server.model.entity.Sample) SequencingReadAnalysis(org.icgc.dcc.song.server.model.analysis.SequencingReadAnalysis) 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) VariantCallAnalysis(org.icgc.dcc.song.server.model.analysis.VariantCallAnalysis) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test)

Example 8 with VariantCallAnalysis

use of org.icgc.dcc.song.server.model.analysis.VariantCallAnalysis in project SONG by overture-stack.

the class DeserializationTest method testVariantCallDeserialization.

@Test
public void testVariantCallDeserialization() {
    val a1 = fromJson(TestFiles.getJsonNodeFromClasspath("documents/deserialization/variantcall-deserialize1.json"), Analysis.class);
    val sa1 = ((VariantCallAnalysis) a1).getExperiment();
    assertThat(sa1.getAnalysisId()).isEmpty();
    assertThat(sa1.getMatchedNormalSampleSubmitterId()).isNull();
    assertThat(sa1.getVariantCallingTool()).isNull();
    assertThat(sa1.getInfo().path("random").isNull()).isTrue();
    val a2 = fromJson(TestFiles.getJsonNodeFromClasspath("documents/deserialization/variantcall-deserialize2.json"), Analysis.class);
    val sa2 = ((VariantCallAnalysis) a2).getExperiment();
    assertThat(sa2.getAnalysisId()).isEmpty();
    assertThat(sa2.getMatchedNormalSampleSubmitterId()).isNull();
    assertThat(sa2.getVariantCallingTool()).isNull();
}
Also used : lombok.val(lombok.val) VariantCallAnalysis(org.icgc.dcc.song.server.model.analysis.VariantCallAnalysis) Test(org.junit.Test)

Example 9 with VariantCallAnalysis

use of org.icgc.dcc.song.server.model.analysis.VariantCallAnalysis in project SONG by overture-stack.

the class AnalysisService method updateAnalysis.

public ResponseEntity<String> updateAnalysis(String studyId, Analysis analysis) {
    val id = analysis.getAnalysisId();
    repository.deleteCompositeEntities(id);
    saveCompositeEntities(studyId, id, analysis.getSample());
    repository.deleteFiles(id);
    analysis.getFile().forEach(f -> fileInfoService.delete(f.getObjectId()));
    saveFiles(id, studyId, analysis.getFile());
    analysisInfoService.update(id, analysis.getInfoAsString());
    if (analysis instanceof SequencingReadAnalysis) {
        val experiment = ((SequencingReadAnalysis) analysis).getExperiment();
        updateSequencingRead(id, experiment);
    } else if (analysis instanceof VariantCallAnalysis) {
        val experiment = ((VariantCallAnalysis) analysis).getExperiment();
        updateVariantCall(id, experiment);
    }
    return ok("AnalysisId %s was updated successfully", analysis.getAnalysisId());
}
Also used : lombok.val(lombok.val) SequencingReadAnalysis(org.icgc.dcc.song.server.model.analysis.SequencingReadAnalysis) VariantCallAnalysis(org.icgc.dcc.song.server.model.analysis.VariantCallAnalysis)

Example 10 with VariantCallAnalysis

use of org.icgc.dcc.song.server.model.analysis.VariantCallAnalysis in project SONG by overture-stack.

the class AnalysisConverter method buildVariantCallAnalysis.

private static VariantCallAnalysis buildVariantCallAnalysis(VariantCallAggregate variantCallAggregate) {
    val analysisType = AnalysisTypes.resolve(variantCallAggregate.getType());
    checkState(analysisType == VARIANT_CALL, "The input VariantCallAggregate [%s] is NOT of analysisType [%s]", variantCallAggregate, VARIANT_CALL.getAnalysisTypeName());
    val variantCallAnalysis = new VariantCallAnalysis();
    val analysisId = variantCallAggregate.getAnalysisId();
    variantCallAnalysis.setAnalysisId(analysisId);
    variantCallAnalysis.setAnalysisState(PUBLISHED.toString());
    variantCallAnalysis.setStudy(variantCallAggregate.getStudyId());
    variantCallAnalysis.setInfo(NA);
    val variantCallExperiment = VariantCall.create(analysisId, variantCallAggregate.getVariantCallingTool(), variantCallAggregate.getMatchedNormalSampleSubmitterId());
    variantCallAnalysis.setExperiment(variantCallExperiment);
    return variantCallAnalysis;
}
Also used : lombok.val(lombok.val) VariantCallAnalysis(org.icgc.dcc.song.server.model.analysis.VariantCallAnalysis)

Aggregations

lombok.val (lombok.val)10 VariantCallAnalysis (org.icgc.dcc.song.server.model.analysis.VariantCallAnalysis)10 Test (org.junit.Test)6 SequencingReadAnalysis (org.icgc.dcc.song.server.model.analysis.SequencingReadAnalysis)4 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)2 WireMock.aResponse (com.github.tomakehurst.wiremock.client.WireMock.aResponse)1 WireMock.get (com.github.tomakehurst.wiremock.client.WireMock.get)1 WireMock.urlMatching (com.github.tomakehurst.wiremock.client.WireMock.urlMatching)1 WireMockConfiguration.options (com.github.tomakehurst.wiremock.core.WireMockConfiguration.options)1 WireMockRule (com.github.tomakehurst.wiremock.junit.WireMockRule)1 Maps (com.google.common.collect.Maps)1 Sets (com.google.common.collect.Sets)1 Sets.newHashSet (com.google.common.collect.Sets.newHashSet)1 String.format (java.lang.String.format)1 ArrayList (java.util.ArrayList)1 Collectors.toSet (java.util.stream.Collectors.toSet)1 Slf4j (lombok.extern.slf4j.Slf4j)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Assertions.fail (org.assertj.core.api.Assertions.fail)1 ANALYSIS_ID_NOT_FOUND (org.icgc.dcc.song.core.exceptions.ServerErrors.ANALYSIS_ID_NOT_FOUND)1