コード例 #1
0
        public void PrunedForcedAlleleShouldBeCalled()
        {
            var mockCandidateToBatch = new Mock <ICandidateBatch>();
            var candidateAllele1     = new CandidateAllele("chr1", 10, "G", "T", AlleleCategory.Snv);

            mockCandidateToBatch.Setup(s => s.GetCandidates()).Returns(new List <CandidateAllele> {
                candidateAllele1
            });
            mockCandidateToBatch.SetupGet(s => s.MaxClearedPosition).Returns(100);
            var config = new VariantCallerConfig {
                MinCoverage = 20
            };
            var myChrRef = new ChrReference()
            {
                Name     = "chr1",
                Sequence = "ATGGCCTACGATTAGTAGGT"
            };

            config.ChrReference = myChrRef;
            //config.MinCoverage = 20;
            var mockCoverageCalculator = new Mock <ICoverageCalculator>();

            mockCoverageCalculator.Setup(x => x.Compute(It.IsAny <CalledAllele>(), It.IsAny <IAlleleSource>()));
            var mockGenotypeCalculator = new Mock <IGenotypeCalculator>();

            mockGenotypeCalculator.Setup(x => x.SetGenotypes(It.IsAny <IEnumerable <CalledAllele> >())).Returns <List <CalledAllele> >(s => s);     //note: returns allele to prune
            config.GenotypeCalculator = mockGenotypeCalculator.Object;
            config.LocusProcessor     = new DiploidLocusProcessor();
            var alleleCaller = new AlleleCaller(config, null, null, mockCoverageCalculator.Object);

            var mockAlleleSource = new Mock <IAlleleSource>();



            var observedAllelewithoutForcedAllele = alleleCaller.Call(mockCandidateToBatch.Object, mockAlleleSource.Object);

            Assert.Equal(0, observedAllelewithoutForcedAllele.Count);

            var forcedGtAlleles = new HashSet <Tuple <string, int, string, string> >
            {
                new Tuple <string, int, string, string>("chr1", 10, "G", "T")
            };

            alleleCaller.AddForcedGtAlleles(forcedGtAlleles);

            var observedCalledAllele = alleleCaller.Call(mockCandidateToBatch.Object, mockAlleleSource.Object);

            Assert.Equal(1, observedCalledAllele.Count);
            Assert.True(observedCalledAllele.First().Value.First().IsForcedToReport);
        }
コード例 #2
0
ファイル: Factory.cs プロジェクト: zhaohongqiangsoliva/Pisces
        protected virtual IAlleleCaller CreateVariantCaller(ChrReference chrReference, ChrIntervalSet intervalSet, IAlignmentSource alignmentSource, HashSet <Tuple <string, int, string, string> > forceGtAlleles = null)
        {
            var coverageCalculator = CreateCoverageCalculator(alignmentSource);
            var genotypeCalculator = GenotypeCreator.CreateGenotypeCalculator(
                _options.VariantCallingParameters.PloidyModel, _options.VariantCallingParameters.MinimumFrequencyFilter,
                _options.VariantCallingParameters.MinimumCoverage,
                _options.VariantCallingParameters.DiploidSNVThresholdingParameters,
                _options.VariantCallingParameters.DiploidINDELThresholdingParameters,
                _options.VariantCallingParameters.AdaptiveGenotypingParameters,
                _options.VariantCallingParameters.MinimumGenotypeQScore,
                _options.VariantCallingParameters.MaximumGenotypeQScore,
                _options.VariantCallingParameters.TargetLODFrequency,
                _options.VariantCallingParameters.MinimumFrequency,
                chrReference.Name, _options.VariantCallingParameters.IsMale);

            genotypeCalculator.SetMinFreqFilter(_options.VariantCallingParameters.MinimumFrequencyFilter);

            var locusProcessor = _options.VariantCallingParameters.PloidyModel == PloidyModel.DiploidByThresholding
                ? (ILocusProcessor) new DiploidLocusProcessor()
                : new SomaticLocusProcessor();

            var variantCallerConfig = new VariantCallerConfig
            {
                IncludeReferenceCalls        = _options.VcfWritingParameters.OutputGvcfFile,
                MinVariantQscore             = _options.VariantCallingParameters.MinimumVariantQScore,
                MaxVariantQscore             = _options.VariantCallingParameters.MaximumVariantQScore,
                MinGenotypeQscore            = _options.VariantCallingParameters.MinimumGenotypeQScore,
                MaxGenotypeQscore            = _options.VariantCallingParameters.MaximumGenotypeQScore,
                VariantQscoreFilterThreshold = _options.VariantCallingParameters.MinimumVariantQScoreFilter,
                NoCallFilterThreshold        = _options.VariantCallingParameters.NoCallFilterThreshold,
                AmpliconBiasFilterThreshold  = _options.VariantCallingParameters.AmpliconBiasFilterThreshold,
                MinCoverage  = _options.VariantCallingParameters.MinimumCoverage,
                MinFrequency = genotypeCalculator.MinVarFrequency,
                NoiseLevelUsedForQScoring  = _options.VariantCallingParameters.NoiseLevelUsedForQScoring,
                StrandBiasModel            = _options.VariantCallingParameters.StrandBiasModel,
                StrandBiasFilterThreshold  = _options.VariantCallingParameters.StrandBiasAcceptanceCriteria,
                FilterSingleStrandVariants = _options.VariantCallingParameters.FilterOutVariantsPresentOnlyOneStrand,
                GenotypeCalculator         = genotypeCalculator,
                VariantFreqFilter          = genotypeCalculator.MinVarFrequencyFilter,
                LowGTqFilter       = _options.VariantCallingParameters.LowGenotypeQualityFilter,
                IndelRepeatFilter  = _options.VariantCallingParameters.IndelRepeatFilter,
                LowDepthFilter     = _options.VariantCallingParameters.LowDepthFilter,
                ChrReference       = chrReference,
                RMxNFilterSettings = new RMxNFilterSettings
                {
                    RMxNFilterMaxLengthRepeat = _options.VariantCallingParameters.RMxNFilterMaxLengthRepeat,
                    RMxNFilterMinRepetitions  = _options.VariantCallingParameters.RMxNFilterMinRepetitions,
                    RMxNFilterFrequencyLimit  = _options.VariantCallingParameters.RMxNFilterFrequencyLimit
                },
                NoiseModel     = _options.VariantCallingParameters.NoiseModel,
                LocusProcessor = locusProcessor
            };



            var alleleCaller = new AlleleCaller(variantCallerConfig, intervalSet,
                                                CreateVariantCollapser(chrReference.Name, coverageCalculator),
                                                coverageCalculator);

            alleleCaller.AddForcedGtAlleles(forceGtAlleles);

            return(alleleCaller);
        }