Closed mwes closed 4 years ago
Per request, an example inverse would be given the URI "https://hub.sd2e.org/user/sd2e/design/UWBF_6390/1" and "Transcriptic" as the lab, we would want this method to return "6390".
This is the inverse of the current query_designs_by_lab_ids which, given "6390" and "Transcriptic" resolves to the URI "https://hub.sd2e.org/user/sd2e/design/UWBF_6390/1"
sbh-prospector can be used to do this lookup. Here's a function that uses sbh-prospector that looks up the info:
import sbh_prospector as sbhp
def query_lab_id(sbh_query, uri, lab):
lab_uri = 'http://sd2e.org#{}_UID'.format(lab)
result = sbhp.o_query(sbh_query, uri, lab_uri)
if result:
return result[0]
else:
return None
Example calls:
query_lab_id(sbhq, 'https://hub.sd2e.org/user/sd2e/design/UWBF_6390/1', 'Transcriptic')
'6390'
query_lab_id(sbhq, 'https://hub.sd2e.org/user/sd2e/design/UWBF_6390/1', 'Ginkgo')
'162063'
If you still want a function added to synbiohub_adapter we can write one.
Thanks - what is the expected usage of sbh_prospector vs. synbiohub_adapter going forward? Should we be using sbh_prospector?
It would be good to wrap this in a common function, otherwise this snippet will need to be repeated in various codebases that want to do this e.g. XPlan. It also lets you hide the internal structure of triple store in case that ever changes
I think sbh_prospector is for letting folks explore on their own, or write a quick query on their own as the example above demonstrates. No need to wait for a function to get added to synbiohub_adapter.
Your argument about making this a common function is a good one. I think of it in terms of promotion. A quick query can be written, then as it evolves into a commonly used function, it can be promoted to a library routine with an appropriate API.
Certainly the function above does nothing in terms of hiding the structure of the internals, and that's another good point you make. I hope, however, that it demystifies a little bit. We can add an method to synbiohub_adapter with a beefier API that matches query_designs_by_lab_ids
.
Given a URI, Dan Bryce needs to resolve that URI back to the internal id a lab uses. The use case is telling a lab, e.g. Strateos to use a given strain in an experiment. Strateos, however, does not understand SD2 Common Names/URIs, but they do understand their internal identifiers. This is needed as part of XPlan/round-trip automation for Yeast States.