From: Axel Kohlmeyer (akohlmey_at_gmail.com)
Date: Sat Jan 17 2015 - 08:39:19 CST

this has indeed nothing to do with the file format but the fact that
coordinates in VMD are stored as single precision floating point
numbers but Tcl can only treat such numbers as double precision
floating point numbers. due to the very nature of floating point
numbers (they can represent a very large range of numbers with a
limited number of bits and thus only have a _relative_ precision
instead of an absolute precision of fixed point or integer numbers), a
lot of numbers cannot be represented and instead the closest
representable number is used instead. since floating point is stored
in a 2 based exponential format and not in the 10 based we usually
use, there are some unexpected quirks: e.g. the number 0.3 cannot be
represented exactly. this doesn't show, if the number is rounded on
output according to the available precision in the floating point
format (~7 digits in single precision, ~15 digits in double
precision), but is exposed when a single precision is promoted to
double precision and then output accordingly. you can see this very
clearly in the presented examples that they *do* represent the
original numbers if rounded to 7 digits relative precision.

since the data in a PDB flie format has even less precision storing it
in single precision internally is not diminishing the results in
anyway. it is just that when dealing with low precision data, one has
to pay attention to how it may look like when upconverted to higher
precision.

axel.

On Sat, Jan 17, 2015 at 6:57 AM, Michail Palaiokostas Avramidis
<m.palaiokostas_at_qmul.ac.uk> wrote:
> My initial answer was based on the following:
>
>
> A PDB file is a txt file with a special structure, interpreted as a
> coordinate file by special programs. Other than that, it does not include
> any "hidden" data. What you see is what you get apart maybe from some
> special format characters such as \t, \n etc.
>
>
> Having said that, the "problem" must be on the interpretation program (so in
> this case VMD). As you can also see in the TCL wiki:
> http://wiki.tcl.tk/11969 ,what you observe is normal.
>
> Just to be safe however, try to initialize the variables first.
> Alternatively, try the example of the wiki. Make two variables, 0.1 and 0.3,
> print them, sum them and see if what you get is exactly 0.400000000000.
>
>
> Best,
>
> Michalis
>
>
> -------------------------------------------------------------------
> Michail (Michalis) Palaiokostas-Avramidis
> PhD Student
> School of Engineering and Materials Science
> Queen Mary, University of London
> United Kingdom
> LinkedIn Profile
> -------------------------------------------------------------------
> ________________________________
> From: Ashar Malik <asharjm_at_gmail.com>
> Sent: Saturday, January 17, 2015 11:01 AM
> To: Michail Palaiokostas Avramidis; vmd-l_at_ks.uiuc.edu
> Subject: Re: vmd-l: Is a PDB file hiding something ???
>
> I would disagree with that.
>
> here is why:
>
> This is in the pdb:
> 71.696 112.940 -84.327
>
> after using the code the output is:
>
> {71.69599914550781 112.94000244140625 -84.3270034790039}
>
> If you observe the x-coordinates -- 71.696 is in the PDB which is being read
> into TCL by the script i sent earlier and it shows 71.695999 .,.. that means
> that PDB TEXT file was displaying a rounded off number. Where as -- somehow
> when the TCL script read the PDB TEXT file ... it produced -- 71.69599..
> which is the un-rounded off number.
>
> On Sat, Jan 17, 2015 at 11:23 PM, Michail Palaiokostas Avramidis
> <m.palaiokostas_at_qmul.ac.uk> wrote:
>>
>> Hi Ashar,
>>
>> I think that a coordinate is stored as a double precision number in the
>> memory. However the PDB file contains only a fraction of a double number's
>> decimals. Therefore the rest are filled with what the memory had before. If
>> it is important for you to have zero's in that level, I suppose you can
>> find a way to initialize the variables in a way that gives 0 for all digits.
>>
>> Hope that helps.
>>
>> Best,
>> Michail Palaiokostas
>>
>>
>>
>> ---- Ashar Malik wrote ----
>>
>>
>> Hi,
>>
>> The coordinates in the PDB file of an atom are:
>>
>> 75.146 114.983 -86.817
>>
>> using
>>
>> for {set i $first} {$i < $last} {incr i} {
>> set sel3 [atomselect top "resid $i and name C1'"]
>> puts [$sel3 get {x y z}]
>> }
>>
>> they are returned as:
>>
>> {75.14600372314453 114.98300170898438 -86.81700134277344}
>>
>> Question:
>>
>> Maybe I am missing some understanding of something here:
>>
>> How does VMD/TCL script get the higher precision??
>>
>> Any comments anyone ??
>>
>> --
>> Best,
>> /A
>
>
>
>
> --
> Best,
> /A

-- 
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.