Spaces:
Sleeping
Sleeping
Commit
·
9425f80
1
Parent(s):
9cffd28
Update code/add_structure.py
Browse files- code/add_structure.py +15 -1
code/add_structure.py
CHANGED
|
@@ -7,7 +7,7 @@ from urllib.parse import urlparse, parse_qs, urlencode
|
|
| 7 |
import requests
|
| 8 |
from requests.adapters import HTTPAdapter, Retry
|
| 9 |
from unipressed import IdMappingClient
|
| 10 |
-
|
| 11 |
## Code adapted from UniProt documentation.
|
| 12 |
def get_pdb_ids_2(protein_id):
|
| 13 |
POLLING_INTERVAL = 5
|
|
@@ -165,5 +165,19 @@ def get_pdb_ids(protein_id):
|
|
| 165 |
get_pdb_ids_2(protein_id)
|
| 166 |
except KeyError:
|
| 167 |
get_pdb_ids_2(protein_id)
|
|
|
|
| 168 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 169 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
import requests
|
| 8 |
from requests.adapters import HTTPAdapter, Retry
|
| 9 |
from unipressed import IdMappingClient
|
| 10 |
+
"""
|
| 11 |
## Code adapted from UniProt documentation.
|
| 12 |
def get_pdb_ids_2(protein_id):
|
| 13 |
POLLING_INTERVAL = 5
|
|
|
|
| 165 |
get_pdb_ids_2(protein_id)
|
| 166 |
except KeyError:
|
| 167 |
get_pdb_ids_2(protein_id)
|
| 168 |
+
"""
|
| 169 |
|
| 170 |
+
def get_pdb_ids(protein_id):
|
| 171 |
+
try:
|
| 172 |
+
request = IdMappingClient.submit(
|
| 173 |
+
source="UniProtKB_AC-ID", dest="PDB", ids={protein_id})
|
| 174 |
+
pdb_list = list(request.each_result())
|
| 175 |
+
return [i['to'] for i in pdb_list]
|
| 176 |
|
| 177 |
+
except requests.exceptions.HTTPError:
|
| 178 |
+
return []
|
| 179 |
+
except unipressed.id_mapping.core.IdMappingError:
|
| 180 |
+
print('IdMappingError caused by UniProt API service, please try later.')
|
| 181 |
+
return []
|
| 182 |
+
except KeyError:
|
| 183 |
+
return []
|