Exemple #1
0
        private void ComputeGenotypeAndFilterAllele(List <CalledAllele> allelesAtPosition)
        {
            //pruning ref calls
            if (allelesAtPosition.Any(v => v.Type != AlleleCategory.Reference && !v.IsForcedToReport))//(v => v is BaseCalledAllele))
            {
                allelesAtPosition.RemoveAll(v => (v.Type == AlleleCategory.Reference));
            }

            //set GT and GT score, and prune any variant calls that exceed the ploidy model
            var allelesToPrune = _genotypeCalculator.SetGenotypes(allelesAtPosition.Where(x => !x.IsForcedToReport).ToList());



            foreach (var alleleToPrune in allelesToPrune)
            {
                var allele = new Tuple <string, int, string, string>(alleleToPrune.Chromosome,
                                                                     alleleToPrune.ReferencePosition, alleleToPrune.ReferenceAllele, alleleToPrune.AlternateAllele);


                if (ForcedGtAlleles == null || !ForcedGtAlleles.Contains(allele))
                {
                    allelesAtPosition.Remove(alleleToPrune);
                }
            }


            foreach (var allele in allelesAtPosition)
            {
                if (_config.LowGTqFilter.HasValue && allele.GenotypeQscore < _config.LowGTqFilter)
                {
                    allele.AddFilter(FilterType.LowGenotypeQuality);
                }
            }


            allelesAtPosition.Sort((a1, a2) =>
            {
                var refCompare = a1.ReferenceAllele.CompareTo(a2.ReferenceAllele);
                return(refCompare == 0 ? a1.AlternateAllele.CompareTo(a2.AlternateAllele) : refCompare);
            });
        }