コード例 #1
0
ファイル: example_openmm.py プロジェクト: wxrui2013/pytim
    (see also the mdtraj interoperability)
"""
# openmm imports
from simtk.openmm.app import *
from simtk.openmm import *
from simtk.unit import *
# pytim
import pytim
from pytim.datafiles import WATER_PDB

# usual openmm setup, we load one of pytim's example files
pdb = PDBFile(WATER_PDB)
forcefield = ForceField('amber99sb.xml', 'spce.xml')
system = forcefield.createSystem(pdb.topology,
                                 nonbondedMethod=PME,
                                 nonbondedCutoff=1 * nanometer)
integrator = LangevinIntegrator(300 * kelvin, 1 / picosecond,
                                0.002 * picoseconds)
simulation = Simulation(pdb.topology, system, integrator)
simulation.context.setPositions(pdb.positions)

# just pass the openmm Simulation object to pytim
inter = pytim.ITIM(simulation)
print(repr(inter.atoms))

# the new interfacial atoms will be computed at the end
# of the integration cycle
simulation.step(10)
print(repr(inter.atoms))
コード例 #2
0
ファイル: example_water.py プロジェクト: wxrui2013/pytim
# -*- Mode: python; tab-width: 4; indent-tabs-mode:nil; coding: utf-8 -*-
# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
import MDAnalysis as mda
import pytim
from pytim.datafiles import *

u = mda.Universe(WATER_GRO)
#oxygens = u.select_atoms("name OW")
#g = oxygens
#radii = pytim_data.vdwradii(G43A1_TOP)
interface = pytim.ITIM(u, alpha=2., max_layers=4, molecular=True)
layer = interface.layers[0, 0]  # first layer, upper side
print(repr(interface.layers[0, 0]))

interface.writepdb('layers.pdb', centered=False)
コード例 #3
0
from pytim import observables

##########################
sampling_frequency = 50  # change this to 1 to sample each frame
##########################

u = mda.Universe(WATER_GRO, WATER_XTC)
L = np.min(u.dimensions[:3])
oxygens = u.select_atoms("name OW")
radii = pytim_data.vdwradii(G43A1_TOP)

rdf = observables.RDF2D(u, max_radius='full', nbins=120)

interface = pytim.ITIM(u,
                       alpha=2.,
                       group=oxygens,
                       max_layers=4,
                       radii_dict=radii,
                       cluster_cut=3.5)

for ts in u.trajectory[::sampling_frequency]:
    print("frame " + str(ts.frame) + " / " + str(len(u.trajectory)))
    layer = interface.layers[0, 0]
    rdf.sample(layer, layer)

rdf.rdf[0] = 0.0
np.savetxt('RDF.dat', np.column_stack((rdf.bins, rdf.rdf)))
print('RDF saved to RDF.dat')
if sampling_frequency > 1:
    print(
        'set sampling_frequency  = 1 in order to sample each frame in the trajectory'
    )
コード例 #4
0
# -*- Mode: python; tab-width: 4; indent-tabs-mode:nil; coding: utf-8 -*-
# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
import MDAnalysis as mda
import numpy as np
import pytim
from pytim import observables
from pytim.datafiles import *

use_matplotlib  = False

interface = pytim.ITIM(mda.Universe(WATER_GRO))
box = interface.universe.dimensions[:3]

# triangulate the surface
surface = observables.LayerTriangulation(interface)

# obtain : statistics on the surface, two Delaunay objects,
#          the points belonging to the surfaces,
#          the triangles points clipped to the simulation box
stats, tri, points, trim = surface.compute()


msg = 'The total triangulated surface has an area of {:04.1f} Angstrom^2'
print(msg.format( stats[0]))

if use_matplotlib == False:
    print "set use_matplotlib = True to display the triangulated surface"

if use_matplotlib:
    # plot the triangulation using matplotlib
    from mpl_toolkits.mplot3d import Axes3D
コード例 #5
0
import MDAnalysis as mda
import pytim
from pytim.datafiles import WATER_GRO
u = mda.Universe(WATER_GRO)
inter = pytim.ITIM(u)
コード例 #6
0
# -*- Mode: python; tab-width: 4; indent-tabs-mode:nil; coding: utf-8 -*-
# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
import MDAnalysis as mda
import pytim
from pytim.datafiles import *

u = mda.Universe(WATER_GRO)
radii = pytim_data.vdwradii(G43A1_TOP)

interface = pytim.ITIM(u, max_layers=4, molecular=True, cluster_cut=3.5)
interface.writepdb('layers.pdb')
コード例 #7
0
ファイル: example_mdtraj.py プロジェクト: wxrui2013/pytim
# -*- Mode: python; tab-width: 4; indent-tabs-mode:nil; coding: utf-8 -*-
# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
"""
    This example shows how to use pytim classes on trajectories
    loaded with MDTraj (http://mdtraj.org/)
    (see also the openmm interoperability)
"""

import mdtraj
import pytim
from pytim.datafiles import WATER_GRO, WATER_XTC

t = mdtraj.load_xtc(WATER_XTC, top=WATER_GRO)
inter = pytim.ITIM(t)
for step in t[:]:
    print("surface atoms: " + repr(inter.atoms.indices))
コード例 #8
0
# -*- Mode: python; tab-width: 4; indent-tabs-mode:nil; coding: utf-8 -*-
# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
import MDAnalysis as mda
import numpy as np
import pytim
from pytim import observables
from pytim.datafiles import *

u = mda.Universe(WATER_GRO, WATER_XTC)
oxygens = u.select_atoms("name OW")
radii = pytim_data.vdwradii(G43A1_TOP)

number = observables.Number()
interface = pytim.ITIM(u, alpha=2.)

profile = observables.Profile(group=oxygens,
                              observable=number,
                              interface=interface)

for t in u.trajectory[::]:
    print t.frame,
    profile.sample()

print ""

low, up, avg = profile.get_values(binwidth=0.1)
bins = (low + up) / 2.
np.savetxt('intrdist.dat', list(zip(bins, avg)), fmt=['%.5f', '%e'])

# the maximum, excluding the delta contribution