summary refs log tree commit diff
path: root/gnu/packages/patches
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/packages/patches')
-rw-r--r--gnu/packages/patches/avalon-toolkit-rdkit-fixes.patch110
1 files changed, 110 insertions, 0 deletions
diff --git a/gnu/packages/patches/avalon-toolkit-rdkit-fixes.patch b/gnu/packages/patches/avalon-toolkit-rdkit-fixes.patch
new file mode 100644
index 0000000000..c93a9869ed
--- /dev/null
+++ b/gnu/packages/patches/avalon-toolkit-rdkit-fixes.patch
@@ -0,0 +1,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);