comparison mirdeep2/mirdeep2_wrapper.pl @ 0:5b9519f4b165

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