public void Compare() { var collapser = new VariantCollapser(null); // priority should be given to known, fully anchored, longer, more frequent, and left positioned var candidateA = GetBasicInsertion(); var candidateB = GetBasicInsertion(); candidateA.OpenOnLeft = true; candidateB.OpenOnLeft = true; Assert.Equal(0, collapser.Compare(candidateA, candidateB)); Assert.Equal(0, collapser.Compare(candidateB, candidateA)); candidateA.Alternate = "AAGTACGT"; Assert.Equal(-1, collapser.Compare(candidateA, candidateB)); candidateB.Coordinate = 4; Assert.Equal(1, collapser.Compare(candidateA, candidateB)); candidateA.Frequency = 0.0000005f; candidateB.Frequency = 0.0000004f; Assert.Equal(-1, collapser.Compare(candidateA, candidateB)); candidateB.Alternate = "ACGTACGTT"; Assert.Equal(1, collapser.Compare(candidateA, candidateB)); candidateA.OpenOnLeft = false; Assert.Equal(-1, collapser.Compare(candidateA, candidateB)); candidateB.IsKnown = true; Assert.Equal(1, collapser.Compare(candidateA, candidateB)); }
private void ExecuteTest(List <CandidateAllele> candidates, int expectedNumAfter, int?expectedSupport = null, int?maxClearedPosition = null, List <CandidateAllele> known = null, Action <List <CandidateAllele> > candidateAssertions = null, Action <List <CandidateAllele> > stage = null, Action <List <CandidateAllele> > addedBackAssertions = null) { var addedBack = new List <CandidateAllele>(); ResetSupport(candidates); var collapser = new VariantCollapser(known); var mockSource = GetMockSource(addedBack); if (stage != null) { stage(candidates); } var result = collapser.Collapse(new List <CandidateAllele>(candidates.Select(c => c.DeepCopy())), mockSource.Object, maxClearedPosition); Assert.Equal(expectedNumAfter, result.Count); if (expectedSupport.HasValue) { Assert.Equal(expectedSupport, result[0].Support); } if (candidateAssertions != null) { candidateAssertions(result); } if (addedBackAssertions != null) { addedBackAssertions(addedBack); } // order of candidates shouldnt matter addedBack.Clear(); ResetSupport(candidates); if (stage != null) { stage(candidates); } var reverse = new List <CandidateAllele>(candidates.Select(c => c.DeepCopy())); reverse.Reverse(); result = collapser.Collapse(reverse, mockSource.Object, maxClearedPosition); Assert.Equal(expectedNumAfter, result.Count); if (expectedSupport.HasValue) { Assert.Equal(expectedSupport, result[0].Support); } if (candidateAssertions != null) { candidateAssertions(result); } if (addedBackAssertions != null) { addedBackAssertions(addedBack); } }
private void ExecuteEndednessTest(List <CandidateAllele> candidates, bool expectOpenOnLeft, bool expectOpenOnRight) { var collapser = new VariantCollapser(null); var mockSource = GetMockSource(null); var forward = candidates.Select(candidate => candidate.DeepCopy()).ToList(); var result = collapser.Collapse(forward, mockSource.Object, null); Assert.Equal(result[0].OpenOnLeft, expectOpenOnLeft); Assert.Equal(result[0].OpenOnRight, expectOpenOnRight); }