Search in sources :

Example 36 with ArgsEngine

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

the class SamFileExtract 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", "--input-file", true);
        myArgsEngine.add("-b", "--bed-dir", true);
        myArgsEngine.add("-o", "--output-file", true);
        myArgsEngine.parse(args);
    }
    if (myArgsEngine.getBoolean("-i")) {
        bam_in = myArgsEngine.getString("-i");
    } else {
        printUsage();
        throw new IllegalArgumentException("Please specify the location of your FASTQ files.");
    }
    if (myArgsEngine.getBoolean("-b")) {
        bed_in = myArgsEngine.getString("-b");
    } else {
        printUsage();
        throw new IllegalArgumentException("Please specify a barcode key file.");
    }
    if (myArgsEngine.getBoolean("-o")) {
        bam_out = myArgsEngine.getString("-o");
    } else {
        myLogger.warn("No enzyme specified.  Using enzyme listed in key file.");
    }
}
Also used : ArgsEngine(cz1.util.ArgsEngine)

Example 37 with ArgsEngine

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

the class Anchor method setParameters.

@Override
public void setParameters(String[] args) {
    // TODO Auto-generated method stub
    if (myArgsEngine == null) {
        myArgsEngine = new ArgsEngine();
        myArgsEngine.add("-s", "--subject", true);
        myArgsEngine.add("-q", "--query", true);
        myArgsEngine.add("-a", "--align", true);
        myArgsEngine.add("-g", "--graph", true);
        myArgsEngine.add("-k", "--kmer-size", true);
        myArgsEngine.add("-i", "--min-identity", true);
        myArgsEngine.add("-f", "--min-fraction", true);
        myArgsEngine.add("-di", "--diff-identity", true);
        myArgsEngine.add("-df", "--diff-fraction", true);
        myArgsEngine.add("-t", "--threads", true);
        myArgsEngine.add("-d", "--debug", false);
        myArgsEngine.add("-dd", "--debug-debug", false);
        myArgsEngine.add("-o", "--out-prefix", true);
        myArgsEngine.parse(args);
    }
    if (myArgsEngine.getBoolean("-s")) {
        this.subject_file = myArgsEngine.getString("-s");
    } else {
        printUsage();
        throw new IllegalArgumentException("Please specify the subject/reference file.");
    }
    if (myArgsEngine.getBoolean("-q")) {
        this.query_file = myArgsEngine.getString("-q");
        if (!this.query_file.endsWith(".fasta"))
            throw new RuntimeException("Query file need to be in FASTA format!!!");
    } else {
        printUsage();
        throw new IllegalArgumentException("Please specify the query file.");
    }
    if (myArgsEngine.getBoolean("-a")) {
        this.align_file = myArgsEngine.getString("-a");
    } else {
        printUsage();
        throw new IllegalArgumentException("Please specify the alignment file of query sequences to subject sequences.");
    }
    if (myArgsEngine.getBoolean("-g")) {
        this.asm_graph = myArgsEngine.getString("-g");
    }
    if (myArgsEngine.getBoolean("-k")) {
        this.kmer_size = Integer.parseInt(myArgsEngine.getString("-k"));
    }
    if (myArgsEngine.getBoolean("-o")) {
        this.out_prefix = myArgsEngine.getString("-o");
        if (new File(out_prefix + ".fa").exists() || new File(out_prefix + ".map").exists() || new File(out_prefix + "_unplaced.map").exists()) {
            throw new RuntimeException("Output files exist. Please specify a different name.");
        }
    } else {
        printUsage();
        throw new IllegalArgumentException("Please specify the prefix of output files.");
    }
    if (myArgsEngine.getBoolean("-i")) {
        this.min_ident = 100 * Math.min(1.0, Double.parseDouble(myArgsEngine.getString("-i")));
    }
    if (myArgsEngine.getBoolean("-f")) {
        this.min_frac = Double.parseDouble(myArgsEngine.getString("-f"));
    }
    if (myArgsEngine.getBoolean("-di")) {
        this.diff_ident = Double.parseDouble(myArgsEngine.getString("-di"));
    }
    if (myArgsEngine.getBoolean("-t")) {
        int t = Integer.parseInt(myArgsEngine.getString("-t"));
        if (t < this.num_threads)
            this.num_threads = t;
        Constants.omp_threads = this.num_threads;
        myLogger.info("OMP_THREADS = " + this.num_threads);
    }
    if (myArgsEngine.getBoolean("-df")) {
        this.diff_frac = Double.parseDouble(myArgsEngine.getString("-df"));
    }
    if (myArgsEngine.getBoolean("-d")) {
        this.debug = true;
    }
    if (myArgsEngine.getBoolean("-dd")) {
        this.debug = true;
        this.ddebug = true;
    }
}
Also used : File(java.io.File) ArgsEngine(cz1.util.ArgsEngine)

