Search in sources :

Example 21 with ArgsEngine

use of cz1.util.ArgsEngine in project polyGembler by c-zhou.

the class RenjinLOD method setParameters.

@Override
public void setParameters(String[] args) {
    // TODO Auto-generated method stub
    if (args.length == 0) {
        printUsage();
        throw new IllegalArgumentException("\n\nPlease use the above arguments/options.\n\n");
    }
    if (myArgsEngine == null) {
        myArgsEngine = new ArgsEngine();
        myArgsEngine.add("-i", "--ds-file", true);
        myArgsEngine.add("-o", "--prefix", true);
        myArgsEngine.add("-n", "--haplotype", true);
        myArgsEngine.add("-g", "--txt-in", true);
        myArgsEngine.parse(args);
    }
    if (myArgsEngine.getBoolean("-i")) {
        ds_in = myArgsEngine.getString("-i").split(",");
    } else {
        printUsage();
        throw new IllegalArgumentException("Please specify your input zip file.");
    }
    if (myArgsEngine.getBoolean("-o")) {
        r_out = myArgsEngine.getString("-o");
    } else {
        printUsage();
        throw new IllegalArgumentException("Please specify your output file prefix.");
    }
    if (myArgsEngine.getBoolean("-n")) {
        n_hap = Integer.parseInt(myArgsEngine.getString("-n"));
    } else {
        printUsage();
        throw new IllegalArgumentException("Please specify your input zip file.");
    }
    if (myArgsEngine.getBoolean("-g")) {
        txt_in = myArgsEngine.getString("-g");
    } else {
        printUsage();
        throw new IllegalArgumentException("Please specify your output file prefix.");
    }
}
Also used : ArgsEngine(cz1.util.ArgsEngine)

Example 22 with ArgsEngine

use of cz1.util.ArgsEngine in project polyGembler by c-zhou.

the class Redundas method setParameters.

@Override
public void setParameters(String[] args) {
    // TODO Auto-generated method stub
    if (myArgsEngine == null) {
        myArgsEngine = new ArgsEngine();
        myArgsEngine.add("-q", "--query", true);
        myArgsEngine.add("-b", "--blast", true);
        myArgsEngine.add("-i", "--min-identity", true);
        myArgsEngine.add("-m", "--min-match", true);
        myArgsEngine.add("-x", "--max-overhang", true);
        myArgsEngine.add("-f", "--min-fraction", true);
        myArgsEngine.add("-o", "--out-prefix", true);
        myArgsEngine.parse(args);
    }
    if (myArgsEngine.getBoolean("-q")) {
        this.query_file = myArgsEngine.getString("-q");
    } else {
        printUsage();
        throw new IllegalArgumentException("Please specify the query file.");
    }
    if (myArgsEngine.getBoolean("-b")) {
        this.blast_out = myArgsEngine.getString("-b");
    } else {
        printUsage();
        throw new IllegalArgumentException("Please specify the BLAST file.");
    }
    if (myArgsEngine.getBoolean("-i")) {
        this.min_ident = Double.parseDouble(myArgsEngine.getString("-i"));
    }
    if (myArgsEngine.getBoolean("-m")) {
        this.min_match = Integer.parseInt(myArgsEngine.getString("-m"));
    }
    if (myArgsEngine.getBoolean("-x")) {
        this.max_overhang = Integer.parseInt(myArgsEngine.getString("-x"));
    }
    if (myArgsEngine.getBoolean("-f")) {
        this.min_frac = Double.parseDouble(myArgsEngine.getString("-f"));
    }
    if (myArgsEngine.getBoolean("-o")) {
        this.out_prefix = myArgsEngine.getString("-o");
        if (new File(out_prefix + ".fa").exists() || new File(out_prefix + "_redundas.fa").exists()) {
            throw new RuntimeException("Output files exist. Please specify a different name.");
        }
    } else {
        printUsage();
        throw new IllegalArgumentException("Please specify the prefix of output files.");
    }
}
Also used : File(java.io.File) ArgsEngine(cz1.util.ArgsEngine)

Example 23 with ArgsEngine

use of cz1.util.ArgsEngine in project polyGembler by c-zhou.

the class SuperScaffoldConstructor method setParameters.

@Override
public void setParameters(String[] args) {
    // TODO Auto-generated method stub
    if (args.length == 0) {
        printUsage();
        throw new IllegalArgumentException("\n\nPlease use the above arguments/options.\n\n");
    }
    if (myArgsEngine == null) {
        myArgsEngine = new ArgsEngine();
        myArgsEngine.add("-i", "--rf", true);
        myArgsEngine.add("-o", "--prefix", true);
        myArgsEngine.add("-rlib", "--R-external-libs", true);
        myArgsEngine.parse(args);
    }
    if (myArgsEngine.getBoolean("-i")) {
        rf_file = myArgsEngine.getString("-i");
    } else {
        printUsage();
        throw new IllegalArgumentException("Please specify your recombinatio frequency file.");
    }
    if (myArgsEngine.getBoolean("-o")) {
        out_prefix = myArgsEngine.getString("-o");
    } else {
        printUsage();
        throw new IllegalArgumentException("Please specify your output file prefix.");
    }
    if (myArgsEngine.getBoolean("-rlib")) {
        RLibPath = myArgsEngine.getString("-rlib");
    }
}
Also used : ArgsEngine(cz1.util.ArgsEngine)

Example 24 with ArgsEngine

use of cz1.util.ArgsEngine in project polyGembler by c-zhou.

