Mercurial > repos > ufz > omero_get_value
comparison omero_metadata_upload.py @ 5:f5c4f523432d draft default tip
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 3f4e79a4e8350481f3c8d70bc64f01b4cb0a4bf0
author | ufz |
---|---|
date | Fri, 13 Jun 2025 20:47:38 +0000 |
parents | 5513b999c56e |
children |
comparison
equal
deleted
inserted
replaced
4:7a94eb8c345d | 5:f5c4f523432d |
---|---|
17 elif ann_type == "table": | 17 elif ann_type == "table": |
18 id_tb_ann = ez.post_table(conn, df, object_type=obj_type, object_id=int(did), title=an_name, | 18 id_tb_ann = ez.post_table(conn, df, object_type=obj_type, object_id=int(did), title=an_name, |
19 headers=True) | 19 headers=True) |
20 tb_dict = ez.get_table(conn, id_tb_ann) | 20 tb_dict = ez.get_table(conn, id_tb_ann) |
21 return tb_dict | 21 return tb_dict |
22 elif ann_type == "attachement": | |
23 id_file_attach = ez.post_file_annotation(conn, file_path=data_dict, ns=an_name, object_type=obj_type, object_id=int(did)) | |
24 return id_file_attach | |
22 except Exception as e: | 25 except Exception as e: |
23 log_error(f"Error uploading metadata for {obj_type} with ID {did}: {str(e)}") | 26 log_error(f"Error uploading metadata for {obj_type} with ID {did}: {str(e)}") |
24 return None | 27 return None |
25 | 28 |
26 def log_error(message): | 29 def log_error(message): |
39 | 42 |
40 if ann_type == "table": | 43 if ann_type == "table": |
41 data_dict = df.to_dict(orient='records') | 44 data_dict = df.to_dict(orient='records') |
42 elif ann_type == "KV": | 45 elif ann_type == "KV": |
43 data_dict = {col: df[col].iloc[0] for col in df.columns} | 46 data_dict = {col: df[col].iloc[0] for col in df.columns} |
47 elif ann_type == "attachement": | |
48 data_dict = ann_file | |
44 | 49 |
45 try: | 50 try: |
46 with ez.connect(user, pws, "", host, port, secure=True) as conn: | 51 with ez.connect(user, pws, "", host, port, secure=True) as conn: |
47 if obj_type == "project": | 52 if obj_type == "project": |
48 if did is None: | 53 if did is None: |
84 parser.add_argument('--port', required=True, type=int, help='OMERO port') | 89 parser.add_argument('--port', required=True, type=int, help='OMERO port') |
85 parser.add_argument('--obj_type', required=True, choices=['project', 'screen', 'dataset', 'plate', | 90 parser.add_argument('--obj_type', required=True, choices=['project', 'screen', 'dataset', 'plate', |
86 'well ', 'image'], | 91 'well ', 'image'], |
87 help='Type of OMERO object') | 92 help='Type of OMERO object') |
88 parser.add_argument('--did', type=int, help='ID of the object (if it exists)') | 93 parser.add_argument('--did', type=int, help='ID of the object (if it exists)') |
89 parser.add_argument('--ann_type', required=True, choices=['table', 'KV'], help='Annotation type') | 94 parser.add_argument('--ann_type', required=True, choices=['table', 'KV', "attachement"], help='Annotation type') |
90 parser.add_argument('--ann_file', required=True, help='Path to the annotation file') | 95 parser.add_argument('--ann_file', required=True, help='Path to the annotation file') |
91 parser.add_argument('--an_name', required=True, help='Namespace or title for the annotation') | 96 parser.add_argument('--an_name', required=True, help='Namespace or title for the annotation') |
92 parser.add_argument('--log_file', default='metadata_import_log.txt', help='Path to the log file') | 97 parser.add_argument('--log_file', default='metadata_import_log.txt', help='Path to the log file') |
93 | 98 |
94 args = parser.parse_args() | 99 args = parser.parse_args() |