Created
April 16, 2025 10:18
-
-
Save dominikl/20a6c73e7073db8c315a3118ffc1b6b3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import omero.cli | |
import pandas as pd | |
from omero.rtypes import rint | |
data = { | |
"id": [], | |
"name": [], | |
"type": [], | |
"imported_from_path": [], | |
"download_location": [], | |
"zarr": [] | |
} | |
df = pd.DataFrame(data) | |
def get_import_from_path(conn, imageId): | |
query = "select fse from Fileset f \ | |
join f.usedFiles as fse \ | |
join f.images as imgs \ | |
where :id in imgs" | |
params = omero.sys.ParametersI() | |
params.addId(imageId) | |
res = conn.getQueryService().findAllByQuery(query, params) | |
if res and len(res) > 0: | |
return res[0].clientPath._val | |
return None | |
def get_image_info(conn, image): | |
path = get_import_from_path(conn, image.getId()) | |
if path: | |
kind = "NA" | |
if path.startswith("uod/idr/filesets") or \ | |
path.startswith("nfs/bioimage") or \ | |
path.startswith("idr/filesets") or \ | |
path.startswith("idr/tmp") or \ | |
path.startswith("idr/incoming"): | |
kind = "IDR" | |
elif path.startswith("uod/idr/metadata"): | |
kind = "Github" | |
elif path.startswith("bia"): | |
kind = "Embassy_S3_2" | |
elif path.startswith("https://uk1s3.embassy.ebi.ac.uk/bia-integrator-data"): | |
kind = "Embassy_S3" | |
zarr = "No" | |
if ".zarr" in path: | |
zarr = "Yes" | |
return (path, kind, zarr) | |
return (None, None, None) | |
def get_container_info(container, is_screen): | |
try: | |
if is_screen: | |
for plate in container.listChildren(): | |
for well in plate.listChildren(): | |
for wellsample in well.listChildren(): | |
path, kind, zarr = get_image_info(conn, wellsample.getImage()) | |
return (container.getId(), container.getName(), "Screen", path, kind, zarr) | |
else: | |
for dataset in container.listChildren(): | |
for image in dataset.listChildren(): | |
path, kind, zarr = get_image_info(conn, image) | |
return (container.getId(), container.getName(), "Project", path, kind, zarr) | |
except Exception as e: | |
print(e) | |
return None | |
with omero.cli.cli_login() as c: | |
conn = omero.gateway.BlitzGateway(client_obj=c.get_client()) | |
for project in conn.listProjects(): | |
print("Checking: ", project.getName()) | |
info = get_container_info(project, False) | |
if info: | |
df.loc[len(df)] = info | |
for screen in conn.listScreens(): | |
print("Checking: ", screen.getName()) | |
info = get_container_info(screen, True) | |
if info: | |
df.loc[len(df)] = info | |
df.sort_values(by=['name'], inplace=True) | |
df.to_csv('list_submissions.csv', index=False) | |
print(df) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment