Example #1
0
        public void AddAndGetAlleleCounts()
        {
            var testRegion = new RegionState(1000, 2000);

            for (var i = 0; i < 5; i++)
            {
                testRegion.AddAlleleCount(1001, AlleleType.A, DirectionType.Forward);
            }
            for (var i = 0; i < 2; i++)
            {
                testRegion.AddAlleleCount(1001, AlleleType.C, DirectionType.Forward);
            }
            for (var i = 0; i < 12; i++)
            {
                testRegion.AddAlleleCount(1001, AlleleType.C, DirectionType.Reverse);
            }
            for (var i = 0; i < 15; i++)
            {
                testRegion.AddAlleleCount(2000, AlleleType.A, DirectionType.Stitched);
            }

            Assert.Equal(testRegion.GetAlleleCount(1001, AlleleType.A, DirectionType.Forward), 5);
            Assert.Equal(testRegion.GetAlleleCount(1001, AlleleType.C, DirectionType.Forward), 2);
            Assert.Equal(testRegion.GetAlleleCount(1001, AlleleType.C, DirectionType.Reverse), 12);
            Assert.Equal(testRegion.GetAlleleCount(2000, AlleleType.A, DirectionType.Stitched), 15);
            Assert.Equal(testRegion.GetAlleleCount(1000, AlleleType.A, DirectionType.Stitched), 0);
            Assert.Equal(testRegion.GetAlleleCount(1500, AlleleType.A, DirectionType.Forward), 0);
        }
Example #2
0
        private IAlleleSource CreateMockStateManager(List <AlleleCount> states, int refCounts = 0)
        {
            var mockAlleleCountSource = new Mock <IAlleleSource>();

            var numAnchorTypes = 5;
            var regionState    = new RegionState(1, 1000, numAnchorTypes);


            foreach (var state in states)
            {
                for (var directionIndex = 0; directionIndex < Constants.NumDirectionTypes; directionIndex++)
                {
                    for (var anchorIndex = 0; anchorIndex < numAnchorTypes * 2 + 1; anchorIndex++)
                    {
                        for (var i = 0; i < state.DirectionCoverage[directionIndex, anchorIndex]; i++)
                        {
                            regionState.AddAlleleCount(state.Coordinate, state.AlleleType, (DirectionType)directionIndex, anchorIndex);
                        }
                    }
                }
                mockAlleleCountSource.Setup(
                    s => s.GetAlleleCount(state.Coordinate,
                                          state.AlleleType,
                                          It.IsAny <DirectionType>(), It.IsAny <int>(), It.IsAny <int?>(), It.IsAny <bool>(), It.IsAny <bool>()))
                .Returns((int c, AlleleType a, DirectionType d, int minAnchor, int?maxAnchor, bool fromEnd, bool symm) =>
                {
                    return(regionState.GetAlleleCount(c, a, d, minAnchor, maxAnchor, fromEnd, symm));
                }
                         );
            }

            mockAlleleCountSource.Setup(c => c.GetGappedMnvRefCount(It.IsAny <int>())).Returns(refCounts);

            return(mockAlleleCountSource.Object);
        }
Example #3
0
        public void ExecuteTest_GetCandidates(bool withReference, bool withIntervals)
        {
            var testRegion   = new RegionState(1, 50);
            var chrReference = new ChrReference()
            {
                Name     = "chr1",
                Sequence = string.Concat(Enumerable.Repeat("A", 50))
            };
            var snv1 = new CandidateAllele("chr1", 5, "A", "T", AlleleCategory.Snv)
            {
                SupportByDirection = new [] { 10, 5, 0 }
            };
            var snv2 = new CandidateAllele("chr1", 15, "A", "T", AlleleCategory.Snv)
            {
                SupportByDirection = new[] { 10, 5, 0 }
            };

            testRegion.AddCandidate(snv1);
            testRegion.AddCandidate(snv2);

            for (var i = 0; i < 5; i++)
            {
                testRegion.AddAlleleCount(5, AlleleType.A, DirectionType.Stitched);  // ref @ variant position
                testRegion.AddAlleleCount(6, AlleleType.A, DirectionType.Stitched);  // ref by itself
                testRegion.AddAlleleCount(10, AlleleType.C, DirectionType.Stitched); // nonref by itself (no ref)
                testRegion.AddAlleleCount(15, AlleleType.A, DirectionType.Reverse);  // ref (multiple directions) + nonref
                testRegion.AddAlleleCount(15, AlleleType.A, DirectionType.Forward);
                testRegion.AddAlleleCount(15, AlleleType.T, DirectionType.Reverse);
            }

            ChrIntervalSet intervals = null;

            if (withIntervals)
            {
                intervals = new ChrIntervalSet(new List <CallSomaticVariants.Logic.RegionState.Region>()
                {
                    new CallSomaticVariants.Logic.RegionState.Region(3, 6),
                    new CallSomaticVariants.Logic.RegionState.Region(16, 16)
                }, "chr1");
            }
            var expectedList = new List <CandidateAllele>();

            expectedList.Add(snv1);
            expectedList.Add(snv2);

            if (withReference)
            {
                expectedList.Add(new CandidateAllele("chr1", 5, "A", "A", AlleleCategory.Reference)
                {
                    SupportByDirection = new[] { 0, 0, 5 }
                });
                expectedList.Add(new CandidateAllele("chr1", 6, "A", "A", AlleleCategory.Reference)
                {
                    SupportByDirection = new[] { 0, 0, 5 }
                });
                expectedList.Add(new CandidateAllele("chr1", 10, "A", "A", AlleleCategory.Reference)
                {
                    SupportByDirection = new[] { 0, 0, 0 }
                });
                expectedList.Add(new CandidateAllele("chr1", 15, "A", "A", AlleleCategory.Reference)
                {
                    SupportByDirection = new[] { 5, 5, 0 }
                });
            }

            if (withIntervals)
            {
                expectedList = expectedList.Where(c => c.Coordinate == 5 || c.Coordinate == 6 || c.Type != AlleleCategory.Reference).ToList();
                if (withReference)
                {
                    expectedList.Add(new CandidateAllele("chr1", 3, "A", "A", AlleleCategory.Reference)
                    {
                        SupportByDirection = new[] { 0, 0, 0 }
                    });
                    expectedList.Add(new CandidateAllele("chr1", 4, "A", "A", AlleleCategory.Reference)
                    {
                        SupportByDirection = new[] { 0, 0, 0 }
                    });
                    expectedList.Add(new CandidateAllele("chr1", 16, "A", "A", AlleleCategory.Reference)
                    {
                        SupportByDirection = new[] { 0, 0, 0 }
                    });
                }
            }
            var allCandidates = testRegion.GetAllCandidates(withReference, chrReference, intervals);

            VerifyCandidates(expectedList, allCandidates);
        }