Example #1
0
        public void GenerateMimToGeneSymbolFile(GeneSymbolUpdater geneSymbolUpdater)
        {
            using StreamWriter writer = new StreamWriter(_mimToSymbolStream);
            using var response        = _httpClient.GetAsync(Mim2GeneUrl).Result;
            using var reader          = new StreamReader(response.Content.ReadAsStreamAsync().Result);
            writer.WriteLine("#MIM number\tGene symbol");
            string line;

            while ((line = reader.ReadLine()) != null)
            {
                if (line.OptimizedStartsWith('#'))
                {
                    continue;
                }

                var fields     = line.OptimizedSplit('\t');
                var geneSymbol = fields[3];
                if (string.IsNullOrEmpty(geneSymbol))
                {
                    continue;
                }

                var mimNumber         = fields[0];
                var entrezGeneId      = fields[2];
                var ensemblGeneId     = fields[4];
                var updatedGeneSymbol = geneSymbolUpdater.UpdateGeneSymbol(geneSymbol, ensemblGeneId, entrezGeneId);
                if (string.IsNullOrEmpty(updatedGeneSymbol))
                {
                    continue;
                }

                writer.WriteLine($"{mimNumber}\t{updatedGeneSymbol}");
            }
        }
Example #2
0
        public IDictionary <string, string> GenerateMimToGeneSymbol(GeneSymbolUpdater geneSymbolUpdater)
        {
            var mimNumberToGeneSymbol = new Dictionary <string, string>();

            using (StreamWriter writer = new StreamWriter(_minToSymbolStream))
                using (var response = _httpClient.GetAsync(Mim2GeneUrl).Result)
                    using (var reader = new StreamReader(response.Content.ReadAsStreamAsync().Result))
                    {
                        writer.WriteLine("#MIM number\tGene symbol");
                        string line;
                        while ((line = reader.ReadLine()) != null)
                        {
                            if (line.OptimizedStartsWith('#'))
                            {
                                continue;
                            }

                            var    fields     = line.OptimizedSplit('\t');
                            string geneSymbol = fields[3];
                            if (string.IsNullOrEmpty(geneSymbol))
                            {
                                continue;
                            }

                            string mimNumber         = fields[0];
                            string entrezGeneId      = fields[2];
                            string ensemblGeneId     = fields[4];
                            string updatedGeneSymbol = geneSymbolUpdater.UpdateGeneSymbol(geneSymbol, ensemblGeneId, entrezGeneId);
                            if (string.IsNullOrEmpty(updatedGeneSymbol))
                            {
                                continue;
                            }

                            writer.WriteLine($"{mimNumber}\t{updatedGeneSymbol}");
                            mimNumberToGeneSymbol[mimNumber] = updatedGeneSymbol;
                        }
                    }

            return(mimNumberToGeneSymbol);
        }
Example #3
0
        private IDictionary <string, string> GetMimNumberToGeneSymbol(HttpClient httpClient, string mim2GeneUrl, ZipArchive zipArchive)
        {
            var mimNumberToGeneSymbol = new Dictionary <string, string>();

            using (StreamWriter writer = zipArchive == null ? null : new StreamWriter(zipArchive.CreateEntry("mim2gene.txt").Open()))
                using (var response = httpClient.GetAsync(mim2GeneUrl).Result)
                    using (var reader = new StreamReader(response.Content.ReadAsStreamAsync().Result))
                    {
                        string line;
                        while ((line = reader.ReadLine()) != null)
                        {
                            writer?.WriteLine(line);
                            if (line.OptimizedStartsWith('#'))
                            {
                                continue;
                            }
                            var    fields     = line.OptimizedSplit('\t');
                            string geneSymbol = fields[3];
                            if (string.IsNullOrEmpty(geneSymbol))
                            {
                                continue;
                            }
                            string mimNumber         = fields[0];
                            string entrezGeneId      = fields[2];
                            string ensemblGeneId     = fields[4];
                            string updatedGeneSymbol = _geneSymbolUpdater.UpdateGeneSymbol(geneSymbol, ensemblGeneId, entrezGeneId);
                            if (string.IsNullOrEmpty(updatedGeneSymbol))
                            {
                                continue;
                            }

                            mimNumberToGeneSymbol[mimNumber] = updatedGeneSymbol;
                        }
                    }

            return(mimNumberToGeneSymbol);
        }