Beispiel #1
0
        public override ParsingResult <CommonOptions> Parse(SuccessfulResultCollection parseInput)
        {
            var    bAlleleSites     = parseInput.Get(BAlleleSites);
            bool   isDbSnpVcf       = parseInput.Get(IsDbSnpVcf);
            var    ploidyBed        = parseInput.Get(PloidyBed);
            var    output           = parseInput.Get(Output);
            var    wholeGenomeFasta = parseInput.Get(WholeGenomeFasta);
            var    kmerFasta        = parseInput.Get(KmerFasta);
            var    filterBed        = parseInput.Get(FilterFile);
            var    sampleName       = parseInput.Get(SampleName);
            var    customParameters = parseInput.Get(CustomParameters);
            string startCheckpoint  = parseInput.Get(StartCheckpoint);
            string stopCheckpoint   = parseInput.Get(StopCheckpoint);

            return(ParsingResult <CommonOptions> .SuccesfulResult(
                       new CommonOptions(
                           bAlleleSites,
                           isDbSnpVcf,
                           ploidyBed,
                           output,
                           wholeGenomeFasta,
                           kmerFasta,
                           filterBed,
                           sampleName,
                           customParameters,
                           startCheckpoint,
                           stopCheckpoint)));
        }
Beispiel #2
0
        public override ParsingResult <IModeRunner> Parse(SuccessfulResultCollection parseInput)
        {
            CommonOptions commonOptions = parseInput.Get(CommonOptionsParser);
            var           bam           = parseInput.Get(Bam);

            return(ParsingResult <IModeRunner> .SuccesfulResult(new GermlineWgsRunner(commonOptions, bam)));
        }
        public override ParsingResult <BaseOptions> Parse(SuccessfulResultCollection parseInput)
        {
            var helpResult    = parseInput.Get(Help);
            var versionResult = parseInput.Get(Version);

            return(ParsingResult <BaseOptions> .SuccesfulResult(new BaseOptions(helpResult, versionResult)));
        }
        public override ParsingResult <IModeRunner> Parse(SuccessfulResultCollection parseInput)
        {
            CommonOptions            commonOptions            = parseInput.Get(CommonOptionsParser);
            SomaticEnrichmentOptions somaticEnrichmentOptions = parseInput.Get(SomaticEnrichmentOptionsParser);

            return(ParsingResult <IModeRunner> .SuccesfulResult(new SomaticEnrichmentRunner(commonOptions, somaticEnrichmentOptions)));
        }
        public override ParsingResult <SomaticEnrichmentOptions> Parse(SuccessfulResultCollection parseInput)
        {
            var bam            = parseInput.Get(Bam);
            var manifest       = parseInput.Get(Manifest);
            var controlBams    = parseInput.Get(ControlBams);
            var controlBinned  = parseInput.Get(ControlBinned);
            var controlBinSize = parseInput.Get(ControlBinSize);
            var controlPloidy  = parseInput.Get(ControlPloidyBed);

            var controlBinnedBools = new List <bool> {
                controlBinned != null, controlBinSize != null, controlPloidy != null
            };

            if (controlBams.Any() && controlBinnedBools.Any(controlBinnedBool => controlBinnedBool))
            {
                return(ParsingResult <SomaticEnrichmentOptions> .FailedResult($"Error: option {ControlBams.Info.Name} cannot be combined with any of {ControlBinned.Info.Name}, {ControlBinSize.Info.Name}, {ControlPloidyBed.Info.Name} "));
            }

            if (controlBinned != null && controlBinSize == null)
            {
                return(ParsingResult <SomaticEnrichmentOptions> .FailedResult($"Error: {ControlBinSize.Info.Name} is required when using the {ControlBinned.Info.Name} option"));
            }

            return(ParsingResult <SomaticEnrichmentOptions> .SuccesfulResult(
                       new SomaticEnrichmentOptions(
                           bam,
                           manifest,
                           controlBams,
                           controlBinned,
                           controlBinSize.HasValue ? (int)controlBinSize.Value : 0,
                           controlPloidy)));
        }
        public override ParsingResult <IModeRunner> Parse(SuccessfulResultCollection parseInput)
        {
            CommonOptions      commonOptions      = parseInput.Get(CommonOptionsParser);
            TumorNormalOptions tumorNormalOptions = parseInput.Get(TumorNormalOptionsParser);

            return(ParsingResult <IModeRunner> .SuccesfulResult(new TumorNormalWgsRunner(commonOptions, tumorNormalOptions)));
        }
