public void AddAndGetAlleleCounts() { var anchorSize = 5; var wellAnchoredIndex = anchorSize; var testRegion = new MyRegionState(1000, 2000, anchorSize); for (var i = 0; i < 5; i++) { testRegion.AddAlleleCount(1001, AlleleType.A, DirectionType.Forward, wellAnchoredIndex); } for (var i = 0; i < 2; i++) { testRegion.AddAlleleCount(1001, AlleleType.C, DirectionType.Forward, wellAnchoredIndex); } for (var i = 0; i < 12; i++) { testRegion.AddAlleleCount(1001, AlleleType.C, DirectionType.Reverse, wellAnchoredIndex); } for (var i = 0; i < 15; i++) { testRegion.AddAlleleCount(2000, AlleleType.A, DirectionType.Stitched, wellAnchoredIndex); } 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); }
public void ExecuteTest_GetCandidates(bool withReference, bool withIntervals) { var anchorSize = 5; var wellAnchoredIndex = anchorSize; var testRegion = new MyRegionState(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, wellAnchoredIndex); // ref @ variant position testRegion.AddAlleleCount(6, AlleleType.A, DirectionType.Stitched, wellAnchoredIndex); // ref by itself testRegion.AddAlleleCount(10, AlleleType.C, DirectionType.Stitched, wellAnchoredIndex); // nonref by itself (no ref) testRegion.AddAlleleCount(15, AlleleType.A, DirectionType.Reverse, wellAnchoredIndex); // ref (multiple directions) + nonref testRegion.AddAlleleCount(15, AlleleType.A, DirectionType.Forward, wellAnchoredIndex); testRegion.AddAlleleCount(15, AlleleType.T, DirectionType.Reverse, wellAnchoredIndex); } ChrIntervalSet intervals = null; if (withIntervals) { intervals = new ChrIntervalSet(new List <Region>() { new Region(3, 6), new 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.ReferencePosition == 5 || c.ReferencePosition == 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); }