Skip to content

Commit

Permalink
added option to call all contigs
Browse files Browse the repository at this point in the history
  • Loading branch information
lh3 committed Jun 6, 2021
1 parent c735fdb commit 68ddbc4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
10 changes: 6 additions & 4 deletions dipcall-aux.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env k8

var version = "0.1";
var version = "0.3";

var getopt = function(args, ostr) {
var oli; // option letter list index
Expand Down Expand Up @@ -42,16 +42,18 @@ var getopt = function(args, ostr) {

function vcfpair(args)
{
var c, is_male = false, sample = 'syndip', fn_par = null, par = null;
while ((c = getopt(args, "ms:p:")) != null) {
var c, is_male = false, sample = 'syndip', fn_par = null, par = null, all_ctg = false;
while ((c = getopt(args, "ams:p:")) != null) {
if (c == 's') sample = getopt.arg;
else if (c == 'p') fn_par = getopt.arg, is_male = true;
else if (c == 'a') all_ctg = true;
}
if (getopt.ind == args.length) {
print("Usage: dipcall-aux.js vcfpair [options] <in.pair.vcf>");
print("Options:");
print(" -p FILE chrX PAR; assuming male sample []");
print(" -s STR sample name [" + sample + "]");
print(" -a call on all contigs regardless of naming");
exit(1);
}

Expand All @@ -68,7 +70,7 @@ function vcfpair(args)
file.close();
}

var re_ctg = is_male? /^(chr)?([0-9]+|X|Y)$/ : /^(chr)?([0-9]+|X)$/;
var re_ctg = all_ctg? /^\S+$/ : is_male? /^(chr)?([0-9]+|X|Y)$/ : /^(chr)?([0-9]+|X)$/;
var label = ['1', '2'];
var buf = new Bytes();
var file = args[getopt.ind] == '-'? new File() : new File(args[getopt.ind]);
Expand Down
9 changes: 6 additions & 3 deletions run-dipcall
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ use Getopt::Std;
my $version = "0.3";

my %opts = (t=>8);
getopts("t:d:x:muz:W:", \%opts);
getopts("t:d:x:muz:W:a", \%opts);

die("Usage: run-dipcall [options] <prefix> <ref.fa> <pat.fa> <mat.fa>
Options:
-t INT number of threads [$opts{t}]
-d FILE unimap/minimap2 index for ref.fa []
-a call on all contigs regardless of naming
-x FILE PAR on chrX; assuming male
-z INT Z-drop [mapper default]
-m use minimap2 for mapping (default)
Expand Down Expand Up @@ -87,10 +88,12 @@ push(@mak, "");
push(@mak, "$pre.pair.vcf.gz:$pre.hap1.bam $pre.hap2.bam");
push(@mak, q{ $(ROOT)/htsbox pileup -q5 -evcf $(REF_FA) $^ | $(ROOT)/htsbox bgzip > $@});
push(@mak, "$pre.dip.vcf.gz:$pre.pair.vcf.gz");

my $pair_opt = defined($opts{a})? "-a" : "";
if ($is_male) {
push(@mak, q{ $(ROOT)/k8 $(ROOT)/dipcall-aux.js vcfpair } . qq{-p $opts{x}} . q{ $< | $(ROOT)/htsbox bgzip > $@});
push(@mak, q{ $(ROOT)/k8 $(ROOT)/dipcall-aux.js vcfpair} . qq{ $pair_opt -p $opts{x} } . q{$< | $(ROOT)/htsbox bgzip > $@});
} else {
push(@mak, q{ $(ROOT)/k8 $(ROOT)/dipcall-aux.js vcfpair $< | $(ROOT)/htsbox bgzip > $@});
push(@mak, q{ $(ROOT)/k8 $(ROOT)/dipcall-aux.js vcfpair} . qq{ $pair_opt } . q{$< | $(ROOT)/htsbox bgzip > $@});
}
push(@mak, "");

Expand Down

0 comments on commit 68ddbc4

Please sign in to comment.