Beispiel #1
0
        public void CallRefs(IVcfNeighborhood completedNbhd)
        {
            var suckedUpRefCalls = completedNbhd.UsedRefCountsLookup;
            Dictionary <int, CalledAllele> possibleRefs = new Dictionary <int, CalledAllele>();
            var variantsRecalledByMnvCaller             = completedNbhd.GetOriginalVcfVariants();

            foreach (var allele in variantsRecalledByMnvCaller)
            {
                int suckedUpRefCallCount = 0;
                if (suckedUpRefCalls.ContainsKey(allele.ReferencePosition))
                {
                    suckedUpRefCallCount = suckedUpRefCalls[allele.ReferencePosition].Counts;
                }

                var newRef = ReCallAsRef(allele, suckedUpRefCallCount);

                if (!possibleRefs.ContainsKey(newRef.ReferencePosition))
                {
                    completedNbhd.NbhdGTcalculator.SetGenotypes(new List <CalledAllele> {
                        newRef
                    });
                    possibleRefs.Add(newRef.ReferencePosition, newRef);
                }
            }

            completedNbhd.CalledRefs = possibleRefs;
        }
Beispiel #2
0
        public void CallRefs(IVcfNeighborhood completedNbhd)
        {
            var suckedUpRefCalls = completedNbhd.UsedRefCountsLookup;
            Dictionary <int, CalledAllele> possibleRefs = new Dictionary <int, CalledAllele>();
            var variantsRecalledByMnvCaller             = completedNbhd.GetOriginalVcfVariants();

            foreach (var allele in variantsRecalledByMnvCaller)
            {
                int suckedUpRefCallCount = 0;
                if (suckedUpRefCalls.ContainsKey(allele.Coordinate))
                {
                    suckedUpRefCallCount = suckedUpRefCalls[allele.Coordinate];
                }

                var newRef = ReCallAsRef(allele, suckedUpRefCallCount);

                if (!possibleRefs.ContainsKey(newRef.Coordinate))
                {
                    possibleRefs.Add(newRef.Coordinate, newRef);
                }
            }

            completedNbhd.CalledRefs = possibleRefs;
        }
Beispiel #3
0
        public static List <CalledAllele> GetMergedListOfVariants(IVcfNeighborhood completedNbhd, List <CalledAllele> originalVariantsInsideRange)
        {
            var mergedVariantList = new List <CalledAllele>();
            Dictionary <int, List <CalledAllele> > foundMNVS = completedNbhd.CalledVariants;

            //track which variants got used for MNV phasing.
            var indexesOfVariantsRecalledByMnvCaller = completedNbhd.GetOriginalVcfVariants();

            //decide which of the original variants we keep, and which get replaced.
            for (int i = 0; i < originalVariantsInsideRange.Count; i++)
            {
                var  originalCall          = originalVariantsInsideRange[i];
                var  currentPosition       = originalCall.ReferencePosition;
                bool variantWasAlreadyUsed = CheckIfUsed(indexesOfVariantsRecalledByMnvCaller, originalCall);


                if (foundMNVS.ContainsKey(currentPosition))
                {
                    //add all the MNVs
                    mergedVariantList.AddRange(foundMNVS[currentPosition]);
                    foundMNVS[currentPosition] = new List <CalledAllele>();//empty out the list, but leave the fact that there were MNVs here.

                    //add back any original variants,
                    //so long as they were not used by the caller, and not reference
                    if (!(variantWasAlreadyUsed) &&
                        (originalCall.Type != Pisces.Domain.Types.AlleleCategory.Reference))
                    {
                        mergedVariantList.Add(originalCall);
                    }

                    continue;
                }

                //Else, we did not find any MNVs here.
                //Then this position should be either the original call from the vcf,
                //or a new reference call converted from a variant that got used by the MNV caller.
                if (variantWasAlreadyUsed)
                {
                    var newRef = completedNbhd.CalledRefs[originalCall.ReferencePosition];

                    //sometimes several variants were used, all at the same position. we dont need to add new references for all of them.
                    if ((mergedVariantList.Count == 0) || (mergedVariantList.Last().ReferencePosition != currentPosition))
                    {
                        mergedVariantList.Add(newRef);
                    }
                }
                else //wasnt used for MNV calling
                {
                    mergedVariantList.Add(originalVariantsInsideRange[i]);
                }
            }

            //incase we called any MNVs past the edge of the input VCF.
            foreach (var mnvsLeft in foundMNVS)
            {
                mergedVariantList.AddRange(mnvsLeft.Value);
            }

            var comparer = new AlleleCompareByLoci();

            mergedVariantList.Sort(comparer);


            return(mergedVariantList);
        }