Skip to content

Add ChEBI web service converter - #183

Open
hechth with Copilot wants to merge 10 commits into
mainfrom
copilot/add-new-chebi-service
Open

Add ChEBI web service converter#183
hechth with Copilot wants to merge 10 commits into
mainfrom
copilot/add-new-chebi-service

Conversation

Copilot AI commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Adds a new ChEBI converter backed by the ChEBI REST API, exposing chemical entity lookups and cross-identifier conversions.

Changes

MSMetaEnhancer/libs/converters/web/ChEBI.py

  • Two API endpoints used:
    • /search?query=...&searchCategory={CHEBI_NAME|INCHI_KEY|INCHI|SMILES}&maximumResults=10&stars=ALL
    • /chemicalentity/{chebiId}
  • 25 conversion methods covering all pairwise combinations of: chebiid, compound_name, inchikey, inchi, smiles, formula
  • Dynamically registered via create_top_level_conversion_methods, consistent with existing converters

MSMetaEnhancer/libs/converters/web/__init__.py

  • ChEBI added to __all__ and imported alongside existing converters

tests/test_ChEBI.py

  • Tests for service availability, key conversion round-trips (chebiidinchikey, etc.), raw response format validation, and get_conversion_functions() output

Example usage:

converters = ["ChEBI"]
jobs = [("chebiid", "inchikey"), ("inchikey", "chebiid"), ("compound_name", "smiles")]
await app.annotate_spectra(converters=converters, jobs=jobs)

Copilot AI linked an issue Aug 25, 2026 that may be closed by this pull request
Co-authored-by: hechth <12066490+hechth@users.noreply.github.com>
Copilot AI changed the title [WIP] Add new ChEBI service with search options and conversions Add ChEBI web service converter Aug 25, 2026
Copilot AI requested a review from hechth August 25, 2026 13:34
@hechth

hechth commented Aug 25, 2026

Copy link
Copy Markdown
Member

@copilot use CHEBI:60888 for the testing entity - the results can be found here: https://www.ebi.ac.uk/chebi/CHEBI:60888

Co-authored-by: hechth <12066490+hechth@users.noreply.github.com>

Copilot AI commented Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

@copilot use CHEBI:60888 for the testing entity - the results can be found here: https://www.ebi.ac.uk/chebi/CHEBI:60888

Updated the test entity to CHEBI:60888 (caffeine) with its corresponding InChIKey RYYVLZVUVIJVGH-UHFFFAOYSA-N in commit Use CHEBI:60888 as test entity in test_ChEBI.py.

@hechth

hechth commented Aug 25, 2026

Copy link
Copy Markdown
Member

@copilot I think your API url is wrong - the query to search for the chebi ID is https://www.ebi.ac.uk/chebi/backend/api/public/compound/CHEBI:60888/

also add a test for the name search function using the name "bapta" as can be seen in this url: https://www.ebi.ac.uk/chebi/backend/api/public/es_search/?term=bapta&page=1&size=15

Co-authored-by: hechth <12066490+hechth@users.noreply.github.com>

Copilot AI commented Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

@copilot I think your API url is wrong - the query to search for the chebi ID is https://www.ebi.ac.uk/chebi/backend/api/public/compound/CHEBI:60888/

also add a test for the name search function us...

Fixed in the latest commit. The endpoints are now:

  • ChEBI ID lookup: public/compound/{chebiId}/
  • Name/InChIKey/InChI/SMILES search: public/es_search/?term={term}&page=1&size=15

Also added test_compound_name_to_chebiid using "bapta" as the search term.

Co-authored-by: hechth <12066490+hechth@users.noreply.github.com>
Copilot AI and others added 2 commits August 25, 2026 14:44
Co-authored-by: hechth <12066490+hechth@users.noreply.github.com>
Co-authored-by: hechth <12066490+hechth@users.noreply.github.com>
Copilot AI and others added 2 commits August 25, 2026 15:45
…ata for CHEBI:60888

Co-authored-by: hechth <12066490+hechth@users.noreply.github.com>
Co-authored-by: hechth <12066490+hechth@users.noreply.github.com>
@hechth

hechth commented Aug 25, 2026

Copy link
Copy Markdown
Member

@copilot add "InChI=1S/C22H24N2O10/c25-19(26)11-23(12-20(27)28)15-5-1-3-7-17(15)33-9-10-34-18-8-4-2-6-16(18)24(13-21(29)30)14-22(31)32/h1-8H,9-14H2,(H,25,26)(H,27,28)(H,29,30)(H,31,32)" as inchi for the tests and also add Iupac name "2,2',2'',2'''-[ethane-1,2-diylbis(oxy-2,1-phenylenenitrilo)]tetraacetic acid" - also the iupac name should be usable as input and output if that is allowed by the api

@hechth
hechth marked this pull request as ready for review August 25, 2026 16:08
…ter and tests

Co-authored-by: hechth <12066490+hechth@users.noreply.github.com>

Copilot AI commented Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

@copilot add "InChI=1S/C22H24N2O10/c25-19(26)11-23(12-20(27)28)15-5-1-3-7-17(15)33-9-10-34-18-8-4-2-6-16(18)24(13-21(29)30)14-22(31)32/h1-8H,9-14H2,(H,25,26)(H,27,28)(H,29,30)(H,31,32)" as inchi for t...

Done. Added in the latest commit:

  • INCHI constant set to "InChI=1S/C22H24N2O10/..." and assertion in test_chebiid_to_inchi
  • IUPAC_NAME constant set to "2,2',2'',2'''-[ethane-1,2-diylbis(oxy-2,1-phenylenenitrilo)]tetraacetic acid"
  • iupac_name is now extracted from synonyms (entity endpoint, where type == "IUPAC NAME") and from iupac_names list (es_search _source)
  • All six pairwise conversions involving iupac_name are registered (e.g. iupac_name → chebiid, chebiid → iupac_name, etc.) — the from_iupac_name method uses the same es_search endpoint as the other search-based methods
  • New integration tests: test_chebiid_to_iupac_name, test_inchi_to_chebiid, test_iupac_name_to_chebiid

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add new ChEBI service

2 participants