From 53560c3c71ef71af8724788b7a7df0f132cc749e Mon Sep 17 00:00:00 2001 From: Carlos Vega <carlos.vega@uni.lu> Date: Tue, 19 Nov 2019 12:19:01 +0100 Subject: [PATCH] added method to convert entity codes from colon to underscore syntax --- biokb/utils.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/biokb/utils.py b/biokb/utils.py index 092c792..270a7ec 100644 --- a/biokb/utils.py +++ b/biokb/utils.py @@ -1,5 +1,10 @@ -def uri_to_code(uri: str) -> str: - """Translates URIs such as http://lcsb.uni.lu/biokb/entities/BTO_0001043 to BTO_0001043 +def standarise_underscored_entity_code(entity_code: str) -> str: + return entity_code.replace(':', '_', 1) + + +def uri_to_entity_code(uri: str) -> str: + """Translates URIs such as http://lcsb.uni.lu/biokb/entities/BTO_0001043 to BTO:0001043 + Replaces only the first underscore with colon. Arguments: uri {str} -- [description] @@ -7,4 +12,4 @@ def uri_to_code(uri: str) -> str: Returns: str -- [description] """ - return uri.split('/')[-1] + return uri.split('/')[-1].replace('_', ':', 1) -- GitLab