Re: Feature request for the colvars module -- TCL syntax

From: Ajasja Ljubetič (
Date: Tue Jan 18 2011 - 07:17:54 CST

Dear Jrme and Chris,

In general I think that this templating system I
linked<> to
could be used directly from the NAMD conf file. It would take the input
template and output a substituted conf file. I think something like this
could be implemented in pure TCL
colvarsConfig [substify]

This would then create a filled out template and return the correct
file name.

All my "problems" are basically just minor inconveniences, result from the
fact that I'm spoiled by NAMD's TCL syntax.
Here are some concrete examples:

0) I use TCL variables extensivaly in NAMD conf files here's an example:
set strucname $env(STRUCTNAME)
structure $strucname.psf
coordinates $strucname.pdb
#set length $env(LENGTH_NS) ;#ns
set timestep 1 ;#femtosecond
#set numsteps [expr round(($length * 1000000)/ $timestep)]

1) Lets say I would like to change the number of samples for each bin. But
then I have to edit the number of steps to run in the NAMD conf file as well
(and I always kept forgetting this). Using TCl I could just do:

set fullsamples 500
set numbins 10 ;#

set numsteps [expr $fullsamples*($numbins+1)]
run $numsteps
colvar {
  name chi1

  width [expr 360/$numbins]
  lowerboundary -180
  upperboundary 180

abf {
  colvars chi1
  fullSamples $fullsamples

2) Let's say I have 5 colvars and I would like to run the simulations on the
pairs of colvars. Using TCl I could have just one pair of configurations
files instead of 10 pairs.

set colvar1 chi1
set colvar2 chi2
if {[string compare "chi1" $colvar1 ] || [string compare "chi1" $colvar2 ] }
.define chi1..

if {[string compare "chi2" $colvar1 ] || [string compare "chi2" $colvar2] }
.define chi2..
abf {
  colvars $colvar1 $colvar2
  fullSamples $fullsamples

3) Let's say I have some similar systems (a protein labeled at different
positions). Using enviorment variables I could use the same pair of conf
files and pass the different atom IDs like this:

 dihedral {
    group1 { $env(ATOM1) }
    group2 { $env(ATOM2)}
    group3 { $env(ATOM3)}
    group4 { $env(ATOM4)}

Best regards,

This archive was generated by hypermail 2.1.6 : Wed Feb 29 2012 - 05:23:31 CST