13
|
1 #!/usr/bin/env perl
|
|
2
|
|
3 # Flexbar wrapper for Galaxy tool definition, version 2.5
|
|
4 # Author: Johannes Roehr
|
|
5
|
|
6 use warnings;
|
|
7 use strict;
|
|
8
|
|
9 # this parses the last 4 arguments
|
|
10 # what is id -> xml $output.id
|
|
11 # what is folder -> xml $__new_file_path__
|
|
12 # what is format? -> xml $reads.ext
|
|
13 my ($outFile, $id, $folder, $format) = @ARGV[($#ARGV - 3) .. $#ARGV];
|
|
14
|
|
15 # this parses all but the last four arguments
|
|
16 # contains the call to the flexbar actual
|
|
17 my $call = join " ", @ARGV[0..($#ARGV - 4)];
|
|
18
|
|
19 # this calls flexbar and
|
|
20 # prefix for output files will be "FlexbarTargetFile"
|
|
21 system $call .' --target FlexbarTargetFile > '. $outFile and exit 1;
|
|
22
|
|
23 # now we parse all output files
|
|
24 foreach(<FlexbarTargetFile*>){
|
|
25
|
|
26 # determine filetype
|
|
27 my $fileType;
|
|
28
|
|
29 $fileType = $1 if /\.(\w+)$/;
|
|
30 $fileType = $format if /\.\w*fast\w$/;
|
|
31 $fileType = 'fasta' if /\.fasta$/;
|
|
32 $fileType = 'csfasta' if /\.csfasta$/;
|
|
33 $fileType = 'tabular' if /\.lengthdist$/;
|
|
34
|
|
35 # this is just the filename from the for loop
|
|
36 my $file = $_;
|
|
37
|
|
38 # replace underscores by minus in $_
|
|
39 s/_/-/g;
|
|
40
|
|
41 # set new name for output files
|
|
42 my $name = "primary_". $id ."_". $_ ."_visible_". $fileType;
|
|
43
|
|
44 # rename output file to a pattern recognized by flexbar?
|
|
45 rename $file, $name;
|
|
46 # best guess: this seems to move the file into a folder
|
|
47 # rename behavious is not specified by perl... or implementation differs.
|
|
48 rename $name, $folder;
|
|
49 }
|