示例#1
0
        private IEnumerable <CalledAllele> GetNextBlockOfOriginalAllelesFromVcfVar()
        {
            var  vcfVar = new VcfVariant();
            bool worked = _variantSource.GetNextVariant(vcfVar);

            if (!worked)
            {
                return(new List <CalledAllele>());
            }

            return(VcfVariantUtilities.Convert(new List <VcfVariant> {
                vcfVar
            }));
        }
示例#2
0
        public IEnumerable <VcfNeighborhood> GetBatchOfNeighborhoods(int numNbhdsSoFar)
        {
            _nextBatchOfNeighborhoods.Clear();
            _nextBatchOfNeighborhoods.AddRange(_unfinshedNeighborhoods);
            _unfinshedNeighborhoods.Clear();

            bool keepAddingNbhdsToTheBatch = true;

            while (keepAddingNbhdsToTheBatch)
            {
                keepAddingNbhdsToTheBatch = _vcfVariantSource.GetNextVariant(_tempRawVcfVariant);

                //only loose _tempRawVcfVariant if it was null. We are done with the file.
                if (!keepAddingNbhdsToTheBatch)
                {
                    break;
                }

                var allelesUnpackedFromVcfVariant = VcfVariantUtilities.Convert(new List <VcfVariant> {
                    _tempRawVcfVariant
                });


                foreach (var currentAllele in allelesUnpackedFromVcfVariant)
                {
                    if (currentAllele.Filters.Contains(FilterType.ForcedReport))
                    {
                        continue;
                    }

                    var currentVariantSite = new VariantSite(currentAllele);
                    var refBase            = currentVariantSite.VcfReferenceAllele.Substring(0, 1);

                    //append the next base, unless we have a repeated variant.
                    if (currentVariantSite.VcfReferencePosition != _lastVariantSite.VcfReferencePosition)
                    {
                        _referenceStringBetweenVariants += refBase;
                    }

                    //check its not reference or otherwise useless
                    if (!IsEligibleVariant(currentAllele))
                    {
                        continue;
                    }

                    //the current variant is close to the last one
                    if (IsProximal(currentVariantSite, _lastVariantSite, _phasableVariantCriteria.PhasingDistance))
                    {
                        keepAddingNbhdsToTheBatch = FitVariantsInNeighborhood(_lastVariantSite, currentVariantSite,
                                                                              _referenceStringBetweenVariants, numNbhdsSoFar);

                        _referenceStringBetweenVariants = "";
                    }
                    else
                    {
                        _referenceStringBetweenVariants = "";
                    }

                    _lastVariantSite = currentVariantSite;
                }
            }

            PrepNbhdsForUse(_nextBatchOfNeighborhoods);

            return(_nextBatchOfNeighborhoods);
        }