X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=rsem-calculate-expression;h=fec2e310471c331d4bdf3b745ad4c129f2f5aee1;hb=1d786dca8b4c9c1e2176a28a669d2d16cd93e395;hp=4d1b70a8a4dca169ccb0702caf32d2bb30caaa2f;hpb=0165dcc248203dce454881b6f1707cdf248497c2;p=rsem.git
diff --git a/rsem-calculate-expression b/rsem-calculate-expression
index 4d1b70a..fec2e31 100755
--- a/rsem-calculate-expression
+++ b/rsem-calculate-expression
@@ -2,9 +2,12 @@
use Getopt::Long;
use Pod::Usage;
-use File::Basename;
+use FindBin;
+use lib $FindBin::Bin;
use strict;
+use rsem_perl_utils qw(runCommand collectResults showVersionInfo);
+
#const
my $BURNIN = 200;
my $NCV = 1000;
@@ -18,10 +21,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;
@@ -111,7 +110,7 @@ GetOptions("keep-intermediate-files" => \$keep_intermediate_files,
"q|quiet" => \$quiet,
"h|help" => \$help) or pod2usage(-exitval => 2, -verbose => 2);
-my ($fn, $dir, $suf) = fileparse($0);
+my $dir = "$FindBin::Bin/";
pod2usage(-verbose => 2) if ($help == 1);
&showVersionInfo($dir) if ($version == 1);
@@ -347,78 +346,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 = ) {
- 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 = ;
- chomp($line);
- close(INPUT);
- print "$line\n";
- exit(0);
-}
-
__END__
=head1 NAME