public void IdealNoiseModelRoundTrips()
        {
            var idealNoiseModel = (
                NoiseModel.TryGetByName("ideal", out var model)
                ? model
                : throw new Exception("Failed to get noise model by name.")
                );

            idealNoiseModel.AssertSerializationRoundTrips();
        }
        public void IdealStabilizerNoiseModelRoundTrips()
        {
            var idealStabilizerModel = (
                NoiseModel.TryGetByName("ideal_stabilizer", out var model)
                ? model
                : throw new Exception("Could not get noise model by name.")
                );

            idealStabilizerModel.AssertSerializationRoundTrips();
        }
Beispiel #3
0
        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));
            }
        }