From 923accf58c5abadd24d1b8478d1d66937c858f0c Mon Sep 17 00:00:00 2001 From: nitin-ebi <79518737+nitin-ebi@users.noreply.github.com> Date: Thu, 26 Oct 2023 09:45:31 +0100 Subject: [PATCH] EVA-3425 make sure reference and alternate are always uppercase (#107) * make sure reference and alternate are always uppercase --- .../commons/core/models/AbstractVariant.java | 6 ++-- .../models/AbstractVariantSourceEntry.java | 8 ++++-- .../core/models/VariantStatistics.java | 8 +++--- .../models/factories/VariantVcfFactory.java | 7 +++-- .../core/models/genotype/Genotype.java | 8 +++--- .../core/models/AbstractVariantTest.java | 7 +++++ .../eva/commons/core/models/GenotypeTest.java | 19 +++++++++++++ .../core/models/VariantStatisticsTest.java | 18 ++++++++++++ .../factories/VariantVcfFactoryTest.java | 8 ++++++ .../mongodb/entities/VariantMongo.java | 7 +++-- .../projections/SimplifiedVariant.java | 3 ++ .../subdocuments/VariantSourceEntryMongo.java | 7 +++-- .../commons/mongodb/filter/FilterBuilder.java | 8 ++++-- .../mongodb/MongoVariantConversionTest.java | 13 +++++++-- .../mongodb/SimplifiedVariantTest.java | 28 +++++++++++++++++++ .../VariantSourceEntryConversionTest.java | 14 ++++++++++ .../filter/VariantRepositoryFilterTest.java | 11 ++++++++ 17 files changed, 156 insertions(+), 24 deletions(-) create mode 100644 variation-commons-core/src/test/java/uk/ac/ebi/eva/commons/core/models/GenotypeTest.java create mode 100644 variation-commons-core/src/test/java/uk/ac/ebi/eva/commons/core/models/VariantStatisticsTest.java create mode 100644 variation-commons-mongodb/src/test/java/uk/ac/ebi/eva/commons/mongodb/SimplifiedVariantTest.java diff --git a/variation-commons-core/src/main/java/uk/ac/ebi/eva/commons/core/models/AbstractVariant.java b/variation-commons-core/src/main/java/uk/ac/ebi/eva/commons/core/models/AbstractVariant.java index 299c48d5..fc2cb755 100644 --- a/variation-commons-core/src/main/java/uk/ac/ebi/eva/commons/core/models/AbstractVariant.java +++ b/variation-commons-core/src/main/java/uk/ac/ebi/eva/commons/core/models/AbstractVariant.java @@ -124,6 +124,8 @@ public AbstractVariant(String chromosome, long start, long end, String reference if (chromosome == null || chromosome.trim().equals("")) { throw new IllegalArgumentException("Chromosome name cannot be empty"); } + reference = Objects.nonNull(reference) ? reference.toUpperCase() : null; + alternate = Objects.nonNull(alternate) ? alternate.toUpperCase() : null; this.chromosome = chromosome; this.setCoordinates(start, end); this.setReference(reference); @@ -200,11 +202,11 @@ public String getMainId() { } private void setReference(String reference) { - this.reference = (reference != null) ? reference : ""; + this.reference = (reference != null) ? reference.toUpperCase() : ""; } private void setAlternate(String alternate) { - this.alternate = (alternate != null) ? alternate : ""; + this.alternate = (alternate != null) ? alternate.toUpperCase() : ""; } private void setCoordinates(long start, long end) { diff --git a/variation-commons-core/src/main/java/uk/ac/ebi/eva/commons/core/models/AbstractVariantSourceEntry.java b/variation-commons-core/src/main/java/uk/ac/ebi/eva/commons/core/models/AbstractVariantSourceEntry.java index 857e166e..276360ce 100644 --- a/variation-commons-core/src/main/java/uk/ac/ebi/eva/commons/core/models/AbstractVariantSourceEntry.java +++ b/variation-commons-core/src/main/java/uk/ac/ebi/eva/commons/core/models/AbstractVariantSourceEntry.java @@ -19,6 +19,7 @@ import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; +import java.util.stream.Collectors; /** * Entry that associates a variant and a file in a variant archive. It contains @@ -65,7 +66,7 @@ public AbstractVariantSourceEntry(String fileId, String studyId, String[] second this.fileId = fileId; this.studyId = studyId; if (secondaryAlternates != null) { - this.secondaryAlternates = Arrays.copyOf(secondaryAlternates, secondaryAlternates.length); + setSecondaryAlternates(secondaryAlternates); } else { this.secondaryAlternates = new String[]{}; } @@ -105,7 +106,10 @@ public String[] getSecondaryAlternates() { } public void setSecondaryAlternates(String[] secondaryAlternates) { - this.secondaryAlternates = secondaryAlternates; + this.secondaryAlternates = Arrays.stream(secondaryAlternates) + .map(a->a.toUpperCase()) + .collect(Collectors.toList()) + .toArray(new String[0]); } @Override diff --git a/variation-commons-core/src/main/java/uk/ac/ebi/eva/commons/core/models/VariantStatistics.java b/variation-commons-core/src/main/java/uk/ac/ebi/eva/commons/core/models/VariantStatistics.java index 466385fd..802378e3 100644 --- a/variation-commons-core/src/main/java/uk/ac/ebi/eva/commons/core/models/VariantStatistics.java +++ b/variation-commons-core/src/main/java/uk/ac/ebi/eva/commons/core/models/VariantStatistics.java @@ -112,8 +112,8 @@ public VariantStatistics(String referenceAllele, String alternateAlleles, int numMissingAlleles, int numMissingGenotypes, int numMendelErrors, float percentCasesDominant, float percentControlsDominant, float percentCasesRecessive, float percentControlsRecessive) { - this.refAllele = referenceAllele; - this.altAllele = alternateAlleles; + this.refAllele = Objects.nonNull(referenceAllele) ? referenceAllele.toUpperCase() : null; + this.altAllele = Objects.nonNull(alternateAlleles) ? alternateAlleles.toUpperCase() : null; this.variantType = variantType; this.maf = maf; @@ -142,7 +142,7 @@ public String getRefAllele() { } public void setRefAllele(String refAllele) { - this.refAllele = refAllele; + this.refAllele = Objects.nonNull(refAllele) ? refAllele.toUpperCase() : null; } public String getAltAllele() { @@ -150,7 +150,7 @@ public String getAltAllele() { } public void setAltAllele(String altAllele) { - this.altAllele = altAllele; + this.altAllele = Objects.nonNull(altAllele) ? altAllele.toUpperCase() : null; } public VariantType getVariantType() { diff --git a/variation-commons-core/src/main/java/uk/ac/ebi/eva/commons/core/models/factories/VariantVcfFactory.java b/variation-commons-core/src/main/java/uk/ac/ebi/eva/commons/core/models/factories/VariantVcfFactory.java index be8fb70f..e13c482b 100644 --- a/variation-commons-core/src/main/java/uk/ac/ebi/eva/commons/core/models/factories/VariantVcfFactory.java +++ b/variation-commons-core/src/main/java/uk/ac/ebi/eva/commons/core/models/factories/VariantVcfFactory.java @@ -131,11 +131,14 @@ public boolean isIncludeIds() { } protected String getReference(String[] fields) { - return fields[3].equals(".") ? "" : fields[3]; + return fields[3].equals(".") ? "" : fields[3].toUpperCase(); } protected String[] getAlternateAlleles(String[] fields) { - return fields[4].split(","); + return Arrays.stream(fields[4].split(",")) + .map(a->a.toUpperCase()) + .collect(Collectors.toList()) + .toArray(new String[0]); } protected float getQuality(String[] fields) { diff --git a/variation-commons-core/src/main/java/uk/ac/ebi/eva/commons/core/models/genotype/Genotype.java b/variation-commons-core/src/main/java/uk/ac/ebi/eva/commons/core/models/genotype/Genotype.java index 68c449d1..6cb06b4c 100644 --- a/variation-commons-core/src/main/java/uk/ac/ebi/eva/commons/core/models/genotype/Genotype.java +++ b/variation-commons-core/src/main/java/uk/ac/ebi/eva/commons/core/models/genotype/Genotype.java @@ -47,8 +47,8 @@ public Genotype(String genotype) { } public Genotype(String genotype, String ref, String alt) { - this.reference = ref; - this.alternate = alt; + this.reference = Objects.nonNull(ref) ? ref.toUpperCase() : null; + this.alternate = Objects.nonNull(alt) ? alt.toUpperCase() : null; this.phased = genotype.contains("|"); this.count = 0; parseGenotype(genotype); @@ -96,7 +96,7 @@ public String getReference() { } void setReference(String reference) { - this.reference = reference; + this.reference = Objects.nonNull(reference) ? reference.toUpperCase() : null; } public String getAlternate() { @@ -104,7 +104,7 @@ public String getAlternate() { } void setAlternate(String alternate) { - this.alternate = alternate; + this.alternate = Objects.nonNull(alternate) ? alternate.toUpperCase() : null; } public int getAllele(int i) { diff --git a/variation-commons-core/src/test/java/uk/ac/ebi/eva/commons/core/models/AbstractVariantTest.java b/variation-commons-core/src/test/java/uk/ac/ebi/eva/commons/core/models/AbstractVariantTest.java index af0421e0..38d6893a 100644 --- a/variation-commons-core/src/test/java/uk/ac/ebi/eva/commons/core/models/AbstractVariantTest.java +++ b/variation-commons-core/src/test/java/uk/ac/ebi/eva/commons/core/models/AbstractVariantTest.java @@ -99,6 +99,13 @@ public void testRefAltAssignmentInConstructor() { assertEquals("T", variant.getAlternate()); } + @Test + public void testChangeRefAltToUpperCase() { + Variant variant = new Variant("1", 1, 1, "c", "t"); + assertEquals("C", variant.getReference()); + assertEquals("T", variant.getAlternate()); + } + @Test public void testRefAltAssignmentInRenormalization() { Variant variant = new Variant("1", 1, 1, "", "T"); diff --git a/variation-commons-core/src/test/java/uk/ac/ebi/eva/commons/core/models/GenotypeTest.java b/variation-commons-core/src/test/java/uk/ac/ebi/eva/commons/core/models/GenotypeTest.java new file mode 100644 index 00000000..f2dea9db --- /dev/null +++ b/variation-commons-core/src/test/java/uk/ac/ebi/eva/commons/core/models/GenotypeTest.java @@ -0,0 +1,19 @@ +package uk.ac.ebi.eva.commons.core.models; + +import org.junit.Test; +import uk.ac.ebi.eva.commons.core.models.genotype.Genotype; + +import static org.junit.Assert.assertEquals; + +public class GenotypeTest { + + @Test + public void testChangeRefAltToUpperCase() { + Genotype genotype = new Genotype("", "a", "t"); + + assertEquals("A", genotype.getReference()); + assertEquals("T", genotype.getAlternate()); + } + + +} diff --git a/variation-commons-core/src/test/java/uk/ac/ebi/eva/commons/core/models/VariantStatisticsTest.java b/variation-commons-core/src/test/java/uk/ac/ebi/eva/commons/core/models/VariantStatisticsTest.java new file mode 100644 index 00000000..d8704edb --- /dev/null +++ b/variation-commons-core/src/test/java/uk/ac/ebi/eva/commons/core/models/VariantStatisticsTest.java @@ -0,0 +1,18 @@ +package uk.ac.ebi.eva.commons.core.models; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +public class VariantStatisticsTest { + + @Test + public void testChangeRefAltToUpperCase() { + VariantStatistics variantStatistics = new VariantStatistics("a", "t", null, + -1, -1, "", "", -1, -1, -1, + -1, -1, -1, -1); + assertEquals("A", variantStatistics.getRefAllele()); + assertEquals("T", variantStatistics.getAltAllele()); + } + +} diff --git a/variation-commons-core/src/test/java/uk/ac/ebi/eva/commons/core/models/factories/VariantVcfFactoryTest.java b/variation-commons-core/src/test/java/uk/ac/ebi/eva/commons/core/models/factories/VariantVcfFactoryTest.java index 88252de2..9cae83f3 100644 --- a/variation-commons-core/src/test/java/uk/ac/ebi/eva/commons/core/models/factories/VariantVcfFactoryTest.java +++ b/variation-commons-core/src/test/java/uk/ac/ebi/eva/commons/core/models/factories/VariantVcfFactoryTest.java @@ -250,6 +250,14 @@ public void testVariantIds() { Collections.singleton("rs123,rs456")); } + @Test + public void testChangeRefAltToUpperCase(){ + String line = "chr1\t1000\t.\tt\tg\t.\t.\t."; + List expResult = Collections.singletonList(new Variant("chr1", 1000, 1000, "T", "G")); + List result = factory.create(FILE_ID, STUDY_ID, line); + assertEquals(expResult, result); + } + private void checkIds(VariantVcfFactory variantVcfFactory, String vcfLine, Set expectedIds) { List expectedVariants = new LinkedList<>(); expectedVariants.add(new Variant("1", 1000, 1000, "C", "T")); diff --git a/variation-commons-mongodb/src/main/java/uk/ac/ebi/eva/commons/mongodb/entities/VariantMongo.java b/variation-commons-mongodb/src/main/java/uk/ac/ebi/eva/commons/mongodb/entities/VariantMongo.java index c3384e0f..e23846a3 100644 --- a/variation-commons-mongodb/src/main/java/uk/ac/ebi/eva/commons/mongodb/entities/VariantMongo.java +++ b/variation-commons-mongodb/src/main/java/uk/ac/ebi/eva/commons/mongodb/entities/VariantMongo.java @@ -34,6 +34,7 @@ import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.Map; +import java.util.Objects; import java.util.Set; /** @@ -201,8 +202,8 @@ public VariantMongo(String id, VariantType type, String chromosome, long start, this.start = start; this.end = end; this.length = length; - this.reference = reference; - this.alternate = alternate; + this.reference = Objects.nonNull(reference) ? reference.toUpperCase() : null; + this.alternate = Objects.nonNull(alternate) ? alternate.toUpperCase() : null; this.at = at; this.hgvs = new LinkedHashSet<>(); if (hgvs != null && !hgvs.isEmpty()) { @@ -229,6 +230,8 @@ public VariantMongo(String id, VariantType type, String chromosome, long start, public static String buildVariantId(String chromosome, long start, String reference, String alternate) { StringBuilder builder = new StringBuilder(chromosome); + reference = reference.toUpperCase(); + alternate = alternate.toUpperCase(); builder.append("_"); builder.append(start); builder.append("_"); diff --git a/variation-commons-mongodb/src/main/java/uk/ac/ebi/eva/commons/mongodb/entities/projections/SimplifiedVariant.java b/variation-commons-mongodb/src/main/java/uk/ac/ebi/eva/commons/mongodb/entities/projections/SimplifiedVariant.java index ebdac378..2c8d55ed 100644 --- a/variation-commons-mongodb/src/main/java/uk/ac/ebi/eva/commons/mongodb/entities/projections/SimplifiedVariant.java +++ b/variation-commons-mongodb/src/main/java/uk/ac/ebi/eva/commons/mongodb/entities/projections/SimplifiedVariant.java @@ -23,6 +23,7 @@ import java.util.HashSet; import java.util.Map; +import java.util.Objects; import java.util.Set; import static uk.ac.ebi.eva.commons.mongodb.entities.VariantMongo.ALTERNATE_FIELD; @@ -79,6 +80,8 @@ public class SimplifiedVariant { public SimplifiedVariant(VariantType variantType, String chromosome, long start, long end, int length, String reference, String alternate, Map> hgvs) { + reference = Objects.nonNull(reference) ? reference.toUpperCase() : null; + alternate = Objects.nonNull(alternate) ? alternate.toUpperCase() : null; this.id = buildVariantId(chromosome, start, reference, alternate); this.variantType = variantType; this.chromosome = chromosome; diff --git a/variation-commons-mongodb/src/main/java/uk/ac/ebi/eva/commons/mongodb/entities/subdocuments/VariantSourceEntryMongo.java b/variation-commons-mongodb/src/main/java/uk/ac/ebi/eva/commons/mongodb/entities/subdocuments/VariantSourceEntryMongo.java index 05b4754d..d894c035 100644 --- a/variation-commons-mongodb/src/main/java/uk/ac/ebi/eva/commons/mongodb/entities/subdocuments/VariantSourceEntryMongo.java +++ b/variation-commons-mongodb/src/main/java/uk/ac/ebi/eva/commons/mongodb/entities/subdocuments/VariantSourceEntryMongo.java @@ -27,6 +27,7 @@ import java.io.IOException; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.HashMap; import java.util.List; @@ -100,8 +101,10 @@ public VariantSourceEntryMongo(String fileId, String studyId, String[] alternate this.fileId = fileId; this.studyId = studyId; if (alternates != null && alternates.length > 0) { - this.alternates = new String[alternates.length]; - System.arraycopy(alternates, 0, this.alternates, 0, alternates.length); + this.alternates = Arrays.stream(alternates) + .map(a->a.toUpperCase()) + .collect(Collectors.toList()) + .toArray(new String[0]); } if (attributes != null) { diff --git a/variation-commons-mongodb/src/main/java/uk/ac/ebi/eva/commons/mongodb/filter/FilterBuilder.java b/variation-commons-mongodb/src/main/java/uk/ac/ebi/eva/commons/mongodb/filter/FilterBuilder.java index 24b55755..ed0e2c89 100644 --- a/variation-commons-mongodb/src/main/java/uk/ac/ebi/eva/commons/mongodb/filter/FilterBuilder.java +++ b/variation-commons-mongodb/src/main/java/uk/ac/ebi/eva/commons/mongodb/filter/FilterBuilder.java @@ -23,6 +23,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.stream.Collectors; /** * Class for building filters for querying using the VariantRepository @@ -114,21 +115,22 @@ public FilterBuilder withVariantTypes(VariantType variantType) { public FilterBuilder withAlternates(List alternates) { if (alternates != null && !alternates.isEmpty()) { - filters.add(new VariantRepositoryAlternateFilter(alternates)); + List alternatesUppercase = alternates.stream().map(a->a.toUpperCase()).collect(Collectors.toList()); + filters.add(new VariantRepositoryAlternateFilter(alternatesUppercase)); } return this; } public FilterBuilder withAlternates(String alternate) { if (alternate != null) { - filters.add(new VariantRepositoryAlternateFilter(Collections.singletonList(alternate))); + filters.add(new VariantRepositoryAlternateFilter(Collections.singletonList(alternate.toUpperCase()))); } return this; } public FilterBuilder withReferenceBases(String referenceBases) { if (referenceBases != null) { - filters.add(new VariantRepositoryReferenceBasesFilter(Collections.singletonList(referenceBases))); + filters.add(new VariantRepositoryReferenceBasesFilter(Collections.singletonList(referenceBases.toUpperCase()))); } return this; } diff --git a/variation-commons-mongodb/src/test/java/uk/ac/ebi/eva/commons/mongodb/MongoVariantConversionTest.java b/variation-commons-mongodb/src/test/java/uk/ac/ebi/eva/commons/mongodb/MongoVariantConversionTest.java index d56b5508..65c3c9f7 100644 --- a/variation-commons-mongodb/src/test/java/uk/ac/ebi/eva/commons/mongodb/MongoVariantConversionTest.java +++ b/variation-commons-mongodb/src/test/java/uk/ac/ebi/eva/commons/mongodb/MongoVariantConversionTest.java @@ -17,7 +17,6 @@ import com.lordofthejars.nosqlunit.mongodb.MongoDbConfigurationBuilder; import com.lordofthejars.nosqlunit.mongodb.MongoDbRule; - import org.bson.BsonArray; import org.bson.BsonString; import org.bson.Document; @@ -31,7 +30,6 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringRunner; - import uk.ac.ebi.eva.commons.core.models.pipeline.VariantSourceEntry; import uk.ac.ebi.eva.commons.core.models.ws.VariantSourceEntryWithSampleNames; import uk.ac.ebi.eva.commons.core.models.ws.VariantWithSamplesAndAnnotation; @@ -180,7 +178,7 @@ private Document buildMongoVariantWithFiles() { private Document buildMongoBasicVariant() { VariantWithSamplesAndAnnotation variant = new VariantWithSamplesAndAnnotation(CHROMOSOME, START, END, REFERENCE, - ALTERNATE, null); + ALTERNATE, null); Document mongoVariant = new Document("_id", VARIANT_ID) .append(VariantMongo.IDS_FIELD, Collections.singleton(RS_666)) .append(VariantMongo.TYPE_FIELD, variant.getType().name()) @@ -249,4 +247,13 @@ public void testConvertToDataModelTypeEmptyIds() { assertNotNull(variant.getIds()); assertTrue(variant.getIds().isEmpty()); } + + @Test + public void testChangeRefAltToUpperCase() { + VariantMongo variantMongo = new VariantMongo(new VariantWithSamplesAndAnnotation("chr1", START, + END, "a", "t", null)); + Assert.assertEquals("A", variantMongo.getReference()); + Assert.assertEquals("T", variantMongo.getAlternate()); + } + } diff --git a/variation-commons-mongodb/src/test/java/uk/ac/ebi/eva/commons/mongodb/SimplifiedVariantTest.java b/variation-commons-mongodb/src/test/java/uk/ac/ebi/eva/commons/mongodb/SimplifiedVariantTest.java new file mode 100644 index 00000000..18721490 --- /dev/null +++ b/variation-commons-mongodb/src/test/java/uk/ac/ebi/eva/commons/mongodb/SimplifiedVariantTest.java @@ -0,0 +1,28 @@ +package uk.ac.ebi.eva.commons.mongodb; + +import org.junit.Test; +import uk.ac.ebi.eva.commons.mongodb.entities.projections.SimplifiedVariant; + +import java.lang.reflect.Field; + +import static org.junit.Assert.assertEquals; + +public class SimplifiedVariantTest { + + @Test + public void testChangeRefAltToUpperCase() throws NoSuchFieldException, IllegalAccessException { + SimplifiedVariant simplifiedVariant = new SimplifiedVariant(null, "", -1, -1, + -1, "a", "t", null); + + Field refField = SimplifiedVariant.class.getDeclaredField("reference"); + Field altField = SimplifiedVariant.class.getDeclaredField("alternate"); + refField.setAccessible(true); + altField.setAccessible(true); + String refValue = (String) refField.get(simplifiedVariant); + String altValue = (String) altField.get(simplifiedVariant); + + assertEquals("A", refValue); + assertEquals("T", altValue); + + } +} diff --git a/variation-commons-mongodb/src/test/java/uk/ac/ebi/eva/commons/mongodb/VariantSourceEntryConversionTest.java b/variation-commons-mongodb/src/test/java/uk/ac/ebi/eva/commons/mongodb/VariantSourceEntryConversionTest.java index afccdfce..2a277a59 100644 --- a/variation-commons-mongodb/src/test/java/uk/ac/ebi/eva/commons/mongodb/VariantSourceEntryConversionTest.java +++ b/variation-commons-mongodb/src/test/java/uk/ac/ebi/eva/commons/mongodb/VariantSourceEntryConversionTest.java @@ -166,5 +166,19 @@ public void testConvertFromVariantSourceEntryMongoToVariantSourceEntry() { Assert.assertEquals("1/1", variantSourceEntryWithSampleNames.getSamplesDataMap().get("NA003").get("GT")); } + @Test + public void testChangeRefAltToUpperCaseVariantSourceEntry() { + VariantSourceEntry variantSourceEntry = new VariantSourceEntry(null, "", new String[]{"a"}, + null, null, null, null); + Assert.assertEquals("A", variantSourceEntry.getSecondaryAlternates()[0]); + + } + + @Test + public void testChangeRefAltToUpperCaseVariantEntrySourceMongo() { + VariantSourceEntryMongo variantSourceEntryMongo = new VariantSourceEntryMongo(new VariantSourceEntry(null, + "", new String[]{"a"}, null, null, null, null)); + Assert.assertEquals( "A", variantSourceEntryMongo.getSecondaryAlternates()[0]); + } } diff --git a/variation-commons-mongodb/src/test/java/uk/ac/ebi/eva/commons/mongodb/filter/VariantRepositoryFilterTest.java b/variation-commons-mongodb/src/test/java/uk/ac/ebi/eva/commons/mongodb/filter/VariantRepositoryFilterTest.java index 9ec1b397..6c0bb6e1 100644 --- a/variation-commons-mongodb/src/test/java/uk/ac/ebi/eva/commons/mongodb/filter/VariantRepositoryFilterTest.java +++ b/variation-commons-mongodb/src/test/java/uk/ac/ebi/eva/commons/mongodb/filter/VariantRepositoryFilterTest.java @@ -18,6 +18,7 @@ */ package uk.ac.ebi.eva.commons.mongodb.filter; +import org.bson.Document; import org.junit.Test; import org.springframework.data.mongodb.core.query.Criteria; @@ -67,4 +68,14 @@ public void getCriteriaIn() throws Exception { Criteria test = filter.getCriteria(); assertEquals(expected, test); } + + @Test + public void testChangeRefAltToUpperCase() { + List filters = new FilterBuilder().getBeaconFilters("a", "t", + null, null); + assertEquals("A", ((List) ((Document)filters.get(0).getCriteria().getCriteriaObject() + .get("ref")).get("$in")).get(0)); + assertEquals("T", ((List) ((Document)filters.get(1).getCriteria().getCriteriaObject() + .get("alt")).get("$in")).get(0)); + } } \ No newline at end of file