diff --git a/src/curies/api.py b/src/curies/api.py index b11e62e..39d4573 100644 --- a/src/curies/api.py +++ b/src/curies/api.py @@ -566,6 +566,11 @@ def bimap(self) -> Mapping[str, str]: """Get the bijective mapping between CURIE prefixes and URI prefixes.""" return {r.prefix: r.uri_prefix for r in self.records} + @property + def reverse_bimap(self) -> Mapping[str, str]: + """Get the bijective mapping between URI CURIE prefixes and CURIE prefixes.""" + return {r.uri_prefix: r.prefix for r in self.records} + def _match_record( self, external: Record, case_sensitive: bool = True ) -> Mapping[RecordKey, list[str]]: diff --git a/tests/test_api.py b/tests/test_api.py index 01256c1..9e1d94b 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -396,7 +396,9 @@ def test_convert(self): def _assert_convert(self, converter: Converter): self.assertIn("GO", converter.prefix_map) self.assertIn("GO", converter.bimap) + self.assertIn("GO", converter.reverse_bimap.values()) self.assertIn("http://purl.obolibrary.org/obo/GO_", converter.reverse_prefix_map) + self.assertIn("http://purl.obolibrary.org/obo/GO_", converter.reverse_bimap) self.assertIn("http://purl.obolibrary.org/obo/GO_", converter.trie) self.assertIn("http://purl.obolibrary.org/obo/GO_", converter.bimap.values()) for curie, uri in [