Example 38 with ArgsEngine

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

the class Consensus 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");
    }
    switch(args[0].toUpperCase()) {
        case "COUNT":
            this.task_list = Task.count;
            break;
        case "PARSE":
            this.task_list = Task.parse;
            break;
        case "ALL":
            this.task_list = Task.all;
            break;
        default:
            printUsage();
            throw new IllegalArgumentException("\n\nPlease use the above arguments/options.\n\n");
    }
    String[] args2 = new String[args.length - 1];
    System.arraycopy(args, 1, args2, 0, args2.length);
    if (myArgsEngine == null) {
        myArgsEngine = new ArgsEngine();
        myArgsEngine.add("-q", "--query", true);
        myArgsEngine.add("-m", "--map", true);
        myArgsEngine.add("-as", "--block-size", true);
        myArgsEngine.add("-bs", "--batch-size", true);
        myArgsEngine.add("-t", "--threads", true);
        myArgsEngine.add("-l", "--min-size", true);
        myArgsEngine.add("-o", "--out", true);
        myArgsEngine.addWildOptions(s_lib, true);
        myArgsEngine.addWildOptions(pe_lib, true);
        myArgsEngine.addWildOptions(mp_lib, true);
        myArgsEngine.addWildOptions(ins_lib, true);
        myArgsEngine.addWildOptions(w_lib, true);
        myArgsEngine.parse(args2);
    }
    switch(this.task_list) {
        case count:
            if (myArgsEngine.getBoolean("-m")) {
                this.map_file = myArgsEngine.getString("-m");
            } else {
                printUsage();
                throw new IllegalArgumentException("Please specify the map file.");
            }
            if (myArgsEngine.getBoolean("-t")) {
                this.THREADS = Integer.parseInt(myArgsEngine.getString("-t"));
            }
            if (myArgsEngine.getBoolean("-o")) {
                this.out_prefix = myArgsEngine.getString("-o");
            } else {
                printUsage();
                throw new IllegalArgumentException("Please specify the output file.");
            }
            this.parseDataLibrary(args2);
            break;
        case parse:
            if (myArgsEngine.getBoolean("-q")) {
                this.sequence_file = myArgsEngine.getString("-q");
            } else {
                printUsage();
                throw new IllegalArgumentException("Please specify the contig file.");
            }
            if (myArgsEngine.getBoolean("-m")) {
                this.map_file = myArgsEngine.getString("-m");
            } else {
                printUsage();
                throw new IllegalArgumentException("Please specify the map file.");
            }
            if (myArgsEngine.getBoolean("-l")) {
                this.min_size = Integer.parseInt(myArgsEngine.getString("-l"));
            }
            if (myArgsEngine.getBoolean("-o")) {
                this.out_prefix = myArgsEngine.getString("-o");
            } else {
                printUsage();
                throw new IllegalArgumentException("Please specify the output file.");
            }
            break;
        case all:
            if (myArgsEngine.getBoolean("-q")) {
                this.sequence_file = myArgsEngine.getString("-q");
            } else {
                printUsage();
                throw new IllegalArgumentException("Please specify the contig file.");
            }
            if (myArgsEngine.getBoolean("-m")) {
                this.map_file = myArgsEngine.getString("-m");
            } else {
                printUsage();
                throw new IllegalArgumentException("Please specify the map file.");
            }
            if (myArgsEngine.getBoolean("-t")) {
                this.THREADS = Integer.parseInt(myArgsEngine.getString("-t"));
            }
            if (myArgsEngine.getBoolean("-l")) {
                this.min_size = Integer.parseInt(myArgsEngine.getString("-l"));
            }
            if (myArgsEngine.getBoolean("-o")) {
                this.out_prefix = myArgsEngine.getString("-o");
            } else {
                printUsage();
                throw new IllegalArgumentException("Please specify the output file.");
            }
            this.parseDataLibrary(args2);
            break;
        default:
            throw new RuntimeException("!!!");
    }
}
Also used : ArgsEngine(cz1.util.ArgsEngine)

