Merge lp:~pierrepo/ptools/bug539468 into lp:ptools

Proposed by Pierre Poulain on 2010-06-03
Status: Merged
Approved by: Adrien Saladin on 2010-06-07
Approved revision: 439
Merged at revision: 438
Proposed branch: lp:~pierrepo/ptools/bug539468
Merge into: lp:ptools
Diff against target: 368 lines (+103/-82)
2 files modified
PyAttract/attract.py (+53/-42)
Tutorial/doc/tutorial.tex (+50/-40)
To merge this branch: bzr merge lp:~pierrepo/ptools/bug539468
Reviewer Review Type Date Requested Status
Adrien Saladin 2010-06-03 Approve on 2010-06-07
Review via email: mp+26727@code.launchpad.net

Description of the change

- fix bug 53946: add options to attract.py
- nicer timing message
- updated tutorial

To post a comment you must log in.
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'PyAttract/attract.py'
2--- PyAttract/attract.py 2010-03-29 07:43:24 +0000
3+++ PyAttract/attract.py 2010-06-03 17:08:23 +0000
4@@ -3,7 +3,7 @@
5 from ptools import *
6 import sys
7 import os
8-import time
9+#import time
10 import datetime
11 import math
12 import string
13@@ -168,70 +168,80 @@
14
15 # check if a required file is found
16 def checkFile(name, comment):
17- flag = os.path.exists(name)
18- if not flag :
19- print "ERROR: file %s is missing" %(name)
20- print "ERROR: %s" %(comment)
21- exit(2)
22+ flag = os.path.exists(name)
23+ if not flag :
24+ msg = "ERROR: file %s not found\n" %(name)
25+ if comment != "":
26+ msg += "ERROR: %s" %(comment)
27+ sys.exit(msg)
28
29
30 ###########################
31 ## MAIN ATTRACT PROGRAM #
32 ###########################
33 from optparse import OptionParser
34-parser = OptionParser()
35-parser.add_option("-s", "--single", action="store_true", dest="single",default=False,help="single minimization mode")
36+parser = OptionParser(usage="%prog -r receptor_file -l ligand_file [-h] [-s] [-t] [--ref]")
37+parser.add_option("-r", "--receptor", action="store", type="string", dest="receptor_name", help="name of the receptor file")
38+parser.add_option("-l", "--ligand", action="store", type="string", dest="ligand_name", help="name of the ligand file")
39+parser.add_option("-s", "--single", action="store_true", dest="single", default=False, help="single minimization mode")
40 parser.add_option("--ref", action="store", type="string", dest="reffile", help="reference ligand for rmsd" )
41 parser.add_option("-t", "--translation", action="store", type="int", dest="transnb", help="translation number (distributed mode) starting from 0 for the first one!")
42 (options, args) = parser.parse_args()
43
44-receptor_name=args[0]
45-ligand_name=args[1]
46+
47+#receptor_name=args[0]
48+#ligand_name=args[1]
49
50 print """
51 **********************************************************************
52+** **
53 ** ATTRACT (Python edition) **
54-** version: this is a development version, **
55-** see below for details **
56+** based on the PTools library **
57+** **
58 **********************************************************************
59-Attract.py
60-using PTools revision %s, from branch %s, unique id %s
61+PTools revision %s
62+from branch %s
63+unique id %s
64 """%(Version().revstr, Version().branchnick, Version().revid)
65
66-
67-
68 import locale
69-import datetime
70-
71
72 #locale.setlocale(locale.LC_ALL, 'fr_FR')
73-now = datetime.datetime.now()
74-print now,"(",now.strftime("%A %B %d %Y, %H:%M"),")"
75+time_start = datetime.datetime.now()
76+#print now,"(",now.strftime("%A %B %d %Y, %H:%M"),")"
77+print "Start time:", time_start
78
79 #==========================
80 # check required files
81 #==========================
82 # receptor
83-checkFile(receptor_name, "A receptor file is needed.")
84+if not options.receptor_name:
85+ parser.print_help()
86+ parser.error("option -r is mandatory")
87+checkFile(options.receptor_name, "")
88 # ligand
89-checkFile(ligand_name, "A ligand file is needed.")
90+if not options.ligand_name:
91+ parser.print_help()
92+ parser.error("option -l is mandatory")
93+checkFile(options.ligand_name, "")
94 # attract.inp
95-checkFile("attract.inp", "A parameters file is needed.")
96+checkFile("attract.inp", "parameters file is required.")
97 # aminon.par
98-checkFile("aminon.par", "A forcefield file is needed.")
99+checkFile("aminon.par", "forcefield file is required.")
100
101 #==========================
102 # read parameter file
103 #==========================
104
105+print "Reading parameters file: attract.inp"
106 (nbminim,lignames,minimlist,rstk) = readParams("attract.inp")
107 print "rstk = ",rstk
108-rec=Rigidbody(receptor_name)
109-lig=Rigidbody(ligand_name)
110+rec=Rigidbody(options.receptor_name)
111+lig=Rigidbody(options.ligand_name)
112 rec=AttractRigidbody(rec)
113 lig=AttractRigidbody(lig)
114-print "Receptor (fixed) %s has %d particules" %(receptor_name,rec.Size())
115-print "Ligand (mobile) %s has %d particules" %(ligand_name,lig.Size())
116+print "Reading receptor (fixed): %s with %d particules" %( options.receptor_name, rec.Size() )
117+print "Reading ligand (mobile): %s with %d particules" %( options.ligand_name, lig.Size() )
118
119 if (options.single and options.transnb):
120 parser.error("options -s and -t are mutually exclusive")
121@@ -242,28 +252,28 @@
122 ftraj = open(trjname, "w")
123
124 if (options.reffile):
125- print "using reference file: %s"%options.reffile
126+ checkFile(options.reffile, "")
127 ref=Rigidbody(options.reffile)
128+ print "Reading reference file: %s with %d particules" %( options.reffile, ref.Size() )
129 refca = ref.CA()
130 if refca.Size() == 0: #No C alpha atom, ligand is probably a dna
131 Rmsd_alias = Rmsd
132- print "No Calpha atom found for ligand (dna ?), I will calculate rmsd on all grains"
133+ print "No Calpha atom found for ligand (DNA?). RMSD will be calculated on all grains"
134 else:
135 Rmsd_alias = rmsdca
136
137-
138 if (not options.single):
139 #systematic docking with default translations and rotations
140 # check for rotation.dat and translation.dat
141- checkFile("rotation.dat", "A rotation file is needed.")
142- checkFile("translation.dat", "A translation file is needed.\nFormer users may rename translat.dat into translation.dat.")
143+ checkFile("rotation.dat", "rotation file is required.")
144+ checkFile("translation.dat", "translation file is required.\nFormer users can rename translat.dat into translation.dat.")
145 translations=Translation()
146 rotations=Rotation()
147 else: #(single mode)
148 #creates dummy translation and rotation
149 translations=[[1,lig.FindCenter()]]
150 rotations=[(0,0,0)]
151- print "Single mode"
152+ print "Single mode simulation"
153
154
155
156@@ -272,8 +282,8 @@
157 transnb=0
158 if (options.transnb!=None):
159 # check for rotation.dat and translation.dat
160- checkFile("rotation.dat", "A rotation file is needed.")
161- checkFile("translation.dat", "A translation file is needed.\nFormer users may rename translat.dat into translation.dat.")
162+ checkFile("rotation.dat", "rotation file is required.")
163+ checkFile("translation.dat", "translation file is required.\nFormer users may rename translat.dat into translation.dat.")
164 trans=Rigidbody("translation.dat")
165 co=trans.GetCoords(options.transnb)
166 translations=[[options.transnb+1,co]]
167@@ -356,8 +366,8 @@
168
169 #output compressed ligand and receptor:
170 if ( not options.single and printFiles==True):
171- print compress_file(receptor_name)
172- print compress_file(ligand_name)
173+ print compress_file(options.receptor_name)
174+ print compress_file(options.ligand_name)
175 print compress_file("aminon.par")
176 print compress_file("translation.dat")
177 print compress_file("rotation.dat")
178@@ -368,8 +378,9 @@
179 ftraj.close()
180 print "Saved all minimization variables (translations/rotations) in %s" %(trjname)
181
182-
183-now = datetime.datetime.now()
184-print "Finished at: ",now.strftime("%A %B %d %Y, %H:%M")
185-
186+# print end and elapsed time
187+time_end = datetime.datetime.now()
188+#print "Finished at: ",now.strftime("%A %B %d %Y, %H:%M")
189+print "End time:", time_end
190+print "Elapsed time:", time_end - time_start
191
192
193=== modified file 'Tutorial/doc/tutorial.tex'
194--- Tutorial/doc/tutorial.tex 2010-04-23 07:33:13 +0000
195+++ Tutorial/doc/tutorial.tex 2010-06-03 17:08:23 +0000
196@@ -90,7 +90,7 @@
197 \subsubsection{On Debian or Debian-like systems (Ubuntu)}
198
199 \begin{verbatim}
200-apt-get install scons libboost-dev libbost-python-dev gccxml
201+apt-get install scons libboost-dev libboost-python-dev gccxml
202 \end{verbatim}
203 %
204 See \ref{pyplusplus} for installing necessary tools for building python bindings.
205@@ -720,17 +720,20 @@
206 \item docking parameters ({\tt attract.inp})
207 \end{itemize}
208
209-ATTRACT can be used with different options:
210+ATTRACT can be used with different options.
211 \begin{itemize}
212-\item {\tt -s}, performs one single serie of minimisations with the ligand in its initial position.
213+\item \verb@-r@ or \verb@--receptor@ (mandatory): defines the receptor file.
214+\item \verb@-l@ or \verb@--ligand@ (mandatory): defines the ligand file.
215+\item \verb@ -s@ (optional): performs one single serie of minimisations with the ligand in its initial position.
216 \item \verb@--ref@, (optional) provides a ligand PDB file as a reference (reduced). After each docking, the RMSD is calculated between this reference structure and the simulated ligand.
217-\item \verb!--t transnb!, loads only the translation number {\tt transnb} (and all its associated rotations). This option is very usefull for dispatching a simulation over a cluster of computers.
218+\item \verb@--t transnb@ (optional): loads only the translation number {\tt transnb} (and all its associated rotations). This option is very usefull for dispatching a simulation over a cluster of computers.
219+\item \verb@-h@ or \verb@--help@ (optional): reminds possible options.
220 \end{itemize}
221
222
223 A single ATTRACT simulation (optimization) may thus be obtained by:
224 \begin{verbatim}
225-attract.py receptor.red ligand.red --ref=ligand.red -s > single.att
226+attract.py -r receptor.red -l ligand.red --ref=ligand.red -s > single.att
227 \end{verbatim}
228
229 The first PDB file provided must be the receptor file (and the second the ligand).
230@@ -739,72 +742,79 @@
231 \newpage
232 \linenumbers*
233 \begin{verbatim}
234-
235 **********************************************************************
236+** **
237 ** ATTRACT (Python edition) **
238-** version: 0.3 **
239+** based on the PTools library **
240+** **
241 **********************************************************************
242-Attract.py: $Id: Attract.py 616 2008-11-25 12:42:39Z asaladin $
243-using PTools: 614
244+PTools revision 437
245+from branch bug539468
246+unique id pierre_poulain-20100603130128-awuyfelj7avtls54
247
248-2008-12-11 00:08:18.212859 ( Thursday December 11 2008, 00:08 )
249+Start time: 2010-06-03 18:50:57.506277
250+Reading parameters file: attract.inp
251 6 series of minimizations
252 rstk = 0.0005
253-Receptor (fixed) receptor.red has 522 particules
254-Ligand (mobile) ligand.red has 126 particules
255-using reference file: ligand.red
256-Single mode
257+Reading receptor (fixed): receptor.red with 246 particules
258+Reading ligand (mobile): ligand.red with 162 particules
259+Reading reference file: ligand.red with 162 particules
260+Single mode simulation
261 @@@@@@@ Translation nb 1 @@@@@@@
262 ----- Rotation nb 1 -----
263 {{ minimization nb 1 of 6 ; cutoff= 99.50 (A) ; maxiter= 100
264 number of free variables for the minimizer: 6
265-CONVERGENCE: REL_REDUCTION_OF_F <= FACTR*EPSMCH | 72 iterations
266+CONVERGENCE: REL_REDUCTION_OF_F <= FACTR*EPSMCH | 69 iterations
267 {{ minimization nb 2 of 6 ; cutoff= 38.73 (A) ; maxiter= 100
268 number of free variables for the minimizer: 6
269-CONVERGENCE: REL_REDUCTION_OF_F <= FACTR*EPSMCH | 2 iterations
270+CONVERGENCE: REL_REDUCTION_OF_F <= FACTR*EPSMCH | 9 iterations
271 {{ minimization nb 3 of 6 ; cutoff= 31.62 (A) ; maxiter= 100
272 number of free variables for the minimizer: 6
273-CONVERGENCE: REL_REDUCTION_OF_F <= FACTR*EPSMCH | 3 iterations
274+CONVERGENCE: REL_REDUCTION_OF_F <= FACTR*EPSMCH | 13 iterations
275 {{ minimization nb 4 of 6 ; cutoff= 22.36 (A) ; maxiter= 50
276 number of free variables for the minimizer: 6
277-CONVERGENCE: REL_REDUCTION_OF_F <= FACTR*EPSMCH | 10 iterations
278+CONVERGENCE: REL_REDUCTION_OF_F <= FACTR*EPSMCH | 11 iterations
279 {{ minimization nb 5 of 6 ; cutoff= 22.36 (A) ; maxiter= 50
280 number of free variables for the minimizer: 6
281-CONVERGENCE: REL_REDUCTION_OF_F <= FACTR*EPSMCH | 1 iterations
282+CONVERGENCE: REL_REDUCTION_OF_F <= FACTR*EPSMCH | 3 iterations
283 {{ minimization nb 6 of 6 ; cutoff= 22.36 (A) ; maxiter= 50
284 number of free variables for the minimizer: 6
285 CONVERGENCE: REL_REDUCTION_OF_F <= FACTR*EPSMCH | 1 iterations
286 Trans Rot Ener RmsdCA_ref
287-== 1 1 -58.3541422 1.19455904733
288+== 1 1 -58.4463779 1.23525236672
289 ### MAT BEGIN
290-MAT 0.9973001 0.0414787 -0.0605965 0.4545131
291-MAT -0.0430245 0.9987753 -0.0244310 1.9814388
292-MAT 0.0595089 0.0269722 0.9978633 -2.8603610
293+MAT 0.9941915 -0.0969983 0.0466331 0.4410928
294+MAT 0.0984211 0.9947151 -0.0292441 -1.1030090
295+MAT -0.0435501 0.0336639 0.9984839 0.5793707
296 MAT 0.0000000 0.0000000 0.0000000 1.0000000
297 ### MAT END
298
299-Finished at: Thursday December 11 2008, 00:08
300-
301+Saved all minimization variables (translations/rotations) in minimization.trj
302+End time: 2010-06-03 18:50:58.031199
303+Elapsed time: 0:00:00.524922
304 \end{verbatim}
305 \nolinenumbers
306
307 \begin{itemize}
308-\item{\bf line 9:} starting date and time of the simulation
309-\item{\bf lines 18--20:} minimization 1. Minimization index, cutoff
310-in \AA\ and maximum number of iterations (line~18).
311-Number of variables (line~19). End of minimization (line~20), either
312+\item{\bf lines 1--6:} header
313+\item{\bf lines 7--9:} PTools library revision, branch and unique id
314+\item{\bf line 11:} starting date and time of the simulation
315+\item{\bf lines 21--23:} minimization 1. Minimization index, cutoff
316+in \AA\ and maximum number of iterations (line~21).
317+Number of variables (line~22). End of minimization (line~23), either
318 convergence is achieved (the number of performed iterations is specified),
319 either maximum number of steps is reached.
320-\item{\bf lines 21--23:} minimization 2.
321-\item{\bf lines 24--26:} minimization 3.
322-\item{\bf lines 27--29:} minimization 4.
323-\item{\bf lines 30--32:} minimization 5.
324-\item{\bf lines 33--35:} minimization 6.
325-\item{\bf lines 36--37:} final result after the 6 minimizations. With a single series of minimization, the default translation ({\tt Trans}) is 1 and the default rotation ({\tt Rot}) is 1.
326+\item{\bf lines 24--26:} minimization 2.
327+\item{\bf lines 27--29:} minimization 3.
328+\item{\bf lines 30--32:} minimization 4.
329+\item{\bf lines 33--35:} minimization 5.
330+\item{\bf lines 36--38:} minimization 6.
331+\item{\bf lines 39--40:} final result after the 6 minimizations. With a single series of minimization, the default translation ({\tt Trans}) is 1 and the default rotation ({\tt Rot}) is 1.
332 Energy ({\tt Ener}) is given in RT unit and the C$_{\alpha}$-RMSD
333 ({\tt RmsdCA\_ref}) in \AA\ if the \verb@--ref@ option is specified.
334-\item{\bf lines 38--43:} rotation/translation matrix of the ligand compared to its initial position.
335-\item{\bf line 45:} end date and time of the simulation.
336+\item{\bf lines 41--46:} rotation/translation matrix of the ligand compared to its initial position.
337+\item{\bf line 49:} end date and time of the simulation.
338+\item{\bf line 50:} elapsed time for the simulation
339 \end{itemize}
340
341 Here, the final energy is -58.4~RT unit and the RMSD is 1.2~\AA, which is pretty close from the initial position. (In a \emph{perfect} simulation, RMSD would be, of course, 0.0~\AA).
342@@ -813,7 +823,7 @@
343
344 For a full systematic docking in the translational and rotational space (using both {\tt translation.dat} and {\tt rotation.dat} files), the command line is:
345 \begin{verbatim}
346-attract.py receptor.red ligand.red --ref=ligand.red > docking.att &
347+attract.py -r receptor.red -l ligand.red --ref=ligand.red > docking.att &
348 \end{verbatim}
349
350 The output file {\tt docking.att} contains all informations on the docking simulation.
351@@ -1074,7 +1084,7 @@
352
353 An ATTRACT optimization is done with:
354 \begin{verbatim}
355-attract.py receptor.red ligand.red --ref=ligand.red -s > single.att
356+attract.py -r receptor.red -l ligand.red --ref=ligand.red -s > single.att
357 \end{verbatim}
358
359 Here, the final energy is -38.4~RT unit and the RMSD is 1.3~\AA\ which is very close
360@@ -1087,7 +1097,7 @@
361
362 A systematic docking simulation is then:
363 \begin{verbatim}
364-attract.py receptor.red ligand.red --ref=ligand.red > docking.att &
365+attract.py -r receptor.red -l ligand.red --ref=ligand.red > docking.att &
366 \end{verbatim}
367
368 The output file {\tt docking.att} contains all informations on the docking

Subscribers

People subscribed via source and target branches

to all changes: