示例#1
0
        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(entrezGeneIdToSymbol, ensemblGeneIdToSymbol) = GeneUtilities.ParseUniversalGeneArchive(_inputReferencePath, _universalGeneArchivePath);
            var geneSymbolUpdater = new GeneSymbolUpdater(entrezGeneIdToSymbol, ensemblGeneIdToSymbol);

            using (var omimQuery = new OmimQuery(_apiKey, _outputDirectory))
            {
                omimQuery.GenerateMimToGeneSymbolFile(geneSymbolUpdater);
                omimQuery.GenerateJsonResponse();
            }
            OmimVersion.WriteToFile(OmimQuery.JsonResponseFile, _outputDirectory);

            geneSymbolUpdater.DisplayStatistics();
            return(ExitCodes.Success);
        }
示例#2
0
        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);
        }