コード例 #1
0
ファイル: EvaluateCNVTest.cs プロジェクト: zhang919/canvas
        public void TestFalseNegatives()
        {
            var cnvEvaluator = new CnvEvaluator(new CNVChecker(null, new Dictionary <string, List <CNInterval> >(), null));

            var          baseCounter = new BaseCounter(5, 0, 4999);
            const string chr         = "1";
            var          calls       = new Dictionary <string, List <CnvCall> >
            {
                [chr] = new List <CnvCall>
                {
                    new CnvCall(chr, start: 1, end: 1000, cn: 2, refPloidy: 1, passFilter: false, altAllele: "."),
                    new CnvCall(chr, start: 2001, end: 3000, cn: 1, refPloidy: 2, passFilter: true, altAllele: "."),
                    new CnvCall(chr, start: 3001, end: 4000, cn: 1, refPloidy: 2, passFilter: true, altAllele: "."),
                    new CnvCall(chr, start: 4001, end: 5000, cn: 2, refPloidy: 1, passFilter: true, altAllele: "."),
                    new CnvCall(chr, start: 6001, end: 7000, cn: 2, refPloidy: 2, passFilter: true, altAllele: ".")
                }
            };

            var knownCN = new Dictionary <string, List <CNInterval> >
            {
                [chr] = new List <CNInterval>
                {
                    new CNInterval(chr, start: 1, end: 1000, cn: 2),
                    new CNInterval(chr, start: 2001, end: 3000, cn: 1),
                    new CNInterval(chr, start: 3001, end: 4000, cn: 1),
                    new CNInterval(chr, start: 4001, end: 5000, cn: 1),
                    new CNInterval(chr, start: 6001, end: 7000, cn: 2)
                }
            };
            var metrics = cnvEvaluator.CalculateMetrics(knownCN, calls, baseCounter, optionsSkipDiploid: false, includePassingOnly: true);

            Assert.Equal(Convert.ToInt32((2 / 3.0) * 100), Convert.ToInt32(metrics.Recall));
        }
コード例 #2
0
 override public long Increment()
 {
     _stopwatch.Stop();
     Counter.IncrementBy(_stopwatch.ElapsedTicks);
     BaseCounter.Increment();
     _stopwatch.Reset();
     return(Counter.RawValue);
 }
コード例 #3
0
ファイル: Tester.cs プロジェクト: gruan01/Throttle
        /// <summary>
        ///
        /// </summary>
        /// <param name="n"></param>
        public Tester(int boundry, TimeSpan period, int batchCount)
        {
            this.Conn = ConnectionMultiplexer.Connect("localhost:6379");

            this.Counter = new RedisCounter(this.Conn, batchCount);
            this.TS      = new Throttle("test", period, boundry, this.Counter, concurrentCount: 2);
            //this.TS = new Throttle("test", period, boundry);
            this.TS.OnPeriodElapsed += Ts_OnPeriodElapsed;
        }
コード例 #4
0
        override public long Increment()
        {
            if (OperationSuccessful)
            {
                Counter.Increment();
            }
            BaseCounter.Increment();

            return(Counter.RawValue);
        }
コード例 #5
0
 override public long IncrementBy(long value)
 {
     Counter.IncrementBy(value);
     BaseCounter.Increment();
     return(Counter.RawValue);
 }
コード例 #6
0
 internal void Remove(BaseCounter eventCounter)
 {
     lock (this) // Lock the CounterGroup
         _counters.Remove(eventCounter);
 }
コード例 #7
0
 internal void Add(BaseCounter eventCounter)
 {
     lock (this) // Lock the CounterGroup
         _counters.Add(eventCounter);
 }
コード例 #8
0
 public long Decrement()
 {
     BaseCounter.Decrement();
     return(_counter.Decrement());
 }
コード例 #9
0
 public long Increment()
 {
     BaseCounter.Increment();
     return(_counter.Increment());
 }
コード例 #10
0
 public long IncrementBy(long value)
 {
     BaseCounter.Increment();
     return(_counter.IncrementBy(value));
 }
