# HG changeset patch
# User ufz
# Date 1726158643 0
# Node ID 83ccd2b525e5c52b38b49d4dc6d9425253386945
# Parent 267227e757cb3176e61846e3ab49b8d1652e4ce2
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/omero commit 266752b0162fbdb32f132a6702cb661ae36f48f0
diff -r 267227e757cb -r 83ccd2b525e5 omero_import.xml
--- a/omero_import.xml Thu Sep 05 11:55:50 2024 +0000
+++ b/omero_import.xml Thu Sep 12 16:30:43 2024 +0000
@@ -2,7 +2,7 @@
with omero-py
5.18.0
- 1
+ 2
omero
@@ -22,15 +22,22 @@
ln -s '${image}' folder/'${image_identifier}.$image.ext' &&
#end for
+ source '$credentials' &&
omero import folder -T Dataset:name:$dataset_name
-s $omero_host
-p $omero_port
- -u $__user__.extra_preferences.get('omero_account|username', $test_username)
- -w $__user__.extra_preferences.get('omero_account|password', $test_password)
+ -u "\$OMERO_USER"
+ -w "\$OMERO_PASSWORD"
> $log &&
omero logout
]]>
+
+
+
diff -r 267227e757cb -r 83ccd2b525e5 omero_metadata_upload.py
--- a/omero_metadata_upload.py Thu Sep 05 11:55:50 2024 +0000
+++ b/omero_metadata_upload.py Thu Sep 12 16:30:43 2024 +0000
@@ -1,4 +1,5 @@
import argparse
+import json
from datetime import datetime
import ezomero as ez
@@ -73,8 +74,7 @@
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Import metadata into OMERO.')
- parser.add_argument('--user', required=True, help='OMERO username')
- parser.add_argument('--pws', required=True, help='OMERO password')
+ parser.add_argument("--credential-file", dest="credential_file", type=str, required=True, help="Credential file (JSON file with username and password for OMERO)")
parser.add_argument('--host', required=True, help='OMERO host')
parser.add_argument('--port', required=True, type=int, help='OMERO port')
parser.add_argument('--obj_type', required=True, choices=['project', 'screen', 'dataset', 'image'],
@@ -87,6 +87,9 @@
args = parser.parse_args()
- metadata_import_ezo(user=args.user, pws=args.pws, host=args.host, port=args.port,
+ with open(args.credential_file, 'r') as f:
+ crds = json.load(f)
+
+ metadata_import_ezo(user=crds['username'], pws=crds['password'], host=args.host, port=args.port,
obj_type=args.obj_type, did=args.did, ann_type=args.ann_type,
ann_file=args.ann_file, an_name=args.an_name, log_file=args.log_file)
diff -r 267227e757cb -r 83ccd2b525e5 omero_roi_upload.py
--- a/omero_roi_upload.py Thu Sep 05 11:55:50 2024 +0000
+++ b/omero_roi_upload.py Thu Sep 12 16:30:43 2024 +0000
@@ -1,6 +1,8 @@
import argparse
+import json
import re
+import numpy as np
import pandas as pd
from ezomero import connect, post_roi
from ezomero.rois import Ellipse, Label, Line, Point, Polygon, Polyline, Rectangle
@@ -35,6 +37,7 @@
z=row.get('z'),
c=row.get('c'),
t=row.get('t'),
+ label=row.get('label'),
fill_color=parse_color(row.get('fill_color')),
stroke_color=parse_color(row.get('stroke_color')),
stroke_width=row.get('stroke_width')
@@ -60,7 +63,7 @@
y2=row['y2'],
markerStart=row.get('markerStart', None),
markerEnd=row.get('markerEnd', None),
- label=row.get('label', None),
+ label=row.get('label'),
z=row.get('z'),
c=row.get('c'),
t=row.get('t'),
@@ -75,6 +78,7 @@
z=row.get('z'),
c=row.get('c'),
t=row.get('t'),
+ label=row.get('label'),
fill_color=parse_color(row.get('fill_color')),
stroke_color=parse_color(row.get('stroke_color')),
stroke_width=row.get('stroke_width')
@@ -85,6 +89,7 @@
z=row.get('z'),
c=row.get('c'),
t=row.get('t'),
+ label=row.get('label'),
fill_color=parse_color(row.get('fill_color')),
stroke_color=parse_color(row.get('stroke_color')),
stroke_width=row.get('stroke_width')
@@ -95,6 +100,7 @@
z=row.get('z'),
c=row.get('c'),
t=row.get('t'),
+ label=row.get('label'),
fill_color=parse_color(row.get('fill_color')),
stroke_color=parse_color(row.get('stroke_color')),
stroke_width=row.get('stroke_width')
@@ -108,6 +114,7 @@
z=row.get('z'),
c=row.get('c'),
t=row.get('t'),
+ label=row.get('label'),
fill_color=parse_color(row.get('fill_color')),
stroke_color=parse_color(row.get('stroke_color')),
stroke_width=row.get('stroke_width')
@@ -119,6 +126,8 @@
# Open log file
with open(log_file, 'w') as log:
df = pd.read_csv(input_file, sep='\t')
+ # Replace nan to none
+ df = df.replace({np.nan: None})
for index, row in df.iterrows():
msg = f"Processing row {index + 1}/{len(df)}: {row.to_dict()}"
print(msg)
@@ -143,17 +152,19 @@
parser.add_argument("--input_file", help="Path to the input tabular file.")
parser.add_argument("--image_id", type=int, required=True, help="ID of the image to which the ROI will be linked")
parser.add_argument("--host", type=str, required=True, help="OMERO server host")
- parser.add_argument("--user", type=str, required=True, help="OMERO username")
- parser.add_argument("--psw", type=str, required=True, help="OMERO password")
+ parser.add_argument("--credential-file", dest="credential_file", type=str, required=True, help="Credential file (JSON file with username and password for OMERO)")
parser.add_argument("--port", type=int, default=4064, help="OMERO server port")
parser.add_argument("--log_file", type=str, default="process.txt", help="Log file path")
args = parser.parse_args()
+ with open(args.credential_file, 'r') as f:
+ crds = json.load(f)
+
conn = connect(
host=args.host,
- user=args.user,
- password=args.psw,
+ user=crds['username'],
+ password=crds['password'],
port=args.port,
group="",
secure=True
diff -r 267227e757cb -r 83ccd2b525e5 test-data/input_roi_minimal.tsv
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/input_roi_minimal.tsv Thu Sep 12 16:30:43 2024 +0000
@@ -0,0 +1,2 @@
+shape points label
+Polygon (300,300),(350,350),(300,400) Example ROI
diff -r 267227e757cb -r 83ccd2b525e5 test-data/output_table_roi.txt
--- a/test-data/output_table_roi.txt Thu Sep 05 11:55:50 2024 +0000
+++ b/test-data/output_table_roi.txt Thu Sep 12 16:30:43 2024 +0000
@@ -1,14 +1,14 @@
-Processing row 1/7: {'shape': 'Ellipse', 'x': 50.0, 'y': 50.0, 'x_rad': 20.0, 'y_rad': 10.0, 'label': nan, 'fontSize': nan, 'x1': nan, 'y1': nan, 'x2': nan, 'y2': nan, 'points': nan, 'width': nan, 'height': nan, 'fill_color': '(255,0,0,128)', 'stroke_color': '(0,0,0,255)', 'stroke_width': 2, 'z': 0, 'c': 0, 't': 0, 'roi_name': 'Example ROI', 'roi_description': 'This is an example ROI'}
+Processing row 1/7: {'shape': 'Ellipse', 'x': 50.0, 'y': 50.0, 'x_rad': 20.0, 'y_rad': 10.0, 'label': None, 'fontSize': None, 'x1': None, 'y1': None, 'x2': None, 'y2': None, 'points': None, 'width': None, 'height': None, 'fill_color': '(255,0,0,128)', 'stroke_color': '(0,0,0,255)', 'stroke_width': 2, 'z': 0, 'c': 0, 't': 0, 'roi_name': 'Example ROI', 'roi_description': 'This is an example ROI'}
ROI ID: 1 for row 1
-Processing row 2/7: {'shape': 'Label', 'x': 100.0, 'y': 100.0, 'x_rad': nan, 'y_rad': nan, 'label': 'Test Label', 'fontSize': 12.0, 'x1': nan, 'y1': nan, 'x2': nan, 'y2': nan, 'points': nan, 'width': nan, 'height': nan, 'fill_color': '(255,255,255,0)', 'stroke_color': '(0,0,255,255)', 'stroke_width': 1, 'z': 0, 'c': 0, 't': 0, 'roi_name': 'Example ROI', 'roi_description': 'This is an example ROI'}
+Processing row 2/7: {'shape': 'Label', 'x': 100.0, 'y': 100.0, 'x_rad': None, 'y_rad': None, 'label': 'Test Label', 'fontSize': 12.0, 'x1': None, 'y1': None, 'x2': None, 'y2': None, 'points': None, 'width': None, 'height': None, 'fill_color': '(255,255,255,0)', 'stroke_color': '(0,0,255,255)', 'stroke_width': 1, 'z': 0, 'c': 0, 't': 0, 'roi_name': 'Example ROI', 'roi_description': 'This is an example ROI'}
ROI ID: 2 for row 2
-Processing row 3/7: {'shape': 'Line', 'x': nan, 'y': nan, 'x_rad': nan, 'y_rad': nan, 'label': nan, 'fontSize': nan, 'x1': 200.0, 'y1': 200.0, 'x2': 250.0, 'y2': 250.0, 'points': nan, 'width': nan, 'height': nan, 'fill_color': '(0,255,0,128)', 'stroke_color': '(0,0,0,255)', 'stroke_width': 2, 'z': 0, 'c': 1, 't': 0, 'roi_name': 'Example ROI', 'roi_description': 'This is an example ROI'}
+Processing row 3/7: {'shape': 'Line', 'x': None, 'y': None, 'x_rad': None, 'y_rad': None, 'label': None, 'fontSize': None, 'x1': 200.0, 'y1': 200.0, 'x2': 250.0, 'y2': 250.0, 'points': None, 'width': None, 'height': None, 'fill_color': '(0,255,0,128)', 'stroke_color': '(0,0,0,255)', 'stroke_width': 2, 'z': 0, 'c': 1, 't': 0, 'roi_name': 'Example ROI', 'roi_description': 'This is an example ROI'}
ROI ID: 3 for row 3
-Processing row 4/7: {'shape': 'Point', 'x': 150.0, 'y': 150.0, 'x_rad': nan, 'y_rad': nan, 'label': nan, 'fontSize': nan, 'x1': nan, 'y1': nan, 'x2': nan, 'y2': nan, 'points': nan, 'width': nan, 'height': nan, 'fill_color': '(0,0,255,128)', 'stroke_color': '(255,0,0,255)', 'stroke_width': 3, 'z': 0, 'c': 2, 't': 0, 'roi_name': 'Example ROI', 'roi_description': 'This is an example ROI'}
+Processing row 4/7: {'shape': 'Point', 'x': 150.0, 'y': 150.0, 'x_rad': None, 'y_rad': None, 'label': None, 'fontSize': None, 'x1': None, 'y1': None, 'x2': None, 'y2': None, 'points': None, 'width': None, 'height': None, 'fill_color': '(0,0,255,128)', 'stroke_color': '(255,0,0,255)', 'stroke_width': 3, 'z': 0, 'c': 2, 't': 0, 'roi_name': 'Example ROI', 'roi_description': 'This is an example ROI'}
ROI ID: 4 for row 4
-Processing row 5/7: {'shape': 'Polygon', 'x': nan, 'y': nan, 'x_rad': nan, 'y_rad': nan, 'label': nan, 'fontSize': nan, 'x1': nan, 'y1': nan, 'x2': nan, 'y2': nan, 'points': '(300,300),(350,350),(300,400)', 'width': nan, 'height': nan, 'fill_color': '(255,255,0,128)', 'stroke_color': '(0,0,0,255)', 'stroke_width': 2, 'z': 1, 'c': 0, 't': 0, 'roi_name': 'Example ROI', 'roi_description': 'This is an example ROI'}
+Processing row 5/7: {'shape': 'Polygon', 'x': None, 'y': None, 'x_rad': None, 'y_rad': None, 'label': None, 'fontSize': None, 'x1': None, 'y1': None, 'x2': None, 'y2': None, 'points': '(300,300),(350,350),(300,400)', 'width': None, 'height': None, 'fill_color': '(255,255,0,128)', 'stroke_color': '(0,0,0,255)', 'stroke_width': 2, 'z': 1, 'c': 0, 't': 0, 'roi_name': 'Example ROI', 'roi_description': 'This is an example ROI'}
ROI ID: 5 for row 5
-Processing row 6/7: {'shape': 'Polyline', 'x': nan, 'y': nan, 'x_rad': nan, 'y_rad': nan, 'label': nan, 'fontSize': nan, 'x1': nan, 'y1': nan, 'x2': nan, 'y2': nan, 'points': '(400,400),(450,450),(400,500)', 'width': nan, 'height': nan, 'fill_color': '(0,255,255,128)', 'stroke_color': '(0,0,0,255)', 'stroke_width': 3, 'z': 0, 'c': 0, 't': 0, 'roi_name': 'Example ROI', 'roi_description': 'This is an example ROI'}
+Processing row 6/7: {'shape': 'Polyline', 'x': None, 'y': None, 'x_rad': None, 'y_rad': None, 'label': None, 'fontSize': None, 'x1': None, 'y1': None, 'x2': None, 'y2': None, 'points': '(400,400),(450,450),(400,500)', 'width': None, 'height': None, 'fill_color': '(0,255,255,128)', 'stroke_color': '(0,0,0,255)', 'stroke_width': 3, 'z': 0, 'c': 0, 't': 0, 'roi_name': 'Example ROI', 'roi_description': 'This is an example ROI'}
ROI ID: 6 for row 6
-Processing row 7/7: {'shape': 'Rectangle', 'x': 500.0, 'y': 500.0, 'x_rad': nan, 'y_rad': nan, 'label': nan, 'fontSize': nan, 'x1': nan, 'y1': nan, 'x2': nan, 'y2': nan, 'points': nan, 'width': 100.0, 'height': 50.0, 'fill_color': '(255,0,255,128)', 'stroke_color': '(0,0,0,255)', 'stroke_width': 2, 'z': 0, 'c': 0, 't': 0, 'roi_name': 'Example ROI', 'roi_description': 'This is an example ROI'}
+Processing row 7/7: {'shape': 'Rectangle', 'x': 500.0, 'y': 500.0, 'x_rad': None, 'y_rad': None, 'label': None, 'fontSize': None, 'x1': None, 'y1': None, 'x2': None, 'y2': None, 'points': None, 'width': 100.0, 'height': 50.0, 'fill_color': '(255,0,255,128)', 'stroke_color': '(0,0,0,255)', 'stroke_width': 2, 'z': 0, 'c': 0, 't': 0, 'roi_name': 'Example ROI', 'roi_description': 'This is an example ROI'}
ROI ID: 7 for row 7
diff -r 267227e757cb -r 83ccd2b525e5 test-data/output_table_roi_minimal.txt
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/output_table_roi_minimal.txt Thu Sep 12 16:30:43 2024 +0000
@@ -0,0 +1,2 @@
+Processing row 1/1: {'shape': 'Polygon', 'points': '(300,300),(350,350),(300,400)', 'label': 'Example ROI'}
+ROI ID: 8 for row 1