示例#1
0
        public static PiscesOptionsParser GetOriginalPiscesOptions(List <string> vcfHeaderLines, string configFileDir)
        {
            var vcfConfigureFile             = Path.Combine(configFileDir, "PiscesOptions.used.json");
            PiscesOptionsParser piscesParser = new PiscesOptionsParser();

            if (File.Exists(vcfConfigureFile))
            {
                piscesParser = GetOptionsFromConfigFile(vcfConfigureFile);
            }
            else
            {
                Logger.WriteToLog($"Pisces option file {vcfConfigureFile} does not exist. Reading defaults from the VCF header");
                piscesParser = GetPiscesOptionsFromVcfHeader(vcfHeaderLines);
            }

            return(piscesParser);
        }
示例#2
0
        private static PiscesOptionsParser GetOptionsFromConfigFile(string vcfConfigureFile)
        {
            var piscesParser = new PiscesOptionsParser();

            try
            {
                piscesParser.Options = JsonUtil.Deserialize <PiscesApplicationOptions>(vcfConfigureFile);
                Logger.WriteToLog($"Pisces option file {vcfConfigureFile} loaded");
                return(piscesParser);
            }
            catch (Exception ex)
            {
                Logger.WriteExceptionToLog(ex);
                Logger.WriteToLog($"Pisces option file {vcfConfigureFile} failed to load. Continuing without it ");
                piscesParser.ParsingResult.Exception = ex;
                piscesParser.ParsingResult.UpdateExitCode(ExitCodeType.InvalidFileFormat);
                return(piscesParser);
            }
        }
示例#3
0
        public static PiscesOptionsParser GetPiscesOptionsFromVcfHeader(List <string> VcfHeaderLines)
        {
            var piscesParser = new PiscesOptionsParser();
            var startString  = "##Pisces_cmdline=";

            if (VcfHeaderLines.Count != 0 && VcfHeaderLines.Exists(x => x.StartsWith(startString)))
            {
                try
                {
                    var piscesCmd = VcfHeaderLines.FindLast(x => x.StartsWith(startString)).Replace(startString, "").Replace("\"", "").ToLower();
                    piscesCmd = piscesCmd.Replace("-v ", "-vffilter ");    //"v" used to be vf filter, now it returns the version number. Be kind and help the user with this one. If th ey pass "-v" that will shut down all the parsing and output the version.
                    piscesCmd = piscesCmd.Replace("-bamfolder ", "-bam "); //being kind to another obsolete argument

                    //parse the original pisces options, but do not validate.
                    //We dont need to validate everything, just to get the vcf processing options.
                    piscesParser.ParseArgs(piscesCmd.Split(), false);

                    ((PiscesApplicationOptions)piscesParser.Options).SetDerivedParameters();

                    return(piscesParser);
                }
                catch (Exception ex)
                {
                    Logger.WriteToLog("Unable to parse the original Pisces commandline from the input vcf.");
                    Logger.WriteExceptionToLog(ex);

                    piscesParser.ParsingResult.Exception = ex;
                    piscesParser.ParsingResult.UpdateExitCode(ExitCodeType.BadFormat);
                }
            }

            piscesParser.ParsingResult.Exception = new Exception("Pisces command line was not found in the input vcf");
            piscesParser.ParsingResult.UpdateExitCode(ExitCodeType.BadFormat);



            return(piscesParser);
        }