We're Hiring!

OMERO APIs for free format/ key-value search

General user discussion about using the OMERO platform to its fullest. Please ask new questions at https://forum.image.sc/tags/omero
Please note:
Historical discussions about OMERO. Please look for and ask new questions at https://forum.image.sc/tags/omero

There are workflow guides for various OMERO functions on our help site - http://help.openmicroscopy.org

You should find answers to any basic questions about using the clients there.

OMERO APIs for free format/ key-value search

Postby pz3977 » Thu Jul 24, 2014 2:08 pm

Hi,
I am developing a software which is aimed to connect to external databases, search ( e.g. free format search on metadata related to images) and fetch data out of them. I developed my connection to PDB (Protein Data Banks) using their APIs. However, I could not find APIs for free format search or key-value search on OMERO.

Could you please help me how I can search on metadata related to images?

Best regards,
pz3977
pz3977
 
Posts: 31
Joined: Thu Jul 10, 2014 11:39 am

Re: OMERO APIs for free format/ key-value search

Postby wmoore » Fri Jul 25, 2014 11:22 am

I'll answer your question in the context of OMERO 5.0.3 which is due to be released within the next week, and contains several updates to the Lucene-based "free format" searching functionality in the clients and server.

The Python BlitzGateway searchObjects() has a few extra parameters:

Code: Select all
searchObjects(obj_types, text, created=None, fields=(), batchSize=1000, page=0, searchGroup=None, ownedBy=None, useAcquisitionDate=False):


This will return you a list of the specified objects where 'obj_types' is a list of
Code: Select all
["Project", "Dataset", "Image", "Screen", "Plate", "Well"]


E.g.
Code: Select all
>>> for i in conn.searchObjects(["Image"], "tiff"):
>>>     print i.getName()
>>>     
Fig 1A-1min.ome.tiff
Fig 1A-5min.ome.tiff
Fig 2A.ome.tiff
6x4y1z1t1c8b-swatch-2s2p4w2ws.ome-v2010-06.ome.tiff


I just created a script with examples of using all the other parameters
https://gist.github.com/will-moore/e5fe45145fbfc5494127


For key / value searching, you really need to query the Database directly, which requires some knowledge of the OME model.

Have a look at this "Metadata search" example https://gist.github.com/will-moore/5782 ... rch-py-L13

This is an OMERO script which adds Metadata search functionality to the OMERO clients if you add the script to the server, but should give you some ideas for how to query some fields of the DB.

Hope that helps,

Will.
User avatar
wmoore
Team Member
 
Posts: 674
Joined: Mon May 18, 2009 12:46 pm

Re: OMERO APIs for free format/ key-value search

Postby pz3977 » Mon Aug 04, 2014 7:41 am

Hi Will,

Thanks for the complete reply and my apology for late reply. I was not working last week.
I wondered if OMERO.py version 5.0.3 is available. I could not find a link for download!

Best regards,
Parisa
pz3977
 
Posts: 31
Joined: Thu Jul 10, 2014 11:39 am

Re: OMERO APIs for free format/ key-value search

Postby jmoore » Mon Aug 04, 2014 10:04 am

Hi Parisa,

sorry for the delay. We found a few last minutes bugs in the 5.0.3 release candidates and are hoping now to have a build this week. You can either build from the `origin/dev_5_0` yourself, or use one of the builds from http://ci.openmicroscopy.org/job/OMERO-5.0-latest/?. For example, if you have Ice 3.4 installed, you can look here:

http://ci.openmicroscopy.org/job/OMERO-5.0-latest/ICE=3.4,label=ome-c6100-1/lastSuccessfulBuild/artifact/src/target/

Cheers,
~Josh.
User avatar
jmoore
Site Admin
 
Posts: 1591
Joined: Fri May 22, 2009 1:29 pm
Location: Germany

Re: OMERO APIs for free format/ key-value search

Postby pz3977 » Mon Aug 04, 2014 11:19 am

Hi Josh,

Thanks for the reply. Since I am very new to OMERO and python , I prefer to use a ready version with minimum number of bugs. I have Ice3.4 installed but I could not find Omero.py v 5.0.3 in

http://ci.openmicroscopy.org/job/OMERO- ... rc/target/

Should I build some thing? If your release is coming this week, I prefer to wait more few days and get a stable version.

Regards,
pz3977
pz3977
 
Posts: 31
Joined: Thu Jul 10, 2014 11:39 am

Re: OMERO APIs for free format/ key-value search

