fatmacankara commited on
Commit
ae8cb90
·
1 Parent(s): b441d1f

Update code/pdb_featureVector.py

Browse files
Files changed (1) hide show
  1. code/pdb_featureVector.py +4 -30
code/pdb_featureVector.py CHANGED
@@ -223,9 +223,9 @@ def pdb(input_set, mode, impute):
223
  response = requests.get(f"https://www.ebi.ac.uk/pdbe/api/mappings/uniprot/{pdb_code}")
224
  response.raise_for_status() # Check for a successful response
225
  data = response.json()
 
226
  return list(list(list(data.values())[0].values())[0].keys())
227
- except requests.exceptions.RequestException as e:
228
- print(f"Failed to retrieve UniProt data for PDB code {pdb_code}: {e}")
229
  return []
230
  for search in pdbs:
231
  # Step 1: Fetch the PDB file
@@ -233,8 +233,7 @@ def pdb(input_set, mode, impute):
233
  try:
234
  response = requests.get(pdb_url)
235
  response.raise_for_status() # Check for a successful response
236
- except requests.exceptions.RequestException as e:
237
- print(f"Failed to retrieve data for PDB code {search}: {e}")
238
  continue # Skip to the next PDB code if fetching fails
239
 
240
  # Step 2: Parse the PDB file from memory
@@ -265,37 +264,12 @@ def pdb(input_set, mode, impute):
265
  pdb_fasta.at[index, 'pdbID'] = search
266
  pdb_fasta.at[index, 'chain'] = chain_id
267
  pdb_fasta.at[index, 'pdbSequence'] = str(sequence)
268
- pdb_info.at[index, 'uniprotID'] = record.dbxrefs[0].split(':')[1]
269
  pdb_info.at[index, 'pdbID'] = search
270
  pdb_info.at[index, 'chain'] = chain_id
271
  pdb_info.at[index, 'resolution'] = resolution
272
  index += 1
273
 
274
- """
275
-
276
- resolution_method = parser.get_structure(search, file)
277
- st.write(resolution_method)
278
- for record in SeqIO.parse(file, "pdb-seqres"):
279
- st.write('rec', record)
280
- if record.dbxrefs[0].split(':')[0] == 'UNP':
281
- st.write(record.id.split(':')[0])
282
- st.write(record.id.split(':')[1])
283
- pdb_fasta.at[index, 'pdbID'] = record.id.split(':')[0]
284
- pdb_fasta.at[index, 'chain'] = record.id.split(':')[1]
285
- pdb_fasta.at[index, 'pdbSequence'] = str(record.seq)
286
- pdb_info.at[index, 'uniprotID'] = record.dbxrefs[0].split(':')[1]
287
- pdb_info.at[index, 'pdbID'] = record.id.split(':')[0]
288
- pdb_info.at[index, 'chain'] = record.annotations["chain"]
289
- pdb_info.at[index, 'resolution'] = resolution_method.header['resolution']
290
- index += 1
291
- except:
292
- IndexError
293
- pdb_info.at[index, 'uniprotID'] = 'nan'
294
- pdb_info.at[index, 'pdbID'] = 'nan'
295
- pdb_info.at[index, 'chain'] = 'nan'
296
- pdb_info.at[index, 'resolution'] = 'nan'
297
- cnt += 1
298
- """
299
  print()
300
  st.write()
301
  st.write(pdb_info)
 
223
  response = requests.get(f"https://www.ebi.ac.uk/pdbe/api/mappings/uniprot/{pdb_code}")
224
  response.raise_for_status() # Check for a successful response
225
  data = response.json()
226
+ st.write(list(list(list(data.values())[0].values())[0].keys()))
227
  return list(list(list(data.values())[0].values())[0].keys())
228
+ except :
 
229
  return []
230
  for search in pdbs:
231
  # Step 1: Fetch the PDB file
 
233
  try:
234
  response = requests.get(pdb_url)
235
  response.raise_for_status() # Check for a successful response
236
+ except :
 
237
  continue # Skip to the next PDB code if fetching fails
238
 
239
  # Step 2: Parse the PDB file from memory
 
264
  pdb_fasta.at[index, 'pdbID'] = search
265
  pdb_fasta.at[index, 'chain'] = chain_id
266
  pdb_fasta.at[index, 'pdbSequence'] = str(sequence)
267
+ pdb_info.at[index, 'uniprotID'] = ', '.join(uniprot_ids)
268
  pdb_info.at[index, 'pdbID'] = search
269
  pdb_info.at[index, 'chain'] = chain_id
270
  pdb_info.at[index, 'resolution'] = resolution
271
  index += 1
272
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
273
  print()
274
  st.write()
275
  st.write(pdb_info)