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/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