Commit 4463423e authored by Yi Sun's avatar Yi Sun
Browse files

new module relateobjects

parent 83055059
<tool id="cp-relateobjects" name="RelateObjects Module" version="19.05">
<description>Build pipeline section RelateObjects</description>
<requirements>
<requirement type="package" version="2.7.16">python</requirement>
</requirements>
<macros>
<xml name="distToOtherParents">
<conditional name="con_other_parent_dist">
<param name="calc_dist_to_others" label="Calculate distances to other parents?" display="radio" type="select">
<option value="Yes">Yes</option>
<option value="No">No</option>
</param>
<when value="Yes">
<repeat name="rpt_parent_name" title="Parent Name">
<param name="other_parent_name" type="text" label="Parent name"/>
</repeat>
</when>
</conditional>
</xml>
</macros>
<configfiles>
<inputs name="inputs" filename="input.json" />
<configfile name="test">
import json
import sys
input_json_path=sys.argv[1]
as_dict = json.load(open(input_json_path, "r"))
params=json.dumps(as_dict, indent=4, sort_keys=True)
with open("output","w") as f:
f.write(params)
f.close()
</configfile>
<configfile name="script_file">
import json
import sys
import os
FOURSPACES=" "
NEWLINE="\n"
input_json_path = sys.argv[1]
input_pipeline= sys.argv[2]
params = json.load(open(input_json_path, "r"))
def writero():
f.write(NEWLINE)
f.write("RelateObjects:[module_num:"+str(new_count)+"|svn_version:\\'Unknown\\'|variable_revision_number:5|show_window:False|notes:\\x5B\\x5D|batch_state:array(\\x5B\\x5D, dtype=uint8)|enabled:True|wants_pause:False]"+NEWLINE)
f.write(FOURSPACES+"Parent objects:"+ params['parent_objects']+NEWLINE)
f.write(FOURSPACES+"Child objects:"+ params['child_objects']+NEWLINE)
f.write(FOURSPACES+"Calculate child-parent distances?:"+ params['con_dist']['calc_dist']+NEWLINE)
f.write(FOURSPACES+"Calculate per-parent means for all child measurements?:"+ params['means_for_all']+NEWLINE)
dist_others = params['con_dist']['con_other_parent_dist']['calc_dist_to_others']
f.write(FOURSPACES+"Calculate distances to other parents?:"+dist_others+NEWLINE)
name_flag = params['con_save_child']['save_child_as_new']
f.write(FOURSPACES+"Do you want to save the children with parents as a new object set?:"+name_flag+NEWLINE)
if name_flag == "Yes":
f.write(FOURSPACES+"Name the output object:" + params['con_save_child']['name_output']+NEWLINE)
else:
f.write(FOURSPACES+"Name the output object:None"+NEWLINE)
if dist_others == "Yes":
for pname in params['con_dist']['con_other_parent_dist']['rpt_parent_name']:
f.write(FOURSPACES+"Parent name:"+ pname['other_parent_name']+NEWLINE)
with open(input_pipeline) as fin:
lines = fin.readlines()
k,v= lines[4].strip().split(':')
module_count = int(v)
new_count = module_count+1
lines[4]= k+":"+str(new_count)+"\n"
with open("output","w") as f:
f.writelines(lines)
writero()
f.close()
</configfile>
</configfiles>
<command><![CDATA[
python $script_file $inputs $input_pipeline
]]></command>
<inputs>
<param name="input_pipeline" type="data" label="Select pipeline file from previous moudle"/>
<param name="parent_objects" label="Parent objects" type="text"/>
<param name="child_objects" label="Child objects" type="text" />
<param name="means_for_all" label="Calculate per-parent means for all child measurements?:" display="radio" type="select">
<option value="Yes">Yes</option>
<option value="No">No</option>
</param>
<conditional name="con_dist">
<param name="calc_dist" label="Calculate child-parent distances?" type="select">
<option value="None">None</option>
<option value="Centroid">Centroid</option>
<option value="Minimum">Minimum</option>
<option value="Both">Both</option>
</param>
<when value="Centroid">
<expand macro="distToOtherParents" />
</when>
<when value="Minimum">
<expand macro="distToOtherParents" />
</when>
<when value="Both">
<expand macro="distToOtherParents" />
</when>
</conditional>
<conditional name="con_save_child">
<param name="save_child_as_new" label="Do you want to save the children with parents as a new object set?" display="radio" type="select">
<option value="Yes">Yes</option>
<option value="No">No</option>
</param>
<when value="Yes">
<param name="name_output" type="text" label="Name the output object"/>
</when>
</conditional>
</inputs>
<outputs>
<data name="out_file" from_work_dir="output" format="txt" hidden="false">
</data>
</outputs>
<stdio>
<exit_code range="1:" level="fatal" description="Error occured"/>
</stdio>
<tests>
</tests>
<help>
This tool builds a Cellprofiler pipeline with RelateObjects module
</help>
</tool>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment