File: io.rst

package info (click to toggle)
openstructure 2.11.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 206,256 kB
  • sloc: cpp: 188,571; python: 36,686; ansic: 34,298; fortran: 3,275; sh: 312; xml: 146; makefile: 29
file content (713 lines) | stat: -rw-r--r-- 23,918 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
:mod:`~ost.io` - Input and Output of Sequences, Structures and Maps
================================================================================

.. module:: ost.io
  :synopsis: Input and output of sequences, alignments, structures, images and density maps.

.. toctree::
  :hidden:
  
  structure_formats
  sequence_formats
  sequence_profile_formats
  image_formats
  mmcif
  profile

The io module deals with the input and output of :class:`entities
<ost.mol.EntityHandle>`, :class:`alignments <ost.seq.AlignmentHandle>`, 
:class:`sequences <ost.seq.SequenceHandle>`, :class:`images 
<ost.img.ImageHandle>`. Importers for common file formats containing molecules 
such as PDB, SDF and CHARMM trajectory files are available. Sequence and 
alignment file formats such as FASTA and CLUSTALW are supported as well as  
various image data (e.g. png, dm3) and density map files (e.g. CCP4, MRC). 

.. _mol-io:

Molecular Structures
--------------------------------------------------------------------------------

Loading Molecular Structures
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The :mod:`~ost.io` modules offer 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.

.. function:: LoadEntity(filename, format='auto')

  Load entity from disk. If format is set to 'auto', the function guesses the 
  filetype based on the extension of the file e.g. files ending in '.pdb', '.ent', 
  '.ent.gz' and '.pdb.gz' will automatically be loaded as PDB files. For files 
  without or exotic extensions, the format can be set explicitly as the second 
  parameter. 
  
  .. code-block:: python

    # Recognizes SDF file by file extension
    ent = io.LoadEntity('file.sdf')

    # In this case, there is no file extensions, so you have to say it's a 
    # SDF file explicitly
    ent = io.LoadEntity('file', 'sdf')

  For a list of file formats supported by :func:`LoadEntity`, see :doc:`structure_formats`.
  
  :raises: :exc:`~ost.io.IOUnknownFormatException` if the format string supplied 
      is not recognized or the file format can not be detected based on the 
      file extension.
      
      :exc:`~ost.io.IOException` if the import fails due to an erroneous or 
      inexistent file.

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:`LoadPDB`
and mmCIF files with :func:`LoadMMCIF` (this also gives you access to the
:class:`MMCifInfo` class). It offers tighter control over the exact loading
behaviour.

.. autofunction:: ost.io.LoadPDB

.. autofunction:: ost.io.LoadMMCIF

.. function:: PDBStrToEntity(pdb_string, profile=IOProfile(), process=False)

  Load entity from a string in PDB format. By default the entity is loaded with
  an empty IO Profile and is not processed with the :class:`~ost.conop.Processor`,
  even if one is available in the IO Profile.

  :param pdb_string: A PDB file as a string.
  :type pdb_str: :class:`str`

  :param profile: The IO Profile to read the entity with. For more information
      on the IO Profiles available, see :doc:`profile`.
  :type profile: :class:`ost.io.IOProfile`

  :param process: If set to True, run the :class:`~ost.conop.Processor`
      contained in the IO Profile.
  :type process: :class:`bool`

  :rtype: :class:`~ost.mol.EntityHandle`.

  To get an entity equivalent to one loaded with :func:`LoadPDB`, set the
  `profile` and `process` arguments as follows:

  .. code-block:: python

    with open('protein.pdb') as pdb_fh:
        pdb_str = pdb_fh.read()
        ent = io.PDBStrToEntity(pdb_str, ost.io.profiles['DEFAULT'], True)


.. function:: MMCifStrToEntity(mmcif_str, profile=IOProfile(), process=False)

  Load entity from a string in mmCIF format. By default the entity is loaded with
  an empty IO Profile and is not processed with the :class:`~ost.conop.Processor`,
  even if one is available in the IO Profile.

  :param mmcif_str: mmCIF file as a string
  :type mmcif_str: :class:`str`

  :param profile: The IO Profile to read the entity with. For more information
      on the IO Profiles available, see :doc:`profile`.
  :type profile: :class:`ost.io.IOProfile`

  :param process: If set to True, run the :class:`~ost.conop.Processor`
      contained in the IO Profile.
  :type process: :class:`bool`

  :rtype: :class:`~ost.mol.EntityHandle`.

.. autofunction:: ost.io.LoadSDF

