@@ -21,7 +21,7 @@ import argparse # potential python3 3rd party package, added in python/3.5
21
21
22
22
# Pipeline Metadata and globals
23
23
__author__ = 'Skyler Kuhn'
24
- __version__ = 'v1.9.4 '
24
+ __version__ = 'v1.9.5 '
25
25
26
26
__home__ = os .path .dirname (os .path .abspath (__file__ ))
27
27
_name = os .path .basename (sys .argv [0 ])
@@ -122,6 +122,34 @@ def exe_in_path(cmd, path=None):
122
122
return False
123
123
124
124
125
+ def require (cmds , suggestions , path = None ):
126
+ """Enforces an executable is in $PATH
127
+ @param cmds list[<str>]:
128
+ List of executable names to check
129
+ @param suggestions list[<str>]:
130
+ Name of module to suggest loading for a given index
131
+ in param cmd.
132
+ @param path list[<str>]]:
133
+ Optional list of PATHs to check [default: $PATH]
134
+ @return None
135
+ """
136
+ error = False
137
+
138
+ for i in range (len (cmds )):
139
+ available = exe_in_path (cmds [i ])
140
+ if not available :
141
+ c = Colors
142
+ error = True
143
+ err (
144
+ "\n {0}{1}Fatal: {2} is not in $PATH and is required during runtime!{3}" .format (c .bg_red , c .white , cmds [i ], c .end ),
145
+ "\n └── Possible solution: please 'module load {0}' and run again!" .format (suggestions [i ])
146
+ )
147
+
148
+ if error : fatal ()
149
+
150
+ return
151
+
152
+
125
153
def permissions (parser , filename , * args , ** kwargs ):
126
154
"""Checks permissions using os.access() to see the user is authorized to access
127
155
a file/directory. Checks for existence, readability, writability and executability via:
@@ -653,7 +681,6 @@ def dryrun(outdir, config='config.json', snakefile=os.path.join('workflow', 'Sna
653
681
'--configfile={}' .format (config )
654
682
], cwd = outdir ,
655
683
stderr = subprocess .STDOUT )
656
-
657
684
except subprocess .CalledProcessError as e :
658
685
# Singularity is NOT in $PATH
659
686
# Tell user to load both main dependencies to avoid the OSError below
@@ -841,6 +868,11 @@ def run(sub_args):
841
868
@param sub_args <parser.parse_args() object>:
842
869
Parsed arguments for run sub-command
843
870
"""
871
+ # Check for required dependencies
872
+ # The pipelines has only two requirements:
873
+ # snakemake and singularity
874
+ require (['snakemake' , 'singularity' ], ['snakemake' , 'singularity' ])
875
+
844
876
# Get PATH to RNA-seek git repository for copying over pipeline resources
845
877
git_repo = os .path .dirname (os .path .abspath (__file__ ))
846
878
@@ -911,6 +943,9 @@ def unlock(sub_args):
911
943
print ("Unlocking the pipeline's output directory..." )
912
944
outdir = sub_args .output
913
945
946
+ # Check for required dependencies: snakemake
947
+ require (['snakemake' ], ['snakemake' ])
948
+
914
949
try :
915
950
unlock_output = subprocess .check_output ([
916
951
'snakemake' , '--unlock' ,
@@ -1037,8 +1072,13 @@ def build(sub_args):
1037
1072
"""Builds the reference files for the RNA-seek pipeline from a genomic FASTA
1038
1073
file and a GTF file. Disclaimer: hybrid genomes not supported.
1039
1074
@param sub_args <parser.parse_args() object>:
1040
- Parsed arguments for unlock sub-command
1075
+ Parsed arguments for build sub-command
1041
1076
"""
1077
+ # Check for required dependencies
1078
+ # The pipelines has only two requirements:
1079
+ # snakemake and singularity
1080
+ require (['snakemake' , 'singularity' ], ['snakemake' , 'singularity' ])
1081
+
1042
1082
# Get PATH to RNA-seek git repository
1043
1083
# for copying over pipeline resources
1044
1084
git_repo = os .path .dirname (os .path .abspath (__file__ ))
@@ -1115,14 +1155,16 @@ def cache(sub_args):
1115
1155
Local SIFs will be created from images defined in 'config/containers/images.json'.
1116
1156
@TODO: add option to cache other shared S3 resources (i.e. kraken db and fqscreen indices)
1117
1157
@param sub_args <parser.parse_args() object>:
1118
- Parsed arguments for unlock sub-command
1158
+ Parsed arguments for cache sub-command
1119
1159
"""
1160
+ # Check for required dependencies: singularity
1161
+ require (['singularity' ], ['singularity' ])
1162
+
1120
1163
sif_cache = sub_args .sif_cache
1121
1164
# Get absolute PATH to templates in rna-seek git repo
1122
1165
repo_path = os .path .dirname (os .path .abspath (__file__ ))
1123
1166
images = os .path .join (repo_path , 'config' ,'containers' , 'images.json' )
1124
1167
1125
-
1126
1168
# Create image cache
1127
1169
if not exists (sif_cache ):
1128
1170
# Pipeline output directory does not exist on filesystem
0 commit comments