コード例 #11
0
        public static MetricsCalculator CalculateMetrics(BaseCounter baseCounter, int maxCn, int maxPloidy)
        {
            long totalBases               = 0;
            long totalBasesRight          = 0;
            long totalBasesRightDirection = 0;

            long isGainBases                 = 0;
            long callGainBases               = 0;
            long isGainBasesCorrect          = 0;
            long isGainBasesCorrectDirection = 0;

            long isLossBases                 = 0;
            long callLossBases               = 0;
            long isLossBasesCorrect          = 0;
            long isLossBasesCorrectDirection = 0;

            for (var ploidy = 0; ploidy <= maxPloidy; ploidy++)
            {
                for (var trueCn = 0; trueCn <= maxCn; trueCn++)
                {
                    long noCallBases = baseCounter.NoCalls[trueCn, ploidy];
                    if (trueCn < ploidy)
                    {
                        isLossBases += noCallBases;
                    }
                    if (trueCn > ploidy)
                    {
                        isGainBases += noCallBases;
                    }
                    totalBases += noCallBases;
                    for (var callCn = 0; callCn <= maxCn; callCn++)
                    {
                        long bases = baseCounter.BaseCount[trueCn, callCn, ploidy];
                        totalBases += bases;
                        if (trueCn == callCn)
                        {
                            totalBasesRight += bases;
                        }
                        if (trueCn < ploidy && callCn < ploidy || trueCn == ploidy && callCn == ploidy || trueCn > ploidy && callCn > ploidy)
                        {
                            totalBasesRightDirection += bases;
                        }
                        if (trueCn < ploidy)
                        {
                            isLossBases += bases;
                        }
                        if (trueCn > ploidy)
                        {
                            isGainBases += bases;
                        }
                        if (callCn < ploidy)
                        {
                            callLossBases += bases;
                        }
                        if (callCn > ploidy)
                        {
                            callGainBases += bases;
                        }
                        if (trueCn == callCn && trueCn < ploidy)
                        {
                            isLossBasesCorrect += bases;
                        }
                        if (trueCn == callCn && trueCn > ploidy)
                        {
                            isGainBasesCorrect += bases;
                        }
                        if (trueCn > ploidy && callCn > ploidy)
                        {
                            isGainBasesCorrectDirection += bases;
                        }
                        if (trueCn < ploidy && callCn < ploidy)
                        {
                            isLossBasesCorrectDirection += bases;
                        }
                    }
                }
            }


            // Compute ROI stats:
            long roiBases                 = 0;
            long roiBasesCorrect          = 0;
            long roiBasesCorrectDirection = 0;

            if (baseCounter.RoiBaseCount != null)
            {
                for (var ploidy = 0; ploidy <= maxPloidy; ploidy++)
                {
                    for (var trueCn = 0; trueCn <= maxCn; trueCn++)
                    {
                        for (var callCn = 0; callCn <= maxCn; callCn++)
                        {
                            long bases = baseCounter.RoiBaseCount[trueCn, callCn, ploidy];
                            roiBases += bases;
                            if (trueCn == callCn)
                            {
                                roiBasesCorrect += bases;
                            }
                            if (trueCn < ploidy && callCn < ploidy || trueCn == ploidy && callCn == ploidy || trueCn > ploidy && callCn > ploidy)
                            {
                                roiBasesCorrectDirection += bases;
                            }
                        }
                    }
                }
            }
            return(new MetricsCalculator(totalBases, totalBasesRight, totalBasesRightDirection, isGainBases, callGainBases,
                                         isGainBasesCorrect, isGainBasesCorrectDirection, isLossBases, callLossBases, isLossBasesCorrect,
                                         isLossBasesCorrectDirection, roiBases, roiBasesCorrect, roiBasesCorrectDirection));
        }
コード例 #12
0
 public void TestCleanWord(string word, string expectedValue)
 {
     Assert.AreEqual(expectedValue, BaseCounter.CleanWord(word));
 }
コード例 #13
0
 public long Failure()
 {
     BaseCounter.Increment();
     return(_counter.IncrementBy(0));
 }
コード例 #14
0
 public long Success()
 {
     BaseCounter.Increment();
     return(_counter.IncrementBy(100));
 }