Example 39 with ArgsEngine

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

the class HetCorr 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");
    }
    switch(args[0].toUpperCase()) {
        case "HETCORR":
            this.task_list = Task.hetcorr;
            break;
        case "SORTQ":
            this.task_list = Task.sortq;
            break;
        case "SORTC":
            this.task_list = Task.sortc;
            break;
        case "CORRS":
            this.task_list = Task.corrs;
            break;
        case "CORRP":
            this.task_list = Task.corrp;
            break;
        case "ALL":
            this.task_list = Task.all;
            break;
        default:
            printUsage();
            throw new IllegalArgumentException("\n\nPlease use the above arguments/options.\n\n");
    }
    String[] args2 = new String[args.length - 1];
    System.arraycopy(args, 1, args2, 0, args2.length);
    if (myArgsEngine == null) {
        myArgsEngine = new ArgsEngine();
        myArgsEngine.add("-r", "--region", true);
        myArgsEngine.add("-bs", "--batch-size", true);
        myArgsEngine.add("-t", "--threads", true);
        myArgsEngine.add("-o", "--out-prefix", true);
        myArgsEngine.addWildOptions(se_lib, true);
        myArgsEngine.addWildOptions(pe1_lib, true);
        myArgsEngine.addWildOptions(pe2_lib, true);
        myArgsEngine.addWildOptions(bam_lib, true);
        myArgsEngine.addWildOptions(corr_lib, true);
        myArgsEngine.parse(args2);
    }
    switch(this.task_list) {
        case hetcorr:
            if (myArgsEngine.getBoolean("-r")) {
                this.target_region = myArgsEngine.getString("-r");
            }
            if (myArgsEngine.getBoolean("-t")) {
                this.THREADS = Integer.parseInt(myArgsEngine.getString("-t"));
            }
            if (myArgsEngine.getBoolean("-o")) {
                this.out_prefix = myArgsEngine.getString("-o");
            } else {
                printUsage();
                throw new IllegalArgumentException("Please specify the output file.");
            }
            this.parseDataLibrary(args2);
            break;
        case sortq:
            if (myArgsEngine.getBoolean("-bs")) {
                this.batch_size = Integer.parseInt(myArgsEngine.getString("-bs"));
            }
            if (myArgsEngine.getBoolean("-t")) {
                this.THREADS = Integer.parseInt(myArgsEngine.getString("-t"));
            }
            if (myArgsEngine.getBoolean("-o")) {
                this.out_prefix = myArgsEngine.getString("-o");
            } else {
                printUsage();
                throw new IllegalArgumentException("Please specify the output file.");
            }
            this.parseDataLibrary(args2);
            break;
        case sortc:
            if (myArgsEngine.getBoolean("-bs")) {
                this.batch_size = Integer.parseInt(myArgsEngine.getString("-bs"));
            }
            if (myArgsEngine.getBoolean("-t")) {
                this.THREADS = Integer.parseInt(myArgsEngine.getString("-t"));
            }
            if (myArgsEngine.getBoolean("-o")) {
                this.out_prefix = myArgsEngine.getString("-o");
            } else {
                printUsage();
                throw new IllegalArgumentException("Please specify the output file.");
            }
            this.parseDataLibrary(args2);
            break;
        case corrs:
            if (myArgsEngine.getBoolean("-t")) {
                this.THREADS = Integer.parseInt(myArgsEngine.getString("-t"));
            }
            if (myArgsEngine.getBoolean("-o")) {
                this.out_prefix = myArgsEngine.getString("-o");
            } else {
                printUsage();
                throw new IllegalArgumentException("Please specify the output file.");
            }
            this.parseDataLibrary(args2);
            break;
        case corrp:
            if (myArgsEngine.getBoolean("-t")) {
                this.THREADS = Integer.parseInt(myArgsEngine.getString("-t"));
            }
            if (myArgsEngine.getBoolean("-o")) {
                this.out_prefix = myArgsEngine.getString("-o");
            } else {
                printUsage();
                throw new IllegalArgumentException("Please specify the output file.");
            }
            this.parseDataLibrary(args2);
            break;
        case all:
            if (myArgsEngine.getBoolean("-bs")) {
                this.batch_size = Integer.parseInt(myArgsEngine.getString("-bs"));
            }
            if (myArgsEngine.getBoolean("-t")) {
                this.THREADS = Integer.parseInt(myArgsEngine.getString("-t"));
            }
            if (myArgsEngine.getBoolean("-o")) {
                this.out_prefix = myArgsEngine.getString("-o");
            } else {
                printUsage();
                throw new IllegalArgumentException("Please specify the output file.");
            }
            this.parseDataLibrary(args2);
            break;
        default:
            throw new RuntimeException("!!!");
    }
}
Also used : ArgsEngine(cz1.util.ArgsEngine)

