From c9c7c384a120cdf5f9e95ddea0021f6db9b03885 Mon Sep 17 00:00:00 2001
From: Colin Dewey <cdewey@biostat.wisc.edu>
Date: Thu, 12 May 2011 11:24:19 -0500
Subject: [PATCH] Added check in rsem-plot-model for .stat output directory

---
 rsem-plot-model | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/rsem-plot-model b/rsem-plot-model
index c15a75f..7ca89ec 100755
--- a/rsem-plot-model
+++ b/rsem-plot-model
@@ -2,15 +2,21 @@
 
 argv <- commandArgs(TRUE)
 if (length(argv) != 2) {
-  cat("Usage: rsem-plot-model sample_name outF\n")
+  cat("Usage: rsem-plot-model sample_name output_plot_file\n")
   q(status = 1)
 }
 
 strvec <- strsplit(argv[1], split = "/")[[1]]
 token <- strvec[length(strvec)]
 
-modelF <- paste(argv[1], ".stat/", token, ".model", sep = "")
-cntF <- paste(argv[1], ".stat/", token, ".cnt", sep = "")
+stat.dir <- paste(argv[1], ".stat", sep = "")
+if (!file.exists(stat.dir)) {
+  cat("Error: directory does not exist: ", stat.dir, "\n", sep = "")
+  cat(strwrap("This version of rsem-plot-model only works with the output of RSEM versions >= 1.1.8"), sep="\n")
+  q(status = 1)
+}
+modelF <- paste(stat.dir, "/", token, ".model", sep = "")
+cntF <- paste(stat.dir, "/", token, ".cnt", sep = "")
 
 pdf(argv[2])
 
-- 
2.39.5