Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a method to SchemaView that returns the induced disjunctive range of a slot #2103

Open
sierra-moxon opened this issue May 9, 2024 Discussed in #2101 · 2 comments
Open
Assignees

Comments

@sierra-moxon
Copy link
Member

Discussed in https://github.com/orgs/linkml/discussions/2101

Originally posted by eecavanna May 7, 2024
Hi, this is my first time posting a question here.

Background

I develop an application that interacts with a database that complies with a LinkML schema. That LinkML schema is: nmdc-schema.

I am currently writing a Python script that uses an instance of LinkML's SchemaView Python class to traverse that LinkML schema. I am particularly interested in identifying (and learning about) slots that can contain references to other slots. This is all in pursuit of implementing some referential integrity checks.

That nmdc-schema schema contains the definition of a class named Extraction. Based on a conversation with a teammate and my limited understanding of LinkML, I am under the impression that the has_input slot (in the context of the Extraction class, specifically) must consist of [a reference to] either a Biosample or a ProcessedSample, despite the default range of the has_input slot being NamedThing.

Question

  1. How can I use a SchemaView instance to get that list: Biosample and ProcessedSample?

Here's a screenshot of a Python notebook where I've invoked a few SchemaView methods:

  • A) slot_definition.range (where slot_definition is returned by .induced_slot()) gives me the default range of the slot
  • B) slot_definition.any_of[0].range and [1].range give me the two class names in the any_of list
  • C) schema_view.slot_range_as_union( . . . ) gives me all three class names

Assuming my impression (stated in the "Background" section above) is correct, method (B) is the only one that gives me what I'm looking for. However, I only knew to look at the any_of list after a teammate pointed it out to me. Is there a more general way a SchemaView instance can be used to get a "fully resolved" list of the classes whose instances a slot can contain [references to] (instead of "manually" checking for the presence of a boolean expression; e.g. any_of, none_of)?

image

Footnote for future readers: I work with some of the LinkML developers and have made some assumptions about their familiarity with my situation.

@sierra-moxon sierra-moxon self-assigned this May 9, 2024
@sierra-moxon sierra-moxon added schemaview enhancement New feature or request labels May 9, 2024
@cmungall cmungall changed the title How can I use SchemaView to get the "effective" range of a slot? Add a method to SchemaView that returns the induced disjunctive range of a slot May 9, 2024
@cmungall
Copy link
Member

cmungall commented May 9, 2024

I changed the title, this is a feature request for SV to return the induced slot range as union

@sneakers-the-rat
Copy link
Collaborator

linking my comment from the discussion, i don't think we should just add a method here! https://github.com/orgs/linkml/discussions/2101#discussioncomment-9424071

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants