Skip to content

Commit

Permalink
variants!
Browse files Browse the repository at this point in the history
  • Loading branch information
Luke Sikina committed Feb 4, 2024
1 parent 0f7198a commit 0ce4842
Showing 1 changed file with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.*;
import java.util.stream.Stream;

@Component
public class FlatVCFProcessor implements HpdsProcessor {
Expand Down Expand Up @@ -138,9 +139,9 @@ public void runVcfExcerptQuery(Query query, boolean includePatientData) throws I

log.info("Running VCF Extract query");

Collection<String> variantList = abstractProcessor.getInfoStore("Gene_with_variant").getAllValues().keys();
Collection<String> genes = abstractProcessor.getInfoStore("Gene_with_variant").getAllValues().keys();

log.debug("variantList Size " + variantList.size());
log.debug("variantList Size " + genes.size());

PhenoCube<String> idCube = null;
if(!ID_CUBE_NAME.contentEquals("NONE")) {
Expand Down Expand Up @@ -195,8 +196,11 @@ public void runVcfExcerptQuery(Query query, boolean includePatientData) throws I
writer.writeRow(builder.toString());
VariantBucketHolder<VariantMasks> variantMaskBucketHolder = new VariantBucketHolder<VariantMasks>();


//loop over the variants identified, and build an output row
variantList.stream()
genes.stream()
.map(this::createSingleGeneQuery)
.flatMap(this::safeGetVariantList)
.map(variant -> metadataIndex.findByMultipleVariantSpec(List.of(variant)))
.filter(Objects::nonNull)
.flatMap(m -> m.entrySet().stream())
Expand All @@ -206,6 +210,22 @@ public void runVcfExcerptQuery(Query query, boolean includePatientData) throws I
writer.complete();
}

private Stream<String> safeGetVariantList(Query query) {
try {
return abstractProcessor.getVariantList(query).stream();
} catch (IOException e) {
return Stream.empty();
}
}

private Query createSingleGeneQuery(String gene) {
var q = new Query();
Query.VariantInfoFilter v = new Query.VariantInfoFilter();
v.categoryVariantInfoFilters = Map.of("Gene_with_variant", new String[] {gene});
q.setVariantInfoFilters(List.of(v));
return q;
}

private String createRow(boolean includePatientData, Map.Entry<String, String[]> entry, VariantBucketHolder<VariantMasks> variantMaskBucketHolder, BigInteger patientMasks, Map<String, Integer> patientIndexMap) {
StringBuilder stringBuilder = new StringBuilder();
String variantSpec = entry.getKey();
Expand Down

0 comments on commit 0ce4842

Please sign in to comment.