.. function:: SDFStrToEntity(sdf_string, profile=IOProfile())

  Load entity from a string in SDF format.

  :param pdb_string: A SDF file as a string.

  :param profile: The IO Profile to read the entity with. For more information
      on the IO Profiles available, see :doc:`profile`.
  :type profile: :class:`ost.io.IOProfile`

  :rtype: :class:`~ost.mol.EntityHandle`.

.. class:: ost.io.OMF

  Experimental data format capable of storing minimally required information 
  of a :class:`ost.mol.EntityHandle` in a compressed manner 
  (OMF - OpenStructure Minimal Format). Shares lots of ideas with the mmtf or
  binaryCIF formats but comes with no dependencies attached. User can provide
  an upper error bound of atom coordinates in A which has an effect on
  compression ratio. 

  .. staticmethod:: FromEntity(ent, max_error = 0.0, options=0)

    Generates :class:`ost.io.OMF` object starting from an 
    :class:`ost.mol.EntityHandle`.

    :param ent: Structure data
    :type ent: :class:`ost.mol.EntityHandle`
    :param max_error: Maximum error in A of stored atom coordinates - affects
                      compression ratio
    :type max_error: :class:`float`
    :param options: Control file compression
    :type options: :class:`ost.io.OMFOption`
    :returns: The created :class:`ost.io.OMF` object

  .. staticmethod:: FromFile(filepath)

    Generates :class:`ost.io.OMF` object from a file stored with 
    :func:`ToFile` or a byte string created from :func:`ToBytes`
    that has been dumped to disk.

    :param filepath: The file
    :type filepath: :class:`str`
    :returns: The created :class:`ost.io.OMF` object    

  .. staticmethod:: FromBytes(bytes_string)

    Generates :class:`ost.io.OMF` object from a :class:`bytes` object created
    with :func:`ToBytes`.

    :param bytes_string: The super heavily compressed OMF structure
    :type bytes_string: :class:`bytes`

  .. method:: ToFile(filepath)

    Stores object to file
    
    :param filepath: The file 
    :type filepath: :class:`str`

  .. method:: ToBytes()

    Stores object to :class:`bytes` string
    
    :returns: The :class:`bytes` string

  .. method:: GetMaxError()

    Get maximum error parameter

    :returns: The max error in A of the stored coordinates

  .. method:: GetAU()

    Getter for assymetric unit

    :returns: The assymetric unit as :class:`ost.mol.EntityHandle`

  .. method:: GetEntity()

    Same as :func:`GetAU`

  .. method:: GetAUChain(chain_name)

    Getter for single chain in the assymetric unit

    :param chain_name: The name of the chain you want
    :type chain_name: :class:`str`
    :returns: :class:`ost.mol.EntityHandle` of the AU only containing the 
              specified chain

  .. method:: GetEntityChain(chain_name)

    Same as :func:`GetAUChain`

  .. method:: GetName()

    :returns: The entity name, accessible as
              :class:`ost.mol.EntityHandle.GetName` from the entity that has
              been used to create :class:`OMF` object

  .. method:: GetChainNames()

    :returns: :class:`list` with chain names of the stored structure


.. class:: ost.io.OMFOption

  OMF options control file compression. They can be combined with bitwise or:

  .. code-block:: python

    omf_opts = io.OMFOption.DEFAULT_PEPLIB | io.OMFOption.AVG_BFACTORS

  * DEFAULT_PEPLIB: Compound information (connectivity, chem type etc.) for each
    unique residue in a structure is stored in a library. This option defines a
    default library of such compounds with proteinogenic amino acids. This
    reduces the size of the library that needs to be written for each OMF file.
    IMPORTANT: This option has an impact on compression ratio as internal
    coordinate parameters are only available through the default peptide library
  * AVG_BFACTORS: Protein models often have the same bfactor for all atoms of
    a residue. One example is AFDB. Enabling this option results in only one
    bfactor being stored per residue, thus reducing file size.
  * ROUND_BFACTORS: Round bfactor to integer. This gives sufficient accuracy
    for bfactors in AFDB that are in range [0.0, 100.0].
  * SKIP_SS: Dont save secondary structure to save some memory
  * INFER_PEP_BONDS: Connectivity of compounds is stored in an internal library.
    However, inter-residue connectivity needs to be stored separately. If this
    option is enabled, stereochemically reasonable peptide bonds are inferred
    at loading and there is no need to save them.


Loading Molecular Structures From Remote Repositories
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

