PDB reader has been broken
This issue was created automatically from an original Mantis Issue. Further discussion may take place here.
PDBReader (ATOM and HETATM) has broken.
Format for ATOM and HETATM: |
---|
COLUMNS DATA TYPE CONTENTS |
-------------------------------------------------------------------------------- |
1 - 6 Record name "ATOM " |
7 - 11 Integer Atom serial number. |
13 - 16 Atom Atom name. |
17 Character Alternate location indicator. |
18 - 20 Residue name Residue name. |
22 Character Chain identifier. |
23 - 26 Integer Residue sequence number. |
27 AChar Code for insertion of residues. |
31 - 38 Real(8.3) Orthogonal coordinates for X in Angstroms. |
39 - 46 Real(8.3) Orthogonal coordinates for Y in Angstroms. |
47 - 54 Real(8.3) Orthogonal coordinates for Z in Angstroms. |
55 - 60 Real(6.2) Occupancy. |
61 - 66 Real(6.2) Temperature factor (Default = 0.0). |
73 - 76 LString(4) Segment identifier, left-justified. |
77 - 78 LString(2) Element symbol, right-justified. |
79 - 80 LString(2) Charge on the atom. |
________________________________________________________________________________ |
We have got a input file:
1 2 3 4 5 6 7 8
12345678901234567890123456789012345678901234567890123456789012345678901234567890 ATOM 1 HN1 THR 1 17.017 14.972 4.068 ATOM 2 HN2 THR 1 16.297 13.912 2.883 ATOM 3 N THR 1 16.982 14.095 3.587 ATOM 4 HN3 THR 1 17.707 14.470 3.008 ATOM 5 CA THR 1 16.949 12.808 4.348 ATOM 6 C THR 1 15.686 12.779 5.142 ATOM 7 O THR 1 15.236 13.827 5.603 ATOM 8 CB THR 1 18.140 12.771 5.349 ATOM 9 OG1 THR 1 19.304 12.851 4.478 ATOM 10 CG2 THR 1 18.163 11.585 6.283 ATOM 11 HOG THR 1 19.613 13.651 4.993
In vtkPDBReader.cxx:
...
line 65: while(fgets(linebuf, sizeof linebuf, fp) != NULL &&
line 66: strncmp("END", linebuf, 3))
line 67: {
line 69: char elem[3] = { 0 };
line 70: char c[7] = { 0 };
line 71: sscanf(&linebuf[0],"%6s", c);
line 72: std::string command = c;
line 73: StdStringToUpper(command);
line 74:
line 75: if (command == "ATOM" || command == "HETATM")
line 76: {
line 77: sscanf(&linebuf[12], "%4s", dum1);
line 78: sscanf(&linebuf[17], "%3s", dum2);
line 79: chain = linebuf[21];
line 80: sscanf(&linebuf[22], "%d", &resi);
line 81: sscanf(&linebuf[30],"%8f%8f%8f", x, x+1, x+2);
line 82: sscanf(&linebuf[76], "%2s", elem);
line 83:
line 84: if (elem[0] == '\0')
line 85: {
line 86: strncpy(elem, dum1, 2);
line 87: }
line 88:
line 89: if (!((elem[0]=='H' || elem[0]=='h') && elem[1]=='\0'))
...
On line 82, read the "Element symbol" than on the line 84 "elem[0] == '\0'". But in our case, "elem" has a garbage value. Maybe add check for attributes (55 >)?
... line 82: if (strlen(linebuf) > 55) line 83: sscanf(&linebuf[76], "%2s", elem); ...
Patch file attached.