예제 #1
0
        private static ExitCodes ProgramExecution()
        {
            var dosageSensitivityVersion = DataSourceVersionReader.GetSourceVersion(_dosageSensitivityFile + ".version");

            string outFileName = $"{dosageSensitivityVersion.Name.Replace(' ','_')}_{dosageSensitivityVersion.Version}";

            using (var dosageSensitivityParser = new DosageSensitivityParser(GZipUtilities.GetAppropriateReadStream(_dosageSensitivityFile)))
                using (var stream = FileUtilities.GetCreateStream(Path.Combine(_outputDirectory, outFileName + SaCommon.NgaFileSuffix)))
                    using (var ngaWriter = new NgaWriter(stream, dosageSensitivityVersion, SaCommon.DosageSensitivityTag, SaCommon.SchemaVersion, false))
                    {
                        ngaWriter.Write(dosageSensitivityParser.GetItems());
                    }

            return(ExitCodes.Success);
        }
예제 #2
0
파일: Main.cs 프로젝트: wangdi2014/Nirvana
        private static ExitCodes ProgramExecution()
        {
            var version = DataSourceVersionReader.GetSourceVersion(_inputFile + ".version");

            string outFileName = $"{version.Name}_{version.Version}";

            //create universal gene archive
            using (var exacParser = new ExacScoresParser(GZipUtilities.GetAppropriateStreamReader(_inputFile)))
                using (var stream = FileUtilities.GetCreateStream(Path.Combine(_outputDirectory, outFileName + SaCommon.NgaFileSuffix)))
                    using (var ngaWriter = new NgaWriter(stream, version, SaCommon.ExacScoreTag, SaCommon.SchemaVersion, false))
                    {
                        ngaWriter.Write(exacParser.GetItems());
                    }

            return(ExitCodes.Success);
        }
예제 #3
0
        private static ExitCodes ProgramExecution()
        {
            var dosageSensitivityVersion = DataSourceVersionReader.GetSourceVersion(_diseaseValidityFile + ".version");

            string outFileName = $"{dosageSensitivityVersion.Name.Replace(' ', '_')}_{dosageSensitivityVersion.Version}";

            // read uga file to get hgnc id to gene symbols dictionary
            using (var diseaseValidityParser = new GeneDiseaseValidityParser(GZipUtilities.GetAppropriateReadStream(_diseaseValidityFile), GetHgncIdToGeneSymbols()))
                using (var stream = FileUtilities.GetCreateStream(Path.Combine(_outputDirectory, outFileName + SaCommon.GeneFileSuffix)))
                    using (var ngaWriter = new NgaWriter(stream, dosageSensitivityVersion, SaCommon.DiseaseValidityTag, SaCommon.SchemaVersion, true))
                    {
                        ngaWriter.Write(diseaseValidityParser.GetItems());
                    }

            return(ExitCodes.Success);
        }
예제 #4
0
        public void ReadBackGeneAnnotations()
        {
            var writeStream = new MemoryStream();
            var version     = new DataSourceVersion("source1", "v1", DateTime.Now.Ticks);
            var ngaWriter   = new NgaWriter(writeStream, version, "mimo", SaCommon.SchemaVersion, true);

            ngaWriter.Write(GetGeneAnnotations());

            var readStream = new MemoryStream(writeStream.ToArray());

            using (var ngaReader = new NgaReader(readStream))
            {
                Assert.Null(ngaReader.GetAnnotation("gene3"));
                Assert.Equal("[{\"mimNumber\":123,\"geneName\":\"gene name 1 ('minibrain', Drosophila, homolog of)\",\"description\":\"describing gene 1\\n\\\"some citation\\\"\",\"phenotypes\":[{\"phenotype\":\"disease 1\",\"mapping\":\"mapping of the wildtype gene\",\"inheritances\":[\"autosomal recessive\"],\"comments\":\"unconfirmed or possibly spurious mapping\"}]}]", ngaReader.GetAnnotation("gene1"));
                Assert.Equal("[{\"mimNumber\":124,\"geneName\":\"gene name 2\",\"phenotypes\":[{\"phenotype\":\"disease 2\",\"mapping\":\"chromosome deletion or duplication syndrome\",\"inheritances\":[\"whatever\",\"never-ever\"],\"comments\":\"nondiseases\"}]}]", ngaReader.GetAnnotation("gene2"));
            }

            ngaWriter.Dispose();
        }
예제 #5
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);
        }
예제 #6
0
        public void ReadBackGeneAnnotations()
        {
            NgaReader    reader;
            var          version = new DataSourceVersion("source1", "v1", DateTime.Now.Ticks);
            const string jsonKey = "mimo";
            const bool   isArray = true;

            using (var ms = new MemoryStream())
            {
                using (var writer = new NgaWriter(ms, version, jsonKey, SaCommon.SchemaVersion, isArray, true))
                {
                    writer.Write(GetGeneAnnotations());
                }

                ms.Position = 0;
                reader      = NgaReader.Read(ms);
            }

            Assert.NotNull(reader);
            Assert.Null(reader.GetAnnotation("gene3"));
            Assert.Equal("[{\"mimNumber\":123,\"geneName\":\"gene name 1 ('minibrain', Drosophila, homolog of)\",\"description\":\"describing gene 1\\n\\\"some citation\\\"\",\"phenotypes\":[{\"phenotype\":\"disease 1\",\"description\":\"This is disease 1\",\"mapping\":\"mapping of the wildtype gene\",\"inheritances\":[\"autosomal recessive\"],\"comments\":[\"unconfirmed or possibly spurious mapping\"]}]}]", reader.GetAnnotation("gene1"));
            Assert.Equal("[{\"mimNumber\":124,\"geneName\":\"gene name 2\",\"phenotypes\":[{\"phenotype\":\"disease 2\",\"description\":\"COVID-19\",\"mapping\":\"chromosome deletion or duplication syndrome\",\"inheritances\":[\"whatever\",\"never-ever\"],\"comments\":[\"nondiseases\"]}]}]", reader.GetAnnotation("gene2"));
        }
예제 #7
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);
        }
예제 #8
0
        private static ExitCodes ProgramExecution()
        {
            Dictionary <string, string> geneIdToSymbols;

            using (var cacheStream = FileUtilities.GetReadStream(CacheConstants.TranscriptPath(_cachePrefix)))
                using (var transcriptCacheReader = new TranscriptCacheReader(cacheStream))
                    using (var refProvider = new ReferenceSequenceProvider(FileUtilities.GetReadStream(_referenceSequncePath)))
                    {
                        geneIdToSymbols = LoadGenesFromCache(refProvider, transcriptCacheReader);
                        Console.WriteLine($"Loaded {geneIdToSymbols.Count} gene symbols from cache.");
                    }

            var version     = DataSourceVersionReader.GetSourceVersion(_inputFile + ".version");
            var outFileName = $"{version.Name}_{version.Version}";

            using (var gnomadGeneParser = new GnomadGeneParser(GZipUtilities.GetAppropriateStreamReader(_inputFile), geneIdToSymbols))
                using (var stream = FileUtilities.GetCreateStream(Path.Combine(_outputDirectory, outFileName + SaCommon.NgaFileSuffix)))
                    using (var ngaWriter = new NgaWriter(stream, version, SaCommon.GnomadGeneScoreTag, SaCommon.SchemaVersion, false))
                    {
                        ngaWriter.Write(gnomadGeneParser.GetItems());
                    }

            return(ExitCodes.Success);
        }