2
$\begingroup$

I am working on a project about phosphorylation, and I am creating a database of some proteins. I have a list of protein accession ids for which I need to get the corresponding PDB file for each one to map it to PSM matrix. I want to get the PDB file using Python or BioPython tools. Any suggestions will be appreciated.

$\endgroup$
3
  • $\begingroup$ Thanks for your reply. I have a list of protein ids, and I want to retrieve PDB code for each one! I made the protein ids database with the phosphorylation cite for each position. However, I need PDB code because I want to map it to PSM matrix. I have no idea how to retrieve PDB code! Thanks again $\endgroup$ Commented Aug 26, 2018 at 5:00
  • 1
    $\begingroup$ Please include a few IDs and the expected outcome, i.e. ID: P26378 should map to PDB: 1FXL, etc. If you just need to do it a few times, you could use the UniProt web interface, just upload a bunch of identifiers and get the corresponding PDB IDs. uniprot.org/uploadlists $\endgroup$ Commented Aug 26, 2018 at 8:51
  • $\begingroup$ Thanks man, I really appreciate your reply. I am currently using this website to map protein accession ids to PDB. However, I want to do it by the code because I have a big list of protein ids. I want to get PDB by code so I can map it to PSSM to get the structure of the proteins. I want to do it in the one piece of code,not separately! Again Thanks for your kind and helpful reply! $\endgroup$ Commented Aug 26, 2018 at 9:22

2 Answers 2

2
$\begingroup$

A typical Uniprot URL would look like the example here:

https://www.uniprot.org/uniprot/?query=ID:P26378&format=tab&columns=id%2Cdatabase(PDB)

The response will be:

Entry Cross-reference (PDB)

P26378 1FXL;1G2E;

We want our query to include the protein ID, the output format should be tab separated and the only contain the columns id and database (PDB).

To get the PDB IDs you would need to split the response, take the last line, split this line after each tab and split it again after each semi-colon.

Using Python's Requests library the whole code would be.

import requests
import time

uniprot_ids = ['P26378', 'O35433', 'Q02910']
url = 'https://www.uniprot.org/uniprot/'

protein_to_pdb = {}
for protein in uniprot_ids:
    params = {
        'format': 'tab',
        'query': 'ID:{}'.format(protein),
        'columns': 'id,database(PDB)'
    }
    contact = ""  # Please set your email address here.
    headers = {'User-Agent': 'Python {}'.format(contact)}
    r = requests.get(url, params=params, headers=headers)

    protein_to_pdb[protein] = str(r.text).splitlines()[-1].split('\t')[-1].split(';')
    protein_to_pdb[protein].pop(-1)
    time.sleep(1)  # be respectful and don't overwhelm the server with requests

print(protein_to_pdb)

  • To accelerate things, you could store your protein_to_pdb dict in a file and only retrieve the new ones
  • Checking if the returned ID matches your input ID is always a good idea
$\endgroup$
3
  • $\begingroup$ Thanks man, I really appreciate your answer and your time with me. Please I want to read a file which has a list of protein ids as df ,and retrieve all PDB codes for each one. I am trying to edit on your code by using :"df.iloc[i,1] = str(r.text).splitlines()[-1].split('\t')[-1].split(';')" ,but there is an error which is "list index out of range". Please can you help me with that? $\endgroup$ Commented Aug 27, 2018 at 1:46
  • $\begingroup$ I did it by using :"df.iloc[i,1] = r" instead of using a list,and I get a file with all protein ids and PDB codes. Is that correct? Or I am missing something! Thank you so much for your answer; it is really helping me a lot. I really appreciate it . $\endgroup$ Commented Aug 27, 2018 at 2:10
  • $\begingroup$ Try a more simple example, just copy a few ids in the list and see if it works. Without seeing your dataframe it is hard to guess where the problem occurs. $\endgroup$ Commented Aug 27, 2018 at 5:46
0
$\begingroup$

You could use mapping between UniProt and PDB entries from the SIFTS project. The uniprot_pdb.csv file there has UniProt accession names followed by a semicolon-separated list of PDB four letter codes.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.