I have a list of chemical id, such as: T3, T2B, F2A... I want to use the chemical IDs to…
- User
I have a list of chemical id, such as: T3, T2B, F2A... I want to use the chemical IDs to find the relevant chemical name, synonyms, isometric SMILES from PDB. How to do that using python?
- Assistant
You can use the RESTful API provided by the PDB (Protein Data Bank) to fetch the information in a JSON format, which you can then parse and extract the details you need, such as the chemical name, isomeric SMILES, and synonyms.
To do that, you can use the following code as an example:
import requests import json # Replace this list with your list of chemical IDs chemical_ids = ['T3', 'T2B', 'F2A'] base_url = 'https://data.rcsb.org/rest/v1/core/polymer_entity/' for chemical_id in chemical_ids: response = requests.get(base_url + chemical_id.upper()) if response.status_code == 200: data = json.loads(response.text) print(f"Chemical ID: {chemical_id}") name = data['rcsb_polymer_entity_container_identifiers']['chem_comp_name'] print(f"Chemical Name: {','.join(name)}") smiles = data['rcsb_polymer_entity']['rcsb_chem_comp_descriptor']['isomeric_smiles'] print(f"Isomeric SMILES: {smiles}") synonyms = data['rcsb_polymer_entity']['rcsb_entity_synonyms'] if synonyms: print(f"Synonyms: {', '.join([synonym['name'] for synonym in synonyms])}") else: print("Synonyms: None") print("\n") else: print(f"Chemical ID: {chemical_id} not found in PDB!\n")