2 not-critical bugs in analyse tool - Redmine #3206
Archive from user: Boris Timofeev
To solve the problem of building complete statistics on all angles and
dichedrals of modified DNA,
(See issue \# 3184), I had to write a small console program on C<span
class="underline"></span> using the libgromacs API.
Two bugs was found and corrected:
1.
The gmx\_conect\_addline parsing function of CONNECT fields in pdb files
appears to contain errors in the format string, due to migrating from
sprintf to std::string in 2019.4.
Must be:
static void gmx\_conect\_addline(gmx\_conect\_t \*con, char \*line)
{
int n, ai, aj;
std::string form2 = “%\*s”;
std::string format = form2 + “%d”;;
if (sscanf(line, format.c\_str(), &ai) 1)
{
do
{
form2 += "%\*s";
format = form2 + "%d";
n = sscanf(line, format.c\_str(), &aj);
if (n 1)
{
gmx\_conect\_add(con, ai - 1, aj - 1); /\* to prevent duplicated records
\*/
}
}
while (n == 1);
}
}
In “git master” branch sprintf function is used and all is right.
Gromacs **never** uses CONNECT records in pdb (source context search),
but this **is not a reason to contain knowingly inoperable code**.
2.
It is further revealed that the gmx angle for Std.deviation sometimes
returns a NAN, i.e. use sqrt from a negative number.
In a detailed review, it was revealed that:
at first, it is mathematically incorrect to calculate the mean square
deviation from the pre-calculated means,
and second, float (32 bit) accuracy is lacking even if the standard
deviation is properly calculated.
I propose the following corrections in patch attached.
*(from redmine: issue id 3206, created on 2019-11-15 by gmxdefault, closed on 2019-12-23)*
* Changesets:
* Revision 7d142404a0f41e9814e638fb87017dced1818bfb by Test User on 2019-11-25T19:10:18Z:
```
Fix duplicate CONNECT records in pdb files
When adding connect records in pdb files, it was not checked if records
already existed and were thus duplicated in output. This patch fixes
this behavior.
Fix originally provided by Boris Timofeev.
refs #3206
Change-Id: I5850f4b6279b37df07282acc4416f433099d90c8
```
* Revision 3751654612251f5c9a67c838914696975eb3be68 by Test User on 2019-12-20T12:29:26Z:
```
Remove problematic output of gmx angle
It could happen that the calculation of the standard deviation
for angles caused a divide by zero error for empty populations.
Because this standard deviation of per frame averages over all
frames was anyhow meaningless, it has been removed.
Refs #3206
Change-Id: Icf541a8b3bef502da9a22b55a8e8154b2d4fc8f8
```
* Uploads:
* [my_angle_analize.patch](/uploads/d084b8311755777c93561dbe61eead1e/my_angle_analize.patch)
* [my_angle_analize.patch](/uploads/063c03be02713f650b0cf4b7c120536d/my_angle_analize.patch)
* [pdb_analyse.cpp](/uploads/9f85701ee35930b06f9f3896584f27f9/pdb_analyse.cpp)
issue