-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathprepare_data.py
More file actions
38 lines (30 loc) · 1.21 KB
/
prepare_data.py
File metadata and controls
38 lines (30 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from pdb_parser_scripts.clean_pdb import clean_pdb
from pdb_parser_scripts.extract_environments import extract_environments
import traceback
import warnings
import os
# !chmod +x reduce/reduce
# !chmod +x pdb_parser_scripts/clean_pdb.py
# !chmod +x pdb_parser_scripts/extract_environments.py
def parse_data(pdb_file,
clean_pdb_file=True
):
clean_file_path = "."
pdb_id = os.path.basename(pdb_file).split(".")[0]
try:
if clean_pdb_file:
with warnings.catch_warnings():
warnings.simplefilter(
'ignore', Bio.PDB.PDBExceptions.PDBConstructionWarning
)
clean_file_path = "data/cleaned"
clean_pdb(pdb_file, clean_file_path, "reduce/reduce")
pdb_id = f"{pdb_id}_clean"
print(f"Protein '{pdb_id}' cleaned successfully." )
extract_environments(f"{clean_file_path}/{pdb_id}.pdb",
pdb_id=pdb_id,
out_dir="data/parsed")
print(f"Protein '{pdb_id}' parsed successfully." )
except Exception:
error_msg = traceback.format_exc()
print(f"{pdb_file} failed.\n {error_msg}")