Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions omero2pandas/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,17 @@
"Screen": omero.model.ScreenI,
"Well": omero.model.WellI,
"Roi": omero.model.RoiI,
"BooleanAnnotation": omero.model.BooleanAnnotationI,
"CommentAnnotation": omero.model.CommentAnnotationI,
"DoubleAnnotation": omero.model.DoubleAnnotationI,
"FileAnnotation": omero.model.FileAnnotationI,
"ListAnnotation": omero.model.ListAnnotationI,
"LongAnnotation": omero.model.LongAnnotationI,
"MapAnnotation": omero.model.MapAnnotationI,
"TagAnnotation": omero.model.TagAnnotationI,
"TermAnnotation": omero.model.TermAnnotationI,
"TimestampAnnotation": omero.model.TimestampAnnotationI,
"XmlAnnotation": omero.model.XmlAnnotationI,
}


Expand Down Expand Up @@ -140,8 +151,9 @@ def generate_omero_columns_csv(csv_path, chunk_size=1000):

def create_table(source, table_name, links, conn, chunk_size):
# Create an OMERO.table and upload data
# Make type case-insensitive
links = [(t.lower().capitalize(), i) for t, i in links]
# Make type case-insensitive, handling annotation caps properly
links = [(t.lower().capitalize().replace("annotation", "Annotation"), i)
for t, i in links]
# Validate link list
working_group = None
roi_only = True
Expand All @@ -151,7 +163,8 @@ def create_table(source, table_name, links, conn, chunk_size):
f"supported as a link target")
if target_type != "Roi":
roi_only = False
target_ob = conn.getObject(target_type, target_id)
target_ob = conn.getQueryService().find(target_type, target_id,
{"omero.group": "-1"})
if target_ob is None:
raise ValueError(f"{target_type} #{target_id} not found")
target_group = target_ob.details.group.id.val
Expand Down Expand Up @@ -225,7 +238,10 @@ def create_table(source, table_name, links, conn, chunk_size):
annotation_obj.id.val, False)
link_buffer = []
for obj_type, obj_id in links:
link_obj = LINK_TYPES[obj_type]()
if "annotation" in obj_type.lower():
link_obj = omero.model.AnnotationAnnotationLinkI()
else:
link_obj = LINK_TYPES[obj_type]()
unloaded_target = OBJECT_TYPES[obj_type](obj_id, False)
link_obj.link(unloaded_target, unloaded_annotation)
link_buffer.append(link_obj)
Expand Down