Commits

Johannes Köster committed 3422894 Merge

Merge branch 'cluster-improvements' of https://bitbucket.org/johanneskoester/snakemake into cluster-improvements

  • Participants
  • Parent commits 0137570, 415401d

Comments (0)

Files changed (4)

File snakemake/jobscript.sh

 #!/bin/sh
-# properties={properties}
+# properties = {properties}
 {workflow.snakemakepath} --snakefile {workflow.snakefile} \
 --force -j{cores} \
 --directory {workdir} --nocolor --notemp --quiet --nolock {job.output} \

File snakemake/utils.py

 __author__ = "Johannes Köster"
 
 import os
+import json
 import io
 import re
 import fnmatch
         raise ValueError(self.errormsg)
 
 
-def read_job_properties(jobscript, prefix="# properties ="):
+def read_job_properties(jobscript, prefix="# properties"):
     with open(jobscript) as jobscript:
         for l in jobscript:
             if l.startswith(prefix):
-                return json.loads(l[len(prefix):])
+                return json.loads(l.split("=")[1])

File tests/test14/qsub.py

+#!/usr/bin/env python3
+import sys
+import os
+import random
+
+from snakemake.utils import read_job_properties
+
+jobscript = sys.argv[1]
+job_properties = read_job_properties(jobscript)
+with open("qsub.log", "w") as log:
+    print(job_properties, file=log)
+
+print(random.randint(1, 100))
+os.system("sh {}".format(jobscript))

File tests/tests.py

 	run(dpath("test13"))
 
 def test14():
-	run(dpath("test14"), snakefile="Snakefile.nonstandard", cluster="./qsub")
+	run(dpath("test14"), snakefile="Snakefile.nonstandard", cluster="./qsub.py")
 
 def test15():
 	run(dpath("test15"))