From c18430487900c93b0682f4a8e41c71bcb16edfc5 Mon Sep 17 00:00:00 2001 From: Ryan Amari Date: Thu, 14 Dec 2023 11:45:06 -0500 Subject: [PATCH] Implement missing endpoints, add profile for integration B --- .../genomic/GenomicProcessorController.java | 17 +++++++--- .../processing/GenomicProcessorConfig.java | 12 +++++++ .../genomic/GenomicProcessorRestClient.java | 33 ++++++++++++++----- .../GenomicProcessorRestClientTest.java | 25 +++++++++++++- .../application-integrationB.properties | 6 ++++ 5 files changed, 79 insertions(+), 14 deletions(-) create mode 100644 service/src/main/resources/application-integrationB.properties diff --git a/genomic-processor/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/genomic/GenomicProcessorController.java b/genomic-processor/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/genomic/GenomicProcessorController.java index ae94f18f..bd2e8d92 100644 --- a/genomic-processor/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/genomic/GenomicProcessorController.java +++ b/genomic-processor/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/genomic/GenomicProcessorController.java @@ -4,10 +4,7 @@ import edu.harvard.hms.dbmi.avillach.hpds.processing.DistributableQuery; import edu.harvard.hms.dbmi.avillach.hpds.processing.GenomicProcessor; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import reactor.core.publisher.Mono; import java.math.BigInteger; @@ -26,7 +23,7 @@ public GenomicProcessorController(GenomicProcessor genomicProcessor) { } @PostMapping("/patients") - public Mono queryForPatientMask(@RequestBody DistributableQuery distributableQuery) throws InterruptedException { + public Mono queryForPatientMask(@RequestBody DistributableQuery distributableQuery) { return genomicProcessor.getPatientMask(distributableQuery); } @@ -40,6 +37,16 @@ public List getPatientIds() { return genomicProcessor.getPatientIds(); } + @GetMapping("/info/columns") + public List getInfoStoreColumns() { + return genomicProcessor.getInfoStoreColumns(); + } + + @GetMapping("/info/values") + public List getInfoStoreValues(@RequestParam("conceptPath") String conceptPath) { + return genomicProcessor.getInfoStoreValues(conceptPath); + } + @GetMapping("/info/meta") public List getInfoMetadata() { return genomicProcessor.getInfoColumnMeta(); diff --git a/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/GenomicProcessorConfig.java b/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/GenomicProcessorConfig.java index 96c5c595..91b2ec27 100644 --- a/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/GenomicProcessorConfig.java +++ b/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/GenomicProcessorConfig.java @@ -9,6 +9,8 @@ import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.IntStream; @SpringBootApplication @PropertySource("classpath:application.properties") @@ -26,6 +28,16 @@ public GenomicProcessor localGenomicProcessor() { return new GenomicProcessorNodeImpl(hpdsGenomicDataDirectory); } + @Bean(name = "localDistributedGenomicProcessor") + @ConditionalOnProperty(prefix = "hpds.genomicProcessor", name = "impl", havingValue = "localDistributed") + public GenomicProcessor localDistributedGenomicProcessor() { + //System.getProperty("HPDS_GENOMIC_DATA_DIRECTORY", "/opt/local/hpds/all/"); + List processorNodes = IntStream.range(1, 22) + .mapToObj(i -> new GenomicProcessorNodeImpl(hpdsGenomicDataDirectory + "/" + i)) + .collect(Collectors.toList()); + return new GenomicProcessorParentImpl(processorNodes); + } + @Bean(name = "remoteGenomicProcessor") @ConditionalOnProperty(prefix = "hpds.genomicProcessor", name = "impl", havingValue = "remote") public GenomicProcessor remoteGenomicProcessor() { diff --git a/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/genomic/GenomicProcessorRestClient.java b/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/genomic/GenomicProcessorRestClient.java index 577c24fa..e45c831f 100644 --- a/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/genomic/GenomicProcessorRestClient.java +++ b/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/genomic/GenomicProcessorRestClient.java @@ -21,6 +21,10 @@ public class GenomicProcessorRestClient implements GenomicProcessor { private final WebClient webClient; + private static final ParameterizedTypeReference> VARIANT_LIST_TYPE_REFERENCE = new ParameterizedTypeReference<>(){}; + private static final ParameterizedTypeReference> INFO_COLUMNS_META_TYPE_REFERENCE = new ParameterizedTypeReference<>(){}; + private static final ParameterizedTypeReference> LIST_OF_STRING_TYPE_REFERENCE = new ParameterizedTypeReference<>(){}; + public GenomicProcessorRestClient(String serviceUrl) { this.webClient = WebClient.builder() .baseUrl(serviceUrl) @@ -41,16 +45,14 @@ public Mono getPatientMask(DistributableQuery distributableQuery) { @Override public Set patientMaskToPatientIdSet(BigInteger patientMask) { - return null; + throw new RuntimeException("Not Implemented"); } @Override public BigInteger createMaskForPatientSet(Set patientSubset) { - return null; + throw new RuntimeException("Not Implemented"); } - private static final ParameterizedTypeReference> VARIANT_LIST_TYPE_REFERENCE = new ParameterizedTypeReference<>(){}; - private static final ParameterizedTypeReference> INFO_COLUMNS_META_TYPE_REFERENCE = new ParameterizedTypeReference<>(){}; @SuppressWarnings("unchecked") @Override public Mono> getVariantList(DistributableQuery distributableQuery) { @@ -65,10 +67,10 @@ public Mono> getVariantList(DistributableQuery distributableQ @Override public List getPatientIds() { - List result = webClient.get() + List result = webClient.get() .uri("/patients/ids") .retrieve() - .bodyToMono(List.class) + .bodyToMono(LIST_OF_STRING_TYPE_REFERENCE) .block(); return result; } @@ -80,12 +82,27 @@ public Optional getMasks(String path, VariantBucketHolder getInfoStoreColumns() { - throw new RuntimeException("Not yet implemented"); + List result = webClient.get() + .uri(uriBuilder -> uriBuilder + .path("/info/columns") + .build()) + .retrieve() + .bodyToMono(LIST_OF_STRING_TYPE_REFERENCE) + .block(); + return result; } @Override public List getInfoStoreValues(String conceptPath) { - throw new RuntimeException("Not Yet implemented"); + List result = webClient.get() + .uri(uriBuilder -> uriBuilder + .path("/info/values") + .queryParam("conceptPath", conceptPath) + .build(conceptPath)) + .retrieve() + .bodyToMono(LIST_OF_STRING_TYPE_REFERENCE) + .block(); + return result; } @Override diff --git a/processing/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/processing/genomic/GenomicProcessorRestClientTest.java b/processing/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/processing/genomic/GenomicProcessorRestClientTest.java index 2a010e7b..08d2e83d 100644 --- a/processing/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/processing/genomic/GenomicProcessorRestClientTest.java +++ b/processing/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/processing/genomic/GenomicProcessorRestClientTest.java @@ -1,9 +1,10 @@ package edu.harvard.hms.dbmi.avillach.hpds.processing.genomic; -import com.fasterxml.jackson.core.JsonProcessingException; +import edu.harvard.hms.dbmi.avillach.hpds.data.genotype.InfoColumnMeta; import edu.harvard.hms.dbmi.avillach.hpds.data.query.Query; import edu.harvard.hms.dbmi.avillach.hpds.processing.DistributableQuery; import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; import java.math.BigInteger; import java.util.ArrayList; @@ -36,4 +37,26 @@ public void simpleTest() { BigInteger patientMaskForVariantInfoFilters = genomicProcessorRestClient.getPatientMask(distributableQuery).block(); System.out.println(patientMaskForVariantInfoFilters); } + + @Test + public void getInfoStoreColumns() { + List infoStoreColumns = genomicProcessorRestClient.getInfoStoreColumns(); + assertTrue(infoStoreColumns.contains("Variant_consequence_calculated")); + } + @Test + public void getInfoStoreValues() { + List infoStoreValues = genomicProcessorRestClient.getInfoStoreValues("Variant_consequence_calculated"); + assertTrue(infoStoreValues.contains("inframe_deletion")); + } + + @Test + public void getInfoColumnMeta() { + List infoColumnMeta = genomicProcessorRestClient.getInfoColumnMeta(); + for (InfoColumnMeta columnMeta : infoColumnMeta) { + if (columnMeta.getKey().equals("Variant_consequence_calculated")) { + return; + } + } + throw new RuntimeException("Variant_consequence_calculated not found in info column meta"); + } } \ No newline at end of file diff --git a/service/src/main/resources/application-integrationB.properties b/service/src/main/resources/application-integrationB.properties new file mode 100644 index 00000000..16c335d2 --- /dev/null +++ b/service/src/main/resources/application-integrationB.properties @@ -0,0 +1,6 @@ +SMALL_JOB_LIMIT = 100 +SMALL_TASK_THREADS = 1 +LARGE_TASK_THREADS = 1 + +hpds.genomicProcessor.impl=localDistributed +HPDS_GENOMIC_DATA_DIRECTORY=/opt/local/hpds/all/ \ No newline at end of file