Using HQL and capturing script output values

Hi OME team,

I’m in need of some help with using HQL to retrieve a omero object from the CLI (in a shell script). I imported a plate using the omero import CLI and it returned the “Plate:<plate_id>” value to me. Now I need to get the well IDs of the wells in that plate and was thinking HQL is the way to do so. I just don’t have enough familiarity with hql and the omero model to know how to structure the query.

Second, I want to feed those well IDs into a script (Wells_To_Plate.py, see: https://github.com/dsudar/OMEROscripts) which reformats each well into a Plate and following the instructions on: https://docs.openmicroscopy.org/omero/5.5.0/developers/scripts/style-guide.html#script-outputs it should return the plate_ID of the Plate created. How do I capture that output value when running the script from the CLI with “omero script launch”?

Thanks,
Damir

Something like this should do it:

bin/omero -q hql --style=plain "select 'Well:'||w.id from Well w where w.plate.id = 792" --limit=-1 | cut -f2 -d: | xargs echo
206730 206731 206732 206733 ...

Note that disabling limit this way is really only advisable when returning just IDs. If the query is taking substantial time to complete, you’ll likely need to run it in a loop with --offset.

This is doable, but would it make sense to take a step back and do this or both of the above in Python directly?

~Josh

Thanks @joshmoore. That works great and helps me understand better how to structure simple HQL queries.

Yes indeed, my initially simple shell scripts to automate imports and some post-processing are becoming complex enough that it starts making sense to do it in Python instead. I was just trying to stick with what has been so easy until now. Actually, I found I can retrieve the Plate generated by the Wells_To_Plate script using a HQL query so I can stick with this a little longer … :slight_smile:

Cheers,
Damir

:smile: Alright. Let us know when you’re ready to take that next step. Script inputs/outputs are all objects and so wouldn’t require any parsing. ~J.