Answers.Body: <p>I found the answer and I thought it may be useful for others. we can use pypdb package for that purpose (it works in unix systems):</p>
  
  <pre><code>import pypdb
  
  all_info = pypdb.get_all_info('1kf6')
  print(all_info)
  </code></pre>
  
  <p>the output is as follows:</p>
  
  <pre><code>{'polymer': [{'@entityNr': '1', '@length': '602', '@type': 'protein', '@weight': '66057.6', 'chain': [{'@id': 'A'}, {'@id': 'M'}], 'Taxonomy': {'@name': 'Escherichia coli', '@id': '562'}, 'macroMolecule': {'@name': 'Fumarate reductase flavoprotein subunit', 'accession': {'@id': 'P00363'}}, 'polymerDescription': {'@description': 'FUMARATE REDUCTASE FLAVOPROTEIN'}, 'enzClass': {'@ec': '1.3.5.4'}}, {'@entityNr': '2', '@length': '243', '@type': 'protein', '@weight': '27021.9', 'chain': [{'@id': 'B'}, {'@id': 'N'}], 'Taxonomy': {'@name': 'Escherichia coli', '@id': '562'}, 'macroMolecule': {'@name': 'Fumarate reductase iron-sulfur subunit', 'accession': {'@id': 'P0AC47'}}, 'polymerDescription': {'@description': 'FUMARATE REDUCTASE IRON-SULFUR PROTEIN'}, 'enzClass': {'@ec': '1.3.5.1'}}, {'@entityNr': '3', '@length': '130', '@type': 'protein', '@weight': '14898.8', 'chain': [{'@id': 'C'}, {'@id': 'O'}], 'Taxonomy': {'@name': 'Escherichia coli', '@id': '562'}, 'macroMolecule': {'@name': 'Fumarate reductase subunit C', 'accession': {'@id': 'P0A8Q0'}}, 'polymerDescription': {'@description': 'FUMARATE REDUCTASE 15 KDA HYDROPHOBIC PROTEIN'}}, {'@entityNr': '4', '@length': '119', '@type': 'protein', '@weight': '13118.9', 'chain': [{'@id': 'D'}, {'@id': 'P'}], 'Taxonomy': {'@name': 'Escherichia coli', '@id': '562'}, 'macroMolecule': {'@name': 'Fumarate reductase subunit D', 'accession': {'@id': 'P0A8Q3'}}, 'polymerDescription': {'@description': 'FUMARATE REDUCTASE 13 KDA HYDROPHOBIC PROTEIN'}}], 'id': '1KF6'}
  </code></pre>
  
  <p>This output gives all the information related to all chains and we can simply find uniprotkb AC of each chain in this output. I also found another answer for this question. This answer can be found <a href="https://www.biostars.org/p/166134/" rel="nofollow noreferrer">here</a> and the following code:</p>
  
  <pre><code>import requests
  from xml.etree.ElementTree import fromstring
  
  pdb_id = '1kf6.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))
  </code></pre>
  
  <p>The output of this code is as follows:</p>
  
  <pre><code>{'pdb_id': '1kf6.A', 'uniprot_id': 'P00363', 'uniprot_name': 'Fumarate reductase flavoprotein subunit'}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-10-24T21:10:12.113Z
