Example #1
0
        private ISomaticVariantCaller CreateMockVariantCaller(VcfFileWriter vcfWriter, ApplicationOptions options, ChrReference chrRef, MockAlignmentExtractor mae, IStrandBiasFileWriter biasFileWriter = null, string intervalFilePath = null)
        {
            var config = new AlignmentSourceConfig
            {
                MinimumMapQuality  = options.MinimumMapQuality,
                OnlyUseProperPairs = options.OnlyUseProperPairs,
            };

            IAlignmentStitcher stitcher = null;

            if (options.StitchReads)
            {
                if (options.UseXCStitcher)
                {
                    stitcher = new XCStitcher(options.MinimumBaseCallQuality);
                }
                else
                {
                    stitcher = new BasicStitcher(options.MinimumBaseCallQuality);
                }
            }

            var mateFinder      = options.StitchReads ? new AlignmentMateFinder(MAX_FRAGMENT_SIZE) : null;
            var RegionPadder    = new RegionPadder(chrRef, null);
            var alignmentSource = new AlignmentSource(mae, mateFinder, stitcher, config);
            var variantFinder   = new CandidateVariantFinder(options.MinimumBaseCallQuality, options.MaxSizeMNV, options.MaxGapBetweenMNV, options.CallMNVs);
            var alleleCaller    = new AlleleCaller(new VariantCallerConfig
            {
                IncludeReferenceCalls        = options.OutputgVCFFiles,
                MinVariantQscore             = options.MinimumVariantQScore,
                MaxVariantQscore             = options.MaximumVariantQScore,
                VariantQscoreFilterThreshold = options.FilteredVariantQScore > options.MinimumVariantQScore ? options.FilteredVariantQScore : (int?)null,
                MinCoverage                = options.MinimumCoverage,
                MinFrequency               = options.MinimumFrequency,
                EstimatedBaseCallQuality   = options.AppliedNoiseLevel == -1 ? options.MinimumBaseCallQuality : options.AppliedNoiseLevel,
                StrandBiasModel            = options.StrandBiasModel,
                StrandBiasFilterThreshold  = options.StrandBiasAcceptanceCriteria,
                FilterSingleStrandVariants = options.FilterOutVariantsPresentOnlyOneStrand,
                GenotypeModel              = options.GTModel
            });
            var stateManager = new RegionStateManager();

            return(new SomaticVariantCaller(
                       alignmentSource,
                       variantFinder,
                       alleleCaller,
                       vcfWriter,
                       stateManager,
                       chrRef,
                       RegionPadder,
                       biasFileWriter));
        }
Example #2
0
        private void ExecuteTest(RegionPadder mapper, CandidateBatch batch,
                                 List <CandidateAllele> expectedAlleles, bool mapAll = false)
        {
            mapper.Pad(batch, mapAll);
            var candidates = batch.GetCandidates();

            Assert.Equal(expectedAlleles.Count, candidates.Count());

            foreach (var candidate in candidates)
            {
                Assert.True(expectedAlleles.Contains(candidate));
            }
        }
Example #3
0
        public void Map()
        {
            // set up test
            var intervals = new List <CallSomaticVariants.Logic.RegionState.Region>
            {
                new CallSomaticVariants.Logic.RegionState.Region(4, 10),
                new CallSomaticVariants.Logic.RegionState.Region(15, 17),
                new CallSomaticVariants.Logic.RegionState.Region(25, 39),
                new CallSomaticVariants.Logic.RegionState.Region(50, 55),
                new CallSomaticVariants.Logic.RegionState.Region(60, 70),
                new CallSomaticVariants.Logic.RegionState.Region(80, 80)
            };

            var mapper = new RegionPadder(_chrReference, new ChrIntervalSet(intervals, "chr1"));

            // ------------------------------------
            // first batch starts after interval start - make sure beginning positions arent skipped
            // ------------------------------------
            var batch = new CandidateBatch
            {
                ClearedRegions = new List <CallSomaticVariants.Logic.RegionState.Region>
                {
                    new CallSomaticVariants.Logic.RegionState.Region(5, 11)
                }
            };
            var expectedAlleles = new List <CandidateAllele>();

            AddReferenceCandidatesByRange(expectedAlleles, new List <Tuple <int, int> >()
            {
                new Tuple <int, int>(4, 4)
            });
            ExecuteTest(mapper, batch, expectedAlleles);

            // ------------------------------------
            // next batch and starts after the second interval, fully covers third interval and partially the fourth
            // ------------------------------------
            batch = new CandidateBatch
            {
                ClearedRegions = new List <CallSomaticVariants.Logic.RegionState.Region>
                {
                    new CallSomaticVariants.Logic.RegionState.Region(20, 52),
                }
            };
            expectedAlleles.Clear();
            AddReferenceCandidatesByRange(expectedAlleles, new List <Tuple <int, int> >()
            {
                new Tuple <int, int>(15, 17)
            });
            ExecuteTest(mapper, batch, expectedAlleles);

            // ------------------------------------
            // next batch contains multiple cleared regions
            // ------------------------------------
            batch = new CandidateBatch
            {
                ClearedRegions = new List <CallSomaticVariants.Logic.RegionState.Region>
                {
                    new CallSomaticVariants.Logic.RegionState.Region(58, 59),
                    new CallSomaticVariants.Logic.RegionState.Region(62, 68)
                }
            };
            expectedAlleles.Clear();
            AddReferenceCandidatesByRange(expectedAlleles, new List <Tuple <int, int> >()
            {
                new Tuple <int, int>(53, 55),
                new Tuple <int, int>(60, 61)
            });
            ExecuteTest(mapper, batch, expectedAlleles);

            // ------------------------------------
            // empty batch
            // ------------------------------------
            batch = new CandidateBatch
            {
                ClearedRegions = null
            };
            expectedAlleles.Clear();
            ExecuteTest(mapper, batch, expectedAlleles);

            // ------------------------------------
            // all the rest
            // ------------------------------------
            batch = new CandidateBatch
            {
                ClearedRegions = new List <CallSomaticVariants.Logic.RegionState.Region>
                {
                    new CallSomaticVariants.Logic.RegionState.Region(69, 69)
                }
            };
            expectedAlleles.Clear();
            AddReferenceCandidatesByRange(expectedAlleles, new List <Tuple <int, int> >()
            {
                new Tuple <int, int>(70, 70),
                new Tuple <int, int>(80, 80)
            });
            ExecuteTest(mapper, batch, expectedAlleles, true);
        }