unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
blob c93a9869ed1acaa51b0c6125f4a19a071345c9d4 3491 bytes (raw)
name: packages/patches/avalon-toolkit-rdkit-fixes.patch 	 # note: path name is non-authoritative(*)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
 
Patches taken from the rdkit fork at this commit (there version
AvalonToolkit_2.0.6-pre.2):
https://github.com/rdkit/ava-formake/commit/d05bee0382b8f4696b2b4b05b0038fb7d559520a

diff -ur a/src/main/C/common/reaccsio.c b/src/main/C/common/reaccsio.c
--- a/src/main/C/common/reaccsio.c
+++ b/src/main/C/common/reaccsio.c
@@ -322,34 +322,49 @@
       fprintf(fp,"\n");
 }
 
+#define MAX_BONDLINE_FIELDS 7
+#define BONDLINE_FIELD_LEN 3
+
 int ReadREACCSBond(Fortran_FILE *fp, struct reaccs_bond_t *bp)
 {
-   int nitems, i;
-   char buffer[MAX_BUFFER+1];
+   int nitems, i, j, k;
+   int bond_line_len, n_chars, pos;
+   int *ptrarray[MAX_BONDLINE_FIELDS];
+   char c;
+   char buffer[BONDLINE_FIELD_LEN+1];
 
    if (fp->status != FORTRAN_NORMAL) return(fp->status);
 
-   strncpy(buffer,fp->buffer,MAX_BUFFER);
-   /* zero pad only atom numbers! */
-   for (i=0; i<6; i++) if (buffer[i] == ' ') buffer[i] = '0';
-
    bp->stereo_symbol = 0;
    bp->dummy = 0;
    bp->topography = 0;
    bp->reaction_mark = NONE;
-   // make sure spaces are interpreted the Fortran-way
-   for (i=9; i<strlen(buffer)  &&  i<21; i+=3)
-   {
-       if ((i+1)<strlen(buffer)  &&  buffer[i+1]==' ') buffer[i+1] = '0';
-       if ((i+2)<strlen(buffer)  &&  buffer[i+2]==' ') buffer[i+2] = '0';
+   ptrarray[0] = &bp->atoms[0];
+   ptrarray[1] = &bp->atoms[1];
+   ptrarray[2] = &bp->bond_type;
+   ptrarray[3] = &bp->stereo_symbol;
+   ptrarray[4] = &bp->dummy;
+   ptrarray[5] = &bp->topography;
+   ptrarray[6] = &bp->reaction_mark;
+   bond_line_len = strlen(fp->buffer);
+   nitems = bond_line_len ? (bond_line_len - 1) / BONDLINE_FIELD_LEN + 1 : 0;
+   if (nitems > MAX_BONDLINE_FIELDS)
+      nitems = MAX_BONDLINE_FIELDS;
+   for (i = 0; i < nitems; ++i)
+   {
+      pos = i * BONDLINE_FIELD_LEN;
+      memset(buffer, 0, BONDLINE_FIELD_LEN + 1);
+      n_chars = bond_line_len - pos;
+      if (n_chars > BONDLINE_FIELD_LEN)
+         n_chars = BONDLINE_FIELD_LEN;
+      for (j = 0, k = 0; j < n_chars; ++j)
+      {
+         c = fp->buffer[pos + j];
+         if (c != ' ')
+            buffer[k++] = c;
+      }
+      sscanf(buffer, "%3d", ptrarray[i]);
    }
-   nitems = sscanf(buffer,
-                   "%3d%3d%3d%3d%3d%3d%3d",
-                   &bp->atoms[0],   &bp->atoms[1],
-                   &bp->bond_type,  &bp->stereo_symbol,
-                   &bp->dummy,
-                   &bp->topography, &bp->reaction_mark);
-
    if (nitems >= 3)
    {
       GetBuffer(fp);
@@ -1582,6 +1597,8 @@
 
    PrintREACCSMolecule(fp, mp,"");
 
+   fputc('\0', fp);
+   fflush(fp);
    rewind(fp);
 
    MolStr = _ReadFile(fp);
diff -ur a/src/main/C/programs/struchk.c b/src/main/C/programs/struchk.c
--- a/src/main/C/programs/struchk.c
+++ b/src/main/C/programs/struchk.c
@@ -1581,6 +1581,22 @@
 
    if ((result & SIZE_CHECK_FAILED) == 0)
    {
+      for (i = 0; i < mp->n_bonds; ++i) {
+         for (j = 0; j < 2; ++j) {
+            if (mp->bond_array[i].atoms[j] < 1 || mp->bond_array[i].atoms[j] > mp->n_atoms)
+            {
+               snprintf(msg_buffer, MAXMSG,
+                  "%10s    : illegal atom # (%d, max allowed is %d) in bond %d",
+                  mp->name, mp->bond_array[i].atoms[j], mp->n_atoms, i + 1);
+               AddMsgToList(msg_buffer);
+               result |= SIZE_CHECK_FAILED;
+            }
+         }
+      }
+   }
+
+   if ((result & SIZE_CHECK_FAILED) == 0)
+   {
       if (convert_atom_texts)
       {
          tmp = ConvertAtomAliases(mp);

debug log:

solving c93a9869ed1acaa51b0c6125f4a19a071345c9d4 ...
found c93a9869ed1acaa51b0c6125f4a19a071345c9d4 in https://git.savannah.gnu.org/cgit/guix.git

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).