biopragmatics / bioregistry

📮 An integrative registry of biological databases, ontologies, and nomenclatures.
https://bioregistry.io
MIT License
115 stars 49 forks source link

Add resolve function to Registry class #157

Closed cthoyt closed 2 years ago

cthoyt commented 2 years ago

The only issue is that because Identifiers.org is broken, this might not work

    def get_resolver(self, prefix: str, identifier: str) -> Optional[str]:
        """Get the resolver string.

        :param prefix: The prefix used in the metaregistry
        :param identifier: The identifier with the prefix
        :return: The URL in the registry for the CURIE, if it's able to provide one

        >>> from bioregistry import get_registry
        >>> get_registry("miriam").get_resolver("go", "1234567")
        'https://identifiers.org/GO:1234567'
        >>> assert get_registry("fairsharing").get_resolver(..., ...) is None
        """
        if self.resolver_url is None:
            return None
        return self.resolver_url.replace("$1", prefix).replace("$2", identifier)
cthoyt commented 2 years ago

This is done