示例#1
0
        public void DoneProcessing()
        {
            var stateManager = new RealignStateManager();

            var allCandidates = new List <CandidateIndel>
            {
                new CandidateIndel(new CandidateAllele("chr1", 500, "A", "AT", AlleleCategory.Insertion)),
                new CandidateIndel(new CandidateAllele("chr1", 1500, "A", "AT", AlleleCategory.Insertion)),
                new CandidateIndel(new CandidateAllele("chr1", 3000, "A", "AT", AlleleCategory.Insertion)),
                new CandidateIndel(new CandidateAllele("chr1", 4000, "A", "AT", AlleleCategory.Insertion)),
                new CandidateIndel(new CandidateAllele("chr1", 4010, "A", "AT", AlleleCategory.Insertion))
            };

            stateManager.AddCandidates(allCandidates);

            var batch = stateManager.GetCandidatesToProcess(1);

            Assert.Equal(null, batch.ClearedRegions);
            Assert.False(batch.HasCandidates);
            stateManager.DoneProcessing(batch);  // effectively does nothing

            // candidates from all previous blocks but nothing cleared
            batch = stateManager.GetCandidatesToProcess(2001);
            Assert.Equal(1, batch.ClearedRegions.Count);
            Assert.Equal(1000, batch.ClearedRegions[0].EndPosition);
            stateManager.DoneProcessing(batch);  // clear first block, but keep it's candidates

            batch = stateManager.GetCandidatesToProcess(3001);
            Assert.Equal(1, batch.ClearedRegions.Count);
            Assert.Equal(2000, batch.ClearedRegions[0].EndPosition);
            VerifyBatchCandidates(batch, allCandidates.Where(c => c.ReferencePosition == 500 || c.ReferencePosition == 1500 || c.ReferencePosition == 3000).ToList());
            stateManager.DoneProcessing(batch); // clear second block, purge block 1 candidates, but keep block 2 candidates

            batch = stateManager.GetCandidatesToProcess(4500);
            Assert.Equal(1, batch.ClearedRegions.Count);
            Assert.Equal(3000, batch.ClearedRegions[0].EndPosition);
            VerifyBatchCandidates(batch, allCandidates.Where(c => c.ReferencePosition == 1500 || c.ReferencePosition == 3000 || c.ReferencePosition == 4000).ToList());
        }
示例#2
0
        public void GetCandidates()
        {
            var stateManager = new RealignStateManager();

            var allCandidates = new List <CandidateIndel>
            {
                new CandidateIndel(new CandidateAllele("chr1", 500, "A", "AT", AlleleCategory.Insertion)),
                new CandidateIndel(new CandidateAllele("chr1", 1500, "A", "AT", AlleleCategory.Insertion)),
                new CandidateIndel(new CandidateAllele("chr1", 3000, "A", "AT", AlleleCategory.Insertion))
            };

            stateManager.AddCandidates(allCandidates);

            // enforce 1 block window for cleared region
            var batch = stateManager.GetCandidatesToProcess(1);

            Assert.Equal(null, batch.ClearedRegions);
            Assert.False(batch.HasCandidates);
            batch = stateManager.GetCandidatesToProcess(501);
            Assert.Equal(null, batch);

            // candidates from all previous blocks but nothing cleared
            batch = stateManager.GetCandidatesToProcess(1999);
            Assert.Equal(null, batch.ClearedRegions);
            VerifyBatchCandidates(batch, allCandidates.Where(c => c.ReferencePosition == 500).ToList());

            batch = stateManager.GetCandidatesToProcess(2001);
            Assert.Equal(1, batch.ClearedRegions.Count);
            Assert.Equal(1000, batch.ClearedRegions[0].EndPosition);
            VerifyBatchCandidates(batch, allCandidates.Where(c => c.ReferencePosition == 500 || c.ReferencePosition == 1500).ToList());

            batch = stateManager.GetCandidatesToProcess(4000);
            Assert.Equal(2, batch.ClearedRegions.Count);
            Assert.Equal(2000, batch.ClearedRegions[1].EndPosition);
            VerifyBatchCandidates(batch, allCandidates);

            batch = stateManager.GetCandidatesToProcess(null);
            Assert.Equal(null, batch.ClearedRegions);
            VerifyBatchCandidates(batch, allCandidates);
        }