From: John Stone (johns_at_ks.uiuc.edu)
Date: Tue Jul 26 2011 - 11:40:45 CDT

Hi,
  The "mol new" and "mol addfile" commands only process one file
at a time. To load multiple files, you should use the "foreach"
command as others have previously suggested. Using eval on "ls" and
things like this is not going to work. The mol commands simply won't
accept more than a single filename at a time, so you MUST use foreach or
another looping construct in order to process a list of files and cause
VMD to load them all. If you want to make it easy to load a bunch of files,
you can make your own Tcl proc to do this:

proc loadfiles { filespec } {
  foreach file [glob $filespec] {
    mol new $file waitfor all
  }
}

Once you've defined the Tcl proc, you can do this:
  loadfiles *.pdb

Cheers,
  John Stone
  vmd_at_ks.uiuc.edu

On Tue, Jul 26, 2011 at 12:14:15PM -0400, Pavan Ghatty wrote:
> Hello Axel,
> My problem is solved. But I was wondering if there was a more elegant way
> of doing things when there is only one pdb file in the workdir. As I
> mentioned in my initial question, there is only one pdb file; protein.pdb
> or edit_protein.pdb. So
> >eval ls [glob *.pdb]
> results in only one file being identified, not two. I understand that "mol
> new" takes only one file/argument per invocation. But that cannot be the
> reason why
> >mol new [eval ls [glob *.pdb]]
> fails in this case. I am just probing this issue to see if there is
> something new to be learned here.
> Thanks
>
> On Mon, Jul 25, 2011 at 3:33 PM, Axel Kohlmeyer <akohlmey_at_gmail.com>
> wrote:
>
> On Mon, Jul 25, 2011 at 2:51 PM, Pavan Ghatty <pavan.vmd_at_gmail.com>
> wrote:
> > Hello All,
> > I have one of the following two files in my workdir. protein.pdb or
> > edit_protein.pdb
> > I would like to do the following:
> > 1. ls *.pdb
> > 2. mol new [ls*.pdb]
>
> this _cannot_ work since mol new only takes a single file as an
> argument.
> > This clearly doesn't work.
> > I tried to see if I could at least select the file using; ls *.pdb.
> > ---------------
> > vmd > ls *.pdb
> > /bin/ls: cannot access *.pdb: No such file or directory
> > child process exited abnormally
> > ---------------
>
> yes. this has to be, since the ls command actually doesn't
> do the expansion of the * wildcard, but the shell itself does it
> when to you type "ls *.pdb" (this is called globbing and can
> be disabled even).
> > I then found out that this works;
> > eval ls [glob *.pdb]
> > But then the following does not work;
> > mol new [eval ls [glob *.pdb]]
> > nor does this
> > mol load pdb [eval ls [glob *.pdb]]
> > They both die with this error;
> > Warning) Unable to ascertain filetype from filename ''; assuming pdb.
> > Can somebody help me out here?
>
> yes, because you have the principle error that mol new only accepts
> one file name
> per invocation. what you have to do is to build a loop (an example for
> that was
> given on the list earlier using some quirky find shell command).
>
> so if you do:
>
> foreach f [glob *.pdb] {
> mol new $f waitfor all
> }
>
> you should get what you desire.
>
> axel.
>
> > Thanks.
>
> --
> Dr. Axel Kohlmeyer
> akohlmey_at_gmail.com http://goo.gl/1wk0
>
> Institute for Computational Molecular Science
> Temple University, Philadelphia PA, USA.

-- 
NIH Resource for Macromolecular Modeling and Bioinformatics
Beckman Institute for Advanced Science and Technology
University of Illinois, 405 N. Mathews Ave, Urbana, IL 61801
http://www.ks.uiuc.edu/~johns/           Phone: 217-244-3349
http://www.ks.uiuc.edu/Research/vmd/       Fax: 217-244-6078