Skip to content

Commit

Permalink
Update VariantKeyGenerator to use GenomicVariant in place of Variant
Browse files Browse the repository at this point in the history
  • Loading branch information
julesjacobsen committed Jan 18, 2024
1 parent 54ac97e commit 7ffa16d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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()
Expand Down

0 comments on commit 7ffa16d

Please sign in to comment.