Пример #1
0
        private void VerifyBatchCandidates(ICandidateBatch batch, List <CandidateIndel> expected)
        {
            var candidates = batch.GetCandidates();

            Assert.Equal(expected.Count, candidates.Count);
            foreach (var candidate in candidates)
            {
                Assert.True(expected.Contains(candidate));
            }
        }
Пример #2
0
        private void VerifyBatchContents(ICandidateBatch batch, List <CandidateAllele> expectedCandidates)
        {
            var candidates = batch.GetCandidates();

            Assert.Equal(expectedCandidates.Count(), candidates.Count);
            foreach (var expected in expectedCandidates)
            {
                Assert.True(candidates.Contains(expected));
            }
        }
Пример #3
0
 public void AddMissingReferences(ICandidateBatch batch, List <Region> intervalsToAdd)
 {
     for (var i = 0; i < intervalsToAdd.Count; i++)
     {
         var interval = intervalsToAdd[i];
         for (var position = interval.StartPosition; position <= interval.EndPosition; position++)
         {
             var refBase = _chrReference.GetBase(position);
             batch.Add(new CandidateAllele(_chrReference.Name, position, refBase, refBase,
                                           AlleleCategory.Reference));
         }
     }
 }
Пример #4
0
        public void DoneProcessing(ICandidateBatch batch)
        {
            var candidateBatch = batch as CandidateBatch;

            if (candidateBatch != null)
            {
                foreach (var key in candidateBatch.BlockKeys)
                {
                    var blockToRemove = _regionLookup[key];
                    _reusableBlocks.Push(blockToRemove); // save for reuse later

                    _regionLookup.Remove(key);
                }
            }
        }
        private void AddCollapsableFromOtherBlocks(ICandidateBatch batch, int maxClearedPosition, int upToPosition)
        {
            // grab all right anchored collapsable variants between max cleared and up to position and add to batch.
            // this really only applies to snv/mnvs.  collapsable insertions always have the same coordinate.
            // if these variants dont collapse, they get added back to state manager later

            foreach (var block in _regionLookup.Values)
            {
                if (block.StartPosition > maxClearedPosition && block.StartPosition <= upToPosition)
                {
                    var collapsableVariants = block.ExtractCollapsable(upToPosition);

                    foreach (var collapsableVariant in collapsableVariants)
                    {
                        batch.Add(collapsableVariant);
                    }
                }
            }
        }
        public virtual void DoneProcessing(ICandidateBatch batch)
        {
            var candidateBatch = batch as CandidateBatch;

            if (candidateBatch != null)
            {
                foreach (var key in candidateBatch.BlockKeys)
                {
                    var blockToRemove = _regionLookup[key];
                    _reusableBlocks.Push(blockToRemove); // save for reuse later

                    _regionLookup.Remove(key);

                    if (_lastAccessedBlock != null && _lastAccessedBlock.Equals(blockToRemove))
                    {
                        _lastAccessedBlock = null;
                    }
                }
            }
        }
Пример #7
0
        public void Pad(ICandidateBatch batch, bool mapAll = false)
        {
            if (IntervalSet == null || (batch.ClearedRegions == null && !mapAll))  // nothing to do
            {
                return;
            }

            var startPosition = Math.Max(_lastClearedPosition + 1, IntervalSet.MinPosition);

            var endPosition = mapAll ? IntervalSet.MaxPosition
                : Math.Min(batch.ClearedRegions.Max(c => c.EndPosition), IntervalSet.MaxPosition);

            if (startPosition > endPosition)
            {
                return;
            }

            var nonClearedIntervals = IntervalSet.GetClipped(new Region(startPosition, endPosition), batch.ClearedRegions);

            AddMissingReferences(batch, nonClearedIntervals);

            _lastClearedPosition = endPosition;
        }
Пример #8
0
        public override void DoneProcessing(ICandidateBatch batch)
        {
            var candidateBatch = batch as CandidateBatch;

            if (batch.MaxClearedPosition.HasValue)
            {
                _lastMaxClearedPosition = batch.MaxClearedPosition.Value;
            }

            if (candidateBatch != null && candidateBatch.BlockKeys.Any())
            {
                var maxBlockKey = candidateBatch.BlockKeys.Max();

                var keysToRemove = new List <int>();
                foreach (var key in _regionLookup.Keys)
                {
                    if (key < maxBlockKey)  // want to only clear blocks outside of 1-block window for next potential batch
                    {
                        keysToRemove.Add(key);
                    }
                }

                foreach (var keyToRemove in keysToRemove)
                {
                    var blockToRemove = _regionLookup[keyToRemove];
                    _reusableBlocks.Push(blockToRemove); // save for reuse later

                    _regionLookup.Remove(keyToRemove);

                    if (_lastAccessedBlock != null && _lastAccessedBlock.Equals(blockToRemove))
                    {
                        _lastAccessedBlock = null;
                    }
                }
            }
        }
Пример #9
0
 /// <summary>
 /// Returns a list of called alleles, sorted by position, reference alternate
 /// </summary>
 /// <param name="batchToCall"></param>
 /// <param name="source"></param>
 /// <returns></returns>
 public SortedList <int, List <CalledAllele> > Call(ICandidateBatch batchToCall, IAlleleSource source)
 {
     return(CallForPositions(batchToCall.GetCandidates(), source, batchToCall.MaxClearedPosition));
 }
Пример #10
0
 public IEnumerable <BaseCalledAllele> Call(ICandidateBatch batchToCall, IStateManager source)
 {
     return(CallForPositions(batchToCall.GetCandidates(), source, batchToCall.MaxClearedPosition));
 }