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)); }
override public long Increment() { _stopwatch.Stop(); Counter.IncrementBy(_stopwatch.ElapsedTicks); BaseCounter.Increment(); _stopwatch.Reset(); return(Counter.RawValue); }
/// <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; }
override public long Increment() { if (OperationSuccessful) { Counter.Increment(); } BaseCounter.Increment(); return(Counter.RawValue); }
override public long IncrementBy(long value) { Counter.IncrementBy(value); BaseCounter.Increment(); return(Counter.RawValue); }
internal void Remove(BaseCounter eventCounter) { lock (this) // Lock the CounterGroup _counters.Remove(eventCounter); }
internal void Add(BaseCounter eventCounter) { lock (this) // Lock the CounterGroup _counters.Add(eventCounter); }
public long Decrement() { BaseCounter.Decrement(); return(_counter.Decrement()); }
public long Increment() { BaseCounter.Increment(); return(_counter.Increment()); }
public long IncrementBy(long value) { BaseCounter.Increment(); return(_counter.IncrementBy(value)); }
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)); }
public void TestCleanWord(string word, string expectedValue) { Assert.AreEqual(expectedValue, BaseCounter.CleanWord(word)); }
public long Failure() { BaseCounter.Increment(); return(_counter.IncrementBy(0)); }
public long Success() { BaseCounter.Increment(); return(_counter.IncrementBy(100)); }