comparison trimmomatic_wrapper.pl @ 3:5f612ae9e505 draft default tip

Uploaded
author simon-gladman
date Wed, 10 Jul 2013 23:32:27 -0400
parents
children
comparison
equal deleted inserted replaced
2:dd41f344987e 3:5f612ae9e505
1 #!/usr/bin/perl
2
3 # trimmomatic_wrapper.pl
4 #
5 # Copyright 2012 Simon Gladman<simon.gladman@monash.edu>
6 #
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
11 #
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20 # MA 02110-1301, USA.
21 #
22 #
23
24 use strict;
25 use warnings;
26 use File::Temp qw( tempdir tempfile);
27
28 my %stuff = @ARGV;
29
30 my $dir = tempdir(CLEANUP => 1);
31 my ($fwdtempfh, $fwdtemp) = tempfile( DIR => $dir );
32 my ($revtempfh, $revtemp) = tempfile( DIR => $dir );
33
34 foreach my $x (keys %stuff){
35 print "$x\t" . $stuff{$x} . "\n";
36 }
37
38 my $tooldir = $stuff{"tool-dir"};
39 my $jar = "$tooldir/shared/jars/trimmomatic-0.22.jar";
40
41 my $numthreads = 4;
42
43
44 my $cmd = "java -cp $jar org.usadellab.trimmomatic.Trimmomatic";
45
46 if($stuff{"paired"} eq "True"){
47 $cmd .= "PE";
48 }
49 else {
50 $cmd .= "SE";
51 }
52
53 $cmd .= " -threads $numthreads";
54
55 $cmd .= " -phred33" if($stuff{"phred"} eq "phred33");
56
57 if($stuff{"log"} eq "True"){
58 $cmd .= " -trimlog " . $stuff{"logfile"};
59 }
60
61 if($stuff{"paired"} eq "True"){
62 $cmd .= " " . join(" ",($stuff{"fwdfile"},$stuff{"revfile"},$stuff{"fwdpairs"},$fwdtemp,$stuff{"revpairs"},$revtemp));
63 }
64 else {
65 $cmd .= " " . join(" ",($stuff{"fwdfile"},$stuff{"singles"}));
66 }
67
68 $cmd .= " " . join(":",("ILLUMINACLIP",$stuff{"adaptfile"},$stuff{"adaptseed"},$stuff{"adaptpalindrome"},$stuff{"adaptsimple"})) if $stuff{"cutadapt"} eq "True";
69
70 $cmd .= " " . join(":",("SLIDINGWINDOW",$stuff{"slidingsize"},$stuff{"slidingqual"})) if $stuff{"slidingwindow"} eq "True";
71
72 $cmd .= " " .join(":",("LEADING",$stuff{"leadingqual"})) if $stuff{"trimleading"} eq "True";
73
74 $cmd .= " " .join(":",("TRAILING",$stuff{"trailingqual"})) if $stuff{"trimtrailing"} eq "True";
75
76 $cmd .= " " .join(":",("CROP",$stuff{"croplen"})) if $stuff{"crop"} eq "True";
77
78 $cmd .= " " .join(":",("HEADCROP",$stuff{"headcroplen"})) if $stuff{"headcrop"} eq "True";
79
80 $cmd .= " " .join(":",("MINLEN",$stuff{"minlen"}));
81
82 print "Command:\t$cmd\n";
83
84 if(system($cmd) == 0){
85 if ($stuff{"paired"} eq "True"){
86 my $catcmd = "cat $fwdtemp $revtemp > " . $stuff{"singles"};
87 system($catcmd) == 0 or die "Something went wrong with the cat command $!";
88 }
89 }
90 else{
91 print "There was an error with trimmomatic! $!";
92 exit(1);
93 }
94
95 exit(0);