:func:`LoadPDB` already provides access to selected structural databases in 
the internet when enabling the *remote* flag. Predefined 
:class:`ost.io.remote.RemoteRepository` objects are available as

.. code-block:: python

  from ost.io import remote
  repo_name = 'smtl'
  repo = remote.REMOTE_REPOSITORIES.get(repo_name)

  # url for entry with id 1ake.1
  print(repo.URLForID('1ake.1'))

where *repo_name* can be one of ['pdb', 'cif', 'pdb_redo', 'smtl'].
Instead of explicit access, you can directly fetch data using:

.. autofunction:: ost.io.remote.RemoteGet
 
.. autofunction:: ost.io.remote.RemoteLoad

.. autoclass:: ost.io.remote.RemoteRepository
  :members:

Saving Molecular Structures
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Saving a complete entity or a view is a matter of calling 
:func:`~ost.io.SaveEntity`.

.. code-block:: python
  
  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:


.. code-block:: python
  
  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')


.. function:: SaveEntity(ent, filename, format='auto')
  
  Save entity to disk. If format is set to 'auto', the function guesses the 
  filetype based on the file extension, otherwise the supplied format is checked 
  against the available export plugins.
  
  :param ent: The entity to be saved
  :type  ent: :class:`~ost.mol.EntityHandle` or :class:`~ost.mol.EntityView`
  :param filename: The filename
  :type  filename: string
  :param format: Name of the format
  :type  format: string
  
  :raises: :exc:`~ost.io.IOUnknownFormatException` if the format string supplied 
      is not recognized or the file format can not be detected based on the 
      file extension.
      
.. autofunction:: ost.io.SavePDB

.. autofunction:: ost.io.SaveMMCIF

.. function:: EntityToPDBStr(ent, profile=IOProfile())

  Return entity as a string in PDB format. 

  :param entity: The :class:`~ost.mol.EntityHandle` or :class:`~ost.mol.EntityView`

  :param profile: The IO Profile to read the entity with. For more information
      on the IO Profiles available, see :doc:`profile`.
  :raises: IOException if the restrictions of the PDB format are not satisfied
           (see :meth:`ost.io.SavePDB`)

  :rtype: string.

.. function:: EntityToSDFStr(ent)

  Return entity as a string in SDF format.

  :param entity: The :class:`~ost.mol.EntityHandle` or :class:`~ost.mol.EntityView`

  :rtype: string.

.. function:: SaveSDF(ent, filename)

  Save entity to disk as an SDF file.

  :param ent: The entity to be saved
  :type  ent: :class:`~ost.mol.EntityHandle` or :class:`~ost.mol.EntityView`
  :param filename: The filename
  :type  filename: string

.. _seq-io:

Sequences and Alignments
--------------------------------------------------------------------------------

Loading sequence or alignment files
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. function:: LoadSequence(filename, format='auto')

  Load sequence data from disk. If format is set to 'auto', the function guesses 
  the filetype based on the extension of the file. Files ending in '.fasta', 
  '.aln' will automatically be loaded.

  :param filename: The filename
  :type  filename: string
  :param format: Name of the format
  :type  format: string
  :rtype: :class:`~ost.seq.SequenceHandle`
  
  For files with non-standard extensions, the format can be set explicitly 
  specifying the `format` parameter. 
  
  .. code-block:: python

    # recognizes FASTA file by file extension
    myseq = io.LoadSequence('seq.fasta')
    # for obtaining a SequenceList
    seqlist = io.LoadSequenceList('seqs.fasta')
    # or for multiple alignments (here from CLUSTAL)
    aln = io.LoadAlignment('algnm.aln', format="clustal")
    
  For a list of file formats supported by :func:`LoadSequence` see
  :doc:`sequence_formats`.
  
  :raises: :exc:`~ost.io.IOUnknownFormatException` if the format string supplied 
      is not recognized or the file format can not be detected based on the 
      file extension.
      
      :exc:`~ost.io.IOException` if the import fails due to an erroneous or 
      inexistent file.

.. function:: LoadSequenceList(filename, format='auto')

  For a description of how to use :func:`LoadSequenceList` please refer to 
  :func:`LoadSequence`. For a list of file formats supported by
  :func:`LoadSequenceList` see :doc:`sequence_formats`.

  :param filename: The filename
  :type  filename: string
  :param format: Name of the format
  :type  format: string
  :rtype: :class:`~ost.seq.SequenceList`

