]> git.donarmstrong.com Git - rsem.git/commitdiff
Added user-friendly error messages if users forget to compile the source codes
authorBo Li <bli@cs.wisc.edu>
Thu, 24 Jan 2013 16:22:52 +0000 (10:22 -0600)
committerBo Li <bli@cs.wisc.edu>
Thu, 24 Jan 2013 16:22:52 +0000 (10:22 -0600)
Transcripts.h
convert-sam-for-rsem
rsem-calculate-expression
rsem-generate-ngvector
rsem-plot-transcript-wiggles
rsem-prepare-reference
rsem_perl_utils.pm [new file with mode: 0644]

index 2637d35d197b0070e636a16a0404c669190b6e6d..19b025eb2a0868a051db6f0530caf2b9819296a6 100644 (file)
@@ -100,7 +100,7 @@ void Transcripts::buildMappings(int n_targets, char** target_name) {
        for (int i = 1; i <= M; i++) {
                const std::string& tid = transcripts[i].getTranscriptID();
                iter = dict.find(tid);
-               assert(iter == dict.end());
+               general_assert(iter == dict.end(), tid + " appears more than once!");
                dict[tid] = i;
        }
 
index 7d60f70974fa7db3dc1b96d615771bd7c23b1206..94b7965e88f4061afd5643ea44220aaa98236041 100755 (executable)
@@ -6,6 +6,8 @@ use File::Basename;
 use File::Path 'rmtree';
 use strict;
 
+use rsem_perl_utils;
+
 my ($in_file, $out_file) = ();
 
 my @tmp_dirs = ();
@@ -79,21 +81,6 @@ print STDERR "Conversion is completed. $out_file will be checked by 'rsem-sam-va
 $command = $dir."rsem-sam-validator $out_file";
 &runCommand($command);
 
-
-# command, {err_msg}
-sub runCommand {
-    print $_[0]."\n";
-    my $status = system($_[0]);
-    if ($status != 0) { 
-       my $errmsg;
-       if (scalar(@_) > 1) { $errmsg = $_[1]; }
-       else { $errmsg = "\"$command\" failed! Please check if you provide correct parameters/options for the pipeline!"; }
-       print $errmsg."\n";
-       exit(-1);
-    }
-    print "\n";
-}
-
 __END__
 
 =head1 NAME
index 4d1b70a8a4dca169ccb0702caf32d2bb30caaa2f..4fbb4a59beac6a449a90e4dc6335d7a9633f6dcc 100755 (executable)
@@ -5,6 +5,8 @@ use Pod::Usage;
 use File::Basename;
 use strict;
 
+use rsem_perl_utils qw(runCommand collectResults showVersionInfo);
+
 #const
 my $BURNIN = 200;
 my $NCV = 1000;
@@ -18,10 +20,6 @@ my $status = 0;
 
 my $read_type = 1; # default, single end with qual
 
-my @transcript_title = ("transcript_id", "gene_id", "length", "effective_length", "expected_count", "TPM", "FPKM", "IsoPct", "pme_expected_count", "pme_TPM", "pme_FPKM", "IsoPct_from_pme_TPM", "TPM_ci_lower_bound", "TPM_ci_upper_bound", "FPKM_ci_lower_bound", "FPKM_ci_upper_bound");
-
-my @gene_title = ("gene_id", "transcript_id(s)", "length", "effective_length", "expected_count", "TPM", "FPKM", "pme_expected_count", "pme_TPM", "pme_FPKM", "TPM_ci_lower_bound", "TPM_ci_upper_bound", "FPKM_ci_lower_bound", "FPKM_ci_upper_bound");
-
 my $bowtie_path = "";
 my $C = 2;
 my $E = 99999999;
@@ -347,78 +345,6 @@ if ($mTime) {
     close(OUTPUT);
 }
 
-# command, {err_msg}
-sub runCommand {
-    print $_[0]."\n";
-    my $status = system($_[0]);
-    if ($status != 0) {
-        my $errmsg = "";
-        if (scalar(@_) > 1) { $errmsg .= $_[1]."\n"; }
-        $errmsg .= "\"$_[0]\" failed! Please check if you provide correct parameters/options for the pipeline!\n";
-        print $errmsg;
-        exit(-1);
-    }
-    print "\n";
-}
-# inpF, outF
-sub collectResults {
-    my $local_status;
-    my ($inpF, $outF);
-    my @results = ();
-    my $line;
-
-    $inpF = $_[1];
-    $outF = $_[2];
-
-    $local_status = open(INPUT, $inpF);
-    if ($local_status == 0) { print "Fail to open file $inpF!\n"; exit(-1); }
-    
-    @results = ();
-    
-    while ($line = <INPUT>) {
-       chomp($line);
-       my @local_arr = split(/\t/, $line);
-       push(@results, \@local_arr); 
-    }
-
-    close(INPUT);
-
-    $local_status = open(OUTPUT, ">$outF");
-    if ($local_status == 0) { print "Fail to create file $outF!\n"; exit(-1); }
-
-    my $n = scalar(@results);
-    my $m = scalar(@{$results[0]});
-
-    $" = "\t";
-
-    my @out_arr = ();
-    for (my $i = 0; $i < $n; $i++) {
-       if ($_[0] eq "isoform") { push(@out_arr, $transcript_title[$i]); }
-       elsif ($_[0] eq "gene") { push(@out_arr, $gene_title[$i]); }
-       else { print "A bug on 'collectResults' is detected!\n"; exit(-1); }
-    }
-    print OUTPUT "@out_arr\n";
-
-    for (my $i = 0; $i < $m; $i++) {
-       @out_arr = ();
-       for (my $j = 0; $j < $n; $j++) { push(@out_arr, $results[$j][$i]); }
-       print OUTPUT "@out_arr\n"; 
-    }
-
-    close(OUTPUT);
-}
-
-# dir
-sub showVersionInfo {
-    open(INPUT, "$_[0]\WHAT_IS_NEW");
-    my $line = <INPUT>;
-    chomp($line);
-    close(INPUT);
-    print "$line\n";
-    exit(0);
-}
-
 __END__
 
 =head1 NAME
index fc97b84e83dfdb058ef2bbe048b56cfc68342507..0f44fd4daa2f153e60d3874a09c948aebc606b62 100755 (executable)
@@ -5,6 +5,8 @@ use Pod::Usage;
 use File::Basename;
 use strict;
 
+use rsem_perl_utils;
+
 my $k = 25;
 my $help = 0;
 
@@ -23,20 +25,6 @@ $command = $dir."EBSeq/rsem-for-ebseq-calculate-clustering-info $k $ARGV[0] $ARG
 $command = $dir."EBSeq/rsem-for-ebseq-generate-ngvector-from-clustering-info $ARGV[1].ump $ARGV[1].ngvec";
 &runCommand($command);
 
-# command, {err_msg}
-sub runCommand {
-    print $_[0]."\n";
-    my $status = system($_[0]);
-    if ($status != 0) {
-        my $errmsg = "";
-        if (scalar(@_) > 1) { $errmsg .= $_[1]."\n"; }
-        $errmsg .= "\"$_[0]\" failed! Please check if you provide correct parameters/options for the pipeline!\n";
-        print $errmsg;
-        exit(-1);
-    }
-    print "\n";
-}
-
 __END__
 
 =head1 NAME
index 46a71aaee21ea7abc7d45533db12b93812c7230a..35dfd75544c7d50d6afa61a41d39ecd8c3241608 100755 (executable)
@@ -5,6 +5,8 @@ use Pod::Usage;
 use File::Basename;
 use strict;
 
+use rsem_perl_utils;
+
 my $gene_list = 0; # default is 0, means input is a transcript list; 1 means input is a gene list
 my $show_unique = 0; # 0, default value, means do not show unique transcript wiggles; 1 means show unique transcript wiggles
 my $help = 0;
@@ -46,21 +48,6 @@ if ($show_unique) {
 $command = $dir."rsem-gen-transcript-plots $ARGV[0] $ARGV[1] $gene_list $show_unique $ARGV[2]";
 &runCommand($command);
 
-
-# command, {err_msg}
-sub runCommand {
-    print $_[0]."\n";
-    my $status = system($_[0]);
-    if ($status != 0) { 
-       my $errmsg;
-       if (scalar(@_) > 1) { $errmsg = $_[1]; }
-       else { $errmsg = "\"$command\" failed! Please check if you provide correct parameters/options for the pipeline!"; }
-       print $errmsg."\n";
-       exit(-1);
-    }
-    print "\n";
-}
-
 __END__
 
 =head1 NAME
index 6c5d5f31ad1dcfc98bec5f999b1bcc7d6eb3eaae..5d954a1fc7b7f411fa8fe46d43b5cda1cb181fa6 100755 (executable)
@@ -5,6 +5,8 @@ use Pod::Usage;
 use File::Basename;
 use strict;
 
+use rsem_perl_utils;
+
 my $status;
 
 my $gtfF = "";
@@ -93,20 +95,6 @@ if (!$no_bowtie) {
     &runCommand($command);
 }
 
-# command, {err_msg}
-sub runCommand {
-    print $_[0]."\n";
-    my $status = system($_[0]);
-    if ($status != 0) {
-        my $errmsg = "";
-        if (scalar(@_) > 1) { $errmsg .= $_[1]."\n"; }
-        $errmsg .= "\"$_[0]\" failed! Please check if you provide correct parameters/options for the pipeline!\n";
-        print $errmsg;
-        exit(-1);
-    }
-    print "\n";
-}
-
 __END__
 
 =head1 NAME
diff --git a/rsem_perl_utils.pm b/rsem_perl_utils.pm
new file mode 100644 (file)
index 0000000..f3edfe4
--- /dev/null
@@ -0,0 +1,97 @@
+#!/usr/bin/perl
+
+package rsem_perl_utils;
+
+use strict;
+
+require Exporter;
+our @ISA = qw(Exporter);
+our @EXPORT = qw(runCommand);
+our @EXPORT_OK = qw(runCommand collectResults showVersionInfo);
+
+# command, {err_msg}
+sub runCommand {
+    print $_[0]."\n";
+    my $status = system($_[0]);
+
+    if ($? == -1) {
+       my @arr = split(/[ \t]+/, $_[0]);
+       print "$arr[0] : $!!\n";
+       print "Please check if you have compiled the associated codes by typing related \"make\" commands and/or made related executables ready to use.\n";
+       exit(-1);
+    }
+
+    if ($status != 0) {
+        my $errmsg = "";
+        if (scalar(@_) > 1) { $errmsg .= $_[1]."\n"; }
+       $errmsg .= "\"$_[0]\" failed! Plase check if you provide correct parameters/options for the pipeline!\n";
+       print $errmsg;
+        exit(-1);
+    }
+    print "\n";
+}
+
+
+my @transcript_title = ("transcript_id", "gene_id", "length", "effective_length", "expected_count", "TPM", "FPKM", "IsoPct", "pme_expected_count", "pme_TPM", "pme_FPKM", "IsoPct_from_pme_TPM", "TPM_ci_lower_bound", "TPM_ci_upper_bound", "FPKM_ci_lower_bound", "FPKM_ci_upper_bound");
+
+my @gene_title = ("gene_id", "transcript_id(s)", "length", "effective_length", "expected_count", "TPM", "FPKM", "pme_expected_count", "pme_TPM", "pme_FPKM", "TPM_ci_lower_bound", "TPM_ci_upper_bound", "FPKM_ci_lower_bound", "FPKM_ci_upper_bound");
+
+# inpF, outF
+sub collectResults {
+    my $local_status;
+    my ($inpF, $outF);
+    my @results = ();
+    my $line;
+
+    $inpF = $_[1];
+    $outF = $_[2];
+
+    $local_status = open(INPUT, $inpF);
+    if ($local_status == 0) { print "Fail to open file $inpF!\n"; exit(-1); }
+    
+    @results = ();
+    
+    while ($line = <INPUT>) {
+       chomp($line);
+       my @local_arr = split(/\t/, $line);
+       push(@results, \@local_arr); 
+    }
+
+    close(INPUT);
+
+    $local_status = open(OUTPUT, ">$outF");
+    if ($local_status == 0) { print "Fail to create file $outF!\n"; exit(-1); }
+
+    my $n = scalar(@results);
+    my $m = scalar(@{$results[0]});
+
+    $" = "\t";
+
+    my @out_arr = ();
+    for (my $i = 0; $i < $n; $i++) {
+       if ($_[0] eq "isoform") { push(@out_arr, $transcript_title[$i]); }
+       elsif ($_[0] eq "gene") { push(@out_arr, $gene_title[$i]); }
+       else { print "A bug on 'collectResults' is detected!\n"; exit(-1); }
+    }
+    print OUTPUT "@out_arr\n";
+
+    for (my $i = 0; $i < $m; $i++) {
+       @out_arr = ();
+       for (my $j = 0; $j < $n; $j++) { push(@out_arr, $results[$j][$i]); }
+       print OUTPUT "@out_arr\n"; 
+    }
+
+    close(OUTPUT);
+}
+
+# dir
+sub showVersionInfo {
+    open(INPUT, "$_[0]\WHAT_IS_NEW");
+    my $line = <INPUT>;
+    chomp($line);
+    close(INPUT);
+    print "$line\n";
+    exit(0);
+}
+
+1;