public void Execute()
        {
            Read read;

            if (_alignmentSource.SourceIsStitched)
            {
                Logger.WriteToLog("Stitched reads detected");
            }

            while ((read = _alignmentSource.GetNextRead()) != null)
            {
                // find candidate variants
                var candidateVariants = _variantFinder.FindCandidates(read, _chrReference.Sequence,
                                                                      _chrReference.Name);

                // track in state manager
                _stateManager.AddCandidates(candidateVariants);
                _stateManager.AddAlleleCounts(read);

                // call anything possible to call
                Call(_alignmentSource.LastClearedPosition);
            }

            Call(); // call everything left

            if (_regionMapper != null)
            {
                _vcfWriter.WriteRemaining(_regionMapper);  // pad any remaining intervals if necessary
            }
            Logger.WriteToLog("Totals: {0} alleles called.  {1} variants collapsed.",
                              _alleleCaller.TotalNumCalled, _alleleCaller.TotalNumCollapsed);
        }
Exemple #2
0
        private IEnumerable <BaseCalledAllele> CallForPositions(IEnumerable <CandidateAllele> candidates, IStateManager source, int?maxPosition)
        {
            var calledAlleles   = new List <BaseCalledAllele>();
            var failedMnvs      = new List <BaseCalledAllele>();
            var callableAlleles = new List <BaseCalledAllele>();

            foreach (var candidate in candidates)
            {
                var variant = Map(candidate);

                if (variant.Type == AlleleCategory.Mnv)
                {
                    ProcessVariant(source, variant);
                    if (IsCallable(variant))
                    {
                        callableAlleles.Add(variant);
                    }
                    else
                    {
                        failedMnvs.Add(variant);
                    }
                }

                else
                {
                    callableAlleles.Add(variant);
                }
            }

            var leftoversInNextBlock = MnvReallocator.ReallocateFailedMnvs(failedMnvs, callableAlleles, maxPosition);

            source.AddCandidates(leftoversInNextBlock.Select(Map));

            source.AddGappedMnvRefCount(GetRefSupportFromGappedMnvs(callableAlleles));

            // need to re-process variants since they may have additional support
            foreach (var baseCalledAllele in callableAlleles)
            {
                ProcessVariant(source, baseCalledAllele);
                if (IsCallable(baseCalledAllele) && ShouldReport(baseCalledAllele))
                {
                    calledAlleles.Add(baseCalledAllele);
                }
            }

            // prune reference call if variants were found
            var allPositions = calledAlleles.Select(c => c.Coordinate).Distinct().ToList();

            foreach (var position in allPositions)
            {
                var allelesAtPosition = calledAlleles.Where(x => x.Coordinate == position);
                var referenceCall     = allelesAtPosition.FirstOrDefault(v => v is CalledReference);
                if (referenceCall != null && allelesAtPosition.Any(v => v is CalledVariant))
                {
                    calledAlleles.Remove(referenceCall);
                }
            }

            return(calledAlleles);
        }
Exemple #3
0
        public void Execute()
        {
            AlignmentSet alignmentSet;

            while ((alignmentSet = _alignmentSource.GetNextAlignmentSet()) != null)
            {
                // find candidate variants
                var candidateVariants = _variantFinder.FindCandidates(alignmentSet, _chrReference.Sequence,
                                                                      _chrReference.Name);

                // track in state manager
                _stateManager.AddCandidates(candidateVariants);
                _stateManager.AddAlleleCounts(alignmentSet);

                // call anything possible to call
                Call(_alignmentSource.LastClearedPosition);
            }

            Call(); // call everything left

            Logger.WriteToLog("Totals: {0} alleles called.", _numCalledAlleles);
        }