From 8fba6bd91c5fce346901a4d16b7c2ea32d705c01 Mon Sep 17 00:00:00 2001
From: Venkat Malladi <venkat.malladi@utsouthwestern.edu>
Date: Sat, 21 Mar 2020 10:17:02 -0500
Subject: [PATCH] Add usage statement.

---
 workflow/main.nf                 |  3 +--
 workflow/scripts/plot_profile.sh | 30 +++++++++++++++++++++++++++++-
 2 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/workflow/main.nf b/workflow/main.nf
index 90f0c90..66278ca 100644
--- a/workflow/main.nf
+++ b/workflow/main.nf
@@ -488,7 +488,6 @@ process plotProfile {
   output:
 
   file '*.{png,gz}' into plotProfile
-  file gtf from gtfFile
 
   when:
 
@@ -497,7 +496,7 @@ process plotProfile {
   script:
   """
   module load deeptools/2.5.0.1
-  bash $baseDir/scripts/plot_profile.sh
+  bash $baseDir/scripts/plot_profile.sh -g $gtfFile
   """
 }
 
diff --git a/workflow/scripts/plot_profile.sh b/workflow/scripts/plot_profile.sh
index 09b15eb..caa7056 100755
--- a/workflow/scripts/plot_profile.sh
+++ b/workflow/scripts/plot_profile.sh
@@ -1,6 +1,17 @@
 #!/bin/bash
 #plot_profile.sh
 
+script_name="plot_profile.sh"
+
+#Help function
+usage() {
+  echo "-h  --Help documentation for $script_name"
+  echo "-g  --File path to gtf/bed files"
+  echo "Example: $script_name -g 'genome.gtf'"
+  exit 1
+}
+
+
 raise()
 {
   echo "${1}" >&2
@@ -55,8 +66,25 @@ plot_profile() {
 
 
 run_main() {
+
+  # Parsing options
+  OPTIND=1 # Reset OPTIND
+  while getopts :g:h opt
+      do
+          case $opt in
+              g) gtf=$OPTARG;;
+              h) usage;;
+          esac
+      done
+
+  shift $(($OPTIND -1))
+
+  # Check for mandatory options
+  if [[ -z $gtf ]]; then
+      usage
+  fi
+
 	bws=$(ls *.bw)
-	gtf=$(ls *.gtf *.bed)
 
   check_tools || exit 1
 
-- 
GitLab