Zaixi commited on
Commit
7fba10f
·
1 Parent(s): 627f393

Delete evaluation

Browse files
evaluation/prepare_receptor4.py DELETED
@@ -1,183 +0,0 @@
1
- #!/usr/bin/env python
2
- #
3
- #
4
- #
5
- # $Header: /opt/cvs/python/packages/share1.5/AutoDockTools/Utilities24/prepare_receptor4.py,v 1.11 2007/11/28 22:40:22 rhuey Exp $
6
- #
7
- import os
8
-
9
- from MolKit import Read
10
- import MolKit.molecule
11
- import MolKit.protein
12
- from AutoDockTools.MoleculePreparation import AD4ReceptorPreparation
13
-
14
-
15
- if __name__ == '__main__':
16
- import sys
17
- import getopt
18
-
19
-
20
- def usage():
21
- "Print helpful, accurate usage statement to stdout."
22
- print "Usage: prepare_receptor4.py -r filename"
23
- print
24
- print " Description of command..."
25
- print " -r receptor_filename "
26
- print " supported file types include pdb,mol2,pdbq,pdbqs,pdbqt, possibly pqr,cif"
27
- print " Optional parameters:"
28
- print " [-v] verbose output (default is minimal output)"
29
- print " [-o pdbqt_filename] (default is 'molecule_name.pdbqt')"
30
- print " [-A] type(s) of repairs to make: "
31
- print " 'bonds_hydrogens': build bonds and add hydrogens "
32
- print " 'bonds': build a single bond from each atom with no bonds to its closest neighbor"
33
- print " 'hydrogens': add hydrogens"
34
- print " 'checkhydrogens': add hydrogens only if there are none already"
35
- print " 'None': do not make any repairs "
36
- print " (default is 'checkhydrogens')"
37
- print " [-C] preserve all input charges ie do not add new charges "
38
- print " (default is addition of gasteiger charges)"
39
- print " [-p] preserve input charges on specific atom types, eg -p Zn -p Fe"
40
- print " [-U] cleanup type:"
41
- print " 'nphs': merge charges and remove non-polar hydrogens"
42
- print " 'lps': merge charges and remove lone pairs"
43
- print " 'waters': remove water residues"
44
- print " 'nonstdres': remove chains composed entirely of residues of"
45
- print " types other than the standard 20 amino acids"
46
- print " 'deleteAltB': remove XX@B atoms and rename XX@A atoms->XX"
47
- print " (default is 'nphs_lps_waters_nonstdres') "
48
- print " [-e] delete every nonstd residue from any chain"
49
- print " 'True': any residue whose name is not in this list:"
50
- print " ['CYS','ILE','SER','VAL','GLN','LYS','ASN', "
51
- print " 'PRO','THR','PHE','ALA','HIS','GLY','ASP', "
52
- print " 'LEU', 'ARG', 'TRP', 'GLU', 'TYR','MET', "
53
- print " 'HID', 'HSP', 'HIE', 'HIP', 'CYX', 'CSS']"
54
- print " will be deleted from any chain. "
55
- print " NB: there are no nucleic acid residue names at all "
56
- print " in the list and no metals. "
57
- print " (default is False which means not to do this)"
58
- print " [-M] interactive "
59
- print " (default is 'automatic': outputfile is written with no further user input)"
60
-
61
-
62
- # process command arguments
63
- try:
64
- opt_list, args = getopt.getopt(sys.argv[1:], 'r:vo:A:Cp:U:eM:')
65
-
66
- except getopt.GetoptError, msg:
67
- print 'prepare_receptor4.py: %s' %msg
68
- usage()
69
- sys.exit(2)
70
-
71
- # initialize required parameters
72
- #-s: receptor
73
- receptor_filename = None
74
-
75
- # optional parameters
76
- verbose = None
77
- #-A: repairs to make: add bonds and/or hydrogens or checkhydrogens
78
- repairs = ''
79
- #-C default: add gasteiger charges
80
- charges_to_add = 'gasteiger'
81
- #-p preserve charges on specific atom types
82
- preserve_charge_types=None
83
- #-U: cleanup by merging nphs_lps, nphs, lps, waters, nonstdres
84
- cleanup = "nphs_lps_waters_nonstdres"
85
- #-o outputfilename
86
- outputfilename = None
87
- #-m mode
88
- mode = 'automatic'
89
- #-e delete every nonstd residue from each chain
90
- delete_single_nonstd_residues = None
91
-
92
- #'r:vo:A:Cp:U:eMh'
93
- for o, a in opt_list:
94
- if o in ('-r', '--r'):
95
- receptor_filename = a
96
- if verbose: print 'set receptor_filename to ', a
97
- if o in ('-v', '--v'):
98
- verbose = True
99
- if verbose: print 'set verbose to ', True
100
- if o in ('-o', '--o'):
101
- outputfilename = a
102
- if verbose: print 'set outputfilename to ', a
103
- if o in ('-A', '--A'):
104
- repairs = a
105
- if verbose: print 'set repairs to ', a
106
- if o in ('-C', '--C'):
107
- charges_to_add = None
108
- if verbose: print 'do not add charges'
109
- if o in ('-p', '--p'):
110
- if not preserve_charge_types:
111
- preserve_charge_types = a
112
- else:
113
- preserve_charge_types = preserve_charge_types + ','+ a
114
- if verbose: print 'preserve initial charges on ', preserve_charge_types
115
- if o in ('-U', '--U'):
116
- cleanup = a
117
- if verbose: print 'set cleanup to ', a
118
- if o in ('-e', '--e'):
119
- delete_single_nonstd_residues = True
120
- if verbose: print 'set delete_single_nonstd_residues to True'
121
- if o in ('-M', '--M'):
122
- mode = a
123
- if verbose: print 'set mode to ', a
124
- if o in ('-h', '--'):
125
- usage()
126
- sys.exit()
127
-
128
-
129
- if not receptor_filename:
130
- print 'prepare_receptor4: receptor filename must be specified.'
131
- usage()
132
- sys.exit()
133
-
134
- #what about nucleic acids???
135
-
136
- mols = Read(receptor_filename)
137
- if verbose: print 'read ', receptor_filename
138
- mol = mols[0]
139
- preserved = {}
140
- if charges_to_add is not None and preserve_charge_types is not None:
141
- preserved_types = preserve_charge_types.split(',')
142
- if verbose: print "preserved_types=", preserved_types
143
- for t in preserved_types:
144
- if verbose: print 'preserving charges on type->', t
145
- if not len(t): continue
146
- ats = mol.allAtoms.get(lambda x: x.autodock_element==t)
147
- if verbose: print "preserving charges on ", ats.name
148
- for a in ats:
149
- if a.chargeSet is not None:
150
- preserved[a] = [a.chargeSet, a.charge]
151
-
152
- if len(mols)>1:
153
- if verbose: print "more than one molecule in file"
154
- #use the molecule with the most atoms
155
- ctr = 1
156
- for m in mols[1:]:
157
- ctr += 1
158
- if len(m.allAtoms)>len(mol.allAtoms):
159
- mol = m
160
- if verbose: print "mol set to ", ctr, "th molecule with", len(mol.allAtoms), "atoms"
161
- mol.buildBondsByDistance()
162
-
163
- if verbose:
164
- print "setting up RPO with mode=", mode,
165
- print "and outputfilename= ", outputfilename
166
- print "charges_to_add=", charges_to_add
167
- print "delete_single_nonstd_residues=", delete_single_nonstd_residues
168
-
169
- RPO = AD4ReceptorPreparation(mol, mode, repairs, charges_to_add,
170
- cleanup, outputfilename=outputfilename,
171
- preserved=preserved,
172
- delete_single_nonstd_residues=delete_single_nonstd_residues)
173
-
174
- if charges_to_add is not None:
175
- #restore any previous charges
176
- for atom, chargeList in preserved.items():
177
- atom._charges[chargeList[0]] = chargeList[1]
178
- atom.chargeSet = chargeList[0]
179
-
180
-
181
- # To execute this command type:
182
- # prepare_receptor4.py -r pdb_file -o outputfilename -A checkhydrogens
183
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
evaluation/vina_score.py DELETED
@@ -1,35 +0,0 @@
1
- from vina import Vina
2
- from rdkit.Chem.rdForceFieldHelpers import UFFOptimizeMolecule
3
- from rdkit import Chem
4
- import numpy as np
5
- import os
6
-
7
- for i in range(100):
8
- path = './' + str(i) + '.sdf'
9
- if os.path.exists(path):
10
- print(path)
11
- v = Vina(sf_name='vina')
12
- v.set_receptor('2rma_protein.pdbqt')
13
- v.set_ligand_from_file('2rma_ligand'+'.pdbqt')
14
-
15
- # Calculate the docking center
16
- mol = Chem.MolFromMolFile(path, sanitize=True)
17
- mol = Chem.AddHs(mol, addCoords=True)
18
- UFFOptimizeMolecule(mol)
19
- pos = mol.GetConformer(0).GetPositions()
20
- center = np.mean(pos, 0)
21
-
22
- v.compute_vina_maps(center=center, box_size=[20, 20, 20])
23
-
24
- # Score the current pose
25
- energy = v.score()
26
- print('Score before minimization: %.3f (kcal/mol)' % energy[0])
27
-
28
- # Minimized locally the current pose
29
- energy_minimized = v.optimize()
30
- print('Score after minimization : %.3f (kcal/mol)' % energy_minimized[0])
31
- v.write_pose('ligand_minimized.pdbqt', overwrite=True)
32
-
33
- # Dock the ligand
34
- v.dock(exhaustiveness=64, n_poses=30)
35
- v.write_poses('out.pdbqt', n_poses=5, overwrite=True)