use of cz1.util.ArgsEngine in project polyGembler by c-zhou.
the class PopulationSimulator 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("-r", "--reference", true);
myArgsEngine.add("-n", "--pop-size", true);
myArgsEngine.add("-p", "--ploidy", true);
myArgsEngine.add("-c", "--centimorgan", true);
myArgsEngine.add("-t", "--threads", true);
myArgsEngine.add("-s", "--run-id", true);
myArgsEngine.add("-o", "--prefix", true);
myArgsEngine.parse(args);
}
String reference, id = "Sc1", output = "./";
int f1 = 94, ploidy = 2;
double cM = -1.0;
if (myArgsEngine.getBoolean("-r")) {
reference = myArgsEngine.getString("-r");
} else {
printUsage();
throw new IllegalArgumentException("Please specify the reference FASTA file.");
}
if (myArgsEngine.getBoolean("-n")) {
f1 = Integer.parseInt(myArgsEngine.getString("-n")) - 2;
}
if (myArgsEngine.getBoolean("-p")) {
ploidy = Integer.parseInt(myArgsEngine.getString("-p"));
}
if (myArgsEngine.getBoolean("-c")) {
cM = Double.parseDouble(myArgsEngine.getString("-c"));
}
if (myArgsEngine.getBoolean("-t")) {
THREADS = Integer.parseInt(myArgsEngine.getString("-t"));
}
if (myArgsEngine.getBoolean("-s")) {
id = myArgsEngine.getString("-s");
}
if (myArgsEngine.getBoolean("-o")) {
output = myArgsEngine.getString("-o");
}
pop = new Population(reference, f1, ploidy, cM, id, output);
}
use of cz1.util.ArgsEngine in project polyGembler by c-zhou.
the class BAMstats method setParameters.
@Override
public void setParameters(String[] args) {
// TODO Auto-generated method stub
if (myArgsEngine == null) {
myArgsEngine = new ArgsEngine();
myArgsEngine.add("-i1", "--in-bam1", true);
myArgsEngine.add("-i2", "--in-bam2", true);
myArgsEngine.add("-o", "--out", true);
myArgsEngine.parse(args);
}
if (myArgsEngine.getBoolean("-i1")) {
this.bam_in1 = myArgsEngine.getString("-i1");
} else {
printUsage();
throw new IllegalArgumentException("Please specify the input BAM file.");
}
if (myArgsEngine.getBoolean("-i2")) {
this.bam_in2 = myArgsEngine.getString("-i2");
} else {
printUsage();
throw new IllegalArgumentException("Please specify the input BAM file.");
}
if (myArgsEngine.getBoolean("-o")) {
this.out = myArgsEngine.getString("-o");
} else {
printUsage();
throw new IllegalArgumentException("Please specify the output file.");
}
}
use of cz1.util.ArgsEngine in project polyGembler by c-zhou.
the class TenXSamtools 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 "SORT":
this.task = Task.sort;
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);
switch(this.task) {
case sort:
if (myArgsEngine == null) {
myArgsEngine = new ArgsEngine();
myArgsEngine.add("-i", "--in-bam", true);
myArgsEngine.add("-b", "--barcode", false);
myArgsEngine.add("-n", "--name", false);
myArgsEngine.add("-s", "--batch-size", true);
myArgsEngine.add("-t", "--threads", true);
myArgsEngine.add("-o", "--out-bam", true);
myArgsEngine.parse(args2);
}
if (myArgsEngine.getBoolean("-i")) {
this.bam_in = myArgsEngine.getString("-i");
} else {
printUsage();
throw new IllegalArgumentException("Please specify the input BAM file.");
}
if (myArgsEngine.getBoolean("-b") && myArgsEngine.getBoolean("-n")) {
printUsage();
throw new IllegalArgumentException("Options -b and -n are exculsive!!!");
}
if (myArgsEngine.getBoolean("-b")) {
this.sort_order = Order.barcode;
comprator = new Comparator<SAMRecord>() {
@Override
public int compare(SAMRecord record1, SAMRecord record2) {
// TODO Auto-generated method stub
if (record1 == null && record2 == null)
return 0;
if (record1 == null)
return 1;
if (record2 == null)
return -1;
String bx1 = record1.getStringAttribute("BX"), bx2 = record2.getStringAttribute("BX");
if (bx1 == null && bx2 == null)
return compareSAMRecord(record1, record2);
// none barcode record to the end
if (bx1 == null)
return 1;
if (bx2 == null)
return -1;
int diff = bx1.compareTo(bx2);
return diff == 0 ? compareSAMRecord(record1, record2) : diff;
}
};
}
if (myArgsEngine.getBoolean("-n")) {
this.sort_order = Order.queryname;
comprator = new Comparator<SAMRecord>() {
@Override
public int compare(SAMRecord record1, SAMRecord record2) {
// TODO Auto-generated method stub
if (record1 == null && record2 == null)
return 0;
if (record1 == null)
return 1;
if (record2 == null)
return -1;
if (record1.getReadName().compareTo(record2.getReadName()) == 0)
return compareSAMRecord(record1, record2);
return record1.getReadName().compareTo(record2.getReadName());
}
};
}
if (myArgsEngine.getBoolean("-s")) {
this.batch_size = Integer.parseInt(myArgsEngine.getString("-s"));
}
if (myArgsEngine.getBoolean("-t")) {
this.THREADS = Integer.parseInt(myArgsEngine.getString("-t"));
}
if (myArgsEngine.getBoolean("-o")) {
this.bam_out = myArgsEngine.getString("-o");
} else {
printUsage();
throw new IllegalArgumentException("Please specify the output BAM file.");
}
break;
default:
throw new RuntimeException("!!!");
}
}
use of cz1.util.ArgsEngine in project polyGembler by c-zhou.
the class TenxMoleculeTools method setParameters.
@Override
public void setParameters(String[] args) {
// TODO Auto-generated method stub
if (myArgsEngine == null) {
myArgsEngine = new ArgsEngine();
myArgsEngine.add("-i", "--in", true);
myArgsEngine.add("-t", "--threads", true);
myArgsEngine.add("-o", "--out", true);
myArgsEngine.parse(args);
}
if (myArgsEngine.getBoolean("-i")) {
this.file_in = myArgsEngine.getString("-i");
} else {
printUsage();
throw new IllegalArgumentException("Please specify the input file.");
}
if (myArgsEngine.getBoolean("-t")) {
this.THREADS = Integer.parseInt(myArgsEngine.getString("-t"));
}
if (myArgsEngine.getBoolean("-o")) {
this.file_out = myArgsEngine.getString("-o");
} else {
printUsage();
throw new IllegalArgumentException("Please specify the output file.");
}
}
use of cz1.util.ArgsEngine in project polyGembler by c-zhou.
the class Gembler 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-vcf", true);
myArgsEngine.add("-a", "--input-assembly", true);
myArgsEngine.add("-o", "--prefix", true);
myArgsEngine.add("-x", "--max-iter", true);
myArgsEngine.add("-p", "--ploidy", true);
myArgsEngine.add("-f", "--parent", 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("-S", "--random-seed", true);
myArgsEngine.add("-t", "--threads", true);
myArgsEngine.add("-l", "--min-depth", true);
myArgsEngine.add("-u", "--max-depth", true);
myArgsEngine.add("-q", "--min-qual", true);
myArgsEngine.add("-mf", "--min-maf", true);
myArgsEngine.add("-mm", "--max-missing", true);
myArgsEngine.add("-c", "--min-snp-count", true);
myArgsEngine.add("-r", "--repeat", true);
myArgsEngine.add("-rr", "--refinement-round", true);
myArgsEngine.add("-nb", "--best", true);
myArgsEngine.add("-phi", "--skew-phi", true);
myArgsEngine.add("-nd", "--drop", true);
myArgsEngine.add("-rlib", "--R-external-libs", true);
myArgsEngine.add("-frac", "--frac-thresold", true);
myArgsEngine.add("-gz", "--genome-size", true);
myArgsEngine.parse(args);
}
if (myArgsEngine.getBoolean("-i")) {
in_vcf = myArgsEngine.getString("-i");
} else {
printUsage();
throw new IllegalArgumentException("Please specify your input VCF file.");
}
if (myArgsEngine.getBoolean("-a")) {
assembly_file = myArgsEngine.getString("-a");
}
if (myArgsEngine.getBoolean("-o")) {
out_prefix = myArgsEngine.getString("-o");
} else {
printUsage();
throw new IllegalArgumentException("Please specify your output file prefix.");
}
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");
founder_haps = Constants._founder_haps.split(":");
} else {
printUsage();
throw new IllegalArgumentException("Please specify the parent samples (seperated by a \":\").");
}
int c = 0;
if (myArgsEngine.getBoolean("-G")) {
field = Field.GT;
c++;
}
if (myArgsEngine.getBoolean("-D")) {
field = Field.AD;
c++;
}
if (myArgsEngine.getBoolean("-L")) {
field = Field.PL;
c++;
}
if (c > 1)
throw new IllegalArgumentException("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("-t")) {
THREADS = Integer.parseInt(myArgsEngine.getString("-t"));
}
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("-mf")) {
min_maf = Double.parseDouble(myArgsEngine.getString("-mf"));
}
if (myArgsEngine.getBoolean("-mm")) {
max_missing = Double.parseDouble(myArgsEngine.getString("-mm"));
}
if (myArgsEngine.getBoolean("-c")) {
min_snpc = Integer.parseInt(myArgsEngine.getString("-c"));
}
if (myArgsEngine.getBoolean("-r")) {
String[] rs = myArgsEngine.getString("-r").split(",");
if (rs.length != 3)
throw new IllegalArgumentException("Option -r/--repeat should " + "be 3 integers seperated by \",\".");
for (int i = 0; i < 3; i++) repeat[i] = Integer.parseInt(rs[i]);
}
if (myArgsEngine.getBoolean("-rr")) {
refine_round = Integer.parseInt(myArgsEngine.getString("-rr"));
}
if (myArgsEngine.getBoolean("-nb")) {
nB = Integer.parseInt(myArgsEngine.getString("-nb"));
}
if (myArgsEngine.getBoolean("-phi")) {
phi = Double.parseDouble(myArgsEngine.getString("-phi"));
}
if (myArgsEngine.getBoolean("-nd")) {
drop = Integer.parseInt(myArgsEngine.getString("-nd"));
}
if (myArgsEngine.getBoolean("-rlib")) {
RLibPath = myArgsEngine.getString("-rlib");
}
if (myArgsEngine.getBoolean("-frac")) {
frac_thresh = Double.parseDouble(myArgsEngine.getString("-frac"));
}
if (myArgsEngine.getBoolean("-gz")) {
genome_size = Double.parseDouble(myArgsEngine.getString("-gz"));
}
}
Aggregations