def __new__(cls, something): if '10.' in something: if 'http' in something and 'doi.org' not in something: pass # probably a publisher uri that uses the handle else: return idlib.Doi(something) if 'orcid' in something: return idlib.Orcid(something) if '/ror.org/' in something or something.startswith('ror:'): return idlib.Ror(something) if 'protocols.io' in something: return idlib.Pio(something) return oq.OntId(something) return OntTerm(something) # use the better local version of OntTerm
def test_ontid_curie_as_iri(self): try: oq.OntId(iri='BIRNLEX:796') raise AssertionError('should have failed with ValueError') except ValueError: pass
def test_ontid_curie(self): oq.OntId(curie='BIRNLEX:796')
def test_ontid_iri(self): oq.OntId(iri='http://uri.neuinfo.org/nifa/nifstd/birnleex_796')
def test_ontid_curie_uriref(self): c = oq.OntId(rdflib.URIRef(oq.OntId('RO:0000087'))) cl = oq.OntId('RO:0000087') assert c.curie == cl.curie, f'{c!r} != {cl!r}'
def test_a_curies(self): oq.OntCuries['new-prefix'] = 'https://my-prefixed-thing.org/' oq.OntCuries['new-prefix'] = 'https://my-prefixed-thing.org/' a = oq.OntCuries['new-prefix'] oq.OntId('new-prefix:working')
def test_id(self): oq.OntId('UBERON:0000955') oq.OntId('http://purl.obolibrary.org/obo/UBERON_0000955') oq.OntId(prefix='UBERON', suffix='0000955')
SKIP_NETWORK, reason='Skipping due to network requirement') oq.OntCuries(CURIE_MAP) suffixes = ( '', 'hello', 'world', 'ev:il', '1234567', '1232/123123/asdfasdf', 'lol_this#is/even-worse/_/123', ) test_graph = rdflib.Graph() triples = ( ('UBERON:0000955', 'rdf:type', 'owl:Class'), ('UBERON:0000955', 'rdfs:label', 'brain'), ('UBERON:0000955', 'rdfs:subClassOf', 'owl:Thing'), ('BIRNLEX:796', 'rdf:type', 'owl:Class'), ('BIRNLEX:796', 'rdfs:label', 'Brain'), ('BIRNLEX:796', 'definition:', 'Gray mushy thing in the nogin.'), ('BIRNLEX:796', 'NIFRID:synonym', 'biocpu'), ('BIRNLEX:796', 'NIFRID:synonym', 'thinkthink'), ) for proto_t in triples: test_graph.add( rdflib.URIRef(oq.OntId(e)) if ':' in e else rdflib.Literal(e) for e in proto_t)
# FIXME TODO per service ... + mismatch warning oq.OntCuries({ 'rdf': str(rdflib.RDF), 'rdfs': str(rdflib.RDFS), 'owl': str(rdflib.OWL), 'BFO': 'http://purl.obolibrary.org/obo/BFO_', 'UBERON': 'http://purl.obolibrary.org/obo/UBERON_', 'NLX': 'http://uri.neuinfo.org/nif/nifstd/nlx_', 'BIRNLEX': 'http://uri.neuinfo.org/nif/nifstd/birnlex_', 'ILX': 'http://uri.interlex.org/base/ilx_', 'RO': 'http://purl.obolibrary.org/obo/RO_', 'hasRole': 'http://purl.obolibrary.org/obo/RO_0000087', }) oq.OntCuries({ 'hasPart': oq.OntId('BFO:0000051'), 'partOf': oq.OntId('BFO:0000050'), }) OntId = oq.OntId class ServiceBase: def setUp(self): class OntTerm(oq.OntTerm): pass OntTerm.query_init(self.remote) self.OntTerm = OntTerm def test_ontid(self): t = self.OntTerm(OntId('UBERON:0000955'))