コード例 #1
0
        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));
            }
        }
コード例 #2
0
ファイル: OmimParser.cs プロジェクト: wook2014/Nirvana
        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));
            }
        }
コード例 #3
0
ファイル: Main.cs プロジェクト: wook2014/Nirvana
        private static ExitCodes ProgramExecution()
        {
            var omimSchema = OmimSchema.Get();

            var    omimParser  = new OmimParser(_mimToGeneFile, _omimJsonFile, omimSchema);
            var    version     = omimParser.GetVersion();
            string outFileName = $"{version.Name}_{version.Version}";

            using (var nsaStream = FileUtilities.GetCreateStream(Path.Combine(_outputDirectory, outFileName + SaCommon.GeneFileSuffix)))
                using (var ngaWriter = new NgaWriter(nsaStream, version, SaCommon.OmimTag, SaCommon.SchemaVersion, true))
                    using (var saJsonSchemaStream = FileUtilities.GetCreateStream(Path.Combine(_outputDirectory, outFileName + SaCommon.GeneFileSuffix + SaCommon.JsonSchemaSuffix)))
                        using (var schemaWriter = new StreamWriter(saJsonSchemaStream))
                        {
                            var omimItems   = omimParser.GetItems();
                            var geneToItems = OmimUtilities.GetGeneToOmimEntriesAndSchema(omimItems);
                            ngaWriter.Write(geneToItems);
                            schemaWriter.Write(omimSchema);
                        }

            return(ExitCodes.Success);
        }
コード例 #4
0
ファイル: OmimParser.cs プロジェクト: wook2014/Nirvana
        private static IDictionary <int, string> GetPhenotypeDescriptions(EntryRoot entryRoot)
        {
            IDictionary <int, string> phenotypeToDescription = new Dictionary <int, string>();

            foreach (var entry in entryRoot.omim.entryList)
            {
                var item = entry.entry;
                // gene only item
                if (item.prefix == '*')
                {
                    continue;
                }

                var description = OmimUtilities.ExtractAndProcessItemDescription(item);
                if (string.IsNullOrEmpty(description))
                {
                    continue;
                }
                phenotypeToDescription[item.mimNumber] = description;
            }

            return(phenotypeToDescription);
        }
コード例 #5
0
        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++;
            }
        }
コード例 #6
0
ファイル: Main.cs プロジェクト: wangdi2014/Nirvana
        private static ExitCodes ProgramExecution()
        {
            _apiKey = GetEnvironmentVariable(OmimApiKeyEnvironmentVariableName);
            if (_apiKey == null)
            {
                throw new InvalidDataException("Please set the OMIM API key as the environment variable \"OmimApiKey\".");
            }

            var    version      = OmimVersion.GetVersion();
            string outFileName  = $"{version.Name}_{version.Version}";
            string dumpFilePath = Path.Combine(_outputDirectory, OmimDumpFileBaseName + version.Version + OmimDumpFileSuffix);

            var(entrezGeneIdToSymbol, ensemblGeneIdToSymbol) = OmimUtilities.ParseUniversalGeneArchive(_inputReferencePath, _universalGeneArchivePath);
            var geneSymbolUpdater = new GeneSymbolUpdater(entrezGeneIdToSymbol, ensemblGeneIdToSymbol);

            var omimSchema = OmimSchema.Get();

            using (var omimParser = new OmimParser(geneSymbolUpdater, omimSchema, _apiKey, dumpFilePath))
                using (var nsaStream = FileUtilities.GetCreateStream(Path.Combine(_outputDirectory, outFileName + SaCommon.NgaFileSuffix)))
                    using (var ngaWriter = new NgaWriter(nsaStream, version, SaCommon.OmimTag, SaCommon.SchemaVersion, true))
                        using (var saJsonSchemaStream = FileUtilities.GetCreateStream(Path.Combine(_outputDirectory, outFileName + SaCommon.NgaFileSuffix + SaCommon.JsonSchemaSuffix)))
                            using (var schemaWriter = new StreamWriter(saJsonSchemaStream))
                            {
                                var omimItems   = omimParser.GetItems();
                                var geneToItems = OmimUtilities.GetGeneToOmimEntriesAndSchema(omimItems);
                                ngaWriter.Write(geneToItems);
                                schemaWriter.Write(omimSchema);
                            }

            geneSymbolUpdater.DisplayStatistics();
            using (var writer = new StreamWriter(FileUtilities.GetCreateStream("UpdatedGeneSymbols.txt")))
            {
                geneSymbolUpdater.WriteUpdatedGeneSymbols(writer);
            }

            return(ExitCodes.Success);
        }