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