0
|
1 #!/usr/bin/perl
|
|
2
|
|
3 use File::Temp qw/ tempfile tempdir /;
|
|
4 use File::Copy qw/ copy /;
|
|
5 use Cwd;
|
|
6
|
|
7 $ENV{PATH} .= ":/usr/local/apps/mirdeep2/2.0.0.5:/usr/local/apps/bowtie/0.12.9:/usr/local/apps/viennarna/current/bin:/usr/local/randfold-2.0/bin";
|
|
8
|
|
9 $collapsed_reads = $ARGV[0];
|
|
10 $bowtie_index_name = $ARGV[1];
|
|
11 $bowtie_files_path = $ARGV[2];
|
|
12 $arf_file = $ARGV[3];
|
|
13 $mirna_ref = $ARGV[4];
|
|
14 $mirna_other = $ARGV[5];
|
|
15 $precursors = $ARGV[6];
|
|
16 $file_path = $ARGV[7];
|
|
17 $input_name = $ARGV[8];
|
|
18
|
|
19 $csv_output = $ARGV[9];
|
|
20 $html_output = $ARGV[10];
|
|
21 $survey_output = $ARGV[11];
|
|
22 $mrd_output = $ARGV[12];
|
|
23
|
|
24 # the rest are options
|
|
25 $options = join (" ", @ARGV[13..$#ARGV]);
|
|
26
|
|
27 #point to correct bowtie index path
|
|
28 $basename = `basename $bowtie_index_name`;
|
|
29 chomp $basename;
|
|
30
|
|
31 # create the path used to house the pdfs
|
|
32 chomp $file_path;
|
|
33 system ("mkdir -p $file_path");
|
|
34
|
|
35 # do all the dirty work in a temp directory
|
|
36 $cwd = cwd();
|
|
37 $tempdir = tempdir(CLEANUP => 1);
|
|
38 chdir ($tempdir);
|
|
39
|
|
40 if ($mirna_ref eq "None") {$mirna_ref="none";}
|
|
41 if ($mirna_other eq "None") {$mirna_other="none";}
|
|
42 if ($precursors eq "None") {$precursors="none";}
|
|
43
|
|
44 $ret_mirdeep2 = `miRDeep2.pl $collapsed_reads $bowtie_files_path/$basename $arf_file $mirna_ref $mirna_other $precursors -v $options 2> /dev/null`;
|
|
45 system ("cp $tempdir/pdfs*/*.pdf $file_path");
|
|
46
|
|
47 $csv_file = `ls $tempdir/result*.csv`;
|
|
48 chomp $csv_file;
|
|
49 if ($csv_file eq "") {die "Error: Cannot find csv result file in dir $tempdir\n";}
|
|
50
|
|
51 $html_file = `ls $tempdir/result*.html`;
|
|
52 chomp $html_file;
|
|
53 if ($html_file eq "") {die "Error: Cannot find html result file in dir $tempdir\n";}
|
|
54
|
|
55 $survey_file = `ls $tempdir/mirdeep_runs/run*/survey.csv`;
|
|
56 chomp $survey_file;
|
|
57 if ($survey_file eq "") {die "Error: Cannot find survey result file in dir $tempdir\n";}
|
|
58
|
|
59 $mrd_file = `ls $tempdir/mirdeep_runs/run*/output.mrd`;
|
|
60 chomp $mrd_file;
|
|
61 if ($mrd_file eq "") {die "Error: Cannot find hairpin result file in dir $tempdir\n";}
|
|
62
|
|
63 # replacing mirdeep created links with relative links in galaxy
|
|
64 system ("sed -r -i 's/file:\\/\\/.+\\/(.+\\.pdf)/\\1/g' $html_file");
|
|
65
|
|
66 copy ($csv_file, $csv_output);
|
|
67 copy ($html_file, $html_output);
|
|
68 copy ($survey_file, $survey_output);
|
|
69 copy ($mrd_file, $mrd_output);
|
|
70
|
|
71 chdir($cwd);
|