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

Convert IRI -> CURIE using bioregistry while parse-ing a KGCL command. #6

Merged
merged 9 commits into from
Aug 16, 2022

Conversation

hrshdhgd
Copy link
Collaborator

@hrshdhgd hrshdhgd commented Jul 28, 2022

Triggered by this comment.

@hrshdhgd hrshdhgd requested review from cmungall and matentzn July 28, 2022 20:16
src/kgcl_schema/grammar/parser.py Outdated Show resolved Hide resolved
pref, i = parse_iri(uri[0].replace("<", "").replace(">",""))
pref = get_preferred_prefix(pref)
curie = curie_to_str(pref, i)
input = input.replace(uri[0], curie)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(but dont sweat it)

src/kgcl_schema/grammar/parser.py Outdated Show resolved Hide resolved
src/kgcl_schema/grammar/parser.py Outdated Show resolved Hide resolved
src/kgcl_schema/grammar/parser.py Outdated Show resolved Hide resolved
pref = get_preferred_prefix(pref)
curie = curie_to_str(pref, i)
input = input.replace(uri[0], curie)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems very hacky to replace URIs with CURIEs just so the KGCL parser works. Why is that necessary?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When adding synonyms, apparently only CURIEs are expected and ehnce the conversion from URI => CURIE. Just a judgement call, there could be a better way of handling this. Ideas?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont know how that parser works, but if CURIES are expected, wouldn't it be better to make sure the input is "valid kgcl" using a validator and not trying to hack anything? The user can be forced to provide CURIEs if that is what the spec wants..

In any case, I would for sure factor out the method def replace_uris_with_curies_in_kgcl_command(input) into its how, document it etc. Not convinced this is great but if its necessary to be parseable than so be it.

@hrshdhgd hrshdhgd merged commit 87901f1 into main Aug 16, 2022
@hrshdhgd hrshdhgd deleted the add-bioregistry branch August 16, 2022 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Do not require <>s in URIs
3 participants