Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce KEGG ID conversions to BridgeDB service #104

Merged
merged 2 commits into from
May 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [dev] - unreleased
### Added
* KEGG ID conversions support to BridgeDB service [#101](https://github.com/RECETOX/MSMetaEnhancer/issues/101)
### Changed
### Removed

## [0.2.2] - 2022-04-27
### Added
* introduced `error` level into logging [#95](https://github.com/RECETOX/MSMetaEnhancer/issues/95)
Expand Down
27 changes: 24 additions & 3 deletions MSMetaEnhancer/libs/converters/web/BridgeDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,42 @@ def __init__(self, session):
# service URLs
self.endpoints = {'BridgeDB': 'https://webservice.bridgedb.org/Human/xrefs/'}

self.codes = {'hmdbid': 'Ch', 'pubchemid': 'Cpc', 'chemspiderid': 'Cs', 'wikidataid': 'Wd', 'chebiid': 'Ce'}
self.codes = {'hmdbid': 'Ch', 'pubchemid': 'Cpc', 'chemspiderid': 'Cs', 'wikidataid': 'Wd', 'chebiid': 'Ce',
'keggid': 'Ck'}
self.identifiers = {'PubChem-compound': 'pubchemid', 'Chemspider': 'chemspiderid', 'ChEBI': 'chebiid',
'HMDB': 'hmdbid', 'Wikidata': 'wikidataid'}
'HMDB': 'hmdbid', 'Wikidata': 'wikidataid', 'KEGG Compound': 'keggid'}

# generate top level methods defining allowed conversions
conversions = [('hmdbid', 'pubchemid', 'from_hmdbid'),
('hmdbid', 'chemspiderid', 'from_hmdbid'),
('hmdbid', 'wikidataid', 'from_hmdbid'),
('hmdbid', 'chebiid', 'from_hmdbid'),
('hmdbid', 'keggid', 'from_hmdbid'),
('pubchemid', 'hmdbid', 'from_pubchemid'),
('pubchemid', 'chemspiderid', 'from_pubchemid'),
('pubchemid', 'wikidataid', 'from_pubchemid'),
('pubchemid', 'chebiid', 'from_pubchemid'),
('pubchemid', 'keggid', 'from_pubchemid'),
('chemspiderid', 'hmdbid', 'from_chemspiderid'),
('chemspiderid', 'pubchemid', 'from_chemspiderid'),
('chemspiderid', 'wikidataid', 'from_chemspiderid'),
('chemspiderid', 'chebiid', 'from_chemspiderid'),
('chemspiderid', 'keggid', 'from_chemspiderid'),
('wikidataid', 'hmdbid', 'from_wikidataid'),
('wikidataid', 'pubchemid', 'from_wikidataid'),
('wikidataid', 'chemspiderid', 'from_wikidataid'),
('wikidataid', 'chebiid', 'from_wikidataid'),
('wikidataid', 'keggid', 'from_wikidataid'),
('chebiid', 'hmdbid', 'from_chebiid'),
('chebiid', 'pubchemid', 'from_chebiid'),
('chebiid', 'chemspiderid', 'from_chebiid'),
('chebiid', 'wikidataid', 'from_chebiid')
('chebiid', 'wikidataid', 'from_chebiid'),
('chebiid', 'keggid', 'from_chebiid'),
('keggid', 'hmdbid', 'from_keggid'),
('keggid', 'pubchemid', 'from_keggid'),
('keggid', 'chemspiderid', 'from_keggid'),
('keggid', 'wikidataid', 'from_keggid'),
('keggid', 'chebiid', 'from_keggid'),
]
Comment on lines 22 to 52
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this could be also at some point made as all possible combinations between the 4 initial identifiers - otherwise all good!

self.create_top_level_conversion_methods(conversions)

Expand Down Expand Up @@ -91,6 +102,16 @@ async def from_chebiid(self, chebiid):
args = f'{self.codes["chebiid"]}/{chebiid}'
return await self.call_service(args)

async def from_keggid(self, keggid):
"""
Convert KEGG ID to all possible IDs using BridgeDB web service

:param keggid: given KEGG ID number
:return: obtained IDs
"""
args = f'{self.codes["keggid"]}/{keggid}'
return await self.call_service(args)

async def call_service(self, args):
response = await self.query_the_service('BridgeDB', args)
if response:
Expand Down