-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ALS-4978: Move genomic client from genomic processor project
- Loading branch information
Showing
8 changed files
with
146 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 2 additions & 4 deletions
6
processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/GenomicProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,17 @@ | ||
package edu.harvard.hms.dbmi.avillach.hpds.processing; | ||
|
||
import edu.harvard.hms.dbmi.avillach.hpds.data.query.Query; | ||
|
||
import java.math.BigInteger; | ||
import java.util.Collection; | ||
import java.util.Set; | ||
|
||
public interface GenomicProcessor { | ||
BigInteger getPatientMaskForVariantInfoFilters(DistributableQuery distributableQuery); | ||
BigInteger getPatientMask(DistributableQuery distributableQuery); | ||
|
||
Set<Integer> patientMaskToPatientIdSet(BigInteger patientMask); | ||
|
||
BigInteger createMaskForPatientSet(Set<Integer> patientSubset); | ||
|
||
Collection<String> processVariantList(DistributableQuery distributableQuery); | ||
Collection<String> getVariantList(DistributableQuery distributableQuery); | ||
|
||
String[] getPatientIds(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
...ava/edu/harvard/hms/dbmi/avillach/hpds/processing/genomic/GenomicProcessorRestClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package edu.harvard.hms.dbmi.avillach.hpds.processing.genomic; | ||
|
||
import edu.harvard.hms.dbmi.avillach.hpds.data.query.Query; | ||
import edu.harvard.hms.dbmi.avillach.hpds.processing.DistributableQuery; | ||
import edu.harvard.hms.dbmi.avillach.hpds.processing.GenomicProcessor; | ||
import org.springframework.http.HttpHeaders; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.web.reactive.function.client.WebClient; | ||
import reactor.core.publisher.Mono; | ||
|
||
import java.math.BigInteger; | ||
import java.util.Collection; | ||
import java.util.Set; | ||
|
||
public class GenomicProcessorRestClient implements GenomicProcessor { | ||
|
||
private final WebClient webClient; | ||
|
||
public GenomicProcessorRestClient(String serviceUrl) { | ||
this.webClient = WebClient.builder() | ||
.baseUrl(serviceUrl) | ||
.defaultHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) | ||
.build(); | ||
} | ||
|
||
@Override | ||
public BigInteger getPatientMask(DistributableQuery distributableQuery) { | ||
return webClient.post() | ||
.uri("/patients") | ||
.contentType(MediaType.APPLICATION_JSON) | ||
.body(Mono.just(distributableQuery), DistributableQuery.class) | ||
.retrieve() | ||
.bodyToMono(BigInteger.class) | ||
.block(); | ||
} | ||
|
||
@Override | ||
public Set<Integer> patientMaskToPatientIdSet(BigInteger patientMask) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public BigInteger createMaskForPatientSet(Set<Integer> patientSubset) { | ||
return null; | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
@Override | ||
public Collection<String> getVariantList(DistributableQuery distributableQuery) { | ||
return webClient.post() | ||
.uri("/variants") | ||
.contentType(MediaType.APPLICATION_JSON) | ||
.body(Mono.just(distributableQuery), DistributableQuery.class) | ||
.retrieve() | ||
.bodyToMono(Collection.class) | ||
.block(); | ||
} | ||
|
||
@Override | ||
public String[] getPatientIds() { | ||
return new String[0]; | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
...edu/harvard/hms/dbmi/avillach/hpds/processing/genomic/GenomicProcessorRestClientTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package edu.harvard.hms.dbmi.avillach.hpds.processing.genomic; | ||
|
||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import edu.harvard.hms.dbmi.avillach.hpds.data.query.Query; | ||
import edu.harvard.hms.dbmi.avillach.hpds.processing.DistributableQuery; | ||
import org.junit.Test; | ||
|
||
import java.math.BigInteger; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Set; | ||
|
||
public class GenomicProcessorRestClientTest { | ||
|
||
private GenomicProcessorRestClient genomicProcessorRestClient = new GenomicProcessorRestClient("http://localhost:8090/"); | ||
|
||
|
||
@Test | ||
public void test() throws JsonProcessingException { | ||
DistributableQuery distributableQuery = new DistributableQuery(); | ||
|
||
List<Query.VariantInfoFilter> variantInfoFilters = new ArrayList<>(); | ||
Query.VariantInfoFilter variantInfoFilter = new Query.VariantInfoFilter(); | ||
variantInfoFilter.categoryVariantInfoFilters = Map.of( | ||
"Gene_with_variant", new String[]{"FRG1FP"} | ||
); | ||
Query.VariantInfoFilter variantInfoFilter2 = new Query.VariantInfoFilter(); | ||
variantInfoFilter2.categoryVariantInfoFilters = Map.of( | ||
"Gene_with_variant", new String[]{"ACTG1P3"} | ||
); | ||
variantInfoFilters.add(variantInfoFilter2); | ||
distributableQuery.setVariantInfoFilters(variantInfoFilters); | ||
distributableQuery.setPatientIds(Set.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)); | ||
|
||
BigInteger patientMaskForVariantInfoFilters = genomicProcessorRestClient.getPatientMask(distributableQuery); | ||
System.out.println(patientMaskForVariantInfoFilters); | ||
} | ||
} |