.. function:: LoadAlignment(filename, format='auto')

  For a description of how to use :func:`LoadAlignment` please refer to 
  :func:`LoadSequence`. For a list of file formats supported by 
  :func:`LoadAlignment` see :doc:`sequence_formats`.

  :param filename: The filename
  :type  filename: string
  :param format: Name of the format
  :type  format: string
  :rtype: :class:`~ost.seq.AlignmentHandle`

.. function:: LoadSequenceProfile(filename, format='auto')

  Load sequence profile data from disk. If format is set to 'auto', the function
  guesses the filetype based on the extension of the file. Files ending in
  '.hhm' (output of HHblits) and '.pssm' (ASCII Table (PSSM) output of PSI-BLAST
  as generated with blastpgp and flag -Q) will automatically be loaded.
  
  For files with non-standard extensions, the format can be set explicitly 
  specifying the `format` parameter. 
  
  .. code-block:: python

    # recognizes hhm file by file extension
    myprof = io.LoadSequenceProfile('myhmm.hhm')
    # recognizes pssm file by file extension
    myprof = io.LoadSequenceProfile('myprof.pssm')

    # to override format
    myprof = io.LoadSequenceProfile('myfile', format='hhm')
    myprof = io.LoadSequenceProfile('myfile', format='pssm')
    
  For a list of file formats supported by :func:`LoadSequenceProfile` see
  :doc:`sequence_profile_formats`.

  :param filename: The filename
  :type  filename: string
  :param format: Name of the format
  :type  format: string
  
  :rtype: :class:`~ost.seq.ProfileHandle`

  :raises: :exc:`~ost.io.IOUnknownFormatException` if the format string supplied 
      is not recognized or the file format can not be detected based on the 
      file extension.
      
      :exc:`~ost.io.IOException` if the import fails due to an erroneous or 
      inexistent file.

.. function:: AlignmentFromString(data, format)

  Load alignment from string.

  The format argument is mandatory. For a list of supported formats,
  see :doc:`sequence_formats`.

  :param data: The alignment
  :type  data: string
  :param format: Name of the format
  :type  format: string
  :rtype: :class:`~ost.seq.AlignmentHandle`

.. function:: SequenceFromString(data, format)

  Load sequence from string.

  The format argument is mandatory. For a list of supported formats,
  see :doc:`sequence_formats`.

  :param data: The sequence
  :type  data: string
  :param format: Name of the format
  :type  format: string
  :rtype: :class:`~ost.seq.SequenceHandle`

.. function:: SequenceListFromString(data, format)

  Load a list of sequences from string.

  The format argument is mandatory. For a list of supported formats,
  see :doc:`sequence_formats`.

  :param data: The list of sequences
  :type  data: string
  :param format: Name of the format
  :type  format: string
  :rtype: :class:`~ost.seq.SequenceList`

.. function:: SequenceProfileFromString(data, format)

  Load sequence profile from string.

  The format argument is mandatory.

  :param data: String containing the data you would read from a file with
               specified format.
  :type  data: string
  :param format: Name of the format. Can either be "hhm" or "pssm".
  :type  format: string
  :rtype: :class:`~ost.seq.ProfileHandle`

Saving Sequence Data
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. function:: SaveSequence(sequence, filename, format='auto')

  Saving sequence data is performed by calling :func:`SaveSequence`.
  For files with non-standard extensions, the format can be set explicitly 
  specifying the 'format' parameter. 
  
  .. code-block:: python

    # recognizes FASTA file by file extension
    io.SaveSequence(myseq, 'seq.fasta')
    # for saving a SequenceList
    io.SaveSequenceList(seqlist, 'seqlist.fasta')
    # or for multiple alignments (here in FASTA format)
    io.SaveAlignment(aln, 'aln.fasta')
    
  For a list of file formats supported by :func:`SaveSequence` see
  :doc:`sequence_formats`.

  :param sequence: The sequence
  :type  sequence: :class:`~ost.seq.SequenceHandle`
  :param filename: The filename
  :type  filename: string
  :param format: Name of the format
  :type  format: string

  :raises: :exc:`~ost.io.IOUnknownFormatException` if the format string supplied 
      is not recognized or the file format can not be detected based on the 
      file extension.
      
      :exc:`~ost.io.IOException` if the import fails due to an erroneous or 
      inexistent file.

.. function:: SaveSequenceList(seq_list, filename, format='auto')

  For a desription of how to use :func:`SaveSequenceList` please refer to 
  :func:`SaveSequence`. For a list of file formats supported by 
  :func:`SaveSequenceList` see :doc:`sequence_formats`.

  :param seq_list: The sequence list
  :type  seq_list: :class:`~ost.seq.SequenceList`
  :param filename: The filename
  :type  filename: string
  :param format: Name of the format
  :type  format: string

