VMD-L Mailing List
From: Axel Kohlmeyer (akohlmey_at_gmail.com)
Date: Wed Jan 25 2012 - 14:46:05 CST
- Next message: John Stone: "Looking for nice example images for VMD 1.9.1 release page..."
- Previous message: jeela keel: "Re: Re: atomselect counting"
- In reply to: jeela keel: "Re: Re: atomselect counting"
- Next in thread: Peter C. Lai: "Re: Re: atomselect counting"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
On Wed, Jan 25, 2012 at 2:48 PM, jeela keel <jeela22_at_gmail.com> wrote:
>
> Dear Alex and VMD users,
>
> Thank you for your help and I am sorry if I was not clear earlier. I am
> looking for a way of counting a molecule for example with an index 452, how
> many times does this molecule appear in the selection or how many times it
> is in the list of the molcules that are selected.
wait... now you are talking about molecules and not atoms.
that is even more confusing.
>
> Based on your suggestion , started writing the following :
>
> So I make the selection of the atom atom_select
arrrgggghhhhh!!!! what is the selection text for this?
without knowing exactly what you are doing, (and what
you *want* to do) it is very difficult to debug it.
you are leaving out very important information. here.
> then get the index of the atom selected set atom1_list [$atom1_select get
> index]
> get the number of the atoms in the list atoms1_number [llength
> [$atom1_select list]]
> for {set k 0} {$k < $atoms1_number } {incr k} {
> set atom1 [lindex $atom1_list $k]
this part of code is needlessly complicated. the following does the same:
foreach atom1 [$atom1_select list] {
> set atom2_select [atomselect top "resname SOL and pbwithin
> 5.00 of index $atom1"]
so this one makes only sense, if *none* of the atoms
in $atom1_select have the SOL resname. is this true?
> set atom2_index [$atom2_select get index]
> set atom2_list [ $atom2_index list ]
these two statements produce the exact same result.
> set num_atom2 [ llength $atom2_list]
and this is the same as:
set num_atom2 [$atom2_select num]
> puts " atoms: $atom2_list and num_atoms
> : $num_atom2 "
>
> so I get something like this for one single frame. in the list there are
> three atoms with index 452 and two atoms of index 1942 and nine atoms of
> index 1855.
>
> atom : 1855 num_atoms 1
> atom : 1855 num_atoms 1
> atom : 452 num_atoms 1
> atom : 452 num_atoms 1
> atom : 1855 num_atoms 1
> atom : 1855 num_atoms 1
> atom : 1942 num_atoms 1
> atom : 1855 num_atoms 1
> atom : 1855 num_atoms 1
> atom : 1855 num_atoms 1
> atom : 1942 num_atoms 1
> atom : 1855 num_atoms 1
> atom : 452 num_atoms 1
> atom : 1855 num_atoms 1
>
> the question I am trying to solve, is how do I count how many atoms are that
> have same index ( meaning how many times the same atom is selected). and
> create a new list that has something like this
>
> index 452 3
> index 1855 9
> index 1942 2
ok. so i would propose something along the following lines:
set matches {}
set cutoff 5.0
set sel1 [atomselect top "some selection"]
foreach atom1 [$sel1 list] {
set sel2 [atomselect top "resname SOL and pbwithin $cutoff of
index $atom1"]
foreach i [$sel2 list] {
lappend matches $i
}
$sel2 delete
}
set indices [lsort -integer -unique $matches]
set sorted[lsort -integer $matches]
foreach idx $indices {
set num [llength [lsearch -integer -sorted -increasing $sorted $idx]]
puts "atom $idx $num"
}
HTH,
axel.
> Thank you for any suggestions or sharing scripts that are solving similar
> question.
>
> Jeela
>
>
>
> On Wed, Jan 25, 2012 at 10:12 AM, Axel Kohlmeyer <akohlmey_at_gmail.com> wrote:
>>
>> On Wed, Jan 25, 2012 at 9:39 AM, jeela keel <jeela22_at_gmail.com> wrote:
>> > Hello VMD users,
>> >
>> > Is possible to count how many of same atomselect is in a list or how
>> > many
>> > times atomselect is selected? Using VMD , selected molecules that are
>> > close
>> > to different parts of protein and selected some molecules more than once
>> > and
>> > want to know how many times the same atomselect is been selected or how
>> > many
>> > of them are in the list per each frame.
>> >
>> > for example in frame 1 there are 4 of atomselect2345 (same molecule) and
>> > 5
>> > of atomselect8509 and so on.
>>
>> your wording is a bit confusing. lets first see whether we are on the same
>> page.
>>
>> an "atom selection", i.e. the procedure that is created by the
>> atomselect command,
>> is in essence a list of atoms that is generated based on a rule (the
>> selection text).
>>
>> from what i gather, you are now looking for the *intersection*
>> of two atom selections, right?
>>
>> there are multiple ways to do that. for example, create a new
>> selection that contains
>> the first selection text combined with the section selection text via
>> an "and" condition.
>>
>> if you want to do that in an automated fashion, there should be
>> something like this:
>>
>> set selintersect [atomselect top "([$sel1 text]) and ([$sel2 text])"]
>>
>> you could also write a small proc that computes the intersection of
>> [$sel1 get index] and [$sel2 get index]. there is an 'intersect' command
>> in TclX that does this automatically, but VMD does not contain TclX.
>>
>> it should also be straightforward to write a small proc to do this.
>> you can write the proc fairly efficiently, since you can rely on the
>> fact that index lists are always pre-sorted with increasing index.
>>
>> a good place to look for Tcl script hacks and existing solutions
>> is the Tcl/Tk wiki at: http://wiki.tcl.tk
>>
>> axel.
>>
>>
>> > I have used the command llength and num before that counts how many
>> > atoms
>> > are in a list, but this time I need to count how many times each
>> > specific
>> > atomselect is selected in the same frame. then move to next frame where
>> > there are different atomselect that again change with next frame.
>> >
>> > I am trying to write a script to do the above but I am wondering if
>> > there is
>> > a command that can be useful to use in the script . Did anybody wrote
>> > something similar to what am trying to do or have any suggestion. Thank
>> > you
>> > for your help and suggestions.
>> >
>> > jeela
>>
>>
>>
>> --
>> Dr. Axel Kohlmeyer
>> akohlmey_at_gmail.com http://goo.gl/1wk0
>>
>> College of Science and Technology
>> Temple University, Philadelphia PA, USA.
>>
>
-- Dr. Axel Kohlmeyer akohlmey_at_gmail.com http://goo.gl/1wk0 College of Science and Technology Temple University, Philadelphia PA, USA.
- Next message: John Stone: "Looking for nice example images for VMD 1.9.1 release page..."
- Previous message: jeela keel: "Re: Re: atomselect counting"
- In reply to: jeela keel: "Re: Re: atomselect counting"
- Next in thread: Peter C. Lai: "Re: Re: atomselect counting"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]