Beispiel #7
0
        public ParsingResult <IModeLauncher> Parse(string[] args, TextWriter standardWriter, TextWriter errorWriter)
        {
            if (args.Empty() || !_modeParsers.ContainsKey(args[0]))
            {
                return(GetMissingModeResult(args, standardWriter, errorWriter));
            }
            var mode    = _modeParsers[args[0]];
            var options = new OptionCollection <IModeLauncher> {
                BaseOptionsParser, mode
            };
            var result = options.Parse(args.Skip(1));
            ParsingResult <IModeLauncher> failedResult;

            if (!result.RemainingArgs.Any() && HandleBaseOptions(result.Get(BaseOptionsParser).Result, standardWriter, mode))
            {
                return(ParsingResult <IModeLauncher> .SuccesfulResult(new NullModeLauncher()));
            }

            if (!result.Validate(out failedResult))
            {
                errorWriter.WriteLine(failedResult.ErrorMessage);
                errorWriter.WriteLine();
                ShowHelp(errorWriter, mode);
                return(failedResult);
            }
            var runner = result.Get(mode).Result;

            return(ParsingResult <IModeLauncher> .SuccesfulResult(new ModeLauncher(runner, args, GetVersion(), mode.Name)));
        }
        public override ParsingResult <TumorNormalOptions> Parse(SuccessfulResultCollection parseInput)
        {
            var tumorBam   = parseInput.Get(TumorBam);
            var somaticVcf = parseInput.Get(SomaticVcf);

            return(ParsingResult <TumorNormalOptions> .SuccesfulResult(
                       new TumorNormalOptions(tumorBam, somaticVcf)));
        }
Beispiel #9
0
        public override ParsingResult <IModeRunner> Parse(SuccessfulResultCollection parseInput)
        {
            CommonOptions      commonOptions      = parseInput.Get(CommonOptionsParser);
            TumorNormalOptions tumorNormalOptions = parseInput.Get(TumorNormalOptionsParser);
            var normalBam = parseInput.Get(NormalBam);
            var manifest  = parseInput.Get(Manifest);

            return(ParsingResult <IModeRunner> .SuccesfulResult(new TumorNormalEnrichmentRunner(commonOptions, tumorNormalOptions, normalBam, manifest)));
        }
        public override ParsingResult <string> Parse(SuccessfulResultCollection parseInput)
        {
            string value = parseInput.Get(this);

            if (value == null)
            {
                return(ParsingResult <string> .FailedResult($"Error: {Name} is a required option"));
            }
            return(ParsingResult <string> .SuccesfulResult(value));
        }
Beispiel #11
0
        public override ParsingResult <IDirectoryLocation> Parse(string value)
        {
            IDirectoryLocation location = value == null ? null : new DirectoryLocation(value);

            if (location == null || location.Exists)
            {
                return(ParsingResult <IDirectoryLocation> .SuccesfulResult(location));
            }
            return(ParsingResult <IDirectoryLocation> .FailedResult($"Error: {location} does not exist"));
        }
Beispiel #12
0
        private static IParsingResult GetParseResult(OptionInfo <string> optionInfo, OptionData optionData)
        {
            ParsingResult <string> result = ParsingResult <string> .SuccesfulResult(optionData.Data.FirstOrDefault());

            if (optionData.Data.Count > 1)
            {
                result = ParsingResult <string> .FailedResult($"Error: {optionInfo.Name} can only be specified once");
            }
            return(optionInfo.Parse(new SuccessfulResultCollection(optionInfo, result)));
        }