Postby jmoore » Mon Aug 04, 2014 11:55 am

pz3977 wrote:If your release is coming this week, I prefer to wait more few days and get a stable version.


That makes complete sense. The release will be announced here on the forums and on the mailing lists.
~J.
User avatar
jmoore
Site Admin
 
Posts: 1591
Joined: Fri May 22, 2009 1:29 pm
Location: Germany

Re: OMERO APIs for free format/ key-value search

Postby pz3977 » Tue Aug 12, 2014 6:55 am

Hi,
First of all I want to thank you for improving search functionality in new version. I was looking forward to using it. Then I would like to ask the following questions:

1. Is there any way to search a keyword without specifing the field name? As it is mentioned in https://gist.github.com/will-moore/e5fe45145fbfc5494127, I could search a keyword which exists for example, in file.contents:

for i in conn.searchObjects(["Dataset", "Image"], "tiff", fields=["file.contents"]):
print i.OMERO_CLASS, i.getName()

In order to search a keyword which may exists in any field, is there any solution?(Does fields=[] works?)) or Can I search all metadata using following code?

for i in conn.searchObjects(["Dataset", "Image"], "tiff"):
print i.OMERO_CLASS, i.getName()

2. I was wondered about the regular expression which is used for search. In my experiment, it could not find the image, when part of text (the last part) in its metadata is being searched.

3. How can I search metadata releated microscope settings? Are the search fields limited to 'name', 'description', 'annotation', 'file.name', 'file.format', 'file.contents', 'file.path' or I could find other metadata as well?

Best regards,
pz3977
pz3977
 
Posts: 31
Joined: Thu Jul 10, 2014 11:39 am

Re: OMERO APIs for free format/ key-value search

Postby wmoore » Tue Aug 12, 2014 9:07 am

Hi,

Maybe you missed the first example at https://gist.github.com/will-moore/e5fe45145fbfc5494127 for searching without specifying fields (just as you'd guessed):

Code: Select all
for i in conn.searchObjects(["Image"], "tiff"):
   print i.OMERO_CLASS, i.getName()


To build the Lucene search index, we generate keywords from text by splitting on non-alphanumeric characters. So, to find eGFP-H2B you'd need to search for *GFP or eGFP or H2B or H2*, but not GFP. You can read a little more about this at the user-guide: http://help.openmicroscopy.org/search.html.

For metadata search, did you look at https://gist.github.com/will-moore/5782 ... rch-py-L13? You can upload this script directly to the OMERO server since it is an OMERO.script (as described here http://www.openmicroscopy.org/site/supp ... oad-script) and you will have a basic metadata search UI available in the clients under the scripts menu.
Or you can just use the code examples. It gets a little tricky since you have to have some knowledge of the OMERO model to build the correct DB query. But that should at least get you started.
User avatar
wmoore
Team Member
 
Posts: 674
Joined: Mon May 18, 2009 12:46 pm

Re: OMERO APIs for free format/ key-value search

Postby pz3977 » Tue Aug 12, 2014 10:18 pm

Hi wmoore,

Many thanks for the reply. As you said, I tried to upload Metadata_Search.py which is provided in https://gist.github.com/will-moore/5782 ... rch-py-L13, to check how metadata search works, however, it does not identify "script" keyword. Following are the steps which I did:
Since I do not have any server locally installed, I tried to connect to server ""omero.ohsu.edu"" to upload the script:(using OMERO.py)
$ bin/omero shell --login
server..
login..
pass..
in[1]: omero script upload Metadata_Script.py --official

the error : invalid syntax, pointing to "script"

I appreciate it if you could help me. How can I upload and use the script without locally installed server?

Regards,
pz3977
pz3977
 
Posts: 31
Joined: Thu Jul 10, 2014 11:39 am

Re: OMERO APIs for free format/ key-value search

Postby wmoore » Tue Aug 12, 2014 11:26 pm

You don't need to use the shell. Simply do this:

Code: Select all
$ bin/omero script upload path/to/Metadata_Script.py --official


and you will get asked for server and login details if you are not already logged in.
You'll need to be an admin to upload 'official' scripts.

Then look in the scripts in the clients and you'll see the script under whatever path/to/Metadata_Script.py you used above (so it helps to get this right if you want other users to find scripts in the 'right' place).

Hope that helps,

Will.
User avatar
wmoore
Team Member
 
Posts: 674
Joined: Mon May 18, 2009 12:46 pm

Next

Return to User Discussion

Who is online

Users browsing this forum: Google [Bot] and 1 guest