Skip to content

Commit

Permalink
Add logging for specific use case
Browse files Browse the repository at this point in the history
  • Loading branch information
ramari16 committed Mar 23, 2024
1 parent 1f16776 commit 0ac2ce0
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.Serializable;
import java.math.BigInteger;
Expand All @@ -11,6 +13,9 @@
import java.util.stream.Collectors;

public class VariableVariantMasks implements Serializable {

private static Logger log = LoggerFactory.getLogger(VariableVariantMasks.class);

private static final long serialVersionUID = 6225420483804601477L;
private static final String oneone = "11";
private static final char one = '1';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,11 @@ public boolean equals(Object o) {
public int hashCode() {
return Objects.hash(bitmask);
}

@Override
public String toString() {
return "VariantMaskBitmaskImpl{" +
"bitmask=" + bitmask.toString() +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,20 @@ public FileBackedJsonIndexStorage<Integer, ConcurrentHashMap<String, VariableVar
}

VariableVariantMasks mergeResult = VariableVariantMasks.append(entry.getValue(), variantStore1PatientCount, variantMasks2, variantStore2PatientCount);
if (entry.getKey().equals("chr3,11805,T,A,LINC01986,splice_donor_region_variant")) {
log.info("Mask 1: " + Optional.ofNullable(entry.getValue().heterozygousMask).map(VariantMask::toString).orElse("empty"));
log.info("Mask 2: " + Optional.ofNullable(variantMasks2.heterozygousMask).map(VariantMask::toString).orElse("empty"));
log.info("Merged mask: " + Optional.ofNullable(mergeResult.heterozygousMask).map(VariantMask::toString).orElse("empty"));

Set<Integer> patientIds1 = VariableVariantMasks.patientMaskToPatientIdSet(Optional.ofNullable(entry.getValue().heterozygousMask).orElse(VariantMask.emptyInstance()), Arrays.asList(variantStore1.getPatientIds()));
log.info("Patients 1: " + Joiner.on(",").join(patientIds1));

Set<Integer> patientIds2 = VariableVariantMasks.patientMaskToPatientIdSet(Optional.ofNullable(variantMasks2.heterozygousMask).orElse(VariantMask.emptyInstance()), Arrays.asList(variantStore2.getPatientIds()));
log.info("Patients 2: " + Joiner.on(",").join(patientIds2));

Set<Integer> mergedPatientIds = VariableVariantMasks.patientMaskToPatientIdSet(Optional.ofNullable(mergeResult.heterozygousMask).orElse(VariantMask.emptyInstance()), Arrays.asList(mergedVariantStore.getPatientIds()));
log.info("Merged patient ids: " + Joiner.on(",").join(mergedPatientIds));
}
mergedMasks.put(entry.getKey(), mergeResult);
}
// Any entry in the second set that is not in the merged set can be merged with an empty variant mask,
Expand Down Expand Up @@ -285,8 +299,8 @@ public FileBackedJsonIndexStorage<Integer, ConcurrentHashMap<String, VariableVar
ConcurrentHashMap<String, VariableVariantMasks> maskMap = merged.get(key);
maskMap.keySet().stream().sorted().limit(5).forEach(variantSpec -> {
VariableVariantMasks variableVariantMasks = maskMap.get(variantSpec);
VariantMask union = Optional.ofNullable(variableVariantMasks.heterozygousMask).orElse(VariantMask.emptyInstance()).union(Optional.ofNullable(variableVariantMasks.homozygousMask).orElse(VariantMask.emptyInstance()));
Set<Integer> patientsWithVariant = VariableVariantMasks.patientMaskToPatientIdSet(union, Arrays.asList(mergedVariantStore.getPatientIds()));
VariantMask heteroMask = Optional.ofNullable(variableVariantMasks.heterozygousMask).orElse(VariantMask.emptyInstance());
Set<Integer> patientsWithVariant = VariableVariantMasks.patientMaskToPatientIdSet(heteroMask, Arrays.asList(mergedVariantStore.getPatientIds()));
log.info("Patients with variant [" + variantSpec + "]: " + Joiner.on(",").join(patientsWithVariant));
});

Expand Down

0 comments on commit 0ac2ce0

Please sign in to comment.