-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrunBBduk.pl
executable file
·62 lines (50 loc) · 1.6 KB
/
runBBduk.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env perl
=head1 Author
Dinghua Li <[email protected]>
=head1 Usage
runBBduk.pl [options] <read1.fq> [read2.fq]
=head1 Options
-a Trim adapters using BBDuk
-q <int> Quality fitlering threshold [10]
-e <float> Entropy for low-complexity filtering [0.75]
-p <str> output prefix
=cut
use warnings;
use strict;
use Getopt::Long;
my $bbduk = "/nas3/dhli_1/software/bbmap/bbduk2.sh";
my $adapters = "/nas3/dhli_1/software/bbmap/resources/adapters.fa";
my $qual_t = 10;
my $trim_ad;
my $entropy = 0.75;
my $out_prefix;
GetOptions(
"a" => \$trim_ad,
"q=i" => \$qual_t,
"e=f" => \$entropy,
"p=s" => \$out_prefix
);
unless (@ARGV >= 1 and defined $out_prefix) {
die `pod2text $0`;
}
my $is_pe = (@ARGV >= 2)? 1 : 0;
my $read1 = $ARGV[0];
my $read2 = $ARGV[1] if ($is_pe);
print STDERR trim()." | ".low_compl_filter()."\n";
system(trim()." | ".low_compl_filter()) == 0 or die "Failed: $?";
sub trim {
my @trim_cmd = ($bbduk, "qtrim=rl", "trimq=".$qual_t, "qin=33"); # WARNING hard code
push(@trim_cmd, "threads=12");
push(@trim_cmd, "minlength=50");
push(@trim_cmd, "in=".$read1, "out=stdout.fq");
push(@trim_cmd, "ref=".$adapters, "hdist=1") if ($trim_ad);
push(@trim_cmd, "in2=".$read2) if ($is_pe);
return join(" ", @trim_cmd);
}
sub low_compl_filter {
my @filter_cmd = ($bbduk, "entropy=".$entropy, "in=stdin.fq", "outm=".$out_prefix.".low_compl.fq.gz");
push(@filter_cmd, "threads=12", "qin=33"); # WARNING hard code
push(@filter_cmd, "out=".$out_prefix.".bbduk_1.fq.gz");
push(@filter_cmd, "out2=".$out_prefix.".bbduk_2.fq.gz") if $is_pe;
return join(" ", @filter_cmd);
}