Answers.LastActivityDate: 2017-10-24T21:10:12.113Z
Answers.UserDisplayName: Sara
Answers.Body: <p>While not as nice as using SIFT. You can use the <a href="https://sparql.uniprot.org" rel="nofollow noreferrer">uniprot sparql</a> endpoint as well to get mappings.</p>
  <pre><code>PREFIX up: &lt;http://purl.uniprot.org/core/&gt;
  SELECT
    ?pdbId ?chain ?pdbChain ?uniprot
  WHERE
  {
    # A space separated list of pairs of PDB identifiers and the chain code.
    VALUES(?pdbId ?pdbChain) { ('6VXC' 'A') ('1BG3' 'B') }
  
    # Make an IRI out of the pdbId
    BIND(iri(concat('http://rdf.wwpdb.org/pdb/', ?pdbId)) AS ?pdb)
  
    # Map to UniProt entries
    ?uniprot rdfs:seeAlso ?pdb .
    ?pdb up:database &lt;http://purl.uniprot.org/database/PDB&gt; ;
     up:chainSequenceMapping ?chainSm .
    ?chainSm up:chain ?chainsPlusRange .
  
    # Extract the list of chains from the text representation.
    BIND(STRBEFORE(?chainsPlusRange, '=') AS ?chain)
  
    # Filter those that match.
    FILTER(CONTAINS(?chain, ?pdbChain))
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-10-04T14:01:42.167Z
Answers.LastActivityDate: 2022-10-04T14:01:42.167Z
Answers.UserDisplayName: Jerven
Answers.Body: <p>An alternative solution involves the use of the <a href="http://www.ebi.ac.uk/pdbe/docs/sifts/" rel="nofollow noreferrer">SIFTS</a> resource from the EBI. I wrote <a href="https://github.com/mgalardini/pdb2uniprot/blob/master/parse_sifts.py" rel="nofollow noreferrer">a python parser</a> for their xml format, which will give you a mapping between a pdb and a uniprot entry at the single residue level.</p>
  
  <pre><code>$ curl --silent "ftp://ftp.ebi.ac.uk/pub/databases/msd/sifts/xml/1kf6.xml.gz" | gunzip | python parse_sifts.py
  1kf6    A       M       0       P00363  M       1
  1kf6    A       Q       1       P00363  Q       2
  1kf6    A       T       2       P00363  T       3
  1kf6    A       F       3       P00363  F       4
  1kf6    A       Q       4       P00363  Q       5
  1kf6    A       A       5       P00363  A       6
  1kf6    A       D       6       P00363  D       7
  1kf6    A       L       7       P00363  L       8
  1kf6    A       A       8       P00363  A       9
  1kf6    A       I       9       P00363  I       10
  [...]
  </code></pre>
  
  <p>The returned fields are as follows:</p>
  
  <ul>
  <li>pdb ID</li>
  <li>chain</li>
  <li>pdb residue</li>
  <li>pdb position</li>
  <li>uniprot ID</li>
  <li>uniprot residue</li>
  <li>uniprot position</li>
  </ul>
  
  <p>In the above snippet, just put your PDB ID of choice to retrieve the data you need.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-10-27T20:22:56.650Z
Answers.Text: It seems to be good but when I entered the code ($ curl --silent "ftp://ftp.ebi.ac.uk/pub/databases/msd/sifts/xml/1kf6.xml.gz" |                    gunzip | python parse_sifts.py) in Cygwin, I got the following error: python: can't open file 'parse_sifts.py': [Errno 2] No such file or directory
  (23) Failed writing body
Answers.UserDisplayName: Sara
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-10-29T11:34:40.603Z
Answers.Text: Are you sure that the Python script was in the same directory where you executed the snippet?
Answers.UserDisplayName: mgalardini
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-10-29T13:45:11.010Z
Answers.Text: When I try to open "ftp.ebi.ac.uk/pub/databases/msd/sifts/xml/1kf6.xml.gz" in my browser, I'll get this error: This site can’t be reached
  
  The webpage at ftp://ftp.ebi.ac.uk/pub/databases/msd/sifts/xml/1kf6.xml.gz" might be temporarily down or it may have moved permanently to a new web address.
  ERR_FTP_FAILED. 
  I think the problem is because of the server.
Answers.UserDisplayName: Sara
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-10-29T20:58:57.243Z
Answers.Text: I just tried and it worked for me fine: ftp://ftp.ebi.ac.uk/pub/databases/msd/sifts/xml/1kf6.xml.gz
Answers.UserDisplayName: mgalardini
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-10-30T20:05:32.597Z
Answers.Text: Now it just worked for me too...
Answers.UserDisplayName: Sara
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-10-27T08:28:37.083Z
Answers.LastActivityDate: 2017-10-27T08:28:37.083Z
Answers.UserDisplayName: mgalardini
Answers.Body: <p>Check out this file on SIFT.
  ftp.ebi.ac.uk/pub/databases/msd/sifts/csv/pdb_chain_uniprot.csv
  It contains residue-wise mapping of PDB chains with uniprot ids.</p>
  
  <pre><code># 2020/04/12 - 21:03 | PDB: 15.20 | UniProt: 2020.02
  PDB,CHAIN,SP_PRIMARY,RES_BEG,RES_END,PDB_BEG,PDB_END,SP_BEG,SP_END
  101m,A,P02185,1,154,0,153,1,154
  102l,A,P00720,1,40,1,40,1,40
  102l,A,P00720,42,165,41,None,41,164
  .
  .
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-04-17T23:50:13.537Z
Answers.LastActivityDate: 2020-04-17T23:50:13.537Z
Answers.UserDisplayName: user345394
Body: <p>I have a lot of PDB IDs and I need to get uniprot fasta sequences of these PDB IDs special chains by API services. For example, imagine that I need to get fasta sequence of '1kf6' 'A' chain. The uniprot entry (Accession) for this '1kf6' chain is 'P00363'. If I find a way to get this entry, I can simply retrieve its fasta sequence using bioservices package:</p>
  
  <pre><code>from bioservices import *
  u = UniProt()
  sequence = u.retrieve("P00363","fasta")
  print(sequence)
  </code></pre>
  
  <p>The main problem is that I don't know how can I find this uniprot entry("P00363" here) for each chains in PDB IDs(here I imagine that I don't know this "P00363" is the uniprot entry for '1kf6' 'A' chain and I'm trying to find it using API services). I tried to use ID mapping. In ID mapping cross-references, the chain name for each entry is specified and if I can add a cross-reference column to u.search('1kf6', columns="id,entry name,length, genes,pdb"), I can simply find the entry related to my favourite chain. The following code returns some entries each related to one of '1kf6' chains. The problem is that I don't know exactly which entry is related to 'A' chain that here is my favorite chain. In the following code, id searches for entry and other parameters search for sth else related to them:</p>
  
  <pre><code>from bioservices import *
  u = UniProt()
  res = u.search("1kf6",columns="id,entry name,length, genes")
  print(res)
  </code></pre>
  
  <p>Each one of the following words can be used and added to columns part:</p>
  
  <pre><code>'id', 'entry name', 'genes', 'genes(PREFERRED)', 'genes(ALTERNATIVE)', 'genes(OLN)', 'genes(ORF)', 'organism', 'organism-id', 'protein names', 'proteome', 'lineage(ALL)', 'lineage-id', 'virus hosts', 'fragement', 'sequence', 'length', 'mass', 'encodedon', 'comment(ALTERNATIVE PRODUCTS)', 'comment(ERRONEOUS GENE MODEL PREDICTION)', 'comment(ERRONEOUS INITIATION)', 'comment(ERRONEOUS TERMINATION)', 'comment(ERRONEOUS TRANSLATION)', 'comment(FRAMESHIFT)', 'comment(MASS SPECTROMETRY)', 'comment(POLYMORPHISM)', 'comment(RNA EDITING)', 'comment(SEQUENCE CAUTION)', 'feature(ALTERNATIVE SEQUENCE)', 'feature(NATURAL VARIANT)', 'feature(NON ADJACENT RESIDUES)', 'feature(NON STANDARD RESIDUE)', 'feature(NON TERMINAL RESIDUE)', 'feature(SEQUENCE CONFLICT)', 'feature(SEQUENCE UNCERTAINTY)', 'version(sequence)', 'domains', 'domain', 'comment(DOMAIN)', 'comment(SIMILARITY)', 'feature(COILED COIL)', 'feature(COMPOSITIONAL BIAS)', 'feature(DOMAIN EXTENT)', 'feature(MOTIF)', 'feature(REGION)', 'feature(REPEAT)', 'feature(ZINC FINGER)', 'ec', 'comment(ABSORPTION)', 'comment(CATALYTIC ACTIVITY)', 'comment(COFACTOR)', 'comment(ENZYME REGULATION)', 'comment(FUNCTION)', 'comment(KINETICS)', 'comment(PATHWAY)', 'comment(REDOX POTENTIAL)', 'comment(TEMPERATURE DEPENDENCE)', 'comment(PH DEPENDENCE)', 'feature(ACTIVE SITE)', 'feature(BINDING SITE)', 'feature(DNA BINDING)', 'feature(METAL BINDING)', 'feature(NP BIND)', 'feature(SITE)', 'go', 'go(biological process)', 'go(molecular function)', 'go(cellular component)', 'go-id', 'interpro', 'interactor', 'comment(SUBUNIT)', 'citation', 'citationmapping', 'created', 'last-modified', 'sequence-modified', 'version(entry)', '3d', 'feature(BETA STRAND)', 'feature(HELIX)', 'feature(TURN)', 'comment(SUBCELLULAR LOCATION)', 'feature(INTRAMEMBRANE)', 'feature(TOPOLOGICAL DOMAIN)', 'feature(TRANSMEMBRANE)', 'annotation score', 'score', 'features', 'comment(CAUTION)', 'comment(TISSUE SPECIFICITY)', 'comment(GENERAL)', 'keywords', 'context', 'existence', 'tools', 'reviewed', 'feature', 'families', 'subcellular locations', 'taxonomy', 'version', 'clusters', 'comments', 'database', 'keyword-id', 'pathway', 'score'
  </code></pre>
  
  <p>I used some of the above words in columns part but they couldn't retrieve chain name. Anyone know which one of the above parameters can give me the chain name for this PDB ID? or anyone has any other idea for finding uniprot entry(UniprotKB AC) related to each PDB ID chain by API services?</p>
  
Tags: <fasta><python><pdb><api>
Title: How to map PDB chains to Uniprot IDs using API services
ThreadText: # How to map PDB chains to Uniprot IDs using API services
  
  (Asked by: username_0 on 2017-10-24)
  
  I have a lot of PDB IDs and I need to get uniprot fasta sequences of these PDB IDs special chains by API services. For example, imagine that I need to get fasta sequence of '1kf6' 'A' chain. The uniprot entry (Accession) for this '1kf6' chain is 'P00363'. If I find a way to get this entry, I can simply retrieve its fasta sequence using bioservices package:
  
  ```
  from bioservices import *
  u = UniProt()
  sequence = u.retrieve("P00363","fasta")
  print(sequence)
  
  ```
  
  The main problem is that I don't know how can I find this uniprot entry("P00363" here) for each chains in PDB IDs(here I imagine that I don't know this "P00363" is the uniprot entry for '1kf6' 'A' chain and I'm trying to find it using API services). I tried to use ID mapping. In ID mapping cross-references, the chain name for each entry is specified and if I can add a cross-reference column to u.search('1kf6', columns="id,entry name,length, genes,pdb"), I can simply find the entry related to my favourite chain. The following code returns some entries each related to one of '1kf6' chains. The problem is that I don't know exactly which entry is related to 'A' chain that here is my favorite chain. In the following code, id searches for entry and other parameters search for sth else related to them:
  
  ```
  from bioservices import *
  u = UniProt()
  res = u.search("1kf6",columns="id,entry name,length, genes")
  print(res)
  
  ```
  
  Each one of the following words can be used and added to columns part:
  
  ```
  'id', 'entry name', 'genes', 'genes(PREFERRED)', 'genes(ALTERNATIVE)', 'genes(OLN)', 'genes(ORF)', 'organism', 'organism-id', 'protein names', 'proteome', 'lineage(ALL)', 'lineage-id', 'virus hosts', 'fragement', 'sequence', 'length', 'mass', 'encodedon', 'comment(ALTERNATIVE PRODUCTS)', 'comment(ERRONEOUS GENE MODEL PREDICTION)', 'comment(ERRONEOUS INITIATION)', 'comment(ERRONEOUS TERMINATION)', 'comment(ERRONEOUS TRANSLATION)', 'comment(FRAMESHIFT)', 'comment(MASS SPECTROMETRY)', 'comment(POLYMORPHISM)', 'comment(RNA EDITING)', 'comment(SEQUENCE CAUTION)', 'feature(ALTERNATIVE SEQUENCE)', 'feature(NATURAL VARIANT)', 'feature(NON ADJACENT RESIDUES)', 'feature(NON STANDARD RESIDUE)', 'feature(NON TERMINAL RESIDUE)', 'feature(SEQUENCE CONFLICT)', 'feature(SEQUENCE UNCERTAINTY)', 'version(sequence)', 'domains', 'domain', 'comment(DOMAIN)', 'comment(SIMILARITY)', 'feature(COILED COIL)', 'feature(COMPOSITIONAL BIAS)', 'feature(DOMAIN EXTENT)', 'feature(MOTIF)', 'feature(REGION)', 'feature(REPEAT)', 'feature(ZINC FINGER)', 'ec', 'comment(ABSORPTION)', 'comment(CATALYTIC ACTIVITY)', 'comment(COFACTOR)', 'comment(ENZYME REGULATION)', 'comment(FUNCTION)', 'comment(KINETICS)', 'comment(PATHWAY)', 'comment(REDOX POTENTIAL)', 'comment(TEMPERATURE DEPENDENCE)', 'comment(PH DEPENDENCE)', 'feature(ACTIVE SITE)', 'feature(BINDING SITE)', 'feature(DNA BINDING)', 'feature(METAL BINDING)', 'feature(NP BIND)', 'feature(SITE)', 'go', 'go(biological process)', 'go(molecular function)', 'go(cellular component)', 'go-id', 'interpro', 'interactor', 'comment(SUBUNIT)', 'citation', 'citationmapping', 'created', 'last-modified', 'sequence-modified', 'version(entry)', '3d', 'feature(BETA STRAND)', 'feature(HELIX)', 'feature(TURN)', 'comment(SUBCELLULAR LOCATION)', 'feature(INTRAMEMBRANE)', 'feature(TOPOLOGICAL DOMAIN)', 'feature(TRANSMEMBRANE)', 'annotation score', 'score', 'features', 'comment(CAUTION)', 'comment(TISSUE SPECIFICITY)', 'comment(GENERAL)', 'keywords', 'context', 'existence', 'tools', 'reviewed', 'feature', 'families', 'subcellular locations', 'taxonomy', 'version', 'clusters', 'comments', 'database', 'keyword-id', 'pathway', 'score'
  
  ```
  
  I used some of the above words in columns part but they couldn't retrieve chain name. Anyone know which one of the above parameters can give me the chain name for this PDB ID? or anyone has any other idea for finding uniprot entry(UniprotKB AC) related to each PDB ID chain by API services?
  
  **Tags:** fasta, python, pdb, api
  
  
  ---
  
  ## 4 answers
  
  ### Answer by username_0 on 2017-10-24. Score: 3 | Accepted answer
  
  I found the answer and I thought it may be useful for others. we can use pypdb package for that purpose (it works in unix systems):
  
  ```
  import pypdb
  
  all_info = pypdb.get_all_info('1kf6')
  print(all_info)
  
  ```
  
  the output is as follows:
  
  ```
  {'polymer': [{'@entityNr': '1', '@length': '602', '@type': 'protein', '@weight': '66057.6', 'chain': [{'@id': 'A'}, {'@id': 'M'}], 'Taxonomy': {'@name': 'Escherichia coli', '@id': '562'}, 'macroMolecule': {'@name': 'Fumarate reductase flavoprotein subunit', 'accession': {'@id': 'P00363'}}, 'polymerDescription': {'@description': 'FUMARATE REDUCTASE FLAVOPROTEIN'}, 'enzClass': {'@ec': '1.3.5.4'}}, {'@entityNr': '2', '@length': '243', '@type': 'protein', '@weight': '27021.9', 'chain': [{'@id': 'B'}, {'@id': 'N'}], 'Taxonomy': {'@name': 'Escherichia coli', '@id': '562'}, 'macroMolecule': {'@name': 'Fumarate reductase iron-sulfur subunit', 'accession': {'@id': 'P0AC47'}}, 'polymerDescription': {'@description': 'FUMARATE REDUCTASE IRON-SULFUR PROTEIN'}, 'enzClass': {'@ec': '1.3.5.1'}}, {'@entityNr': '3', '@length': '130', '@type': 'protein', '@weight': '14898.8', 'chain': [{'@id': 'C'}, {'@id': 'O'}], 'Taxonomy': {'@name': 'Escherichia coli', '@id': '562'}, 'macroMolecule': {'@name': 'Fumarate reductase subunit C', 'accession': {'@id': 'P0A8Q0'}}, 'polymerDescription': {'@description': 'FUMARATE REDUCTASE 15 KDA HYDROPHOBIC PROTEIN'}}, {'@entityNr': '4', '@length': '119', '@type': 'protein', '@weight': '13118.9', 'chain': [{'@id': 'D'}, {'@id': 'P'}], 'Taxonomy': {'@name': 'Escherichia coli', '@id': '562'}, 'macroMolecule': {'@name': 'Fumarate reductase subunit D', 'accession': {'@id': 'P0A8Q3'}}, 'polymerDescription': {'@description': 'FUMARATE REDUCTASE 13 KDA HYDROPHOBIC PROTEIN'}}], 'id': '1KF6'}
  
  ```
  
  This output gives all the information related to all chains and we can simply find uniprotkb AC of each chain in this output. I also found another answer for this question. This answer can be found [here](https://www.biostars.org/p/166134/) and the following code:
  
  ```
  import requests
  from xml.etree.ElementTree import fromstring
  
  pdb_id = '1kf6.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))
  
  ```
  
  The output of this code is as follows:
  
  ```
  {'pdb_id': '1kf6.A', 'uniprot_id': 'P00363', 'uniprot_name': 'Fumarate reductase flavoprotein subunit'}
  
  ```
  
  
  ---
  
  ### Answer by username_1 on 2022-10-04. Score: 2
  
  While not as nice as using SIFT. You can use the [uniprot sparql](https://sparql.uniprot.org) endpoint as well to get mappings.
  
  ```
  PREFIX up: <http://purl.uniprot.org/core/>
  SELECT
    ?pdbId ?chain ?pdbChain ?uniprot
  WHERE
  {
    # A space separated list of pairs of PDB identifiers and the chain code.
    VALUES(?pdbId ?pdbChain) { ('6VXC' 'A') ('1BG3' 'B') }
  
    # Make an IRI out of the pdbId
    BIND(iri(concat('http://rdf.wwpdb.org/pdb/', ?pdbId)) AS ?pdb)
  
    # Map to UniProt entries
    ?uniprot rdfs:seeAlso ?pdb .
    ?pdb up:database <http://purl.uniprot.org/database/PDB> ;
     up:chainSequenceMapping ?chainSm .
    ?chainSm up:chain ?chainsPlusRange .
  
    # Extract the list of chains from the text representation.
    BIND(STRBEFORE(?chainsPlusRange, '=') AS ?chain)
  
    # Filter those that match.
    FILTER(CONTAINS(?chain, ?pdbChain))
  }
  
  ```
  
  
  ---
  
  ### Answer by username_2 on 2017-10-27. Score: 2
  
  An alternative solution involves the use of the [SIFTS](http://www.ebi.ac.uk/pdbe/docs/sifts/) resource from the EBI. I wrote [a python parser](https://github.com/username_2/pdb2uniprot/blob/master/parse_sifts.py) for their xml format, which will give you a mapping between a pdb and a uniprot entry at the single residue level.
  
  ```
  $ curl --silent "ftp://ftp.ebi.ac.uk/pub/databases/msd/sifts/xml/1kf6.xml.gz" | gunzip | python parse_sifts.py
  1kf6    A       M       0       P00363  M       1
  1kf6    A       Q       1       P00363  Q       2
  1kf6    A       T       2       P00363  T       3
  1kf6    A       F       3       P00363  F       4
  1kf6    A       Q       4       P00363  Q       5
  1kf6    A       A       5       P00363  A       6
  1kf6    A       D       6       P00363  D       7
  1kf6    A       L       7       P00363  L       8
  1kf6    A       A       8       P00363  A       9
  1kf6    A       I       9       P00363  I       10
  [...]
  
  ```
  
  The returned fields are as follows:
  
  * pdb ID
  * chain
  * pdb residue
  * pdb position
  * uniprot ID
  * uniprot residue
  * uniprot position
  
  In the above snippet, just put your PDB ID of choice to retrieve the data you need.
  
  > **Comments:**
  > **username_0**: It seems to be good but when I entered the code ($ curl --silent "ftp://ftp.ebi.ac.uk/pub/databases/msd/sifts/xml/1kf6.xml.gz" |                    gunzip | python parse_sifts.py) in Cygwin, I got the following error: python: can't open file 'parse_sifts.py': [Errno 2] No such file or directory (23) Failed writing body  
  > **username_2**: Are you sure that the Python script was in the same directory where you executed the snippet?  
  > **username_0**: When I try to open "ftp.ebi.ac.uk/pub/databases/msd/sifts/xml/1kf6.xml.gz" in my browser, I'll get this error: This site can’t be reached  The webpage at ftp://ftp.ebi.ac.uk/pub/databases/msd/sifts/xml/1kf6.xml.gz" might be temporarily down or it may have moved permanently to a new web address. ERR_FTP_FAILED.  I think the problem is because of the server.  
  > **username_2**: I just tried and it worked for me fine: ftp://ftp.ebi.ac.uk/pub/databases/msd/sifts/xml/1kf6.xml.gz  
  > **username_0**: Now it just worked for me too...  
  
  ---
  
  ### Answer by username_3 on 2020-04-17. Score: 1
  
  Check out this file on SIFT.
  ftp.ebi.ac.uk/pub/databases/msd/sifts/csv/pdb\_chain\_uniprot.csv
  It contains residue-wise mapping of PDB chains with uniprot ids.
  
  ```
  # 2020/04/12 - 21:03 | PDB: 15.20 | UniProt: 2020.02
  PDB,CHAIN,SP_PRIMARY,RES_BEG,RES_END,PDB_BEG,PDB_END,SP_BEG,SP_END
  101m,A,P02185,1,154,0,153,1,154
  102l,A,P00720,1,40,1,40,1,40
  102l,A,P00720,42,165,41,None,41,164
  .
  .
  
  ```
  
  
  ---
  
  