From: Axel Kohlmeyer (akohlmey_at_cmm.chem.upenn.edu)
Date: Wed Dec 24 2008 - 15:53:27 CST

On Wed, 24 Dec 2008, BIN ZHANG wrote:

BZ> Hi, Axel:

hi bin,

BZ> All I was trying to do is to generate a pdb file that has beta values
BZ> indicating the CG bead IDs of each atom. ( similar to the pdb ref file in
BZ> SBCG. http://www.ks.uiuc.edu/Research/vmd/plugins/cgtools/ )

that still doesn't make it a good idea. storing numbers greater
than 999.99 in the beta field would create invalid .pdb files,
as your excerpt already demonstrates.

VMD internally doesn't care where data is coming from, so
- as i was writing before - the cleanest way would be to
load this from a seperate external file.

e.g. after making all your assignments, you can just do:

set fp [open "cgid-to-beta.map" w]
set all [atomselect top all]
puts $fp "[$all get beta]"
$all delete
unset all
close $fp
unset fp

and then upon loading your all atoms structure you could just do:

set fp [open "cgid-to-beta.map" r]
set all [atomselect top all]
$all set beta [gets $fp]
$all delete
unset all
close $fp
unset fp

and you're good to go.

you could even turn those two little code fragments into tcl procs
and define them in your .vmdrc file to have them always available
(just pass the molecule id and the filename).

alternately, you could research other file formats, that are more
flexible in their formatting and more suitable for larger systems.
i am certain VMD supports several that fit the bill.

BZ> I think now the problem comes from the floating point comparison rather than
BZ> the format itself. Because when I use :
BZ> set $sel [atomselect top "beta 1004"]
BZ> puts [$sel get beta]
BZ> I would get 1004, 1005, and 1006, which means these 3 numbers are not
BZ> distinguished anymore.
BZ>
BZ> But the following trick gives what I want :
BZ> set $sel [atomselect top "beta > 1004-0.5 and beta < 1004 + 0.5"]
BZ>
BZ> Does this make sense?

this is because beta is a floating point number and is read in as
a float. however not all integer numbers can be stored perfectly
in a floating point number, specifically, if they are stored in
single precision internally.

BZ> If this was true, I would expect SBCG also have similar problems, because I
BZ> didn't see any attention was paid to deal with this issue.

the abuse of various data fields in .pdb file is in my opinion
a very bad habit and should be avoided wherever possible.

axel.

BZ> Thanks a lot.
BZ>
BZ> Bin
BZ>

-- 
=======================================================================
Axel Kohlmeyer   akohlmey_at_cmm.chem.upenn.edu   http://www.cmm.upenn.edu
   Center for Molecular Modeling   --   University of Pennsylvania
Department of Chemistry, 231 S.34th Street, Philadelphia, PA 19104-6323
tel: 1-215-898-1582,  fax: 1-215-573-6233,  office-tel: 1-215-898-5425
=======================================================================
If you make something idiot-proof, the universe creates a better idiot.