Mercurial > repos > ufz > omero_dataset_to_plate
annotate omero_get_id.py @ 0:5ad32d18fe82 draft
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
author | ufz |
---|---|
date | Mon, 16 Dec 2024 20:56:16 +0000 |
parents | |
children |
rev | line source |
---|---|
0
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
1 import argparse |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
2 import csv |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
3 import json |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
4 import sys |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
5 |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
6 import ezomero as ez |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
7 |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
8 |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
9 def get_ids_ezo(user, pws, host, port, final_obj_type, parent_obj_type, parent_id=None, tsv_file="id_list.tsv"): |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
10 |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
11 # Function to write tabular file from the ezomero output |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
12 def write_ids_to_tsv(data): |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
13 with open(tsv_file, 'w', newline='') as f: |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
14 writer = csv.writer(f, delimiter='\t') |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
15 for item in data: |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
16 writer.writerow([item]) # Write each ID |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
17 |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
18 with ez.connect(user, pws, "", host, port, secure=True) as conn: |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
19 |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
20 if final_obj_type == "Project": |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
21 proj_ids = ez.get_project_ids(conn) |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
22 write_ids_to_tsv(proj_ids) |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
23 return proj_ids |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
24 |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
25 elif final_obj_type == "Dataset": |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
26 args = {'project': None} |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
27 if parent_obj_type == "Project": |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
28 args['project'] = parent_id |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
29 ds_ids = ez.get_dataset_ids(conn, **args) |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
30 write_ids_to_tsv(ds_ids) |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
31 return ds_ids |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
32 |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
33 elif final_obj_type == "Image": |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
34 args = { |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
35 'project': None, |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
36 'dataset': None, |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
37 'plate': None, |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
38 'well': None |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
39 } |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
40 if parent_obj_type == "Project": |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
41 args['project'] = parent_id |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
42 elif parent_obj_type == "Dataset": |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
43 args['dataset'] = parent_id |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
44 elif parent_obj_type == "Plate": |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
45 args['plate'] = parent_id |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
46 elif parent_obj_type == "Well": |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
47 args['well'] = parent_id |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
48 elif parent_obj_type != "All": |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
49 raise ValueError("Object set as parent_obj_type is not compatible") |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
50 |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
51 ds_ims = ez.get_image_ids(conn, **args) |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
52 write_ids_to_tsv(ds_ims) |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
53 return ds_ims |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
54 |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
55 elif final_obj_type == "Annotation": |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
56 map_annot_ids = ez.get_map_annotation_ids(conn, parent_obj_type, parent_id) |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
57 write_ids_to_tsv(map_annot_ids) |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
58 return map_annot_ids |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
59 |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
60 elif final_obj_type == "Tag": |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
61 tag_ids = ez.get_tag_ids(conn, parent_obj_type, parent_id) |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
62 write_ids_to_tsv(tag_ids) |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
63 return tag_ids |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
64 |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
65 elif final_obj_type == "Roi": |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
66 roi_ids = ez.get_roi_ids(conn, parent_id) |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
67 write_ids_to_tsv(roi_ids) |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
68 return roi_ids |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
69 |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
70 elif final_obj_type == "Table": |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
71 file_ann_ids = ez.get_file_annotation_ids(conn, parent_obj_type, parent_id) |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
72 write_ids_to_tsv(file_ann_ids) |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
73 return file_ann_ids |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
74 |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
75 else: |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
76 sys.exit(f"Unsupported object type: {filter}") |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
77 |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
78 |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
79 # Argument parsing |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
80 if __name__ == "__main__": |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
81 parser = argparse.ArgumentParser(description="Fetch OMERO object IDs as TSV from parent object.") |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
82 parser.add_argument("--credential-file", dest="credential_file", type=str, |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
83 required=True, help="Credential file (JSON file with username and password for OMERO)") |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
84 parser.add_argument('--host', required=True, |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
85 help="Host server address.") |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
86 parser.add_argument('--port', required=True, type=int, |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
87 help='OMERO port') |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
88 parser.add_argument('--final_obj_type', required=True, |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
89 help="Type of object to fetch ID: Project, Dataset, Image, Annotation, Tag, Roi, or Table.") |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
90 parser.add_argument('--parent_obj_type', required=True, |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
91 help="Type of object from which you fetch IDs: Project, Dataset, Plate, Well, Image (or 'All' if you want to get all objects).") |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
92 parser.add_argument('--parent_id', required=False, type=int, |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
93 help="ID of the OMERO object in `--parent_obj_type`, not required if you used `--parent_obj_type All`.") |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
94 parser.add_argument('--tsv_file', default='id_list.tsv', |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
95 help="Output TSV file path.") |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
96 args = parser.parse_args() |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
97 |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
98 if args.parent_id is None and args.parent_obj_type != "All": |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
99 raise ValueError("ID is only optional is you use `--parent_obj_type All`") |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
100 |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
101 if args.final_obj_type == "Roi" and args.parent_obj_type != "Image": |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
102 raise ValueError("Roi IDs can only be retrived from images, use `--parent_obj_type Image`") |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
103 |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
104 if args.parent_obj_type == "All" and args.final_obj_type not in ["Image", "Dataset", "Project"]: |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
105 raise ValueError("Only Images, Datasets and Projects is compatible with `--parent_obj_type All`") |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
106 |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
107 with open(args.credential_file, 'r') as f: |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
108 crds = json.load(f) |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
109 |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
110 # Call the main function to get the object and save it as a TSV |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
111 get_ids_ezo(user=crds['username'], pws=crds['password'], host=args.host, |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
112 port=args.port, |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
113 final_obj_type=args.final_obj_type, |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
114 parent_obj_type=args.parent_obj_type, |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
115 parent_id=args.parent_id, |
5ad32d18fe82
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents:
diff
changeset
|
116 tsv_file=args.tsv_file) |