1 | #!/usr/bin/env python
|
---|
2 | # main.py
|
---|
3 | #
|
---|
4 | # Copyright 2007 Frank Eisenmenger, U.H.E. Hansmann,
|
---|
5 | # Jan H. Meinke, Sandipan Mohanty
|
---|
6 |
|
---|
7 | ## \mainpage pySMMP: Python bindings to SMMP v. 1.1.
|
---|
8 | # SMMP is a FORTRAN library for simulating proteins. It provides
|
---|
9 | # minimization routines and various Monte Carlo methods. SMMP uses an all-atom
|
---|
10 | # representation of the protein. It stores the configuration within the
|
---|
11 | # standard geometry model. In the standard geometry model the internal degrees
|
---|
12 | # of freedom, e.g., the dihedral angles, the bond lengths, etc. are stored and
|
---|
13 | # the cartesian coordinates are calculated on the fly. For more details on
|
---|
14 | # the model SMMP uses and the functions it provides see the manual (manual.ps).
|
---|
15 | #
|
---|
16 | # pySMMP builds on SMMP. It provides python bindings to the functions and
|
---|
17 | # global variables, but it uses classes to represent the Proteins and
|
---|
18 | # algorithms.
|
---|
19 | #
|
---|
20 | # \section sec_tutorial A Tutorial: A canonical Monte Carlo simulation of protein A
|
---|
21 | #
|
---|
22 | # The basic setup is the same for most simulations. This tutorial takes you
|
---|
23 | # step by step to a running simulation. First we need to import the library
|
---|
24 | # \code
|
---|
25 | # import smmp
|
---|
26 | # \endcode
|
---|
27 | # This makes the smmp routines available to the Python interpreter. Next we
|
---|
28 | # create the universe by initializing a universe.Universe object by first
|
---|
29 | # importing the universe package and then setting the object:
|
---|
30 | # \code
|
---|
31 | # import universe
|
---|
32 | # myUniverse = universe.Universe(T=300)
|
---|
33 | # \endcode
|
---|
34 | # This initializes the smmp library as well. We also set the initial
|
---|
35 | # temperature of the universe to 300K. The Universe object initializes the
|
---|
36 | # SMMP library and keeps track of global parameters, e.g, the temperature T.
|
---|
37 | # After you created a Universe, you can initialize a Protein. Proteins can
|
---|
38 | # be read from a sequence and a variable file or from a PDB file.
|
---|
39 | # \code
|
---|
40 | # import protein
|
---|
41 | #
|
---|
42 | # protA = protein.Protein("1bdd.seq", "1bdd.var")
|
---|
43 | # myUniverse.add(protA)
|
---|
44 | # \endcode
|
---|
45 | # Adding the protein to myUniverse makes the universe aware of it.
|
---|
46 | # Now you are ready to run a simulation. You can also querry the protein for
|
---|
47 | # various properties, e.g.,
|
---|
48 | # \code
|
---|
49 | # print protA.rgyr()
|
---|
50 | # \endcode
|
---|
51 | # prints the radius of gyration of the protein.
|
---|
52 | # A canonical Monte Carlo algorithm is available in the algorithms package.
|
---|
53 | # \code
|
---|
54 | # import algorithms
|
---|
55 | # myMC = algorithms.CanonicalMonteCarlo(myUniverse, 1000, 10000)
|
---|
56 | # \endcode
|
---|
57 | # This sets up a simulation with 1000 steps for equilibration and a default
|
---|
58 | # length of 10000 sweeps.
|
---|
59 | # The quickest way to run the simulation is by calling the run method of the
|
---|
60 | # algorithm object myMC to do the entire Monte Carlo run.
|
---|
61 | # \code
|
---|
62 | # myMC.run()
|
---|
63 | # \endcode
|
---|
64 |
|
---|
65 | import sys, time
|
---|
66 | from optparse import OptionParser
|
---|
67 | from protein import *
|
---|
68 | from universe import *
|
---|
69 | from algorithms import CanonicalMonteCarlo
|
---|
70 |
|
---|
71 | if __name__ == "__main__":
|
---|
72 | # Set up command line options
|
---|
73 | usage = "usage: %prog [options] seq-filename"
|
---|
74 | parser = OptionParser(usage = usage, version="%prog 20050805")
|
---|
75 | parser.add_option("-v", "--variables", dest="varFileName",
|
---|
76 | help="read amino-acid conformation from FILE", metavar="FILE")
|
---|
77 | parser.add_option("--equi", type="int", dest="nequi", default=100,
|
---|
78 | help="number of sweeps for equilibration", metavar="n")
|
---|
79 | parser.add_option("--sweeps", type="int", dest="sweeps", default=10000,
|
---|
80 | help="number of sweeps for annealing", metavar="n")
|
---|
81 | parser.add_option("--mes", type="int", dest="mes", default=10,
|
---|
82 | help="number of sweeps between measurements", metavar="n")
|
---|
83 | parser.add_option("--Tmax", type="float", dest="tmax", default=1000,
|
---|
84 | help="maximum temperature for annealing", metavar="T")
|
---|
85 | parser.add_option("--Tmin", type="float", dest="tmin", default=100,
|
---|
86 | help="maximum temperature for annealing",metavar="T")
|
---|
87 |
|
---|
88 | (options, args) = parser.parse_args()
|
---|
89 | if len(args) < 1:
|
---|
90 | parser.print_help()
|
---|
91 | sys.exit()
|
---|
92 | seqFileName = args[0]
|
---|
93 |
|
---|
94 | # Start simulation setup.
|
---|
95 | myUniv = Universe(T=300, st=0)
|
---|
96 | p1 = Protein(seqFileName, options.varFileName)
|
---|
97 | p1.setOrigin((0, 0, 0), (0, 0, 0))
|
---|
98 | myUniv.add(p1)
|
---|
99 | T = 300.0
|
---|
100 | smmp.outpdb(1, "start.pdb")
|
---|
101 | print "E of starting configuration.", myUniv.energy()
|
---|
102 | ts = time.time()
|
---|
103 | smmp.minim(1, options.sweeps, 1.0E-12)
|
---|
104 |
|
---|
105 | smmp.outpdb(1, "equi.pdb")
|
---|
106 |
|
---|
107 | t1 = time.clock()
|
---|
108 | print myUniv.energy(), myUniv.rgyr(), myUniv.helix(), p1.hbond(), (t1-ts)
|
---|
109 | p1.saveVariables("final.var")
|
---|
110 | smmp.outpdb(0, "final.pdb")
|
---|
111 | te = time.time()
|
---|
112 | print "The calculation took %ss." % (te - ts)
|
---|
113 |
|
---|
114 |
|
---|