示例#1
0
        private void ExecuteRepeatTest(string variantBases, string repeatUnit, int repeatsInReference, int repeatThreshold, bool shouldBeFlagged)
        {
            var offset = 5 * repeatUnit.Length * repeatsInReference;

            offset = 10;

            // Test with insertion
            var variant = CreateRepeatVariant(variantBases);

            variant.Coordinate = offset + repeatUnit.Length;
            var chrReference = new ChrReference
            {
                Sequence = CreateRepeat(repeatUnit, repeatsInReference, variant.Coordinate)
            };


            AlleleProcessor.Process(variant, 0.01f, 0, 0,
                                    true, 0, 0, repeatThreshold, null, chrReference);

            Assert.Equal(shouldBeFlagged, variant.Filters.Contains(FilterType.IndelRepeatLength));

            // Test with deletion
            variant            = CreateRepeatVariant(variantBases, true);
            variant.Coordinate = offset + repeatUnit.Length;

            AlleleProcessor.Process(variant, 0.01f, 0, 0,
                                    true, 0, 0, repeatThreshold, null, chrReference);
            Assert.Equal(shouldBeFlagged, variant.Filters.Contains(FilterType.IndelRepeatLength));
        }
示例#2
0
        private void ExecuteFilteringTest(int totalCoverage, int qscore, bool strandBias,
                                          int?lowDepthFilter, int minQscore, bool singleStrandVariant, float?variantFreq,
                                          float?lowGQ, int?indelRepeat, List <FilterType> expectedFilters, bool isRefAllele = false)
        {
            var variant = TestHelper.CreatePassingVariant(isRefAllele);

            variant.TotalCoverage = totalCoverage;
            variant.VariantQscore = qscore;
            variant.StrandBiasResults.BiasAcceptable          = !strandBias;
            variant.StrandBiasResults.VarPresentOnBothStrands = !singleStrandVariant;
            var chrRef = new ChrReference();

            if (indelRepeat > 0)
            {
                variant.AlternateAllele = "AAAAAA";
                chrRef.Sequence         = "AAAAAAAA";

                if (!isRefAllele)
                {
                    variant.Type = AlleleCategory.Insertion;
                }
            }


            AlleleProcessor.Process(variant, 0.01f, lowDepthFilter, minQscore,
                                    true, variantFreq, lowGQ, indelRepeat, null, 0.6f, chrRef);

            Assert.Equal(variant.Filters.Count, expectedFilters.Count);
            foreach (var filter in variant.Filters)
            {
                Assert.True(expectedFilters.Contains(filter));
            }
        }
示例#3
0
        public void HappyPath()
        {
            var variant = TestHelper.CreatePassingVariant(false);

            variant.ReferenceSupport = 10;
            AlleleProcessor.Process(variant, 0.01f, 100, 20, false, 0f, 10f, 0, null, 0.6f, new ChrReference());
            Assert.False(variant.Filters.Any());
            Assert.Equal(0.02f, variant.FractionNoCalls);
            Assert.Equal(Genotype.HeterozygousAltRef, variant.Genotype);
        }
示例#4
0
        private void ExecuteNoCallTest(int totalCoverage, int numNoCalls, float expectedFraction)
        {
            var variant = CreatePassingVariant(false);

            variant.NumNoCalls    = numNoCalls;
            variant.TotalCoverage = totalCoverage;

            AlleleProcessor.Process(variant, GenotypeModel.Symmetrical, 0.01f, 100, 20, false);
            Assert.Equal(expectedFraction, variant.FractionNoCalls);
        }
示例#5
0
        private void ExecuteNoCallTest(int totalCoverage, int numNoCalls, float expectedFraction)
        {
            var variant = TestHelper.CreatePassingVariant(false);

            variant.NumNoCalls    = numNoCalls;
            variant.TotalCoverage = totalCoverage;

            AlleleProcessor.Process(variant, 0.01f, 100, 20, false, 10f, 10f, 8, null, 0.6f, new ChrReference());

            Assert.Equal(expectedFraction, variant.FractionNoCalls);
        }
示例#6
0
        public void HappyPath()
        {
            var variant = CreatePassingVariant(false);

            ((CalledVariant)variant).ReferenceSupport = 10;
            AlleleProcessor.Process(variant, GenotypeModel.Symmetrical, 0.01f, 100, 20, false);

            Assert.False(variant.Filters.Any());
            Assert.Equal(0.02f, variant.FractionNoCalls);
            Assert.Equal(Genotype.HeterozygousAlt, variant.Genotype);
        }
示例#7
0
        private void TestRepeats(string variantBases, int repeatThreshold, bool shouldBeFlagged, int referencePosition,
                                 ChrReference chrReferenceLong, bool isDeletion, int lengthToEnd)
        {
            var variant = CreateRepeatVariant(variantBases, isDeletion);

            variant.ReferencePosition = referencePosition;

            AlleleProcessor.Process(variant, 0.01f, 0, 0,
                                    true, 0, 0, repeatThreshold, null, 0.6f, chrReferenceLong);

            Assert.Equal(shouldBeFlagged, variant.Filters.Contains(FilterType.IndelRepeatLength));
        }
示例#8
0
        private void ExecuteGenotypeTest(int totalCoverage, float refFrequency, bool isReference, GenotypeModel model, Genotype expectedGenotype)
        {
            var variant = CreatePassingVariant(isReference);

            variant.TotalCoverage = totalCoverage;
            if (!isReference)
            {
                var refSupport = (int)(refFrequency * totalCoverage);
                variant.AlleleSupport = totalCoverage - refSupport;
                ((CalledVariant)variant).ReferenceSupport = refSupport;
            }
            AlleleProcessor.Process(variant, model, 0.01f, 100, 20, false);

            Assert.Equal(expectedGenotype, variant.Genotype);
        }
示例#9
0
        private void ExecuteFilteringTest(int totalCoverage, int qscore, bool strandBias, int minCoverage, int minQscore, bool singleStrandVariant,
                                          List <FilterType> expectedFilters)
        {
            var variant = CreatePassingVariant(false);

            variant.TotalCoverage = totalCoverage;
            variant.Qscore        = qscore;
            variant.StrandBiasResults.BiasAcceptable          = !strandBias;
            variant.StrandBiasResults.VarPresentOnBothStrands = !singleStrandVariant;

            AlleleProcessor.Process(variant, GenotypeModel.Symmetrical, 0.01f, minCoverage, minQscore, true);

            Assert.Equal(variant.Filters.Count, expectedFilters.Count);
            foreach (var filter in variant.Filters)
            {
                Assert.True(expectedFilters.Contains(filter));
            }
        }
示例#10
0
        private void ExecuteRMxNTest(string variantBases, string referenceSequence, int expectedRepeatLength, AlleleCategory category, 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)
            {
                ReferenceAllele   = refAllele,
                AlternateAllele   = altAllele,
                ReferencePosition = alleleCoordinate
            };

            RMxNFilterSettings rmxnFilterSettings = new RMxNFilterSettings();

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

            // If expected repeats == N, flag
            AlleleProcessor.Process(allele, 0.01f, 0, 0,
                                    true, 0, 0, null, rmxnFilterSettings, 0.6f, new ChrReference()
            {
                Sequence = cleanReferenceSequence
            });
            Assert.True(allele.Filters.Contains(FilterType.RMxN));

            // If expected repeats > N, flag
            rmxnFilterSettings.RMxNFilterMinRepetitions = expectedRepeatLength - 1;

            AlleleProcessor.Process(allele, 0.01f, 0, 0,
                                    true, 0, 0, null, rmxnFilterSettings, 0.6f, new ChrReference()
            {
                Sequence = cleanReferenceSequence
            });

            Assert.True(allele.Filters.Contains(FilterType.RMxN));

            // If expected repeats < N, flag
            rmxnFilterSettings.RMxNFilterMinRepetitions = expectedRepeatLength + 1;

            AlleleProcessor.Process(allele, 0.01f, 0, 0,
                                    true, 0, 0, null, rmxnFilterSettings, 0.6f, new ChrReference()
            {
                Sequence = cleanReferenceSequence
            });

            Assert.False(allele.Filters.Contains(FilterType.RMxN));

            // RMxN isn't valid on reference calls
            rmxnFilterSettings.RMxNFilterMinRepetitions = expectedRepeatLength + 1;

            AlleleProcessor.Process(new CalledAllele()
            {
            }, 0.01f, 0, 0,
                                    true, 0, 0, null, rmxnFilterSettings, 0.6f, new ChrReference()
            {
                Sequence = cleanReferenceSequence
            });

            Assert.False(allele.Filters.Contains(FilterType.RMxN));
        }
