annotate omero_metadata_upload.py @ 3:ecb13e93fae2 draft default tip

planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit b77b2be85447cb7040ed855e8dbd2ec4677c4eb6
author ufz
date Thu, 19 Dec 2024 14:57:46 +0000
parents 5513b999c56e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
1 import argparse
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
2 import json
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
3 from datetime import datetime
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
4
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
5 import ezomero as ez
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
6 import pandas as pd
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
7
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
8
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
9 def metadata_import_ezo(user, pws, host, port, obj_type, did=None, ann_type="table", ann_file=None, an_name=None,
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
10 log_file='metadata_import_log.txt'):
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
11 def upload_metadata(conn, obj_type, did, data_dict, df, ann_type, an_name):
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
12 try:
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
13 if ann_type == "KV":
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
14 id_map_ann = ez.post_map_annotation(conn, obj_type, object_id=int(did), kv_dict=data_dict, ns=an_name)
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
15 ma_dict = ez.get_map_annotation(conn, id_map_ann)
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
16 return ma_dict
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
17 elif ann_type == "table":
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
18 id_tb_ann = ez.post_table(conn, df, object_type=obj_type, object_id=int(did), title=an_name,
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
19 headers=True)
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
20 tb_dict = ez.get_table(conn, id_tb_ann)
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
21 return tb_dict
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
22 except Exception as e:
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
23 log_error(f"Error uploading metadata for {obj_type} with ID {did}: {str(e)}")
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
24 return None
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
25
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
26 def log_error(message):
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
27 with open(log_file, 'w') as f:
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
28 f.write(f"ERROR: {message}\n")
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
29
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
30 def log_success(message):
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
31 with open(log_file, 'w') as f:
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
32 f.write(f"SUCCESS: {message}\n")
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
33
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
34 try:
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
35 df = pd.read_csv(ann_file, delimiter='\t')
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
36 except FileNotFoundError as e:
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
37 log_error(f"Annotation file not found: {str(e)}")
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
38 return
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
39
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
40 if ann_type == "table":
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
41 data_dict = df.to_dict(orient='records')
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
42 elif ann_type == "KV":
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
43 data_dict = {col: df[col].iloc[0] for col in df.columns}
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
44
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
45 try:
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
46 with ez.connect(user, pws, "", host, port, secure=True) as conn:
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
47 if obj_type == "project":
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
48 if did is None:
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
49 did = ez.post_project(conn, project_name=str(datetime.now()))
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
50 result = upload_metadata(conn, "Project", did, data_dict, df, ann_type, an_name)
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
51 elif obj_type == "screen":
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
52 if did is None:
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
53 did = ez.post_screen(conn, screen_name=str(datetime.now()))
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
54 result = upload_metadata(conn, "Screen", did, data_dict, df, ann_type, an_name)
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
55 elif obj_type == "dataset":
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
56 if did is None:
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
57 did = ez.post_dataset(conn, dataset_name=str(datetime.now()))
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
58 result = upload_metadata(conn, "Dataset", did, data_dict, df, ann_type, an_name)
2
5513b999c56e planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents: 0
diff changeset
59 elif obj_type == "plate":
5513b999c56e planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents: 0
diff changeset
60 result = upload_metadata(conn, "Plate", did, data_dict, df, ann_type, an_name)
5513b999c56e planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents: 0
diff changeset
61 elif obj_type == "well":
5513b999c56e planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents: 0
diff changeset
62 result = upload_metadata(conn, "Well", did, data_dict, df, ann_type, an_name)
0
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
63 elif obj_type == "image":
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
64 result = upload_metadata(conn, "Image", did, data_dict, df, ann_type, an_name)
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
65 else:
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
66 raise ValueError("Unsupported object type provided: {}".format(obj_type))
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
67
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
68 if result is not None:
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
69 log_success(f"Successfully uploaded metadata for {obj_type} with ID {did}. Result: {result}")
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
70 else:
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
71 log_error(f"Failed to upload metadata for {obj_type} with ID {did}.")
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
72
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
73 conn.close()
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
74
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
75 except Exception as e:
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
76 log_error(f"Connection error: {str(e)}")
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
77
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
78
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
79 if __name__ == "__main__":
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
80 parser = argparse.ArgumentParser(description='Import metadata into OMERO.')
2
5513b999c56e planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents: 0
diff changeset
81 parser.add_argument("--credential-file", dest="credential_file", type=str, required=True,
5513b999c56e planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents: 0
diff changeset
82 help="Credential file (JSON file with username and password for OMERO)")
0
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
83 parser.add_argument('--host', required=True, help='OMERO host')
1ae349b83c08 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('--port', required=True, type=int, help='OMERO port')
2
5513b999c56e planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents: 0
diff changeset
85 parser.add_argument('--obj_type', required=True, choices=['project', 'screen', 'dataset', 'plate',
5513b999c56e planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 636cbb62d59819caca5bc9eab0a8ec31be5bdd46
ufz
parents: 0
diff changeset
86 'well ', 'image'],
0
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
87 help='Type of OMERO object')
1ae349b83c08 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('--did', type=int, help='ID of the object (if it exists)')
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
89 parser.add_argument('--ann_type', required=True, choices=['table', 'KV'], help='Annotation type')
1ae349b83c08 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('--ann_file', required=True, help='Path to the annotation file')
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
91 parser.add_argument('--an_name', required=True, help='Namespace or title for the annotation')
1ae349b83c08 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('--log_file', default='metadata_import_log.txt', help='Path to the log file')
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
93
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
94 args = parser.parse_args()
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
95
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
96 with open(args.credential_file, 'r') as f:
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
97 crds = json.load(f)
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
98
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
99 metadata_import_ezo(user=crds['username'], pws=crds['password'], host=args.host, port=args.port,
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
100 obj_type=args.obj_type, did=args.did, ann_type=args.ann_type,
1ae349b83c08 planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 19d84fd5a372f1428e3e5670144881a56e8af8b2
ufz
parents:
diff changeset
101 ann_file=args.ann_file, an_name=args.an_name, log_file=args.log_file)