OpenTreeOfLife / peyotl

python library for interacting with Open Tree of Life resources
BSD 2-Clause "Simplified" License
11 stars 7 forks source link

NexsonProxy provides no way to get study-level properties #137

Open jar398 opened 8 years ago

jar398 commented 8 years ago

such as ^ot:focalClade. or am I missing something?

kcranston commented 8 years ago

What are you trying to do? I don't use NexsonProxy to get study-level properties. I'd do something like this:

    for study_id, studyobj in phy.iter_study_objs():
        nexml = get_nexml_el(studyobj)
        year = nexml.get('^ot:studyYear')
jar398 commented 8 years ago

NexsonProxy does a lot of other things that seem very nice that aren't provided by the raw nexson blob (get_nexml_el), such as structured access to OTUs, trees, edges, and nodes.

"Provides high level wrappers around a Nexson data model blob to let it be treated as if it were a list of OTUs and a list of trees"

If it is useful, then as a matter of design it ought to provide at least as much service as the low-level form, since otherwise people will end up using a mix of the two, which would be confusing. If it is not useful, it should be deleted.

I am trying to rewrite parts of the conflict code (which is in jython and uses Java libraries) so that it looks more like peyotl. (I can't use peyotl directly since it doesn't run in jython.)

jimallman commented 8 years ago

@jar398, you can get study-level properties like so:

np = NexsonProxy(nexson=blob)
nexml = np._nexml_el
year = nexml.get('^ot:studyYear')

Would you like a less "private" getter, like np.get_nexml_el()?

jar398 commented 8 years ago

Yes, less private, please, and maybe more abstract (not just exposing the raw json).