Esempio n. 1
0
    def setUp(self):
        self.mol = Molecule.create()
        self.mol.load(data('water.psf'))
        self.mol.load(data('water.pdb'))
        self.mol.load(data('water.1.dcd'))
        self.mol.frame = 0

        self.other = Molecule.create()
        self.other.load(data('water.psf'))
        self.other.load(data('water.pdb'))

        MOLECULES.top = self.mol

        self.addCleanup(clear_labels)
Esempio n. 2
0
    def setUp(self):
        self.mol = Molecule.create()
        self.mol.load(data('water.psf'))
        self.mol.load(data('water.pdb'))
        self.mol.load(data('water.1.dcd'))
        self.mol.frame = 0

        self.other = Molecule.create()
        self.other.load(data('water.psf'))
        self.other.load(data('water.pdb'))

        MOLECULES.top = self.mol

        self.addCleanup(clear_labels)
Esempio n. 3
0
    def test_molecule_create(self):
        # Test molecule creation
        old_molids = VMD.molecule.listall()
        created = Molecule.create()
        self.assertNotIn(created.molid, old_molids)
        self.assertTrue(VMD.molecule.exists(created.molid))
        self.assertEqual(VMD.molecule.get_filenames(created.molid), [])
        self.assertEqual(VMD.molecule.get_filetypes(created.molid), [])

        # Check create with name
        other = Molecule.create('The One')
        self.assertEqual(other.name, 'The One')
        self.assertTrue(VMD.molecule.exists(other.molid))
        self.assertEqual(VMD.molecule.get_filenames(other.molid), [])
        self.assertEqual(VMD.molecule.get_filetypes(other.molid), [])
Esempio n. 4
0
    def test_molecule_comparison(self):
        # Test molecule comparison
        mol1 = Molecule(self.molid)
        mol2 = Molecule(self.molid)
        other = Molecule.create()

        self.assertEqual(mol1, mol1)
        self.assertEqual(mol1, mol2)
        self.assertNotEqual(mol1, other)
        self.assertNotEqual(mol2, other)
Esempio n. 5
0
    def test_molecule_load(self):
        # Test file loading
        mol = Molecule.create()
        mol.load(data('water.psf'))
        self.assertEqual(VMD.molecule.get_filenames(mol.molid), [data('water.psf')])
        self.assertEqual(VMD.molecule.get_filetypes(mol.molid), ['psf'])
        mol.load(data('water.pdb'), FORMAT_PDB)
        self.assertEqual(VMD.molecule.get_filenames(mol.molid), [data('water.psf'), data('water.pdb')])
        self.assertEqual(VMD.molecule.get_filetypes(mol.molid), ['psf', 'pdb'])
        mol.load(data('water.1.dcd'))
        self.assertEqual(VMD.molecule.get_filenames(mol.molid),
                         [data('water.psf'), data('water.pdb'), data('water.1.dcd')])
        self.assertEqual(VMD.molecule.get_filetypes(mol.molid), ['psf', 'pdb', 'dcd'])

        self.assertRaises(ValueError, mol.load, 'no_extension')
Esempio n. 6
0
    def test_rmsd_collector(self):
        # Test RMSD collector
        ref = Molecule.create()
        ref.load(data('water.psf'))
        ref.load(data('water.pdb'))
        dset = DataSet()
        dset.add_collector(RMSDCollector('all', Selection('all', ref)))
        dset.add_collector(RMSDCollector('all and name OH2', Selection('all and name OH2', ref)))
        dset.add_collector(RMSDCollector('all and noh', Selection('all and noh', ref), name='noh'))
        analyzer = Analyzer(self.mol, [data('water.1.dcd')])
        analyzer.add_dataset(dset)
        analyzer.analyze()

        # Write data to check result
        buf = StringIO()
        dset.write(buf)
        # Check the result
        self.assertEqual(buf.getvalue(), open(data('rmsd.dat')).read())
Esempio n. 7
0
    def test_rmsd_collector(self):
        # Test RMSD collector
        ref = Molecule.create()
        ref.load(data('water.psf'))
        ref.load(data('water.pdb'))
        dset = DataSet()
        dset.add_collector(RMSDCollector('all', Selection('all', ref)))
        dset.add_collector(
            RMSDCollector('all and name OH2',
                          Selection('all and name OH2', ref)))
        dset.add_collector(
            RMSDCollector('all and noh',
                          Selection('all and noh', ref),
                          name='noh'))
        analyzer = Analyzer(self.mol, [data('water.1.dcd')])
        analyzer.add_dataset(dset)
        analyzer.analyze()

        # Write data to check result
        buf = StringIO()
        dset.write(buf)
        # Check the result
        self.assertEqual(buf.getvalue(), open(data('rmsd.dat')).read())
Esempio n. 8
0
 def setUp(self):
     # Prepare molecule
     self.mol = Molecule.create()
     self.mol.load(data('water.psf'))
Esempio n. 9
0
 def setUp(self):
     # Prepare molecule
     self.mol = Molecule.create()
     self.mol.load(data('water.psf'))
Esempio n. 10
0
 def setUp(self):
     self.mol = Molecule.create()
     self.mol.load(data('water.psf'))
     # Storage for callback data
     self.coords = []
     self.frames = []
Esempio n. 11
0
"""Generate a constraints for MDFF simulation."""
import VMD
from pyvmd.molecules import Molecule

