public static IGenotypeCalculator CreateGenotypeCalculator(PloidyModel ploidyModel, float minimumFrequencyFilter, int minEmitDepth, DiploidThresholdingParameters snvParameters, DiploidThresholdingParameters indelParameters, AdaptiveGenotypingParameters adaptiveGenotypingParameters, int minGQscore, int maxGQscore, float targetLODVariantFrequency, float minimumEmitFrequency = 0, string refName = null, bool?isMale = null) { var ploidyModelForThisChr = GetPloidyForThisChr(ploidyModel, isMale, refName); switch (ploidyModelForThisChr) { case PloidyModel.Haploid: return(new HaploidGenotyper(minEmitDepth, minGQscore, maxGQscore, snvParameters.MinorVF, snvParameters.MajorVF)); case PloidyModel.DiploidByAdaptiveGT: return(new DiploidAdaptiveGenotyper(minEmitDepth, minGQscore, maxGQscore, adaptiveGenotypingParameters)); case PloidyModel.DiploidByThresholding: return(new DiploidThresholdingGenotyper(snvParameters, snvParameters, minEmitDepth, minGQscore, maxGQscore)); case PloidyModel.Somatic: default: return(new SomaticGenotyper(minimumFrequencyFilter, minEmitDepth, minGQscore, maxGQscore, minimumEmitFrequency, targetLODVariantFrequency)); } }
public static IGenotypeCalculator CreateGenotypeCalculator(PloidyModel ploidyModel, float minCalledVariantFreq, int minCalledVariantDepth, DiploidThresholdingParameters parameters, int minGQscore, int maxGQscore) { return((ploidyModel == PloidyModel.Somatic) ? (IGenotypeCalculator) new SomaticGenotypeCalculator(minCalledVariantFreq, minCalledVariantDepth, minGQscore, maxGQscore) : new DiploidGenotypeCalculator(parameters, minCalledVariantDepth, minGQscore, maxGQscore)); }
public static IGenotypeCalculator CreateGenotypeCalculator(PloidyModel ploidyModel, float minimumFrequencyFilter, int minEmitDepth, DiploidThresholdingParameters snvParameters, DiploidThresholdingParameters indelParameters, int minGQscore, int maxGQscore, float targetLODVariantFrequency, float minimumEmitFrequency = 0, string refName = null, bool?isMale = null) { if (ploidyModel == PloidyModel.Somatic || refName == "chrM") { return(new SomaticGenotypeCalculator(minimumFrequencyFilter, minEmitDepth, minGQscore, maxGQscore, minimumEmitFrequency, targetLODVariantFrequency)); } if (isMale == null) { return(new DiploidGenotypeCalculator(snvParameters, indelParameters, minEmitDepth, minGQscore, maxGQscore)); } if (isMale.Value && (refName == "chrY" || refName == "chrX")) { return(new HaploidGenotyeCalculator(minEmitDepth, minGQscore, maxGQscore, snvParameters.MinorVF, snvParameters.MajorVF)); } if (!isMale.Value && refName == "chrY") { Common.IO.Utility.Logger.WriteWarningToLog("chrY exists in Female samples"); return(new HaploidGenotyeCalculator(minEmitDepth, minGQscore, maxGQscore, snvParameters.MinorVF, snvParameters.MajorVF)); } return(new DiploidGenotypeCalculator(snvParameters, snvParameters, minEmitDepth, minGQscore, maxGQscore)); }
public static PloidyModel GetPloidyForThisChr(PloidyModel samplePloidy, bool?isMale, string refName) { //if the sample is somatic, we always call it as somatic. //if the sample is Mitochondrial, we call as heteroplasmic (somatic in our implementaion) if ((samplePloidy == PloidyModel.Somatic) || (refName == "chrM") || (refName == "M")) { return(PloidyModel.Somatic); } //if we say its haploid, or its a sex chr, call as haploid if (samplePloidy == PloidyModel.Haploid) { return(PloidyModel.Haploid); } //if we did not set a gender, treat all chr equal if (isMale == null) { return(samplePloidy); } if (isMale.Value && (refName == "chrY" || refName == "chrX" || refName == "Y" || refName == "X")) { return(PloidyModel.Haploid); } if (!isMale.Value && (refName == "chrY" || refName == "Y")) { Common.IO.Utility.Logger.WriteWarningToLog("chrY exists in Female samples"); return(PloidyModel.Haploid); } //The only remaining option is that this is meant to be a diploid sample, // and we are processing a chr that is meant to be diploid. We can call it directly, as requested.. return(samplePloidy); }
public ApplicationOptions UpdateOptions(string[] arguments) { string lastArgumentField = string.Empty; try { int argumentIndex = 0; while (argumentIndex < arguments.Length) { if (string.IsNullOrEmpty(arguments[argumentIndex])) { argumentIndex++; continue; } string value = null; if (argumentIndex < arguments.Length - 1) { value = arguments[argumentIndex + 1].Trim(); } lastArgumentField = arguments[argumentIndex].ToLower(); switch (lastArgumentField) { case "-v": case "-ver": PrintVersionToConsole(); return(null); //case "-a": depracated case "-minvq": case "-minvariantqscore": MinimumVariantQScore = int.Parse(value); break; //case "-b": depracated case "-minbq": case "-minbasecallquality": MinimumBaseCallQuality = int.Parse(value); break; case "-b": case "-bam": BAMPaths = value.Split(_delimiter); break; case "-c": case "-mindp": case "-mindepth": case "-mincoverage": //last release this is available. trying to be nice for backwards compatibility with Isas. MinimumDepth = int.Parse(value); break; case "-d": case "-debug": DebugMode = bool.Parse(value); break; case "-minvf": //used to be "f" case "-minimumvariantfrequency": case "-minimumfrequency": MinimumFrequency = float.Parse(value); break; case "-vqfilter": //used to be "F" case "-variantqualityfilter": FilteredVariantQScore = int.Parse(value); break; case "-vffilter": //used to be "v" case "-minvariantfrequencyfilter": FilteredVariantFrequency = float.Parse(value); break; case "-gqfilter": case "-genotypequalityfilter": LowGenotypeQualityFilter = int.Parse(value); break; case "-repeatfilter": IndelRepeatFilter = int.Parse(value); break; case "-mindpfilter": case "-mindepthfilter": LowDepthFilter = int.Parse(value); break; case "-ssfilter": //used to be "fo" case "-enablesinglestrandfilter": FilterOutVariantsPresentOnlyOneStrand = bool.Parse(value); break; case "-g": case "-genomepaths": GenomePaths = value.Split(_delimiter); break; case "-nl": case "-noiselevelforqmodel": AppliedNoiseLevel = int.Parse(value); break; case "-gvcf": OutputgVCFFiles = bool.Parse(value); break; case "-callmnvs": //case "-phasesnps": obsolete CallMNVs = bool.Parse(value); break; case "-maxmnvlength": //case "-MaxPhaseSNPLength": obsolete //case "-MaxPhasedSNPLength": obsolete MaxSizeMNV = int.Parse(value); break; case "-maxgapbetweenmnv": case "-maxrefgapinmnv": //case "-MaxGapPhasedSNP":: obsolete MaxGapBetweenMNV = int.Parse(value); break; case "-i": case "-intervalpaths": IntervalPaths = value.Split(_delimiter); break; case "-minmq": //used to be "m" case "-minmapquality": MinimumMapQuality = int.Parse(value); break; case "-ploidy": if (value.ToLower().Contains("somatic")) { PloidyModel = PloidyModel.Somatic; } else if (value.ToLower().Contains("diploid")) { PloidyModel = PloidyModel.Diploid; } else { throw new ArgumentException(string.Format("Unknown ploidy model '{0}'", value)); } break; case "-diploidgenotypeparameters": var parameters = ParseStringToFloat(value.Split(_delimiter)); if (parameters.Length != 3) { throw new ArgumentException(string.Format("DiploidGenotypeParamteers argument requires exactly three values.")); } DiploidThresholdingParameters = new DiploidThresholdingParameters(parameters); break; case "-crushvcf": bool crushedallelestyle = bool.Parse(value); AllowMultipleVcfLinesPerLoci = !(crushedallelestyle); break; case "-sbmodel": if (value.ToLower().Contains("poisson")) { StrandBiasModel = StrandBiasModel.Poisson; } else if (value.ToLower().Contains("extended")) { StrandBiasModel = StrandBiasModel.Extended; } else { throw new ArgumentException(string.Format("Unknown strand bias model '{0}'", value)); } break; case "-outputsbfiles": OutputBiasFiles = bool.Parse(value); break; case "-pp": case "-onlyuseproperpairs": OnlyUseProperPairs = bool.Parse(value); break; case "-maxvq": case "-maxvariantqscore": MaximumVariantQScore = int.Parse(value); break; case "-maxgq": case "-maxgenotypeqscore": MaximumGenotypeQScore = int.Parse(value); break; case "-mingq": case "-minqenotypeqscore": MinimumGenotypeQScore = int.Parse(value); break; case "-sbfilter": case "-maxacceptablestrandbiasfilter": StrandBiasAcceptanceCriteria = float.Parse(value); break; case "-stitchpairedreads": throw new ArgumentException("StitchPairedReads option is obsolete."); case "-t": MaxNumThreads = int.Parse(value); break; case "-threadbychr": ThreadByChr = bool.Parse(value); break; case "-reportnocalls": ReportNoCalls = bool.Parse(value); break; case "-xcstitcher": throw new ArgumentException("XCStitcher option is obsolete."); case "-collapse": Collapse = bool.Parse(value); break; case "-collapsefreqthreshold": CollapseFreqThreshold = float.Parse(value); break; case "-collapsefreqratiothreshold": CollapseFreqRatioThreshold = float.Parse(value); break; case "-priorspath": PriorsPath = value; break; case "-trimmnvpriors": TrimMnvPriors = bool.Parse(value); break; case "-nifydisagreements": throw new ArgumentException("NifyDisagreements option is no longer valid: stitching within Pisces is obsolete."); case "-coverageMethod": if (value.ToLower() == "approximate") { CoverageMethod = CoverageMethod.Approximate; } else if (value.ToLower() == "exact") { CoverageMethod = CoverageMethod.Exact; } else { throw new ArgumentException(string.Format("Unknown coverage method '{0}'", value)); } break; case "-reportrccounts": ReportRcCounts = bool.Parse(value); break; case "-mono": MonoPath = value; break; case "-rmxnfilter": bool turnOn = true; bool worked = (bool.TryParse(value, out turnOn)); if (worked) { if (turnOn) { // stick with defaults } else { //turn off RMxNFilterMaxLengthRepeat = null; RMxNFilterMinRepetitions = null; } break; } //else, it wasnt a bool... var rmxnThresholds = ParseStringToFloat(value.Split(_delimiter)); if ((rmxnThresholds.Length < 2) || (rmxnThresholds.Length > 3)) { throw new ArgumentException(string.Format("RMxNFilter argument requires two or three values.")); } RMxNFilterMaxLengthRepeat = (int)rmxnThresholds[0]; RMxNFilterMinRepetitions = (int)rmxnThresholds[1]; if (rmxnThresholds.Length > 2) { RMxNFilterFrequencyLimit = (float)rmxnThresholds[2]; } break; case "-noisemodel": NoiseModel = value.ToLower() == "window" ? NoiseModel.Window : NoiseModel.Flat; break; case "-skipnonintervalalignments": throw new Exception(string.Format("'SkipNonIntervalAlignments' option has been depracated until further notice. ", arguments[argumentIndex])); //(it has bugs, speed issues, and no plan to fix it) default: if (!base.UpdateOptions(lastArgumentField, value)) { throw new Exception(string.Format("Unknown argument '{0}'", arguments[argumentIndex])); } break; } argumentIndex += 2; } CommandLineArguments = arguments; return(this); } catch (Exception ex) { throw new Exception(string.Format("Unable to parse argument {0}: {1}", lastArgumentField, ex.Message)); } }