38
|
1 #!/usr/bin/env perl
|
|
2
|
44
|
3 # Flexbar wrapper for Galaxy tool definition, version 3.5.0
|
38
|
4 # Author: Johannes Roehr
|
|
5
|
|
6 use warnings;
|
|
7 use strict;
|
|
8
|
|
9 my $format;
|
|
10 my @inFiles;
|
|
11 my @outFiles;
|
|
12
|
42
|
13 my $compression = "";
|
|
14
|
38
|
15 foreach(0..$#ARGV){
|
|
16 my $arg = $ARGV[$_];
|
|
17
|
40
|
18 if($arg =~ /\.(fastq\w+)$/ || $arg =~ /\.(fastq\w+\.gz)$/ || $arg =~ /\.(fastq\w+\.bz2)$/){
|
38
|
19
|
40
|
20 if(defined $format && $format ne $1){
|
42
|
21 warn "Read files should have the same format.\n";
|
40
|
22 exit 1;
|
|
23 }
|
38
|
24 $format = $1;
|
40
|
25
|
38
|
26 my $file = $arg;
|
|
27
|
|
28 $arg =~ s/\.fastq\w+$/\.fastq/;
|
|
29 $arg =~ s/\.fastq\w+\.gz$/\.fastq\.gz/;
|
40
|
30 $arg =~ s/\.fastq\w+\.bz2$/\.fastq\.bz2/;
|
|
31
|
42
|
32 $compression = "GZ" if $arg =~ /\.fastq\.gz$/;
|
|
33 $compression = "BZ2" if $arg =~ /\.fastq\.bz2$/;
|
38
|
34
|
|
35 $ARGV[$_] = $arg;
|
42
|
36
|
|
37 if($arg =~ /\.dat_input\w\.fastq$/ || $arg =~ /\.dat_input\w\.fastq\.gz$/ || $arg =~ /\.dat_input\w\.fastq\.bz2$/){
|
|
38 push @inFiles, $arg;
|
|
39 rename $file, $arg;
|
|
40 }
|
|
41
|
|
42 push @outFiles, $arg if $arg =~ /\.dat\.fastq$/ || $arg =~ /\.dat\.fastq\.gz$/ || $arg =~ /\.dat\.fastq\.bz2$/;
|
38
|
43 }
|
|
44 }
|
|
45
|
42
|
46 my $barcoded = 0;
|
|
47
|
|
48 $barcoded = 1 if $ARGV[$#ARGV] =~ /barcoded$/;
|
|
49
|
|
50 my $call = join " ", @ARGV[0..($#ARGV - $barcoded)];
|
|
51
|
|
52 # $call = $call ." --zip-output ". $compression if $barcoded && $compression ne "";
|
38
|
53
|
|
54 system $call and exit 1;
|
|
55
|
|
56
|
|
57 unlink $_ or warn "Could not unlink $_: $!" foreach(@inFiles);
|
|
58
|
42
|
59 if($barcoded){
|
|
60 $format =~ s/\.gz//;
|
|
61 $format =~ s/\.bz2//;
|
38
|
62
|
42
|
63 foreach(<$ARGV[$#ARGV]/flexbarOut*.fastq*>){
|
|
64
|
|
65 my $file = $_;
|
|
66
|
|
67 s/fastq$/$format/;
|
|
68 # s/fastq\.gz$/$format/;
|
|
69 # s/fastq\.bz2$/$format/;
|
|
70
|
|
71 rename $file, $_;
|
|
72 }
|
|
73 }
|
|
74 else{
|
|
75 foreach(@outFiles){
|
|
76
|
|
77 my $file = $_;
|
|
78
|
|
79 s/\.fastq$//;
|
|
80 s/\.fastq\.gz$//;
|
|
81 s/\.fastq\.bz2$//;
|
|
82
|
|
83 rename $file, $_;
|
|
84 }
|
38
|
85 }
|
|
86
|