From: Goedde, Chris (CGOEDDE_at_depaul.edu)
Date: Wed Feb 21 2018 - 12:46:31 CST

There has to be something else going on:

% set data 2
2
% mol load pdb Si_S_config$data.pdb
Unable to load structure file Si_S_config2.pdb

If data really held the value 2, the mol command would try to load the correct file.

I’m guessing that your data variable ends with a carriage return that you need to strip off or avoid from the start to make this work.

This is my go-to site for figuring out how to do stuff in tcl:

http://www.tcl.tk/man/tcl8.5/tutorial/tcltutorial.html

Chris

> On Feb 21, 2018, at 12:18 PM, Dive, Aniruddha Mukund <aniruddha.dive_at_wsu.edu> wrote:
>
> Thanks John for your suggestion,
>
> I understand the use of $env(VARIABLE) prior to launching VMD. To avoid the use of that I am writing the value of variable to a "tmp" file and then I read the value of variable from the "tmp" file in the TCL script. I am able to successfully read the value of the variable from the tmp file in the TCL script. The error I face is that VMD is not able to load the trajectory file through the below command in the TCL Script
>
> mol load pdb Si_S_config$data.pdb
>
> Below is the error I get with the attached TCL Script:
> file16
> 2
> 2
> 2
> 2
> 2
> 2
> 2
> 2
> 2
> 2
>
> Si_S_config2
> 2
> 2
> 2
> 2
> 2
> 2
> 2
> 2
> 2
> .pdb
> ERROR) Could not read file Si_S_config2
> ERROR) 2
> ERROR) 2
> ERROR) 2
> ERROR) 2
> ERROR) 2
> ERROR) 2
> ERROR) 2
> ERROR) 2
> ERROR) 2
> Unable to load structure file Si_S_config2
> 2
> 2
> 2
> 2
> 2
> 2
> 2
> 2
> 2
> .pdb
> There is no 'top' molecule in atomselect's 'molId'
>
> The file name I want to load is Si_S_config2.pdb, but somehow the file name ends after$data and it doesnot read the filename as Si_S_config2.pdb but instead as Si_S_config2 and .pdb separately. Kindly let me know how to get around this issue? Is this issue due to non declaration of $env(VARIABLE)?
>
> Regards,
> Aniruddha M Dive
> PhD student
> School of Mechanical and Materials Engg.
> Washington State University
> From: John Stone <johns_at_ks.uiuc.edu>
> Sent: Tuesday, February 20, 2018 8:49:00 AM
> To: Dive, Aniruddha Mukund
> Cc: vmd-l_at_ks.uiuc.edu
> Subject: Re: vmd-l: VMD TCL Script to save last frame of a trajectory using bash+tcl scripts
>
> Hi,
> You need to use Tcl's $env(VARIABLE) interface to obtain environment
> variables set in external command shells prior to launching VMD.
> Similarly, when using bash/bourne shells, you will need to use
> "export FOO=BAR" to ensure that the variable propagates to subshells
> and child processes like the VMD instance(s) you want to run.
>
> Best regards,
> John Stone
> vmd_at_ks.uiuc.edu
>
> On Mon, Feb 19, 2018 at 10:37:33PM +0000, Dive, Aniruddha Mukund wrote:
> > Hi All,
> >
> > I am trying to make a bash script which will traverse through various
> > directories and save the coordinates of the last frame from a trajectory
> > in each of the directory. I have made a bash script attached hereby to
> > help me traverse through different directories and along with that I have
> > made another tcl script to save the coordinates of the last frame from the
> > trajectory. The TCL script works fine without the variable introduced
> > while loading the molecule. But when I introduce a variable in the name of
> > the molecule in the TCL script, the script is not able to recognize the
> > molecule and hence cannot load the molecule.
> >
> > Kindly let me know what could be a possible reason for this?
> >
> > Aniruddha M Dive
> >
> > PhD student
> >
> > School of Mechanical and Materials Engg.
> >
> > Washington State University
>
> > set f [open tmp]
> > set data [read $f]
> > close $f
> > puts "Si_S_config$data.pdb"
> > mol load pdb Si_S_config$data.pdb
> > [atomselect top all frame last] writepdb Si_S_config_$data.pdb
> >
>
>
>
> --
> NIH Center for Macromolecular Modeling and Bioinformatics
> Beckman Institute for Advanced Science and Technology
> University of Illinois, 405 N. Mathews Ave, Urbana, IL 61801
> https://urldefense.proofpoint.com/v2/url?u=http-3A__www.ks.uiuc.edu_-7Ejohns_&d=DwIBAg&c=C3yme8gMkxg_ihJNXS06ZyWk4EJm8LdrrvxQb-Je7sw&r=G3Jrh1AoXSkPz7yuBQgIlebQbWzju12uzXWQYpZ4LHQ&m=tOC1-rIvhPp6PtZ9S914jhrbTthmVA8rUjiq8G4qyn0&s=fHQRGu0hGd-b3U_pbDEooqL-l1iRcwPkwfDcqVnCcBk&e= Phone: 217-244-3349
> https://urldefense.proofpoint.com/v2/url?u=http-3A__www.ks.uiuc.edu_Research_vmd_&d=DwIBAg&c=C3yme8gMkxg_ihJNXS06ZyWk4EJm8LdrrvxQb-Je7sw&r=G3Jrh1AoXSkPz7yuBQgIlebQbWzju12uzXWQYpZ4LHQ&m=tOC1-rIvhPp6PtZ9S914jhrbTthmVA8rUjiq8G4qyn0&s=rg0rUjJYj9eRMZHSFKtbQ9BxIcnJV4Ni09LTJlRqovg&e=
> <write_pdb.tcl><write_pdb_bgf.sh>