The code to load and save structures is not directly part of the mol module, but rather lives in a module dedicated to input and output of any kind of data: The
:mod:`~ost.io` module. We will be using functions of this module to load
structures.
One of the most commonly used file formats for macromolecular structures are
PDB (Brookhaven Protein Data Bank) files. The official name for molecules
stored in a PDB file is an *entity* and we decided to follow this convention
in OpenStructure. You will hear this word all the time, but you can replace
the word entity with molecule (or most of the time even protein) in your head.
Loading a PDB file leaves you with an :class:`~ost.mol.EntityHandle`. This is
the central class holding together :class:`chains <ost.mol.ChainHandle>`,
:class:`residues <ost.mol.ResidueHandle>` and
:class:`atoms <ost.mol.AtomHandle>` in a straight-forward hierarchy. This
hierarchy will always be intact: there are no atoms without a residue they
belong to and no residues without chains which have to belong to an entity.
Beside the molecule itself, there are a lot of additional attributes stored in
the entity, like the
:attr:`centre of mass <ost.mol.EntityHandle.center_of_mass>`.
This will load the fragment from the specified file 'fragment.pdb' and store the
result in fragment. The :func:`~ost.io.LoadPDB` has many options, which, for
simplicity will not be discussed here. If you want to know more about the
function, type:
.. code-block:: python
help(io.LoadPDB)
or read the :func:`online documentation <ost.io.LoadPDB>`.
The loaded structure is an instance of :class:`~ost.mol.EntityHandle` which offers a comprehensive interface to inspect an manipulate molecular structures. Now let's inspect what we just loaded:
.. code-block:: python
print len(fragment.chains), fragment.chains
print len(fragment.residues), fragment.residues
print len(fragment.atoms), fragment.atoms
As you can see, our fragment consists of one peptide chain of 12 amino acids and
has 81 atoms in total. Now let's examine our fragment in more detail. Enter the
For visually inspecting the fragment, we now create a graphical representation
of the entity. The graphical representation is completely separate from the :class:`~ost.mol.EntityHandle` class. This is on purpose. When writing processing scripts, usually no graphical representation is required and things would be slowed down without any reason. The following code will take our fragment and initialise a :class:`gfx.Entity<ost.gfx.Entity>`, add it to the scene, and center the camera on it.
.. code-block:: python
go=gfx.Entity("Fragment", fragment)
scene.Add(go)
scene.CenterOn(go)
Now you will see the fragment in the 3D window.
Use the mouse to rotate, zoom in and shift the camera. Double clicking on an
atom will center the camera on that atom. If you want to learn more about the
:mod:`~ost.gfx` module, you are encouraged to read :doc:`the gfx
intro<intro-03>` and the :mod:`gfx documentation<ost.gfx`.
This tutorial is aimed at users that would like to get their hands dirty and
execute commands in Python and write scripts rather clicking their way through a
shiny user interface. The user interface of OpenStructure is in a very early
state anyway that you probably won't go far by clicking your way through...
The tutorial is divided into several parts. The first part of the tutorial is a
walk-through of the basic functionality you will be using in your everyday work, followed by an introduction to the :mod:`~ost.mol`, :mod:`~ost.img` and :mod:`~ost.seq` modules.