From d6fba66240112d86a48f27e8af76d5cd28a79aca Mon Sep 17 00:00:00 2001 From: Awab Ahmed Date: Wed, 20 Sep 2023 13:12:25 +0100 Subject: [PATCH] fix spanning deletion annotation --- .../VariantAnnotationCalculator.java | 9 ++++++-- .../annotation/VariantAnnotationUtils.java | 3 +++ .../impl/VariantAnnotationCalculatorTest.java | 21 +++++++++++++++++++ pom.xml | 2 +- 4 files changed, 32 insertions(+), 3 deletions(-) diff --git a/cellbase-core/src/main/java/org/opencb/cellbase/core/variant/annotation/VariantAnnotationCalculator.java b/cellbase-core/src/main/java/org/opencb/cellbase/core/variant/annotation/VariantAnnotationCalculator.java index a0df55d77..356b11a90 100644 --- a/cellbase-core/src/main/java/org/opencb/cellbase/core/variant/annotation/VariantAnnotationCalculator.java +++ b/cellbase-core/src/main/java/org/opencb/cellbase/core/variant/annotation/VariantAnnotationCalculator.java @@ -1078,7 +1078,12 @@ private ProteinVariantAnnotation getProteinAnnotation(ConsequenceType consequenc } private ConsequenceTypeCalculator getConsequenceTypeCalculator(Variant variant) throws UnsupportedURLVariantFormat { - switch (VariantAnnotationUtils.getVariantType(variant)) { + VariantType variantType = VariantAnnotationUtils.getVariantType(variant); + if (variantType == null) { + logger.error("There is no ConsequenceTypeCalculator for variant %s because it doesn't have a valid type", variant); + throw new UnsupportedURLVariantFormat("Invalid variant type"); + } + switch (variantType) { case SNV: return new ConsequenceTypeSNVCalculator(); case INSERTION: @@ -1104,7 +1109,7 @@ private ConsequenceTypeCalculator getConsequenceTypeCalculator(Variant variant) default: logger.error("There is no ConsequenceTypeCalculator for variant %s of type %s", variant, - VariantAnnotationUtils.getVariantType(variant) + variantType ); throw new UnsupportedURLVariantFormat(); } diff --git a/cellbase-core/src/main/java/org/opencb/cellbase/core/variant/annotation/VariantAnnotationUtils.java b/cellbase-core/src/main/java/org/opencb/cellbase/core/variant/annotation/VariantAnnotationUtils.java index 7be2151fd..383d122ba 100644 --- a/cellbase-core/src/main/java/org/opencb/cellbase/core/variant/annotation/VariantAnnotationUtils.java +++ b/cellbase-core/src/main/java/org/opencb/cellbase/core/variant/annotation/VariantAnnotationUtils.java @@ -658,6 +658,9 @@ protected static StringBuilder appendChromosome(String chromosome, StringBuilder } public static VariantType getVariantType(Variant variant) throws UnsupportedURLVariantFormat { + if (variant.isSpanningDeletion()) { + return null; + } if (variant.getType() == null) { variant.setType(Variant.inferType(variant.getReference(), variant.getAlternate())); } diff --git a/cellbase-lib/src/test/java/org/opencb/cellbase/lib/impl/VariantAnnotationCalculatorTest.java b/cellbase-lib/src/test/java/org/opencb/cellbase/lib/impl/VariantAnnotationCalculatorTest.java index d434dce98..c712d4c4e 100644 --- a/cellbase-lib/src/test/java/org/opencb/cellbase/lib/impl/VariantAnnotationCalculatorTest.java +++ b/cellbase-lib/src/test/java/org/opencb/cellbase/lib/impl/VariantAnnotationCalculatorTest.java @@ -38,6 +38,7 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.*; +import java.util.concurrent.ExecutionException; import java.util.stream.Collectors; import static org.junit.Assert.*; @@ -2437,6 +2438,26 @@ public void testLongMNVConsequenceTypesFailsForAboveThresholdLength() throws Exc variantAnnotationCalculator.getAllConsequenceTypesByVariant(aboveThresholdVariant, queryOptions); } + @Test + public void testSpanningDeletionAnnotation() throws ExecutionException, InterruptedException { + Variant variant = new Variant("10:133754330:GCCC:*"); + QueryOptions queryOptions = new QueryOptions("useCache", false); + queryOptions.put("include", "consequenceType,hgvs"); + queryOptions.put("normalize", true); + queryOptions.put("skipDecompose", false); + QueryResult cellBaseDataResult = variantAnnotationCalculator + .getAnnotationByVariant(variant, queryOptions); + assertTrue(cellBaseDataResult.getResult().get(0).getConsequenceTypes().isEmpty()); + assertTrue(cellBaseDataResult.getResult().get(0).getHgvs().isEmpty()); + } + + @Test(expected = UnsupportedURLVariantFormat.class) + public void testSpanningDeletionConsequenceTypeThrowsException() { + Variant variant = new Variant("10:133754330:GCCC:*"); + QueryOptions queryOptions = new QueryOptions("useCache", false); + variantAnnotationCalculator.getAllConsequenceTypesByVariant(variant, queryOptions); + } + public String getSequenceOntologyTerms(String transcriptID, List consequenceTypeList){ for (ConsequenceType consequenceType : consequenceTypeList) { if (consequenceType.getEnsemblTranscriptId().equals(transcriptID)){ diff --git a/pom.xml b/pom.xml index 85adc8ada..77a905767 100644 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,7 @@ 4.12.5 1.8 3.7.5 - 1.5.6 + 1.5.7 0.1.0 2.10.5 3.1.0