I'm using snakemake for some automation and had a question about determining which rule fails when 'onerror' is called.
I have tried cycling through the rules to determine which outputs don't exist, but the rules aren't ordered correctly.
Here's the code I'm using in onerror:
#find out which rule failed
failed_rule = None
for rulename in dir(rules):
rule = getattr(rules,rulename)
if hasattr(rule,'output'):
output = getattr(rule,'output')
print ('rule: ',rulename, output)
#check if output file exists
if output and (not os.path.exists(str(output))):
failed_rule = rule
print ('Failed rule is ', rulename)
break
Thanks in advance