VMD-L Mailing List
From: MD Simulation (mdsimulationgroup_at_gmail.com)
Date: Sat Jul 01 2017 - 20:12:31 CDT
- Next message: Vermaas, Joshua: "Re: Get empirical formula of fragment"
- Previous message: MD Simulation: "Fragment determination"
- Next in thread: Vermaas, Joshua: "Re: Get empirical formula of fragment"
- Reply: Vermaas, Joshua: "Re: Get empirical formula of fragment"
- Reply: Axel Kohlmeyer: "Re: Get empirical formula of fragment"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Hello,
I'm trying to write a procedure that will determine the empirical formula
of a fragment:
proc get_empirical_formula {frag_number} {
> set frag_sel [atomselect top "fragment $frag_number"]
> set atoms [$frag_sel get element]
>
> set empirical_formula [dict create]
> foreach atom $atoms {
> if {[dict exists $empirical_formula $atom]} {
> set value [expr {[dict get $empirical_formula $atom] + 1}]
> dict set $empirical_formula $atom $value
> } else {
> dict set $empirical_formula $atom 1
> }
> }
> puts $empirical_formula
> }
>
The idea is that when you get the elements of the frag_sel, you'll get a
list, for instance "C C H H H H H H". I then try to foreach the atom list
and increment a dictionary value. When I try to print the dictionary, all
I get is empty.
Any help would be appreciated. Thanks
- Next message: Vermaas, Joshua: "Re: Get empirical formula of fragment"
- Previous message: MD Simulation: "Fragment determination"
- Next in thread: Vermaas, Joshua: "Re: Get empirical formula of fragment"
- Reply: Vermaas, Joshua: "Re: Get empirical formula of fragment"
- Reply: Axel Kohlmeyer: "Re: Get empirical formula of fragment"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]