exports measurements into one or more files
macros.xml
import json
import sys
import os
FOURSPACES=@SPACES@
input_json_path = sys.argv[1]
input_pipeline= sys.argv[2]
params = json.load(open(input_json_path, "r"))
def write_etss():
_str = "\nExportToSpreadsheet:[module_num:%d|svn_version:\\'Unknown\\'|variable_revision_number:12|show_window:True|notes:\\x5B\\x5D|batch_state:array(\\x5B\\x5D, dtype=uint8)|enabled:True|wants_pause:False]\n" % new_count
_str += FOURSPACES + "Select the column delimiter:%s\n" % params["delimiter"]
_str += FOURSPACES + "Add image metadata columns to your object data file?:%s\n" % params["add_metadata_column_to_object"]
measurement = params["con_measurement_export"]
_str += FOURSPACES + "Select the measurements to export:%s\n" % measurement['export_measurement']
_str += FOURSPACES + "Calculate the per-image mean values for object measurements?:%s\n" % params['calc_mean']
_str += FOURSPACES + "Calculate the per-image median values for object measurements?:%s\n" % params['calc_median']
_str += FOURSPACES + "Calculate the per-image standard deviation values for object measurements?:%s\n" % params['calc_standard_deviation']
_str += FOURSPACES + "Output file location:%s\\x7C\n" % params['output_file_location']
create_gene = params["con_create_gene_pattern"]["create_gene_pattern"]
if create_gene == "No":
_str += FOURSPACES + "Create a GenePattern GCT file?:%s\n" % create_gene
_str += FOURSPACES + "Select source of sample row name:Metadata\n"
_str += FOURSPACES + "Select the image to use as the identifier:None\n"
_str += FOURSPACES + "Select the metadata to use as the identifier:None\n"
else:
_str += FOURSPACES + "Create a GenePattern GCT file?:%s\n" % create_gene
_str += FOURSPACES + "Select the image to use as the identifier:None\n"
_str += FOURSPACES + "Select the metadata to use as the identifier:None\n"
export_all_measurements = params["con_export_all_measurements"]["export_all_measurements"]
if export_all_measurements == "Yes":
_str += FOURSPACES + "Export all measurement types?:%s\n" % export_all_measurements
if 'select_measurements' in params['con_measurement_export']:
_str += FOURSPACES + "Press button to select measurements:%s\n" % params['con_measurement_export']['select_measurements']
else:
_str += FOURSPACES + "Press button to select measurements:\n"
_str += FOURSPACES + "Representation of Nan/Inf:%s\n" % params["represent_nan"]
_str += FOURSPACES + "Add a prefix to file names?:%s\n" % params["con_prefix"]["add_prefix"]
if "filename_prefix" in params["con_prefix"]:
_str += FOURSPACES + "Filename prefix:%s\n" % params["con_prefix"]["filename_prefix"]
else:
_str += FOURSPACES + "Filename prefix:MyPrefix_\n"
_str += FOURSPACES + "Overwrite existing files without warning?:%s\n" % params["overwrite_existing_file"]
if export_all_measurements == "Yes":
_str += FOURSPACES + "Data to export:Do not use\n"
_str += FOURSPACES + "Combine these object measurements with those of the previous object?:No\n"
_str += FOURSPACES + "File name:DATA.csv\n"
_str += FOURSPACES + "Use the object name for the file name?:Yes\n"
else:
_str += FOURSPACES + "Data to export:%s\n" % params["con_export_all_measurements"]["data_to_export"]
return _str
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 + ":%d\n" % new_count
with open("output", "w") as f:
f.writelines(lines)
f.write(write_etss())
f.close()