Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

Commit

Permalink
Fixing bug when annotating MELT with missing AD (#95).
Browse files Browse the repository at this point in the history
Closes: #95
Related-Issue: #95
Projected-Results-Impact: none
  • Loading branch information
holtgrewe committed Jan 24, 2023
1 parent 98d437b commit ff749cc
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## v0.32 (work in progress)

- Fixing bug when annotating MELT with missing AD (#95).

## v0.31

- Interpret `FORMAT/SQ` as Float (#93).
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>com.github.bihealth</groupId>
<artifactId>VarfishAnnotator</artifactId>
<packaging>pom</packaging>
<version>0.31</version>
<version>0.32-SNAPSHOT</version>

<name>${project.groupId}:${project.artifactId}</name>
<description>Variant annotation for Varfish</description>
Expand Down
2 changes: 1 addition & 1 deletion varfish-annotator-cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<parent>
<groupId>com.github.bihealth</groupId>
<artifactId>VarfishAnnotator</artifactId>
<version>0.31</version>
<version>0.32-SNAPSHOT</version>
</parent>

<properties>
Expand Down
2 changes: 1 addition & 1 deletion varfish-annotator-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<parent>
<groupId>com.github.bihealth</groupId>
<artifactId>VarfishAnnotator</artifactId>
<version>0.31</version>
<version>0.32-SNAPSHOT</version>
</parent>

<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ protected void buildSampleGenotypeImpl(
SampleGenotypeBuilder builder, VariantContext ctx, int alleleNo, String sample) {
final Genotype genotype = ctx.getGenotype(sample);
final int dp = genotype.getDP();
final int ad = genotype.getAD().length > 0 ? genotype.getAD()[0] : 0;
final int ad =
(genotype.getAD() != null && genotype.getAD().length > 0) ? genotype.getAD()[0] : 0;
builder.setPairedEndCoverage(dp);
builder.setPairedEndVariantSupport(ad);
builder.setSplitReadCoverage(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.google.common.collect.ComparisonChain;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import java.math.BigDecimal;
import java.util.*;
import java.util.ArrayList;
import java.util.Collection;
Expand Down Expand Up @@ -292,14 +293,21 @@ private static Map<String, Object> jsonObjectToMap(JSONObject jsonObject) {
final Map<String, Object> result = new TreeMap<>();
for (String key : jsonObject.keySet()) {
final Object value = jsonObject.get(key);
if (value instanceof Integer || value instanceof Double || value instanceof String) {
if (value instanceof Integer
|| value instanceof Double
|| value instanceof Float
|| value instanceof String) {
result.put(key, value);
} else if (value instanceof BigDecimal) {
final BigDecimal bdValue = (BigDecimal) value;
result.put(key, bdValue.doubleValue());
} else if (value instanceof JSONObject) {
result.put(key, jsonObjectToMap((JSONObject) value));
} else if (value instanceof JSONArray) {
result.put(key, ((JSONArray) value).toList());
} else {
throw new RuntimeException("Cannot handle JSON object: " + value);
throw new RuntimeException(
"Cannot handle JSON object: " + value + " of type " + value.getClass());
}
}
return result;
Expand Down

0 comments on commit ff749cc

Please sign in to comment.