From: Ashar Malik (asharjm_at_gmail.com)
Date: Fri Dec 15 2017 - 17:34:44 CST

Hey,

To get you to write your own code here is a hint.

(Assuming I understand your question -- this may be way off)

Think that all your PDB files are in a folder.
In your script use glob to populate a list of pdb files using something
like

set pdb_list [glob *.pdb]

Now use a for loop over this list. Do something like

foreach pdb_file $pdb_list {

..

}

Inside the for loop load the PDB

mol load pdb_file $pdb

Note that every time you load a molecule it becomes "top". So running the
code you sent with "top" will work for the last molecule added.

So now there are two ways -- I can think of.

Given that there is no relationship between the PDB files and all
calculations are done with one pdb file. You can simply run through the for
loop above loading a new PDB file in each iteration
Making the selections doing your work and deleting those selections to
proper memory management.

The other way is that each time a new PDB file is loaded a ID will be
assigned to that molecule
Grab that ID using the molinfo command with the ID (
http://www.ks.uiuc.edu/Research/vmd/vmd-1.7.1/ug/node125.html )

Append that to a list using "lappend" and then iterate over that list of
molecular IDs.

Note that you may have to put two for loops, one to load the molecules and
grab their IDs. The second to iterate over the list of IDs and do the work.
If you just want to work on PDB files without having to go back and forth
between them you should just used the earlier approach and not log the IDs.
To use the molecule's ID you can do something like

[atomselect 17 all] # note that I replaced top with an integer 17 so if I
have 30 molecules loaded into VMD - I can use this to select everything in
molecule which was assigned mol ID 17.

Hope this helps.

On Sat, Dec 16, 2017 at 11:39 AM, Windle,Stephen <snw42_at_drexel.edu> wrote:

> Good evening.
>
>
> I am running a script to output distances on selected molecules to a
> specific file. I was trying to get it to loop between all the files loaded,
> but my loops don't seem to be working. What I want it to do is to run this
> script, but inside a loop that moves onto the next loaded .pdb file, and do
> the same, but output it to the end of the .dat file, so that it will cycle
> through however many files I have loaded and just add them to the end,
> making one really long file. The script is below (this is what it looks
> like before I started trying to add a for loop to have it run through the
> loaded files):
>
>
> set allsel [atomselect top "sidechain and resname ALA"]
> set residuelist [lsort -unique -integer [$allsel get residue]]
>
> set ressellist [list ]
> foreach residue $residuelist {
> lappend ressellist [atomselect top "residue $residue"]
> }
>
> set file [open "myoutput.dat" w]
>
>
> for { set i 0 } { $i < [llength $ressellist] } { incr i } {
> for { set j [expr {$i+1}] } { $j < [llength $ressellist] } { incr j } {
> puts $file "$i $j [veclength [vecsub [measure center [lindex $ressellist
> $i]] [measure center [lindex $ressellist $j]]]]"
> }
>
> }
>
> close $file
>
> ...I am very new to the VMD environment, and haven't had luck looking
> through the manuals and readme files, so I'm not sure what I'm doing wrong.
> Thanks!
>
>
> -Stephen
>

-- 
Best,
/A