mrzhang commited on
Commit
ab0501d
·
1 Parent(s): 3094872

Upload aggregate_binding_site_informations.py

Browse files
aggregate_binding_site_informations.py ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ '''Aggregate the binding site informations into a single json file.
3
+ '''
4
+
5
+ import os
6
+ import json
7
+
8
+
9
+ def aggregate_binding_site_informations(file):
10
+
11
+ filename=file.name.split('/')[-1][0:4]#pdb文件名
12
+
13
+
14
+ input_path = './output/out_binding_site/{0}'.format(filename)
15
+ output_file = './output/binding_site_database_summary_1.json'
16
+ aggregated_binding_sites = []
17
+
18
+ for d1 in os.listdir(input_path):
19
+
20
+ for bf in os.listdir(os.path.join(input_path, d1)):
21
+
22
+ if bf.endswith('.json'):
23
+
24
+ info_file = os.path.join(input_path, d1, bf)
25
+ bs_id = bf.split('.')[0].split('_')[-1]
26
+
27
+ pdb_file = os.path.join(input_path, d1, 'binding_site_{0}.pdb.gz'.format(bs_id))
28
+ ligand_params_file = os.path.join(input_path, d1, 'ligand_{0}.params'.format(bs_id))
29
+
30
+ if not os.path.exists(ligand_params_file):
31
+ ligand_params_file = 'TRUE'
32
+
33
+ with open(info_file, 'r') as f:
34
+ b_info = json.load(f)
35
+
36
+ aggregated_binding_sites.append({'info_file': info_file,
37
+ 'pdb_file' : pdb_file,
38
+ 'ligand_params_file' : ligand_params_file,
39
+ 'binding_site_info':b_info})
40
+
41
+
42
+
43
+ with open(output_file, 'w') as f:
44
+ json.dump(aggregated_binding_sites, f, indent=' ')
45
+ return
46
+
47
+