diff --git a/modules/index.rst b/modules/index.rst index 8cc338a82b9480f516d927e48b3894b80b61e8d0..afc2142cfb81f0b06d9c83755207b29523132d7a 100644 --- a/modules/index.rst +++ b/modules/index.rst @@ -41,7 +41,9 @@ For Starters Molecules -------------------------------------------------------------------------------- -**Overview**: :doc:`molecules intro <intro-01>` | :doc:`mol overview <mol/base/mol>` | :doc:`graphical entity<gfx/entity>` | :doc:`entity <mol/base/entity>` | :doc:`queries <mol/base/query>` +**Overview**: :doc:`molecules intro <intro-01>` | :doc:`mol overview <mol/base/mol>` | :doc:`graphical entity<gfx/entity>` | :doc:`entity <mol/base/entity>` | :doc:`queries <mol/base/query>` | :doc:`algorithms <mol/alg/molalg>` + +**Trajectories**: :doc:`basics <mol/base/traj>` | :ref:`analysis <traj-analysis>` **Input/Output**: :ref:`loading and saving molecules <mol-io>` diff --git a/modules/mol/alg/doc/molalg.rst b/modules/mol/alg/doc/molalg.rst index fa3d676aeb593bb38f76857ef1e31a6cdb49195e..4730eec073af926ec47ef043930e75f1685515fb 100644 --- a/modules/mol/alg/doc/molalg.rst +++ b/modules/mol/alg/doc/molalg.rst @@ -82,6 +82,8 @@ The following function detects steric clashes in atomic structures. Two atoms ar :returns: The filtered :class:`~ost.mol.EntityView` +.. _traj-analysis: + Trajectory Analysis -------------------------------------------------------------------------------- diff --git a/modules/mol/base/doc/entity.rst b/modules/mol/base/doc/entity.rst index 4520df521aa86b3f51c8e61bd59a03864903a76b..1ee9e6bdae35cce7abfe51d84e0315a354bc25da 100644 --- a/modules/mol/base/doc/entity.rst +++ b/modules/mol/base/doc/entity.rst @@ -583,7 +583,18 @@ The Handle Classes .. attribute:: pos - The atom's position in global coordinates. Also available as :meth:`GetPos`. + The atom's position in global coordinates, transformed by the entity + transformation. Also available as :meth:`GetPos`. + + Read-only. + + :type: :class:`~ost.geom.Vec3` + + .. attribute:: original_pos + + The atom's untransformed position in global coordinates. Also available as + :meth:`GetOriginalPos`. + Read-only. :type: :class:`~ost.geom.Vec3` diff --git a/modules/mol/base/doc/mol.rst b/modules/mol/base/doc/mol.rst index 1ac7e3f2691b0a28cd299f7176ffa43e8bb4451b..976c2c8aa1ced240e5c461fb7f46745c60d0b36a 100644 --- a/modules/mol/base/doc/mol.rst +++ b/modules/mol/base/doc/mol.rst @@ -12,4 +12,5 @@ The mol module implements data structures to work with molecular datasets. At it entity editors query - surface \ No newline at end of file + surface + traj \ No newline at end of file diff --git a/modules/mol/base/doc/traj.rst b/modules/mol/base/doc/traj.rst new file mode 100644 index 0000000000000000000000000000000000000000..41730915f3efd9c94fc6fe59598f01f9a4125812 --- /dev/null +++ b/modules/mol/base/doc/traj.rst @@ -0,0 +1,220 @@ +Trajectories +================================================================================ + +.. currentmodule:: ost.mol + + +.. function:: CreateCoordGroup(atoms) + + :param atoms: List of atoms. All atoms must be from the same entity. + :type atoms: :class:`AtomHandleList` + + :rtype: :class:`CoordGroupHandle` + :returns: A coord group with zero frames + +.. class:: CoordGroupHandle + + A collection of coordinate frames, e.g. an MD trajectory. Create with + :func:`CreateCoordGroup`. + + + .. attribute:: entity + + The attached entity. + + :type: :class:`EntityHandle` + + .. attribute:: atoms + + The atoms of this coord group. The order of atoms is the same as the + positions in the coord frames. All atoms are from the same entity. + + :type: :class:`AtomHandleList` + .. method:: AddFrames(frames) + + Combine two trajectories by appending the frames of the second to the first + :param frames: a valid coord group + :type frames: :class:`CoordGroupHandle` + + .. method:: Capture() + + Record the atom positions of the entity attached to this coord group in a + new coordinate frame. Note that the atom positions transformed by the entity + transform will be stored. Only available for mutable coord groups. + + :see: :attr:`AtomHandle.pos` + + .. method:: CaptureInto(frame_index) + + Same as :meth:`Capture`, but doesn't create a new frame and stores the + coordinates directly into frame with index *frame_index*. Only available for + mutable coord groups. + + :param frame_index: index of the frame + :type frame_index: int + + .. method:: CopyFrame(frame_index) + + Copies the coordinates of frame with index *frame_index* to the attached + entity. + + :param frame_index: index of the frame + :type frame_index: int + + .. method:: Filter(view) + + Returns a new trajectory containing only coordinates of the atoms in view. + Useful to remove water and other solvent molecules from a trajectory to + save memory. + + :param view: a valid entity view + :type view: :class:`EntityView` + :rtype: :class:`CoordGroupHandle` + + .. method:: GetAtomCount() + + Returns the number of atoms in the coord group + + :rtype: int + + + .. method:: GetAtomList() + + Returns the atoms of the coord group in the same order they appear in the + coordinate frames. + + :rtype: :class:`AtomHandleList` + + .. method:: GetAtomPos(frame_index, atom) + + Get position of *atom* in frame with index *frame_index*. + + + :param frame_index: frame index + :type frame_index: int + :param atom: A valid atom + :type atom: :class:`AtomHandle` + :rtype: :class:`Vec3` + + .. method:: GetEntity() + + Returns the attached entity + + :rtype: :class:`EntityHandle` + + .. method:: GetFrameCount() + + Returns the number of frames of this coord group + + :rtype: int + + .. method:: IsValid() + + Whether this coord group is valid + + :rtype: bool + + .. method:: SetAtomPos(frame_index, atom, pos) + + Set position of *atom* in frame with index *frame_index* to *pos* + + :param frame_index: index of the frame + :type frame_index: int + :param atom: a valid atom + :type atom: :class:`AtomHandle` + :param pos: new position of the atom + :type pos: :class:`Vec3` + + .. method:: SetFramePositions(frame_index, positions) + + Set the frame positions of frame with index *frame_index*. Order and count + of positions must match :attr:`atoms`. + + :param frame_index: index of frame + :type frame_index: int + :param positions: list of positions + :type positions: :class:`~ost.geom.Vec3List` + + +.. class:: CoordFrame + + A single frame of coordinates in a :class:`CoordGroupHandle`. + + .. method:: GetAngle(atom1, atom2, atom3) + + :param atom1: first atom + :type atom1: :class:`AtomHandle` + :param atom2: second (central) atom + :type atom2: :class:`AtomHandle` + :param atom3: third atom + :type atom3: :class:`AtomHandle` + + :returns: the angle in radians between the 3 atoms + :rtype: float + + .. method:: GetAtomPos(atom) + + Returns the position of the atom in the coord frame + + :param atom: A valid atom handle + :type atom: :class:`AtomHandle` + + + + :rtype: :class:`Vec3` + + .. method:: GetCenterOfMassPos(view) + + + :param view: A valid entity view + :type view: :class:`EntityView` + :rtype: :class:`Vec3` + + .. method:: GetDihedralAngle(atom1, atom2, atom3, atom4) + + Get dihedral angle of the four atoms. + + :param atom1: First atom. Must be valid + :type atom1: :class:`AtomHandle` + :param atom2: Second atom. Must be valid + :type atom2: :class:`AtomHandle` + :param atom3: Third atom. Must be valid + :type atom3: :class:`AtomHandle` + :param atom3: Fourth atom. Must be valid + :type atom3: :class:`AtomHandle` + + :rtype: float + + .. method:: GetDistanceBetwAtoms(atom1, atom2) + + Get distance in (Angstroem) between *atom1* and *atom2* in coord frame. + + :param atom1: First atom. Must be valid + :type atom1: :class:`AtomHandle` + :param atom2: Second atom. Must be valid + :type atom2: :class:`AtomHandle` + :rtype: float + + .. method:: GetDistanceBetwCenterOfMass(view1, view2) + + Get distance between center of mass of the first selection and the second. + + :param view1: First view. Must be valid + :type view1: :class:`EntityView` + :param view2: Second view. Must be valid + :type view2: :class:`EntityView` + :rtype: float + + .. method:: GetRMSD(view1, view2) + + Get RMSD between two views in the coord frame. The coordinates of the views + are taken as is without superposition. The two views must have the same + number of atoms. Atoms are matches as they appear in + :attr:`EntityView.atoms`. + + :param view1: First view. Must be valid + :type view1: :class:`EntityView` + :param view2: Second view. Must be valid + :type view2: :class:`EntityView` + :rtype: float + diff --git a/modules/mol/base/pymod/export_atom.cc b/modules/mol/base/pymod/export_atom.cc index 42e18e0ce5f720e439429536192f10576608c5bd..f232d498cc3f52d61419d0c441c59e530470f737 100644 --- a/modules/mol/base/pymod/export_atom.cc +++ b/modules/mol/base/pymod/export_atom.cc @@ -53,6 +53,9 @@ void export_Atom() .add_property("pos", make_function(&AtomBase::GetPos, return_value_policy<copy_const_reference>())) + .add_property("original_pos", + make_function(&AtomBase::GetOriginalPos, + return_value_policy<copy_const_reference>())) .add_property("name", make_function(&AtomBase::GetName, return_value_policy<copy_const_reference>()), diff --git a/modules/mol/base/pymod/export_coord_group.cc b/modules/mol/base/pymod/export_coord_group.cc index ebd0f1f33daa0fc703d92f4e5351626741b52f61..794db5363c6ae050262e51c29608977ef83d569a 100644 --- a/modules/mol/base/pymod/export_coord_group.cc +++ b/modules/mol/base/pymod/export_coord_group.cc @@ -53,6 +53,7 @@ void export_CoordGroup() .def("GetAtomPos",&CoordGroupHandle::GetAtomPos) .def("CopyFrame",&CoordGroupHandle::CopyFrame) .add_property("atoms", &CoordGroupHandle::GetAtomList) + .add_property("entity", &CoordGroupHandle::GetEntity) .def("IsValid", &CoordGroupHandle::IsValid) .def("Capture", capture1) .def("Capture", capture2)