From 0d0dcea5978dfb9c4af3676933ef4199fd09dd95 Mon Sep 17 00:00:00 2001
From: Christopher Schmied <schmied@mpi-cbg.de>
Date: Fri, 22 May 2015 12:47:54 +0200
Subject: [PATCH] Added define_xml_czi to snakemake workflow

---
 spim_registration/timelapse/Snakefile         | 26 +++++++++----------
 spim_registration/timelapse/tomancak_czi.json | 25 +++++++++---------
 2 files changed, 26 insertions(+), 25 deletions(-)

diff --git a/spim_registration/timelapse/Snakefile b/spim_registration/timelapse/Snakefile
index 69a0716..a3ab631 100755
--- a/spim_registration/timelapse/Snakefile
+++ b/spim_registration/timelapse/Snakefile
@@ -2,13 +2,13 @@ import os, glob, sys, re
 
 #where are we (can be configured through -d/--directory flag)
 JOBDIR=os.path.abspath(os.path.curdir)
-if JOBDIR[-1] != "/":
+if JOBDIR[-1] != "/": # this checks if jobdir ends with slash if not it adds a slash
    JOBDIR+="/"
 
 #data specific config file, expected to be inside JOBDIR
 configfile: "tomancak_czi.json"
    
-datasets = glob.glob('*00.h5')
+datasets = glob.glob('*00.h5') # searches JOBDIR for files that match this wildcard expression
 
 #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')
@@ -33,14 +33,15 @@ rule done:
     input: [ ds+"_deconvolved" for ds in datasets ]
 
 # add part for defining xml file on czi dataset
-rule define_xml:
-	input: "{czi_base}.czi"
-	output: "{xml_name}.xml"
-	threads: 1
-	message: "Execute define xml with {threads} threads on the following files {input}"
-	log: "define_xml.log"
-	run: cmd_string = produce_string("""{fiji-prefix} {fiji-app} \
-	-Dimage_file_directory={jdir}\
+rule define_xml_czi:
+    input: glob.glob('*.czi')
+    output: config["define_xml_czi"]["first_xml_filename"] + ".xml"
+    threads: 1
+    message: "Execute define xml with {threads} threads on the following files {input}"
+    log: "define_xml.log"
+    run: 
+        cmd_string = produce_string("""{fiji-prefix} {fiji-app} \
+        -Dimage_file_directory={jdir} \
 	-Dfirst_czi={first_czi} \
 	-Dangle_1={angle_1} \
 	-Dangle_2={angle_2} \
@@ -59,10 +60,9 @@ rule define_xml:
 	-- --no-splash {bsh_file}""",
 	config["common"],
 	config["define_xml_czi"],
-	jdir=JOBDIR,
-	output="{output}")
+	jdir=JOBDIR)
 	
-	shell(cmd_string)
+        shell(cmd_string)
 	
 rule registration:
     input: "{xml_base}-{file_id}-00.h5"
diff --git a/spim_registration/timelapse/tomancak_czi.json b/spim_registration/timelapse/tomancak_czi.json
index d5e2031..a328e67 100755
--- a/spim_registration/timelapse/tomancak_czi.json
+++ b/spim_registration/timelapse/tomancak_czi.json
@@ -9,18 +9,19 @@
     
     "define_xml_czi" :
     {
-    	    "pixel_distance_x" : "0.2875535786151886" 	# Manual calibration x
-    	    "pixel_distance_y" : "0.2875535786151886" 	# Manual calibration y
-    	    "pixel_distance_z" : "1.50000" 	# Manual calibration z
-    	    "pixel_unit" : "um"			# unit of manual calibration	    
-    	    "first_czi" : "2015-02-21_LZ1_Stock68_3.czi"
-    	    "angle_1" : "0"
-    	    "angle_2" : "72"
-    	    "angle_3" :"144"
-    	    "angle_4" :"216"
-    	    "angle_5" : "288"
-    	    "illumination_1" : "0"
-    	    "bsh_file" : "define_czi.bsh"    
+    	    "first_xml_filename" : "\"Stock68\"",
+    	    "pixel_distance_x" : "0.2875535786151886",
+    	    "pixel_distance_y" : "0.2875535786151886",
+    	    "pixel_distance_z" : "1.50000", 
+    	    "pixel_unit" : "um",				    
+    	    "first_czi" : "2015-02-21_LZ1_Stock68_3.czi",
+    	    "angle_1" : "0",
+    	    "angle_2" : "72",
+    	    "angle_3" :"144",
+    	    "angle_4" :"216",
+    	    "angle_5" : "288",
+    	    "illumination_1" : "0",
+    	    "bsh_file" : "define_czi.bsh" 
     },
     
     "registration" :
-- 
GitLab