public void TryStitch_MergeReadsSmall() { //Migrated from old Pisces: Originally called Pisces_MergeReadsSmall //test1: happy path //0 1 2 3 4 5 6 7 8 9 //- C A T A T //- - - - A T A G G var read1 = ReadTestHelper.CreateRead("chr1", "CATAT", 1, new CigarAlignment("5M"), new byte[] { 1, 2, 3, 4, 5 }, 4); StitcherTestHelpers.SetReadDirections(read1, DirectionType.Forward); var read2 = ReadTestHelper.CreateRead("chr1", "ATAGG", 4, new CigarAlignment("5M"), new byte[] { 1, 20, 30, 40, 50 }, 1); StitcherTestHelpers.SetReadDirections(read2, DirectionType.Reverse); var alignmentSet = new AlignmentSet(read1, read2); var stitcher = StitcherTestHelpers.GetStitcher(10, nifyDisagreements: false); stitcher.TryStitch(alignmentSet); TestSuccesfullyStitchedRead(read1, read2, 0, "8M", (mergedRead) => { Assert.Equal(mergedRead.Sequence, "CATATAGG"); StitcherTestHelpers.CompareQuality(new byte[] { 1, 2, 3, 5, 25, 30, 40, 50 }, mergedRead.Qualities); var expectedDirections = StitcherTestHelpers.BuildDirectionMap(new List <IEnumerable <DirectionType> > { StitcherTestHelpers.BuildDirectionSegment(DirectionType.Forward, 3), StitcherTestHelpers.BuildDirectionSegment(DirectionType.Stitched, 2), StitcherTestHelpers.BuildDirectionSegment(DirectionType.Reverse, 3) }); StitcherTestHelpers.VerifyDirectionType(expectedDirections, mergedRead.CigarDirections.Expand().ToArray()); }); //test2: different bases, one with low Q //0 1 2 3 4 5 6 7 8 9 //- C A T A G //- - - - A T A G G read1 = ReadTestHelper.CreateRead("chr1", "CATAG", 1, new CigarAlignment("5M"), new byte[] { 1, 2, 3, 4, 5 }, 4); StitcherTestHelpers.SetReadDirections(read1, DirectionType.Reverse); read2 = ReadTestHelper.CreateRead("chr1", "ATAGG", 4, new CigarAlignment("5M"), new byte[] { 1, 20, 30, 40, 50 }, 1); StitcherTestHelpers.SetReadDirections(read2, DirectionType.Forward); TestSuccesfullyStitchedRead(read1, read2, 10, "8M", (mergedRead) => { Assert.NotNull(mergedRead); Assert.Equal("CATATAGG", mergedRead.Sequence); StitcherTestHelpers.CompareQuality(new byte[] { 1, 2, 3, 5, 20, 30, 40, 50 }, mergedRead.Qualities); var expectedDirections = StitcherTestHelpers.BuildDirectionMap(new List <IEnumerable <DirectionType> > { StitcherTestHelpers.BuildDirectionSegment(DirectionType.Reverse, 3), StitcherTestHelpers.BuildDirectionSegment(DirectionType.Stitched, 2), StitcherTestHelpers.BuildDirectionSegment(DirectionType.Forward, 3) }); StitcherTestHelpers.VerifyDirectionType(expectedDirections, mergedRead.CigarDirections.Expand().ToArray()); }); //test3: different bases, both with high Q //0 1 2 3 4 5 6 7 8 9 //- C A T A G //- - - - A T A G G read1 = ReadTestHelper.CreateRead("chr1", "CATAG", 1, new CigarAlignment("5M"), new byte[] { 50, 92, 92, 92, 92 }, 4); read2 = ReadTestHelper.CreateRead("chr1", "ATAGG", 4, new CigarAlignment("5M"), new byte[] { 2, 20, 30, 40, 50 }, 1); StitcherTestHelpers.SetReadDirections(read1, DirectionType.Forward); StitcherTestHelpers.SetReadDirections(read2, DirectionType.Reverse); TestSuccesfullyStitchedRead(read1, read2, 10, "8M", (mergedRead) => { Assert.NotNull(mergedRead); Assert.Equal("CATANAGG", mergedRead.Sequence); StitcherTestHelpers.CompareQuality(new byte[] { 50, 92, 92, 93, 0, 30, 40, 50 }, mergedRead.Qualities); var expectedDirections = StitcherTestHelpers.BuildDirectionMap(new List <IEnumerable <DirectionType> > { StitcherTestHelpers.BuildDirectionSegment(DirectionType.Forward, 3), StitcherTestHelpers.BuildDirectionSegment(DirectionType.Stitched, 2), StitcherTestHelpers.BuildDirectionSegment(DirectionType.Reverse, 3) }); StitcherTestHelpers.VerifyDirectionType(expectedDirections, mergedRead.CigarDirections.Expand().ToArray()); }, nifyDisagreements: true); }
public void TryStitch_ReCo() { // Real example from ReCo, was failing to generate the correct stitched cigar var read1Bases = "GTACTCCTACAGTCCCACCCCTCCCCTATAAACCTTATGAATCCCCGTTCACTTAGATGCCAGCTTGGCAAGGAAGGGAAGTACACATCTGTTGACAGTAATGAAATATCCTTGATAAGGATTTAAATTTTGGATGTGCTG"; var read2Bases = "ACCTACAGTCCCACCCCTCCCCTATAAACCTTAGGAATCCCCGTTCACTTAGATGCCAGCTTGGCAAGGAAGGGAAGTACACATCTGTTGACAGTAATGAAATATCCTTGATAAGGATTTAAATTTTGGATGTGCTGAGCT"; // 8 9 // 3 4 5 6 7 8 9 0 1 2 // s s s s s M M M M M ... // - - - - M M M M M M ... // F F F F R S S S S S ... // Stitched directions if we don't allow softclip to contribute // F F F F S S S S S S ... // Stitched directions if we do allow softclip to contribute var read1 = DomainTestHelper.CreateRead("chr21", read1Bases, 16685488, new CigarAlignment("5S136M")); var read2 = DomainTestHelper.CreateRead("chr21", read2Bases, 16685487, new CigarAlignment("137M4S")); StitcherTestHelpers.SetReadDirections(read2, DirectionType.Reverse); var stitcher = new BasicStitcher(10, useSoftclippedBases: false); var alignmentSet = new AlignmentSet(read1, read2); stitcher.TryStitch(alignmentSet); // Without allowing softclips to count to support, should still get a M at an M/S overlap, but it won't be stitched. var mergedRead = StitcherTestHelpers.GetMergedRead(alignmentSet); Assert.Equal("4S137M4S", mergedRead.CigarData.ToString()); var expectedDirections = StitcherTestHelpers.BuildDirectionMap(new List <IEnumerable <DirectionType> > { StitcherTestHelpers.BuildDirectionSegment(DirectionType.Forward, 4), StitcherTestHelpers.BuildDirectionSegment(DirectionType.Reverse, 1), StitcherTestHelpers.BuildDirectionSegment(DirectionType.Stitched, 136), StitcherTestHelpers.BuildDirectionSegment(DirectionType.Reverse, 4) }); StitcherTestHelpers.VerifyDirectionType(expectedDirections, mergedRead.CigarDirections.Expand().ToArray()); stitcher = new BasicStitcher(10, useSoftclippedBases: true); alignmentSet = new AlignmentSet(read1, read2); stitcher.TryStitch(alignmentSet); mergedRead = StitcherTestHelpers.GetMergedRead(alignmentSet); Assert.Equal("4S137M4S", mergedRead.CigarData.ToString()); expectedDirections = StitcherTestHelpers.BuildDirectionMap(new List <IEnumerable <DirectionType> > { StitcherTestHelpers.BuildDirectionSegment(DirectionType.Forward, 4), StitcherTestHelpers.BuildDirectionSegment(DirectionType.Reverse, 1), StitcherTestHelpers.BuildDirectionSegment(DirectionType.Stitched, 136), StitcherTestHelpers.BuildDirectionSegment(DirectionType.Reverse, 4) }); StitcherTestHelpers.VerifyDirectionType(expectedDirections, mergedRead.CigarDirections.Expand().ToArray()); // If we're not ignoring probe softclips, go back to the original expected directions (1 more stitched from probe) stitcher = new BasicStitcher(10, useSoftclippedBases: true, ignoreProbeSoftclips: false); alignmentSet = new AlignmentSet(read1, read2); stitcher.TryStitch(alignmentSet); mergedRead = StitcherTestHelpers.GetMergedRead(alignmentSet); Assert.Equal("4S137M4S", mergedRead.CigarData.ToString()); expectedDirections = StitcherTestHelpers.BuildDirectionMap(new List <IEnumerable <DirectionType> > { StitcherTestHelpers.BuildDirectionSegment(DirectionType.Forward, 4), StitcherTestHelpers.BuildDirectionSegment(DirectionType.Stitched, 137), StitcherTestHelpers.BuildDirectionSegment(DirectionType.Reverse, 4) }); StitcherTestHelpers.VerifyDirectionType(expectedDirections, mergedRead.CigarDirections.Expand().ToArray()); }