示例#11
0
        public void IndelRepeat_ChromosomeEdgeCases()
        {
            var chrReference = new ChrReference()
            {
                Sequence = String.Concat(Enumerable.Repeat("A", 75))
            };

            // Wherever the variant is in the reference, as long as it's within it, R8 filter should be ok.
            // See exception below.
            for (int i = 0; i < chrReference.Sequence.Length - 1; i++)
            {
                var variant = TestHelper.CreatePassingVariant(false);
                variant.ReferencePosition = i;

                variant.Type            = AlleleCategory.Insertion;
                variant.ReferenceAllele = "A";
                variant.AlternateAllele = "AA";

                AlleleProcessor.Process(variant, 0.01f, 0, 0,
                                        true, 0, 0, 2, null, 0.6f, chrReference);

                Assert.Equal(true, variant.Filters.Contains(FilterType.IndelRepeatLength));
            }

            // Quirk: A variant at the last or second-to-last position of the chromosome does not get R8 filtered
            // This comes from the legacy code that we implemented _only_ to maintain continuity with Isas, and it appears that this was an intentional behavior (comment in the code is "this handles cases where a deletion is larger than the number of downstream flanking bases").
            // This test is here to show the behavior.
            var variantAtLastPosition = TestHelper.CreatePassingVariant(false);

            variantAtLastPosition.ReferencePosition = chrReference.Sequence.Length; // Last position of chrom (variant positions are 1-based)
            variantAtLastPosition.Type            = AlleleCategory.Insertion;
            variantAtLastPosition.ReferenceAllele = "A";
            variantAtLastPosition.AlternateAllele = "AA";
            AlleleProcessor.Process(variantAtLastPosition, 0.01f, 0, 0,
                                    true, 0, 0, 2, null, 0.6f, chrReference);
            Assert.Equal(false, variantAtLastPosition.Filters.Contains(FilterType.IndelRepeatLength));

            var variantAtSecondToLastPosition = TestHelper.CreatePassingVariant(false);

            variantAtSecondToLastPosition.ReferencePosition = chrReference.Sequence.Length - 1; // Second to last position of chrom (variant positions are 1-based)
            variantAtSecondToLastPosition.Type            = AlleleCategory.Insertion;
            variantAtSecondToLastPosition.ReferenceAllele = "A";
            variantAtSecondToLastPosition.AlternateAllele = "AA";
            AlleleProcessor.Process(variantAtSecondToLastPosition, 0.01f, 0, 0,
                                    true, 0, 0, 2, null, 0.6f, chrReference);
            Assert.Equal(false, variantAtSecondToLastPosition.Filters.Contains(FilterType.IndelRepeatLength));


            // Variant decidedly outside of chromosome - throws exception because trying to substring at nonsensical positions of chromosome.
            // This is a non-sensical scenario, just demonstrating that it throws exception.
            // Note that if the variant was just one base outside of the chromosome, it wouldn't throw this exception (returns false -- again, not a real scenario, just documenting it)... .NET behavior for substring: returns empty string "if startIndex is equal to the length of this instance and length is zero."
            var variantOutsideOfChromosome = TestHelper.CreatePassingVariant(false);

            variantOutsideOfChromosome.ReferencePosition = chrReference.Sequence.Length + 2;
            variantOutsideOfChromosome.Type            = AlleleCategory.Insertion;
            variantOutsideOfChromosome.ReferenceAllele = "A";
            variantOutsideOfChromosome.AlternateAllele = "AA";

            Assert.Throws <ArgumentOutOfRangeException>(() => AlleleProcessor.Process(variantOutsideOfChromosome, 0.01f, 0, 0,
                                                                                      true, 0, 0, 2, null, 0.6f, chrReference));
        }