ExamplesΒΆ

Here, we highlight some useful simple examples for pywindow. These are copied from the examples path in the github repository.

We can load molecules in multiple ways:

import pywindow as pw

# From xyz, or pdb file:
molsys = pw.MolecularSystem.load_file(path / "PUDXES.xyz")

# From an rdkit molecule:
# rdkit_mol = Chem.MolFromMol2File(input_file)
# molsys = pw.MolecularSystem.load_rdkit_mol(rdkit_mol)

# Then convert to molecule.
mol = molsys.system_to_molecule()

There are specific methods available for analysis only some aspects of a molecule, but you can also just run the full analysis:

# Separate:
# mol.calculate_centre_of_mass()
# mol.calculate_maximum_diameter()
# mol.calculate_average_diameter()
# mol.calculate_pore_diameter()
# mol.calculate_pore_volume()
# mol.calculate_pore_diameter_opt()
# mol.calculate_pore_volume_opt()
# mol.calculate_windows()

# All together:
mol.full_analysis()

Warning

The full analysis may fail on certain steps, so if you only need specific things, do that.

We can output to .json for the data, and .pdb for the structure, with added information about pore and window (We can now visualise the molecule, its centre of pore and its window centroids):

mol.dump_properties_json(
    filepath=str(path / "PUDXES_out.json"),
    override=True,
)

mol.dump_molecule(
    filepath=str(path / "PUDXES_out.pdb"),
    include_coms=True,
    override=True,
)