-
stefan authored
git-svn-id: https://dng.biozentrum.unibas.ch/svn/openstructure/trunk@2373 5a81b35b-ba03-0410-adc8-b2c5c5119f08
stefan authoredgit-svn-id: https://dng.biozentrum.unibas.ch/svn/openstructure/trunk@2373 5a81b35b-ba03-0410-adc8-b2c5c5119f08
:mod:`~ost.io` - Input and Output of Sequences, Structures and Maps
The io module deals with input and output of :class:`entities <ost.mol.EntityHandle>`, :class:`alignments <ost.seq.AlignmentHandle>`, and :class:`images <ost.img.ImageHandle>`. Importers for common file formats such as PDB, SDF, FASTA, CLUSTAL W, DX and CHARMM trajectory files are available.
Molecular Structures
Loading Molecular Structures
The :mod:`~ost.io` modules offers several ways to load molecular structures depending on your requirements. The most general way is offered by :func:`~ost.io.LoadEntity`, which will automatically detect the file format based on the file extension.
Some of the formats have a dedicated function that allows you to tweak many parameters that affect the import. PDB files can be loaded with :func:`~ost.io.LoadPDB`. It offers a tighter control over the exact loading behaviour.
Saving Molecular Structures
Saving a complete entity or a view is a matter of calling :func:`~ost.io.SaveEntity`.
ent=io.LoadEntity('protein.pdb')
# save full entity
io.SaveEntity(ent, 'full.pdb')
# only save C-alpha atoms
io.SaveEntity(ent.Select('aname=CA and peptide=true'), 'calpha.pdb')
:func:`~ost.io.SavePDB` provides a simple way to save several entities into one file:
ent=io.LoadEntity('protein.pdb')
# Save complete entity
io.SavePDB(ent, 'full.pdb')
# Save chain A and chain B separately
io.SavePDB([ent.Select('cname=A'), ent.Select('cname=B')], 'split.pdb')