Mercurial > repos > bgruening > cp_measure_image_intensity
diff tile.py @ 6:b64af54c5c09 draft default tip
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 57a0433defa3cbc37ab34fbb0ebcfaeb680db8d5
author | bgruening |
---|---|
date | Sun, 05 Nov 2023 09:28:54 +0000 |
parents | 8536b1ae0254 |
children |
line wrap: on
line diff
--- a/tile.py Fri Feb 26 14:08:05 2021 +0000 +++ b/tile.py Sun Nov 05 09:28:54 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)