diff --git a/src/main/java/uk/ac/ebi/eva/commons/models/data/Variant.java b/src/main/java/uk/ac/ebi/eva/commons/models/data/Variant.java index 67729dbd9..0012ff474 100644 --- a/src/main/java/uk/ac/ebi/eva/commons/models/data/Variant.java +++ b/src/main/java/uk/ac/ebi/eva/commons/models/data/Variant.java @@ -135,6 +135,8 @@ public Variant(String chromosome, int start, int end, String reference, String a this.chromosome = chromosome; this.start = start; this.end = end; + reference = Objects.nonNull(reference) ? reference.toUpperCase() : null; + alternate = Objects.nonNull(alternate) ? alternate.toUpperCase() : null; this.reference = (reference != null) ? reference : ""; this.alternate = (alternate != null) ? alternate : ""; @@ -229,7 +231,7 @@ public String getReference() { } public void setReference(String reference) { - this.reference = reference; + this.reference = reference.toUpperCase(); this.length = Math.max(reference.length(), alternate.length()); } @@ -238,7 +240,7 @@ public String getAlternate() { } public void setAlternate(String alternate) { - this.alternate = alternate; + this.alternate = alternate.toUpperCase(); this.length = Math.max(reference.length(), alternate.length()); } diff --git a/src/main/java/uk/ac/ebi/eva/commons/models/data/VariantSourceEntry.java b/src/main/java/uk/ac/ebi/eva/commons/models/data/VariantSourceEntry.java index 65a3f8773..aedb74107 100644 --- a/src/main/java/uk/ac/ebi/eva/commons/models/data/VariantSourceEntry.java +++ b/src/main/java/uk/ac/ebi/eva/commons/models/data/VariantSourceEntry.java @@ -22,6 +22,7 @@ import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.stream.Collectors; /** * Entry that associates a variant and a file in a variant archive. It contains @@ -82,7 +83,7 @@ public VariantSourceEntry(String fileId, String studyId) { public VariantSourceEntry(String fileId, String studyId, String[] secondaryAlternates, String format) { this.fileId = fileId; this.studyId = studyId; - this.secondaryAlternates = secondaryAlternates; + setSecondaryAlternates(secondaryAlternates); this.format = format; this.samplesData = new ArrayList<>(); @@ -111,7 +112,10 @@ public String[] getSecondaryAlternates() { } public void setSecondaryAlternates(String[] secondaryAlternates) { - this.secondaryAlternates = secondaryAlternates; + this.secondaryAlternates = secondaryAlternates==null ? new String[0] : Arrays.stream(secondaryAlternates) + .map(a->a.toUpperCase()) + .collect(Collectors.toList()) + .toArray(new String[0]); } public String getFormat() { diff --git a/src/main/java/uk/ac/ebi/eva/commons/models/data/VariantStats.java b/src/main/java/uk/ac/ebi/eva/commons/models/data/VariantStats.java index e8a7e1aa3..46a205fed 100644 --- a/src/main/java/uk/ac/ebi/eva/commons/models/data/VariantStats.java +++ b/src/main/java/uk/ac/ebi/eva/commons/models/data/VariantStats.java @@ -104,8 +104,8 @@ public VariantStats(String chromosome, int position, String referenceAllele, Str Variant.VariantType variantType, float maf, float mgf, String mafAllele, String mgfGenotype, 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; @@ -134,7 +134,7 @@ public String getRefAllele() { } public void setRefAllele(String refAllele) { - this.refAllele = refAllele; + this.refAllele = Objects.nonNull(refAllele) ? refAllele.toUpperCase() : null; } public String getAltAllele() { @@ -142,7 +142,7 @@ public String getAltAllele() { } public void setAltAllele(String altAllele) { - this.altAllele = altAllele; + this.altAllele = Objects.nonNull(altAllele) ? altAllele.toUpperCase() : null; } public Variant.VariantType getVariantType() { diff --git a/src/main/java/uk/ac/ebi/eva/commons/models/mongo/entity/Annotation.java b/src/main/java/uk/ac/ebi/eva/commons/models/mongo/entity/Annotation.java index 1cd191d97..052e3f684 100644 --- a/src/main/java/uk/ac/ebi/eva/commons/models/mongo/entity/Annotation.java +++ b/src/main/java/uk/ac/ebi/eva/commons/models/mongo/entity/Annotation.java @@ -25,6 +25,7 @@ import java.util.Collections; import java.util.HashSet; +import java.util.Objects; import java.util.Set; /** @@ -83,6 +84,8 @@ public Annotation(String chromosome, int start, int end, String referenceAllele, this.vepVersion = vepVersion; this.vepCacheVersion = vepCacheVersion; + referenceAllele = Objects.nonNull(referenceAllele) ? referenceAllele.toUpperCase() : null; + alternativeAllele = Objects.nonNull(alternativeAllele) ? alternativeAllele.toUpperCase() : null; this.id = buildAnnotationId(chromosome, start, referenceAllele, alternativeAllele, vepVersion, vepCacheVersion); this.xrefs = new HashSet<>(); this.consequenceTypes = new HashSet<>(); diff --git a/src/main/java/uk/ac/ebi/eva/commons/models/mongo/entity/VariantDocument.java b/src/main/java/uk/ac/ebi/eva/commons/models/mongo/entity/VariantDocument.java index cce17112f..375c3c25d 100644 --- a/src/main/java/uk/ac/ebi/eva/commons/models/mongo/entity/VariantDocument.java +++ b/src/main/java/uk/ac/ebi/eva/commons/models/mongo/entity/VariantDocument.java @@ -29,6 +29,7 @@ import java.util.HashSet; import java.util.Map; +import java.util.Objects; import java.util.Set; /** @@ -116,6 +117,8 @@ public class VariantDocument { public VariantDocument(Variant.VariantType variantType, String chromosome, int start, int end, int length, String reference, String alternate, Map> hgvs, Set ids, Set variantSources) { + 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; @@ -139,6 +142,8 @@ public VariantDocument(Variant.VariantType variantType, String chromosome, int s public VariantDocument(Variant.VariantType variantType, String chromosome, int start, int end, int length, String reference, String alternate, Set hgvs, Set ids, Set variantSources) { + 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; @@ -160,6 +165,8 @@ public VariantDocument(Variant.VariantType variantType, String chromosome, int s } public static String buildVariantId(String chromosome, int start, String reference, String alternate) { + reference = reference.toUpperCase(); + alternate = alternate.toUpperCase(); StringBuilder builder = new StringBuilder(chromosome); builder.append("_"); builder.append(start); diff --git a/src/main/java/uk/ac/ebi/eva/commons/models/mongo/entity/projections/SimplifiedVariant.java b/src/main/java/uk/ac/ebi/eva/commons/models/mongo/entity/projections/SimplifiedVariant.java index 9b8583ed4..14346a7de 100644 --- a/src/main/java/uk/ac/ebi/eva/commons/models/mongo/entity/projections/SimplifiedVariant.java +++ b/src/main/java/uk/ac/ebi/eva/commons/models/mongo/entity/projections/SimplifiedVariant.java @@ -23,6 +23,7 @@ import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Set; import static uk.ac.ebi.eva.commons.models.mongo.entity.VariantDocument.ALTERNATE_FIELD; @@ -79,6 +80,8 @@ public class SimplifiedVariant { public SimplifiedVariant(Variant.VariantType variantType, String chromosome, int start, int 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/src/main/java/uk/ac/ebi/eva/commons/models/mongo/entity/subdocuments/VariantSourceEntryMongo.java b/src/main/java/uk/ac/ebi/eva/commons/models/mongo/entity/subdocuments/VariantSourceEntryMongo.java index b7e3c9f78..8d96ad103 100644 --- a/src/main/java/uk/ac/ebi/eva/commons/models/mongo/entity/subdocuments/VariantSourceEntryMongo.java +++ b/src/main/java/uk/ac/ebi/eva/commons/models/mongo/entity/subdocuments/VariantSourceEntryMongo.java @@ -22,11 +22,13 @@ import java.io.IOException; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; +import java.util.stream.Collectors; /** * Mongo database representation of Variant Source entry. @@ -73,8 +75,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]); } attrs = buildAttributes(attributes); diff --git a/src/main/java/uk/ac/ebi/eva/pipeline/io/mappers/AccessionReportLineMapper.java b/src/main/java/uk/ac/ebi/eva/pipeline/io/mappers/AccessionReportLineMapper.java index d1feaa655..6c20bd7c1 100644 --- a/src/main/java/uk/ac/ebi/eva/pipeline/io/mappers/AccessionReportLineMapper.java +++ b/src/main/java/uk/ac/ebi/eva/pipeline/io/mappers/AccessionReportLineMapper.java @@ -21,6 +21,7 @@ import java.util.Arrays; import java.util.HashSet; +import java.util.Objects; import java.util.Set; public class AccessionReportLineMapper extends VariantVcfFactory implements LineMapper { @@ -37,7 +38,7 @@ public Variant mapLine(String line, int lineNumber) { String chromosome = fields[0]; int position = Integer.parseInt(fields[1]); String reference = getReference(fields); - String alternateAllele = fields[4]; + String alternateAllele = Objects.nonNull(fields[4]) ? fields[4].toUpperCase() : null ; VariantCoreFields keyFields = getVariantCoreKeyFields(chromosome, position, reference, alternateAllele); Variant variant = new Variant(chromosome, (int) keyFields.getStart(), (int) keyFields.getEnd(), keyFields.getReference(), keyFields.getAlternate()); @@ -48,7 +49,7 @@ public Variant mapLine(String line, int lineNumber) { } private String getReference(String[] fields) { - return fields[3].equals(".") ? "" : fields[3]; + return fields[3].equals(".") ? "" : fields[3].toUpperCase(); } private Set getIds(String[] fields) { diff --git a/src/main/java/uk/ac/ebi/eva/pipeline/io/mappers/AnnotationLineMapper.java b/src/main/java/uk/ac/ebi/eva/pipeline/io/mappers/AnnotationLineMapper.java index 528375fae..7ab79ebb3 100644 --- a/src/main/java/uk/ac/ebi/eva/pipeline/io/mappers/AnnotationLineMapper.java +++ b/src/main/java/uk/ac/ebi/eva/pipeline/io/mappers/AnnotationLineMapper.java @@ -182,8 +182,8 @@ private Map parseVariant(String variantString, String coordinates parsedVariant.put("chromosome", leftVariantFields[0]); } parsedVariant.put("start", leftVariantFields[leftVariantFields.length-2]); - parsedVariant.put("reference", leftVariantFields[leftVariantFields.length-1]); - parsedVariant.put("alternative", variantFields[1]); + parsedVariant.put("reference", leftVariantFields[leftVariantFields.length-1].toUpperCase()); + parsedVariant.put("alternative", variantFields[1].toUpperCase()); } catch (ArrayIndexOutOfBoundsException e) { logger.error("Unexpected variant format for column 1: "+variantString); throw e; diff --git a/src/main/java/uk/ac/ebi/eva/pipeline/io/mappers/VariantVcfFactory.java b/src/main/java/uk/ac/ebi/eva/pipeline/io/mappers/VariantVcfFactory.java index 85f5fda3f..5c3cc92d8 100644 --- a/src/main/java/uk/ac/ebi/eva/pipeline/io/mappers/VariantVcfFactory.java +++ b/src/main/java/uk/ac/ebi/eva/pipeline/io/mappers/VariantVcfFactory.java @@ -37,6 +37,7 @@ import java.util.TreeMap; import java.util.logging.Level; import java.util.logging.Logger; +import java.util.stream.Collectors; import static java.lang.Math.max; @@ -121,11 +122,14 @@ private Set getIds(String[] fields) { } private String getReference(String[] fields) { - return fields[3].equals(".") ? "" : fields[3]; + return fields[3].equals(".") ? "" : fields[3].toUpperCase(); } private String[] getAlternateAlleles(String[] fields, String chromosome, int position, String reference) { - return fields[4].split(","); + return Arrays.stream(fields[4].split(",")) + .map(a->a.toUpperCase()) + .collect(Collectors.toList()) + .toArray(new String[0]); } private float getQuality(String[] fields) { diff --git a/src/main/java/uk/ac/ebi/eva/pipeline/model/EnsemblVariant.java b/src/main/java/uk/ac/ebi/eva/pipeline/model/EnsemblVariant.java index ff2f4230f..899693c50 100644 --- a/src/main/java/uk/ac/ebi/eva/pipeline/model/EnsemblVariant.java +++ b/src/main/java/uk/ac/ebi/eva/pipeline/model/EnsemblVariant.java @@ -52,8 +52,8 @@ public EnsemblVariant(String chromosome, long start, long end, String reference, this.chromosome = chromosome; this.start = start; this.end = end; - this.reference = reference; - this.alternate = alternate; + this.reference = reference.toUpperCase(); + this.alternate = alternate.toUpperCase(); transformToEnsemblFormat(); } diff --git a/src/main/java/uk/ac/ebi/eva/pipeline/model/PopulationStatistics.java b/src/main/java/uk/ac/ebi/eva/pipeline/model/PopulationStatistics.java index 1ba02c911..815ce43a2 100644 --- a/src/main/java/uk/ac/ebi/eva/pipeline/model/PopulationStatistics.java +++ b/src/main/java/uk/ac/ebi/eva/pipeline/model/PopulationStatistics.java @@ -25,6 +25,7 @@ import uk.ac.ebi.eva.pipeline.Application; import java.util.Map; +import java.util.Objects; /** * Statistics related to a set of samples for a given variant. @@ -122,7 +123,7 @@ public String getReference() { } void setReference(String reference) { - this.reference = reference; + this.reference = Objects.nonNull(reference) ? reference.toUpperCase() : null; } public String getAlternate() { @@ -130,7 +131,7 @@ public String getAlternate() { } void setAlternate(String alternate) { - this.alternate = alternate; + this.alternate = Objects.nonNull(alternate) ? alternate.toUpperCase() : null; } public String getCohortId() { diff --git a/src/test/java/uk/ac/ebi/eva/commons/models/data/VariantSourceEntryTest.java b/src/test/java/uk/ac/ebi/eva/commons/models/data/VariantSourceEntryTest.java new file mode 100644 index 000000000..c08f8fa23 --- /dev/null +++ b/src/test/java/uk/ac/ebi/eva/commons/models/data/VariantSourceEntryTest.java @@ -0,0 +1,14 @@ +package uk.ac.ebi.eva.commons.models.data; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +public class VariantSourceEntryTest { + @Test + public void testChangeRefAltToUpperCase() { + VariantSourceEntry variantSourceEntry = new VariantSourceEntry(null, null, new String[]{"a", "t"}, null); + assertEquals("A", variantSourceEntry.getSecondaryAlternates()[0]); + assertEquals("T", variantSourceEntry.getSecondaryAlternates()[1]); + } +} diff --git a/src/test/java/uk/ac/ebi/eva/commons/models/data/VariantStatsTest.java b/src/test/java/uk/ac/ebi/eva/commons/models/data/VariantStatsTest.java new file mode 100644 index 000000000..2685f1e74 --- /dev/null +++ b/src/test/java/uk/ac/ebi/eva/commons/models/data/VariantStatsTest.java @@ -0,0 +1,14 @@ +package uk.ac.ebi.eva.commons.models.data; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +public class VariantStatsTest { + @Test + public void testChangeRefAltToUpperCase() { + VariantStats variantStats = new VariantStats("a", "t", null); + assertEquals("A", variantStats.getRefAllele()); + assertEquals("T", variantStats.getAltAllele()); + } +} diff --git a/src/test/java/uk/ac/ebi/eva/commons/models/data/VariantTest.java b/src/test/java/uk/ac/ebi/eva/commons/models/data/VariantTest.java new file mode 100644 index 000000000..d2f6f6d5e --- /dev/null +++ b/src/test/java/uk/ac/ebi/eva/commons/models/data/VariantTest.java @@ -0,0 +1,14 @@ +package uk.ac.ebi.eva.commons.models.data; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +public class VariantTest { + @Test + public void testChangeRefAltToUpperCase() { + Variant variant = new Variant("1", 1, 1, "c", "t"); + assertEquals("C", variant.getReference()); + assertEquals("T", variant.getAlternate()); + } +} diff --git a/src/test/java/uk/ac/ebi/eva/commons/models/mongo/AnnotationTest.java b/src/test/java/uk/ac/ebi/eva/commons/models/mongo/AnnotationTest.java new file mode 100644 index 000000000..ec04abbb4 --- /dev/null +++ b/src/test/java/uk/ac/ebi/eva/commons/models/mongo/AnnotationTest.java @@ -0,0 +1,16 @@ +package uk.ac.ebi.eva.commons.models.mongo; + +import org.junit.Test; +import uk.ac.ebi.eva.commons.models.mongo.entity.Annotation; + +import static org.junit.Assert.assertEquals; + +public class AnnotationTest { + + @Test + public void testChangeRefAltToUpperCase() { + Annotation annotation = new Annotation("chr", 1, 1, "a", "t", + "vep", "vep_cache"); + assertEquals("chr_1_A_T_vep_vep_cache", annotation.getId()); + } +} diff --git a/src/test/java/uk/ac/ebi/eva/commons/models/mongo/VariantDocumentTest.java b/src/test/java/uk/ac/ebi/eva/commons/models/mongo/VariantDocumentTest.java new file mode 100644 index 000000000..9ace55726 --- /dev/null +++ b/src/test/java/uk/ac/ebi/eva/commons/models/mongo/VariantDocumentTest.java @@ -0,0 +1,22 @@ +package uk.ac.ebi.eva.commons.models.mongo; + +import org.junit.Test; +import uk.ac.ebi.eva.commons.models.data.Variant; +import uk.ac.ebi.eva.commons.models.mongo.entity.VariantDocument; + +import java.util.Map; +import java.util.Set; + +import static org.junit.Assert.assertEquals; + +public class VariantDocumentTest { + @Test + public void testChangeRefAltToUpperCase() { + VariantDocument variantDocument = new VariantDocument(Variant.VariantType.SNV, "chr", 1, + 2, 1, "a", "t", (Map>) null, + null, null); + + assertEquals("A", variantDocument.getReference()); + assertEquals("T", variantDocument.getAlternate()); + } +} diff --git a/src/test/java/uk/ac/ebi/eva/commons/models/mongo/projections/SimplifiedVariantTest.java b/src/test/java/uk/ac/ebi/eva/commons/models/mongo/projections/SimplifiedVariantTest.java new file mode 100644 index 000000000..122f651e2 --- /dev/null +++ b/src/test/java/uk/ac/ebi/eva/commons/models/mongo/projections/SimplifiedVariantTest.java @@ -0,0 +1,21 @@ +package uk.ac.ebi.eva.commons.models.mongo.projections; + +import org.junit.Test; +import uk.ac.ebi.eva.commons.models.data.Variant; +import uk.ac.ebi.eva.commons.models.mongo.entity.projections.SimplifiedVariant; + +import java.util.HashMap; + +import static org.junit.Assert.assertEquals; + +public class SimplifiedVariantTest { + + @Test + public void testChangeRefAltToUpperCase() { + SimplifiedVariant simplifiedVariant = new SimplifiedVariant(Variant.VariantType.SNV, "chr", + 1, 2, 1, "a", "t", new HashMap<>()); + assertEquals("A", simplifiedVariant.getReference()); + assertEquals("T", simplifiedVariant.getAlternate()); + } + +} diff --git a/src/test/java/uk/ac/ebi/eva/commons/models/mongo/subdocuments/VariantSourceEntryMongoTest.java b/src/test/java/uk/ac/ebi/eva/commons/models/mongo/subdocuments/VariantSourceEntryMongoTest.java new file mode 100644 index 000000000..c15d7d0b0 --- /dev/null +++ b/src/test/java/uk/ac/ebi/eva/commons/models/mongo/subdocuments/VariantSourceEntryMongoTest.java @@ -0,0 +1,24 @@ +package uk.ac.ebi.eva.commons.models.mongo.subdocuments; + +import org.junit.Test; +import uk.ac.ebi.eva.commons.models.mongo.entity.subdocuments.VariantSourceEntryMongo; + +import java.lang.reflect.Field; +import java.util.HashMap; + +import static org.junit.Assert.assertEquals; + +public class VariantSourceEntryMongoTest { + @Test + public void testChangeRefAltToUpperCase() throws NoSuchFieldException, IllegalAccessException { + VariantSourceEntryMongo variantSourceEntryMongo = new VariantSourceEntryMongo(null, null, + new String[]{"a", "t"}, new HashMap<>()); + + Field altField = VariantSourceEntryMongo.class.getDeclaredField("alternates"); + altField.setAccessible(true); + String[] altValue = (String[]) altField.get(variantSourceEntryMongo); + + assertEquals("A", altValue[0]); + assertEquals("T", altValue[1]); + } +} diff --git a/src/test/java/uk/ac/ebi/eva/pipeline/io/mappers/AccessionReportLineMapperTest.java b/src/test/java/uk/ac/ebi/eva/pipeline/io/mappers/AccessionReportLineMapperTest.java new file mode 100644 index 000000000..e359800d1 --- /dev/null +++ b/src/test/java/uk/ac/ebi/eva/pipeline/io/mappers/AccessionReportLineMapperTest.java @@ -0,0 +1,17 @@ +package uk.ac.ebi.eva.pipeline.io.mappers; + +import org.junit.Test; +import uk.ac.ebi.eva.commons.models.data.Variant; + +import static org.junit.Assert.assertEquals; + +public class AccessionReportLineMapperTest { + + @Test + public void testChangeRefAltToUpperCase() { + Variant variant = new AccessionReportLineMapper().mapLine("chr\t1\tid\ta\tt\tabc", 1); + + assertEquals("A", variant.getReference()); + assertEquals("T", variant.getAlternate()); + } +} diff --git a/src/test/java/uk/ac/ebi/eva/pipeline/io/mappers/AnnotationLineMapperTest.java b/src/test/java/uk/ac/ebi/eva/pipeline/io/mappers/AnnotationLineMapperTest.java index e95bf1b30..229c744af 100644 --- a/src/test/java/uk/ac/ebi/eva/pipeline/io/mappers/AnnotationLineMapperTest.java +++ b/src/test/java/uk/ac/ebi/eva/pipeline/io/mappers/AnnotationLineMapperTest.java @@ -22,6 +22,8 @@ import uk.ac.ebi.eva.commons.models.mongo.entity.subdocuments.Score; import uk.ac.ebi.eva.test.data.VepOutputContent; +import java.util.ArrayList; +import java.util.List; import java.util.Set; import static junit.framework.TestCase.assertNull; @@ -130,4 +132,13 @@ public void shouldParseVepOutputWithExtraFields() { assertEquals(expectedSift, sifts); assertEquals(expectedPolyphen, polyphen); } + + @Test + public void testChangeRefAltToUpperCase(){ + String vepOutputContent = "20_63351_a/g\t20:63351\tG\tENSG00000178591\tENST00000608838\tTranscript\tupstream_gene_variant\t-\t-\t-\t-\t-\trs181305519\tDISTANCE=4540;STRAND=1;SYMBOL=DEFB125;SYMBOL_SOURCE=HGNC;HGNC_ID=18105;BIOTYPE=processed_transcript;GMAF=G:0.0005;AFR_MAF=G:0.0020;polyphen=possibly_damaging(0.859);sift=tolerated(0.07)"; + AnnotationLineMapper lineMapper = new AnnotationLineMapper(VEP_VERSION, VEP_CACHE_VERSION); + String annotLine = vepOutputContent.split("\n")[0]; + Annotation annotation = lineMapper.mapLine(annotLine, 0); + assertEquals("20_63351_A_G", annotation.buildVariantId()); + } } diff --git a/src/test/java/uk/ac/ebi/eva/pipeline/io/mappers/VariantVcfFactoryTest.java b/src/test/java/uk/ac/ebi/eva/pipeline/io/mappers/VariantVcfFactoryTest.java index 9dbb5b8e5..4188606c8 100644 --- a/src/test/java/uk/ac/ebi/eva/pipeline/io/mappers/VariantVcfFactoryTest.java +++ b/src/test/java/uk/ac/ebi/eva/pipeline/io/mappers/VariantVcfFactoryTest.java @@ -587,4 +587,13 @@ public void testVariantIds() { assertEquals(expResult, result); assertEquals(emptySet, result.get(0).getIds()); } -} + + @Test + public void testChangeRefAltToUpperCase() { + String line = "chr1\t1000\t.\tt\tg\t.\t.\t.\tGT\t0/1"; + List expResult = Collections.singletonList(new Variant("chr1", 1000, 1000, "T", "G")); + List result = factory.create(FILE_ID, STUDY_ID, line); + assertEquals(expResult, result); + } + + } diff --git a/src/test/java/uk/ac/ebi/eva/pipeline/model/EnsemblVariantTest.java b/src/test/java/uk/ac/ebi/eva/pipeline/model/EnsemblVariantTest.java index eecb7c27c..d395f8e22 100644 --- a/src/test/java/uk/ac/ebi/eva/pipeline/model/EnsemblVariantTest.java +++ b/src/test/java/uk/ac/ebi/eva/pipeline/model/EnsemblVariantTest.java @@ -17,7 +17,6 @@ package uk.ac.ebi.eva.pipeline.model; import org.junit.Test; - import uk.ac.ebi.eva.commons.models.data.Variant; import uk.ac.ebi.eva.pipeline.io.mappers.VariantVcfFactory; @@ -88,7 +87,7 @@ public void transformInsertionFromVcfToEnsemblCoordinates() throws Exception { assertEquals("A", alternate); EnsemblVariant insertion = new EnsemblVariant(result.get(0).getChromosome(), start, result.get(0).getEnd(), - reference, alternate); + reference, alternate); assertEquals(4, insertion.getStart()); assertEquals(3, insertion.getEnd()); assertEquals("-/A", insertion.getRefAlt()); @@ -109,9 +108,15 @@ public void transformDeletionFromVcfToEnsemblCoordinates() throws Exception { assertEquals("", alternate); EnsemblVariant insertion = new EnsemblVariant(result.get(0).getChromosome(), start, result.get(0).getEnd(), - reference, alternate); + reference, alternate); assertEquals(3, insertion.getStart()); assertEquals(3, insertion.getEnd()); assertEquals("C/-", insertion.getRefAlt()); } + + @Test + public void testChangeRefAltToUpperCase() { + EnsemblVariant ensemblVariant = new EnsemblVariant("chr", 1, 2, "a", "t"); + assertEquals("A/T", ensemblVariant.getRefAlt()); + } } diff --git a/src/test/java/uk/ac/ebi/eva/pipeline/model/PopulationStatisticsTest.java b/src/test/java/uk/ac/ebi/eva/pipeline/model/PopulationStatisticsTest.java new file mode 100644 index 000000000..d77dbda63 --- /dev/null +++ b/src/test/java/uk/ac/ebi/eva/pipeline/model/PopulationStatisticsTest.java @@ -0,0 +1,18 @@ +package uk.ac.ebi.eva.pipeline.model; + +import org.junit.Test; + +import java.util.HashMap; + +import static org.junit.Assert.assertEquals; + +public class PopulationStatisticsTest { + @Test + public void testChangeRefAltToUpperCase() { + PopulationStatistics populationStatistics = new PopulationStatistics("variantId", "chr", 1, + "a", "t", "cohortId", "studyId", -1, -1, null, null, + -1, -1, new HashMap<>()); + assertEquals("A", populationStatistics.getReference()); + assertEquals("T", populationStatistics.getAlternate()); + } +}