the class VCFResampling method setParameters.

@Override
public void setParameters(String[] args) {
    if (args.length == 0) {
        printUsage();
        throw new IllegalArgumentException("\n\nPlease use the above arguments/options.\n\n");
    }
    if (myArgsEngine == null) {
        myArgsEngine = new ArgsEngine();
        myArgsEngine.add("-i", "--data-in", true);
        myArgsEngine.add("-p", "--ploidy", true);
        myArgsEngine.add("-w", "--window-size", true);
        myArgsEngine.add("-0", "--min-snp-number", true);
        myArgsEngine.add("-f", "--founder-haps", true);
        myArgsEngine.add("-o", "--data-out", true);
        myArgsEngine.parse(args);
    }
    if (myArgsEngine.getBoolean("-i")) {
        data_in = myArgsEngine.getString("-i");
    } else {
        printUsage();
        throw new IllegalArgumentException("Please specify your VCF file.");
    }
    if (myArgsEngine.getBoolean("-o")) {
        data_out = myArgsEngine.getString("-o");
    } else {
        data_out = data_in.replaceAll(".zip$", ".resampled.zip");
    }
    if (myArgsEngine.getBoolean("-p")) {
        ploidy = Integer.parseInt(myArgsEngine.getString("-p"));
        Constants._ploidy_H = ploidy;
    }
    if (myArgsEngine.getBoolean("-w")) {
        String w_str = myArgsEngine.getString("-w");
        Pattern p = Pattern.compile("(^\\d+)(.*?$)");
        Matcher m = p.matcher(w_str);
        m.find();
        int w_val = Integer.parseInt(m.group(1));
        String w_unit = m.group(2);
        int multiplier = 1;
        if (!w_unit.equals(""))
            switch(w_unit) {
                case "K":
                case "k":
                case "Kb":
                case "kb":
                    multiplier = 1000;
                    break;
                case "M":
                case "m":
                case "Mb":
                case "mb":
                    multiplier = 1000000;
                    break;
                case "G":
                case "g":
                case "Gb":
                case "gb":
                    multiplier = 1000000000;
                    break;
                default:
                    throw new RuntimeException("unknown multiplier!!! \n    " + "Accepted suffix: K, k, Kb, kb, M, m, Mb, mb, G, g, Gb, gb.\n");
            }
        window_size = w_val * multiplier;
        System.out.println(window_size);
    }
    if (myArgsEngine.getBoolean("-f")) {
        founder_haps = myArgsEngine.getString("-f").split(":");
    } else {
        printUsage();
        throw new IllegalArgumentException("Please specify the parent samples.");
    }
    if (myArgsEngine.getBoolean("-0")) {
        min_snp = Integer.parseInt(myArgsEngine.getString("-0"));
    }
}
Also used : Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) ArgsEngine(cz1.util.ArgsEngine)

Example 25 with ArgsEngine

use of cz1.util.ArgsEngine in project polyGembler by c-zhou.

the class VCFtools method setParameters.

@Override
public void setParameters(String[] args) {
    if (args.length == 0) {
        printUsage();
        throw new IllegalArgumentException("\n\nPlease use the above arguments/options.\n\n");
    }
    if (myArgsEngine == null) {
        myArgsEngine = new ArgsEngine();
        myArgsEngine.add("-i", "--vcf", true);
        myArgsEngine.add("-l", "--min-depth", true);
        myArgsEngine.add("-p", "--ploidy", true);
        myArgsEngine.add("-u", "--max-depth", true);
        myArgsEngine.add("-q", "--min-qual", true);
        myArgsEngine.add("-f", "--min-maf", true);
        myArgsEngine.add("-m", "--max-missing", true);
        myArgsEngine.add("-o", "--prefix", true);
        myArgsEngine.parse(args);
    }
    if (myArgsEngine.getBoolean("-i")) {
        vcf_in = myArgsEngine.getString("-i");
    } else {
        printUsage();
        throw new IllegalArgumentException("Please specify your VCF file.");
    }
    if (myArgsEngine.getBoolean("-o")) {
        vcf_out = myArgsEngine.getString("-o");
    } else {
        printUsage();
        throw new IllegalArgumentException("Please specify the output file.");
    }
    if (myArgsEngine.getBoolean("-p")) {
        ploidy = Integer.parseInt(myArgsEngine.getString("-p"));
    }
    if (myArgsEngine.getBoolean("-l")) {
        min_depth = Integer.parseInt(myArgsEngine.getString("-l"));
    }
    if (myArgsEngine.getBoolean("-u")) {
        max_depth = Integer.parseInt(myArgsEngine.getString("-u"));
    }
    if (myArgsEngine.getBoolean("-q")) {
        min_qual = Integer.parseInt(myArgsEngine.getString("-q"));
    }
    if (myArgsEngine.getBoolean("-f")) {
        min_maf = Double.parseDouble(myArgsEngine.getString("-f"));
    }
    if (myArgsEngine.getBoolean("-m")) {
        max_missing = Double.parseDouble(myArgsEngine.getString("-m"));
    }
}
Also used : ArgsEngine(cz1.util.ArgsEngine)

Aggregations

ArgsEngine (cz1.util.ArgsEngine)43 File (java.io.File)10 MathIllegalArgumentException (org.apache.commons.math3.exception.MathIllegalArgumentException)5 BufferedReader (java.io.BufferedReader)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 GBS (cz1.simulation.model.GBS)1 Population (cz1.simulation.model.Population)1 SAMRecord (htsjdk.samtools.SAMRecord)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1