Exemplo n.º 1
0
# Create a 'map' annotation (list of key: value pairs)
# ====================================================
key_value_data = [["Drug Name", "Monastrol"], ["Concentration", "5 mg/ml"]]
map_ann = omero.gateway.MapAnnotationWrapper(conn)
# Use 'client' namespace to allow editing in Insight & web
namespace = omero.constants.metadata.NSCLIENTMAPANNOTATION
map_ann.setNs(namespace)
map_ann.setValue(key_value_data)
map_ann.save()
project = conn.getObject("Project", projectId)
# NB: only link a client map annotation to a single object
project.linkAnnotation(map_ann)

# Count the number of annotations on one or many objects
# ===========================================================
print(conn.countAnnotations('Project', [projectId]))

# List all annotations on an object. Get text from tags
# ===========================================================
for ann in project.listAnnotations():
    print(ann.getId(), ann.OMERO_TYPE, end=' ')
    print(" added by ", ann.link.getDetails().getOwner().getOmeName())
    if ann.OMERO_TYPE == omero.model.TagAnnotationI:
        print("Tag value:", ann.getTextValue())

# Remove Annotations from an Object (delete link)
project = conn.getObject("Project", projectId)
to_delete = []
for ann in project.listAnnotations():
    if ann.ns != namespace:
        to_delete.append(ann.link.id)