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