use of cz1.util.ArgsEngine in project polyGembler by c-zhou.
the class RFEstimatorML 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("-ex", "--experiment-id", true);
myArgsEngine.add("-i", "--hap-file", true);
myArgsEngine.add("-o", "--prefix", true);
myArgsEngine.add("-f", "--parent", true);
myArgsEngine.add("-p", "--ploidy", true);
myArgsEngine.add("-nb", "--best", true);
myArgsEngine.add("-t", "--threads", true);
myArgsEngine.add("-phi", "--skew-phi", true);
myArgsEngine.add("-nd", "--drop", true);
myArgsEngine.parse(args);
}
if (myArgsEngine.getBoolean("-i")) {
in_haps = myArgsEngine.getString("-i");
} else {
printUsage();
throw new IllegalArgumentException("Please specify your input zip file.");
}
if (myArgsEngine.getBoolean("-o")) {
out_prefix = myArgsEngine.getString("-o");
} else {
printUsage();
throw new IllegalArgumentException("Please specify your output file prefix.");
}
if (myArgsEngine.getBoolean("-ex")) {
expr_id = myArgsEngine.getString("-ex");
} else {
expr_id = guessExperimentId();
myLogger.warn("No experiment prefix provided, I guess it's " + expr_id + ". Please\n" + "specify it with -ex/--experiment-id option if it's incorrect.");
}
if (myArgsEngine.getBoolean("-f")) {
founder_haps = myArgsEngine.getString("-f").split(":");
} else {
printUsage();
throw new IllegalArgumentException("Please specify the parent samples (seperated by a \":\").");
}
if (myArgsEngine.getBoolean("-p")) {
int ploidy = Integer.parseInt(myArgsEngine.getString("-p"));
Constants.ploidy(ploidy);
Constants._haplotype_z = ploidy * 2;
probs_uniform = new double[ploidy * 2];
Arrays.fill(probs_uniform, .5 / ploidy);
ploidy2 = ploidy / 2;
shift_bits2 = mask_length * ploidy;
}
if (myArgsEngine.getBoolean("-nb")) {
best_n = Integer.parseInt(myArgsEngine.getString("-nb"));
}
if (myArgsEngine.getBoolean("-t")) {
THREADS = Integer.parseInt(myArgsEngine.getString("-t"));
}
if (myArgsEngine.getBoolean("-phi")) {
skew_phi = Integer.parseInt(myArgsEngine.getString("-phi"));
}
if (myArgsEngine.getBoolean("-nd")) {
drop_thres = Integer.parseInt(myArgsEngine.getString("-nd"));
}
setHaps();
}
use of cz1.util.ArgsEngine in project polyGembler by c-zhou.
the class RFEstimatorRS3 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("-ex", "--experiment-id", true);
myArgsEngine.add("-i", "--hap-file", true);
myArgsEngine.add("-o", "--prefix", true);
myArgsEngine.add("-f", "--parent", true);
myArgsEngine.add("-p", "--ploidy", true);
myArgsEngine.add("-nb", "--best", true);
myArgsEngine.add("-t", "--threads", true);
myArgsEngine.add("-phi", "--skew-phi", true);
myArgsEngine.add("-nd", "--drop", true);
myArgsEngine.parse(args);
}
if (myArgsEngine.getBoolean("-i")) {
in_haps = myArgsEngine.getString("-i");
} else {
printUsage();
throw new IllegalArgumentException("Please specify your input zip file.");
}
if (myArgsEngine.getBoolean("-o")) {
out_prefix = myArgsEngine.getString("-o");
} else {
printUsage();
throw new IllegalArgumentException("Please specify your output file prefix.");
}
if (myArgsEngine.getBoolean("-ex")) {
expr_id = myArgsEngine.getString("-ex");
} else {
expr_id = guessExperimentId();
myLogger.warn("No experiment prefix provided, I guess it's " + expr_id + ". Please\n" + "specify it with -ex/--experiment-id option if it's incorrect.");
}
if (myArgsEngine.getBoolean("-f")) {
founder_haps = myArgsEngine.getString("-f").split(":");
} else {
printUsage();
throw new IllegalArgumentException("Please specify the parent samples (seperated by a \":\").");
}
if (myArgsEngine.getBoolean("-p")) {
int ploidy = Integer.parseInt(myArgsEngine.getString("-p"));
Constants.ploidy(ploidy);
Constants._haplotype_z = ploidy * 2;
probs_uniform = new double[ploidy * 2];
Arrays.fill(probs_uniform, .5 / ploidy);
ploidy2 = ploidy / 2;
shift_bits2 = mask_length * ploidy;
}
if (myArgsEngine.getBoolean("-nb")) {
best_n = Integer.parseInt(myArgsEngine.getString("-nb"));
}
if (myArgsEngine.getBoolean("-t")) {
THREADS = Integer.parseInt(myArgsEngine.getString("-t"));
}
if (myArgsEngine.getBoolean("-phi")) {
skew_phi = Double.parseDouble(myArgsEngine.getString("-phi"));
}
if (myArgsEngine.getBoolean("-nd")) {
drop_thres = Integer.parseInt(myArgsEngine.getString("-nd"));
}
setHaps();
}
use of cz1.util.ArgsEngine in project polyGembler by c-zhou.
the class Resampler 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", "--input", true);
myArgsEngine.add("-o", "--prefix", true);
myArgsEngine.add("-ex", "--experiment-id", true);
myArgsEngine.add("-hf", "--hmm-file", true);
myArgsEngine.add("-c", "--scaffold", true);
myArgsEngine.add("-cs", "--start-position", true);
myArgsEngine.add("-ce", "--end-position", true);
myArgsEngine.add("-x", "--max-iter", true);
myArgsEngine.add("-p", "--ploidy", true);
myArgsEngine.add("-f", "--parent", true);
myArgsEngine.add("-s", "--initial-seperation", true);
myArgsEngine.add("-r", "--reverse", true);
myArgsEngine.add("-G", "--genotype", false);
myArgsEngine.add("-D", "--allele-depth", false);
myArgsEngine.add("-L", "--genotype-likelihood", false);
myArgsEngine.add("-b", "--segmental-kmeans", false);
myArgsEngine.add("-e", "--train-exp", false);
myArgsEngine.add("-S", "--random-seed", true);
myArgsEngine.add("-rs", "--resampling", true);
myArgsEngine.add("-pp", "--print-plot", false);
myArgsEngine.add("-sp", "--save-plot", true);
myArgsEngine.parse(args);
}
if (myArgsEngine.getBoolean("-i")) {
in_zip = myArgsEngine.getString("-i");
} else {
printUsage();
throw new IllegalArgumentException("Please specify your input zip file.");
}
if (myArgsEngine.getBoolean("-o")) {
out_prefix = myArgsEngine.getString("-o");
} else {
printUsage();
throw new IllegalArgumentException("Please specify your output file prefix.");
}
if (myArgsEngine.getBoolean("-ex")) {
expr_id = myArgsEngine.getString("-ex");
} else {
expr_id = new File(in_zip).getName().replaceAll(".zip$", "").replace(".", "").replace("_", "");
}
if (myArgsEngine.getBoolean("-hf")) {
hmm_file = myArgsEngine.getString("-hf");
}
if (myArgsEngine.getBoolean("-c")) {
scaff = myArgsEngine.getString("-c").split(":");
} else {
printUsage();
throw new IllegalArgumentException("Please specify the scaffold(s).");
}
if (myArgsEngine.getBoolean("-cs") ^ myArgsEngine.getBoolean("-ce")) {
printUsage();
throw new IllegalArgumentException("Need to specify both start position " + "and end position or none of them.");
}
if (myArgsEngine.getBoolean("-cs")) {
String[] s = myArgsEngine.getString("-cs").split(":");
start_pos = new int[scaff.length];
int n = Math.min(scaff.length, s.length);
for (int i = 0; i != n; i++) start_pos[i] = Integer.parseInt(s[i]);
for (int i = n; i < start_pos.length; i++) start_pos[i] = Integer.MIN_VALUE;
}
if (myArgsEngine.getBoolean("-ce")) {
String[] s = myArgsEngine.getString("-ce").split(":");
end_pos = new int[scaff.length];
int n = Math.min(scaff.length, s.length);
for (int i = 0; i != n; i++) end_pos[i] = Integer.parseInt(s[i]);
for (int i = n; i < end_pos.length; i++) end_pos[i] = Integer.MAX_VALUE;
}
if (myArgsEngine.getBoolean("-x")) {
max_iter = Integer.parseInt(myArgsEngine.getString("-x"));
}
if (myArgsEngine.getBoolean("-p")) {
Constants.ploidy(Integer.parseInt(myArgsEngine.getString("-p")));
}
if (myArgsEngine.getBoolean("-f")) {
Constants._founder_haps = myArgsEngine.getString("-f");
} else {
printUsage();
throw new IllegalArgumentException("Please specify the parent samples (seperated by a \":\").");
}
if (myArgsEngine.getBoolean("-s")) {
String[] ss = myArgsEngine.getString("-s").split(":");
if (ss.length < scaff.length - 1)
throw new RuntimeException("Number of scaffolds does not match number of initial seperations!!!");
seperation = new double[scaff.length - 1];
for (int i = 0; i < seperation.length; i++) seperation[i] = Double.parseDouble(ss[i]);
} else {
seperation = new double[scaff.length - 1];
for (int i = 0; i < seperation.length; i++) seperation[i] = Math.max(Math.round(Constants.rand.nextDouble() * Constants._max_initial_seperation), 1);
}
boolean isRF = Constants.isRF(seperation);
if (isRF) {
for (int i = 0; i < seperation.length; i++) seperation[i] = Constants.haldane(seperation[i]);
}
if (myArgsEngine.getBoolean("-r")) {
String[] dd = myArgsEngine.getString("-r").split(":");
if (dd.length < scaff.length)
throw new RuntimeException("Number of scaffolds does not match number of reverses!!!");
reverse = new boolean[scaff.length];
for (int i = 0; i < reverse.length; i++) reverse[i] = Boolean.parseBoolean(dd[i]);
} else {
reverse = new boolean[scaff.length];
Arrays.fill(reverse, false);
}
int i = 0;
if (myArgsEngine.getBoolean("-G")) {
field = Field.GT;
i++;
}
if (myArgsEngine.getBoolean("-D")) {
field = Field.AD;
i++;
}
if (myArgsEngine.getBoolean("-L")) {
field = Field.PL;
i++;
}
if (i > 1)
throw new RuntimeException("Options -G/--genotype, " + "-D/--allele-depth, and -L/--genotype-likelihood " + "are exclusive!!!");
if (myArgsEngine.getBoolean("-b")) {
vbt = true;
throw new RuntimeException("Viterbi training not supported yet!!!");
}
if (myArgsEngine.getBoolean("-S")) {
Constants.seed = Long.parseLong(myArgsEngine.getString("-S"));
Constants.setRandomGenerator();
}
if (myArgsEngine.getBoolean("-rs")) {
resampling = Integer.parseInt(myArgsEngine.getString("-rs"));
}
if (myArgsEngine.getBoolean("-e")) {
trainExp = true;
}
if (myArgsEngine.getBoolean("-pp")) {
Constants.plot(true);
}
if (myArgsEngine.getBoolean("-sp")) {
plot_pdf = myArgsEngine.getString("-sp");
Constants.plot(true);
Constants.printPlots(true);
}
}
use of cz1.util.ArgsEngine in project polyGembler by c-zhou.
the class TwoPointConstructor 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("-r", "--fixed-rf", true);
myArgsEngine.add("-2", "--two-point", 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("-2")) {
twopoint_file = myArgsEngine.getString("--two-point");
} else {
printUsage();
throw new IllegalArgumentException("Please specify your two-point file prefix.");
}
if (myArgsEngine.getBoolean("-r")) {
fixed_rf = Double.parseDouble(myArgsEngine.getString("-r"));
}
if (myArgsEngine.getBoolean("-rlib")) {
RLibPath = myArgsEngine.getString("-rlib");
}
}
use of cz1.util.ArgsEngine in project polyGembler by c-zhou.
the class FastqToTagSequence 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("-t", "--threads", true);
myArgsEngine.add("-T", "--trim-leading", true);
myArgsEngine.add("-b", "--unassgined-reads", 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("-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("-t")) {
THREADS = Integer.parseInt(myArgsEngine.getString("-t"));
}
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");
}
this.makeOutputDir();
}
Aggregations