Answers.Body: <p>Not sure if you want the structure exactly or a handle of some sort, but the best way i know to get ALL your 5000 identifiers to map to uniprot/pdb is uniprot's <a href="https://www.uniprot.org/uploadlists/" rel="nofollow noreferrer">mapping service</a>.
  You can either copy your ids straight from excel or parse with python ex.:</p>
  
  <pre><code>import pandas as pd
  import os
  
  file_name = 'aap7847_Zhang_SM_Table-S5.xlsx'
  sheetname = 'Table S5'
  df = pd.read_excel(file_name, sheet_name=sheetname, skiprows=1)
  ids = list(df['Gene_ID'])
  
  name_of_file_to_save_to = "geneIds.txt"
  with open(name_of_file_to_save_to, "w") as newf:
      for id in ids:
          print("{}\n".format(id), file=newf)
      newf.close()
  </code></pre>
  
  <p>You can then save the Uniprot's response and either add it as a column to your file or map to other parts of Elixir ecosystem with SIFTS, for example, as @Matteo Ferla says.
  <a href="https://i.sstatic.net/MK1Qq.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/MK1Qq.png" alt="enter image description here"></a></p>
  
  <hr>
  
  <p>In the case that you maybe need a single id's information, you could hit their API too, although this wouldn't work for bulk or at least didn't work for me. You can map the uniprot accession you get from this to PDB or whatever else you need!</p>
  
  <pre><code>import requests
  def get_uniprot_accession(geneid, format='list'):
      resp = requests.get(
          "https://www.uniprot.org/uniprot/?query={}&amp;sort=score&amp;format={}".format(geneid, format)).text
      if format == 'list':
          resp = resp.strip()
      return resp
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-04-30T20:18:28.013Z
Answers.LastActivityDate: 2020-04-30T20:18:28.013Z
Answers.UserDisplayName: rtviii
Body: <p>I want to map some gene ids to their proteins structures if they exist.
  The genes are rows of this <a href="https://science.sciencemag.org/highwire/filestream/709675/field_highwire_adjunct_files/5/aap7847_Zhang_SM_Table-S5.xlsx" rel="nofollow noreferrer">CSV</a>. There are other information that may help also such as Product description but that may lead to anbiguities. I am looking for a programmatic way, biopython or pdb API?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-04-30T12:54:55.730Z
Comments.Text: From [EMBL SIFTS](https://www.ebi.ac.uk/pdbe/services/SIFTS) you can download a table that goes from Uniprot ID to PDB and chain and numbers that can give you any offset. Do note that offset correction is a problem for about 10% —I use python's `pymol2` module to fix these (yup, silly but best option). Also if the organism is common you might wanna check out [SwissModel's premade threaded models of close homologues](https://swissmodel.expasy.org/)(20% id min)
Comments.UserDisplayName: Matteo Ferla
Tags: <gene><protein-structure>
Title: Map gene IDs to protein structure if exist
ThreadText: # Map gene IDs to protein structure if exist
  
  (Asked by: username_0 on 2020-04-30)
  
  I want to map some gene ids to their proteins structures if they exist.
  The genes are rows of this [CSV](https://science.sciencemag.org/highwire/filestream/709675/field_highwire_adjunct_files/5/aap7847_Zhang_SM_Table-S5.xlsx). There are other information that may help also such as Product description but that may lead to anbiguities. I am looking for a programmatic way, biopython or pdb API?
  
  **Tags:** gene, protein-structure
  
  > **Comments:**
  > **username_1**: From [EMBL SIFTS](https://www.ebi.ac.uk/pdbe/services/SIFTS) you can download a table that goes from Uniprot ID to PDB and chain and numbers that can give you any offset. Do note that offset correction is a problem for about 10% —I use python's `pymol2` module to fix these (yup, silly but best option). Also if the organism is common you might wanna check out [SwissModel's premade threaded models of close homologues](https://swissmodel.expasy.org/)(20% id min)  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2020-04-30. Score: 2
  
  Not sure if you want the structure exactly or a handle of some sort, but the best way i know to get ALL your 5000 identifiers to map to uniprot/pdb is uniprot's [mapping service](https://www.uniprot.org/uploadlists/).
  You can either copy your ids straight from excel or parse with python ex.:
  
  ```
  import pandas as pd
  import os
  
  file_name = 'aap7847_Zhang_SM_Table-S5.xlsx'
  sheetname = 'Table S5'
  df = pd.read_excel(file_name, sheet_name=sheetname, skiprows=1)
  ids = list(df['Gene_ID'])
  
  name_of_file_to_save_to = "geneIds.txt"
  with open(name_of_file_to_save_to, "w") as newf:
      for id in ids:
          print("{}\n".format(id), file=newf)
      newf.close()
  
  ```
  
  You can then save the Uniprot's response and either add it as a column to your file or map to other parts of Elixir ecosystem with SIFTS, for example, as @username_1 says.
  [![enter image description here](https://i.sstatic.net/MK1Qq.png)](https://i.sstatic.net/MK1Qq.png)
  
  ---
  
  In the case that you maybe need a single id's information, you could hit their API too, although this wouldn't work for bulk or at least didn't work for me. You can map the uniprot accession you get from this to PDB or whatever else you need!
  
  ```
  import requests
  def get_uniprot_accession(geneid, format='list'):
      resp = requests.get(
          "https://www.uniprot.org/uniprot/?query={}&sort=score&format={}".format(geneid, format)).text
      if format == 'list':
          resp = resp.strip()
      return resp
  
  ```
  
  
  ---
  
  