From 7ffa16d85dd4cce2f63b3b1c9b4f04b75acf75b1 Mon Sep 17 00:00:00 2001 From: Jules Jacobsen Date: Thu, 18 Jan 2024 09:52:00 +0000 Subject: [PATCH] Update VariantKeyGenerator to use GenomicVariant in place of Variant --- .../exomiser/autoconfigure/genome/VariantKeyGenerator.java | 5 +++-- .../autoconfigure/genome/VariantKeyGeneratorTest.java | 7 ++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/exomiser-spring-boot-autoconfigure/src/main/java/org/monarchinitiative/exomiser/autoconfigure/genome/VariantKeyGenerator.java b/exomiser-spring-boot-autoconfigure/src/main/java/org/monarchinitiative/exomiser/autoconfigure/genome/VariantKeyGenerator.java index ed4c9616d..d608d6564 100644 --- a/exomiser-spring-boot-autoconfigure/src/main/java/org/monarchinitiative/exomiser/autoconfigure/genome/VariantKeyGenerator.java +++ b/exomiser-spring-boot-autoconfigure/src/main/java/org/monarchinitiative/exomiser/autoconfigure/genome/VariantKeyGenerator.java @@ -22,6 +22,7 @@ import org.monarchinitiative.exomiser.core.model.AlleleProtoAdaptor; import org.monarchinitiative.exomiser.core.model.Variant; +import org.monarchinitiative.svart.GenomicVariant; import org.springframework.cache.interceptor.KeyGenerator; import org.springframework.cache.interceptor.SimpleKey; @@ -46,8 +47,8 @@ public static Object generateKey(Object... params) { } if (params.length == 1) { Object param = params[0]; - if (param instanceof Variant) { - return AlleleProtoAdaptor.toAlleleKey((Variant) param); + if (param instanceof GenomicVariant genomicVariant) { + return AlleleProtoAdaptor.toAlleleKey(genomicVariant); } } return new SimpleKey(params); diff --git a/exomiser-spring-boot-autoconfigure/src/test/java/org/monarchinitiative/exomiser/autoconfigure/genome/VariantKeyGeneratorTest.java b/exomiser-spring-boot-autoconfigure/src/test/java/org/monarchinitiative/exomiser/autoconfigure/genome/VariantKeyGeneratorTest.java index bdcb689b5..6cd388e8f 100644 --- a/exomiser-spring-boot-autoconfigure/src/test/java/org/monarchinitiative/exomiser/autoconfigure/genome/VariantKeyGeneratorTest.java +++ b/exomiser-spring-boot-autoconfigure/src/test/java/org/monarchinitiative/exomiser/autoconfigure/genome/VariantKeyGeneratorTest.java @@ -22,10 +22,9 @@ import org.junit.jupiter.api.Test; import org.monarchinitiative.exomiser.core.genome.GenomeAssembly; -import org.monarchinitiative.exomiser.core.model.Variant; -import org.monarchinitiative.exomiser.core.model.VariantEvaluation; import org.monarchinitiative.exomiser.core.proto.AlleleProto; import org.monarchinitiative.svart.CoordinateSystem; +import org.monarchinitiative.svart.GenomicVariant; import org.monarchinitiative.svart.Strand; import org.springframework.cache.interceptor.SimpleKey; @@ -46,9 +45,7 @@ public void returnsEmptyKeyForEmptyQuery() throws Exception { @Test public void returnsKeyForVariant() throws Exception { - Variant variant = VariantEvaluation.builder() - .variant(GenomeAssembly.HG19.getContigById(1), Strand.POSITIVE, CoordinateSystem.oneBased(), 2345, "A", "T") - .build(); + GenomicVariant variant = GenomicVariant.of(GenomeAssembly.HG19.getContigById(1), Strand.POSITIVE, CoordinateSystem.oneBased(), 2345, "A", "T"); // AlleleKey has no genomeAssembly. This might have been a bit of an oversight, but with assembly-specific caches // created in version 10.1.1 it's OK to use the AlleleKey as the cache key AlleleProto.AlleleKey expected = AlleleProto.AlleleKey.newBuilder()