public CustomGene(string geneSymbol, List <string[]> values, SaJsonSchema jsonSchema, string inputLine) { GeneSymbol = geneSymbol; _values = values; _jsonSchema = jsonSchema; _inputLine = inputLine; }
public static Dictionary <string, List <ISuppGeneItem> > GetGeneToOmimEntriesAndSchema(IEnumerable <OmimItem> omimItems) { var geneToOmimEntries = new Dictionary <string, List <ISuppGeneItem> >(); SaJsonSchema jsonSchema = null; foreach (var item in omimItems) { if (jsonSchema == null) { jsonSchema = item.JsonSchema; } if (item.GeneSymbol == null) { continue; } if (geneToOmimEntries.TryGetValue(item.GeneSymbol, out var mimList)) { mimList.Add(item); } else { geneToOmimEntries[item.GeneSymbol] = new List <ISuppGeneItem> { item }; } } return(geneToOmimEntries); }
public void CheckAndGetBoolFromString_InvalidValue_ThrowException() { Assert.Throws <UserErrorException>(() => SaJsonSchema.CheckAndGetBoolFromString("T")); Assert.Throws <UserErrorException>(() => SaJsonSchema.CheckAndGetBoolFromString("F")); Assert.Throws <UserErrorException>(() => SaJsonSchema.CheckAndGetBoolFromString("0")); Assert.Throws <UserErrorException>(() => SaJsonSchema.CheckAndGetBoolFromString("-")); }
public static OmimItem.Phenotype GetPhenotype(PhenotypeMap phenotypeMap, SaJsonSchema jsonSchema) { var phenotypeItem = phenotypeMap.phenotypeMap; var(phenotype, comments) = ExtractPhenotypeAndComments(phenotypeItem.phenotype); return(new OmimItem.Phenotype(phenotypeItem.phenotypeMimNumber, phenotype, (OmimItem.Mapping)phenotypeItem.phenotypeMappingKey, comments, ExtractInheritances(phenotypeItem.phenotypeInheritance), jsonSchema)); }
public static OmimItem.Phenotype GetPhenotype(PhenotypeMap phenotypeMap, SaJsonSchema jsonSchema) { var phenotypeItem = phenotypeMap.phenotypeMap; var(phenotype, _) = ExtractPhenotypeAndComments(phenotypeItem.phenotype); //Don't output any comments for now return(new OmimItem.Phenotype(phenotypeItem.phenotypeMimNumber, phenotype, (OmimItem.Mapping)phenotypeItem.phenotypeMappingKey, OmimItem.Comments.unknown, ExtractInheritances(phenotypeItem.phenotypeInheritance), jsonSchema)); }
public OmimItem(string geneSymbol, string geneName, string description, int mimNumber, List <Phenotype> phenotypes, SaJsonSchema jsonSchema) { GeneSymbol = geneSymbol; _geneName = geneName; _description = description; _mimNumber = mimNumber; _phenotypes = phenotypes; JsonSchema = jsonSchema; }
public Phenotype(int mimNumber, string phenotype, Mapping mapping, Comment[] comments, HashSet <string> inheritance, SaJsonSchema schema) { _mimNumber = mimNumber; _phenotype = phenotype; _mapping = mapping; _comments = comments; _inheritance = inheritance; _jsonSchema = schema; }
public void OutputKeyAnnotation_AsExpected() { var sb = new StringBuilder(); var jsonSchema = new SaJsonSchema(sb); jsonSchema.AddAnnotation("name", SaJsonKeyAnnotation.CreateFromProperties(SaJsonValueType.String, 0, null)); jsonSchema.OutputKeyAnnotation("name"); Assert.Equal("\"name\":{\"type\":\"string\"}", sb.ToString()); }
public void Create_InitialJsonObject_AsExpected() { var sb = new StringBuilder(); SaJsonSchema.Create(sb, "test", SaJsonValueType.ObjectArray, new List <string>()); const string expectedJsonString = "{\"$schema\":\"" + SchemaVersion + "\",\"type\":\"object\",\"properties\":{\"test\":{\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{"; Assert.Equal(expectedJsonString, sb.ToString()); }
public void CheckAndGetBoolFromString_AsExpected() { Assert.True(SaJsonSchema.CheckAndGetBoolFromString("true")); Assert.True(SaJsonSchema.CheckAndGetBoolFromString("TRUE")); Assert.False(SaJsonSchema.CheckAndGetBoolFromString("false")); Assert.False(SaJsonSchema.CheckAndGetBoolFromString("False")); Assert.False(SaJsonSchema.CheckAndGetBoolFromString("")); Assert.False(SaJsonSchema.CheckAndGetBoolFromString(".")); }
/// <summary> /// constructor /// </summary> public CustomInterval(IChromosome chromosome, int start, int end, List <string[]> values, SaJsonSchema jsonSchema, string inputLine) { Chromosome = chromosome; Start = start; End = end; VariantType = VariantType.structural_alteration; _values = values; _jsonSchema = jsonSchema; _inputLine = inputLine; }
public CustomItem(IChromosome chromosome, int start, string refAllele, string altAllele, string[][] values, SaJsonSchema jsonSchema, string inputLine) { Chromosome = chromosome; Position = start; RefAllele = refAllele; AltAllele = altAllele; _values = values; _jsonSchema = jsonSchema; _inputLine = inputLine; }
public OmimParser(GeneSymbolUpdater geneSymbolUpdater, SaJsonSchema jsonSchema, string apiKey, string dumpFilePath) { _geneSymbolUpdater = geneSymbolUpdater; _jsonSchema = jsonSchema; if (dumpFilePath != null) { _zipFileStream = new FileStream(dumpFilePath, FileMode.Create); _zipArchive = new ZipArchive(_zipFileStream, ZipArchiveMode.Create); } _httpClient = new HttpClient(); _httpClient.DefaultRequestHeaders.Add("ApiKey", apiKey); }
public static SaJsonSchema Get() { var jsonSchema = SaJsonSchema.Create(new StringBuilder(), SaCommon.ClinvarTag, PrimaryValueType, JsonKeys); jsonSchema.SetNonSaKeys(new [] { "isAlleleSpecific" }); foreach ((string key, var valueType) in JsonKeys.Zip(ValueTypes, (a, b) => (a, b))) { jsonSchema.AddAnnotation(key, SaJsonKeyAnnotation.CreateFromProperties(valueType, 0, null)); } return(jsonSchema); }
public void GetJsonString_AsExpected() { var jsonSchema = SaJsonSchema.Create(new StringBuilder(), "test", SaJsonValueType.ObjectArray, new List <string> { "name", "phone", "employed" }); jsonSchema.AddAnnotation("name", SaJsonKeyAnnotation.CreateFromProperties(SaJsonValueType.String, 0, null)); jsonSchema.AddAnnotation("phone", SaJsonKeyAnnotation.CreateFromProperties(SaJsonValueType.Number, 0, "phone number")); jsonSchema.AddAnnotation("employed", SaJsonKeyAnnotation.CreateFromProperties(SaJsonValueType.Bool, 0, null)); var jsonString = jsonSchema.GetJsonString(new List <string[]> { new[] { "Ada" }, new[] { "123456" }, new[] { "true" } }); Assert.Equal("\"name\":\"Ada\",\"phone\":123456,\"employed\":true", jsonString); }
public void GetJsonString_DoubleValueHandling_AsExpected() { var jsonSchema = SaJsonSchema.Create(new StringBuilder(), "test", SaJsonValueType.ObjectArray, new List <string> { "allAf", "doubleValue1", "doubleValue2" }); jsonSchema.AddAnnotation("allAf", SaJsonKeyAnnotation.CreateFromProperties(SaJsonValueType.Number, CustomAnnotationCategories.AlleleFrequency, null)); jsonSchema.AddAnnotation("doubleValue1", SaJsonKeyAnnotation.CreateFromProperties(SaJsonValueType.Number, 0, "A double value")); jsonSchema.AddAnnotation("doubleValue2", SaJsonKeyAnnotation.CreateFromProperties(SaJsonValueType.Number, 0, "Another double value")); var jsonString = jsonSchema.GetJsonString(new List <string[]> { new[] { "0.12345678" }, new[] { "0.12" }, new[] { "0.12345678" } }); Assert.Equal("\"allAf\":0.123457,\"doubleValue1\":0.12,\"doubleValue2\":0.12345678", jsonString); }
public ClinVarItem(IChromosome chromosome, int position, int stop, string refAllele, string altAllele, SaJsonSchema jsonSchema, IEnumerable <string> alleleOrigins, string variantType, string id, string variationId, ClinVarCommon.ReviewStatus reviewStatus, IEnumerable <string> medGenIds, IEnumerable <string> omimIds, IEnumerable <string> orphanetIds, IEnumerable <string> phenotypes, string[] significances, IEnumerable <long> pubmedIds = null, long lastUpdatedDate = long.MinValue ) { Chromosome = chromosome; Position = position; Stop = stop; AlleleOrigins = alleleOrigins; AltAllele = altAllele; JsonSchema = jsonSchema; VariantType = variantType; Id = id; VariationId = variationId; MedGenIds = medGenIds; OmimIds = omimIds; OrphanetIds = orphanetIds; Phenotypes = phenotypes; RefAllele = refAllele; Significances = significances; PubmedIds = pubmedIds; LastUpdatedDate = lastUpdatedDate; IsAlleleSpecific = null; ReviewStatus = reviewStatus; }
public void ToString_AsExpected() { var jsonSchema = SaJsonSchema.Create(new StringBuilder(), "test", SaJsonValueType.ObjectArray, new List <string> { "name", "phone", "employed" }); jsonSchema.AddAnnotation("name", SaJsonKeyAnnotation.CreateFromProperties(SaJsonValueType.String, 0, null)); jsonSchema.AddAnnotation("phone", SaJsonKeyAnnotation.CreateFromProperties(SaJsonValueType.Number, 0, "phone number")); jsonSchema.AddAnnotation("employed", SaJsonKeyAnnotation.CreateFromProperties(SaJsonValueType.Bool, 0, null)); jsonSchema.TotalItems = 100; jsonSchema.KeyCounts["name"] = 100; jsonSchema.KeyCounts["phone"] = 50; jsonSchema.KeyCounts["employed"] = 0; const string expectedJsonSchemaString = "{\"$schema\":\"" + SchemaVersion + "\",\"type\":\"object\",\"properties\":{\"test\":{\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{" + "\"name\":{\"type\":\"string\"},\"phone\":{\"type\":\"number\",\"description\":\"phone number\"}}," + "\"required\":[\"name\"],\"additionalProperties\":false}}}}"; Assert.Equal(expectedJsonSchemaString, jsonSchema.ToString()); // make sure the returned string is the same when ToString method is called more than once Assert.Equal(expectedJsonSchemaString, jsonSchema.ToString()); }
public void CheckAndGetNullableDoubleFromString_GetNull_AsExpected() { Assert.Null(SaJsonSchema.CheckAndGetNullableDoubleFromString("")); Assert.Null(SaJsonSchema.CheckAndGetNullableDoubleFromString(".")); }
public void CheckAndGetNullableDoubleFromString_NotANum_ThrowException() { Assert.Throws <UserErrorException>(() => SaJsonSchema.CheckAndGetNullableDoubleFromString("Bob")); Assert.Throws <UserErrorException>(() => SaJsonSchema.CheckAndGetNullableDoubleFromString("1+1")); Assert.Throws <UserErrorException>(() => SaJsonSchema.CheckAndGetNullableDoubleFromString("bool")); }
public OmimParser(string mimToGeneSymbolFile, string omimJsonFile, SaJsonSchema jsonSchema) { _mimToGeneSymbolFile = mimToGeneSymbolFile; _omimJsonFile = omimJsonFile; _jsonSchema = jsonSchema; }
public static OmimItem.Phenotype GetPhenotype(PhenotypeMap phenotypeMap, IDictionary <int, string> phenotypeDescriptions, SaJsonSchema jsonSchema) { var phenotypeItem = phenotypeMap.phenotypeMap; var mimNumber = phenotypeItem.phenotypeMimNumber; phenotypeDescriptions.TryGetValue(mimNumber, out var description); var(phenotype, comments) = ExtractPhenotypeAndComments(phenotypeItem.phenotype); return(new OmimItem.Phenotype(mimNumber, phenotype, description, (OmimItem.Mapping)phenotypeItem.phenotypeMappingKey, comments, ExtractInheritances(phenotypeItem.phenotypeInheritance), jsonSchema)); }
private void InitiateSchema() { JsonSchema = SaJsonSchema.Create(new StringBuilder(), JsonTag, SaJsonValueType.Object, JsonKeys); }