VMD-L Mailing List
From: Vermaas, Joshua (Joshua.Vermaas_at_nrel.gov)
Date: Mon Jul 03 2017 - 13:28:39 CDT
- Next message: Axel Kohlmeyer: "Re: Get empirical formula of fragment"
- Previous message: MD Simulation: "Get empirical formula of fragment"
- In reply to: MD Simulation: "Get empirical formula of fragment"
- Next in thread: Axel Kohlmeyer: "Re: Get empirical formula of fragment"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
What does the second line return when you try it in the tkconsole? Alot of file formats do not populate the element by default, and even the ones that CAN have element information do not always have it. If the element field isn't filled in, you can guess it from other filled in fields using topotools (see http://www.ks.uiuc.edu/Research/vmd/plugins/topotools/#TOC-guessatom-property-from-)
-Josh
On 07/01/2017 08:29 PM, MD Simulation wrote:
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: Axel Kohlmeyer: "Re: Get empirical formula of fragment"
- Previous message: MD Simulation: "Get empirical formula of fragment"
- In reply to: MD Simulation: "Get empirical formula of fragment"
- Next in thread: Axel Kohlmeyer: "Re: Get empirical formula of fragment"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]