public void MergeTwoConsensusPeaks(int xLeft, int xRight, int yLeft, int yRight, int cLeft, int cRight) { // Arrange var mspc = new Mspc(); var sA = new Bed <Peak>(); sA.Add(new Peak(left: xLeft, right: xRight, value: 0.01), _chr, _strand); mspc.AddSample(0, sA); var sB = new Bed <Peak>(); sB.Add(new Peak(left: yLeft, right: yRight, value: 0.01), _chr, _strand); mspc.AddSample(1, sB); // Act mspc.Run(new Config(ReplicateType.Biological, 1, 1, 1, 1, 1F, MultipleIntersections.UseLowestPValue)); var cp = mspc.GetConsensusPeaks()[_chr].First(); // Assert Assert.True(cp.Source.Left == cLeft && cp.Source.Right == cRight); }
private ReadOnlyDictionary <uint, Result <Peak> > InitializeAndRun(MultipleIntersections miChoice, bool trackSupportingPeaks = false) { // Arrange var sA = new Bed <Peak>(); sA.Add(r11, _chr, _strand); var sB = new Bed <Peak>(); sB.Add(r21, _chr, _strand); sB.Add(r22, _chr, _strand); sB.Add(r23, _chr, _strand); var mspc = new Mspc(trackSupportingPeaks); mspc.AddSample(0, sA); mspc.AddSample(1, sB); // Act return(mspc.Run(new Config(ReplicateType.Biological, 1e-4, 1e-8, 1e-8, 2, 1F, miChoice))); }
private Bed <Peak> CreateSample(int offset, int chrCount, int iCount) { var rtv = new Bed <Peak>(); for (int c = 0; c < chrCount; c++) { for (int i = 0; i < iCount; i++) { rtv.Add( new Peak( left: (10 * i) + 1 + offset, right: (10 * i) + 4 + offset, value: 1E-6, name: "r1" + i ), "chr" + c, '*'); } } return(rtv); }
public void T2() { // Arrange var sA = new Bed <Peak>(); var r11 = new Peak(left: 10, right: 26, value: 1e-4, name: "r11"); sA.Add(r11, _chr, _strand); var sB = new Bed <Peak>(); var r21 = new Peak(left: 5, right: 12, value: 1e-4, name: "r21"); var r22 = new Peak(left: 16, right: 18, value: 1e-7, name: "r22"); var r23 = new Peak(left: 22, right: 28, value: 1e-4, name: "r23"); sB.Add(r21, _chr, _strand); sB.Add(r22, _chr, _strand); sB.Add(r23, _chr, _strand); var mspc = new Mspc(); mspc.AddSample(0, sA); mspc.AddSample(1, sB); var config = new Config(ReplicateType.Biological, 1e-3, 1e-8, 1e-8, 2, 1F, MultipleIntersections.UseLowestPValue); // Act var res = mspc.Run(config); // Assert Assert.True(res[0].Chromosomes[_chr].Get(Attributes.Confirmed).Count() == 1); Assert.False(res[0].Chromosomes[_chr].Get(Attributes.Discarded).Any()); Assert.True(res[0].Chromosomes[_chr].Get(Attributes.Confirmed).ToList()[0].Source.CompareTo(r11) == 0); Assert.True(res[1].Chromosomes[_chr].Get(Attributes.Confirmed).Count() == 1); Assert.True(res[1].Chromosomes[_chr].Get(Attributes.Discarded).Count() == 2); Assert.True(res[1].Chromosomes[_chr].Get(Attributes.Confirmed).ToList()[0].Source.CompareTo(r22) == 0); Assert.True(res[1].Chromosomes[_chr].Get(Attributes.Discarded).ToList()[0].Source.CompareTo(r21) == 0); Assert.True(res[1].Chromosomes[_chr].Get(Attributes.Discarded).ToList()[1].Source.CompareTo(r23) == 0); }
private string RunMSPCAndExportResultsWithMultiChr() { var s0 = new Bed <Peak>(); for (int i = 0; i < peaks.Count; i++) { s0.Add(peaks[i], chrs[i], _strand); } var s1 = new Bed <Peak>(); s1.Add(new Peak(800, 900, 1E-2), "chr5", _strand); var mspc = new Mspc(); mspc.AddSample(0, s0); mspc.AddSample(1, s1); mspc.Run(new Config(ReplicateType.Biological, 1e-4, 1e-5, 1e-5, 1, 0.05F, MultipleIntersections.UseLowestPValue)); var path = Environment.CurrentDirectory + Path.DirectorySeparatorChar + "MSPCTests_" + new Random().NextDouble().ToString(); new Exporter <Peak>().Export(_sidfm, mspc.GetResults(), mspc.GetConsensusPeaks(), new Options(path, false, _attributes)); return(path); }
private ReadOnlyDictionary <uint, Result <Peak> > RunThenCancelMSPC(int iCount, Status status) { var sA = new Bed <Peak>(); var sB = new Bed <Peak>(); for (int i = 0; i < iCount; i++) { sA.Add(new Peak( left: (10 * i) + 1, right: (10 * i) + 4, value: 1E-4, summit: 0, name: "r1" + i), _chr, _strand); sB.Add(new Peak( left: (10 * i) + 6, right: (10 * i) + 9, value: 1E-5, summit: 0, name: "r1" + i), _chr, _strand); } var mspc = new Mspc(); mspc.AddSample(0, sA); mspc.AddSample(1, sB); var config = new Config(ReplicateType.Biological, 1e-1, 1e-2, 1e-2, 1, 0.05F, MultipleIntersections.UseLowestPValue); switch (status) { case Status.Init: _continueIni = new AutoResetEvent(false); _continueIni.Reset(); mspc.StatusChanged += WaitingIni; // MSPC is expected to confirm peaks using the following configuration. mspc.RunAsync(config); _continueIni.WaitOne(); break; case Status.Process: _continuePrc = new AutoResetEvent(false); _continuePrc.Reset(); mspc.StatusChanged += WaitingPrc; // MSPC is expected to confirm peaks using the following configuration. mspc.RunAsync(config); _continuePrc.WaitOne(); break; case Status.MTC: _continueMtc = new AutoResetEvent(false); _continueMtc.Reset(); mspc.StatusChanged += WaitingMtc; // MSPC is expected to confirm peaks using the following configuration. mspc.RunAsync(config); _continueMtc.WaitOne(); break; case Status.Consensu: _continueCon = new AutoResetEvent(false); _continueCon.Reset(); mspc.StatusChanged += WaitingCon; // MSPC is expected to confirm peaks using the following configuration. mspc.RunAsync(config); _continueCon.WaitOne(); break; } // With the following configuration, MSPC discards all the peaks. // This can help asserting if the asynchronous process of // the previous execution is canceled, and instead the following asynchronous // execution is completed. mspc.RunAsync(new Config(ReplicateType.Biological, 1e-10, 1e-20, 1e-200, 1, 0.05F, MultipleIntersections.UseLowestPValue)); mspc.Done.WaitOne(); return(mspc.GetResults()); }