annotate flexbar.pl @ 40:2fcee21876db draft

Uploaded
author jtilman
date Sun, 01 Jul 2018 08:00:26 -0400
parents 216a55a39b52
children e1f80a81ba2c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38
216a55a39b52 Uploaded
jtilman
parents:
diff changeset
1 #!/usr/bin/env perl
216a55a39b52 Uploaded
jtilman
parents:
diff changeset
2
216a55a39b52 Uploaded
jtilman
parents:
diff changeset
3 # Flexbar wrapper for Galaxy tool definition, version 3.4.2
216a55a39b52 Uploaded
jtilman
parents:
diff changeset
4 # Author: Johannes Roehr
216a55a39b52 Uploaded
jtilman
parents:
diff changeset
5
216a55a39b52 Uploaded
jtilman
parents:
diff changeset
6 use warnings;
216a55a39b52 Uploaded
jtilman
parents:
diff changeset
7 use strict;
216a55a39b52 Uploaded
jtilman
parents:
diff changeset
8
216a55a39b52 Uploaded
jtilman
parents:
diff changeset
9 my $format;
216a55a39b52 Uploaded
jtilman
parents:
diff changeset
10 my @inFiles;
216a55a39b52 Uploaded
jtilman
parents:
diff changeset
11 my @outFiles;
216a55a39b52 Uploaded
jtilman
parents:
diff changeset
12
216a55a39b52 Uploaded
jtilman
parents:
diff changeset
13 foreach(0..$#ARGV){
216a55a39b52 Uploaded
jtilman
parents:
diff changeset
14 my $arg = $ARGV[$_];
216a55a39b52 Uploaded
jtilman
parents:
diff changeset
15
40
2fcee21876db Uploaded
jtilman
parents: 38
diff changeset
16 if($arg =~ /\.(fastq\w+)$/ || $arg =~ /\.(fastq\w+\.gz)$/ || $arg =~ /\.(fastq\w+\.bz2)$/){
38
216a55a39b52 Uploaded
jtilman
parents:
diff changeset
17
40
2fcee21876db Uploaded
jtilman
parents: 38
diff changeset
18 if(defined $format && $format ne $1){
2fcee21876db Uploaded
jtilman
parents: 38
diff changeset
19 print STDERR "Paired read files should have the same format.\n";
2fcee21876db Uploaded
jtilman
parents: 38
diff changeset
20 exit 1;
2fcee21876db Uploaded
jtilman
parents: 38
diff changeset
21 }
38
216a55a39b52 Uploaded
jtilman
parents:
diff changeset
22 $format = $1;
40
2fcee21876db Uploaded
jtilman
parents: 38
diff changeset
23
38
216a55a39b52 Uploaded
jtilman
parents:
diff changeset
24 my $file = $arg;
216a55a39b52 Uploaded
jtilman
parents:
diff changeset
25
216a55a39b52 Uploaded
jtilman
parents:
diff changeset
26 $arg =~ s/\.fastq\w+$/\.fastq/;
216a55a39b52 Uploaded
jtilman
parents:
diff changeset
27 $arg =~ s/\.fastq\w+\.gz$/\.fastq\.gz/;
40
2fcee21876db Uploaded
jtilman
parents: 38
diff changeset
28 $arg =~ s/\.fastq\w+\.bz2$/\.fastq\.bz2/;
2fcee21876db Uploaded
jtilman
parents: 38
diff changeset
29
2fcee21876db Uploaded
jtilman
parents: 38
diff changeset
30 push @inFiles, $arg if $arg =~ /\.dat_input\.fastq$/ || $arg =~ /\.dat_input\.fastq\.gz$/ || $arg =~ /\.dat_input\.fastq\.bz2$/;
2fcee21876db Uploaded
jtilman
parents: 38
diff changeset
31 push @outFiles, $arg if $arg =~ /\.dat\.fastq$/ || $arg =~ /\.dat\.fastq\.gz$/ || $arg =~ /\.dat\.fastq\.bz2$/;
38
216a55a39b52 Uploaded
jtilman
parents:
diff changeset
32
216a55a39b52 Uploaded
jtilman
parents:
diff changeset
33 $ARGV[$_] = $arg;
216a55a39b52 Uploaded
jtilman
parents:
diff changeset
34 rename $file, $arg;
216a55a39b52 Uploaded
jtilman
parents:
diff changeset
35 }
216a55a39b52 Uploaded
jtilman
parents:
diff changeset
36 }
216a55a39b52 Uploaded
jtilman
parents:
diff changeset
37
216a55a39b52 Uploaded
jtilman
parents:
diff changeset
38 my $call = join " ", @ARGV;
216a55a39b52 Uploaded
jtilman
parents:
diff changeset
39
216a55a39b52 Uploaded
jtilman
parents:
diff changeset
40 system $call and exit 1;
216a55a39b52 Uploaded
jtilman
parents:
diff changeset
41
216a55a39b52 Uploaded
jtilman
parents:
diff changeset
42
216a55a39b52 Uploaded
jtilman
parents:
diff changeset
43 unlink $_ or warn "Could not unlink $_: $!" foreach(@inFiles);
216a55a39b52 Uploaded
jtilman
parents:
diff changeset
44
216a55a39b52 Uploaded
jtilman
parents:
diff changeset
45 foreach(@outFiles){
216a55a39b52 Uploaded
jtilman
parents:
diff changeset
46
216a55a39b52 Uploaded
jtilman
parents:
diff changeset
47 my $file = $_;
216a55a39b52 Uploaded
jtilman
parents:
diff changeset
48
216a55a39b52 Uploaded
jtilman
parents:
diff changeset
49 s/\.fastq$//;
216a55a39b52 Uploaded
jtilman
parents:
diff changeset
50 s/\.fastq\.gz$//;
40
2fcee21876db Uploaded
jtilman
parents: 38
diff changeset
51 s/\.fastq\.bz2$//;
38
216a55a39b52 Uploaded
jtilman
parents:
diff changeset
52
216a55a39b52 Uploaded
jtilman
parents:
diff changeset
53 rename $file, $_;
216a55a39b52 Uploaded
jtilman
parents:
diff changeset
54 }
216a55a39b52 Uploaded
jtilman
parents:
diff changeset
55