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

Proposed by Pierre Poulain
Status: Merged
Approved by: Adrien Saladin
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 Approve
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.
Revision history for this message
Adrien Saladin (adrien-saladin) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'PyAttract/attract.py'
--- PyAttract/attract.py 2010-03-29 07:43:24 +0000
+++ PyAttract/attract.py 2010-06-03 17:08:23 +0000
@@ -3,7 +3,7 @@
3from ptools import *3from ptools import *
4import sys4import sys
5import os5import os
6import time6#import time
7import datetime7import datetime
8import math8import math
9import string9import string
@@ -168,70 +168,80 @@
168168
169# check if a required file is found169# check if a required file is found
170def checkFile(name, comment):170def checkFile(name, comment):
171 flag = os.path.exists(name)171 flag = os.path.exists(name)
172 if not flag :172 if not flag :
173 print "ERROR: file %s is missing" %(name)173 msg = "ERROR: file %s not found\n" %(name)
174 print "ERROR: %s" %(comment)174 if comment != "":
175 exit(2) 175 msg += "ERROR: %s" %(comment)
176 sys.exit(msg)
176177
177178
178###########################179###########################
179## MAIN ATTRACT PROGRAM #180## MAIN ATTRACT PROGRAM #
180###########################181###########################
181from optparse import OptionParser182from optparse import OptionParser
182parser = OptionParser()183parser = OptionParser(usage="%prog -r receptor_file -l ligand_file [-h] [-s] [-t] [--ref]")
183parser.add_option("-s", "--single", action="store_true", dest="single",default=False,help="single minimization mode")184parser.add_option("-r", "--receptor", action="store", type="string", dest="receptor_name", help="name of the receptor file")
185parser.add_option("-l", "--ligand", action="store", type="string", dest="ligand_name", help="name of the ligand file")
186parser.add_option("-s", "--single", action="store_true", dest="single", default=False, help="single minimization mode")
184parser.add_option("--ref", action="store", type="string", dest="reffile", help="reference ligand for rmsd" )187parser.add_option("--ref", action="store", type="string", dest="reffile", help="reference ligand for rmsd" )
185parser.add_option("-t", "--translation", action="store", type="int", dest="transnb", help="translation number (distributed mode) starting from 0 for the first one!")188parser.add_option("-t", "--translation", action="store", type="int", dest="transnb", help="translation number (distributed mode) starting from 0 for the first one!")
186(options, args) = parser.parse_args()189(options, args) = parser.parse_args()
187190
188receptor_name=args[0]191
189ligand_name=args[1]192#receptor_name=args[0]
193#ligand_name=args[1]
190194
191print """195print """
192**********************************************************************196**********************************************************************
197** **
193** ATTRACT (Python edition) **198** ATTRACT (Python edition) **
194** version: this is a development version, **199** based on the PTools library **
195** see below for details **200** **
196**********************************************************************201**********************************************************************
197Attract.py202PTools revision %s
198using PTools revision %s, from branch %s, unique id %s203from branch %s
204unique id %s
199"""%(Version().revstr, Version().branchnick, Version().revid)205"""%(Version().revstr, Version().branchnick, Version().revid)
200206
201
202
203import locale207import locale
204import datetime
205
206208
207#locale.setlocale(locale.LC_ALL, 'fr_FR')209#locale.setlocale(locale.LC_ALL, 'fr_FR')
208now = datetime.datetime.now()210time_start = datetime.datetime.now()
209print now,"(",now.strftime("%A %B %d %Y, %H:%M"),")"211#print now,"(",now.strftime("%A %B %d %Y, %H:%M"),")"
212print "Start time:", time_start
210213
211#==========================214#==========================
212# check required files215# check required files
213#==========================216#==========================
214# receptor217# receptor
215checkFile(receptor_name, "A receptor file is needed.")218if not options.receptor_name:
219 parser.print_help()
220 parser.error("option -r is mandatory")
221checkFile(options.receptor_name, "")
216# ligand222# ligand
217checkFile(ligand_name, "A ligand file is needed.")223if not options.ligand_name:
224 parser.print_help()
225 parser.error("option -l is mandatory")
226checkFile(options.ligand_name, "")
218# attract.inp227# attract.inp
219checkFile("attract.inp", "A parameters file is needed.")228checkFile("attract.inp", "parameters file is required.")
220# aminon.par229# aminon.par
221checkFile("aminon.par", "A forcefield file is needed.")230checkFile("aminon.par", "forcefield file is required.")
222231
223#==========================232#==========================
224# read parameter file233# read parameter file
225#==========================234#==========================
226235
236print "Reading parameters file: attract.inp"
227(nbminim,lignames,minimlist,rstk) = readParams("attract.inp")237(nbminim,lignames,minimlist,rstk) = readParams("attract.inp")
228print "rstk = ",rstk238print "rstk = ",rstk
229rec=Rigidbody(receptor_name)239rec=Rigidbody(options.receptor_name)
230lig=Rigidbody(ligand_name)240lig=Rigidbody(options.ligand_name)
231rec=AttractRigidbody(rec)241rec=AttractRigidbody(rec)
232lig=AttractRigidbody(lig)242lig=AttractRigidbody(lig)
233print "Receptor (fixed) %s has %d particules" %(receptor_name,rec.Size())243print "Reading receptor (fixed): %s with %d particules" %( options.receptor_name, rec.Size() )
234print "Ligand (mobile) %s has %d particules" %(ligand_name,lig.Size())244print "Reading ligand (mobile): %s with %d particules" %( options.ligand_name, lig.Size() )
235245
236if (options.single and options.transnb):246if (options.single and options.transnb):
237 parser.error("options -s and -t are mutually exclusive")247 parser.error("options -s and -t are mutually exclusive")
@@ -242,28 +252,28 @@
242 ftraj = open(trjname, "w")252 ftraj = open(trjname, "w")
243253
244if (options.reffile):254if (options.reffile):
245 print "using reference file: %s"%options.reffile255 checkFile(options.reffile, "")
246 ref=Rigidbody(options.reffile)256 ref=Rigidbody(options.reffile)
257 print "Reading reference file: %s with %d particules" %( options.reffile, ref.Size() )
247 refca = ref.CA()258 refca = ref.CA()
248 if refca.Size() == 0: #No C alpha atom, ligand is probably a dna259 if refca.Size() == 0: #No C alpha atom, ligand is probably a dna
249 Rmsd_alias = Rmsd260 Rmsd_alias = Rmsd
250 print "No Calpha atom found for ligand (dna ?), I will calculate rmsd on all grains"261 print "No Calpha atom found for ligand (DNA?). RMSD will be calculated on all grains"
251 else:262 else:
252 Rmsd_alias = rmsdca263 Rmsd_alias = rmsdca
253264
254
255if (not options.single):265if (not options.single):
256 #systematic docking with default translations and rotations266 #systematic docking with default translations and rotations
257 # check for rotation.dat and translation.dat267 # check for rotation.dat and translation.dat
258 checkFile("rotation.dat", "A rotation file is needed.")268 checkFile("rotation.dat", "rotation file is required.")
259 checkFile("translation.dat", "A translation file is needed.\nFormer users may rename translat.dat into translation.dat.")269 checkFile("translation.dat", "translation file is required.\nFormer users can rename translat.dat into translation.dat.")
260 translations=Translation()270 translations=Translation()
261 rotations=Rotation()271 rotations=Rotation()
262else: #(single mode)272else: #(single mode)
263 #creates dummy translation and rotation273 #creates dummy translation and rotation
264 translations=[[1,lig.FindCenter()]]274 translations=[[1,lig.FindCenter()]]
265 rotations=[(0,0,0)]275 rotations=[(0,0,0)]
266 print "Single mode"276 print "Single mode simulation"
267277
268278
269279
@@ -272,8 +282,8 @@
272transnb=0282transnb=0
273if (options.transnb!=None):283if (options.transnb!=None):
274 # check for rotation.dat and translation.dat284 # check for rotation.dat and translation.dat
275 checkFile("rotation.dat", "A rotation file is needed.")285 checkFile("rotation.dat", "rotation file is required.")
276 checkFile("translation.dat", "A translation file is needed.\nFormer users may rename translat.dat into translation.dat.")286 checkFile("translation.dat", "translation file is required.\nFormer users may rename translat.dat into translation.dat.")
277 trans=Rigidbody("translation.dat")287 trans=Rigidbody("translation.dat")
278 co=trans.GetCoords(options.transnb)288 co=trans.GetCoords(options.transnb)
279 translations=[[options.transnb+1,co]]289 translations=[[options.transnb+1,co]]
@@ -356,8 +366,8 @@
356366
357#output compressed ligand and receptor:367#output compressed ligand and receptor:
358if ( not options.single and printFiles==True): 368if ( not options.single and printFiles==True):
359 print compress_file(receptor_name)369 print compress_file(options.receptor_name)
360 print compress_file(ligand_name)370 print compress_file(options.ligand_name)
361 print compress_file("aminon.par")371 print compress_file("aminon.par")
362 print compress_file("translation.dat")372 print compress_file("translation.dat")
363 print compress_file("rotation.dat")373 print compress_file("rotation.dat")
@@ -368,8 +378,9 @@
368 ftraj.close()378 ftraj.close()
369 print "Saved all minimization variables (translations/rotations) in %s" %(trjname)379 print "Saved all minimization variables (translations/rotations) in %s" %(trjname)
370380
371381# print end and elapsed time
372now = datetime.datetime.now()382time_end = datetime.datetime.now()
373print "Finished at: ",now.strftime("%A %B %d %Y, %H:%M")383#print "Finished at: ",now.strftime("%A %B %d %Y, %H:%M")
374384print "End time:", time_end
385print "Elapsed time:", time_end - time_start
375386
376387
=== modified file 'Tutorial/doc/tutorial.tex'
--- Tutorial/doc/tutorial.tex 2010-04-23 07:33:13 +0000
+++ Tutorial/doc/tutorial.tex 2010-06-03 17:08:23 +0000
@@ -90,7 +90,7 @@
90\subsubsection{On Debian or Debian-like systems (Ubuntu)}90\subsubsection{On Debian or Debian-like systems (Ubuntu)}
9191
92\begin{verbatim}92\begin{verbatim}
93apt-get install scons libboost-dev libbost-python-dev gccxml93apt-get install scons libboost-dev libboost-python-dev gccxml
94\end{verbatim}94\end{verbatim}
95%95%
96See \ref{pyplusplus} for installing necessary tools for building python bindings.96See \ref{pyplusplus} for installing necessary tools for building python bindings.
@@ -720,17 +720,20 @@
720\item docking parameters ({\tt attract.inp})720\item docking parameters ({\tt attract.inp})
721\end{itemize}721\end{itemize}
722722
723ATTRACT can be used with different options:723ATTRACT can be used with different options.
724\begin{itemize}724\begin{itemize}
725\item {\tt -s}, performs one single serie of minimisations with the ligand in its initial position.725\item \verb@-r@ or \verb@--receptor@ (mandatory): defines the receptor file.
726\item \verb@-l@ or \verb@--ligand@ (mandatory): defines the ligand file.
727\item \verb@ -s@ (optional): performs one single serie of minimisations with the ligand in its initial position.
726\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.728\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.
727\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.729\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.
730\item \verb@-h@ or \verb@--help@ (optional): reminds possible options.
728\end{itemize}731\end{itemize}
729732
730733
731A single ATTRACT simulation (optimization) may thus be obtained by:734A single ATTRACT simulation (optimization) may thus be obtained by:
732\begin{verbatim}735\begin{verbatim}
733attract.py receptor.red ligand.red --ref=ligand.red -s > single.att736attract.py -r receptor.red -l ligand.red --ref=ligand.red -s > single.att
734\end{verbatim}737\end{verbatim}
735738
736The first PDB file provided must be the receptor file (and the second the ligand).739The first PDB file provided must be the receptor file (and the second the ligand).
@@ -739,72 +742,79 @@
739\newpage742\newpage
740\linenumbers*743\linenumbers*
741\begin{verbatim}744\begin{verbatim}
742
743**********************************************************************745**********************************************************************
746** **
744** ATTRACT (Python edition) **747** ATTRACT (Python edition) **
745** version: 0.3 **748** based on the PTools library **
749** **
746**********************************************************************750**********************************************************************
747Attract.py: $Id: Attract.py 616 2008-11-25 12:42:39Z asaladin $751PTools revision 437
748using PTools: 614752from branch bug539468
753unique id pierre_poulain-20100603130128-awuyfelj7avtls54
749754
7502008-12-11 00:08:18.212859 ( Thursday December 11 2008, 00:08 )755Start time: 2010-06-03 18:50:57.506277
756Reading parameters file: attract.inp
7516 series of minimizations7576 series of minimizations
752rstk = 0.0005758rstk = 0.0005
753Receptor (fixed) receptor.red has 522 particules759Reading receptor (fixed): receptor.red with 246 particules
754Ligand (mobile) ligand.red has 126 particules760Reading ligand (mobile): ligand.red with 162 particules
755using reference file: ligand.red761Reading reference file: ligand.red with 162 particules
756Single mode762Single mode simulation
757@@@@@@@ Translation nb 1 @@@@@@@763@@@@@@@ Translation nb 1 @@@@@@@
758----- Rotation nb 1 -----764----- Rotation nb 1 -----
759{{ minimization nb 1 of 6 ; cutoff= 99.50 (A) ; maxiter= 100765{{ minimization nb 1 of 6 ; cutoff= 99.50 (A) ; maxiter= 100
760number of free variables for the minimizer: 6766number of free variables for the minimizer: 6
761CONVERGENCE: REL_REDUCTION_OF_F <= FACTR*EPSMCH | 72 iterations767CONVERGENCE: REL_REDUCTION_OF_F <= FACTR*EPSMCH | 69 iterations
762{{ minimization nb 2 of 6 ; cutoff= 38.73 (A) ; maxiter= 100768{{ minimization nb 2 of 6 ; cutoff= 38.73 (A) ; maxiter= 100
763number of free variables for the minimizer: 6769number of free variables for the minimizer: 6
764CONVERGENCE: REL_REDUCTION_OF_F <= FACTR*EPSMCH | 2 iterations770CONVERGENCE: REL_REDUCTION_OF_F <= FACTR*EPSMCH | 9 iterations
765{{ minimization nb 3 of 6 ; cutoff= 31.62 (A) ; maxiter= 100771{{ minimization nb 3 of 6 ; cutoff= 31.62 (A) ; maxiter= 100
766number of free variables for the minimizer: 6772number of free variables for the minimizer: 6
767CONVERGENCE: REL_REDUCTION_OF_F <= FACTR*EPSMCH | 3 iterations773CONVERGENCE: REL_REDUCTION_OF_F <= FACTR*EPSMCH | 13 iterations
768{{ minimization nb 4 of 6 ; cutoff= 22.36 (A) ; maxiter= 50774{{ minimization nb 4 of 6 ; cutoff= 22.36 (A) ; maxiter= 50
769number of free variables for the minimizer: 6775number of free variables for the minimizer: 6
770CONVERGENCE: REL_REDUCTION_OF_F <= FACTR*EPSMCH | 10 iterations776CONVERGENCE: REL_REDUCTION_OF_F <= FACTR*EPSMCH | 11 iterations
771{{ minimization nb 5 of 6 ; cutoff= 22.36 (A) ; maxiter= 50777{{ minimization nb 5 of 6 ; cutoff= 22.36 (A) ; maxiter= 50
772number of free variables for the minimizer: 6778number of free variables for the minimizer: 6
773CONVERGENCE: REL_REDUCTION_OF_F <= FACTR*EPSMCH | 1 iterations779CONVERGENCE: REL_REDUCTION_OF_F <= FACTR*EPSMCH | 3 iterations
774{{ minimization nb 6 of 6 ; cutoff= 22.36 (A) ; maxiter= 50780{{ minimization nb 6 of 6 ; cutoff= 22.36 (A) ; maxiter= 50
775number of free variables for the minimizer: 6781number of free variables for the minimizer: 6
776CONVERGENCE: REL_REDUCTION_OF_F <= FACTR*EPSMCH | 1 iterations782CONVERGENCE: REL_REDUCTION_OF_F <= FACTR*EPSMCH | 1 iterations
777 Trans Rot Ener RmsdCA_ref783 Trans Rot Ener RmsdCA_ref
778== 1 1 -58.3541422 1.19455904733784== 1 1 -58.4463779 1.23525236672
779### MAT BEGIN785### MAT BEGIN
780MAT 0.9973001 0.0414787 -0.0605965 0.4545131 786MAT 0.9941915 -0.0969983 0.0466331 0.4410928
781MAT -0.0430245 0.9987753 -0.0244310 1.9814388 787MAT 0.0984211 0.9947151 -0.0292441 -1.1030090
782MAT 0.0595089 0.0269722 0.9978633 -2.8603610 788MAT -0.0435501 0.0336639 0.9984839 0.5793707
783MAT 0.0000000 0.0000000 0.0000000 1.0000000 789MAT 0.0000000 0.0000000 0.0000000 1.0000000
784### MAT END790### MAT END
785791
786Finished at: Thursday December 11 2008, 00:08792Saved all minimization variables (translations/rotations) in minimization.trj
787793End time: 2010-06-03 18:50:58.031199
794Elapsed time: 0:00:00.524922
788\end{verbatim}795\end{verbatim}
789\nolinenumbers796\nolinenumbers
790797
791\begin{itemize}798\begin{itemize}
792\item{\bf line 9:} starting date and time of the simulation799\item{\bf lines 1--6:} header
793\item{\bf lines 18--20:} minimization 1. Minimization index, cutoff 800\item{\bf lines 7--9:} PTools library revision, branch and unique id
794in \AA\ and maximum number of iterations (line~18). 801\item{\bf line 11:} starting date and time of the simulation
795Number of variables (line~19). End of minimization (line~20), either 802\item{\bf lines 21--23:} minimization 1. Minimization index, cutoff
803in \AA\ and maximum number of iterations (line~21).
804Number of variables (line~22). End of minimization (line~23), either
796convergence is achieved (the number of performed iterations is specified), 805convergence is achieved (the number of performed iterations is specified),
797either maximum number of steps is reached.806either maximum number of steps is reached.
798\item{\bf lines 21--23:} minimization 2.807\item{\bf lines 24--26:} minimization 2.
799\item{\bf lines 24--26:} minimization 3.808\item{\bf lines 27--29:} minimization 3.
800\item{\bf lines 27--29:} minimization 4.809\item{\bf lines 30--32:} minimization 4.
801\item{\bf lines 30--32:} minimization 5.810\item{\bf lines 33--35:} minimization 5.
802\item{\bf lines 33--35:} minimization 6.811\item{\bf lines 36--38:} minimization 6.
803\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. 812\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.
804Energy ({\tt Ener}) is given in RT unit and the C$_{\alpha}$-RMSD 813Energy ({\tt Ener}) is given in RT unit and the C$_{\alpha}$-RMSD
805({\tt RmsdCA\_ref}) in \AA\ if the \verb@--ref@ option is specified.814({\tt RmsdCA\_ref}) in \AA\ if the \verb@--ref@ option is specified.
806\item{\bf lines 38--43:} rotation/translation matrix of the ligand compared to its initial position.815\item{\bf lines 41--46:} rotation/translation matrix of the ligand compared to its initial position.
807\item{\bf line 45:} end date and time of the simulation.816\item{\bf line 49:} end date and time of the simulation.
817\item{\bf line 50:} elapsed time for the simulation
808\end{itemize}818\end{itemize}
809819
810Here, 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).820Here, 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).
@@ -813,7 +823,7 @@
813823
814For a full systematic docking in the translational and rotational space (using both {\tt translation.dat} and {\tt rotation.dat} files), the command line is:824For a full systematic docking in the translational and rotational space (using both {\tt translation.dat} and {\tt rotation.dat} files), the command line is:
815\begin{verbatim}825\begin{verbatim}
816attract.py receptor.red ligand.red --ref=ligand.red > docking.att &826attract.py -r receptor.red -l ligand.red --ref=ligand.red > docking.att &
817\end{verbatim}827\end{verbatim}
818828
819The output file {\tt docking.att} contains all informations on the docking simulation. 829The output file {\tt docking.att} contains all informations on the docking simulation.
@@ -1074,7 +1084,7 @@
10741084
1075An ATTRACT optimization is done with:1085An ATTRACT optimization is done with:
1076\begin{verbatim}1086\begin{verbatim}
1077attract.py receptor.red ligand.red --ref=ligand.red -s > single.att1087attract.py -r receptor.red -l ligand.red --ref=ligand.red -s > single.att
1078\end{verbatim}1088\end{verbatim}
10791089
1080Here, the final energy is -38.4~RT unit and the RMSD is 1.3~\AA\ which is very close1090Here, the final energy is -38.4~RT unit and the RMSD is 1.3~\AA\ which is very close
@@ -1087,7 +1097,7 @@
10871097
1088A systematic docking simulation is then:1098A systematic docking simulation is then:
1089\begin{verbatim}1099\begin{verbatim}
1090attract.py receptor.red ligand.red --ref=ligand.red > docking.att &1100attract.py -r receptor.red -l ligand.red --ref=ligand.red > docking.att &
1091\end{verbatim}1101\end{verbatim}
10921102
1093The output file {\tt docking.att} contains all informations on the docking 1103The output file {\tt docking.att} contains all informations on the docking

Subscribers

People subscribed via source and target branches

to all changes: