Beispiel #1
0
def test(fn):
    x=xdrfile(fn)
    if x.natoms != natoms1: print "natoms != natoms1",x.natoms,natoms1
    for k,f in enumerate(x):
        if f.step != step1+k: print "incorrect step",f.step,step1+k,k
        if fabs(f.time-time1-k) > toler: print "incorrect time",f.time,time1+k
        if not x.mode&mTrr and fabs(f.prec-prec1) > toler: print "incorrect precision",f.prec,prec1
        if x.mode&mTrr and fabs(f.lam-lam1) > toler: print "incorrect lambda",f.lam,lam1
        for i in range(DIM):
            for j in range(DIM):
                if fabs(f.box[i][j] - box1[i][j]) > toler: print "box incorrect",f.box[i][j],box1[i][j]
        for i in range(x.natoms):
            for j in range(DIM):
                target = (i+1)*3.7 + (j+1)
                if  f.x[i][j] - target > toler : print "x incorrect"
    print fn,"OK"
Beispiel #2
0
def test(fn):
    x = xdrfile(fn)
    if x.natoms != natoms1: print "natoms != natoms1", x.natoms, natoms1
    for k, f in enumerate(x):
        if f.step != step1 + k: print "incorrect step", f.step, step1 + k, k
        if fabs(f.time - time1 - k) > toler:
            print "incorrect time", f.time, time1 + k
        if not x.mode & mTrr and fabs(f.prec - prec1) > toler:
            print "incorrect precision", f.prec, prec1
        if x.mode & mTrr and fabs(f.lam - lam1) > toler:
            print "incorrect lambda", f.lam, lam1
        for i in range(DIM):
            for j in range(DIM):
                if fabs(f.box[i][j] - box1[i][j]) > toler:
                    print "box incorrect", f.box[i][j], box1[i][j]
        for i in range(x.natoms):
            for j in range(DIM):
                target = (i + 1) * 3.7 + (j + 1)
                if f.x[i][j] - target > toler: print "x incorrect"
    print fn, "OK"
Beispiel #3
0
# input: .xtc file specified as the first argument
# output: stdin dump of coordinates in a format suitable for
#        piping it into the pitch-n-roll analysis programme
#------------------------------------------------------------
# The .xtc file should contain only the atoms of interest
#  (e.g. CA carbons)
# with PBC already REMOVED!!!
#------------------------------------------------------------


from xdrfile import *
import sys

#you have to compile with --enable-shared
#and have libxdrfile.so in the LD_LIBRARY_PATH

if len(sys.argv)!=2:
  print "Missing file argument\nUsage: sample.py FILE"
  sys.exit()


x=xdrfile(sys.argv[1]) 
print x.natoms
for f in x:   #iterates frames
    #print "%8s %8s %8s %8s   Step: %8d "%("Atom","X","Y","Z",f.step) #print header
    print "%8d" % (f.step),
    for atcoor in f.x:  #iterate atoms
      print "%8.3f %8.3f %8.3f"%(atcoor[0],atcoor[1],atcoor[2]), #print coords one after another (note the comma at the end of the print command)
    print

   import IPython
   import cPickle
   # just a shorthand for a long class name
   reswtraj = residue_with_traj
   nframes = 351194
   #nframes = 400 # testing
   membrane_resnames=["POPC"]

   if len(sys.argv)!=3:
     print "Missing file argument\nUsage: sample.py CONF TRAJ"
     sys.exit()

   #open trajectory
   traj_filename = sys.argv[2]
   try:
      trajectory=xdrfile(traj_filename) 
   except:
      print "Error: Trajectory filename '%s' not right" % (traj_filename,)
      sys.exit(1)
   print "Opened trajectory with %5d atoms. " % (trajectory.natoms,)

   #make neg = Model instance based on configuration in conf_filename
   conf_filename = sys.argv[1]
   try:
      neg = pmx.model.Model(filename=conf_filename)
   except:
      print "Error: Model filename '%s' not right" % (conf_filename,)
      sys.exit(1)

   membrane = reswtraj(pmx.molecule.Molecule(),nframes=nframes)
   membrane.mol.resname="POPC"
Beispiel #5
0
#  and/or sell copies of the Software, and to permit persons to whom the
#  Software is furnished to do so, subject to the following conditions:
#
#  The above copyright notice and this permission notice shall be included in
#  all copies or substantial portions of the Software.
#
#  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
#  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
#  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
#  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
#  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
#  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
#  DEALINGS IN THE SOFTWARE.
#
from xdrfile import *
import sys

# you have to compile with --enable-shared
# and have libxdrfile.so in the LD_LIBRARY_PATH

if len(sys.argv) != 2:
    print "Missing file argument\nUsage: sample.py FILE"
    sys.exit()


x = xdrfile(sys.argv[1])
for f in x:  # iterates frames
    print "%8s %8s %8s %8s   Step: %8d " % ("Atom", "X", "Y", "Z", f.step)  # print header
    for i, a in enumerate(f.x):  # iterate atoms
        print "%8d %8.1f %8.1f %8.1f" % (i + 1, a[0], a[1], a[2])  # print atom number, x, y, z
Beispiel #6
0
    import IPython
    import cPickle
    # just a shorthand for a long class name
    reswtraj = residue_with_traj
    nframes = 351194
    #nframes = 400 # testing
    membrane_resnames = ["POPC"]

    if len(sys.argv) != 3:
        print "Missing file argument\nUsage: sample.py CONF TRAJ"
        sys.exit()

    #open trajectory
    traj_filename = sys.argv[2]
    try:
        trajectory = xdrfile(traj_filename)
    except:
        print "Error: Trajectory filename '%s' not right" % (traj_filename, )
        sys.exit(1)
    print "Opened trajectory with %5d atoms. " % (trajectory.natoms, )

    #make neg = Model instance based on configuration in conf_filename
    conf_filename = sys.argv[1]
    try:
        neg = pmx.model.Model(filename=conf_filename)
    except:
        print "Error: Model filename '%s' not right" % (conf_filename, )
        sys.exit(1)

    membrane = reswtraj(pmx.molecule.Molecule(), nframes=nframes)
    membrane.mol.resname = "POPC"
    #Изготовление списка пар, соответствующих списку остатков
    pairs=map(\
        lambda pair:(residues.index(pair[0]),residues.index(pair[1])),\
        pairs)
    print pairs
#Индексация атомов выбранных плоскостей
planes=[]
for residue in residues:
    planes.append((\
        topology.index[residue[0]][residue[1]][plane_atoms[residue[0]][0]],\
        topology.index[residue[0]][residue[1]][plane_atoms[residue[0]][1]],\
        topology.index[residue[0]][residue[1]][plane_atoms[residue[0]][2]]))


#Чтение траектории
xtc=xdrfile(arguments[1][1])
#Анализ стэкинга
stacking=[]
equations=[[] for plane in planes]
residue_quantity=len(residues)
times=[]
#По всем состояниям
count=0
for frame in xtc:
    stacking+=[[]]
    #stacking[-1]+=[frame.step]
    times+=[str(frame.time/1000)]
    #По всем остаткам считаем уравнения плоскостей
    for i in range(residue_quantity):
        try:
            atom1=frame.x[planes[i][0]]