public void ParseHeaderLines_InconsistentFields() { const string invalidHeaderLines = "#title=InternalGeneAnnotation\n" + "#geneSymbol\tgeneId\tphenotype\tmimNumber\tnotes\n" + "#categories\t\t\tstring\tnumber\t.\n" + "#descriptions\t.\t.\t.\t.\tSome\tText\tHere\n" + "#type\t\t\tstring\tnumber\t.\n"; using (var parser = new GeneAnnotationsParser(GetReadStream(invalidHeaderLines), EntrezGeneIdToSymbol, EnsemblIdToSymbol)) { Assert.Throws <UserErrorException>(() => parser.ParseHeaderLines()); } }
public void ParseHeaderLines_version_and_Description() { const string headerLines = "#title=InternalGeneAnnotation\n" + "#version=v1.1\n" + "#description=Internal Gene Annotation\n" + "#geneSymbol\tgeneId\tOMIM Description\tIs Oncogene\tphenotype\tmimNumber\tnotes\n" + "#categories\t.\tDescription\tFilter\t\tIdentifier\t.\n" + "#descriptions\t.\tGene description from OMIM\t\tGene phenotype\t\tFree text\n" + "#type\t\tstring\tbool\tstring\tnumber\tstring\n"; using (var parser = new GeneAnnotationsParser(GetReadStream(headerLines), EntrezGeneIdToSymbol, EnsemblIdToSymbol)) { parser.ParseHeaderLines(); Assert.Equal("v1.1", parser.Version); Assert.Equal("Internal Gene Annotation", parser.DataSourceDescription); } }
public void ParseHeaderLines_AsExpected() { const string headerLines = "#title=InternalGeneAnnotation\n" + "#geneSymbol\tgeneId\tOMIM Description\tIs Oncogene\tphenotype\tmimNumber\tnotes\n" + "#categories\t.\tDescription\tFilter\t\tIdentifier\t.\n" + "#descriptions\t.\tGene description from OMIM\t\tGene phenotype\t\tFree text\n" + "#type\t\tstring\tbool\tstring\tnumber\tstring\n"; using (var parser = new GeneAnnotationsParser(GetReadStream(headerLines), EntrezGeneIdToSymbol, EnsemblIdToSymbol)) { parser.ParseHeaderLines(); var expectedJsonKeys = new[] { "OMIM Description", "Is Oncogene", "phenotype", "mimNumber", "notes" }; var expectedCategories = new[] { CustomAnnotationCategories.Description, CustomAnnotationCategories.Filter, CustomAnnotationCategories.Unknown, CustomAnnotationCategories.Identifier, CustomAnnotationCategories.Unknown }; var expectedDescriptions = new[] { "Gene description from OMIM", null, "Gene phenotype", null, "Free text" }; var expectedTypes = new[] { SaJsonValueType.String, SaJsonValueType.Bool, SaJsonValueType.String, SaJsonValueType.Number, SaJsonValueType.String }; Assert.Equal("InternalGeneAnnotation", parser.JsonTag); Assert.Equal(expectedJsonKeys, parser.JsonKeys); Assert.Equal(expectedCategories, parser.Categories); Assert.Equal(expectedDescriptions, parser.Descriptions); Assert.Equal(expectedTypes, parser.ValueTypes); } }