There is such an endpoint at pdb: http://www.rcsb.org/pdb/software/rest.do see the part on "Third-party annotations and PDB to UniProtKB mapping".
Example mapping for 4hhb.A chain: http://www.rcsb.org/pdb/rest/das/pdb_uniprot_mapping/alignment?query=4hhb.A
You can make a request to that endpoin and parse out Uniprot accession id of a chain from xml that is returned. If you need any additional info (like protein name on Unirpot) you can use the accession id to do that.
Here is some sample code:
import requests
from xml.etree.ElementTree import fromstring
pdb_id = '4hhb.A'
pdb_mapping_url = 'http://www.rcsb.org/pdb/rest/das/pdb_uniprot_mapping/alignment'
uniprot_url = 'http://www.uniprot.org/uniprot/{}.xml'
def get_uniprot_accession_id(response_xml):
root = fromstring(response_xml)
return next(
el for el in root.getchildren()[0].getchildren()
if el.attrib['dbSource'] == 'UniProt'
).attrib['dbAccessionId']
def get_uniprot_protein_name(uniport_id):
uinprot_response = requests.get(
uniprot_url.format(uniport_id)
).text
return fromstring(uinprot_response).find(
'.//{http://uniprot.org/uniprot}recommendedName/{http://uniprot.org/uniprot}fullName'
).text
def map_pdb_to_uniprot(pdb_id):
pdb_mapping_response = requests.get(
pdb_mapping_url, params={'query': pdb_id}
).text
uniprot_id = get_uniprot_accession_id(pdb_mapping_response)
uniprot_name = get_uniprot_protein_name(uniprot_id)
return {
'pdb_id': pdb_id,
'uniprot_id': uniprot_id,
'uniprot_name': uniprot_name
}
print map_pdb_to_uniprot(pdb_id)
Result:
{'pdb_id': '4hhb.A', 'uniprot_id': 'P69905', 'uniprot_name': 'Hemoglobin subunit alpha'}