# HG changeset patch # User lldelisle # Date 1718611548 0 # Node ID 82f2efb462008218f3a3b5751103c2b3f7e4ef4f # Parent b0876c73076b9a15bbce77e89aeb68b86bf429c1 planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/omero_get_children_ids commit 3a5c830ad68e29c5e9f91edffa0a548c77aac141 diff -r b0876c73076b -r 82f2efb46200 omero_get_children_ids.py --- a/omero_get_children_ids.py Fri Dec 22 12:55:40 2023 +0000 +++ b/omero_get_children_ids.py Mon Jun 17 08:05:48 2024 +0000 @@ -20,22 +20,32 @@ return (omero_username, omero_password) -def recursive_get_children_id(parent_object, final_object_type): +def recursive_get_children_id(parent_object, final_object_type, get_name): output = [] if parent_object.OMERO_CLASS == 'WellSample': - return [parent_object.getImage().id] + if get_name: + parent_image = parent_object.getImage() + return [f"{parent_image.id}\t{parent_image.getName()}"] + else: + return [parent_object.getImage().id] for children in parent_object.listChildren(): if children.OMERO_CLASS == final_object_type.title(): - output.append(children.id) + if get_name: + output.append(f"{children.id}\t{children.getName()}") + else: + output.append(children.id) else: # We need to go one step further - output += recursive_get_children_id(children, final_object_type) + output += recursive_get_children_id( + children, final_object_type, get_name + ) return output def get_children_ids(parent_object_type, omero_id, final_object_type, + get_name, omero_username, omero_password, omero_host="idr.openmicroscopy.org", @@ -46,7 +56,9 @@ ) as conn: # Retrieve omero object parent_object = conn.getObject(parent_object_type.title(), omero_id) - return recursive_get_children_id(parent_object, final_object_type) + return recursive_get_children_id( + parent_object, final_object_type, get_name + ) if __name__ == "__main__": @@ -62,12 +74,15 @@ type=int, default=None, required=True) p.add_argument("--final-object-type", dest="final_object_type", type=str, default=None, required=True) + p.add_argument("--get-name", dest="get_name", + action="store_true", default=False) p.add_argument("--output", type=str, default=None, required=True) args = p.parse_args() children_ids = get_children_ids( args.parent_object_type, args.omero_id, args.final_object_type, + args.get_name, *get_omero_credentials(args.config_file), omero_host=args.omero_host, omero_secured=args.omero_secured, diff -r b0876c73076b -r 82f2efb46200 omero_get_children_ids.xml --- a/omero_get_children_ids.xml Fri Dec 22 12:55:40 2023 +0000 +++ b/omero_get_children_ids.xml Mon Jun 17 08:05:48 2024 +0000 @@ -1,7 +1,7 @@ Get children ids - 0.1.0 + 0.2.0 0 @@ -29,6 +29,7 @@ --omero-id '$omero_object.omero_id' --final-object-type '$omero_object.final_object_type' --output '$output' + $get_name ]]> + @@ -131,6 +133,23 @@ + + + + + + + + + + + + + + + + + @@ -263,5 +282,7 @@ This tool will create a file with the list of all children ids of a given omero object. +If the option is set, it can also retrive the names. + ]]> \ No newline at end of file