Skip to content

Commit

Permalink
Implement missing endpoints, add profile for integration B
Browse files Browse the repository at this point in the history
  • Loading branch information
ramari16 committed Dec 14, 2023
1 parent ef3f480 commit c184304
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -26,7 +23,7 @@ public GenomicProcessorController(GenomicProcessor genomicProcessor) {
}

@PostMapping("/patients")
public Mono<BigInteger> queryForPatientMask(@RequestBody DistributableQuery distributableQuery) throws InterruptedException {
public Mono<BigInteger> queryForPatientMask(@RequestBody DistributableQuery distributableQuery) {
return genomicProcessor.getPatientMask(distributableQuery);
}

Expand All @@ -40,6 +37,16 @@ public List<String> getPatientIds() {
return genomicProcessor.getPatientIds();
}

@GetMapping("/info/columns")
public List<String> getInfoStoreColumns() {
return genomicProcessor.getInfoStoreColumns();
}

@GetMapping("/info/values")
public List<String> getInfoStoreValues(@RequestParam("conceptPath") String conceptPath) {
return genomicProcessor.getInfoStoreValues(conceptPath);
}

@GetMapping("/info/meta")
public List<InfoColumnMeta> getInfoMetadata() {
return genomicProcessor.getInfoColumnMeta();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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<GenomicProcessor> 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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ public class GenomicProcessorRestClient implements GenomicProcessor {

private final WebClient webClient;

private static final ParameterizedTypeReference<Collection<String>> VARIANT_LIST_TYPE_REFERENCE = new ParameterizedTypeReference<>(){};
private static final ParameterizedTypeReference<List<InfoColumnMeta>> INFO_COLUMNS_META_TYPE_REFERENCE = new ParameterizedTypeReference<>(){};
private static final ParameterizedTypeReference<List<String>> LIST_OF_STRING_TYPE_REFERENCE = new ParameterizedTypeReference<>(){};

public GenomicProcessorRestClient(String serviceUrl) {
this.webClient = WebClient.builder()
.baseUrl(serviceUrl)
Expand All @@ -41,16 +45,14 @@ public Mono<BigInteger> getPatientMask(DistributableQuery distributableQuery) {

@Override
public Set<Integer> patientMaskToPatientIdSet(BigInteger patientMask) {
return null;
throw new RuntimeException("Not Implemented");
}

@Override
public BigInteger createMaskForPatientSet(Set<Integer> patientSubset) {
return null;
throw new RuntimeException("Not Implemented");
}

private static final ParameterizedTypeReference<Collection<String>> VARIANT_LIST_TYPE_REFERENCE = new ParameterizedTypeReference<>(){};
private static final ParameterizedTypeReference<List<InfoColumnMeta>> INFO_COLUMNS_META_TYPE_REFERENCE = new ParameterizedTypeReference<>(){};
@SuppressWarnings("unchecked")
@Override
public Mono<Collection<String>> getVariantList(DistributableQuery distributableQuery) {
Expand All @@ -65,10 +67,10 @@ public Mono<Collection<String>> getVariantList(DistributableQuery distributableQ

@Override
public List<String> getPatientIds() {
List result = webClient.get()
List<String> result = webClient.get()
.uri("/patients/ids")
.retrieve()
.bodyToMono(List.class)
.bodyToMono(LIST_OF_STRING_TYPE_REFERENCE)
.block();
return result;
}
Expand All @@ -80,12 +82,27 @@ public Optional<VariantMasks> getMasks(String path, VariantBucketHolder<VariantM

@Override
public List<String> getInfoStoreColumns() {
throw new RuntimeException("Not yet implemented");
List<String> result = webClient.get()
.uri(uriBuilder -> uriBuilder
.path("/info/columns")
.build())
.retrieve()
.bodyToMono(LIST_OF_STRING_TYPE_REFERENCE)
.block();
return result;
}

@Override
public List<String> getInfoStoreValues(String conceptPath) {
throw new RuntimeException("Not Yet implemented");
List<String> 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
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -36,4 +37,26 @@ public void simpleTest() {
BigInteger patientMaskForVariantInfoFilters = genomicProcessorRestClient.getPatientMask(distributableQuery).block();
System.out.println(patientMaskForVariantInfoFilters);
}

@Test
public void getInfoStoreColumns() {
List<String> infoStoreColumns = genomicProcessorRestClient.getInfoStoreColumns();
assertTrue(infoStoreColumns.contains("Variant_consequence_calculated"));
}
@Test
public void getInfoStoreValues() {
List<String> infoStoreValues = genomicProcessorRestClient.getInfoStoreValues("Variant_consequence_calculated");
assertTrue(infoStoreValues.contains("inframe_deletion"));
}

@Test
public void getInfoColumnMeta() {
List<InfoColumnMeta> 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");
}
}
Original file line number Diff line number Diff line change
@@ -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/

0 comments on commit c184304

Please sign in to comment.