From: Windle,Stephen (snw42_at_drexel.edu)
Date: Fri Nov 03 2017 - 17:43:44 CDT

Excellent! Yea. I just download the .pdb files straight from the databank website so they all just the PDB ID. Thanks again!

-Steve
________________________________
From: Vermaas, Joshua <Joshua.Vermaas_at_nrel.gov>
Sent: Friday, November 3, 2017 6:32:09 PM
To: Windle,Stephen; vmd-l_at_ks.uiuc.edu
Subject: Re: vmd-l: Computing atom distances

Hi Stephen,

Sure. Take a look at the molinfo command. It lets you do stuff like:

foreach mid [molinfo list] {
set filename [molinfo $mid get filename]
puts $filename
}

If your input file names are somewhat sane, this will probably be your pdbid (or something close to it).

-Josh

On 11/03/2017 03:58 PM, Windle,Stephen wrote:

Ah. Right after I sent that message I thought to try that, and it seemed to work. My current script is now:

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

Next step is to write another loop that does this for every file that is loaded and outputs it into its own data file. That much seems pretty simple. Question: I figure it's easy to increment the output file names to correspond with the their ID number from the molecule list in VMD main. I should be able to name it by the selected protein's PDB ID, right? Would I just set another variable to the PDB ID for the selected molecule? Again, thank you for all your help. I'm a second year undergrad whose only coding experience has been in C++, so this has been a great resource!

-Steve

________________________________
From: Vermaas, Joshua <Joshua.Vermaas_at_nrel.gov><mailto:Joshua.Vermaas_at_nrel.gov>
Sent: Friday, November 3, 2017 5:35:00 PM
To: Windle,Stephen; vmd-l_at_ks.uiuc.edu<mailto:vmd-l_at_ks.uiuc.edu>
Subject: Re: vmd-l: Computing atom distances

Basically yes. :) The innermost puts should be "puts $file ..." where ... is the rest of the command. This will put 1 element per line. If you don't want that, you should look at the -nonewline option, and put in new lines where needed.

-Josh

On 11/03/2017 03:29 PM, Windle,Stephen wrote:

Thank you all for your tips. They've been most helpful. If I've learned anything in coding, it's that fixing one problem leads to another. This is no exception. For some reason, my output file is empty. The numbers I want are showing up in the TK Console just not making it to the file. I am assuming I'm doing something foolish with the script. Here it is (it's a slightly adjusted variation of what was already posted on this thread):

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]

puts $file [
for { set i 0 } { $i < [llength $ressellist] } { incr i } {
for { set j [expr {$i+1}] } { $j < [llength $ressellist] } { incr j } {
puts "$i $j [veclength [vecsub [measure center [lindex $ressellist $i]] [measure center [lindex $ressellist $j]]]]"
}
}
]

close $file

Am I putting my "puts $file" command in the wrong place? Should it go inside the for loop? Thanks again!

-Steve

________________________________
From: Vermaas, Joshua <Joshua.Vermaas_at_nrel.gov><mailto:Joshua.Vermaas_at_nrel.gov><mailto:Joshua.Vermaas_at_nrel.gov><mailto:Joshua.Vermaas_at_nrel.gov>
Sent: Tuesday, October 31, 2017 7:03:12 PM
To: Windle,Stephen; vmd-l_at_ks.uiuc.edu<mailto:vmd-l_at_ks.uiuc.edu><mailto:vmd-l_at_ks.uiuc.edu>
Subject: Re: vmd-l: Computing atom distances

Hi Steve,

Tcl can be a messy beast. :) In terms of loading every single pdb in a directory, that is fairly simple:

set pdblist [glob *.pdb]
foreach pdb $pdblist {
mol new $pdb
}

Now you want to make some sort of measurement afterward. This also isn't *too* bad, but it really depends on what exactly you want to be measuring, why, and what kind of data format you want to get out. The simplest way might be something like this:

set allsel [atomselect top "protein"]
set residuelist [lsort -unique -integer [$allsel get residue]]

set ressellist [list ]
foreach residue $residuelist {
lappend ressellist [atomselect top "residue $residue"]
}

for { set i 0 } { $i < [llength $ressellist] } { incr i } {
for { set j [expr {$i+1}] } { $j < [llength $ressellist] } { incr j } {
puts "$i $j [veclength [vecsub [measure center [lindex $ressellist $i]] [measure center [lindex $ressellist $j]]]]"
}
}

This will measure the distance between any pair of protein residues in the top molecule, while only making a relatively small number of atomselections. Things a beginning VMDer should definitely read are the userguide (https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.ks.uiuc.edu%2FResearch%2Fvmd%2Fcurrent%2Fug&data=02%7C01%7Csnw42%40drexel.edu%7C5c2434391fd84f23ac4008d520b394ae%7C3664e6fa47bd45a696708c4f080f8ca6%7C0%7C0%7C636450878022113423&sdata=gxGdXXLbFoeDc9lfFAvLPVhuXoDGk5c%2B%2BZjsY%2BZJ6Is%3D&reserved=0), particularly the sections about Tcl/Tk scripting, and the available vector and matrix commands. Additionally, useful tcl commands to know/read up on are things like glob, expr, and the list-related commands. I often will refer back to https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.tcl.tk%2Fman%2Ftcl%2FTclCmd%2Fcontents.htm&data=02%7C01%7Csnw42%40drexel.edu%7C5c2434391fd84f23ac4008d520b394ae%7C3664e6fa47bd45a696708c4f080f8ca6%7C0%7C0%7C636450878022113423&sdata=IRYnIC42wio2RpfqIN0vQnd%2BHiqBMiS81rvo6RoHswU%3D&reserved=0.

Happy coding!

-Josh Vermaas

On 10/31/2017 04:17 PM, Windle,Stephen wrote:

VMD Users,

Good afternoon. I am very new to the VMD software, and I am working on putting together a script for a specific purpose, but I am unsure how much of it can be done as a single script. Essentially, I want to measure the distances between all the side chains of a specific amino acid in a given protein (for example distances between all the valine side chains). However, I want to be able to load anywhere from 1000-10,000 molecules into VMD and have the script do this for each molecule consecutively, exporting them into individual files (I should be able to write a loop for this, I imagine). So far I'm able to load a molecule and isolate the side chains of a specific amino acid. So my two key questions are this: Can a loop be written to load every .pdb file in a given folder, and what are the console commands to measure the distance between each side chain once they've been isolated into a named selection. I have tried searching through the indexed messages but to no avail. If someone could point me in the right direction that would be greatly appreciated. Thank you!

Regards,

Steve Windle