예제 #1
0
        public void TryStitch_NoXC_Unstitchable()
        {
            var read1 = TestHelper.CreateRead("chr1", "ATCGATCG", 12345,
                                              new CigarAlignment("8M"), qualityForAll: 30);

            var read2_noOverlap = TestHelper.CreateRead("chr1", "A", 2384,
                                                        new CigarAlignment("1M"), qualityForAll: 30);

            var read2_overlap = TestHelper.CreateRead("chr1", "ATCGTT", 12349,
                                                      new CigarAlignment("6M"), qualityForAll: 30);

            var read2_diffChrom = TestHelper.CreateRead("chr2", "ATCGTT", 12349,
                                                        new CigarAlignment("6M"), qualityForAll: 30);

            var read2_nonOverlap_border = TestHelper.CreateRead("chr1", "AT", 12343,
                                                                new CigarAlignment("2M"), qualityForAll: 30);

            var stitcher = StitcherTestHelpers.GetStitcher(10);

            ;
            // -----------------------------------------------
            // Either of the partner reads is missing*
            // *(only read that could be missing is read 2, if read 1 was missing couldn't create alignment set)
            // -----------------------------------------------
            // Should throw an exception
            var alignmentSet = new AlignmentSet(read1, null);

            Assert.Throws <ArgumentException>(() => stitcher.TryStitch(alignmentSet));

            // -----------------------------------------------
            // No overlap, reads are far away
            // -----------------------------------------------
            // Shouldn't stitch
            alignmentSet = new AlignmentSet(read1, read2_noOverlap);
            stitcher.TryStitch(alignmentSet);
            Assert.Equal(2, alignmentSet.ReadsForProcessing.Count);
            StitcherTestHelpers.TestUnstitchableReads(read1, read2_noOverlap, 0, (unStitchableReads) =>
            {
                Assert.Equal(1, unStitchableReads.Count(x => StitcherTestHelpers.VerifyReadsEqual(read1, x)));
                Assert.Equal(1, unStitchableReads.Count(x => StitcherTestHelpers.VerifyReadsEqual(read2_noOverlap, x)));
            });

            // -----------------------------------------------
            // No overlap, reads are directly neighboring
            // -----------------------------------------------
            // Shouldn't stitch
            alignmentSet = new AlignmentSet(read1, read2_nonOverlap_border);
            stitcher.TryStitch(alignmentSet);
            Assert.Equal(2, alignmentSet.ReadsForProcessing.Count);
            StitcherTestHelpers.TestUnstitchableReads(read1, read2_nonOverlap_border, 0, (unStitchableReads) =>
            {
                Assert.Equal(1, unStitchableReads.Count(x => StitcherTestHelpers.VerifyReadsEqual(read1, x)));
                Assert.Equal(1, unStitchableReads.Count(x => StitcherTestHelpers.VerifyReadsEqual(read2_nonOverlap_border, x)));
            });

            // -----------------------------------------------
            // No overlap, reads on diff chromosomes
            // -----------------------------------------------
            // Should throw exception
            alignmentSet = new AlignmentSet(read1, read2_diffChrom);
            var ex = Assert.Throws <ArgumentException>(() => stitcher.TryStitch(alignmentSet));

            Assert.Contains("Partner reads are from different chromosomes", ex.Message, StringComparison.InvariantCultureIgnoreCase); // This is brittle but since a variety of exceptions can happen in this process want to make sure it's this specific one
        }
        public void CallSomaticVariants_MergeReadsWithInsertion_BoundaryTests()
        {
            //Migrated from old Pisces: Originally called CallSomaticVariants_MergeReadsWithInsertion_BoundaryTests

            // insertion at edge of read

            //0 1 2 3 - - - 4 5 6 7 8 9
            //- C A T A T A G G
            //- - - - A T A G G T A A

            var read1 = TestHelper.CreateRead("chr1",
                                              "CATATAGG",
                                              1,
                                              new CigarAlignment("3M3I2M"),
                                              new byte[8],
                                              4);

            var read2 = TestHelper.CreateRead("chr1",
                                              "ATAGGTAA",
                                              4,
                                              new CigarAlignment("3S5M"),
                                              new byte[8],
                                              1);

            TestSuccesfullyStitchedRead(read1, read2, 0, "3M3I5M", (mergedRead) =>
            {
                Assert.NotNull(mergedRead);
                Assert.Equal(mergedRead.Sequence, "CATATAGGTAA");
            });


            //0 1 2 3 - - - 4 5 6 7 8 9
            //- C A T A T A G G
            //- - - - - T A G G T A A

            read1 = TestHelper.CreateRead("chr1", "CATATAGG", 1, new CigarAlignment("3M3I2M"),
                                          new byte[8], 4);

            read2 = TestHelper.CreateRead("chr1", "TAGGTAA", 4, new CigarAlignment("2S5M"),
                                          new byte[8], 1);

            TestSuccesfullyStitchedRead(read1, read2, 0, "3M3I5M", (mergedRead) =>
            {
                Assert.NotNull(mergedRead);
                Assert.Equal(mergedRead.Sequence, "CATATAGGTAA");
            });

            // shouldnt be able to stitch soft clipped areas only if XC tag not provided
            //0 1 2 3 - - - 4 5 6 7 8 9
            //- C A T A T A G G
            //- - - - - T A G G T A A

            read1 = TestHelper.CreateRead("chr1", "CATATAGG", 1, new CigarAlignment("3M5S"),
                                          new byte[8], 4);

            read2 = TestHelper.CreateRead("chr1", "TAGGTAA", 4, new CigarAlignment("2S5M"),
                                          new byte[8], 1);

            StitcherTestHelpers.TestUnstitchableReads(read1, read2, 0, (unStitchableReads) =>
            {
                Assert.Equal(1, unStitchableReads.Count(x => StitcherTestHelpers.VerifyReadsEqual(read1, x)));
                Assert.Equal(1, unStitchableReads.Count(x => StitcherTestHelpers.VerifyReadsEqual(read2, x)));
            });
        }