]> git.donarmstrong.com Git - rsem.git/blob - rsem-plot-transcript-wiggles
add new files
[rsem.git] / rsem-plot-transcript-wiggles
1 #!/usr/bin/perl
2
3 use Getopt::Long;
4 use Pod::Usage;
5 use File::Basename;
6 use strict;
7
8 my $gene_list = 0; # default is 0, means input is a transcript list; 1 means input is a gene list
9 my $show_unique = 0; # 0, default value, means do not show unique transcript wiggles; 1 means show unique transcript wiggles
10 my $help = 0;
11
12 GetOptions("gene-list" => \$gene_list,
13            "show-unique" => \$show_unique,
14            "h|help" => \$help) or pod2usage(-exitval => 2, -verbose => 2);
15
16 pod2usage(-verbose => 2) if ($help == 1);
17 pod2usage(-msg => "Invalid number of arguments!", -exitval => 2, -verbose => 2) if (scalar(@ARGV) != 3);
18
19 my ($fn, $dir, $suf) = fileparse($0);
20 my $command = "";
21
22 unless (-e "$ARGV[0].transcript.readdepth") {
23     $command = $dir."rsem-bam2readdepth $ARGV[0].transcript.sorted.bam > $ARGV[0].transcript.readdepth";
24     &runCommand($command);
25 }
26
27 if ($show_unique) {
28     unless (-e "$ARGV[0].uniq.transcript.bam") {
29         $command = $dir."rsem-get-unique $ARGV[0].transcript.bam $ARGV[0].uniq.transcript.bam";
30         &runCommand($command);
31     }
32     unless (-e "$ARGV[0].uniq.transcript.sorted.bam") {
33         $command = $dir."sam/samtools sort $ARGV[0].uniq.transcript.bam $ARGV[0].uniq.transcript.sorted";
34         &runCommand($command);
35     }
36     unless (-e "$ARGV[0].uniq.transcript.readdepth") {
37         $command = $dir."rsem-bam2readdepth $ARGV[0].uniq.transcript.sorted.bam > $ARGV[0].uniq.transcript.readdepth";
38         &runCommand($command);
39     }
40 }
41
42 $command = $dir."rsem-gen-transcript-plots $ARGV[0] $ARGV[1] $gene_list $show_unique $ARGV[2]";
43 &runCommand($command);
44
45 # command, {err_msg}
46 sub runCommand {
47     print $_[0]."\n";
48     my $status = system($_[0]);
49     if ($status != 0) { 
50         my $errmsg;
51         if (scalar(@_) > 1) { $errmsg = $_[1]; }
52         else { $errmsg = "\"$command\" failed! Plase check if you provide correct parameters/options for the pipeline!"; }
53         print $errmsg."\n";
54         exit(-1);
55     }
56     print "\n";
57 }
58
59 __END__
60
61 =head1 NAME
62
63 rsem-plot-transcript-wiggles
64
65 =head1 SYNOPSIS
66
67 =over
68
69  rsem-plot-transcript-wiggles [options] sample_name input_list output_plot_file
70
71 =back
72
73 =head1 ARGUMENTS
74
75 =over
76
77 =item B<sample_name>
78
79 blablabla
80
81 =item B<input_list>
82
83 blablabla
84
85 =item B<output_plot_file>
86
87 blablabla
88
89 =back
90
91 =head1 OPTIONS
92
93 =over
94
95 =item B<--gene-list>
96
97 blablabla
98
99 =item B<--show-unique>
100
101 blablabla
102
103 =item B<-h/--help>
104
105 Show help information.
106
107 =back
108
109 =head1 DESCRIPTION
110
111 blablabla
112
113 =head1 OUTPUT
114
115 blablabla
116
117 =head1 EXAMPLES
118
119 =cut