List of usage examples for org.apache.commons.cli PosixParser parse
public CommandLine parse(Options options, String[] arguments, Properties properties) throws ParseException
From source file:uni.bielefeld.cmg.sparkhit.util.Parameter.java
public DefaultParam importCommandLine() { /* Assigning Parameter ID to an ascending number */ putParameterID();//www .j a v a2 s.c o m /* Assigning parameter descriptions to each parameter ID */ addParameterInfo(); /* need a Object parser of PosixParser class for the function parse of CommandLine class */ PosixParser parser = new PosixParser(); /* print out help information */ HelpParam help = new HelpParam(parameter, parameterMap); /* check each parameter for assignment */ try { long input_limit = -1; int threads = Runtime.getRuntime().availableProcessors(); /* Set Object cl of CommandLine class for Parameter storage */ CommandLine cl = parser.parse(parameter, arguments, true); if (cl.hasOption(HELP)) { help.printHelp(); System.exit(0); } if (cl.hasOption(HELP2)) { help.printHelp(); System.exit(0); } if (cl.hasOption(VERSION)) { System.exit(0); } /* Checking all parameters */ String value; if ((value = cl.getOptionValue(IDENTITY)) != null) { if (Integer.decode(value) >= 0 || Integer.decode(value) <= 100) { param.readIdentity = Integer.decode(value); if (param.readIdentity >= 94) { param.setKmerOverlap(0); param.setKmerSize(12); } } else { throw new RuntimeException("Parameter " + IDENTITY + " should not be integer of %"); } } if ((value = cl.getOptionValue(KMER_SIZE)) != null) { if (Integer.decode(value) >= 8 || Integer.decode(value) <= 12) { param.kmerSize = Integer.decode(value); param.setKmerSize(param.kmerSize); } else { throw new RuntimeException("Parameter " + KMER_SIZE + " should be set between 8-12"); } } if ((value = cl.getOptionValue(OVERLAP)) != null) { if (Integer.decode(value) >= 0 || Integer.decode(value) <= param.kmerSize) { param.kmerOverlap = Integer.decode(value); } else { throw new RuntimeException( "Parameter " + OVERLAP + " should not be bigger than kmer size or smaller than 0"); } } /** * not available for now */ if ((value = cl.getOptionValue(BUILD_REF)) != null) { param.inputBuildPath = new File(value).getAbsolutePath(); param.inputFaPath = param.inputBuildPath; return param; } if ((value = cl.getOptionValue(THREADS)) != null) { if (Integer.decode(value) <= threads) { param.threads = Integer.decode(value); } else if (Integer.decode(value) == 0) { param.threads = threads; } else if (Integer.decode(value) < 0) { throw new RuntimeException( "Parameter " + THREADS + " come on, CPU number could not be smaller than 1"); } else { throw new RuntimeException("Parameter " + THREADS + " is bigger than the number of your CPUs. Should be smaller than " + threads); } } if ((value = cl.getOptionValue(PARTITIONS)) != null) { param.partitions = Integer.decode(value); } if ((value = cl.getOptionValue(EVALUE)) != null) { param.eValue = Double.parseDouble(value); } if ((value = cl.getOptionValue(GLOBAL)) != null) { param.globalOrLocal = Integer.decode(value); } if ((value = cl.getOptionValue(UNMASK)) != null) { if (Integer.decode(value) == 1 || Integer.decode(value) == 0) { param.maskRepeat = Integer.decode(value); } else { throw new RuntimeException("Parameter " + UNMASK + " should be set as 1 or 0"); } } if ((value = cl.getOptionValue(COVERAGE)) != null) { param.alignLength = Integer.decode(value); } if ((value = cl.getOptionValue(MINLENGTH)) != null) { if (Integer.decode(value) >= 0) { param.minReadSize = Integer.decode(value); } else { throw new RuntimeException("Parameter " + MINLENGTH + " should be larger than 0"); } } if ((value = cl.getOptionValue(ATTEMPTS)) != null) { if (Integer.decode(value) >= 1) { param.maxTrys = Integer.decode(value); } else { throw new RuntimeException("Parameter " + ATTEMPTS + " at least try once"); } } if ((value = cl.getOptionValue(HITS)) != null) { if (Integer.decode(value) >= 0) { param.reportRepeatHits = Integer.decode(value); } else { throw new RuntimeException("Parameter " + HITS + " should be bigger than 0"); } } if ((value = cl.getOptionValue(STRAND)) != null) { if (Integer.decode(value) == 0 || Integer.decode(value) == 1 || Integer.decode(value) == 2) { param.chains = Integer.decode(value); } else { throw new RuntimeException("Parameter " + STRAND + " should be either 0, 1 or 2"); } } if ((value = cl.getOptionValue(INPUT_FASTQ)) != null) { param.inputFqPath = value; } else if ((value = cl.getOptionValue(INPUT_LINE)) != null) { param.inputFqLinePath = value; param.inputFqPath = value; } else { help.printHelp(); System.exit(0); //throw new IOException("Input query file not specified.\nUse -help for list of options"); } /* not applicable for HDFS and S3 */ /* using TextFileBufferInput for such purpose */ // File inputFastq = new File(param.inputFqPath).getAbsoluteFile(); // if (!inputFastq.exists()){ // err.println("Input query file not found."); // return; //i } if ((value = cl.getOptionValue(OUTPUT_FILE)) != null) { param.outputPath = value; } else { info.readMessage("Output file not set of -outfile options"); info.screenDump(); } if ((value = cl.getOptionValue(INPUT_REF)) != null) { param.inputFaPath = new File(value).getAbsolutePath(); } else { info.readMessage("Input reference file had not specified."); info.screenDump(); } File inputFasta = new File(param.inputFaPath).getAbsoluteFile(); if (!inputFasta.exists()) { info.readMessage("Input reference file had not found."); info.screenDump(); } File outfile = new File(param.outputPath).getAbsoluteFile(); if (outfile.exists()) { info.readParagraphedMessages( "Output file : \n\t" + param.outputPath + "\nalready exists, will be overwrite."); info.screenDump(); Runtime.getRuntime().exec("rm -rf " + param.outputPath); } if (param.inputFqPath.endsWith(".gz")) { } param.bestNas = (param.alignLength * param.readIdentity) / 100; param.bestKmers = param.alignLength - (param.alignLength - param.bestNas) * 4 - 3; if (param.bestKmers < (param.kmerSize - 3)) { param.bestKmers = param.kmerSize - 3; } if (param.maskRepeat == 0) { param.validNt = param.validNtNomask; param.invalidNt = param.nxNomask; } } catch (IOException e) { // Don`t catch this, NaNaNaNa, U can`t touch this. info.readMessage("Parameter settings incorrect."); info.screenDump(); e.printStackTrace(); System.exit(0); } catch (RuntimeException e) { info.readMessage("Parameter settings incorrect."); info.screenDump(); e.printStackTrace(); System.exit(0); } catch (ParseException e) { info.readMessage("Parameter settings incorrect."); info.screenDump(); e.printStackTrace(); System.exit(0); } return param; }
From source file:uni.bielefeld.cmg.sparkhit.util.ParameterForChisquareTester.java
public DefaultParam importCommandLine() { /* Assigning Parameter ID to an ascending number */ putParameterID();//from w w w.j a v a 2s.com /* Assigning parameter descriptions to each parameter ID */ addParameterInfo(); /* need a Object parser of PosixParser class for the function parse of CommandLine class */ PosixParser parser = new PosixParser(); /* print out help information */ HelpParam help = new HelpParam(parameter, parameterMap); /* check each parameter for assignment */ try { long input_limit = -1; int threads = Runtime.getRuntime().availableProcessors(); /* Set Object cl of CommandLine class for Parameter storage */ CommandLine cl = parser.parse(parameter, arguments, true); if (cl.hasOption(HELP)) { help.printStatisticerHelp(); System.exit(0); } if (cl.hasOption(HELP2)) { help.printStatisticerHelp(); System.exit(0); } if (cl.hasOption(VERSION)) { System.exit(0); } /* Checking all parameters */ String value; if ((value = cl.getOptionValue(PARTITIONS)) != null) { param.partitions = Integer.decode(value); } if ((value = cl.getOptionValue(COLUMN)) != null) { param.columns = value; param.columnStart = Integer.decode(value.split("-")[0]); param.columnEnd = Integer.decode(value.split("-")[1]); } else { param.columnStart = Integer.decode(param.columns.split("-")[0]); param.columnEnd = Integer.decode(param.columns.split("-")[1]); } if ((value = cl.getOptionValue(COLUMN2)) != null) { param.columns2 = value; param.column2Start = Integer.decode(value.split("-")[0]); param.column2End = Integer.decode(value.split("-")[1]); } else { param.column2Start = Integer.decode(param.columns.split("-")[0]); param.column2End = Integer.decode(param.columns.split("-")[1]); } if (cl.hasOption(CACHE)) { param.cache = true; } if ((value = cl.getOptionValue(INPUT_VCF)) != null) { param.inputFqPath = value; } else if ((value = cl.getOptionValue(INPUT_TAB)) != null) { param.inputFqPath = value; } else { help.printStatisticerHelp(); System.exit(0); // throw new IOException("Input file not specified.\nUse -help for list of options"); } /* not applicable for HDFS and S3 */ /* using TextFileBufferInput for such purpose */ // File inputFastq = new File(param.inputFqPath).getAbsoluteFile(); // if (!inputFastq.exists()){ // err.println("Input query file not found."); // return; //i } if ((value = cl.getOptionValue(OUTPUT_LINE)) != null) { param.outputPath = value; } else { help.printStatisticerHelp(); info.readMessage("Output file not set with -outfile options"); info.screenDump(); System.exit(0); } File outfile = new File(param.outputPath).getAbsoluteFile(); if (outfile.exists()) { info.readParagraphedMessages( "Output file : \n\t" + param.outputPath + "\nalready exists, will be overwrite."); info.screenDump(); Runtime.getRuntime().exec("rm -rf " + param.outputPath); } } catch (IOException e) { // Don`t catch this, NaNaNaNa, U can`t touch this. info.readMessage("Parameter settings incorrect."); info.screenDump(); e.printStackTrace(); System.exit(0); } catch (RuntimeException e) { info.readMessage("Parameter settings incorrect."); info.screenDump(); e.printStackTrace(); System.exit(0); } catch (ParseException e) { info.readMessage("Parameter settings incorrect."); info.screenDump(); e.printStackTrace(); System.exit(0); } return param; }
From source file:uni.bielefeld.cmg.sparkhit.util.ParameterForCluster.java
public DefaultParam importCommandLine() { /* Assigning Parameter ID to an ascending number */ putParameterID();//from ww w .j av a 2s. c o m /* Assigning parameter descriptions to each parameter ID */ addParameterInfo(); /* need a Object parser of PosixParser class for the function parse of CommandLine class */ PosixParser parser = new PosixParser(); /* print out help information */ HelpParam help = new HelpParam(parameter, parameterMap); /* check each parameter for assignment */ try { long input_limit = -1; int threads = Runtime.getRuntime().availableProcessors(); /* Set Object cl of CommandLine class for Parameter storage */ CommandLine cl = parser.parse(parameter, arguments, true); if (cl.hasOption(HELP)) { help.printStatisticerHelp(); System.exit(0); } if (cl.hasOption(HELP2)) { help.printStatisticerHelp(); System.exit(0); } if (cl.hasOption(VERSION)) { System.exit(0); } /* Checking all parameters */ String value; if ((value = cl.getOptionValue(PARTITIONS)) != null) { param.partitions = Integer.decode(value); } if ((value = cl.getOptionValue(WINDOW)) != null) { param.window = Integer.decode(value); } if ((value = cl.getOptionValue(COLUMN)) != null) { param.columns = value; param.columnStart = Integer.decode(value.split("-")[0]); param.columnEnd = Integer.decode(value.split("-")[1]); } else { param.columnStart = Integer.decode(param.columns.split("-")[0]); param.columnEnd = Integer.decode(param.columns.split("-")[1]); } if (cl.hasOption(CACHE)) { param.cache = true; } if ((value = cl.getOptionValue(MODELS)) != null) { param.model = Integer.decode(value); } if ((value = cl.getOptionValue(CLUSTER)) != null) { param.clusterNum = Integer.decode(value); } if ((value = cl.getOptionValue(ITERATION)) != null) { param.iterationNum = Integer.decode(value); } if ((value = cl.getOptionValue(INPUT_VCF)) != null) { param.inputFqPath = value; } else if ((value = cl.getOptionValue(INPUT_TAB)) != null) { param.inputFqPath = value; } else { help.printStatisticerHelp(); System.exit(0); // throw new IOException("Input file not specified.\nUse -help for list of options"); } /* not applicable for HDFS and S3 */ /* using TextFileBufferInput for such purpose */ // File inputFastq = new File(param.inputFqPath).getAbsoluteFile(); // if (!inputFastq.exists()){ // err.println("Input query file not found."); // return; //i } if ((value = cl.getOptionValue(OUTPUT_LINE)) != null) { param.outputPath = value; } else { help.printStatisticerHelp(); info.readMessage("Output file not set with -outfile options"); info.screenDump(); System.exit(0); } File outfile = new File(param.outputPath).getAbsoluteFile(); if (outfile.exists()) { info.readParagraphedMessages( "Output file : \n\t" + param.outputPath + "\nalready exists, will be overwrite."); info.screenDump(); Runtime.getRuntime().exec("rm -rf " + param.outputPath); } } catch (IOException e) { // Don`t catch this, NaNaNaNa, U can`t touch this. info.readMessage("Parameter settings incorrect."); info.screenDump(); e.printStackTrace(); System.exit(0); } catch (RuntimeException e) { info.readMessage("Parameter settings incorrect."); info.screenDump(); e.printStackTrace(); System.exit(0); } catch (ParseException e) { info.readMessage("Parameter settings incorrect."); info.screenDump(); e.printStackTrace(); System.exit(0); } return param; }
From source file:uni.bielefeld.cmg.sparkhit.util.ParameterForConverter.java
public DefaultParam importCommandLine() { /* Assigning Parameter ID to an ascending number */ putParameterID();//from w ww . j av a 2s . co m /* Assigning parameter descriptions to each parameter ID */ addParameterInfo(); /* need a Object parser of PosixParser class for the function parse of CommandLine class */ PosixParser parser = new PosixParser(); /* print out help information */ HelpParam help = new HelpParam(parameter, parameterMap); /* check each parameter for assignment */ try { long input_limit = -1; int threads = Runtime.getRuntime().availableProcessors(); /* Set Object cl of CommandLine class for Parameter storage */ CommandLine cl = parser.parse(parameter, arguments, true); if (cl.hasOption(HELP)) { help.printConverterHelp(); System.exit(0); } if (cl.hasOption(HELP2)) { help.printConverterHelp(); System.exit(0); } if (cl.hasOption(VERSION)) { System.exit(0); } /* Checking all parameters */ String value; if ((value = cl.getOptionValue(PARTITIONS)) != null) { param.partitions = Integer.decode(value); } if ((value = cl.getOptionValue(INPUT_FASTQ)) != null) { param.inputFqPath = value; } else { help.printConverterHelp(); System.exit(0); // throw new IOException("Input file not specified.\nUse -help for list of options"); } if ((value = cl.getOptionValue(OUTPUT_FORMAT)) != null) { param.outputformat = Integer.decode(value); } /* not applicable for HDFS and S3 */ /* using TextFileBufferInput for such purpose */ // File inputFastq = new File(param.inputFqPath).getAbsoluteFile(); // if (!inputFastq.exists()){ // err.println("Input query file not found."); // return; //i } if ((value = cl.getOptionValue(OUTPUT_LINE)) != null) { param.outputPath = value; } else { info.readMessage("Output file not set of -outfile options"); info.screenDump(); } File outfile = new File(param.outputPath).getAbsoluteFile(); if (outfile.exists()) { info.readParagraphedMessages( "Output file : \n\t" + param.outputPath + "\nalready exists, will be overwrite."); info.screenDump(); Runtime.getRuntime().exec("rm -rf " + param.outputPath); } // param.bestNas = (param.alignLength * param.readIdentity) / 100; // param.bestKmers = param.alignLength - (param.alignLength - param.bestNas) * 4 - 3; } catch (IOException e) { // Don`t catch this, NaNaNaNa, U can`t touch this. info.readMessage("Parameter settings incorrect."); info.screenDump(); e.printStackTrace(); System.exit(0); } catch (RuntimeException e) { info.readMessage("Parameter settings incorrect."); info.screenDump(); e.printStackTrace(); System.exit(0); } catch (ParseException e) { info.readMessage("Parameter settings incorrect."); info.screenDump(); e.printStackTrace(); System.exit(0); } return param; }
From source file:uni.bielefeld.cmg.sparkhit.util.ParameterForCorrelationer.java
public DefaultParam importCommandLine() { /* Assigning Parameter ID to an ascending number */ putParameterID();//from w ww.j a v a 2 s . c om /* Assigning parameter descriptions to each parameter ID */ addParameterInfo(); /* need a Object parser of PosixParser class for the function parse of CommandLine class */ PosixParser parser = new PosixParser(); /* print out help information */ HelpParam help = new HelpParam(parameter, parameterMap); /* check each parameter for assignment */ try { long input_limit = -1; int threads = Runtime.getRuntime().availableProcessors(); /* Set Object cl of CommandLine class for Parameter storage */ CommandLine cl = parser.parse(parameter, arguments, true); if (cl.hasOption(HELP)) { help.printStatisticerHelp(); System.exit(0); } if (cl.hasOption(HELP2)) { help.printStatisticerHelp(); System.exit(0); } if (cl.hasOption(VERSION)) { System.exit(0); } /* Checking all parameters */ String value; if ((value = cl.getOptionValue(PARTITIONS)) != null) { param.partitions = Integer.decode(value); } if ((value = cl.getOptionValue(COLUMN)) != null) { param.columns = value; param.columnStart = Integer.decode(value.split("-")[0]); param.columnEnd = Integer.decode(value.split("-")[1]); } else { param.columnStart = Integer.decode(param.columns.split("-")[0]); param.columnEnd = Integer.decode(param.columns.split("-")[1]); } if (cl.hasOption(CACHE)) { param.cache = true; } if ((value = cl.getOptionValue(INPUT_VCF)) != null) { param.inputFqPath = value; } else if ((value = cl.getOptionValue(INPUT_TAB)) != null) { param.inputFqPath = value; } else { help.printStatisticerHelp(); System.exit(0); // throw new IOException("Input file not specified.\nUse -help for list of options"); } /* not applicable for HDFS and S3 */ /* using TextFileBufferInput for such purpose */ // File inputFastq = new File(param.inputFqPath).getAbsoluteFile(); // if (!inputFastq.exists()){ // err.println("Input query file not found."); // return; //i } if ((value = cl.getOptionValue(OUTPUT_LINE)) != null) { param.outputPath = value; } else { help.printStatisticerHelp(); info.readMessage("Output file not set with -outfile options"); info.screenDump(); System.exit(0); } File outfile = new File(param.outputPath).getAbsoluteFile(); if (outfile.exists()) { info.readParagraphedMessages( "Output file : \n\t" + param.outputPath + "\nalready exists, will be overwrite."); info.screenDump(); Runtime.getRuntime().exec("rm -rf " + param.outputPath); } } catch (IOException e) { // Don`t catch this, NaNaNaNa, U can`t touch this. info.readMessage("Parameter settings incorrect."); info.screenDump(); e.printStackTrace(); System.exit(0); } catch (RuntimeException e) { info.readMessage("Parameter settings incorrect."); info.screenDump(); e.printStackTrace(); System.exit(0); } catch (ParseException e) { info.readMessage("Parameter settings incorrect."); info.screenDump(); e.printStackTrace(); System.exit(0); } return param; }
From source file:uni.bielefeld.cmg.sparkhit.util.ParameterForDecompresser.java
public DefaultParam importCommandLine() { /* Assigning Parameter ID to an ascending number */ putParameterID();/*from w w w. j a v a2 s . c o m*/ /* Assigning parameter descriptions to each parameter ID */ addParameterInfo(); /* need a Object parser of PosixParser class for the function parse of CommandLine class */ PosixParser parser = new PosixParser(); /* print out help information */ HelpParam help = new HelpParam(parameter, parameterMap); /* check each parameter for assignment */ try { long input_limit = -1; int threads = Runtime.getRuntime().availableProcessors(); /* Set Object cl of CommandLine class for Parameter storage */ CommandLine cl = parser.parse(parameter, arguments, true); if (cl.hasOption(HELP)) { help.printDecompresserHelp(); System.exit(0); } if (cl.hasOption(HELP2)) { help.printDecompresserHelp(); System.exit(0); } if (cl.hasOption(VERSION)) { System.exit(0); } /* Checking all parameters */ String value; if ((value = cl.getOptionValue(PARTITIONS)) != null) { param.partitions = Integer.decode(value); } if ((value = cl.getOptionValue(INPUT_FASTQ)) != null) { param.inputFqPath = value; } else if ((value = cl.getOptionValue(INPUT_LINE)) != null) { param.inputFqLinePath = value; param.inputFqPath = value; } else { help.printDecompresserHelp(); System.exit(0); // throw new IOException("Input file not specified.\nUse -help for list of options"); } /* not applicable for HDFS and S3 */ /* using TextFileBufferInput for such purpose */ // File inputFastq = new File(param.inputFqPath).getAbsoluteFile(); // if (!inputFastq.exists()){ // err.println("Input query file not found."); // return; //i } if ((value = cl.getOptionValue(OUTPUT_LINE)) != null) { param.outputPath = value; } else { help.printDecompresserHelp(); info.readMessage("Output file not set with -outfile options"); info.screenDump(); System.exit(0); } File outfile = new File(param.outputPath).getAbsoluteFile(); if (outfile.exists()) { info.readParagraphedMessages( "Output file : \n\t" + param.outputPath + "\nalready exists, will be overwrite."); info.screenDump(); Runtime.getRuntime().exec("rm -rf " + param.outputPath); } if (cl.hasOption(FASTQ_FILTER)) { param.filterFastq = true; } if (cl.hasOption(FASTA_CONVERT)) { param.filterToFasta = true; } if (cl.hasOption(LINE_FASTA)) { param.lineToFasta = true; } // param.bestNas = (param.alignLength * param.readIdentity) / 100; // param.bestKmers = param.alignLength - (param.alignLength - param.bestNas) * 4 - 3; } catch (IOException e) { // Don`t catch this, NaNaNaNa, U can`t touch this. info.readMessage("Parameter settings incorrect."); info.screenDump(); e.printStackTrace(); System.exit(0); } catch (RuntimeException e) { info.readMessage("Parameter settings incorrect."); info.screenDump(); e.printStackTrace(); System.exit(0); } catch (ParseException e) { info.readMessage("Parameter settings incorrect."); info.screenDump(); e.printStackTrace(); System.exit(0); } return param; }
From source file:uni.bielefeld.cmg.sparkhit.util.ParameterForParallelizer.java
public DefaultParam importCommandLine() { /* Assigning Parameter ID to an ascending number */ putParameterID();// w w w . j a v a 2 s . c om /* Assigning parameter descriptions to each parameter ID */ addParameterInfo(); /* need a Object parser of PosixParser class for the function parse of CommandLine class */ PosixParser parser = new PosixParser(); /* print out help information */ HelpParam help = new HelpParam(parameter, parameterMap); /* check each parameter for assignment */ try { long input_limit = -1; int threads = Runtime.getRuntime().availableProcessors(); /* Set Object cl of CommandLine class for Parameter storage */ CommandLine cl = parser.parse(parameter, arguments, true); if (cl.hasOption(HELP)) { help.printScriptPiperHelp(); System.exit(0); } if (cl.hasOption(HELP2)) { help.printScriptPiperHelp(); System.exit(0); } if (cl.hasOption(VERSION)) { System.exit(0); } /* Checking all parameters */ String value; if ((value = cl.getOptionValue(PARTITIONS)) != null) { param.partitions = Integer.decode(value); } if ((value = cl.getOptionValue(INPUT_NODES)) != null) { param.inputNodes = Integer.decode(value); } else { help.printScriptPiperHelp(); System.exit(0); // throw new IOException("Input file not specified.\nUse -help for list of options"); } /* not applicable for HDFS and S3 */ /* using TextFileBufferInput for such purpose */ // File inputFastq = new File(param.inputFqPath).getAbsoluteFile(); // if (!inputFastq.exists()){ // err.println("Input query file not found."); // return; //i } if ((value = cl.getOptionValue(OUTPUT_LINE)) != null) { param.outputPath = value; } else { help.printScriptPiperHelp(); info.readMessage("Output file not set with -outfile options"); info.screenDump(); System.exit(0); } File outfile = new File(param.outputPath).getAbsoluteFile(); if (outfile.exists()) { info.readParagraphedMessages( "Output file : \n\t" + param.outputPath + "\nalready exists, will be overwrite."); info.screenDump(); Runtime.getRuntime().exec("rm -rf " + param.outputPath); } if ((value = cl.getOptionValue(INPUT_TOOL)) != null) { param.tool = value.replaceAll("\"", ""); info.readParagraphedMessages("External tool locate at : \n\t" + param.tool + "\nplease ensure that all nodes have such tools in the same path.\nOr it is located in a shared file system.\nOr use a Docker container"); info.screenDump(); } else { help.printScriptPiperHelp(); info.readMessage("External tool path have not been set with parameter -tool"); info.screenDump(); System.exit(0); } if ((value = cl.getOptionValue(TOOL_DEPEND)) != null) { param.toolDepend = value.replaceAll("\"", ""); info.readParagraphedMessages("External tool Dependencies : \n\t" + param.toolDepend + "\n"); info.screenDump(); } else { info.readMessage( "External tool dependencies have not been set, will run with tool build-in Interpreter"); info.screenDump(); } if ((value = cl.getOptionValue(TOOL_PARAM)) != null) { param.toolParam = value.replaceAll("\"", ""); info.readParagraphedMessages("External tool parameter : \n\t" + param.toolParam + "\nThe entire command looks like : \n\t" + param.toolDepend + " " + param.tool + " " + param.toolParam); info.screenDump(); info.readParagraphedMessages("Final external command is : \n\t" + param.toolDepend + " " + param.tool + " " + param.toolParam); info.screenDump(); } else { info.readMessage("External tool parameter have not been set, will run with its default parameter"); info.screenDump(); } // param.bestNas = (param.alignLength * param.readIdentity) / 100; // param.bestKmers = param.alignLength - (param.alignLength - param.bestNas) * 4 - 3; } catch (IOException e) { // Don`t catch this, NaNaNaNa, U can`t touch this. info.readMessage("Parameter settings incorrect."); info.screenDump(); e.printStackTrace(); System.exit(0); } catch (RuntimeException e) { info.readMessage("Parameter settings incorrect."); info.screenDump(); e.printStackTrace(); System.exit(0); } catch (ParseException e) { info.readMessage("Parameter settings incorrect."); info.screenDump(); e.printStackTrace(); System.exit(0); } return param; }
From source file:uni.bielefeld.cmg.sparkhit.util.ParameterForReductioner.java
public DefaultParam importCommandLine() { /* Assigning Parameter ID to an ascending number */ putParameterID();/* ww w. ja v a 2 s. c o m*/ /* Assigning parameter descriptions to each parameter ID */ addParameterInfo(); /* need a Object parser of PosixParser class for the function parse of CommandLine class */ PosixParser parser = new PosixParser(); /* print out help information */ HelpParam help = new HelpParam(parameter, parameterMap); /* check each parameter for assignment */ try { long input_limit = -1; int threads = Runtime.getRuntime().availableProcessors(); /* Set Object cl of CommandLine class for Parameter storage */ CommandLine cl = parser.parse(parameter, arguments, true); if (cl.hasOption(HELP)) { help.printStatisticerHelp(); System.exit(0); } if (cl.hasOption(HELP2)) { help.printStatisticerHelp(); System.exit(0); } if (cl.hasOption(VERSION)) { System.exit(0); } /* Checking all parameters */ String value; if ((value = cl.getOptionValue(PARTITIONS)) != null) { param.partitions = Integer.decode(value); } if ((value = cl.getOptionValue(WINDOW)) != null) { param.window = Integer.decode(value); } if ((value = cl.getOptionValue(COLUMN)) != null) { param.columns = value; param.columnStart = Integer.decode(value.split("-")[0]); param.columnEnd = Integer.decode(value.split("-")[1]); } else { param.columnStart = Integer.decode(param.columns.split("-")[0]); param.columnEnd = Integer.decode(param.columns.split("-")[1]); } if (cl.hasOption(CACHE)) { param.cache = true; } if ((value = cl.getOptionValue(COMPO)) != null) { param.componentNum = Integer.decode(value); } if ((value = cl.getOptionValue(INPUT_VCF)) != null) { param.inputFqPath = value; } else if ((value = cl.getOptionValue(INPUT_TAB)) != null) { param.inputFqPath = value; } else { help.printStatisticerHelp(); System.exit(0); // throw new IOException("Input file not specified.\nUse -help for list of options"); } /* not applicable for HDFS and S3 */ /* using TextFileBufferInput for such purpose */ // File inputFastq = new File(param.inputFqPath).getAbsoluteFile(); // if (!inputFastq.exists()){ // err.println("Input query file not found."); // return; //i } if ((value = cl.getOptionValue(OUTPUT_LINE)) != null) { param.outputPath = value; } else { help.printStatisticerHelp(); info.readMessage("Output file not set with -outfile options"); info.screenDump(); System.exit(0); } File outfile = new File(param.outputPath).getAbsoluteFile(); if (outfile.exists()) { info.readParagraphedMessages( "Output file : \n\t" + param.outputPath + "\nalready exists, will be overwrite."); info.screenDump(); Runtime.getRuntime().exec("rm -rf " + param.outputPath); } } catch (IOException e) { // Don`t catch this, NaNaNaNa, U can`t touch this. info.readMessage("Parameter settings incorrect."); info.screenDump(); e.printStackTrace(); System.exit(0); } catch (RuntimeException e) { info.readMessage("Parameter settings incorrect."); info.screenDump(); e.printStackTrace(); System.exit(0); } catch (ParseException e) { info.readMessage("Parameter settings incorrect."); info.screenDump(); e.printStackTrace(); System.exit(0); } return param; }
From source file:uni.bielefeld.cmg.sparkhit.util.ParameterForRegressioner.java
public DefaultParam importCommandLine() { /* Assigning Parameter ID to an ascending number */ putParameterID();/*w w w. j a v a 2 s .co m*/ /* Assigning parameter descriptions to each parameter ID */ addParameterInfo(); /* need a Object parser of PosixParser class for the function parse of CommandLine class */ PosixParser parser = new PosixParser(); /* print out help information */ HelpParam help = new HelpParam(parameter, parameterMap); /* check each parameter for assignment */ try { long input_limit = -1; int threads = Runtime.getRuntime().availableProcessors(); /* Set Object cl of CommandLine class for Parameter storage */ CommandLine cl = parser.parse(parameter, arguments, true); if (cl.hasOption(HELP)) { help.printStatisticerHelp(); System.exit(0); } if (cl.hasOption(HELP2)) { help.printStatisticerHelp(); System.exit(0); } if (cl.hasOption(VERSION)) { System.exit(0); } /* Checking all parameters */ String value; if ((value = cl.getOptionValue(PARTITIONS)) != null) { param.partitions = Integer.decode(value); } if ((value = cl.getOptionValue(WINDOW)) != null) { param.window = Integer.decode(value); } if ((value = cl.getOptionValue(COLUMN)) != null) { param.columns = value; param.columnStart = Integer.decode(value.split("-")[0]); param.columnEnd = Integer.decode(value.split("-")[1]); } else { param.columnStart = Integer.decode(param.columns.split("-")[0]); param.columnEnd = Integer.decode(param.columns.split("-")[1]); } if (cl.hasOption(CACHE)) { param.cache = true; } if ((value = cl.getOptionValue(MODELS)) != null) { param.model = Integer.decode(value); } if ((value = cl.getOptionValue(ITERATION)) != null) { param.iterationNum = Integer.decode(value); } if ((value = cl.getOptionValue(INPUT_VCF)) != null) { param.inputFqPath = value; } else if ((value = cl.getOptionValue(INPUT_TAB)) != null) { param.inputFqPath = value; } else { help.printStatisticerHelp(); System.exit(0); // throw new IOException("Input file not specified.\nUse -help for list of options"); } if ((value = cl.getOptionValue(INPUT_TRAIN)) != null) { param.inputTrainPath = value; } else { help.printStatisticerHelp(); System.exit(0); } /* not applicable for HDFS and S3 */ /* using TextFileBufferInput for such purpose */ // File inputFastq = new File(param.inputFqPath).getAbsoluteFile(); // if (!inputFastq.exists()){ // err.println("Input query file not found."); // return; //i } if ((value = cl.getOptionValue(OUTPUT_LINE)) != null) { param.outputPath = value; } else { help.printStatisticerHelp(); info.readMessage("Output file not set with -outfile options"); info.screenDump(); System.exit(0); } File outfile = new File(param.outputPath).getAbsoluteFile(); if (outfile.exists()) { info.readParagraphedMessages( "Output file : \n\t" + param.outputPath + "\nalready exists, will be overwrite."); info.screenDump(); Runtime.getRuntime().exec("rm -rf " + param.outputPath); } } catch (IOException e) { // Don`t catch this, NaNaNaNa, U can`t touch this. info.readMessage("Parameter settings incorrect."); info.screenDump(); e.printStackTrace(); System.exit(0); } catch (RuntimeException e) { info.readMessage("Parameter settings incorrect."); info.screenDump(); e.printStackTrace(); System.exit(0); } catch (ParseException e) { info.readMessage("Parameter settings incorrect."); info.screenDump(); e.printStackTrace(); System.exit(0); } return param; }
From source file:uni.bielefeld.cmg.sparkhit.util.ParameterForReporter.java
public DefaultParam importCommandLine() { /* Assigning Parameter ID to an ascending number */ putParameterID();/*ww w . java 2s . c o m*/ /* Assigning parameter descriptions to each parameter ID */ addParameterInfo(); /* need a Object parser of PosixParser class for the function parse of CommandLine class */ PosixParser parser = new PosixParser(); /* print out help information */ HelpParam help = new HelpParam(parameter, parameterMap); /* check each parameter for assignment */ try { long input_limit = -1; int threads = Runtime.getRuntime().availableProcessors(); /* Set Object cl of CommandLine class for Parameter storage */ CommandLine cl = parser.parse(parameter, arguments, true); if (cl.hasOption(HELP)) { help.printReporterHelp(); System.exit(0); } if (cl.hasOption(HELP2)) { help.printReporterHelp(); System.exit(0); } if (cl.hasOption(VERSION)) { System.exit(0); } /* Checking all parameters */ String value; if ((value = cl.getOptionValue(PARTITIONS)) != null) { param.partitions = Integer.decode(value); } if ((value = cl.getOptionValue(INPUT_KEY)) != null) { param.word = value; } if ((value = cl.getOptionValue(INPUT_VALUE)) != null) { param.count = Integer.decode(value); } if ((value = cl.getOptionValue(INPUT_HIT)) != null) { param.inputResultPath = value; } else { help.printReporterHelp(); System.exit(0); // throw new IOException("Input file not specified.\nUse -help for list of options"); } /* not applicable for HDFS and S3 */ /* using TextFileBufferInput for such purpose */ // File inputFastq = new File(param.inputFqPath).getAbsoluteFile(); // if (!inputFastq.exists()){ // err.println("Input query file not found."); // return; //i } if ((value = cl.getOptionValue(OUTPUT_REPORT)) != null) { param.outputPath = value; } else { info.readMessage("Output file not set of -outfile options"); info.screenDump(); } File outfile = new File(param.outputPath).getAbsoluteFile(); if (outfile.exists()) { info.readParagraphedMessages( "Output file : \n\t" + param.outputPath + "\nalready exists, will be overwrite."); info.screenDump(); Runtime.getRuntime().exec("rm -rf " + param.outputPath); } // param.bestNas = (param.alignLength * param.readIdentity) / 100; // param.bestKmers = param.alignLength - (param.alignLength - param.bestNas) * 4 - 3; } catch (IOException e) { // Don`t catch this, NaNaNaNa, U can`t touch this. info.readMessage("Parameter settings incorrect."); info.screenDump(); e.printStackTrace(); System.exit(0); } catch (RuntimeException e) { info.readMessage("Parameter settings incorrect."); info.screenDump(); e.printStackTrace(); System.exit(0); } catch (ParseException e) { info.readMessage("Parameter settings incorrect."); info.screenDump(); e.printStackTrace(); System.exit(0); } return param; }