annotate mirdeep2/mirdeep2_wrapper.pl @ 0:5b9519f4b165

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