当前位置: 首页>>代码示例>>C#>>正文


C# IProgressReporter.Update方法代码示例

本文整理汇总了C#中IProgressReporter.Update方法的典型用法代码示例。如果您正苦于以下问题:C# IProgressReporter.Update方法的具体用法?C# IProgressReporter.Update怎么用?C# IProgressReporter.Update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IProgressReporter的用法示例。


在下文中一共展示了IProgressReporter.Update方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LoadUcscSnps

        public void LoadUcscSnps(string snpPath, bool clearSnps, IProgressReporter progress = null)
        {
            //Clear?
            if (clearSnps)
            {
                Snps.Clear();
            }

            //Log
            progress?.Update("Loading SNPs");
            
            //Init
            var lineCount = 0;
            _splitter = null;  
            
            //Read file      
            using (var reader = _fileReaderFactory.GetFileReader(snpPath))
            {
                foreach (var line in reader)
                {
                    //Loop init
                    lineCount++;
                    if (lineCount == 1)
                    {
                        var testSplit = line.Split('\t');
                        _splitter = new StringSplitter(testSplit.Length);
                        continue;
                    }

                    //Read data
                    // ReSharper disable once PossibleNullReferenceException
                    _splitter.Split(line, '\t');
                    var lineSplit = _splitter.Results;
                    var snp = new Snp();

                    //Build data
                    snp.Chromosome = lineSplit[1];
                    snp.Pos = lineSplit[2];
                    snp.RsId = lineSplit[4];
                    snp.Strand = lineSplit[6];
                    snp.SnpRef = lineSplit[7];
                    snp.Observed = lineSplit[9];

                    if (snp.SnpRef.Length == 1 && snp.SnpRef != "-")
                    {
                        if (snp.Strand == "+")
                        {
                            snp.SnpAlt = snp.Observed[0] == snp.SnpRef[0] ? snp.Observed[2].ToString() : snp.Observed[0].ToString();
                        }
                        else
                        {
                            var newObs = new char[3];
                            newObs[1] = '/';

                            //Reverse observed
                            if(snp.Observed[0] == 'A') { newObs[2] = 'T';}
                            else if (snp.Observed[0] == 'T') { newObs[2] = 'A'; }
                            else if (snp.Observed[0] == 'G') { newObs[2] = 'C'; }
                            else if (snp.Observed[0] == 'C') { newObs[2] = 'G'; }

                            if (snp.Observed[2] == 'A') { newObs[0] = 'T'; }
                            else if (snp.Observed[2] == 'T') { newObs[0] = 'A'; }
                            else if (snp.Observed[2] == 'G') { newObs[0] = 'C'; }
                            else if (snp.Observed[2] == 'C') { newObs[0] = 'G'; }

                            var observed = new String(newObs);
                            snp.SnpAlt = observed[0] == snp.SnpRef[0] ? observed[2].ToString() : observed[0].ToString();
                        }

                        if (!Snps.ContainsKey(snp.RsId))
                        {
                            Snps.Add(snp.RsId, snp);
                        }
                    }

                    //Progress
                    lineCount++;
                    if (progress != null && lineCount % 10 == 1)
                    {
                        var perc = (double)reader.Stream.Position / reader.Stream.Length;
                        progress.Update(perc);
                    }
                }
            }
        }
开发者ID:UCL-Genomics,项目名称:genomics-common,代码行数:85,代码来源:VariantManager.cs


注:本文中的IProgressReporter.Update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。