public IEnumerable <OmimItem> GetItems() { var mimToGeneSymbol = GetMimNumberToGeneSymbol(); foreach (var entry in GetEntryItems()) { int mimNumber = entry.mimNumber; string description = entry.textSectionList?[0].textSection.textSectionContent.RemoveLinks().RemoveFormatControl(); string geneName = entry.geneMap?.geneName; var phenotypes = entry.geneMap?.phenotypeMapList?.Select(x => OmimUtilities.GetPhenotype(x, _jsonSchema.GetSubSchema("phenotypes"))) .ToList() ?? new List <OmimItem.Phenotype>(); yield return(new OmimItem(mimToGeneSymbol[mimNumber.ToString()], geneName, description, mimNumber, phenotypes, _jsonSchema)); } }
private IEnumerable <OmimItem> GetOmimItemsFromMinNumbers(IDictionary <string, string> mimToGeneSymbol, ZipArchive zipArchive) { var i = 0; var queryIndex = 1; var mimNumbers = mimToGeneSymbol.Select(x => x.Key).ToArray(); while (i < mimNumbers.Length) { int endMimNumberIndex = Math.Min(i + EntryQueryLimit - 1, mimNumbers.Length - 1); string mimNumberString = GetMimNumbersString(mimNumbers, i, endMimNumberIndex); string queryUrl = GetApiQueryUrl(OmimApiUrl, EntryHandler, ("mimNumber", mimNumberString), ("include", "text:description"), ("include", "externalLinks"), ("include", "geneMap"), ("format", ReturnDataFormat)); using (StreamWriter writer = zipArchive == null ? null : new StreamWriter(zipArchive.CreateEntry($"EntryQueryResponses/response{queryIndex}.txt").Open())) using (var response = _httpClient.GetAsync(queryUrl).Result) { string responseContent = response.Content.ReadAsStringAsync().Result; writer?.Write(responseContent); var entryResponse = JsonConvert.DeserializeObject <EntryRoot>(responseContent); var entryIndex = 0; foreach (var entry in entryResponse.omim.entryList) { int mimNumber = entry.entry.mimNumber; string description = OmimUtilities.RemoveLinksInText(entry.entry.textSectionList?[0].textSection.textSectionContent); string geneName = entry.entry.geneMap?.geneName; var phenotypes = entry.entry.geneMap?.phenotypeMapList?.Select(x => OmimUtilities.GetPhenotype(x, _jsonSchema.GetSubSchema("phenotypes"))).ToList() ?? new List <OmimItem.Phenotype>(); yield return(new OmimItem(mimToGeneSymbol[mimNumber.ToString()], geneName, description, mimNumber, phenotypes, _jsonSchema)); entryIndex++; } } i = endMimNumberIndex + 1; queryIndex++; } }
private IEnumerable <OmimItem> GetOmimItems(EntryRoot entryRoot, IDictionary <int, string> mimToGeneSymbol, IDictionary <int, string> phenotypeDescriptions) { foreach (var entry in entryRoot.omim.entryList) { var item = entry.entry; var mimNumber = item.mimNumber; //skip if not a supported gene symbol if (!mimToGeneSymbol.TryGetValue(mimNumber, out var geneSymbol)) { continue; } string description = OmimUtilities.ExtractAndProcessItemDescription(item); string geneName = item.geneMap?.geneName; var phenotypes = item.geneMap?.phenotypeMapList?.Select(x => OmimUtilities.GetPhenotype(x, phenotypeDescriptions, _jsonSchema.GetSubSchema("phenotypes"))) .ToList() ?? new List <OmimItem.Phenotype>(); yield return(new OmimItem(geneSymbol, geneName, description, mimNumber, phenotypes, _jsonSchema)); } }