Example #1
0
        public virtual ISomaticVariantCaller CreateSomaticVariantCaller(
            ChrReference chrReference, string bamFilePath, IVcfWriter <CalledAllele> vcfWriter,
            IStrandBiasFileWriter biasFileWriter = null, string intervalFilePath = null, List <string> chrToProcess = null)
        {
            var alignmentSource = CreateAlignmentSource(chrReference, bamFilePath, chrToProcess);
            var variantFinder   = CreateVariantFinder();
            var intervalSet     = GetIntervalSet(chrReference.Name, bamFilePath);
            var alleleCaller    = CreateVariantCaller(chrReference, intervalSet);
            var stateManager    = CreateStateManager(intervalSet, alignmentSource.SourceIsStitched);
            var intervalPadder  = CreateRegionPadder(chrReference, intervalSet, _options.OutputgVCFFiles);

            return(new SomaticVariantCaller(alignmentSource, variantFinder, alleleCaller,
                                            vcfWriter, stateManager, chrReference, intervalPadder, biasFileWriter, intervalSet));
        }
Example #2
0
 public SomaticVariantCaller(IAlignmentSource alignmentSource, ICandidateVariantFinder variantFinder, IAlleleCaller alleleCaller,
                             IVcfWriter <CalledAllele> vcfWriter, IStateManager stateManager, ChrReference chrReference, IRegionMapper regionMapper,
                             IStrandBiasFileWriter biasFileWriter, ChrIntervalSet intervalSet = null)
 {
     _alignmentSource = alignmentSource;
     _variantFinder   = variantFinder;
     _alleleCaller    = alleleCaller;
     _vcfWriter       = vcfWriter;
     _stateManager    = stateManager;
     _chrReference    = chrReference;
     _regionMapper    = regionMapper;
     _biasFileWriter  = biasFileWriter;
     _intervalSet     = intervalSet;
 }
 public SomaticVariantCaller(IAlignmentSource alignmentSource, ICandidateVariantFinder variantFinder, IAlleleCaller alleleCaller,
                             IVcfWriter <CalledAllele> vcfWriter, IStateManager stateManager, ChrReference chrReference, IRegionMapper regionMapper,
                             IStrandBiasFileWriter biasFileWriter, ChrIntervalSet intervalSet = null, HashSet <Tuple <string, int, string, string> > forcedGTAlleles = null)
 {
     _alignmentSource = alignmentSource;
     _variantFinder   = variantFinder;
     _alleleCaller    = alleleCaller;
     _vcfWriter       = vcfWriter;
     _stateManager    = stateManager;
     _chrReference    = chrReference;
     _regionMapper    = regionMapper;
     _biasFileWriter  = biasFileWriter;
     _intervalSet     = intervalSet;
     _forcedGtAlleles = forcedGTAlleles;
     _unProcessedForcedAllelesByPos = CreateForcedAllelePos(_forcedGtAlleles);
 }
Example #4
0
        public SomaticVariantCaller(IAlignmentSource alignmentSource, ICandidateVariantFinder variantFinder, IAlleleCaller alleleCaller,
                                    IVcfWriter vcfWriter, IStateManager stateManager, ChrReference chrReference, IRegionPadder regionMapper, IStrandBiasFileWriter biasFileWriter)
        {
            _alignmentSource = alignmentSource;
            _variantFinder   = variantFinder;
            _alleleCaller    = alleleCaller;
            _vcfWriter       = vcfWriter;
            _stateManager    = stateManager;
            _chrReference    = chrReference;
            _regionMapper    = regionMapper;
            _biasFileWriter  = biasFileWriter;

            if (_alignmentSource.ChromosomeFilter != _chrReference.Name)
            {
                throw new ArgumentException(string.Format("Chromosome filter in alignment source '{0}' does not match to current chromosome '{1}'", _alignmentSource.ChromosomeFilter, _chrReference.Name));
            }
        }
