Skip to content
Snippets Groups Projects
Commit 9119b5ec authored by Peter Steinbach's avatar Peter Steinbach
Browse files

fixed malformed json in cluster config, added regexp magic to snakefile

parent 1cad3b4e
No related branches found
No related tags found
No related merge requests found
import os, glob, sys import os, glob, sys, re
#where are we
if "datadir" not in config.keys():
JOBDIR=os.path.abspath(os.path.curdir)
else:
if os.path.isdir(config['datadir']):
JOBDIR=config['datadir']
else:
print("given data dir does not exist {data}".format(data=config['datadir']))
sys.exit(1)
#where are we (can be configured through -d/--directory flag)
JOBDIR=os.path.abspath(os.path.curdir)
if JOBDIR[-1] != "/": if JOBDIR[-1] != "/":
JOBDIR+="/" JOBDIR+="/"
datasets = glob.glob('*00.h5')
#data specific config file #data specific config file, expected to be inside JOBDIR
configfile: "tomancak.json" configfile: "tomancak.json"
datasets = glob.glob('*00.h5')
#TODO: this should go into a python module in this path
fre = re.compile(r'(?P<xml_base>\w+)-(?P<file_id>\d+)-00.h5')
xml_merge_in = []
for ds in datasets:
bn = os.path.basename(ds)
bn_res = fre.search(bn)
xml_base,file_id = bn_res.group('xml_base'),bn_res.group('file_id')
xml_merge_in.append("{xbase}.job_{fid}.xml".format(xbase=xml_base, fid=file_id))
#TODO: this should go into a python module in this path
def produce_string(_fstring, *args, **kwargs): def produce_string(_fstring, *args, **kwargs):
contents = dict() contents = dict()
for item in args: for item in args:
...@@ -28,12 +30,11 @@ def produce_string(_fstring, *args, **kwargs): ...@@ -28,12 +30,11 @@ def produce_string(_fstring, *args, **kwargs):
return _fstring.format(**contents) return _fstring.format(**contents)
rule done: rule done:
input: [ ds+"-deconvolved" for ds in datasets ] input: [ ds+"_deconvolved" for ds in datasets ]
rule registration: rule registration:
input: "{xml_base}-{file_id,\d+}-00.h5" input: "{xml_base}-{file_id,\d+}-00.h5"
output: "{xml_base}-{file_id,\d+}-00.h5_registered", #convenience files output: "{xml_base}.job_{file_id,\d+}.xml"
"{xml_base}.job_{file_id,\d+}.xml"
log: "{xml_base}-{file_id,\d+}-registration.log" log: "{xml_base}-{file_id,\d+}-registration.log"
run: run:
cmd_string = produce_string( cmd_string = produce_string(
...@@ -73,30 +74,31 @@ rule registration: ...@@ -73,30 +74,31 @@ rule registration:
jdir=JOBDIR, jdir=JOBDIR,
input_xml="{wildcards.xml_base}") input_xml="{wildcards.xml_base}")
cmd_string += "> {log} 2>&1 && touch {output}" cmd_string += "> {log} 2>&1 && touch {output}"
shell(cmd_string) shell(cmd_string)
#shell("touch {output}") #shell("touch {output}")
rule xml_merge: rule xml_merge:
input: [ item+"_registered" for item in datasets ] input: xml_merge_in
output: "{xml_base}_merge.xml" output: "{xml_base}_merge.xml"
log: "{xml_base}_merge.log" log: "{xml_base}_merge.log"
run: run:
cmd_string = produce_string("{fiji-prefix} {fiji-app} -Dimage_file_directory={jdir} -Dmerged_xml={merged_xml} -- --no-splash {bsh_file} > {log} 2>&1", cmd_string = produce_string("{fiji-prefix} {fiji-app} -Dimage_file_directory={jdir} -Dmerged_xml={output} -- --no-splash {bsh_file} > {log} 2>&1",
config["common"], config["common"],
config["xml_merge"], config["xml_merge"],
log="{log}", log="{log}",
jdir=JOBDIR) jdir=JOBDIR,
output="{output}")
shell(cmd_string) shell(cmd_string)
rule external_trafo: rule external_trafo:
input: rules.xml_merge.output input: rules.xml_merge.output
output: rules.xml_merge.output[0] + "_external_trafo" output: rules.xml_merge.output[0] + "_external_trafo"
log: "external_trafo.log" log: "external_trafo.log"
# message: "etrafo {input} -> {output}"
run: run:
cmd_string = produce_string("""{fiji-prefix} {fiji-app} \ cmd_string = produce_string("""{fiji-prefix} {fiji-app} \
-Dimage_file_directory={jdir} \ -Dimage_file_directory={jdir} \
-Dmerged_xml={merged_xml} \ -Dmerged_xml={input} \
-Dtransform_angle={angle} \ -Dtransform_angle={angle} \
-Dtransform_channel={channel} \ -Dtransform_channel={channel} \
-Dtransform_illumination={illumination} \ -Dtransform_illumination={illumination} \
...@@ -108,19 +110,20 @@ rule external_trafo: ...@@ -108,19 +110,20 @@ rule external_trafo:
-- --no-splash {bsh_file}""", -- --no-splash {bsh_file}""",
config["common"], config["common"],
config["external_transform"], config["external_transform"],
jdir=JOBDIR) jdir=JOBDIR,
input="{input}")
cmd_string += "> {log} 2>&1 && touch {output}" cmd_string += "> {log} 2>&1 && touch {output}"
shell(cmd_string) shell(cmd_string)
rule deconvolution: rule deconvolution:
input: rules.external_trafo.output, "{xml_base}-{file_id,\d+}-00.h5" input: rules.external_trafo.output, "{xml_base}-{file_id,\d+}-00.h5", merged_xml="{xml_base}_merge.xml"
output: "{xml_base}-{file_id,\d+}-00.h5-deconvolved" output: "{xml_base}-{file_id,\d+}-00.h5_deconvolved"
log: "{xml_base}-{file_id,\d+}-00.h5-deconvolution.log" log: "{xml_base}-{file_id,\d+}-00-deconvolution.log"
run: run:
cmd_string = produce_string("""{fiji-prefix} {fiji-app} \ cmd_string = produce_string("""{fiji-prefix} {fiji-app} \
-Dimage_file_directory={jdir} \ -Dimage_file_directory={jdir} \
-Ddeco_output_file_directory={jdir} \ -Ddeco_output_file_directory={jdir} \
-Dmerged_xml={merged_xml} \ -Dmerged_xml={merged_xml_file} \
-Dparallel_timepoints={file_id_w} \ -Dparallel_timepoints={file_id_w} \
-Dprocess_timepoint={process_timepoint} \ -Dprocess_timepoint={process_timepoint} \
-Dprocess_channel={process_channel} \ -Dprocess_channel={process_channel} \
...@@ -145,13 +148,15 @@ rule deconvolution: ...@@ -145,13 +148,15 @@ rule deconvolution:
-Dpsf_size_y={psf_size_y} \ -Dpsf_size_y={psf_size_y} \
-Dpsf_size_z={psf_size_z} \ -Dpsf_size_z={psf_size_z} \
-Diterations={iterations} \ -Diterations={iterations} \
-- --no-splash {bsh_file}""", -- --no-splash {bsh_file}""",
config["common"], config["common"],
config["deconvolution"], config["deconvolution"],
file_id_w="{wildcards.file_id}", file_id_w="{wildcards.file_id}",
jdir=JOBDIR) jdir=JOBDIR,
merged_xml_file="{input.merged_xml}"
)
cmd_string += "> {log} 2>&1 && touch {output}" cmd_string += "> {log} 2>&1 && touch {output}"
shell(cmd_string) shell(cmd_string)
rule clean: rule distclean:
shell : "rm -rf *registered" shell : "rm -rf *registered *tif "+str(" ".join(xml_merge_in))
{ {
"__default__" : "__default__" :
{ {
"fiji-app" : "/projects/pilot_spim/Christopher/Test_pipeline_3.0/test_unicore/unicore_jobs/Fiji.app.cuda_new/ImageJ-linux64",
"fiji-good-4-resave" : "/sw/users/schmied/lifeline/Fiji.app.lifeline2/ImageJ-linux64",
"fiji-good-4-deconv" : "/projects/pilot_spim/Christopher/Test_pipeline_3.0/test_unicore/unicore_jobs/Fiji.app.cuda_new/ImageJ-linux64",
"fiji-prefix" : "/sw/bin/xvfb-run -a",
"lsf_extra" : "-R span[hosts=1]", "lsf_extra" : "-R span[hosts=1]",
"lsf_queue" : "short" "lsf_q" : "short"
}, },
"registration" : "registration" :
{ {
"lsf_extra" : "-R span[hosts=1] -R rusage[mem=100000]", "lsf_extra" : "-R span[hosts=1] -R rusage[mem=100000]"
"lsf_queue" : "gpu"
}, },
"produce" : "external_trafo" :
{ {
"lsf_queue" : "short" "lsf_extra" : "-R span[hosts=1] -R rusage[mem=10000]"
},
"deconvolution" :
{
"lsf_extra" : "-n 7 -R span[hosts=1] -R rusage[mem=50000]",
"lsf_q" : "gpu"
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment