public override void Write(IEnumerable <CalledAllele> calledAlleles, IRegionMapper mapper = null) { var comparer = new AlleleCompareByLoci(); var sortedVariants = calledAlleles.OrderBy(a => a, comparer).ThenBy(a => a.ReferenceAllele).ThenBy(a => a.AlternateAllele); base.Write(sortedVariants); }
public override void Write(IEnumerable <CalledAllele> calledAlleles, IRegionMapper mapper = null) { var comparer = new AlleleCompareByLociAndAllele(); var sortedVariants = calledAlleles.OrderBy(a => a, comparer); base.Write(sortedVariants, mapper); }
public override void Write(IEnumerable <CalledAllele> calledAlleles, IRegionMapper mapper = null) { //this is a cheap hack, to be removed as soon as I merge another change. var comparer = new AlleleComparer(); var sortedVariants = calledAlleles.OrderBy(a => a, comparer).ThenBy(a => a.Reference).ThenBy(a => a.Alternate); base.Write(sortedVariants); }
public virtual void Write(string msg, IRegionMapper mapper = null) { if (Writer == null) { throw new IOException("Stream already closed"); } FlushBuffer(mapper); Writer.WriteLine(msg); FlushBuffer(mapper); }
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 virtual void Write(IEnumerable <T> BaseCalledAlleles, IRegionMapper mapper = null) { if (Writer == null) { throw new IOException("Stream already closed"); } BufferList.AddRange(BaseCalledAlleles); if (BufferList.Count >= BufferLimit) { FlushBuffer(mapper); } }
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); }
private void PadIfNeeded(StreamWriter writer, int position, IRegionMapper mapper) { // Pad any no calls that are in intervals between this allele and the last allele written. // We should also enter this block on the first allele encountered (to pick up any intervals before coverage starts). if (mapper != null && (_lastVariantPositionWritten == 0 || _lastVariantPositionWritten + 1 < position)) { CalledAllele nocall; var alleleList = new List <CalledAllele>(); // reuse the list while ((nocall = mapper.GetNextEmptyCall(_lastVariantPositionWritten + 1, position - 1)) != null) { WriteNoCall(nocall, alleleList); } } }
public virtual void Write(List <string> msgs, IRegionMapper mapper = null) { if (Writer == null) { throw new IOException("Stream already closed"); } FlushBuffer(mapper); foreach (var msg in msgs) { Writer.WriteLine(msg); } FlushBuffer(mapper); }
public void FlushBuffer(IRegionMapper mapper = null) { if (AllowMultipleVcfLinesPerLoci) { //we dont crush foreach (var variant in BufferList) { WriteSingleAllele(Writer, variant, mapper); } } else //the VCF spec that makes parsers cry { GroupsAllelesThenWrite(Writer, BufferList, mapper); } BufferList.Clear(); }
public override void WriteRemaining(IRegionMapper mapper = null) { // Pad any nocalls in intervals after coverage ends. // Unlike WriteSingleAllele which is called internally during buffer flushing this is called directly // by external components, like the somatic variant caller. if (mapper != null) { FlushBuffer(mapper); // flush real alleles that are hanging out CalledAllele nocall; var alleleList = new List <CalledAllele>(); // reuse list while ((nocall = mapper.GetNextEmptyCall(_lastVariantPositionWritten + 1, null)) != null) { WriteNoCall(nocall, alleleList); } _lastVariantPositionWritten = 0; // reset in case writer is reused for the next chromosome } }
protected override void WriteSingleAllele(StreamWriter writer, CalledAllele variant, IRegionMapper mapper = null) { // Pad intervals if necessary PadIfNeeded(writer, variant.ReferencePosition, mapper); WriteListOfColocatedAlleles(writer, new List <CalledAllele> { variant }); }
protected abstract void WriteSingleAllele(StreamWriter writer, T variant, IRegionMapper mapper = null);
public VcfFileWriter CreateVcfWriter(string outputVcfPath, VcfWriterInputContext context, IRegionMapper mapper = null) { return(new VcfFileWriter(outputVcfPath, new VcfWriterConfig { DepthFilterThreshold = _options.OutputgVCFFiles ? _options.MinimumDepth : (_options.LowDepthFilter > _options.MinimumDepth)? _options.LowDepthFilter : (int?)null, IndelRepeatFilterThreshold = _options.IndelRepeatFilter > 0 ? _options.IndelRepeatFilter : (int?)null, VariantQualityFilterThreshold = _options.FilteredVariantQScore, GenotypeQualityFilterThreshold = _options.LowGenotypeQualityFilter.HasValue && _options.LowGenotypeQualityFilter > _options.MinimumVariantQScore ? _options.LowGenotypeQualityFilter : null, StrandBiasFilterThreshold = _options.StrandBiasAcceptanceCriteria < 1 ? _options.StrandBiasAcceptanceCriteria : (float?)null, FrequencyFilterThreshold = (_options.FilteredVariantFrequency > _options.MinimumFrequency) ? _options.FilteredVariantFrequency : (float?)null, MinFrequencyThreshold = _options.MinimumFrequency, ShouldOutputNoCallFraction = _options.ReportNoCalls, ShouldOutputStrandBiasAndNoiseLevel = _options.OutputNoiseLevelAndStrandBias(), ShouldFilterOnlyOneStrandCoverage = _options.FilterOutVariantsPresentOnlyOneStrand, EstimatedBaseCallQuality = GetEstimatedBaseCallQuality(), ShouldOutputRcCounts = _options.ReportRcCounts, AllowMultipleVcfLinesPerLoci = _options.AllowMultipleVcfLinesPerLoci, PloidyModel = _options.PloidyModel, RMxNFilterMaxLengthRepeat = _options.RMxNFilterMaxLengthRepeat, RMxNFilterMinRepetitions = _options.RMxNFilterMinRepetitions, RMxNFilterFrequencyLimit = _options.RMxNFilterFrequencyLimit, NoiseModel = _options.NoiseModel }, context)); }
protected abstract void GroupsAllelesThenWrite(StreamWriter writer, List <T> variants, IRegionMapper mapper = null);
protected override void GroupsAllelesThenWrite(StreamWriter writer, List <CalledAllele> variants, IRegionMapper mapper = null) { // variant list is already sorted properly, group as we go. var variantsAtSamePosition = new List <CalledAllele>(); foreach (var variant in variants) { if (!variantsAtSamePosition.Any() || ((variant.ReferencePosition == variantsAtSamePosition[0].ReferencePosition) && (variant.Chromosome == variantsAtSamePosition[0].Chromosome))) { variantsAtSamePosition.Add(variant); } else { // flush PadIfNeeded(writer, variantsAtSamePosition[0].ReferencePosition, mapper); // Pad intervals if necessary WriteListOfColocatedAlleles(Writer, variantsAtSamePosition); variantsAtSamePosition.Clear(); variantsAtSamePosition.Add(variant); } } // final flush if (variantsAtSamePosition.Any()) { PadIfNeeded(writer, variantsAtSamePosition[0].ReferencePosition, mapper); // Pad intervals if necessary WriteListOfColocatedAlleles(Writer, variantsAtSamePosition); } }
public VcfFileWriter CreateVcfWriter(string outputVcfPath, VcfWriterInputContext context, IRegionMapper mapper = null) { return(new VcfFileWriter(outputVcfPath, new VcfWriterConfig(_options.VariantCallingParameters, _options.VcfWritingParameters, _options.BamFilterParameters, null, _options.DebugMode, _options.OutputBiasFiles, _options.ForcedAllelesFileNames.Count > 0), context)); }
public RegionProcessor(IDataReader dataReader, IGraphParser graphParser, IRegionMapper regionMapper) { this._dataReader = dataReader; this._graphParser = graphParser; this._regionMapper = regionMapper; }
public virtual void WriteRemaining(IRegionMapper mapper = null) { // do nothing by default }
public StorefrontCountriesContentsResolver(IStorefrontContext storefrontContext, IRegionMapper mapper) { this.storefrontContext = storefrontContext; this.mapper = mapper; }