Skip to content

Commit

Permalink
Add infrastructure for annotating provider relationships
Browse files Browse the repository at this point in the history
References #32 and #21
  • Loading branch information
cthoyt committed Apr 10, 2021
1 parent 04e2625 commit 1462f1a
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/bioregistry/data/bioregistry.json
Expand Up @@ -567,7 +567,9 @@
"is_identifiers": true,
"is_obo": false,
"prefix": "APID.INTERACTIONS"
}
},
"provides": "uniprot",
"type": "provider"
},
"apo": {
"bioportal": {
Expand Down Expand Up @@ -23990,6 +23992,7 @@
}
},
"validatordb": {
"example": "2h6o",
"miriam": {
"deprecated": false,
"description": "Database of validation results for ligands and non-standard residues in the Protein Data Bank.",
Expand All @@ -24008,7 +24011,10 @@
"is_identifiers": true,
"is_obo": false,
"prefix": "VALIDATORDB"
}
},
"provides": "pdb",
"type": "provider",
"url": "https://webchem.ncbr.muni.cz/Platform/ValidatorDb/ByStructure/$1"
},
"vandf": {
"biolink": {
Expand Down
30 changes: 30 additions & 0 deletions src/bioregistry/resolve.py
Expand Up @@ -292,6 +292,36 @@ def get_owl_download(prefix: str) -> Optional[str]:
return entry.get('ols', {}).get('version.iri')


def is_provider(prefix: str) -> bool:
"""Get if the prefix is a provider.
:param prefix: The prefix to look up
:returns: if the prefix is a provider
>>> assert not is_provider('pdb')
>>> assert is_provider('validatordb')
"""
entry = get(prefix)
if entry is None:
return False
return entry.get('type') == 'provider'


def get_provides_for(prefix: str) -> Optional[str]:
"""Get the resource that the given prefix provides for, or return none if not a provider.
:param prefix: The prefix to look up
:returns: The prefix of the resource that the given prefix provides for, if it's a provider
>>> assert get_provides_for('pdb') is None
>>> assert 'pdb' == get_provides_for('validatordb')
"""
entry = get(prefix)
if entry is None:
return None
return entry.get('provides')


def parse_curie(curie: str) -> Union[Tuple[str, str], Tuple[None, None]]:
"""Parse a CURIE, normalizing the prefix and identifier if necessary.
Expand Down

0 comments on commit 1462f1a

Please sign in to comment.