PSF = 'initial.psf'
PDB = 'initial.pdb'
MDFF_TEMPLATE_PSF = '../template.psf'
MDFF_TEMPLATE_PDB = '../template.pdb'
MDFF_MAP = 'mdff-map.situs'
MDFF_POTENTIAL = 'mdff-potential.dx'
MDFF_WEIGHTS = 'mdff-weights.pdb'
MDFF_CONSTRAINT_HBONDS = 'mdff-hbonds.dat'
MDFF_CONSTRAINT_CISPEPTIDE = 'mdff-cispeptide.dat'
MDFF_CONSTRAINT_CHIRALITY = 'mdff-chirality.dat'

model = Molecule.create()
model.load(PSF)
model.load(PDB)

template = Molecule.create()
template.load(MDFF_TEMPLATE_PSF)
template.load(MDFF_TEMPLATE_PDB)

# Load mdff
VMD.evaltcl('package require mdff')
# Generate simulated MDFF map
VMD.evaltcl('mdff sim [atomselect {molid} protein] -res 5 -o {outfile}'.format(
    molid=template.molid, outfile=MDFF_MAP))
# Convert map to potential
VMD.evaltcl('mdff griddx -i {infile} -o {outfile}'.format(
    infile=MDFF_MAP, outfile=MDFF_POTENTIAL))
Esempio n. 12
0
"""Build a model of a TRP channel."""
import tempfile

import VMD
from pyvmd import measure
from pyvmd.atoms import Selection
from pyvmd.molecules import Molecule, FORMAT_PDB, FORMAT_PSF

TEMPLATE_PDB = '../structures/3j5p.pdb'
TMP_DIR = tempfile.mkdtemp(prefix='vmd_')
TOPOLOGY = '/usr/lib/vmd/plugins/noarch/tcl/readcharmmtop1.1/top_all27_prot_lipid_na.inp'

# Load template
template = Molecule.create()
template.load(TEMPLATE_PDB)

# Center the template
center = measure.center(Selection('all', template))
Selection('all', template).atomsel.moveby((-center[0], -center[1], -center[2]))
# Rotate the template, so model takes less space
VMD.evaltcl('[atomselect %d all] move [transaxis z -35]' % template.molid)

# Save individual chains
for chain in 'ABCD':
    print "Saving monomer %s" % chain
    Selection('chain {} and resid 393 to 502'.format(chain), template).atomsel.write(FORMAT_PDB, '{}/{}1.pdb'.format(TMP_DIR, chain))
    Selection('chain {} and resid 508 to 719'.format(chain), template).atomsel.write(FORMAT_PDB, '{}/{}2.pdb'.format(TMP_DIR, chain))

# Load psfgen and topology
VMD.evaltcl("package require psfgen")
VMD.evaltcl("topology %s" % TOPOLOGY)
Esempio n. 13
0
"""Generate a constraints for TRP channel simulations."""
from pyvmd.atoms import Selection
from pyvmd.molecules import Molecule, FORMAT_PDB

PSF = 'initial.psf'
PDB = '00_minimize/00_minimize.coor'
# Lipid tail simulation constraint
LIPID_TAILS_PDB = 'tails_only.pdb'
# Protein fixed simulation constraint
PROTEIN_PDB = 'protein.pdb'
# Protein CA constraint
BACKBONE_CA_PDB = 'backbone_ca.pdb'

model = Molecule.create()
model.load(PSF)
model.load(PDB, FORMAT_PDB)
model_sel = Selection('all', model)
model_sel.atomsel.set('beta', 0)

# Lipid constraints
# Fix all and release only the lipid tails
model_sel.atomsel.set('occupancy', 1)
Selection('lipid and not name N "C1[1-5]" "H[1-5]\d" P1 "O."', model).atomsel.set('occupancy', 0)
model_sel.atomsel.write(FORMAT_PDB, LIPID_TAILS_PDB)

# Protein constraints
model_sel.atomsel.set('occupancy', 0)
Selection('protein and noh', model).atomsel.set('occupancy', 1)
model_sel.atomsel.write(FORMAT_PDB, PROTEIN_PDB)

# Protein CA constraints
Esempio n. 14
0
 def setUp(self):
     self.mol = Molecule.create()
     self.mol.load(data('water.psf'))
     # Storage for callback data
     self.coords = []
     self.frames = []
Esempio n. 15
0
from pyvmd.datasets import DataSet
from pyvmd.molecules import Molecule

logging.basicConfig(level=logging.INFO)

PARAM_FILE = '../initial.psf'
PREFIXES = ['simulation_A', 'simulation_B']

COLLECTOR_1 = DistanceCollector('resname A2F and name N52B',
                                'protein and resid 1589 and name CD',
                                name="N52-GLU1589")
COLLECTOR_2 = DistanceCollector('resname A2F and name N49B',
                                'protein and resid 1534 and name CD',
                                name="N49-GLU1534")

MOLECULE = Molecule.create()
MOLECULE.load(PARAM_FILE)

for prefix in PREFIXES:
    trajectory = '../%s/%s.dcd' % (prefix, prefix)

    dset = DataSet()
    dset.add_collector(COLLECTOR_1)
    dset.add_collector(COLLECTOR_2)

    analyzer = Analyzer(MOLECULE, [trajectory])
    analyzer.add_dataset(dset)
    analyzer.analyze()

    dset.write('distances/%s.dat' % prefix)