def get_label(self, identifier):
     obo_id = Text.curie_to_obo(identifier)
     text = """
     prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
     select distinct ?label
     from <http://reasoner.renci.org/ontology>
     where {
         $obo_id rdfs:label ?label .
     }
     """
     results = self.triplestore.query_template(inputs={'obo_id': obo_id},
                                               outputs=['label'],
                                               template_text=text)
     if len(results) < 1:
         return ''
     return results[0]['label']
def test_obo_to_curie():
    test_set = {
        'http://purl.obolibrary.org/obo/prefix_suffix':
        'prefix:suffix',
        'http://purl.obolibrary.org/obo/prefix_suffix_suffix':
        'prefix:suffix_suffix',
        'http://purl.obolibrary.org/obo/path/prefix_suffix':
        'path_prefix:suffix',
        'http://purl.obolibrary.org/obo/path/prefix#suffix':
        'path_prefix:suffix',
        'http://purl.obolibrary.org/obo/path/prefix#suffix_more_suffix':
        'path_prefix:suffix_more_suffix'
    }
    for obo, curie in test_set.items():
        assert Text.obo_to_curie(obo) == curie
    # could not find a way to smartly go back to urls containing # back
    do = 3
    for obo, curie in test_set.items():
        if do == 1:
            break
        do -= 1
        assert Text.curie_to_obo(curie) == f'<{obo}>'