.. function:: SaveAlignment(aln, filename, format='auto')

  For a desription of how to use :func:`SaveAlignment` please refer to 
  :func:`SaveSequence`.
  
  For a list of file formats supported by :func:`SaveAlignment` see 
  :doc:`sequence_formats`.

  :param aln: The alignment
  :type  aln: :class:`~ost.seq.AlignmentHandle`
  :param filename: The filename
  :type  filename: string
  :param format: Name of the format
  :type  format: string

.. function:: AlignmentToString(ali, format)

  Return alignment as a string.

  The format argument is mandatory. For a list of supported formats
  see :doc:`sequence_formats`.

  :param ali: The alignment
  :type  ali: :class:`~ost.seq.AlignmentHandle`
  :param format: Name of the format
  :type  format: string
  :rtype: string

.. function:: SequenceToString(seq, format)

  Return sequence as a string.

  The format argument is mandatory. For a list of supported formats
  see :doc:`sequence_formats`.

  :param seq: The sequence
  :type  seq: :class:`~ost.seq.SequenceHandle`
  :param format: Name of the format
  :type  format: string
  :rtype: string

.. function:: SequenceListToString(seq_list, format)

  Return sequence list as a string.

  The format argument is mandatory. For a list of supported formats
  see :doc:`sequence_formats`.

  :param seq_list: The sequence list
  :type  seq: :class:`~ost.seq.SequenceList`
  :param format: Name of the format
  :type  format: string
  :rtype: string

.. _img-io: 

Density Maps
--------------------------------------------------------------------------------

Loading Density Maps
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. function:: LoadImage(filename)
              LoadImage(filename, format)

  Load density map from disk. If no format is given, the function guesses the 
  filetype based on the extension of the file. If the extension is unknown or not present the
  filetype will be guessed based on the content of the file if possible.
  
  :param filename: The filename
  :type  filename: string
  :param format: The file format

  :raises: :exc:`~ost.io.IOUnknownFormatException` if the format supplied 
      is not recognized or the file format can not be detected based on the 
      file extension and content.
      
      :exc:`~ost.io.IOException` if the import fails due to an erroneous or 
      inexistent file.

  .. code-block:: python

    # recognizes mrc file by file extension
    ent = io.LoadImage('file.mrc')

    # it is always possible to explicitly set the image format
    # DAT file explicitly
    ent = io.LoadImage('file', Dat())

  For a list of file formats supported by :func:`LoadImage`, see :doc:`image_formats`.
  



Saving Density Maps
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. function:: SaveImage(image, filename)
              SaveImage(image, filename, format)

  Save density map to disk. If no format is set, the function guesses the 
  filetype based on the file extension.
  
  :param image: The density map to be saved
  :type  image: :class:`~ost.img.IMageHandle`
  :param filename: The filename
  :type  filename: string
  :param format: The file format
  
  :raises: :exc:`~ost.io.IOUnknownFormatException` if the file format can not be detected based on the 
      file extension

  For a list of file formats supported by :func:`SaveImage`, see :doc:`image_formats`.
  
  .. code-block:: python

    # load density map
    image = io.LoadImage('density_map.ccp4')
    # save density map
    io.SaveImage(image, 'new_map.map', CCP4())


Stereochemical Parameters
--------------------------------------------------------------------------------

In order to check the structure for some stereo-chemical and steric clashes
before computing the lDDT scores it is required to pass parameter file based on
Engh and Huber parameters, and on the atomic radii as defined in the Cambridge
Structural Database. OpenStructure ships with default file called
`stereo_chemical_props.txt` located in `$OST_ROOT/share/openstructure`
directory. A function :func:`~ost.io.ReadStereoChemicalPropsFile` is used to
read this file.



.. function:: ReadStereoChemicalPropsFile(filename="", check=True)

  Read stereochemical parameters - if not provided a local version will be used.

  :param filename: The path to the parameter file that will be used. If set
                   to "", it reads the default file shipped with OpenStructure.
  :type filename: :class:`str`
  :param check: Raise an error when any of the resulting tables are empty.
  :type check:  :class:`bool`
  :return: Object containing stereochemical parameters
  :rtype: :class:`~ost.mol.alg.StereoChemicalProps`

.. function:: GetStereoChemicalPropsFile()

  Get the default path to the stereochemical paramteres file.