VMD-L Mailing List
From: Axel Kohlmeyer (akohlmey_at_gmail.com)
Date: Sat Aug 06 2016 - 13:49:48 CDT
- Next message: Arham Amouie: "Re: processing a large "molecule""
- Previous message: Arham Amouie: "processing a large "molecule""
- In reply to: Arham Amouie: "processing a large "molecule""
- Next in thread: Arham Amouie: "Re: processing a large "molecule""
- Reply: Arham Amouie: "Re: processing a large "molecule""
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
On Sat, Aug 6, 2016 at 2:12 PM, Arham Amouie <erham65t_at_remove_yahoo.com> wrote:
> Hi. I've written the following tcl script to change the beta value of all
> the atoms of a large "molecule", composed of about 500,000 atoms:
>
> set crystal [atomselect top "all"]
> set atomsNo [$crystal num]
> $crystal delete
> for {set i 0} {$i < $atomsNo} {incr i} {
> set atom_i [atomselect top "index $i"]
> set atomcolor [$atom_i get beta]
> if {$atomcolor < 0.02} {
> $atom_i set beta 0
> } else {
> $atom_i set beta 1.0
> }
> $atom_i delete
> }
>
> But it's extremely slow. How can I write a much faster script? Is it
> possible within VMD?
yes. in general, you would not create individual atom selections, but
extract, operate, and loop on lists instead and then assign the list
in one go outside the loop.
since your operation on the atoms itself is extremely simple, it can
be done with even less code, without a loop and just two atom
selections.
set sel [atomselect top "beta < 0.02"]
$sel set beta 0
$sel delete
set sel [atomselect top "beta > 0"]
$sel set beta 1.0
$sel delete
axel.
-- Dr. Axel Kohlmeyer akohlmey_at_gmail.com http://goo.gl/1wk0 College of Science & Technology, Temple University, Philadelphia PA, USA International Centre for Theoretical Physics, Trieste. Italy.
- Next message: Arham Amouie: "Re: processing a large "molecule""
- Previous message: Arham Amouie: "processing a large "molecule""
- In reply to: Arham Amouie: "processing a large "molecule""
- Next in thread: Arham Amouie: "Re: processing a large "molecule""
- Reply: Arham Amouie: "Re: processing a large "molecule""
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]