Various Odds & Ends

This tutorial part collects a variety of short explanation of different operations using TopoTools.

Reconstruct a .pdb/.psf files from a LAMMPS data file for use with visualization programs

In most visualization programs specific colors are associated with specific elements. However in a LAMMPS data file that atoms are only identified by their type and thus the embedded data file reader in the topotools package imports those as atom names (unless a very special extended data file syntax is used). The TopoTools plugin has some utilities to help with this process and other VMD script commands can be used to help as well. However, it is important to note that this process can it automated form only recover information that is present in the data. Since the generation of a data file usually means that unneeded information is lost, further reconstruction requires additional knowledge about the system in the data file. The first example discusses the reconstruction of a .psf/.pdb file for a bulk HDPE data file, data.hdpe-x5 using the script reconstructhdpe.tcl.The process starts with reading in the data file (note: the atom style has to be known):

topo readlammpsdata data.hdpe-x5 full

With this information loaded, we would get a visualization like in the left side of the image. Now we can try to guess the element names from the atomic masses and use those to set other properties like atom name or radius. Of course, this step only works, if the masses are actually given in the data file:

topo guessatom element mass

topo guessatom name element

topo guessatom radius element

Based on the element name and further knowledge about the system, we can set a few more properties, that help with analysis or visualization:

set selc [atomselect top {name C}]

$selc set type CT

$selc set resname HDPE

# set residue ID to a 1-based index.

set resid {}

foreach r [$selc get residue] { incr r; lappend resid $r }

$selc set resid $resid

The similar process is performed for all hydrogens. We can then add further cleanups, e.g. retyping of bonds or angles. One very special operation would be the clearing of all defined improper dihedrals, since a look at the embedded coefficient shows that those are all zero. This done via:

topo clearimpropers

Finally we let VMD reanalyze the molecular information and write out the information in the desired formats:

mol reanalyze top

animate write psf hdpe-x5.psf

animate write pdb hdpe-x5.pdb

For a single-walled carbon nanotube (data.swcnt-5,5) we could perform the same operation, but in this case, we need to keep impropers and would benefit from setting a different atom type (for aromatic carbons) as shown in the script reconstructswcnt.tcl.



Combine multiple data files with overlap detection and removal

When merging coordinate files using the ::TopoTools::mergemols procedure, no test is made to check for overlapping atoms or molecules, but elimination of overlaps can be done on the combined molecule just as easily:

set mindist 2.5 ; # minimum required distance between atoms

# load solute molecule

set solute [mol new solute.psf waitfor all]

mol addfile solute.pdb mol $solute waitfor all

# load solvent box, suitable sized and translated

set solvent [mol new solvent.psf waitfor all]

mol addfile solvent.pdb mol $solvent waitfor all

# merge and transfer solvent box dimensions

set combined [TopoTools::mergemols "$solute $solvent"]

molinfo $combined set {a b c alpha beta gamma} [molinfo $solvent get {a b c alpha beta gamma}

# define a macro that make it easy to determine the solute

set sel [atomselect $solute all]

atomselect macro solute "index < [$sel num]"

$sel delete

# create selection of non-overlapping atoms

set sel [atomselect $combined "not (same fragment as (exwithin $mindist of solute))"]

$sel writepsf merged.psf

$sel writepdb merged.pdb

of course this strategy can be easily extended to merge more than two sets of molecules.