PDB Writer

class PdbWriter[source]

Bases: object

A writer class for .pdb files.

Examples

Writing to a File with a Unit Cell

This writer can write to a file with the unit cell included for periodic molecules. Note that this always assumes P1 space group.

import stk

bb1 = stk.BuildingBlock('BrCCBr', [stk.BromoFactory()])
bb2 = stk.BuildingBlock('BrCC(CBr)CBr', [stk.BromoFactory()])
topology_graph = stk.cof.PeriodicHoneycomb(
    building_blocks=(bb1, bb2),
    lattice_size=(3, 3, 1),
)
construction_result = topology_graph.construct()
cof = stk.ConstructedMolecule.init_from_construction_result(
    construction_result=construction_result,
)
writer = stk.PdbWriter()
writer.write(
    molecule=cof,
    path='cof.pdb',
    periodic_info=construction_result.get_periodic_info(),
)

Methods

to_string(molecule[, atom_ids, periodic_info])

Get a .pdb file format string of molecule.

write(molecule, path[, atom_ids, periodic_info])

Write molecule to .pdb file format.

to_string(molecule, atom_ids=None, periodic_info=None)[source]

Get a .pdb file format string of molecule.

Parameters
  • molecule (Molecule) – Molecule to write to .pdb format.

  • atom_ids (iterable of int) – The atom ids of atoms to write. Can be a single int, if a single atom is to be used, or None, if all atoms are to be used.

  • periodic_info (PeriodicInfo) – Information about the periodic cell.

Returns

A string holding the content of a .pdf file.

Return type

string

write(molecule, path, atom_ids=None, periodic_info=None)[source]

Write molecule to .pdb file format.

Parameters
  • molecule (Molecule) – Molecule to write to .pdb format.

  • path (str) – The full path to the file being written.

  • atom_ids (iterable of int) – The atom ids of atoms to write. Can be a single int, if a single atom is to be used, or None, if all atoms are to be used.

  • periodic_info (PeriodicInfo) – Information about the periodic cell.

Returns

None – A file is written.

Return type

NoneType