From: Axel Kohlmeyer (akohlmey_at_vitae.cmm.upenn.edu)
Date: Mon Mar 13 2006 - 18:40:14 CST

On Mon, 13 Mar 2006, andrea spitaleri wrote:

AS> Hi Johns,
AS> the only way to run a own script is first to source it and then use it?
AS> May vmd load it at start up the script without put it in the $vmddir/script?
AS> I couldn't find it any answer ......

andrea,
you also can use standard TCL techniques to have scripts autoloaded.

please have a look at:
http://www.theochem.ruhr-uni-bochum.de/~axel.kohlmeyer/cpmd-vmd/part1.html#chap3_sect3

to make a directory autoloadable, you only need to generate an index
file i use the following trivial script for it:

#!/usr/bin/tclsh

auto_mkindex . *.tcl

note, that the draw extensions (and similar functions) _have_
to be sourced before they are recognized. but the URL from above
shows how to do this in a generic way.

regards,
   axel.

AS>
AS> Reagards,
AS>
AS> andrea
AS>
AS>
AS>
AS> John Stone wrote:
AS>
AS> >Hi Lily,
AS> > Yes, there are various little scripts that can do things like this.
AS> >Take one of these and cut out the stuff you don't need, as all of these
AS> >probably do more than you're looking for.
AS> >
AS> >Here's one that loads a numerically named sequence of PDB files:
AS> > http://www.ks.uiuc.edu/Research/vmd/script_library/scripts/animatepdbs/
AS> >
AS> >Here's another that loads all of the PDB files in a particular
AS> >directory using filename globbing (wildcards), which I've used to
AS> >load the entire PDB into VMD at once, for example:
AS> >
AS> >##
AS> >## Example:
AS> >## load_all_pdb "/Scr/pdb/data/structures/all/pdb/*.Z" 32000
AS> >##
AS> >
AS> >proc load_all_pdb { pdbfilespec maxcount } {
AS> > puts "Gathering candidate files."
AS> > set filelist [glob -types f -- $pdbfilespec]
AS> > set numfiles [llength $filelist]
AS> > set count 0
AS> >
AS> > if { $numfiles > 0 } {
AS> > puts "Searching $numfiles PDB files..."
AS> > foreach {file} $filelist {
AS> > incr count
AS> > if {$count > $maxcount} {
AS> > break;
AS> > }
AS> >
AS> ># puts "$count/$numfiles, loading $file ..."
AS> >
AS> > # detect compressed PDB entry by filename, uncompress, and load
AS> > if { [string match "*.ent.Z" $file] } {
AS> > file delete /tmp/loadpdb.pdb
AS> > exec zcat $file > /tmp/loadpdb.pdb
AS> > mol new /tmp/loadpdb.pdb waitfor all
AS> ># mol rename top $file
AS> > } elseif { [string match "*.ent" $file] } {
AS> > mol new $file type pdb waitfor all
AS> > } elseif { [string match "*.pdb" $file] } {
AS> > mol new $file waitfor all
AS> > } else {
AS> > # Skip unrecognized structure file formats and PDB files without coords
AS> > continue;
AS> > }
AS> > }
AS> > puts "Completed loading $numfiles PDB files..."
AS> > } else {
AS> > puts "No PDB files found"
AS> > }
AS> >}
AS> >
AS> >
AS> >
AS> >
AS> >On Fri, Mar 10, 2006 at 11:41:03AM -0800, lily jin wrote:
AS> >
AS> >
AS> >>In the .VMD file, I have :
AS> >> mol addfile 1.pdb type pdb type pdb waitfor all
AS> >> mol addfile 2.pdb type pdb type pdb waitfor all
AS> >> mol addfile 3.pdb type pdb type pdb waitfor all
AS> >> mol addfile 4.pdb type pdb type pdb waitfor all
AS> >> mol addfile 5.pdb type pdb type pdb waitfor all
AS> >> mol addfile 6.pdb type pdb type pdb waitfor all
AS> >> mol addfile 7.pdb type pdb type pdb waitfor all
AS> >> mol addfile 8.pdb type pdb type pdb waitfor all
AS> >> mol addfile 9.pdb type pdb type pdb waitfor all
AS> >> mol addfile 10.pdb type pdb type pdb waitfor all
AS> >> Is there a way to do the same in a loop? Thanks!
AS> >>
AS> >>
AS> >>Lily
AS> >>
AS> >>---------------------------------
AS> >>Yahoo! Mail
AS> >>Bring photos to life! New PhotoMail makes sharing a breeze.
AS> >>
AS> >>
AS>
AS>

-- 
=======================================================================
Axel Kohlmeyer   akohlmey_at_cmm.chem.upenn.edu   http://www.cmm.upenn.edu
   Center for Molecular Modeling   --   University of Pennsylvania
Department of Chemistry, 231 S.34th Street, Philadelphia, PA 19104-6323
tel: 1-215-898-1582,  fax: 1-215-573-6233,  office-tel: 1-215-898-5425
=======================================================================
If you make something idiot-proof, the universe creates a better idiot.