From: Michael Kreim (mkreim_at_keychem.de)
Date: Wed Apr 22 2009 - 03:50:59 CDT

Dear VMD users,

I observed a strange behaviour in VMD/python using command line arguments.
My program expects two file names and one atomselection string as
parameters. Everything goes well as long as my atomselection does not
contain any spaces. This leads to an error message I don't understand.

To make it short. My script:
# vmd -dispdev text -python -e test.vmdpy -args -i input.pdb -o
output.pdb -s "all"
import sys

for i in range(len(sys.argv)):
    if sys.argv[i]=="-s":
        atomselection=sys.argv[i+1]
    elif sys.argv[i]=="-i":
        inputpdb=sys.argv[i+1]
    elif sys.argv[i]=="-o":
        outputpdb=sys.argv[i+1]

print "atomselction:",atomselection
print "inputpdb: ",inputpdb
print "outputpdb: ",outputpdb
sys.exit()
# --- EOF ---

This shows this behaviour:
$ vmd -dispdev text -python -e test.vmdpy -args -i input.pdb -o
output.pdb -s "all"
Info) VMD for LINUXAMD64, version 1.8.6 (April 6, 2007)
Info) http://www.ks.uiuc.edu/Research/vmd/
Info) Email questions and bug reports to vmd_at_ks.uiuc.edu
Info) Please include this reference in published work using VMD:
Info) Humphrey, W., Dalke, A. and Schulten, K., `VMD - Visual
Info) Molecular Dynamics', J. Molec. Graphics 1996, 14.1, 33-38.
Info) -------------------------------------------------------------
Info) Multithreading available, 4 CPUs detected.
Info) Free system memory: 1486MB (38%)
/home/mkreim/bin/python/python-2.2.3/
Info) Starting Python...
Info) Text interpreter now Python
atomselction: all
inputpdb: input.pdb
outputpdb: output.pdb

$ vmd -dispdev text -python -e test.vmdpy -args -i input.pdb -o
output.pdb -s "all and not water"
argv: Index nicht im gültigen Bereich.

I tested this also with the python 2.5.1 installation of my linux
distribution and with the python2.2 binary of VMD:
$python2.2 test.vmdpy -o out -i in -s "all but not water"
atomselction: all but not water
inputpdb: in
outputpdb: out

As you can see, if I run the program without VMD everything goes well
but VMD leads to this strange "argv: Index nicht im gültigen Bereich."
message.

What am I doing wrong? How can I pass my atomselection strings to
VMD/python-scripts via command line?

Thanking you in anticipation.

With best regards,

Michael Kreim

-- 
Dipl.-Biol. Michael Kreim <mkreim_at_keychem.de>
Technische Universität Darmstadt,
Institut für Botanik, Schnittspahnstr.3, D-64287 Darmstadt