def __init__(self, file): MoleculeFactory.__init__(self) for event, element in iterparse(file): tag = element.tag ob_id = element.attrib.get('id', None) if tag == 'molecule' and ob_id is not None: self.makeGroup(element) element.clear() elif tag == 'templates': element.clear() elif tag == 'universe': self.makeUniverse(element)
def __init__(self, pdb_conf, residue_filter=None, atom_filter=None): """ @param pdb_conf: a PDBConfiguration @type pdb_conf: L{MMTK.PDB.PDBConfiguration} @param residue_filter: a function taking a residue object (as defined in Scientific.IO.PDB) and returning True if that residue is to be kept in the molecule factory @type residue_filter: callable @param atom_filter: a function taking a residue object and an atom object (as defined in Scientific.IO.PDB) and returning True if that atom is to be kept in the molecule factory @type atom_filter: callable """ MoleculeFactory.__init__(self) if residue_filter is None and atom_filter is None: self.pdb_conf = pdb_conf else: self.pdb_conf = copy.deepcopy(pdb_conf) for residue in self.pdb_conf.residues: delete = [] for atom in residue: if atom_filter is not None \ and not atom_filter(residue, atom): delete.append(atom) for atom in delete: residue.deleteAtom(atom) delete = [] for residue in self.pdb_conf.residues: if len(residue) == 0 or \ (residue_filter is not None and not residue_filter(residue)): delete.append(residue) for residue in delete: self.pdb_conf.deleteResidue(residue) self.peptide_chains = [] self.nucleotide_chains = [] self.molecules = {} self.makeAll()
def __init__(self, pdb_conf, residue_filter=None, atom_filter=None): """ :param pdb_conf: a PDBConfiguration :type pdb_conf: :class:`~MMTK.PDB.PDBConfiguration` :param residue_filter: a function taking a residue object (as defined in Scientific.IO.PDB) and returning True if that residue is to be kept in the molecule factory :type residue_filter: callable :param atom_filter: a function taking a residue object and an atom object (as defined in Scientific.IO.PDB) and returning True if that atom is to be kept in the molecule factory :type atom_filter: callable """ MoleculeFactory.__init__(self) if residue_filter is None and atom_filter is None: self.pdb_conf = pdb_conf else: self.pdb_conf = copy.deepcopy(pdb_conf) if atom_filter is not None: for residue in self.pdb_conf.residues: delete = [atom for atom in residue if not atom_filter(residue, atom)] for atom in delete: residue.deleteAtom(atom) if residue_filter is not None: delete = [residue for residue in self.pdb_conf.residues if len(residue) == 0 or not residue_filter(residue)] for residue in delete: self.pdb_conf.deleteResidue(residue) self.peptide_chains = [] self.nucleotide_chains = [] self.molecules = {} self.makeAll()
def __init__(self, mol_system): MoleculeFactory.__init__(self) self.mol_system = mol_system self.group_name_mapping = {} self.peptide_chains = {} self.makeAllGroups()
import unittest from subsets import SubsetTest from MMTK import * from MMTK.MoleculeFactory import MoleculeFactory from MMTK.ForceFields import Amber99ForceField, LennardJonesForceField from MMTK_forcefield import NonbondedList from MMTK.Random import randomPointInBox from MMTK.Geometry import SCLattice from MMTK.Utility import pairs from Scientific.Geometry import ex, ey, ez from Scientific import N from cStringIO import StringIO import itertools factory = MoleculeFactory() factory.createGroup('dihedral_test') factory.addAtom('dihedral_test', 'C1', 'C') factory.addAtom('dihedral_test', 'C2', 'C') factory.addAtom('dihedral_test', 'C3', 'C') factory.addAtom('dihedral_test', 'C4', 'C') factory.addBond('dihedral_test', 'C1', 'C2') factory.addBond('dihedral_test', 'C2', 'C3') factory.addBond('dihedral_test', 'C3', 'C4') factory.setAttribute('dihedral_test', 'C1.amber_atom_type', 'D1') factory.setAttribute('dihedral_test', 'C2.amber_atom_type', 'D2') factory.setAttribute('dihedral_test', 'C3.amber_atom_type', 'D3') factory.setAttribute('dihedral_test', 'C4.amber_atom_type', 'D4')
# Create molecules from scratch # # This example shows how a molecular system (SPCE water) can be set up using # molecule factories instead of the molecular database. # from MMTK import * from MMTK.MoleculeFactory import MoleculeFactory from MMTK.ForceFields import SPCEForceField # Create a new molecule factory. factory = MoleculeFactory() # Create the empty molecule. There is no distinction between groups # and molecules at this level. Everything is a building block. factory.createGroup('water') # Add the atoms. factory.addAtom('water', 'O', 'O') factory.addAtom('water', 'H1', 'H') factory.addAtom('water', 'H2', 'H') # Add the bonds. factory.addBond('water', 'O', 'H1') factory.addBond('water', 'O', 'H2') # Define the atom positions factory.setPosition('water', 'O', Vector(0., 0., 0.00655616814675)) factory.setPosition('water', 'H1', Vector(-0.0756950327264, 0., -0.0520320595151)) factory.setPosition('water', 'H2',