コード例 #1
0
        private static void ApplyFilters(CalledAllele allele, int?minCoverageFilter, int?variantQscoreThreshold, bool filterSingleStrandVariants, float?variantFreqFilter, float?lowGenotypeqFilter, int?indelRepeatFilter,
                                         RMxNFilterSettings rMxNFilterSettings, float?noCallFilter, bool hasStitchedSource, ChrReference chrReference)
        {
            //Reset filters
            allele.Filters.Clear();

            if (minCoverageFilter.HasValue && allele.TotalCoverage < minCoverageFilter)
            {
                allele.AddFilter(FilterType.LowDepth);
            }

            if (variantQscoreThreshold.HasValue && allele.VariantQscore < variantQscoreThreshold && (allele.TotalCoverage != 0))
            {
                //note we wont flag it for Qscore, if its got zero depth, because in that case, the Q score calc was not made anyway.
                allele.AddFilter(FilterType.LowVariantQscore);
            }
            if (allele.Type != AlleleCategory.Reference)
            {
                //No call filter
                if (noCallFilter.HasValue && allele.FractionNoCalls > noCallFilter)
                {
                    allele.AddFilter(FilterType.NoCall);
                }

                if (!allele.StrandBiasResults.BiasAcceptable ||
                    (filterSingleStrandVariants && !allele.StrandBiasResults.VarPresentOnBothStrands))
                {
                    allele.AddFilter(FilterType.StrandBias);
                }

                if (indelRepeatFilter.HasValue && indelRepeatFilter > 0)
                {
                    var indelRepeatLength = ComputeIndelRepeatLength(allele, chrReference.Sequence);
                    if (indelRepeatFilter <= indelRepeatLength)
                    {
                        allele.AddFilter(FilterType.IndelRepeatLength);
                    }
                }

                if (RMxNCalculator.ShouldFilter(allele, rMxNFilterSettings, chrReference.Sequence))
                {
                    allele.AddFilter(FilterType.RMxN);
                }

                if (variantFreqFilter.HasValue && allele.Frequency < variantFreqFilter)
                {
                    allele.AddFilter(FilterType.LowVariantFrequency);
                }

                if (hasStitchedSource) //can only happen for insertions and MNVs
                {
                    if (allele.AlternateAllele.Contains("N"))
                    {
                        allele.AddFilter(FilterType.StrandBias);
                    }
                }
            }
        }
コード例 #2
0
        private void ExecuteRMxNTest(string variantBases, string referenceSequence, int expectedRepeatLength, AlleleCategory category, double allelefrequency, int maxRepeatUnitLength)
        {
            var alleleCoordinate       = referenceSequence.IndexOf('*');
            var cleanReferenceSequence = referenceSequence.Replace("*", "");

            var refAllele = "";
            var altAllele = "";

            if (category == AlleleCategory.Insertion)
            {
                refAllele = cleanReferenceSequence.Substring(alleleCoordinate - 1, 1);
                altAllele = refAllele + variantBases;
            }
            else if (category == AlleleCategory.Deletion)
            {
                altAllele = cleanReferenceSequence.Substring(alleleCoordinate - 1, 1);
                refAllele = altAllele + variantBases;
            }
            else
            {
                refAllele = cleanReferenceSequence.Substring(alleleCoordinate - 1, variantBases.Length);
                altAllele = variantBases;
            }

            var allele = new CalledAllele(category)
            {
                Reference  = refAllele,
                Alternate  = altAllele,
                Coordinate = alleleCoordinate
            };

            allele.TotalCoverage = 1000;
            allele.AlleleSupport = (int)(1000.0 * variantFrequncy);

            RMxNFilterSettings rmxnFilterSettings = new RMxNFilterSettings();

            rmxnFilterSettings.RMxNFilterFrequencyLimit  = 1.1f;
            rmxnFilterSettings.RMxNFilterMaxLengthRepeat = maxRepeatUnitLength;
            rmxnFilterSettings.RMxNFilterMinRepetitions  = expectedRepeatLength;

            // If expected repeats == N, flag
            Assert.True(RMxNCalculator.ShouldFilter(allele, rmxnFilterSettings, cleanReferenceSequence));

            // If expected repeats > N, flag
            rmxnFilterSettings.RMxNFilterMinRepetitions = expectedRepeatLength - 1;
            Assert.True(RMxNCalculator.ShouldFilter(allele, rmxnFilterSettings, cleanReferenceSequence));

            // If expected repeats < N, flag
            rmxnFilterSettings.RMxNFilterMinRepetitions = expectedRepeatLength + 1;
            Assert.False(RMxNCalculator.ShouldFilter(allele, rmxnFilterSettings, cleanReferenceSequence));

            // RMxN isn't valid on reference calls
            rmxnFilterSettings.RMxNFilterMinRepetitions = expectedRepeatLength + 1;
            Assert.False(RMxNCalculator.ShouldFilter(allele, rmxnFilterSettings, cleanReferenceSequence));

            // Even if expected repeats == N, dont flag if VF is too high
            rmxnFilterSettings.RMxNFilterFrequencyLimit = 0.10f;
            rmxnFilterSettings.RMxNFilterMinRepetitions = expectedRepeatLength;
            Assert.False(RMxNCalculator.ShouldFilter(allele, rmxnFilterSettings, cleanReferenceSequence));

            // Even if expected repeats > N, flag, dont flag if VF is too high
            rmxnFilterSettings.RMxNFilterFrequencyLimit = 0.10f;
            rmxnFilterSettings.RMxNFilterMinRepetitions = expectedRepeatLength - 1;
            Assert.False(RMxNCalculator.ShouldFilter(allele, rmxnFilterSettings, cleanReferenceSequence));
        }