Example 40 with ArgsEngine

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

the class Anchor0 method setParameters.

@Override
public void setParameters(String[] args) {
    // TODO Auto-generated method stub
    if (myArgsEngine == null) {
        myArgsEngine = new ArgsEngine();
        myArgsEngine.add("-s", "--subject", true);
        myArgsEngine.add("-q", "--query", true);
        myArgsEngine.add("-b", "--blast", true);
        myArgsEngine.add("-i", "--min-identity", true);
        myArgsEngine.add("-f", "--min-fraction", true);
        myArgsEngine.add("-di", "--diff-identity", true);
        myArgsEngine.add("-df", "--diff-fraction", true);
        myArgsEngine.add("-o", "--out-prefix", true);
        myArgsEngine.parse(args);
    }
    if (myArgsEngine.getBoolean("-s")) {
        this.subject_file = myArgsEngine.getString("-s");
    } else {
        printUsage();
        throw new IllegalArgumentException("Please specify the subject/reference file.");
    }
    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("-o")) {
        this.out_prefix = myArgsEngine.getString("-o");
        if (new File(out_prefix + ".fa").exists() || new File(out_prefix + ".map").exists() || new File(out_prefix + "_unplaced.map").exists()) {
            throw new RuntimeException("Output files exist. Please specify a different name.");
        }
    } else {
        printUsage();
        throw new IllegalArgumentException("Please specify the prefix of output files.");
    }
    if (myArgsEngine.getBoolean("-i")) {
        this.min_ident = 100 * Math.min(1.0, Double.parseDouble(myArgsEngine.getString("-i")));
    }
    if (myArgsEngine.getBoolean("-f")) {
        this.min_frac = Double.parseDouble(myArgsEngine.getString("-f"));
    }
    if (myArgsEngine.getBoolean("-di")) {
        this.diff_ident = Double.parseDouble(myArgsEngine.getString("-di"));
    }
    if (myArgsEngine.getBoolean("-df")) {
        this.diff_frac = Double.parseDouble(myArgsEngine.getString("-df"));
    }
}
Also used : File(java.io.File) 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