Beispiel #13
0
 public virtual ParsingResult <T> Parse(string value)
 {
     if (value == null)
     {
         return(ParsingResult <T> .SuccesfulResult(default(T)));
     }
     try
     {
         T parsedValue = (T)Convert.ChangeType(value, typeof(T));
         return(ParsingResult <T> .SuccesfulResult(parsedValue));
     }
     catch (Exception)
     {
         return(ParsingResult <T> .FailedResult($"Error parsing {Info.Name} option: failed to convert {value} to {typeof(T)}"));
     }
 }
Beispiel #14
0
        public override ParsingResult <List <T> > Parse(SuccessfulResultCollection input)
        {
            var values  = input.Get(Info);
            var results = new List <T>();

            foreach (var value in values)
            {
                var result = _valueOption.Parse(value);
                if (!result.Success)
                {
                    return(ParsingResult <List <T> > .FailedResult(result.ErrorMessage));
                }
                results.Add(result.Result);
            }
            return(ParsingResult <List <T> > .SuccesfulResult(results));
        }
Beispiel #15
0
        public override ParsingResult <Dictionary <string, string> > Parse(SuccessfulResultCollection parseInput)
        {
            List <string> inputs = parseInput.Get(_option);
            var           result = new Dictionary <string, string>();

            foreach (var input in inputs)
            {
                string[] split = input.Split(_separator).Select(untrimmed => untrimmed.Trim()).ToArray();
                if (split.Length != 2)
                {
                    return(ParsingResult <Dictionary <string, string> > .FailedResult($"Error: expected format is {{KEY}}{_separator}{{value}}. Input was {input}"));
                }
                string key   = split[0];
                string value = split[1];
                if (result.ContainsKey(key))
                {
                    return(ParsingResult <Dictionary <string, string> > .FailedResult($"Error parsing {_option.Info.Name}: found duplicate key {key}"));
                }
                result.Add(key, value);
            }
            return(ParsingResult <Dictionary <string, string> > .SuccesfulResult(result));
        }
Beispiel #16
0
        private ParsingResult <IModeLauncher> GetMissingModeResult(IEnumerable <string> args, TextWriter standardWriter, TextWriter errorWriter)
        {
            string error             = "Error: no mode specified";
            var    baseOptionsResult = BaseOptionsParser.Parse(args);

            if (baseOptionsResult.Success)
            {
                if (HandleBaseOptions(baseOptionsResult.Result, standardWriter))
                {
                    return(ParsingResult <IModeLauncher> .SuccesfulResult(new NullModeLauncher()));
                }
            }
            else
            {
                error = baseOptionsResult.ErrorMessage;
            }

            errorWriter.WriteLine(error);
            errorWriter.WriteLine();
            ShowHelp(errorWriter);
            return(ParsingResult <IModeLauncher> .FailedResult(error));
        }
Beispiel #17
0
 public override ParsingResult <T> Parse(SuccessfulResultCollection parseInput)
 {
     return(ParsingResult <T> .SuccesfulResult(parseInput.Get(this)));
 }
Beispiel #18
0
 private static IParsingResult GetParseResult(OptionInfo <List <string> > multiOptionInfo, OptionData optionData)
 {
     return(multiOptionInfo.Parse(new SuccessfulResultCollection(multiOptionInfo, ParsingResult <List <string> > .SuccesfulResult(optionData.Data))));
 }
Beispiel #19
0
 public ParsingResult <bool> Parse(string value)
 {
     return(ParsingResult <bool> .SuccesfulResult(value != null));
 }
Beispiel #20
0
 public override ParsingResult <string> Parse(string value)
 {
     return(ParsingResult <string> .SuccesfulResult(value));
 }