# HG changeset patch # User bgruening # Date 1699176489 0 # Node ID eb6c0871424454e216a9a84377a71575dd2421ff # Parent 0e4dccaafef540d129de02384febd40ac7e32770 planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 57a0433defa3cbc37ab34fbb0ebcfaeb680db8d5 diff -r 0e4dccaafef5 -r eb6c08714244 cellprofiler.xml --- a/cellprofiler.xml Fri Feb 26 14:10:34 2021 +0000 +++ b/cellprofiler.xml Sun Nov 05 09:28:09 2023 +0000 @@ -1,14 +1,21 @@ - - run a CellProfiler pipeline + + with CellProfiler 3 macros.xml - 0 + 1 + + operation_3443 + + + CellProfiler + cellprofiler + .*)_(?P\x5BA-P\x5D\x5B0-9\x5D{2})_s(?P\x5B0-9\x5D)_w(?P\x5B0-9\x5D)\n" - _str += FOURSPACES + "Regular expression to extract from folder name:(?P\x5B0-9\x5D{4}_\x5B0-9\x5D{2}_\x5B0-9\x5D{2})$\n" + _str += ( + FOURSPACES + "Metadata extraction method:Extract from file/folder names\n" + ) + _str += ( + FOURSPACES + + "Regular expression to extract from file name:^(?P.*)_(?P\x5BA-P\x5D\x5B0-9\x5D{2})_s(?P\x5B0-9\x5D)_w(?P\x5B0-9\x5D)\n" + ) + _str += ( + FOURSPACES + + "Regular expression to extract from folder name:(?P\x5B0-9\x5D{4}_\x5B0-9\x5D{2}_\x5B0-9\x5D{2})$\n" + ) _str += FOURSPACES + "Extract metadata from:All images\n" - _str += FOURSPACES + "Select the filtering criteria:and (file does contain \"\")\n" + _str += ( + FOURSPACES + 'Select the filtering criteria:and (file does contain "")\n' + ) _str += FOURSPACES + "Metadata file location:\n" _str += FOURSPACES + "Match file and image metadata:\x5B\x5D\n" _str += FOURSPACES + "Use case insensitive matching?:No\n" else: - _str += FOURSPACES + "Metadata data type:Text\n" # default Text,not possible to select in Galaxy + _str += ( + FOURSPACES + "Metadata data type:Text\n" + ) # default Text,not possible to select in Galaxy _str += FOURSPACES + "Metadata types:{}\n" _str += FOURSPACES + "Extraction method count:%d\n" % method_count for methods in metadata_extraction["extraction_method"]: - _str += FOURSPACES + "Metadata extraction method:%s\n" % methods["metadata_extraction_method"] - _str += FOURSPACES + "Metadata source:%s\n" % methods["con_metadata_source"]["metadata_source"] + _str += ( + FOURSPACES + + "Metadata extraction method:%s\n" + % methods["metadata_extraction_method"] + ) + _str += ( + FOURSPACES + + "Metadata source:%s\n" + % methods["con_metadata_source"]["metadata_source"] + ) if "file_name_regex" in methods["con_metadata_source"]: file_regex = methods["con_metadata_source"]["file_name_regex"] @@ -63,24 +86,62 @@ file_regex = "(?P.*)_(?P[a-zA-Z0-9]+)" folder_regex = "(?P.*)" - _str += FOURSPACES + "Regular expression to extract from file name:%s\n" % file_regex - _str += FOURSPACES + "Regular expression to extract from folder name:%s\n" % folder_regex + _str += ( + FOURSPACES + + "Regular expression to extract from file name:%s\n" % file_regex + ) + _str += ( + FOURSPACES + + "Regular expression to extract from folder name:%s\n" % folder_regex + ) - _str += FOURSPACES + "Extract metadata from:%s\n" % methods["con_metadata_extract_from"]["extract_metadata_from"] + _str += ( + FOURSPACES + + "Extract metadata from:%s\n" + % methods["con_metadata_extract_from"]["extract_metadata_from"] + ) - if methods["con_metadata_extract_from"]["extract_metadata_from"] == "Images matching a rule": + if ( + methods["con_metadata_extract_from"]["extract_metadata_from"] + == "Images matching a rule" + ): rule_str = "" for r in methods["con_metadata_extract_from"]["r_match"]: if r["con_match"]["rule_type"] == "extension": - rule_str += " (" + r["con_match"]["rule_type"] + " " + r["con_match"]["operator"] + " " + \ - r["con_match"]["match_type"] + ")" + rule_str += ( + " (" + + r["con_match"]["rule_type"] + + " " + + r["con_match"]["operator"] + + " " + + r["con_match"]["match_type"] + + ")" + ) else: - rule_str += " (" + r["con_match"]["rule_type"] + " " + r["con_match"]["operator"] + " " +\ - r["con_match"]["contain"] + " \"" + r["con_match"]["match_value"] + "\")" + rule_str += ( + " (" + + r["con_match"]["rule_type"] + + " " + + r["con_match"]["operator"] + + " " + + r["con_match"]["contain"] + + ' "' + + r["con_match"]["match_value"] + + '")' + ) - _str += FOURSPACES + "Select the filtering criteria:" + methods["con_metadata_extract_from"]["match_all_any"] + rule_str + "\n" + _str += ( + FOURSPACES + + "Select the filtering criteria:" + + methods["con_metadata_extract_from"]["match_all_any"] + + rule_str + + "\n" + ) else: - _str += FOURSPACES + "Select the filtering criteria:and (file does contain \"\")\n" # this line is required even if it's not used + _str += ( + FOURSPACES + + 'Select the filtering criteria:and (file does contain "")\n' + ) # this line is required even if it's not used _str += FOURSPACES + "Metadata file location:\n" _str += FOURSPACES + "Match file and image metadata:\x5B\x5D\n" @@ -90,20 +151,30 @@ def write_nameandtypes(): - nameandtypes = params['nameandtypes'] - assign_a_name = nameandtypes['con_assign_a_name_to']['assign_a_name_to'] + nameandtypes = params["nameandtypes"] + assign_a_name = nameandtypes["con_assign_a_name_to"]["assign_a_name_to"] - if "con_select_image_type" in nameandtypes['con_assign_a_name_to']: - con_set_intensity = nameandtypes['con_assign_a_name_to']['con_select_image_type']['con_set_intensity'] - max_intensity = con_set_intensity['maximum_intensity'] if "maximum_intensity" in con_set_intensity else 255.0 + if "con_select_image_type" in nameandtypes["con_assign_a_name_to"]: + con_set_intensity = nameandtypes["con_assign_a_name_to"][ + "con_select_image_type" + ]["con_set_intensity"] + max_intensity = ( + con_set_intensity["maximum_intensity"] + if "maximum_intensity" in con_set_intensity + else 255.0 + ) else: max_intensity = 255.0 - pixel_space = nameandtypes['pixel_space'] + pixel_space = nameandtypes["pixel_space"] - rule_count = len(nameandtypes['con_assign_a_name_to']['r_match_rule']) if "r_match_rule" in nameandtypes['con_assign_a_name_to'] else 1 + rule_count = ( + len(nameandtypes["con_assign_a_name_to"]["r_match_rule"]) + if "r_match_rule" in nameandtypes["con_assign_a_name_to"] + else 1 + ) - process_3d = nameandtypes['pixel_space']['process_3d'] + process_3d = nameandtypes["pixel_space"]["process_3d"] x_spacing = 1.0 if "x_spacing" not in pixel_space else pixel_space["x_spacing"] y_spacing = 1.0 if "y_spacing" not in pixel_space else pixel_space["y_spacing"] z_spacing = 1.0 if "z_spacing" not in pixel_space else pixel_space["z_spacing"] @@ -113,12 +184,26 @@ _str += FOURSPACES + "Assign a name to:%s\n" % assign_a_name if assign_a_name == "All images": - _str += FOURSPACES + "Select the image type:%s\n" % nameandtypes['con_assign_a_name_to']['con_select_image_type']['select_image_type'] - _str += FOURSPACES + "Name to assign these images:%s\n" % nameandtypes['con_assign_a_name_to']['name_to_assign'] + _str += ( + FOURSPACES + + "Select the image type:%s\n" + % nameandtypes["con_assign_a_name_to"]["con_select_image_type"][ + "select_image_type" + ] + ) + _str += ( + FOURSPACES + + "Name to assign these images:%s\n" + % nameandtypes["con_assign_a_name_to"]["name_to_assign"] + ) _str += FOURSPACES + "Match metadata:[]\n" _str += FOURSPACES + "Image set matching method:Order\n" - _str += FOURSPACES + "Set intensity range from:%s\n" % con_set_intensity['set_intensity_range_from'] + _str += ( + FOURSPACES + + "Set intensity range from:%s\n" + % con_set_intensity["set_intensity_range_from"] + ) _str += FOURSPACES + "Assignments count:%s\n" % rule_count _str += FOURSPACES + "Single images count:0\n" _str += FOURSPACES + "Maximum intensity:%.1f\n" % max_intensity @@ -130,7 +215,11 @@ _str += FOURSPACES + "Name to assign these images:DNA\n" _str += FOURSPACES + "Match metadata:[]\n" - _str += FOURSPACES + "Image set matching method:%s\n" % nameandtypes['con_assign_a_name_to']['matching_method'] + _str += ( + FOURSPACES + + "Image set matching method:%s\n" + % nameandtypes["con_assign_a_name_to"]["matching_method"] + ) _str += FOURSPACES + "Set intensity range from:Image metadata\n" _str += FOURSPACES + "Assignments count:%d\n" % rule_count _str += FOURSPACES + "Single images count:0\n" @@ -147,36 +236,77 @@ rule_str = "" if len(rule["r_match"]) > 0: for r in rule["r_match"]: - if r["con_match"]["rule_type"] == "file" or r["con_match"]["rule_type"] == "directory": - rule_str += " (" + r["con_match"]["rule_type"] + " " + r["con_match"]["operator"] + " " + \ - r["con_match"]["contain"] + " \"" + r["con_match"]["match_value"] + "\")" + if ( + r["con_match"]["rule_type"] == "file" + or r["con_match"]["rule_type"] == "directory" + ): + rule_str += ( + " (" + + r["con_match"]["rule_type"] + + " " + + r["con_match"]["operator"] + + " " + + r["con_match"]["contain"] + + ' "' + + r["con_match"]["match_value"] + + '")' + ) else: - rule_str += " (" + r["con_match"]["rule_type"] + " " + r["con_match"]["operator"] + " " + \ - r["con_match"]["match_type"] + ")" + rule_str += ( + " (" + + r["con_match"]["rule_type"] + + " " + + r["con_match"]["operator"] + + " " + + r["con_match"]["match_type"] + + ")" + ) else: - rule_str = " (file does contain \"\")" # need to have a value even if it is not used + rule_str = ' (file does contain "")' # need to have a value even if it is not used - _str += FOURSPACES + "Select the rule criteria:" + rule["match_all_any"] + rule_str + "\n" + _str += ( + FOURSPACES + + "Select the rule criteria:" + + rule["match_all_any"] + + rule_str + + "\n" + ) img_or_obj = rule["con_select_image_type"]["select_image_type"] if img_or_obj == "Objects": _str += FOURSPACES + "Name to assign these images:DNA\n" - _str += FOURSPACES + "Name to assign these objects:%s\n" % rule["con_select_image_type"]["name_to_assign"] + _str += ( + FOURSPACES + + "Name to assign these objects:%s\n" + % rule["con_select_image_type"]["name_to_assign"] + ) else: - _str += FOURSPACES + "Name to assign these images:%s\n" % rule["con_select_image_type"]["name_to_assign"] + _str += ( + FOURSPACES + + "Name to assign these images:%s\n" + % rule["con_select_image_type"]["name_to_assign"] + ) _str += FOURSPACES + "Name to assign these objects:Cell\n" _str += FOURSPACES + "Select the image type:%s\n" % img_or_obj intensity_range = "Image metadata" # default value if img_or_obj == "Grayscale image" or img_or_obj == "Color image": - intensity_range = rule["con_select_image_type"]["con_set_intensity"]["set_intensity_range_from"] + intensity_range = rule["con_select_image_type"]["con_set_intensity"][ + "set_intensity_range_from" + ] _str += FOURSPACES + "Set intensity range from:%s\n" % intensity_range if intensity_range == "Manual": - _str += FOURSPACES + "Maximum intensity:%s\n" % rule["con_select_image_type"]["con_set_intensity"]["maximum_intensity"] + _str += ( + FOURSPACES + + "Maximum intensity:%s\n" + % rule["con_select_image_type"]["con_set_intensity"][ + "maximum_intensity" + ] + ) else: _str += FOURSPACES + "Maximum intensity:255.0\n" @@ -184,9 +314,9 @@ def write_groups(): - groups = params['groups'] + groups = params["groups"] - _str = "\nGroups:[module_num:4|svn_version:\\'Unknown\\'|variable_revision_number:2|show_window:False|notes:\\x5B\\\'The Groups module optionally allows you to split your list of images into image subsets (groups) which will be processed independently of each other. Examples of groupings include screening batches, microtiter plates, time-lapse movies, etc.\\'\\x5D|batch_state:array(\\x5B\\x5D, dtype=uint8)|enabled:True|wants_pause:False]\n" + _str = "\nGroups:[module_num:4|svn_version:\\'Unknown\\'|variable_revision_number:2|show_window:False|notes:\\x5B\\'The Groups module optionally allows you to split your list of images into image subsets (groups) which will be processed independently of each other. Examples of groupings include screening batches, microtiter plates, time-lapse movies, etc.\\'\\x5D|batch_state:array(\\x5B\\x5D, dtype=uint8)|enabled:True|wants_pause:False]\n" group_images = groups["con_groups"]["group_images"] @@ -194,7 +324,10 @@ _str += FOURSPACES + "grouping metadata count:1\n" if group_images == "Yes": - _str += FOURSPACES + "Metadata category:%s\n" % groups["con_groups"]["group_category"] + _str += ( + FOURSPACES + + "Metadata category:%s\n" % groups["con_groups"]["group_category"] + ) else: _str += FOURSPACES + "Metadata category:None\n" @@ -202,13 +335,15 @@ with open("output.cppipe", "w") as f: - headers = ["CellProfiler Pipeline: http://www.cellprofiler.org\n", - "Version:3\n", - "DateRevision:319\n", - "GitHash:\n", - "ModuleCount:4\n", - "HasImagePlaneDetails:False", - "\n"] + headers = [ + "CellProfiler Pipeline: http://www.cellprofiler.org\n", + "Version:3\n", + "DateRevision:319\n", + "GitHash:\n", + "ModuleCount:4\n", + "HasImagePlaneDetails:False", + "\n", + ] f.writelines(headers) diff -r 0e4dccaafef5 -r eb6c08714244 tile.py --- a/tile.py Fri Feb 26 14:10:34 2021 +0000 +++ b/tile.py Sun Nov 05 09:28:09 2023 +0000 @@ -3,85 +3,100 @@ import argparse import json -from cp_common_functions import get_json_value -from cp_common_functions import get_pipeline_lines -from cp_common_functions import get_total_number_of_modules -from cp_common_functions import INDENTATION -from cp_common_functions import update_module_count -from cp_common_functions import write_pipeline - +from cp_common_functions import (get_json_value, + get_pipeline_lines, + get_total_number_of_modules, + INDENTATION, update_module_count, + write_pipeline) MODULE_NAME = "Tile" OUTPUT_FILENAME = "output.cppipe" def build_header(module_name, module_number): - result = "|".join([f"{module_name}:[module_num:{module_number}", - "svn_version:\\'Unknown\\'", - "variable_revision_number:1", - "show_window:True", - "notes:\\x5B\\'Tile the original color image, the outlined image and the image of tracked labels together.\\'\\x5D", - "batch_state:array(\\x5B\\x5D, dtype=uint8)", - "enabled:True", - "wants_pause:False]\n"]) + result = "|".join( + [ + f"{module_name}:[module_num:{module_number}", + "svn_version:\\'Unknown\\'", + "variable_revision_number:1", + "show_window:True", + "notes:\\x5B\\'Tile the original color image, the outlined image and the image of tracked labels together.\\'\\x5D", + "batch_state:array(\\x5B\\x5D, dtype=uint8)", + "enabled:True", + "wants_pause:False]\n", + ] + ) return result def build_main_block(input_params): - result = INDENTATION.join([f"{INDENTATION}Select an input image:{get_json_value(input_params,'input_image')}\n", - f"Name the output image:{get_json_value(input_params,'output_image_name')}\n", - f"Tile assembly method:{get_json_value(input_params,'con_assembly_method.assembly_method')}\n" - ]) + result = INDENTATION.join( + [ + f"{INDENTATION}Select an input image:{get_json_value(input_params,'input_image')}\n", + f"Name the output image:{get_json_value(input_params,'output_image_name')}\n", + f"Tile assembly method:{get_json_value(input_params,'con_assembly_method.assembly_method')}\n", + ] + ) - calc_rows = get_json_value(input_params, 'con_assembly_method.con_calc_no_row.calc_no_row') + calc_rows = get_json_value( + input_params, "con_assembly_method.con_calc_no_row.calc_no_row" + ) no_of_rows = 8 - calc_cols = get_json_value(input_params, 'con_assembly_method.con_calc_no_cols.calc_no_cols') + calc_cols = get_json_value( + input_params, "con_assembly_method.con_calc_no_cols.calc_no_cols" + ) no_of_cols = 12 if calc_rows == "No": - no_of_rows = get_json_value(input_params, 'con_assembly_method.con_calc_no_row.no_of_row') + no_of_rows = get_json_value( + input_params, "con_assembly_method.con_calc_no_row.no_of_row" + ) if calc_cols == "No": - no_of_cols = get_json_value(input_params, 'con_assembly_method.con_calc_no_cols.no_of_cols') + no_of_cols = get_json_value( + input_params, "con_assembly_method.con_calc_no_cols.no_of_cols" + ) - corner_to_begin = get_json_value(input_params, 'con_assembly_method.corner_to_begin') - direction_tiling = get_json_value(input_params, 'con_assembly_method.direction') - meander = get_json_value(input_params, 'con_assembly_method.meander_mode') + corner_to_begin = get_json_value( + input_params, "con_assembly_method.corner_to_begin" + ) + direction_tiling = get_json_value(input_params, "con_assembly_method.direction") + meander = get_json_value(input_params, "con_assembly_method.meander_mode") - assembly_method = get_json_value(input_params, 'con_assembly_method.assembly_method') + assembly_method = get_json_value( + input_params, "con_assembly_method.assembly_method" + ) result += INDENTATION.join( - [f"{INDENTATION}Final number of rows:{str(no_of_rows)}\n", - f"Final number of columns:{str(no_of_cols)}\n", - f"Image corner to begin tiling:{corner_to_begin}\n", - f"Direction to begin tiling:{direction_tiling}\n", - f"Use meander mode?:{meander}\n", - f"Automatically calculate number of rows?:{calc_rows}\n", - f"Automatically calculate number of columns?:{calc_cols}\n" - ]) + [ + f"{INDENTATION}Final number of rows:{str(no_of_rows)}\n", + f"Final number of columns:{str(no_of_cols)}\n", + f"Image corner to begin tiling:{corner_to_begin}\n", + f"Direction to begin tiling:{direction_tiling}\n", + f"Use meander mode?:{meander}\n", + f"Automatically calculate number of rows?:{calc_rows}\n", + f"Automatically calculate number of columns?:{calc_cols}\n", + ] + ) if assembly_method == "Within cycles": - additionals = input_params['con_assembly_method']['rpt_additional_image'] + additionals = input_params["con_assembly_method"]["rpt_additional_image"] for img in additionals: result += INDENTATION.join( - [f"{INDENTATION}Select an additional image to tile:{get_json_value(img, 'additional_img')}\n" - ]) + [ + f"{INDENTATION}Select an additional image to tile:{get_json_value(img, 'additional_img')}\n" + ] + ) result = result.rstrip("\n") return result if __name__ == "__main__": parser = argparse.ArgumentParser() - parser.add_argument( - '-p', '--pipeline', - help='CellProfiler pipeline' - ) - parser.add_argument( - '-i', '--inputs', - help='JSON inputs from Galaxy' - ) + parser.add_argument("-p", "--pipeline", help="CellProfiler pipeline") + parser.add_argument("-i", "--inputs", help="JSON inputs from Galaxy") args = parser.parse_args() pipeline_lines = get_pipeline_lines(args.pipeline) diff -r 0e4dccaafef5 -r eb6c08714244 track_objects.py --- a/track_objects.py Fri Feb 26 14:10:34 2021 +0000 +++ b/track_objects.py Sun Nov 05 09:28:09 2023 +0000 @@ -3,68 +3,95 @@ import argparse import json -from cp_common_functions import get_json_value -from cp_common_functions import get_pipeline_lines -from cp_common_functions import get_total_number_of_modules -from cp_common_functions import INDENTATION -from cp_common_functions import update_module_count -from cp_common_functions import write_pipeline +from cp_common_functions import (get_json_value, + get_pipeline_lines, + get_total_number_of_modules, + INDENTATION, update_module_count, + write_pipeline) MODULE_NAME = "TrackObjects" OUTPUT_FILENAME = "output.cppipe" def build_header(module_name, module_number): - result = "|".join([f"{module_name}:[module_num:{module_number}", - "svn_version:\\'Unknown\\'", - "variable_revision_number:7", - "show_window:True", - "notes:\\x5B\\'Track the embryos across images using the Overlap method\\x3A tracked objects are identified by the amount of frame-to-frame overlap. Save an image of embryos labeled with a unique number across time.\\'\\x5D", - "batch_state:array(\\x5B\\x5D, dtype=uint8)", - "enabled:True", - "wants_pause:False]\n"]) + result = "|".join( + [ + f"{module_name}:[module_num:{module_number}", + "svn_version:\\'Unknown\\'", + "variable_revision_number:7", + "show_window:True", + "notes:\\x5B\\'Track the embryos across images using the Overlap method\\x3A tracked objects are identified by the amount of frame-to-frame overlap. Save an image of embryos labeled with a unique number across time.\\'\\x5D", + "batch_state:array(\\x5B\\x5D, dtype=uint8)", + "enabled:True", + "wants_pause:False]\n", + ] + ) return result def build_main_block(input_params): - result = INDENTATION.join([f"{INDENTATION}Choose a tracking method:{get_json_value(input_params,'con_tracking_method.tracking_method')}\n", - f"Select the objects to track:{get_json_value(input_params,'object_to_track')}\n" - ]) + result = INDENTATION.join( + [ + f"{INDENTATION}Choose a tracking method:{get_json_value(input_params,'con_tracking_method.tracking_method')}\n", + f"Select the objects to track:{get_json_value(input_params,'object_to_track')}\n", + ] + ) - tracking_method = get_json_value(input_params, 'con_tracking_method.tracking_method') + tracking_method = get_json_value( + input_params, "con_tracking_method.tracking_method" + ) obj_measurement = "None" # default value if tracking_method == "Measurements": - measurement_category = get_json_value(input_params, 'con_tracking_method.con_measurement_category.measurement_category') - measurement = get_json_value(input_params, 'con_tracking_method.con_measurement_category.measurement') + measurement_category = get_json_value( + input_params, + "con_tracking_method.con_measurement_category.measurement_category", + ) + measurement = get_json_value( + input_params, "con_tracking_method.con_measurement_category.measurement" + ) if measurement_category == "Intensity" or measurement_category == "Location": - img_measure = get_json_value(input_params, 'con_tracking_method.con_measurement_category.img_measure') + img_measure = get_json_value( + input_params, "con_tracking_method.con_measurement_category.img_measure" + ) obj_measurement = f"{measurement_category}_{measurement}_{img_measure}" else: obj_measurement = f"{measurement_category}_{measurement}" - result += INDENTATION.join([f"{INDENTATION}Select object measurement to use for tracking:{obj_measurement}\n"]) + result += INDENTATION.join( + [ + f"{INDENTATION}Select object measurement to use for tracking:{obj_measurement}\n" + ] + ) if tracking_method == "LAP": # no max distance required, set default for pipeline max_distance = 50 else: - max_distance = get_json_value(input_params, 'con_tracking_method.max_distance') + max_distance = get_json_value(input_params, "con_tracking_method.max_distance") - result += INDENTATION.join([f"{INDENTATION}Maximum pixel distance to consider matches:{max_distance}\n"]) + result += INDENTATION.join( + [f"{INDENTATION}Maximum pixel distance to consider matches:{max_distance}\n"] + ) - display_option = get_json_value(input_params, 'con_tracking_method.display_option') + display_option = get_json_value(input_params, "con_tracking_method.display_option") output_img_name = "TrackedCells" # default value, required by cppipe regardless of its presence in UI - save = get_json_value(input_params, 'con_tracking_method.con_save_coded_img.save_coded_img') + save = get_json_value( + input_params, "con_tracking_method.con_save_coded_img.save_coded_img" + ) if save == "Yes": - output_img_name = get_json_value(input_params, 'con_tracking_method.con_save_coded_img.name_output_img') + output_img_name = get_json_value( + input_params, "con_tracking_method.con_save_coded_img.name_output_img" + ) result += INDENTATION.join( - [f"{INDENTATION}Select display option:{display_option}\n", - f"Save color-coded image?:{save}\n", - f"Name the output image:{output_img_name}\n" - ]) + [ + f"{INDENTATION}Select display option:{display_option}\n", + f"Save color-coded image?:{save}\n", + f"Name the output image:{output_img_name}\n", + ] + ) # LAP method default values movement_model = "Both" @@ -85,67 +112,113 @@ # LAP method if tracking_method == "LAP": - movement_model = get_json_value(input_params, 'con_tracking_method.movement_method') - no_std = get_json_value(input_params, 'con_tracking_method.no_std_radius') - radius_limit_max = get_json_value(input_params, 'con_tracking_method.max_radius') - radius_limit_min = get_json_value(input_params, 'con_tracking_method.min_radius') + movement_model = get_json_value( + input_params, "con_tracking_method.movement_method" + ) + no_std = get_json_value(input_params, "con_tracking_method.no_std_radius") + radius_limit_max = get_json_value( + input_params, "con_tracking_method.max_radius" + ) + radius_limit_min = get_json_value( + input_params, "con_tracking_method.min_radius" + ) radius = f"{radius_limit_min},{radius_limit_max}" - run_second = get_json_value(input_params, 'con_tracking_method.con_second_lap.second_lap') + run_second = get_json_value( + input_params, "con_tracking_method.con_second_lap.second_lap" + ) if run_second == "Yes": - gap_closing = get_json_value(input_params, 'con_tracking_method.con_second_lap.gap_closing') - split_alt = get_json_value(input_params, 'con_tracking_method.con_second_lap.split_alt') - merge_alt = get_json_value(input_params, 'con_tracking_method.con_second_lap.merge_alt') - max_gap_displacement = get_json_value(input_params, 'con_tracking_method.con_second_lap.max_gap_displacement') - max_split = get_json_value(input_params, 'con_tracking_method.con_second_lap.max_split') - max_merge = get_json_value(input_params, 'con_tracking_method.con_second_lap.max_merge') - max_temporal = get_json_value(input_params, 'con_tracking_method.con_second_lap.max_temporal') - max_mitosis_dist = get_json_value(input_params, 'con_tracking_method.con_second_lap.max_mitosis_distance') - mitosis_alt = get_json_value(input_params, 'con_tracking_method.con_second_lap.mitosis_alt') + gap_closing = get_json_value( + input_params, "con_tracking_method.con_second_lap.gap_closing" + ) + split_alt = get_json_value( + input_params, "con_tracking_method.con_second_lap.split_alt" + ) + merge_alt = get_json_value( + input_params, "con_tracking_method.con_second_lap.merge_alt" + ) + max_gap_displacement = get_json_value( + input_params, "con_tracking_method.con_second_lap.max_gap_displacement" + ) + max_split = get_json_value( + input_params, "con_tracking_method.con_second_lap.max_split" + ) + max_merge = get_json_value( + input_params, "con_tracking_method.con_second_lap.max_merge" + ) + max_temporal = get_json_value( + input_params, "con_tracking_method.con_second_lap.max_temporal" + ) + max_mitosis_dist = get_json_value( + input_params, "con_tracking_method.con_second_lap.max_mitosis_distance" + ) + mitosis_alt = get_json_value( + input_params, "con_tracking_method.con_second_lap.mitosis_alt" + ) result += INDENTATION.join( - [f"{INDENTATION}Select the movement model:{movement_model}\n", - f"Number of standard deviations for search radius:{no_std}\n", - f"Search radius limit, in pixel units (Min,Max):{radius}\n", - f"Run the second phase of the LAP algorithm?:{run_second}\n", - f"Gap closing cost:{gap_closing}\n", - f"Split alternative cost:{split_alt}\n", - f"Merge alternative cost:{merge_alt}\n", - f"Maximum gap displacement, in pixel units:{max_gap_displacement}\n", - f"Maximum split score:{max_split}\n", - f"Maximum merge score:{max_merge}\n", - f"Maximum temporal gap, in frames:{max_temporal}\n" - ]) + [ + f"{INDENTATION}Select the movement model:{movement_model}\n", + f"Number of standard deviations for search radius:{no_std}\n", + f"Search radius limit, in pixel units (Min,Max):{radius}\n", + f"Run the second phase of the LAP algorithm?:{run_second}\n", + f"Gap closing cost:{gap_closing}\n", + f"Split alternative cost:{split_alt}\n", + f"Merge alternative cost:{merge_alt}\n", + f"Maximum gap displacement, in pixel units:{max_gap_displacement}\n", + f"Maximum split score:{max_split}\n", + f"Maximum merge score:{max_merge}\n", + f"Maximum temporal gap, in frames:{max_temporal}\n", + ] + ) # common section - filter_by_lifetime = get_json_value(input_params, 'con_tracking_method.con_filter_by_lifetime.filter_by_lifetime') + filter_by_lifetime = get_json_value( + input_params, "con_tracking_method.con_filter_by_lifetime.filter_by_lifetime" + ) use_min = "Yes" # default min_life = 1 # default use_max = "No" # default max_life = 100 # default if filter_by_lifetime == "Yes": - use_min = get_json_value(input_params, 'con_tracking_method.con_filter_by_lifetime.con_use_min.use_min') + use_min = get_json_value( + input_params, + "con_tracking_method.con_filter_by_lifetime.con_use_min.use_min", + ) if use_min == "Yes": - min_life = get_json_value(input_params, 'con_tracking_method.con_filter_by_lifetime.con_use_min.min_lifetime') + min_life = get_json_value( + input_params, + "con_tracking_method.con_filter_by_lifetime.con_use_min.min_lifetime", + ) - use_max = get_json_value(input_params, 'con_tracking_method.con_filter_by_lifetime.con_use_max.use_max') + use_max = get_json_value( + input_params, + "con_tracking_method.con_filter_by_lifetime.con_use_max.use_max", + ) if use_max == "Yes": - max_life = get_json_value(input_params, 'con_tracking_method.con_filter_by_lifetime.con_use_max.max_lifetime') + max_life = get_json_value( + input_params, + "con_tracking_method.con_filter_by_lifetime.con_use_max.max_lifetime", + ) result += INDENTATION.join( - [f"{INDENTATION}Filter objects by lifetime?:{filter_by_lifetime}\n", - f"Filter using a minimum lifetime?:{use_min}\n", - f"Minimum lifetime:{min_life}\n", - f"Filter using a maximum lifetime?:{use_max}\n", - f"Maximum lifetime:{max_life}\n" - ]) + [ + f"{INDENTATION}Filter objects by lifetime?:{filter_by_lifetime}\n", + f"Filter using a minimum lifetime?:{use_min}\n", + f"Minimum lifetime:{min_life}\n", + f"Filter using a maximum lifetime?:{use_max}\n", + f"Maximum lifetime:{max_life}\n", + ] + ) # print 2 leftover from LAP result += INDENTATION.join( - [f"{INDENTATION}Mitosis alternative cost:{mitosis_alt}\n", - f"Maximum mitosis distance, in pixel units:{max_mitosis_dist}\n" - ]) + [ + f"{INDENTATION}Mitosis alternative cost:{mitosis_alt}\n", + f"Maximum mitosis distance, in pixel units:{max_mitosis_dist}\n", + ] + ) # Follow Neighbors # defaults @@ -155,32 +228,36 @@ weight_of_area_diff = 25.0 if tracking_method == "Follow Neighbors": - avg_cell_diameter = get_json_value(input_params, 'con_tracking_method.avg_diameter') - use_adv = get_json_value(input_params, 'con_tracking_method.con_adv_parameter.adv_parameter') + avg_cell_diameter = get_json_value( + input_params, "con_tracking_method.avg_diameter" + ) + use_adv = get_json_value( + input_params, "con_tracking_method.con_adv_parameter.adv_parameter" + ) if use_adv == "Yes": - cost_of_cell = get_json_value(input_params, 'con_tracking_method.con_adv_parameter.cost') - weight_of_area_diff = get_json_value(input_params, 'con_tracking_method.con_adv_parameter.weight') + cost_of_cell = get_json_value( + input_params, "con_tracking_method.con_adv_parameter.cost" + ) + weight_of_area_diff = get_json_value( + input_params, "con_tracking_method.con_adv_parameter.weight" + ) result += INDENTATION.join( - [f"{INDENTATION}Average cell diameter in pixels:{avg_cell_diameter}\n", - f"Use advanced configuration parameters:{use_adv}\n", - f"Cost of cell to empty matching:{cost_of_cell}\n", - f"Weight of area difference in function matching cost:{weight_of_area_diff}\n" - ]) + [ + f"{INDENTATION}Average cell diameter in pixels:{avg_cell_diameter}\n", + f"Use advanced configuration parameters:{use_adv}\n", + f"Cost of cell to empty matching:{cost_of_cell}\n", + f"Weight of area difference in function matching cost:{weight_of_area_diff}\n", + ] + ) result = result.rstrip("\n") return result if __name__ == "__main__": parser = argparse.ArgumentParser() - parser.add_argument( - '-p', '--pipeline', - help='CellProfiler pipeline' - ) - parser.add_argument( - '-i', '--inputs', - help='JSON inputs from Galaxy' - ) + parser.add_argument("-p", "--pipeline", help="CellProfiler pipeline") + parser.add_argument("-i", "--inputs", help="JSON inputs from Galaxy") args = parser.parse_args() pipeline_lines = get_pipeline_lines(args.pipeline)