Search in sources :

Example 1 with ArgsEngine

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

the class GBSpileup 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-fastq", true);
        myArgsEngine.add("-k", "--key-file", true);
        myArgsEngine.add("-e", "--enzyme", true);
        myArgsEngine.add("-q", "--min-qualS", true);
        myArgsEngine.add("-p", "--ploidy", true);
        myArgsEngine.add("-t", "--threads", true);
        myArgsEngine.add("-T", "--trim-leading", true);
        myArgsEngine.add("-b", "--unassgined-reads", true);
        myArgsEngine.add("-f", "--reference", true);
        myArgsEngine.add("-z", "--skip-freebayes", false);
        myArgsEngine.add("-x", "--max-coverage", true);
        myArgsEngine.add("-o", "--prefix", true);
        myArgsEngine.parse(args);
    }
    if (myArgsEngine.getBoolean("-i")) {
        myInputDirName = myArgsEngine.getString("-i");
    } else {
        printUsage();
        throw new IllegalArgumentException("Please specify the location of your FASTQ files.");
    }
    if (myArgsEngine.getBoolean("-k")) {
        myKeyfile = myArgsEngine.getString("-k");
    } else {
        printUsage();
        throw new IllegalArgumentException("Please specify a barcode key file.");
    }
    if (myArgsEngine.getBoolean("-z")) {
        this.skipFB = true;
    } else {
        this.require("freebayes");
    }
    if (myArgsEngine.getBoolean("-f")) {
        myReference = myArgsEngine.getString("-f");
        if (!new File(myReference + ".amb").exists() || !new File(myReference + ".ann").exists() || !new File(myReference + ".bwt").exists() || !new File(myReference + ".pac").exists() || !new File(myReference + ".sa").exists()) {
            String index = "bwa index -p " + myReference + " -a bwtsw " + myReference;
            this.consume(this.bash(index));
        }
    } else {
        printUsage();
        throw new IllegalArgumentException("Please specify the reference.");
    }
    if (myArgsEngine.getBoolean("-e")) {
        myEnzyme = myArgsEngine.getString("-e").split("-");
    } else {
        myLogger.warn("No enzyme specified.  Using enzyme listed in key file.");
        try {
            BufferedReader br = Utils.getBufferedReader(myKeyfile);
            String[] s = br.readLine().split("\\s+");
            int k = -1;
            for (int i = 0; i < s.length; i++) if (s[i].toLowerCase().equals("enzyme"))
                k = i;
            if (k < 0)
                throw new IllegalArgumentException("No enzyme found in the key file. " + "Please specify the enzyme with -e option.\n\n");
            s = br.readLine().split("\\s+");
            myEnzyme = s[k].split("-");
            br.close();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    if (myArgsEngine.getBoolean("-q")) {
        myMinQualS = Integer.parseInt(myArgsEngine.getString("-q"));
    }
    if (myArgsEngine.getBoolean("-p")) {
        myPloidy = Integer.parseInt(myArgsEngine.getString("-p"));
    }
    if (myArgsEngine.getBoolean("-t")) {
        THREADS = Integer.parseInt(myArgsEngine.getString("-t"));
    }
    if (myArgsEngine.getBoolean("-x")) {
        maxCov = Long.parseLong(myArgsEngine.getString("-x"));
    }
    if (myArgsEngine.getBoolean("-T")) {
        int leading = Integer.parseInt(myArgsEngine.getString("-T"));
        if (leading > 0) {
            List<Integer> leadings = new ArrayList<Integer>();
            leadings.add(leading);
            for (int i = 1; i < 4; i++) {
                if (leading - i >= 0)
                    leadings.add(leading - i);
                leadings.add(leading + i);
            }
            myLeadingTrim = new int[leadings.size()];
            for (int i = 0; i < myLeadingTrim.length; i++) myLeadingTrim[i] = leadings.get(i);
        }
    }
    if (myArgsEngine.getBoolean("-o")) {
        myOutputDir = myArgsEngine.getString("-o");
    }
    File out = new File(myOutputDir);
    if (out.exists() && out.isDirectory()) {
        myLogger.warn("Output directory " + myOutputDir + " exsits. " + "We strongly recommend a new location.");
    }
}
Also used : BufferedReader(java.io.BufferedReader) ArrayList(java.util.ArrayList) IOException(java.io.IOException) File(java.io.File) ArgsEngine(cz1.util.ArgsEngine)

Example 2 with ArgsEngine

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

the class MergeBedGenCov 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-dir", true);
        myArgsEngine.add("-0", "--reverse-zero", true);
        myArgsEngine.add("-x", "--max-coverage", true);
        myArgsEngine.add("-o", "--prefix", true);
        myArgsEngine.parse(args);
    }
    if (myArgsEngine.getBoolean("-i")) {
        input_covs = myArgsEngine.getString("-i");
    } else {
        printUsage();
        throw new IllegalArgumentException("Please specify the folder of coverage files.");
    }
    if (myArgsEngine.getBoolean("-o")) {
        output_cov = myArgsEngine.getString("-o");
    }
    if (myArgsEngine.getBoolean("-0")) {
        rev_zero = true;
    }
    if (myArgsEngine.getBoolean("-x")) {
        maxCov = Long.parseLong(myArgsEngine.getString("-x"));
    }
}
Also used : ArgsEngine(cz1.util.ArgsEngine)

Example 3 with ArgsEngine

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

the class MergeTagSequence 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-tags", true);
        myArgsEngine.add("-o", "--prefix", true);
        myArgsEngine.parse(args);
    }
    if (myArgsEngine.getBoolean("-i")) {
        myInputDirName = myArgsEngine.getString("-i");
    } else {
        printUsage();
        throw new IllegalArgumentException("Please specify the location of your FASTQ files.");
    }
    if (myArgsEngine.getBoolean("-o")) {
        myOutputDir = myArgsEngine.getString("-o");
    }
    this.makeOutputDir();
}
Also used : ArgsEngine(cz1.util.ArgsEngine)

Example 4 with ArgsEngine

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

the class SamFileFilter 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-dir", true);
        myArgsEngine.add("-x", "-x/--filter", true);
        myArgsEngine.add("-t", "--threads", true);
        myArgsEngine.add("-o", "--prefix", true);
        myArgsEngine.parse(args);
    }
    if (myArgsEngine.getBoolean("-i")) {
        input_dir = myArgsEngine.getString("-i");
    } else {
        printUsage();
        throw new IllegalArgumentException("Please specify the folder of coverage files.");
    }
    if (myArgsEngine.getBoolean("-o")) {
        output_dir = myArgsEngine.getString("-o");
    }
    if (myArgsEngine.getBoolean("-t")) {
        THREADS = Integer.parseInt(myArgsEngine.getString("-t"));
    }
    if (myArgsEngine.getBoolean("-x")) {
        filter_file = myArgsEngine.getString("-x");
    }
}
Also used : ArgsEngine(cz1.util.ArgsEngine)

Example 5 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("-b", "--blast", 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("-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("-k")) {
        this.kmer_size = Integer.parseInt(myArgsEngine.getString("-k"));
    } else {
        printUsage();
        throw new IllegalArgumentException("Please specify the kmer size of contig construction.");
    }
    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