Example #5
0
        public virtual ISmallVariantCaller CreateSomaticVariantCaller(
            ChrReference chrReference, string bamFilePath, IVcfWriter <CalledAllele> vcfWriter,
            IStrandBiasFileWriter strandBiasFileWriter = null, IAmpliconBiasFileWriter ampliconBiasFileWriter = null, string intervalFilePath = null, List <string> chrToProcess = null)
        {
            var alignmentSource = CreateAlignmentSource(chrReference, bamFilePath, _options.UseStitchedXDInfo, chrToProcess);
            var variantFinder   = CreateVariantFinder();
            var intervalSet     = GetIntervalSet(chrReference.Name, bamFilePath);
            var forceGtAlleles  = SelectForcedAllele(_forcedAllelesByChrom, chrReference.Name, intervalSet);

            var alleleCaller   = CreateVariantCaller(chrReference, intervalSet, alignmentSource, forceGtAlleles);
            var stateManager   = CreateStateManager(intervalSet, alignmentSource.SourceIsStitched, alignmentSource.SourceIsCollapsed);
            var intervalPadder = CreateRegionPadder(chrReference, intervalSet, _options.VcfWritingParameters.OutputGvcfFile);


            return(new SmallVariantCaller(alignmentSource, variantFinder, alleleCaller,
                                          vcfWriter, stateManager, chrReference, intervalPadder, strandBiasFileWriter, ampliconBiasFileWriter, intervalSet, forceGtAlleles));
        }
Example #6
0
 public override ISomaticVariantCaller CreateSomaticVariantCaller(ChrReference chrReference, string bamFilePath, IVcfWriter vcfWriter, IStrandBiasFileWriter biasFileWriter = null, string intervalFilePath = null)
 {
     return(MockSomaticVariantCaller != null ? MockSomaticVariantCaller.Object : base.CreateSomaticVariantCaller(chrReference, bamFilePath, vcfWriter, biasFileWriter, intervalFilePath));
 }
        public static ISomaticVariantCaller CreateMockVariantCaller(VcfFileWriter vcfWriter, ApplicationOptions options, ChrReference chrRef, MockAlignmentExtractor mockAlignmentExtractor, IStrandBiasFileWriter biasFileWriter = null, string intervalFilePath = null)
        {
            var config = new AlignmentSourceConfig
            {
                MinimumMapQuality  = options.MinimumMapQuality,
                OnlyUseProperPairs = options.OnlyUseProperPairs,
            };


            //var mateFinder = options.StitchReads ? new AlignmentMateFinder() : null;
            AlignmentMateFinder mateFinder = null;
            var alignmentSource            = new AlignmentSource(mockAlignmentExtractor, mateFinder, config);
            var variantFinder      = new CandidateVariantFinder(options.MinimumBaseCallQuality, options.MaxSizeMNV, options.MaxGapBetweenMNV, options.CallMNVs);
            var coverageCalculator = new CoverageCalculator();

            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.MinimumDepth,
                MinFrequency               = options.MinimumFrequency,
                EstimatedBaseCallQuality   = options.AppliedNoiseLevel == -1 ? options.MinimumBaseCallQuality : options.AppliedNoiseLevel,
                StrandBiasModel            = options.StrandBiasModel,
                StrandBiasFilterThreshold  = options.StrandBiasAcceptanceCriteria,
                FilterSingleStrandVariants = options.FilterOutVariantsPresentOnlyOneStrand,
                ChrReference               = chrRef
            },
                                                coverageCalculator: coverageCalculator,
                                                variantCollapser: options.Collapse ? new VariantCollapser(null, coverageCalculator) : null);

            var stateManager = new RegionStateManager(
                expectStitchedReads: mockAlignmentExtractor.SourceIsStitched,
                trackOpenEnded: options.Collapse, trackReadSummaries: options.CoverageMethod == CoverageMethod.Approximate);

            //statmanager is an allele source
            Assert.Equal(0, stateManager.GetAlleleCount(1, AlleleType.A, DirectionType.Forward));


            return(new SomaticVariantCaller(
                       alignmentSource,
                       variantFinder,
                       alleleCaller,
                       vcfWriter,
                       stateManager,
                       chrRef,
                       null,
                       biasFileWriter));
        }
Example #8
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));
        }
 public override ISmallVariantCaller CreateSomaticVariantCaller(ChrReference chrReference, string bamFilePath,
                                                                IVcfWriter <CalledAllele> vcfWriter, IStrandBiasFileWriter strandBiasFileWriter = null, IAmpliconBiasFileWriter ampliconBiasFileWriter = null,
                                                                string intervalFilePath = null, List <string> chrToProcess = null)
 {
     return(MockSomaticVariantCaller != null ? MockSomaticVariantCaller.Object : base.CreateSomaticVariantCaller(chrReference, bamFilePath, vcfWriter,
                                                                                                                 strandBiasFileWriter, ampliconBiasFileWriter, intervalFilePath, chrToProcess));
 }