B. Molecular Systems

pDynamo is written in Python using an object-oriented approach. The principal pDynamo class that is used to represent molecular systems that are to be simulated is System. A simple program that creates three instances of this class is Example1.py from the pDynamo3 distribution:

# . Create a water molecule.

water = System.FromAtoms ( [ 8, 1, 1 ] )

water.label = "Water"

water.Summary ( )

# . Create a water dimer.

waterDimer = MergeByAtom ( water, water )

waterDimer.label = "Water Dimer"

waterDimer.Summary ( )

# . Create a hydroxyl.

oh = Selection.FromIterable ( [ 0, 1 ] )

hydroxyl = PruneByAtom ( water, oh )

hydroxyl.label = "Hydroxyl"

hydroxyl.Summary ( )

The program first creates a water molecule by instantiating the System class directly with, as argument, a list containing the atomic numbers of the molecule's atoms. Two other instances of System are then created indirectly. The first is a water dimer which is generated by merging two waters, and the second is a hydroxyl group which is created by taking water and then pruning one of its hydrogens.

It is unusual to instantiate systems directly using System, except in the simplest cases. Instead it is normal to read their definitions from external files or employ special chemical notations. A program that generates a list of instances of the pDynamo logo (!) – the blocked alanine molecule (bALA) – using different molecular representations is Example2.py:

# . Define the molecule.

moleculeName = "bala_c7eq"

smiles = "CC(=O)NC(C)C(=O)NC"

# . Read the molecule from three different files.

molecules = [ ImportSystem ( os.path.join ( dataPath, tag, moleculeName + "." + tag ) ) for tag in ( "mol", "pdb", "xyz" ) ]

# . Generate the molecule from a SMILES string.

molecules.append ( SMILESReader.StringToSystem ( smiles ) )

# . Print summaries of the molecules.

for molecule in molecules:

molecule.Summary ( )

The program employs the four representations, MOL, PDB, SMILES and XYZ. SMILES is a string representation that specifies the system's composition and covalent bond arrangement, whereas the other three are file-based and contain a list of the system's atoms and a copy of their Cartesian coordinates. Links to sites describing some of these representations may be found on the useful links page.

The list of molecule instances, molecules, is created with the file-based representations, MOL, PDB and XYZ, using Python's list comprehension syntax and pDynamo's ImportSystem function, which will automatically recognize the correct file format if standard file extensions are used – in this case, "mol", "pdb" and "xyz". The list is terminated by appending the molecule instance for the string-based representation, SMILES, which, by constrast, must employ the StringToSystem method from the SMILESReader class.


    1. Interconvert different representations of a molecular system using the functions ImportSystem and ExportSystem or, for SMILES, the StringToSystem and StringFromSystem methods of the SMILESReader and SMILESWriter classes, respectively. What happens to the information defined in a particular representation – is it conserved or destroyed?