annotate mirdeep2_wrapper.pl @ 0:1bdefe8a8676 draft default tip

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