Mercurial > repos > simon-gladman > trimmomatic_032
comparison trimmomatic_wrapper.pl @ 2:7d626189cc4c draft
Uploaded
| author | simon-gladman |
|---|---|
| date | Wed, 09 Jul 2014 16:59:49 -0400 |
| parents | |
| children | 18bd222a110e |
comparison
equal
deleted
inserted
replaced
| 1:6a5c492f34e4 | 2:7d626189cc4c |
|---|---|
| 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 #Version 1.1 - goes with Trimmomatic-0.32.jar | |
| 25 | |
| 26 use strict; | |
| 27 use warnings; | |
| 28 use File::Temp qw( tempdir tempfile); | |
| 29 | |
| 30 my %stuff = @ARGV; | |
| 31 | |
| 32 my $dir = tempdir(CLEANUP => 1); | |
| 33 my ($fwdtempfh, $fwdtemp) = tempfile( DIR => $dir ); | |
| 34 my ($revtempfh, $revtemp) = tempfile( DIR => $dir ); | |
| 35 | |
| 36 foreach my $x (keys %stuff){ | |
| 37 print "$x\t" . $stuff{$x} . "\n"; | |
| 38 } | |
| 39 | |
| 40 my $tooldir = $stuff{"tool-dir"}; | |
| 41 my $jar = "$tooldir/trimmomatic-0.32.jar"; | |
| 42 | |
| 43 my $numthreads = $stuff{"threads"}; | |
| 44 | |
| 45 | |
| 46 my $cmd = "java -cp $jar org.usadellab.trimmomatic.Trimmomatic"; | |
| 47 | |
| 48 if($stuff{"paired"} eq "True"){ | |
| 49 $cmd .= "PE"; | |
| 50 } | |
| 51 else { | |
| 52 $cmd .= "SE"; | |
| 53 } | |
| 54 | |
| 55 $cmd .= " -threads $numthreads"; | |
| 56 | |
| 57 $cmd .= " -phred33" if($stuff{"phred"} eq "phred33"); | |
| 58 | |
| 59 if($stuff{"log"} eq "True"){ | |
| 60 $cmd .= " -trimlog " . $stuff{"logfile"}; | |
| 61 } | |
| 62 | |
| 63 if($stuff{"paired"} eq "True"){ | |
| 64 $cmd .= " " . join(" ",($stuff{"fwdfile"},$stuff{"revfile"},$stuff{"fwdpairs"},$fwdtemp,$stuff{"revpairs"},$revtemp)); | |
| 65 } | |
| 66 else { | |
| 67 $cmd .= " " . join(" ",($stuff{"fwdfile"},$stuff{"singles"})); | |
| 68 } | |
| 69 | |
| 70 $cmd .= " " . join(":",("ILLUMINACLIP",$stuff{"adaptfile"},$stuff{"adaptseed"},$stuff{"adaptpalindrome"},$stuff{"adaptsimple"})) if $stuff{"cutadapt"} eq "True"; | |
| 71 | |
| 72 $cmd .= " " . join(":",("SLIDINGWINDOW",$stuff{"slidingsize"},$stuff{"slidingqual"})) if $stuff{"slidingwindow"} eq "True"; | |
| 73 | |
| 74 $cmd .= " " .join(":",("LEADING",$stuff{"leadingqual"})) if $stuff{"trimleading"} eq "True"; | |
| 75 | |
| 76 $cmd .= " " .join(":",("TRAILING",$stuff{"trailingqual"})) if $stuff{"trimtrailing"} eq "True"; | |
| 77 | |
| 78 $cmd .= " " .join(":",("CROP",$stuff{"croplen"})) if $stuff{"crop"} eq "True"; | |
| 79 | |
| 80 $cmd .= " " .join(":",("HEADCROP",$stuff{"headcroplen"})) if $stuff{"headcrop"} eq "True"; | |
| 81 | |
| 82 $cmd .= " " .join(":",("MINLEN",$stuff{"minlen"})); | |
| 83 | |
| 84 print "Command:\t$cmd\n"; | |
| 85 | |
| 86 if(system($cmd) == 0){ | |
| 87 if ($stuff{"paired"} eq "True"){ | |
| 88 my $catcmd = "cat $fwdtemp $revtemp > " . $stuff{"singles"}; | |
| 89 system($catcmd) == 0 or die "Something went wrong with the cat command $!"; | |
| 90 } | |
| 91 } | |
| 92 else{ | |
| 93 print "There was an error with trimmomatic! $!"; | |
| 94 exit(1); | |
| 95 } | |
| 96 | |
| 97 exit(0); |
