From: Justin Gullingsrud (jgulling_at_mccammon.ucsd.edu)
Date: Sat Apr 03 2004 - 09:27:12 CST

Hi,

On Apr 3, 2004, at 5:48 AM, Ahmet Bakan wrote:

> Hi All,
>
> I am trying to write a TCL procedure to calculate the interaction
> potential
> between two proteins and I am stuck at the following point.
> Let's say:
>
> set HB {-0.022000 1.320000}
> set typea [$sel get type]
> set ea [lindex ${$typea} 0]

There's no need for the extra dollar sign. Try:
   set ea [lindex $typea 0]

> return $ea #Returns me "$HB" and i cannot get 0th item of HB
>

I don't see what HB has to do with typea, but if you just want the type
of the first element in the selection, there you go.

By the way, if you're creating a selection for every pair interaction
in your molecule, you're in for a painfully slow script. A much better
way to do this would be to use the "measure contacts" command to find
interacting atom pairs for you, then use the indices to look up the
atom types in a table. Something like:

# one selection for each protein molecule; your selections may differ.
set proA [atomselect top "chain A"]
set proB [atomselect top "chain B"]

# create a table of all the atom types and their positions.
set all [atomselect top all]
set types [$all get type]
set positions [$all get {x y z}]

# Find all atoms in A that are within 5 of atom B. Return as two
lists, corresponding to the atoms
# in A and the atoms in B, respectively.
set contacts [measure contacts 5 $proA $proB]
set atomA [lindex $contacts 0]
set atomB [lindex $contacts 1]

# Loop over elements in each list, grabbing the atom type from the
table and doing whatever
# operation you need to do to get their interaction energy.
foreach A $atomA B $atomB {
   set typeA [lindex $types $A]
   set typeB [lindex $types $B]
   set posA [lindex $positions $A]
   set posB [lindex $positions $B]

   # calculate something based on atom type and positions...
}

You might also want to consider using NAMD to calculate the interaction
energies for you; this will be much faster than anything you could do
with a VMD script.

> If someone can assist me at this point I would be grateful.
> Before I send this mail, I have searched internet for a TCL discussion
> list,
> but could not find an appropriate one. Do you have one to recommend?

For more on Tcl, here's a decent place to start:
http://wiki.tcl.tk/0

Cheers,
Justin

>
> Thanks in advance,
> Ahmet
>
>
> ==========ABC==========
> Ahmet Bakan
> Chemistry, Junior
> Koc University
> abakan_at_ku.edu.tr
> ICQ #86167698
> http://home.ku.edu.tr/~abakan
>
>
>

--
Do you want to see what human eyes have never seen? Look at the moon. 
Do you want to hear what ears have never heard? Listen to the bird's 
cry. Do you want to touch what hands have never touched? Touch the 
earth. Verily I say that God is about to create the world.
-- Borges, "The Theologians"