예제 #1
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);
        }
예제 #2
0
        public void AddAndGetCandidates_Errors()
        {
            var testRegion = new RegionState(1000, 2000);

            Assert.Throws <ArgumentException>(
                () => testRegion.AddCandidate(new CandidateAllele("chr1", 999, "A", "T", AlleleCategory.Snv)));

            Assert.Throws <ArgumentException>(
                () => testRegion.GetAlleleCount(2001, AlleleType.A, DirectionType.Forward));
        }
예제 #3
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);
        }