public void ParseGenomeAssembly_IncorrectFormat_ThrowException() { using (var custParser = new CustomAnnotationsParser(GetReadStream("#assembly-GRCh38"), SequenceProvider)) { Assert.Throws <UserErrorException>(() => custParser.ParseGenomeAssembly()); } }
public void ReadlineAndCheckPrefix_InvalidPrefix_ThrowException() { using (var custParser = new CustomAnnotationsParser(GetReadStream("invalidPrefix=someValue"), SequenceProvider)) { Assert.Throws <UserErrorException>(() => custParser.ReadlineAndCheckPrefix("expectedPrefix", "anyRow")); } }
public void ParseTitle_IncorrectFormat() { using (var custParser = new CustomAnnotationsParser(GetReadStream("#title:customSA"), SequenceProvider)) { Assert.Throws <UserErrorException>(() => custParser.ParseTitle()); } }
public void ParseGenomeAssembly_UnsupportedAssembly_ThrowException() { using (var custParser = new CustomAnnotationsParser(GetReadStream("#assembly=hg19"), SequenceProvider)) { Assert.Throws <UserErrorException>(() => custParser.ParseGenomeAssembly()); } }
public void ParseTitle_Conflict_JsonTag() { using (var custParser = new CustomAnnotationsParser(GetReadStream("#title=topmed"), SequenceProvider)) { Assert.Throws <UserErrorException>(() => custParser.ParseTitle()); } }
public void ParseTags_LessThanFourColumn_ThrowException() { const string tagLine = "#CHROM\tPOS\tREF\n"; using (var caParser = new CustomAnnotationsParser(GetReadStream(tagLine), null)) { Assert.Throws <UserErrorException>(() => caParser.ParseTags()); } }
public void ParseTypes_InvalidType_ThrowException(string type) { string tagAndTypeLines = "#CHROM\tPOS\tREF\tALT\tValue\n" + $"#type\t.\t.\t.\t{type}"; using (var caParser = new CustomAnnotationsParser(GetReadStream(tagAndTypeLines), null)) { caParser.ParseTags(); Assert.Throws <UserErrorException>(() => caParser.ParseTypes()); } }
public void ParseTypes_ValidType_Pass(string type) { string tagAndTypeLines = "#CHROM\tPOS\tREF\tALT\tValue\n" + $"#type\t.\t.\t.\t{type}"; using (var caParser = new CustomAnnotationsParser(GetReadStream(tagAndTypeLines), null)) { caParser.ParseTags(); caParser.ParseTypes(); } }
public void ParseHeaderLines_InconsistentFields() { const string invalidHeaderLines = "#title=IcslAlleleFrequencies\n" + "#assembly=GRCh38\n" + "#CHROM\tPOS\tREF\tALT\tEND\tallAc\tallAn\tallAf\tfailedFilter\tpathogenicity\n" + "#categories\t.\t.\t.\t.\tAlleleCount\tAlleleNumber\tAlleleFrequency\t.\tPrediction\t.\tMore\n" + "#descriptions\t.\t.\t.\t.\tALL\tALL\tALL\n" + "#type\t.\t.\t.\t.\tnumber\tnumber\tnumber\tbool\tstring\tstring"; using (var custParser = new CustomAnnotationsParser(GetReadStream(invalidHeaderLines), null)) { Assert.Throws <UserErrorException>(() => custParser.ParseHeaderLines()); } }
public void CheckPosAndRefColumns_InvalidPosOrRef_ThrowException() { const string tagLine = "#CHROM\t\tREF\tALT\n"; using (var caParser = new CustomAnnotationsParser(GetReadStream(tagLine), null)) { Assert.Throws <UserErrorException>(() => caParser.ParseTags()); } const string tagLine2 = "#CHROM\tPOS\tREFERENCE\tALT\n"; using (var caParser = new CustomAnnotationsParser(GetReadStream(tagLine2), null)) { Assert.Throws <UserErrorException>(() => caParser.ParseTags()); } }
public void GetItems_ExtractCustomFilters_failsOnLargeText() { const string text = "#title=IcslAlleleFrequencies\n" + "#assembly=GRCh38\n" + "#matchVariantsBy=allele\n" + "#CHROM\tPOS\tREF\tALT\tEND\tallAc\tallAn\tallAf\tfailedFilter\tpathogenicity\tnotes\tanyNumber\tcustomFilter\n" + "#categories\t.\t.\t.\t.\tAlleleCount\tAlleleNumber\tAlleleFrequency\t.\tPrediction\t.\t.\tFilter\n" + "#descriptions\t.\t.\t.\t.\tALL\tALL\tALL\t.\t.\t.\t.\t.\n" + "#type\t.\t.\t.\t.\tnumber\tnumber\tnumber\tbool\tstring\tstring\tnumber\tstring\n" + "chr1\t12783\tG\tA\t.\t20\t125568\t0.000159\ttrue\tVUS\t\t1.000\tthe good variant, the bad variant and the ugly variant\n"; using (var custParser = CustomAnnotationsParser.Create(GetReadStream(text), SequenceProvider)) { Assert.Throws <UserErrorException>(() => custParser.GetItems().ToArray()); } }
public void ExtractItems_TrimmedAndLeftShifted() { const string text = "#title=IcslAlleleFrequencies\n" + "#assembly=GRCh38\n" + "#matchVariantsBy=allele\n" + "#CHROM\tPOS\tREF\tALT\tEND\tallAc\tallAn\tallAf\tfailedFilter\tpathogenicity\tnotes\n" + "#categories\t.\t.\t.\t.\tAlleleCount\tAlleleNumber\tAlleleFrequency\t.\tPrediction\t.\n" + "#descriptions\t.\t.\t.\t.\tALL\tALL\tALL\t.\t.\t.\n" + "#type\t.\t.\t.\t.\tnumber\tnumber\tnumber\tbool\tstring\tstring\n"; using (var parser = CustomAnnotationsParser.Create(GetReadStream(text), SequenceProvider)) { var item = parser.ExtractItems("chr1\t12783\tA\tATA\t.\t20\t125568\t0.000159\ttrue\tVUS\t"); Assert.Equal(12782, item.Position); Assert.Equal("", item.RefAllele); Assert.Equal("TA", item.AltAllele); } }
public void ParseHeaderLines_AsExpected() { const string headerLines = "#title=IcslAlleleFrequencies\n" + "#assembly=GRCh38\n" + "#matchVariantsBy=allele\n" + "#CHROM\tPOS\tREF\tALT\tEND\tallAc\tallAn\tallAf\tfailedFilter\tpathogenicity\tnotes\n" + "#categories\t.\t.\t.\t.\tAlleleCount\tAlleleNumber\tAlleleFrequency\t.\tPrediction\t.\n" + "#descriptions\t.\t.\t.\t.\tALL\tALL\tALL\t.\t.\t.\n" + "#type\t.\t.\t.\t.\tnumber\tnumber\tnumber\tbool\tstring\tstring"; using (var custParser = new CustomAnnotationsParser(GetReadStream(headerLines), null)) { custParser.ParseHeaderLines(); var expectedJsonKeys = new[] { "refAllele", "altAllele", "allAc", "allAn", "allAf", "failedFilter", "pathogenicity", "notes" }; var expectedIntervalJsonKeys = new[] { "start", "end", "allAc", "allAn", "allAf", "failedFilter", "pathogenicity", "notes" }; var expectedCategories = new[] { CustomAnnotationCategories.AlleleCount, CustomAnnotationCategories.AlleleNumber, CustomAnnotationCategories.AlleleFrequency, CustomAnnotationCategories.Unknown, CustomAnnotationCategories.Prediction, CustomAnnotationCategories.Unknown }; var expectedDescriptions = new[] { "ALL", "ALL", "ALL", null, null, null }; var expectedTypes = new[] { SaJsonValueType.Number, SaJsonValueType.Number, SaJsonValueType.Number, SaJsonValueType.Bool, SaJsonValueType.String, SaJsonValueType.String }; Assert.Equal("IcslAlleleFrequencies", custParser.JsonTag); Assert.Equal(GenomeAssembly.GRCh38, custParser.Assembly); Assert.True(expectedJsonKeys.SequenceEqual(custParser.JsonKeys)); Assert.True(expectedIntervalJsonKeys.SequenceEqual(custParser.IntervalJsonKeys)); Assert.True(expectedCategories.SequenceEqual(custParser.Categories)); Assert.True(expectedDescriptions.SequenceEqual(custParser.Descriptions)); Assert.Equal(expectedTypes, custParser.ValueTypes); } }
public void GetItems_UnsortedData_ThrowException() { const string text = "#title=IcslAlleleFrequencies\n" + "#assembly=GRCh38\n" + "#matchVariantsBy=allele\n" + "#CHROM\tPOS\tREF\tALT\tEND\tallAc\tallAn\tallAf\tfailedFilter\tpathogenicity\tnotes\tanyNumber\n" + "#categories\t.\t.\t.\t.\tAlleleCount\tAlleleNumber\tAlleleFrequency\t.\tPrediction\t.\t.\n" + "#descriptions\t.\t.\t.\t.\tALL\tALL\tALL\t.\t.\t.\t.\n" + "#type\t.\t.\t.\t.\tnumber\tnumber\tnumber\tbool\tstring\tstring\tnumber\n" + "chr1\t12783\tG\tA\t.\t20\t125568\t0.000159\ttrue\tVUS\t\t1.000\n" + "chr1\t3302\tC\tA\t.\t53\t8928\t0.001421\tfalse\t.\t\t3\n" + "chr1\t18972\tT\tC\t.\t10\t1000\t0.01\tfalse\t.\t\t100.1234567\n" + "chr1\t46993\tA\t<DEL>\t50879\t50\t250\t0.001\tfalse\tbenign\t\t3.1415926"; using (var caParser = CustomAnnotationsParser.Create(GetReadStream(text), SequenceProvider)) { Assert.Throws <UserErrorException>(() => caParser.GetItems().ToArray()); } }
public void GetItems() { const string text = "#title=IcslAlleleFrequencies\n" + "#assembly=GRCh38\n" + "#matchVariantsBy=allele\n" + "#CHROM\tPOS\tREF\tALT\tEND\tallAc\tallAn\tallAf\tfailedFilter\tpathogenicity\tnotes\n" + "#categories\t.\t.\t.\t.\tAlleleCount\tAlleleNumber\tAlleleFrequency\t.\tPrediction\t.\n" + "#descriptions\t.\t.\t.\t.\tALL\tALL\tALL\t.\t.\t.\n" + "#type\t.\t.\t.\t.\tnumber\tnumber\tnumber\tbool\tstring\tstring\n" + "chr1\t14783\tG\tA\t.\t20\t125568\t0.000159\ttrue\tVUS\t\n" + "chr2\t10302\tC\tA\t.\t53\t8928\t0.001421\tfalse\t.\t\n" + "chr2\t46993\tA\t<DEL>\t50879\t50\t250\t0.001\tfalse\tbenign\t"; using (var custParser = CustomAnnotationsParser.Create(GetReadStream(text), SequenceProvider)) { var items = custParser.GetItems().ToArray(); Assert.Equal(2, items.Length); Assert.Equal("\"refAllele\":\"G\",\"altAllele\":\"A\",\"allAc\":20,\"allAn\":125568,\"allAf\":0.000159,\"failedFilter\":true,\"pathogenicity\":\"VUS\"", items[0].GetJsonString()); Assert.Equal("\"refAllele\":\"C\",\"altAllele\":\"A\",\"allAc\":53,\"allAn\":8928,\"allAf\":0.001421", items[1].GetJsonString()); } }
public void IsValidNucleotideSequence_IsValidSequence_Pass() { Assert.True(CustomAnnotationsParser.IsValidNucleotideSequence("actgnACTGN")); Assert.False(CustomAnnotationsParser.IsValidNucleotideSequence("AC-GT")); }