def __init__(self, ff_type=None, system_file=None, **kwargs): """Two pathways can be used starting from FF-specific files or OpenMM XML system. Additional kwargs are variously used depending on the forcefield / pathway that was chosen. supported ff_type ----------------- amber :: give a prmtop and an inpcrd openmm :: give an XML file for the system supported kwargs ---------------- topology :: system-specific or not depending on FF coordinates :: source of coordinates for initial state """ assert (ff_type is None) or (system_file is None) # This dict will store the API calls # along with atom groups and force # parameters needed to generate all # the given restraints self._restraints = dict() self._topology = None topofile = kwargs.get("topology", None) coordfile = kwargs.get("coordinates", None) if ff_type is not None: if ff_type.lower() == "amber": prmtop = AmberPrmtopFile(topofile) inpcrd = AmberInpcrdFile(coordfile) self.system = prmtop.createSystem( nonbondedMethod=NoCutoff ) #CutoffNonPeriodic - according to Ada, this would be good bc its what amber does - preliminary tests show that this hurts small/medium proteins self._topology = Topology.from_openmm(prmtop.topology) self._positions = inpcrd elif system_file is not None: self.load_xml(system_file) if topofile: if topofile.endswith(".pdb"): # this line is a bit silly but Topology class # doesn't seem to directly load PDB so keeps # the imports clean self._topology = Topology.from_openmm( PDBFile(topofile).topology) else: # Inspect and set ff_type # TODO ff_type as instance attribute pass
def show_conformations(self,centers_indices=None, rotations_indices=None, nodes_labels=None, least_rmsd_fit='receptor', center_rmsd_fit='receptor'): tmp_molcomplex = self.get_conformations(centers_indices, rotations_indices, nodes_labels) tmp_mdtraj_topol = _mdtraj_topology.from_openmm(tmp_molcomplex.topology) tmp_mdtraj_traj = _mdtraj_trajectory(tmp_molcomplex.positions/unit.nanometer,tmp_mdtraj_topol) tmp_view = _nv_show_mdtraj(tmp_mdtraj_traj) del(tmp_molcomplex, tmp_mdtraj_topol, tmp_mdtraj_traj) return tmp_view
def subset(self, selector): """ Returns a list of atom indices corresponding to a MDTraj DSL query. Also will accept list of numbers, which will be coerced to int and returned. """ if isinstance(selector, (list, tuple)): return map(int, selector) selector = SELECTORS.get(selector, selector) mdtop = MDTrajTopology.from_openmm(self.handler.topology) return mdtop.select(selector)
def render_traj(topology, positions): traj = Trajectory(positions / unit.nanometers, Topology.from_openmm(topology)) return (show_mdtraj(traj).add_ball_and_stick('all').center_view(zoom=True))