Image structure Image document-save


Writing structures to a PDB file.


structure.write_pdb(file=None, dir=None, model_num=None, compress_type=0, force=False)

Keyword arguments

file: The name of the PDB file.

dir: The directory where the file is located.

model_num: Restrict the writing of structural data to a single model in the PDB file.

compress_type: The type of compression to use when creating the file.

force: A flag which if set to True will cause any pre-existing files to be overwritten.


This will write all of the structural data loaded in the current data pipe to be converted to the PDB format and written to file. Specifying the model number allows single models to be output.

The default behaviour of this function is to not compress the file. The compression can, however, be changed to either bzip2 or gzip compression. If the `.bz2' or `.gz' extension is not included in the file name, it will be added. This behaviour is controlled by the compression type which can be set to

0 -
No compression (no file extension).
1 -
bzip2 compression (`.bz2' file extension).
2 -
gzip compression (`.gz' file extension).

Prompt examples

To write all models and molecules to the PDB file `ensemble.pdb' within the directory `˜/pdb', type one of:

relax> structure.write_pdb('ensemble.pdb', '~/pdb')

relax> structure.write_pdb(file='ensemble.pdb', dir='pdb')

To write model number 3 into the new file `test.pdb', use one of:

relax> structure.write_pdb('test.pdb', model_num=3)

relax> structure.write_pdb(file='test.pdb', model_num=3)

The relax user manual (PDF), created 2016-10-28.