Subversion Repositories wimsdev

Rev

Rev 17890 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 17890 Rev 17891
Line 994... Line 994...
994
  tmfmismatch = false;    /* v0.3m */
994
  tmfmismatch = false;    /* v0.3m */
995
  auto_ssr = false;       /* v0.3n */
995
  auto_ssr = false;       /* v0.3n */
996
  recursion_depth = 0;
996
  recursion_depth = 0;
997
}
997
}
998
 
998
 
999
static inline void init_molstat (mstat)
999
static inline void init_molstat (molstat_rec *mstat)
1000
     molstat_rec *mstat;
-
 
1001
{
1000
{
1002
  /*
1001
  /*
1003
     with mstat do
1002
     with mstat do
1004
     begin
1003
     begin
1005
     n_QA := 0; n_QB := 0; n_chg := 0;
1004
     n_QA := 0; n_QB := 0; n_chg := 0;
Line 1031... Line 1030...
1031
  if (opt_debug)
1030
  if (opt_debug)
1032
    printf ("%s\n", dstr);
1031
    printf ("%s\n", dstr);
1033
}
1032
}
1034
#endif
1033
#endif
1035
 
1034
 
1036
static void left_trim (trimstr)
1035
static void left_trim (char *trimstr)
1037
  char *trimstr;
-
 
1038
{
1036
{
1039
  while (*trimstr != '\0' && (trimstr[0] == ' ' || trimstr[0] == TAB))
1037
  while (*trimstr != '\0' && (trimstr[0] == ' ' || trimstr[0] == TAB))
1040
    strdelete (trimstr, 1, 1);
1038
    strdelete (trimstr, 1, 1);
1041
}
1039
}
1042
/* left_int fixed by D. Bernardi (2020-02-01) */
1040
/* left_int fixed by D. Bernardi (2020-02-01) */
Line 1200... Line 1198...
1200
  return n;
1198
  return n;
1201
}
1199
}
1202
 
1200
 
1203
/*============================= geometry functions ========================== */
1201
/*============================= geometry functions ========================== */
1204
 
1202
 
1205
static double dist3d (p1, p2)
1203
static double dist3d (p_3d p1, p_3d p2)
1206
     p_3d p1, p2;
-
 
1207
{
1204
{
1208
  double res, TEMP, TEMP1, TEMP2;
1205
  double res, TEMP, TEMP1, TEMP2;
1209
 
1206
 
1210
  TEMP = p1.x - p2.x;
1207
  TEMP = p1.x - p2.x;
1211
  TEMP1 = p1.y - p2.y;
1208
  TEMP1 = p1.y - p2.y;
Line 1228... Line 1225...
1228
  is_cis := res;                                          (* experimentally determined
1225
  is_cis := res;                                          (* experimentally determined
1229
end;
1226
end;
1230
*/
1227
*/
1231
/* function is_cis was replaced by a new one in v0.3h */
1228
/* function is_cis was replaced by a new one in v0.3h */
1232
 
1229
 
1233
static p_3d subtract_3d (p1, p2)
1230
static p_3d subtract_3d (p_3d p1, p_3d p2)
1234
     p_3d p1, p2;
-
 
1235
{
1231
{
1236
  p_3d p;
1232
  p_3d p;
1237
 
1233
 
1238
  p.x = p1.x - p2.x;
1234
  p.x = p1.x - p2.x;
1239
  p.y = p1.y - p2.y;
1235
  p.y = p1.y - p2.y;
1240
  p.z = p1.z - p2.z;
1236
  p.z = p1.z - p2.z;
1241
  return p;
1237
  return p;
1242
}
1238
}
1243
 
1239
 
1244
static p_3d add_3d (p1, p2)
1240
static p_3d add_3d (p_3d p1, p_3d p2)
1245
     p_3d p1, p2;
-
 
1246
{
1241
{
1247
  p_3d p;
1242
  p_3d p;
1248
 
1243
 
1249
  p.x = p1.x + p2.x;
1244
  p.x = p1.x + p2.x;
1250
  p.y = p1.y + p2.y;
1245
  p.y = p1.y + p2.y;
Line 1264... Line 1259...
1264
  p1->y = 0.0;
1259
  p1->y = 0.0;
1265
  p1->z = 0.0;
1260
  p1->z = 0.0;
1266
}
1261
}
1267
#endif
1262
#endif
1268
 
1263
 
1269
static double scalar_prod (p1, p2, p3)
1264
static double scalar_prod (p_3d p1, p_3d p2, p_3d p3)
1270
     p_3d p1, p2, p3;
-
 
1271
{
1265
{
1272
  p_3d p;
1266
  p_3d p;
1273
  double res;
1267
  double res;
1274
 
1268
 
1275
  p = subtract_3d (p2, p1);
1269
  p = subtract_3d (p2, p1);
Line 1281... Line 1275...
1281
  p1.z = 0.0;
1275
  p1.z = 0.0;
1282
  res = p2.x * p3.x + p2.y * p3.y + p2.z * p3.z;
1276
  res = p2.x * p3.x + p2.y * p3.y + p2.z * p3.z;
1283
  return res;
1277
  return res;
1284
}
1278
}
1285
 
1279
 
1286
static p_3d cross_prod (p1, p2, p3)
1280
static p_3d cross_prod (p_3d p1, p_3d p2, p_3d p3)
1287
     p_3d p1, p2, p3;
-
 
1288
{
1281
{
1289
  p_3d p, orig_p1;
1282
  p_3d p, orig_p1;
1290
 
1283
 
1291
  orig_p1 = p1;
1284
  orig_p1 = p1;
1292
  p = subtract_3d (p2, p1);
1285
  p = subtract_3d (p2, p1);
Line 1297... Line 1290...
1297
  p.y = p2.z * p3.x - p2.x * p3.z;
1290
  p.y = p2.z * p3.x - p2.x * p3.z;
1298
  p.z = p2.x * p3.y - p2.y * p3.x;
1291
  p.z = p2.x * p3.y - p2.y * p3.x;
1299
  return (add_3d (orig_p1, p));
1292
  return (add_3d (orig_p1, p));
1300
}
1293
}
1301
 
1294
 
1302
static double angle_3d (p1, p2, p3)
1295
static double angle_3d (p_3d p1, p_3d p2, p_3d p3)
1303
     p_3d p1, p2, p3;
-
 
1304
{
1296
{
1305
  p_3d lp1, lp2, lp3, p;
1297
  p_3d lp1, lp2, lp3, p;
1306
  double res = 0.0;
1298
  double res = 0.0;
1307
  double magn_1, magn_2, cos_phi;
1299
  double magn_1, magn_2, cos_phi;
1308
 
1300
 
Line 1327... Line 1319...
1327
    cos_phi = 1.0;
1319
    cos_phi = 1.0;
1328
  res = acos (cos_phi);
1320
  res = acos (cos_phi);
1329
  return res;
1321
  return res;
1330
}
1322
}
1331
 
1323
 
1332
static double torsion (p1, p2, p3, p4)
1324
static double torsion (p_3d p1, p_3d p2, p_3d p3, p_3d p4)
1333
     p_3d p1, p2, p3, p4;
-
 
1334
{
1325
{
1335
  p_3d lp1, lp2, lp3, lp4, d1, c1, c2;
1326
  p_3d lp1, lp2, lp3, lp4, d1, c1, c2;
1336
  double res;
1327
  double res;
1337
  p_3d c1xc2, c2xc1;
1328
  p_3d c1xc2, c2xc1;
1338
  double dist1, dist2, sign;
1329
  double dist1, dist2, sign;
Line 1362... Line 1353...
1362
  else
1353
  else
1363
    sign = -1.0;
1354
    sign = -1.0;
1364
  return (sign * res);
1355
  return (sign * res);
1365
}
1356
}
1366
 
1357
 
1367
static double ctorsion (p1, p2, p3, p4)
1358
static double ctorsion (p_3d p1, p_3d p2, p_3d p3, p_3d p4)
1368
     p_3d p1, p2, p3, p4;
-
 
1369
{
1359
{
1370
  /* calculates "pseudo-torsion" defined by atoms 3 and 4, being both */
1360
  /* calculates "pseudo-torsion" defined by atoms 3 and 4, being both */
1371
  /* attached to atom 2, with respect to axis of atoms 1 and 2 */
1361
  /* attached to atom 2, with respect to axis of atoms 1 and 2 */
1372
  p_3d lp1, lp2, lp3, lp4;
1362
  p_3d lp1, lp2, lp3, lp4;
1373
  /*d1 : p_3d; */
1363
  /*d1 : p_3d; */
Line 1397... Line 1387...
1397
  else
1387
  else
1398
    sign = -1.0;
1388
    sign = -1.0;
1399
  return (sign * res);
1389
  return (sign * res);
1400
}
1390
}
1401
 
1391
 
1402
static boolean is_cis (p1, p2, p3, p4)
1392
static boolean is_cis (p_3d p1, p_3d p2, p_3d p3, p_3d p4)
1403
     p_3d p1, p2, p3, p4;
-
 
1404
{
1393
{
1405
  /* new in v0.3h, uses the dihedral angle */
1394
  /* new in v0.3h, uses the dihedral angle */
1406
  double phi;
1395
  double phi;
1407
  boolean res = false;
1396
  boolean res = false;
1408
 
1397
 
Line 1893... Line 1882...
1893
  ringsearch_mode = opt_rs;     /* v0.3i */
1882
  ringsearch_mode = opt_rs;     /* v0.3i */
1894
}
1883
}
1895
 
1884
 
1896
/*============== input-related functions & procedures ===================== */
1885
/*============== input-related functions & procedures ===================== */
1897
 
1886
 
1898
static char *get_filetype (Result, f)
1887
static char *get_filetype (char *Result, char *f)
1899
  char *Result;
-
 
1900
  char *f;
-
 
1901
{
1888
{
1902
  char rline[256];
1889
  char rline[256];
1903
  char auxstr[256];
1890
  char auxstr[256];
1904
  int i;
1891
  int i;
1905
  boolean mdl1 = false;
1892
  boolean mdl1 = false;
Line 2025... Line 2012...
2025
  tmp_n_bonds = 0;
2012
  tmp_n_bonds = 0;
2026
  tmp_n_rings = 0;
2013
  tmp_n_rings = 0;
2027
}
2014
}
2028
#endif
2015
#endif
2029
 
2016
 
2030
static boolean is_heavyatom (id)
2017
static boolean is_heavyatom (int id)
2031
     int id;
-
 
2032
{
2018
{
2033
  str2 el;
2019
  str2 el;
2034
 
2020
 
2035
  strcpy (el, atom[id - 1].element);
2021
  strcpy (el, atom[id - 1].element);
2036
 
2022
 
Line 2049... Line 2035...
2049
          }
2035
          }
2050
  }
2036
  }
2051
  return true;
2037
  return true;
2052
}
2038
}
2053
 
2039
 
2054
static boolean ndl_alkene_C (ba)
2040
static boolean ndl_alkene_C (int ba)
2055
     int ba;
-
 
2056
{
2041
{
2057
  /* new in v0.3f */
2042
  /* new in v0.3f */
2058
  boolean res = false;
2043
  boolean res = false;
2059
  int i, ba2, FORLIM;
2044
  int i, ba2, FORLIM;
2060
 
2045
 
Line 2074... Line 2059...
2074
          }
2059
          }
2075
  }
2060
  }
2076
  return res;
2061
  return res;
2077
}
2062
}
2078
 
2063
 
2079
static boolean is_metal (id)
2064
static boolean is_metal (int id)
2080
     int id;
-
 
2081
{
2065
{
2082
  boolean r = false;
2066
  boolean r = false;
2083
  str2 el;
2067
  str2 el;
2084
 
2068
 
2085
  strcpy (el, atom[id - 1].element);
2069
  strcpy (el, atom[id - 1].element);
Line 2099... Line 2083...
2099
    /* etc. etc. */
2083
    /* etc. etc. */
2100
    r = true;
2084
    r = true;
2101
  return r;
2085
  return r;
2102
}
2086
}
2103
 
2087
 
2104
static int get_nvalences (a_el)
2088
static int get_nvalences (char *a_el)
2105
     char *a_el;
-
 
2106
{
2089
{
2107
  /* changed name and position in v0.3m */
2090
  /* changed name and position in v0.3m */
2108
  /* preliminary version; should be extended to element/atomtype */
2091
  /* preliminary version; should be extended to element/atomtype */
2109
  int res = 1;
2092
  int res = 1;
2110
 
2093
 
Line 2169... Line 2152...
2169
  if (!strcmp (a_el, "Q "))
2152
  if (!strcmp (a_el, "Q "))
2170
    res = 4;
2153
    res = 4;
2171
  return res;
2154
  return res;
2172
}
2155
}
2173
 
2156
 
2174
static char * convert_type (Result, oldtype)
2157
static char * convert_type (char *Result, char *oldtype)
2175
     char *Result;
-
 
2176
     char *oldtype;
-
 
2177
{
2158
{
2178
  int i;
2159
  int i;
2179
  str3 newtype;
2160
  str3 newtype;
2180
 
2161
 
2181
  sprintf (newtype, "%.3s", oldtype);
2162
  sprintf (newtype, "%.3s", oldtype);
Line 2186... Line 2167...
2186
  if (newtype[0] == '*')
2167
  if (newtype[0] == '*')
2187
    strcpy (newtype, "STR");
2168
    strcpy (newtype, "STR");
2188
  return strcpy (Result, newtype);
2169
  return strcpy (Result, newtype);
2189
}
2170
}
2190
 
2171
 
2191
static char * convert_sybtype (Result, oldtype)
2172
static char * convert_sybtype (char *Result, char *oldtype)
2192
     char *Result;
-
 
2193
     char *oldtype;
-
 
2194
{
2173
{
2195
  str3 newtype;
2174
  str3 newtype;
2196
 
2175
 
2197
  /*  NewType := Copy(OldType,1,3); */
2176
  /*  NewType := Copy(OldType,1,3); */
2198
  /*  For i := 1 To 3 Do NewType[i] := UpCase(NewType[i]); */
2177
  /*  For i := 1 To 3 Do NewType[i] := UpCase(NewType[i]); */
Line 2284... Line 2263...
2284
  if (!strcmp (oldtype, "P.4  "))
2263
  if (!strcmp (oldtype, "P.4  "))
2285
    strcpy (newtype, "P4 ");
2264
    strcpy (newtype, "P4 ");
2286
  return strcpy (Result, newtype);
2265
  return strcpy (Result, newtype);
2287
}
2266
}
2288
 
2267
 
2289
static char * convert_MDLtype (Result, oldtype)
2268
static char * convert_MDLtype (char *Result, char *oldtype)
2290
     char *Result, *oldtype;
-
 
2291
{
2269
{
2292
  str3 newtype;
2270
  str3 newtype;
2293
 
2271
 
2294
  /*  NewType := Copy(OldType,1,3); */
2272
  /*  NewType := Copy(OldType,1,3); */
2295
  /*  For i := 1 To 3 Do NewType[i] := UpCase(NewType[i]); */
2273
  /*  For i := 1 To 3 Do NewType[i] := UpCase(NewType[i]); */
Line 2341... Line 2319...
2341
  if (!strcmp (oldtype, "Q  "))
2319
  if (!strcmp (oldtype, "Q  "))
2342
    strcpy (newtype, "Q  ");
2320
    strcpy (newtype, "Q  ");
2343
  return strcpy (Result, newtype);
2321
  return strcpy (Result, newtype);
2344
}
2322
}
2345
 
2323
 
2346
static char * get_element (Result, oldtype)
2324
static char * get_element (char *Result, char *oldtype)
2347
     char *Result;
-
 
2348
     char *oldtype;
-
 
2349
{
2325
{
2350
  char elemstr[256];
2326
  char elemstr[256];
2351
 
2327
 
2352
  if (!strcmp (oldtype, "H   "))
2328
  if (!strcmp (oldtype, "H   "))
2353
    strcpy (elemstr, "H ");
2329
    strcpy (elemstr, "H ");
Line 2432... Line 2408...
2432
  if (!strcmp (oldtype, "Q   "))
2408
  if (!strcmp (oldtype, "Q   "))
2433
    strcpy (elemstr, "Q ");
2409
    strcpy (elemstr, "Q ");
2434
  return strcpy (Result, elemstr);
2410
  return strcpy (Result, elemstr);
2435
}
2411
}
2436
 
2412
 
2437
static char * get_sybelement (Result, oldtype)
2413
static char * get_sybelement (char *Result,char *oldtype)
2438
     char *Result;
-
 
2439
     char *oldtype;
-
 
2440
{
2414
{
2441
  int i;
2415
  int i;
2442
  str2 elemstr;
2416
  str2 elemstr;
2443
 
2417
 
2444
  if (strpos2 (oldtype, ".", 1) < 2)
2418
  if (strpos2 (oldtype, ".", 1) < 2)
Line 2451... Line 2425...
2451
  for (i = 0; i <= 1; i++)
2425
  for (i = 0; i <= 1; i++)
2452
    elemstr[i] = toupper (elemstr[i]);
2426
    elemstr[i] = toupper (elemstr[i]);
2453
  return strcpy (Result, elemstr);
2427
  return strcpy (Result, elemstr);
2454
}
2428
}
2455
 
2429
 
2456
static char * get_MDLelement (Result, oldtype)
2430
static char * get_MDLelement (char *Result,char *oldtype)
2457
     char *Result;
-
 
2458
     char *oldtype;
-
 
2459
{
2431
{
2460
  int i;
2432
  int i;
2461
  str2 elemstr;
2433
  str2 elemstr;
2462
 
2434
 
2463
  sprintf (elemstr, "%.2s", oldtype);
2435
  sprintf (elemstr, "%.2s", oldtype);
Line 2468... Line 2440...
2468
  if (elemstr[0] == '*')
2440
  if (elemstr[0] == '*')
2469
    strcpy (elemstr, "??");
2441
    strcpy (elemstr, "??");
2470
  return strcpy (Result, elemstr);
2442
  return strcpy (Result, elemstr);
2471
}
2443
}
2472
 
2444
 
2473
static void read_molfile (mfilename)
2445
static void read_molfile (char *mfilename)
2474
     char *mfilename;
-
 
2475
{
2446
{
2476
  /* reads ALCHEMY mol files */
2447
  /* reads ALCHEMY mol files */
2477
  int n;
2448
  int n;
2478
  char rline[256], tmpstr[256];
2449
  char rline[256], tmpstr[256];
2479
  char xstr[256], ystr[256], zstr[256], chgstr[256];
2450
  char xstr[256], ystr[256], zstr[256], chgstr[256];
Line 2593... Line 2564...
2593
    ringprop[n].envelope = false;
2564
    ringprop[n].envelope = false;
2594
  }
2565
  }
2595
  li = ri + 1;
2566
  li = ri + 1;
2596
}
2567
}
2597
 
2568
 
2598
static void read_mol2file (mfilename) char *mfilename;
2569
static void read_mol2file (char *mfilename)
2599
{
2570
{
2600
  /* reads SYBYL mol2 files */
2571
  /* reads SYBYL mol2 files */
2601
  int n, code;
2572
  int n, code;
2602
  char sybatomtype[6];
2573
  char sybatomtype[6];
2603
  char tmpstr[256], rline[256];
2574
  char tmpstr[256], rline[256];
Line 2750... Line 2721...
2750
    ringprop[n].envelope = false;
2721
    ringprop[n].envelope = false;
2751
  }
2722
  }
2752
  li = ri + 1;
2723
  li = ri + 1;
2753
}
2724
}
2754
 
2725
 
2755
static void read_charges (chgstring_)
2726
static void read_charges (char *chgstring_)
2756
     char *chgstring_;
-
 
2757
{
2727
{
2758
  char chgstring[256];
2728
  char chgstring[256];
2759
  int a_id, a_chg;
2729
  int a_id, a_chg;
2760
  /* int n_chrg;*/
2730
  /* int n_chrg;*/
2761
 
2731
 
Line 2811... Line 2781...
2811
          }
2781
          }
2812
    //printf ("ISO %i, %i\n", a_id, a_nucleon_number);
2782
    //printf ("ISO %i, %i\n", a_id, a_nucleon_number);
2813
  }
2783
  }
2814
}
2784
}
2815
 
2785
 
2816
static void read_radicals (radstring_)
2786
static void read_radicals (char *radstring_)
2817
     char *radstring_;
-
 
2818
{
2787
{
2819
  char radstring[256];
2788
  char radstring[256];
2820
  int a_id, a_rad;
2789
  int a_id, a_rad;
2821
 
2790
 
2822
  /* typical example: a molecule with 2 cations + 1 anion */
2791
  /* typical example: a molecule with 2 cations + 1 anion */
Line 3382... Line 3351...
3382
  printf ("M  END\n");
3351
  printf ("M  END\n");
3383
}
3352
}
3384
 
3353
 
3385
/*============= chemical processing functions && procedures ============ */
3354
/*============= chemical processing functions && procedures ============ */
3386
 
3355
 
3387
static boolean is_electroneg (a_el)
3356
static boolean is_electroneg (char *a_el)
3388
     char *a_el;
-
 
3389
{
3357
{
3390
  /* new in v0.3j */
3358
  /* new in v0.3j */
3391
  boolean res = false;
3359
  boolean res = false;
3392
 
3360
 
3393
  if (!strcmp (a_el, "N "))
3361
  if (!strcmp (a_el, "N "))
Line 3439... Line 3407...
3439
            /*writeln('invalid molecule!'); */
3407
            /*writeln('invalid molecule!'); */
3440
          }
3408
          }
3441
  }
3409
  }
3442
}
3410
}
3443
 
3411
 
3444
static void get_neighbors (Result, id)
3412
static void get_neighbors (int *Result, int id)
3445
  int *Result;
-
 
3446
  int id;
-
 
3447
{
3413
{
3448
  int i;
3414
  int i;
3449
  //neighbor_rec nb_tmp;
3415
  //neighbor_rec nb_tmp;
3450
  int nb_count = 0;
3416
  int nb_count = 0;
3451
  //int FORLIM = n_bonds;
3417
  //int FORLIM = n_bonds;
Line 4740... Line 4706...
4740
  if (is_aryl (a_ref, nb[0]))
4706
  if (is_aryl (a_ref, nb[0]))
4741
    r = true;
4707
    r = true;
4742
  return r;
4708
  return r;
4743
}
4709
}
4744
 
4710
 
4745
static boolean is_alkenylsulfanyl (a_view, a_ref)
4711
static boolean is_alkenylsulfanyl (int a_view, int a_ref)
4746
     int a_view, a_ref;
-
 
4747
{
4712
{
4748
  /* v0.3j */
4713
  /* v0.3j */
4749
  boolean r = false;
4714
  boolean r = false;
4750
  neighbor_rec nb;
4715
  neighbor_rec nb;
4751
 
4716
 
Line 4760... Line 4725...
4760
  if (is_alkenyl (a_ref, nb[0]))
4725
  if (is_alkenyl (a_ref, nb[0]))
4761
    r = true;
4726
    r = true;
4762
  return r;
4727
  return r;
4763
}
4728
}
4764
 
4729
 
4765
static boolean is_alkynylsulfanyl (a_view, a_ref)
4730
static boolean is_alkynylsulfanyl (int a_view, int a_ref)
4766
     int a_view, a_ref;
-
 
4767
{
4731
{
4768
  /* v0.3j */
4732
  /* v0.3j */
4769
  boolean r = false;
4733
  boolean r = false;
4770
  neighbor_rec nb;
4734
  neighbor_rec nb;
4771
 
4735
 
Line 4780... Line 4744...
4780
  if (is_alkynyl (a_ref, nb[0]))
4744
  if (is_alkynyl (a_ref, nb[0]))
4781
    r = true;
4745
    r = true;
4782
  return r;
4746
  return r;
4783
}
4747
}
4784
 
4748
 
4785
static boolean is_alkylamino (a_view, a_ref)
4749
static boolean is_alkylamino (int a_view, int a_ref)
4786
     int a_view, a_ref;
-
 
4787
{
4750
{
4788
  boolean r = false;
4751
  boolean r = false;
4789
  neighbor_rec nb;
4752
  neighbor_rec nb;
4790
  int alkyl_count = 0;
4753
  int alkyl_count = 0;
4791
 
4754
 
Line 4802... Line 4765...
4802
  if (alkyl_count == 1)
4765
  if (alkyl_count == 1)
4803
    r = true;
4766
    r = true;
4804
  return r;
4767
  return r;
4805
}
4768
}
4806
 
4769
 
4807
static boolean is_dialkylamino (a_view, a_ref)
4770
static boolean is_dialkylamino (int a_view, int a_ref)
4808
     int a_view, a_ref;
-
 
4809
{
4771
{
4810
  int i;
4772
  int i;
4811
  boolean r = false;
4773
  boolean r = false;
4812
  neighbor_rec nb;
4774
  neighbor_rec nb;
4813
  int alkyl_count = 0;
4775
  int alkyl_count = 0;
Line 4827... Line 4789...
4827
  if (alkyl_count == 2)
4789
  if (alkyl_count == 2)
4828
    r = true;
4790
    r = true;
4829
  return r;
4791
  return r;
4830
}
4792
}
4831
 
4793
 
4832
static boolean is_arylamino (a_view, a_ref)
4794
static boolean is_arylamino (int a_view, int a_ref)
4833
     int a_view, a_ref;
-
 
4834
{
4795
{
4835
  boolean r = false;
4796
  boolean r = false;
4836
  neighbor_rec nb;
4797
  neighbor_rec nb;
4837
  int aryl_count = 0;
4798
  int aryl_count = 0;
4838
 
4799
 
Line 4849... Line 4810...
4849
  if (aryl_count == 1)
4810
  if (aryl_count == 1)
4850
    r = true;
4811
    r = true;
4851
  return r;
4812
  return r;
4852
}
4813
}
4853
 
4814
 
4854
static boolean is_diarylamino (a_view, a_ref)
4815
static boolean is_diarylamino (int a_view, int a_ref)
4855
     int a_view, a_ref;
-
 
4856
{
4816
{
4857
  int i;
4817
  int i;
4858
  boolean r = false;
4818
  boolean r = false;
4859
  neighbor_rec nb;
4819
  neighbor_rec nb;
4860
  int aryl_count = 0;
4820
  int aryl_count = 0;
Line 4874... Line 4834...
4874
  if (aryl_count == 2)
4834
  if (aryl_count == 2)
4875
    r = true;
4835
    r = true;
4876
  return r;
4836
  return r;
4877
}
4837
}
4878
 
4838
 
4879
static boolean is_alkylarylamino (a_view, a_ref)
4839
static boolean is_alkylarylamino (int a_view, int a_ref)
4880
     int a_view, a_ref;
-
 
4881
{
4840
{
4882
  int i;
4841
  int i;
4883
  boolean r = false;
4842
  boolean r = false;
4884
  neighbor_rec nb;
4843
  neighbor_rec nb;
4885
  int alkyl_count = 0, aryl_count = 0;
4844
  int alkyl_count = 0, aryl_count = 0;
Line 4901... Line 4860...
4901
  if (alkyl_count == 1 && aryl_count == 1)
4860
  if (alkyl_count == 1 && aryl_count == 1)
4902
    r = true;
4861
    r = true;
4903
  return r;
4862
  return r;
4904
}
4863
}
4905
 
4864
 
4906
static boolean is_C_monosubst_amino (a_view, a_ref)
4865
static boolean is_C_monosubst_amino (int a_view, int a_ref)
4907
     int a_view, a_ref;
-
 
4908
{
4866
{
4909
  /* new in v0.3j */
4867
  /* new in v0.3j */
4910
  boolean r = false;
4868
  boolean r = false;
4911
  neighbor_rec nb;
4869
  neighbor_rec nb;
4912
  int c_count = 0;
4870
  int c_count = 0;
Line 4925... Line 4883...
4925
  if (c_count == 1)
4883
  if (c_count == 1)
4926
    r = true;
4884
    r = true;
4927
  return r;
4885
  return r;
4928
}
4886
}
4929
 
4887
 
4930
static boolean is_C_disubst_amino (a_view, a_ref)
4888
static boolean is_C_disubst_amino (int a_view, int a_ref)
4931
     int a_view, a_ref;
-
 
4932
{
4889
{
4933
  /* new in v0.3j */
4890
  /* new in v0.3j */
4934
  int i;
4891
  int i;
4935
  boolean r = false;
4892
  boolean r = false;
4936
  neighbor_rec nb;
4893
  neighbor_rec nb;
Line 4954... Line 4911...
4954
  if (c_count == 2)
4911
  if (c_count == 2)
4955
    r = true;
4912
    r = true;
4956
  return r;
4913
  return r;
4957
}
4914
}
4958
 
4915
 
4959
static boolean is_subst_amino (a_view, a_ref)
4916
static boolean is_subst_amino (int a_view, int a_ref)
4960
     int a_view, a_ref;
-
 
4961
{
4917
{
4962
  boolean r = false;
4918
  boolean r = false;
4963
 
4919
 
4964
  if (is_amino (a_view, a_ref) || is_alkylamino (a_view, a_ref) |
4920
  if (is_amino (a_view, a_ref) || is_alkylamino (a_view, a_ref) |
4965
      is_arylamino (a_view, a_ref) || is_dialkylamino (a_view, a_ref) |
4921
      is_arylamino (a_view, a_ref) || is_dialkylamino (a_view, a_ref) |
4966
      is_alkylarylamino (a_view, a_ref) || is_diarylamino (a_view, a_ref))
4922
      is_alkylarylamino (a_view, a_ref) || is_diarylamino (a_view, a_ref))
4967
    r = true;
4923
    r = true;
4968
  return r;
4924
  return r;
4969
}
4925
}
4970
 
4926
 
4971
static boolean is_true_alkylamino (a_view, a_ref)
4927
static boolean is_true_alkylamino (int a_view, int a_ref)
4972
     int a_view, a_ref;
-
 
4973
{
4928
{
4974
  boolean r = false;
4929
  boolean r = false;
4975
  neighbor_rec nb;
4930
  neighbor_rec nb;
4976
  int alkyl_count = 0;
4931
  int alkyl_count = 0;
4977
 
4932
 
Line 4989... Line 4944...
4989
  if (alkyl_count == 1)
4944
  if (alkyl_count == 1)
4990
    r = true;
4945
    r = true;
4991
  return r;
4946
  return r;
4992
}
4947
}
4993
 
4948
 
4994
static boolean is_true_dialkylamino (a_view, a_ref)
4949
static boolean is_true_dialkylamino (int a_view, int a_ref)
4995
     int a_view, a_ref;
-
 
4996
{
4950
{
4997
  int i;
4951
  int i;
4998
  boolean r = false;
4952
  boolean r = false;
4999
  neighbor_rec nb;
4953
  neighbor_rec nb;
5000
  int alkyl_count = 0;
4954
  int alkyl_count = 0;
Line 5016... Line 4970...
5016
    r = true;
4970
    r = true;
5017
  return r;
4971
  return r;
5018
}
4972
}
5019
 
4973
 
5020
#if 0
4974
#if 0
5021
static boolean is_true_alkylarylamino (a_view, a_ref)
4975
static boolean is_true_alkylarylamino (int a_view, int a_ref)
5022
     int a_view, a_ref;
-
 
5023
{
4976
{
5024
  int i;
4977
  int i;
5025
  boolean r = false;
4978
  boolean r = false;
5026
  neighbor_rec nb;
4979
  neighbor_rec nb;
5027
  int alkyl_count = 0, aryl_count = 0;
4980
  int alkyl_count = 0, aryl_count = 0;
Line 5045... Line 4998...
5045
    r = true;
4998
    r = true;
5046
  return r;
4999
  return r;
5047
}
5000
}
5048
#endif
5001
#endif
5049
 
5002
 
5050
static boolean is_hydroxylamino (a_view, a_ref)
5003
static boolean is_hydroxylamino (int a_view, int a_ref)
5051
     int a_view, a_ref;
-
 
5052
{
5004
{
5053
  int i;
5005
  int i;
5054
  boolean r = false;
5006
  boolean r = false;
5055
  neighbor_rec nb;
5007
  neighbor_rec nb;
5056
  int oh_count = 0, het_count = 0;      /* v0.3k */
5008
  int oh_count = 0, het_count = 0;      /* v0.3k */
Line 5081... Line 5033...
5081
  if (oh_count == 1 && het_count == 1)
5033
  if (oh_count == 1 && het_count == 1)
5082
    r = true;
5034
    r = true;
5083
  return r;
5035
  return r;
5084
}
5036
}
5085
 
5037
 
5086
static boolean is_nitro (a_view, a_ref)
5038
static boolean is_nitro (int a_view, int a_ref)
5087
     int a_view, a_ref;
-
 
5088
{
5039
{
5089
  int i;
5040
  int i;
5090
  boolean r = false;
5041
  boolean r = false;
5091
  neighbor_rec nb;
5042
  neighbor_rec nb;
5092
  int o_count = 0, bond_count = 0;
5043
  int o_count = 0, bond_count = 0;
Line 5110... Line 5061...
5110
  if (o_count == 2 && bond_count >= 3)
5061
  if (o_count == 2 && bond_count >= 3)
5111
    r = true;
5062
    r = true;
5112
  return r;
5063
  return r;
5113
}
5064
}
5114
 
5065
 
5115
static boolean is_azido (a_view, a_ref)
5066
static boolean is_azido (int a_view, int a_ref)
5116
     int a_view, a_ref;
-
 
5117
{
5067
{
5118
  boolean r = false;
5068
  boolean r = false;
5119
  neighbor_rec nb;
5069
  neighbor_rec nb;
5120
  int bond_count = 0, n1 = 0, n2 = 0, n3 = 0;
5070
  int bond_count = 0, n1 = 0, n2 = 0, n3 = 0;
5121
 
5071
 
Line 5154... Line 5104...
5154
      bond_count > 3)
5104
      bond_count > 3)
5155
    r = true;
5105
    r = true;
5156
  return r;
5106
  return r;
5157
}
5107
}
5158
 
5108
 
5159
static boolean is_diazonium (a_view, a_ref)
5109
static boolean is_diazonium (int a_view, int a_ref)
5160
     int a_view, a_ref;
-
 
5161
{
5110
{
5162
  boolean r = false;
5111
  boolean r = false;
5163
  neighbor_rec nb;
5112
  neighbor_rec nb;
5164
  int bond_count = 0, chg_count = 0, n1 = 0, n2 = 0;
5113
  int bond_count = 0, chg_count = 0, n1 = 0, n2 = 0;
5165
 
5114
 
Line 5187... Line 5136...
5187
      && bond_count >= 2 && chg_count > 0)
5136
      && bond_count >= 2 && chg_count > 0)
5188
    r = true;
5137
    r = true;
5189
  return r;
5138
  return r;
5190
}
5139
}
5191
 
5140
 
5192
static boolean is_hydroximino_C (id)
5141
static boolean is_hydroximino_C (int id)
5193
     int id;
-
 
5194
{
5142
{
5195
  int i;
5143
  int i;
5196
  boolean r = false;
5144
  boolean r = false;
5197
  neighbor_rec nb;
5145
  neighbor_rec nb;
5198
  int a_het = 0;
5146
  int a_het = 0;
Line 5223... Line 5171...
5223
          r = true;
5171
          r = true;
5224
  }
5172
  }
5225
  return r;
5173
  return r;
5226
}
5174
}
5227
 
5175
 
5228
static boolean is_hydrazono_C (id)
5176
static boolean is_hydrazono_C (int id)
5229
     int id;
-
 
5230
{
5177
{
5231
  int i;
5178
  int i;
5232
  boolean r = false;
5179
  boolean r = false;
5233
  neighbor_rec nb;
5180
  neighbor_rec nb;
5234
  int a_het = 0;
5181
  int a_het = 0;
Line 5264... Line 5211...
5264
            r = true;
5211
            r = true;
5265
  }
5212
  }
5266
  return r;
5213
  return r;
5267
}
5214
}
5268
 
5215
 
5269
static boolean is_alkoxycarbonyl (a_view, a_ref)
5216
static boolean is_alkoxycarbonyl (int a_view, int a_ref)
5270
     int a_view, a_ref;
-
 
5271
{
5217
{
5272
  int i;
5218
  int i;
5273
  boolean r = false;
5219
  boolean r = false;
5274
  neighbor_rec nb;
5220
  neighbor_rec nb;
5275
 
5221
 
Line 5284... Line 5230...
5284
            r = true;
5230
            r = true;
5285
  }
5231
  }
5286
  return r;
5232
  return r;
5287
}
5233
}
5288
 
5234
 
5289
static boolean is_aryloxycarbonyl (a_view, a_ref)
5235
static boolean is_aryloxycarbonyl (int a_view, int a_ref)
5290
     int a_view, a_ref;
-
 
5291
{
5236
{
5292
  int i;
5237
  int i;
5293
  boolean r = false;
5238
  boolean r = false;
5294
  neighbor_rec nb;
5239
  neighbor_rec nb;
5295
 
5240
 
Line 5305... Line 5250...
5305
            r = true;
5250
            r = true;
5306
  }
5251
  }
5307
  return r;
5252
  return r;
5308
}
5253
}
5309
 
5254
 
5310
static boolean is_carbamoyl (a_view, a_ref)
5255
static boolean is_carbamoyl (int a_view, int a_ref)
5311
     int a_view, a_ref;
-
 
5312
{
5256
{
5313
  int i;
5257
  int i;
5314
  boolean r = false;
5258
  boolean r = false;
5315
  neighbor_rec nb;
5259
  neighbor_rec nb;
5316
 
5260
 
Line 5326... Line 5270...
5326
            r = true;
5270
            r = true;
5327
  }
5271
  }
5328
  return r;
5272
  return r;
5329
}
5273
}
5330
 
5274
 
5331
static boolean is_alkoxythiocarbonyl (a_view, a_ref)
5275
static boolean is_alkoxythiocarbonyl (int a_view, int a_ref)
5332
     int a_view, a_ref;
-
 
5333
{
5276
{
5334
  int i;
5277
  int i;
5335
  boolean r = false;
5278
  boolean r = false;
5336
  neighbor_rec nb;
5279
  neighbor_rec nb;
5337
 
5280
 
Line 5346... Line 5289...
5346
            r = true;
5289
            r = true;
5347
  }
5290
  }
5348
  return r;
5291
  return r;
5349
}
5292
}
5350
 
5293
 
5351
static boolean is_aryloxythiocarbonyl (a_view, a_ref)
5294
static boolean is_aryloxythiocarbonyl (int a_view, int a_ref)
5352
     int a_view, a_ref;
-
 
5353
{
5295
{
5354
  int i;
5296
  int i;
5355
  boolean r = false;
5297
  boolean r = false;
5356
  neighbor_rec nb;
5298
  neighbor_rec nb;
5357
 
5299
 
Line 5366... Line 5308...
5366
            r = true;
5308
            r = true;
5367
  }
5309
  }
5368
  return r;
5310
  return r;
5369
}
5311
}
5370
 
5312
 
5371
static boolean is_thiocarbamoyl (a_view, a_ref)
5313
static boolean is_thiocarbamoyl (int a_view, int a_ref)
5372
     int a_view, a_ref;
-
 
5373
{
5314
{
5374
  int i;
5315
  int i;
5375
  boolean r = false;
5316
  boolean r = false;
5376
  neighbor_rec nb;
5317
  neighbor_rec nb;
5377
 
5318
 
Line 5388... Line 5329...
5388
            r = true;
5329
            r = true;
5389
  }
5330
  }
5390
  return r;
5331
  return r;
5391
}
5332
}
5392
 
5333
 
5393
static boolean is_alkanoyl (a_view, a_ref)
5334
static boolean is_alkanoyl (int a_view, int a_ref)
5394
     int a_view, a_ref;
-
 
5395
{
5335
{
5396
  int i;
5336
  int i;
5397
  boolean r = false;
5337
  boolean r = false;
5398
  neighbor_rec nb;
5338
  neighbor_rec nb;
5399
 
5339
 
Line 5409... Line 5349...
5409
            r = true;
5349
            r = true;
5410
  }
5350
  }
5411
  return r;
5351
  return r;
5412
}
5352
}
5413
 
5353
 
5414
static boolean is_aroyl (a_view, a_ref)
5354
static boolean is_aroyl (int a_view, int a_ref)
5415
     int a_view, a_ref;
-
 
5416
{
5355
{
5417
  int i;
5356
  int i;
5418
  boolean r = false;
5357
  boolean r = false;
5419
  neighbor_rec nb;
5358
  neighbor_rec nb;
5420
 
5359
 
Line 5430... Line 5369...
5430
            r = true;
5369
            r = true;
5431
  }
5370
  }
5432
  return r;
5371
  return r;
5433
}
5372
}
5434
 
5373
 
5435
static boolean is_acyl (a_view, a_ref)
5374
static boolean is_acyl (int a_view, int a_ref)
5436
     int a_view, a_ref;
-
 
5437
{
5375
{
5438
  boolean r = false;
5376
  boolean r = false;
5439
 
5377
 
5440
  if (is_alkanoyl (a_view, a_ref) || is_aroyl (a_view, a_ref))
5378
  if (is_alkanoyl (a_view, a_ref) || is_aroyl (a_view, a_ref))
5441
    r = true;
5379
    r = true;
5442
  return r;
5380
  return r;
5443
}
5381
}
5444
 
5382
 
5445
static boolean is_acyl_gen (a_view, a_ref)
5383
static boolean is_acyl_gen (int a_view, int a_ref)
5446
     int a_view, a_ref;
-
 
5447
{
5384
{
5448
  /* new in v0.3j */
5385
  /* new in v0.3j */
5449
  boolean r = false;
5386
  boolean r = false;
5450
 
5387
 
5451
  if (is_oxo_C (a_ref))
5388
  if (is_oxo_C (a_ref))
5452
    r = true;
5389
    r = true;
5453
  return r;
5390
  return r;
5454
}
5391
}
5455
 
5392
 
5456
static boolean is_acylamino (a_view, a_ref)
5393
static boolean is_acylamino (int a_view, int a_ref)
5457
     int a_view, a_ref;
-
 
5458
{
5394
{
5459
  boolean r = false;
5395
  boolean r = false;
5460
  neighbor_rec nb;
5396
  neighbor_rec nb;
5461
  int acyl_count = 0;
5397
  int acyl_count = 0;
5462
 
5398
 
Line 5473... Line 5409...
5473
  if (acyl_count == 1)
5409
  if (acyl_count == 1)
5474
    r = true;
5410
    r = true;
5475
  return r;
5411
  return r;
5476
}
5412
}
5477
 
5413
 
5478
static boolean is_subst_acylamino (a_view, a_ref)
5414
static boolean is_subst_acylamino (int a_view, int a_ref)
5479
     int a_view, a_ref;
-
 
5480
{
5415
{
5481
  /* may be substituted _or_ unsubstituted acylamino group! */
5416
  /* may be substituted _or_ unsubstituted acylamino group! */
5482
  int i;
5417
  int i;
5483
  boolean r = false;
5418
  boolean r = false;
5484
  neighbor_rec nb;
5419
  neighbor_rec nb;
Line 5501... Line 5436...
5501
  if (acyl_count > 0)
5436
  if (acyl_count > 0)
5502
    r = true;
5437
    r = true;
5503
  return r;
5438
  return r;
5504
}
5439
}
5505
 
5440
 
5506
static boolean is_hydrazino (a_view, a_ref)
5441
static boolean is_hydrazino (int a_view, int a_ref)
5507
     int a_view, a_ref;
-
 
5508
{
5442
{
5509
  int i;
5443
  int i;
5510
  boolean r = false;
5444
  boolean r = false;
5511
  neighbor_rec nb;
5445
  neighbor_rec nb;
5512
  int nr_count = 0;
5446
  int nr_count = 0;
Line 5528... Line 5462...
5528
  if (nr_count == 1)
5462
  if (nr_count == 1)
5529
    r = true;
5463
    r = true;
5530
  return r;
5464
  return r;
5531
}
5465
}
5532
 
5466
 
5533
static boolean is_nitroso (a_view, a_ref)
5467
static boolean is_nitroso (int a_view, int a_ref)
5534
     int a_view, a_ref;
-
 
5535
{
5468
{
5536
  /* new in v0.3j */
5469
  /* new in v0.3j */
5537
  boolean r = false;
5470
  boolean r = false;
5538
  neighbor_rec nb;
5471
  neighbor_rec nb;
5539
  int o_count = 0;
5472
  int o_count = 0;
Line 5546... Line 5479...
5546
  if (strcmp (atom[a_ref - 1].element, "N ")
5479
  if (strcmp (atom[a_ref - 1].element, "N ")
5547
      || atom[a_ref - 1].neighbor_count != 2)
5480
      || atom[a_ref - 1].neighbor_count != 2)
5548
    return false;
5481
    return false;
5549
  get_nextneighbors (nb, a_ref, a_view);
5482
  get_nextneighbors (nb, a_ref, a_view);
5550
  a2 = nb[0];
5483
  a2 = nb[0];
5551
  if ((strcmp (atom[a2 - 1].element, "O ") == 0) &
5484
  if ((strcmp (atom[a2 - 1].element, "O ") == 0) &&
5552
      (bond[get_bond (a_ref, a2) - 1].btype == 'D'))
5485
      (bond[get_bond (a_ref, a2) - 1].btype == 'D'))
5553
    o_count++;
5486
    o_count++;
5554
  if (o_count == 1)
5487
  if (o_count == 1)
5555
    r = true;
5488
    r = true;
5556
  return r;
5489
  return r;
5557
}
5490
}
5558
 
5491
 
5559
static boolean is_subst_hydrazino (a_view, a_ref)
5492
static boolean is_subst_hydrazino (int a_view, int a_ref)
5560
     int a_view, a_ref;
-
 
5561
{
5493
{
5562
  int i;
5494
  int i;
5563
  boolean r = false;
5495
  boolean r = false;
5564
  neighbor_rec nb;
5496
  neighbor_rec nb;
5565
  int nr_count = 0;
5497
  int nr_count = 0;
Line 5583... Line 5515...
5583
  if (nr_count == 1)
5515
  if (nr_count == 1)
5584
    r = true;
5516
    r = true;
5585
  return r;
5517
  return r;
5586
}
5518
}
5587
 
5519
 
5588
static boolean is_cyano (a_view, a_ref)
5520
static boolean is_cyano (int a_view, int a_ref)
5589
     int a_view, a_ref;
-
 
5590
{
5521
{
5591
  boolean r = false;
5522
  boolean r = false;
5592
 
5523
 
5593
  if (((strcmp (atom[a_view - 1].atype, "C1 ") == 0) &
5524
  if (((strcmp (atom[a_view - 1].atype, "C1 ") == 0) &&
5594
      (bond[get_bond (a_view, a_ref) - 1].btype == 'T')) &&
5525
      (bond[get_bond (a_view, a_ref) - 1].btype == 'T')) &&
5595
      !strcmp (atom[a_ref - 1].atype, "N1 ") &&
5526
      !strcmp (atom[a_ref - 1].atype, "N1 ") &&
5596
      atom[a_ref - 1].neighbor_count == 1)
5527
      atom[a_ref - 1].neighbor_count == 1)
5597
    r = true;
5528
    r = true;
5598
  return r;
5529
  return r;
5599
}
5530
}
5600
 
5531
 
5601
static boolean is_cyano_c (a_ref)
5532
static boolean is_cyano_c (int a_ref)
5602
     int a_ref;
-
 
5603
{
5533
{
5604
  int i;
5534
  int i;
5605
  boolean r = false;
5535
  boolean r = false;
5606
  neighbor_rec nb;
5536
  neighbor_rec nb;
5607
  int FORLIM;
5537
  int FORLIM;
Line 5617... Line 5547...
5617
            r = true;
5547
            r = true;
5618
  }
5548
  }
5619
  return r;
5549
  return r;
5620
}
5550
}
5621
 
5551
 
5622
static boolean is_nitrile (a_view, a_ref)
5552
static boolean is_nitrile (int a_view, int a_ref)
5623
     int a_view, a_ref;
-
 
5624
{
5553
{
5625
  boolean r = false;
5554
  boolean r = false;
5626
  neighbor_rec nb;
5555
  neighbor_rec nb;
5627
  str2 nb_el;
5556
  str2 nb_el;
5628
 
5557
 
Line 5640... Line 5569...
5640
    r = true;
5569
    r = true;
5641
  /* HCN is also a nitrile! */
5570
  /* HCN is also a nitrile! */
5642
  return r;
5571
  return r;
5643
}
5572
}
5644
 
5573
 
5645
static boolean is_isonitrile (a_view, a_ref)
5574
static boolean is_isonitrile (int a_view, int a_ref)
5646
     int a_view, a_ref;
-
 
5647
{
5575
{
5648
  /* only recognized with CN triple bond! */
5576
  /* only recognized with CN triple bond! */
5649
  boolean r = false;
5577
  boolean r = false;
5650
 
5578
 
5651
  if (((strcmp (atom[a_view - 1].atype, "C1 ") == 0) &&
5579
  if (((strcmp (atom[a_view - 1].atype, "C1 ") == 0) &&
Line 5655... Line 5583...
5655
      && atom[a_view - 1].neighbor_count == 1)
5583
      && atom[a_view - 1].neighbor_count == 1)
5656
    r = true;
5584
    r = true;
5657
  return r;
5585
  return r;
5658
}
5586
}
5659
 
5587
 
5660
static boolean is_cyanate (a_view, a_ref)
5588
static boolean is_cyanate (int a_view, int a_ref)
5661
     int a_view, a_ref;
-
 
5662
{
5589
{
5663
  boolean r = false;
5590
  boolean r = false;
5664
  neighbor_rec nb;
5591
  neighbor_rec nb;
5665
 
5592
 
5666
  if (!is_cyano (a_view, a_ref))
5593
  if (!is_cyano (a_view, a_ref))
Line 5671... Line 5598...
5671
  if (is_alkoxy (a_view, nb[0]) || is_aryloxy (a_view, nb[0]))
5598
  if (is_alkoxy (a_view, nb[0]) || is_aryloxy (a_view, nb[0]))
5672
    r = true;
5599
    r = true;
5673
  return r;
5600
  return r;
5674
}
5601
}
5675
 
5602
 
5676
static boolean is_thiocyanate (a_view, a_ref)
5603
static boolean is_thiocyanate (int a_view, int a_ref)
5677
     int a_view, a_ref;
-
 
5678
{
5604
{
5679
  boolean r = false;
5605
  boolean r = false;
5680
  neighbor_rec nb;
5606
  neighbor_rec nb;
5681
 
5607
 
5682
  if (!is_cyano (a_view, a_ref))
5608
  if (!is_cyano (a_view, a_ref))
Line 6310... Line 6236...
6310
    if (aromatic) printf (" (aromatic)");
6236
    if (aromatic) printf (" (aromatic)");
6311
    putchar ('\n');
6237
    putchar ('\n');
6312
  }
6238
  }
6313
}
6239
}
6314
 
6240
 
6315
static void chk_so2_deriv (a_ref)
6241
static void chk_so2_deriv (int a_ref)
6316
     int a_ref;
-
 
6317
{
6242
{
6318
  int i;
6243
  int i;
6319
  neighbor_rec nb;
6244
  neighbor_rec nb;
6320
  str2 nb_el;
6245
  str2 nb_el;
6321
  int het_count = 0, o_count = 0, or_count = 0, hal_count = 0, n_count = 0,
6246
  int het_count = 0, o_count = 0, or_count = 0, hal_count = 0, n_count = 0,
Line 6384... Line 6309...
6384
  }
6309
  }
6385
  if (het_count == 0 && c_count == 2)   /* sulfone */
6310
  if (het_count == 0 && c_count == 2)   /* sulfone */
6386
    fg[fg_sulfone - 1] = true;
6311
    fg[fg_sulfone - 1] = true;
6387
}
6312
}
6388
 
6313
 
6389
static void chk_p_deriv (a_ref)
6314
static void chk_p_deriv (int a_ref)
6390
     int a_ref;
-
 
6391
{
6315
{
6392
  int i;
6316
  int i;
6393
  neighbor_rec nb;
6317
  neighbor_rec nb;
6394
  str2 nb_el, dbl_het;
6318
  str2 nb_el, dbl_het;
6395
  int het_count;
6319
  int het_count;
Line 6470... Line 6394...
6470
    fg[fg_phosphine - 1] = true;
6394
    fg[fg_phosphine - 1] = true;
6471
  if (c_count == 3 && oh_count == 1)
6395
  if (c_count == 3 && oh_count == 1)
6472
    fg[fg_phosphinoxide - 1] = true;
6396
    fg[fg_phosphinoxide - 1] = true;
6473
}
6397
}
6474
 
6398
 
6475
static void chk_b_deriv (a_ref)
6399
static void chk_b_deriv (int a_ref)
6476
     int a_ref;
-
 
6477
{
6400
{
6478
  int i;
6401
  int i;
6479
  neighbor_rec nb;
6402
  neighbor_rec nb;
6480
  str2 nb_el;
6403
  str2 nb_el;
6481
  int het_count = 0, oh_count = 0, or_count = 0, hal_count = 0, n_count = 0,
6404
  int het_count = 0, oh_count = 0, or_count = 0, hal_count = 0, n_count = 0,
6482
    c_count = 0;
6405
    c_count = 0;
6483
  int FORLIM;
6406
  int FORLIM;
6484
 
6407
 
6485
  if (strcmp (atom[a_ref - 1].element, "B "))
6408
  if (strcmp (atom[a_ref - 1].element, "B "))
6486
    return;
6409
    return;
6487
  memset (nb, 0, sizeof (neighbor_rec));
6410
  memset (nb, 0, sizeof (neighbor_rec));
6488
  get_neighbors (nb, a_ref);
6411
  get_neighbors (nb, a_ref);
6489
  FORLIM = atom[a_ref - 1].neighbor_count;
6412
  FORLIM = atom[a_ref - 1].neighbor_count;
6490
  for (i = 0; i < FORLIM; i++) {
6413
  for (i = 0; i < FORLIM; i++) {
6491
    if (bond[get_bond (a_ref, nb[i]) - 1].btype == 'S') {
6414
    if (bond[get_bond (a_ref, nb[i]) - 1].btype == 'S') {
Line 6516... Line 6439...
6516
  fg[fg_boronic_acid_deriv - 1] = true;
6439
  fg[fg_boronic_acid_deriv - 1] = true;
6517
  if (oh_count == 2)
6440
  if (oh_count == 2)
6518
    fg[fg_boronic_acid - 1] = true;
6441
    fg[fg_boronic_acid - 1] = true;
6519
  if (or_count > 0)
6442
  if (or_count > 0)
6520
    fg[fg_boronic_acid_ester - 1] = true;
6443
    fg[fg_boronic_acid_ester - 1] = true;
6521
}
6444
}
6522
 
6445
 
6523
static void chk_ammon (a_ref)
6446
static void chk_ammon (int a_ref)
6524
     int a_ref;
-
 
6525
{
6447
{
6526
  int i;
6448
  int i;
6527
  neighbor_rec nb;
6449
  neighbor_rec nb;
6528
  str2 nb_el;
6450
  str2 nb_el;
6529
  int het_count = 0, o_count = 0, or_count = 0, r_count = 0;
6451
  int het_count = 0, o_count = 0, or_count = 0, r_count = 0;
Line 6585... Line 6507...
6585
  if (((o_count == 1 && or_count == 1) || o_count == 0) &&
6507
  if (((o_count == 1 && or_count == 1) || o_count == 0) &&
6586
      atom[a_ref - 1].arom == true)
6508
      atom[a_ref - 1].arom == true)
6587
    fg[fg_quart_ammonium - 1] = true;
6509
    fg[fg_quart_ammonium - 1] = true;
6588
}
6510
}
6589
 
6511
 
6590
static void swap_atoms (a1, a2)
6512
static void swap_atoms (int *a1, int *a2)
6591
     int *a1, *a2;
-
 
6592
{
6513
{
6593
  int a_tmp;
6514
  int a_tmp;
6594
 
6515
 
6595
  a_tmp = *a1;
6516
  a_tmp = *a1;
6596
  *a1 = *a2;
6517
  *a1 = *a2;
6597
  *a2 = a_tmp;
6518
  *a2 = a_tmp;
6598
}
6519
}
6599
 
6520
 
6600
static void orient_bond (a1, a2)
6521
static void orient_bond (int *a1, int *a2)
6601
     int *a1, *a2;
-
 
6602
{
6522
{
6603
  str2 a1_el, a2_el;
6523
  str2 a1_el, a2_el;
6604
 
6524
 
6605
  strcpy (a1_el, atom[*a1 - 1].element);
6525
  strcpy (a1_el, atom[*a1 - 1].element);
6606
  strcpy (a2_el, atom[*a2 - 1].element);
6526
  strcpy (a2_el, atom[*a2 - 1].element);
Line 6625... Line 6545...
6625
              atom[*a1 - 1].neighbor_count - hetbond_count (*a1))
6545
              atom[*a1 - 1].neighbor_count - hetbond_count (*a1))
6626
          swap_atoms (a1, a2);
6546
          swap_atoms (a1, a2);
6627
  }
6547
  }
6628
}
6548
}
6629
 
6549
 
6630
static void chk_imine (a_ref, a_view)
6550
static void chk_imine (int a_ref, int a_view)
6631
     int a_ref, a_view;
-
 
6632
{
6551
{
6633
  /* a_ref = C, a_view = N */
6552
  /* a_ref = C, a_view = N */
6634
  int i;
6553
  int i;
6635
  neighbor_rec nb;
6554
  neighbor_rec nb;
6636
  str2 nb_el;
6555
  str2 nb_el;
6637
  int a_het = 0, a_c;
6556
  int a_het = 0, a_c;
6638
  int het_count = 0, c_count = 0, o_count = 0;  /* v0.3k */
6557
  int het_count = 0, c_count = 0, o_count = 0;  /* v0.3k */
6639
  int FORLIM;
6558
  int FORLIM;
6640
 
6559
 
6641
  /* v0.3k */
6560
  /* v0.3k */
6642
  if (atom[a_view - 1].neighbor_count == 1) {
6561
  if (atom[a_view - 1].neighbor_count == 1) {
6643
      if (atom[a_ref - 1].arom == false)
6562
      if (atom[a_ref - 1].arom == false)
6644
        fg[fg_imine - 1] = true;
6563
        fg[fg_imine - 1] = true;
6645
      return;
6564
      return;
Line 6721... Line 6640...
6721
  /* check for semicarbazone or thiosemicarbazone */
6640
  /* check for semicarbazone or thiosemicarbazone */
6722
  if (het_count == 2 && o_count == 2)
6641
  if (het_count == 2 && o_count == 2)
6723
    fg[fg_nitro_compound - 1] = true;
6642
    fg[fg_nitro_compound - 1] = true;
6724
}
6643
}
6725
 
6644
 
6726
static void chk_carbonyl_deriv (a_view, a_ref)
6645
static void chk_carbonyl_deriv (int a_view, int a_ref)
6727
     int a_view, a_ref;
-
 
6728
{
6646
{
6729
  /* a_view = C */
6647
  /* a_view = C */
6730
  int i;
6648
  int i;
6731
  neighbor_rec nb;
6649
  neighbor_rec nb;
6732
  str2 nb_el;
6650
  str2 nb_el;
Line 6747... Line 6665...
6747
              if (is_cyano_c (nb[i]))
6665
              if (is_cyano_c (nb[i]))
6748
                      cn_count++;
6666
                      cn_count++;
6749
              else
6667
              else
6750
                      c_count++;
6668
                      c_count++;
6751
            }
6669
            }
6752
          }
6670
          }
6753
    else {
6671
    else {
6754
            if (bt == 'D')
6672
            if (bt == 'D')
6755
              n_db++;
6673
              n_db++;
6756
          }
6674
          }
6757
  }
6675
  }
6758
  /* new in v0.3b */
6676
  /* new in v0.3b */
6759
  if (is_oxo_C (a_view)) {
6677
  if (is_oxo_C (a_view)) {
6760
    fg[fg_carbonyl - 1] = true;
6678
    fg[fg_carbonyl - 1] = true;
6761
    if (c_count + cn_count < 2) {                       /* new in v0.3b (detection of ketenes) */
6679
    if (c_count + cn_count < 2) {                       /* new in v0.3b (detection of ketenes) */
Line 6765... Line 6683...
6765
              fg[fg_ketene - 1] = true;
6683
              fg[fg_ketene - 1] = true;
6766
          }
6684
          }
6767
    if (c_count == 2) {
6685
    if (c_count == 2) {
6768
            if (atom[a_view - 1].arom)
6686
            if (atom[a_view - 1].arom)
6769
              fg[fg_oxohetarene - 1] = true;
6687
              fg[fg_oxohetarene - 1] = true;
6770
            else
6688
            else
6771
              fg[fg_ketone - 1] = true;
6689
              fg[fg_ketone - 1] = true;
6772
          }
6690
          }
6773
    if (cn_count > 0)
6691
    if (cn_count > 0)
6774
            fg[fg_acyl_cyanide - 1] = true;
6692
            fg[fg_acyl_cyanide - 1] = true;
6775
  }
6693
  }
6776
  if (is_thioxo_C (a_view)) {
6694
  if (is_thioxo_C (a_view)) {
6777
    fg[fg_thiocarbonyl - 1] = true;
6695
    fg[fg_thiocarbonyl - 1] = true;
6778
    if (c_count < 2)
6696
    if (c_count < 2)
6779
            fg[fg_thioaldehyde - 1] = true;
6697
            fg[fg_thioaldehyde - 1] = true;
6780
    if (c_count == 2) {
6698
    if (c_count == 2) {
Line 6784... Line 6702...
6784
              fg[fg_thioketone - 1] = true;
6702
              fg[fg_thioketone - 1] = true;
6785
          }
6703
          }
6786
  }
6704
  }
6787
  if (is_imino_C (a_view))
6705
  if (is_imino_C (a_view))
6788
    chk_imine (a_view, a_ref);
6706
    chk_imine (a_view, a_ref);
6789
}
6707
}
6790
 
6708
 
6791
static void chk_carboxyl_deriv (a_view, a_ref)
6709
static void chk_carboxyl_deriv (int a_view, int a_ref)
6792
     int a_view, a_ref;
-
 
6793
{
6710
{
6794
  int i;
6711
  int i;
6795
  neighbor_rec nb;
6712
  neighbor_rec nb;
6796
  str2 nb_el;
6713
  str2 nb_el;
6797
  int o_count = 0, n_count = 0, s_count = 0;
6714
  int o_count = 0, n_count = 0, s_count = 0;
6798
  int a_o = 0, a_n = 0, a_s = 0, FORLIM;
6715
  int a_o = 0, a_n = 0, a_s = 0, FORLIM;
Line 6854... Line 6771...
6854
                      && atom[a_n - 1].neighbor_count == 1)) {
6771
                      && atom[a_n - 1].neighbor_count == 1)) {
6855
              fg[fg_carboxylic_acid_amide - 1] = true;
6772
              fg[fg_carboxylic_acid_amide - 1] = true;
6856
              fg[fg_carboxylic_acid_prim_amide - 1] = true;
6773
              fg[fg_carboxylic_acid_prim_amide - 1] = true;
6857
            }
6774
            }
6858
            /*if (is_alkylamino(a_view,a_n)) or (is_arylamino(a_view,a_n)) then  */
6775
            /*if (is_alkylamino(a_view,a_n)) or (is_arylamino(a_view,a_n)) then  */
6859
            if (is_C_monosubst_amino (a_view, a_n) &
6776
            if (is_C_monosubst_amino (a_view, a_n) &&
6860
                (!is_subst_acylamino (a_view, a_n))) {                  /* v0.3j */
6777
                (!is_subst_acylamino (a_view, a_n))) {                  /* v0.3j */
6861
              if (bond[get_bond (a_view, a_n) - 1].arom == false)
6778
              if (bond[get_bond (a_view, a_n) - 1].arom == false)
6862
                      fg[fg_carboxylic_acid_amide - 1] = true;
6779
                      fg[fg_carboxylic_acid_amide - 1] = true;
6863
              if (bond[get_bond (a_view, a_n) - 1].arom == false)
6780
              if (bond[get_bond (a_view, a_n) - 1].arom == false)
6864
                      fg[fg_carboxylic_acid_sec_amide - 1] = true;
6781
                      fg[fg_carboxylic_acid_sec_amide - 1] = true;
Line 7047... Line 6964...
7047
        if (is_amino (a_view, a_n) || is_subst_amino (a_view, a_n))
6964
        if (is_amino (a_view, a_n) || is_subst_amino (a_view, a_n))
7048
          fg[fg_carboxylic_acid_amidrazone - 1] = true;
6965
          fg[fg_carboxylic_acid_amidrazone - 1] = true;
7049
  }
6966
  }
7050
}
6967
}
7051
 
6968
 
7052
static void chk_co2_sp2 (a_view, a_ref)
6969
static void chk_co2_sp2 (int a_view, int a_ref)
7053
     int a_view, a_ref;
-
 
7054
{
6970
{
7055
  int i;
6971
  int i;
7056
  neighbor_rec nb;
6972
  neighbor_rec nb;
7057
  str2 nb_el;
6973
  str2 nb_el;
7058
  int o_count = 0, or_count = 0, n_count = 0, nn_count = 0, nnx_count = 0,
6974
  int o_count = 0, or_count = 0, n_count = 0, nn_count = 0, nnx_count = 0,
Line 7082... Line 6998...
7082
                    }
6998
                    }
7083
              if (!strcmp (nb_el, "S ")) {
6999
              if (!strcmp (nb_el, "S ")) {
7084
                      s_count++;
7000
                      s_count++;
7085
                      if (is_alkylsulfanyl (a_view, nb[i]) | is_arylsulfanyl (a_view, nb[i]))
7001
                      if (is_alkylsulfanyl (a_view, nb[i]) | is_arylsulfanyl (a_view, nb[i]))
7086
                        sr_count++;
7002
                        sr_count++;
7087
                    }
7003
                    }
7088
            }
7004
            }
7089
          }
7005
          }
7090
  }
7006
  }
7091
  if (is_oxo_C (a_view)) {
7007
  if (is_oxo_C (a_view)) {
7092
      if (o_count == 2) {
7008
      if (o_count == 2) {
7093
              fg[fg_carbonic_acid_deriv - 1] = true;
7009
              fg[fg_carbonic_acid_deriv - 1] = true;
7094
              if (or_count == 1)
7010
              if (or_count == 1)
Line 7176... Line 7092...
7176
              if (nnx_count == 0)       /* excludes thiosemicarbazones */
7092
              if (nnx_count == 0)       /* excludes thiosemicarbazones */
7177
                      fg[fg_thiourea - 1] = true;
7093
                      fg[fg_thiourea - 1] = true;
7178
            }
7094
            }
7179
          }
7095
          }
7180
  }                             /* end Thioxo-C */
7096
  }                             /* end Thioxo-C */
7181
  if (!(is_true_imino_C (a_view) &
7097
  if (!(is_true_imino_C (a_view) &&
7182
       (bond[get_bond (a_view, a_ref) - 1].arom == false))) {
7098
       (bond[get_bond (a_view, a_ref) - 1].arom == false))) {
7183
      return;
7099
      return;
7184
  }                             /* end Imino-C */
7100
  }                             /* end Imino-C */
7185
  if (o_count == 1 && n_count == 1)
7101
  if (o_count == 1 && n_count == 1)
7186
    fg[fg_isourea - 1] = true;
7102
    fg[fg_isourea - 1] = true;
Line 7188... Line 7104...
7188
    fg[fg_isothiourea - 1] = true;
7104
    fg[fg_isothiourea - 1] = true;
7189
  if (n_count == 2)
7105
  if (n_count == 2)
7190
    fg[fg_guanidine - 1] = true;
7106
    fg[fg_guanidine - 1] = true;
7191
}
7107
}
7192
 
7108
 
7193
static void chk_co2_sp (a_view, a_ref)
7109
static void chk_co2_sp (int a_view, int a_ref)
7194
     int a_view, a_ref;
-
 
7195
{
7110
{
7196
  int i;
7111
  int i;
7197
  neighbor_rec nb;
7112
  neighbor_rec nb;
7198
  str2 nb_el;
7113
  str2 nb_el;
7199
  int o_count = 0, n_count = 0, s_count = 0;
7114
  int o_count = 0, n_count = 0, s_count = 0;
Line 7223... Line 7138...
7223
    fg[fg_isothiocyanate - 1] = true;
7138
    fg[fg_isothiocyanate - 1] = true;
7224
  if (n_count == 2)
7139
  if (n_count == 2)
7225
    fg[fg_carbodiimide - 1] = true;
7140
    fg[fg_carbodiimide - 1] = true;
7226
}
7141
}
7227
 
7142
 
7228
static void chk_triple (a1, a2)
7143
static void chk_triple(int a1,int a2)
7229
     int a1, a2;
-
 
7230
{
7144
{
7231
  str2 a1_el, a2_el;
7145
  str2 a1_el, a2_el;
7232
 
7146
 
7233
  strcpy (a1_el, atom[a1 - 1].element);
7147
  strcpy (a1_el, atom[a1 - 1].element);
7234
  strcpy (a2_el, atom[a2 - 1].element);
7148
  strcpy (a2_el, atom[a2 - 1].element);
Line 7243... Line 7157...
7243
    fg[fg_cyanate - 1] = true;
7157
    fg[fg_cyanate - 1] = true;
7244
  if (is_thiocyanate (a1, a2))
7158
  if (is_thiocyanate (a1, a2))
7245
    fg[fg_thiocyanate - 1] = true;
7159
    fg[fg_thiocyanate - 1] = true;
7246
}
7160
}
7247
 
7161
 
7248
static void chk_ccx (a_view, a_ref)
7162
static void chk_ccx (int a_view, int a_ref)
7249
     int a_view, a_ref;
-
 
7250
{
7163
{
7251
  int i;
7164
  int i;
7252
  neighbor_rec nb;
7165
  neighbor_rec nb;
7253
  int oh_count = 0, or_count = 0, n_count = 0;
7166
  int oh_count = 0, or_count = 0, n_count = 0;
7254
  int FORLIM;
7167
  int FORLIM;
Line 7277... Line 7190...
7277
  /* new in v0.2f   (regard anything else as an alkene) */
7190
  /* new in v0.2f   (regard anything else as an alkene) */
7278
  if (oh_count + or_count + n_count == 0)
7191
  if (oh_count + or_count + n_count == 0)
7279
    fg[fg_alkene - 1] = true;
7192
    fg[fg_alkene - 1] = true;
7280
}
7193
}
7281
 
7194
 
7282
static void chk_xccx (a_view, a_ref)
7195
static void chk_xccx (int a_view, int a_ref)
7283
     int a_view, a_ref;
-
 
7284
{
7196
{
7285
  int i;
7197
  int i;
7286
  neighbor_rec nb;
7198
  neighbor_rec nb;
7287
  int oh_count = 0, or_count = 0, n_count = 0;
7199
  int oh_count = 0, or_count = 0, n_count = 0;
7288
  int FORLIM;
7200
  int FORLIM;
Line 7322... Line 7234...
7322
  /* new in v0.2f   (regard anything else as an alkene) */
7234
  /* new in v0.2f   (regard anything else as an alkene) */
7323
  if (oh_count + or_count + n_count == 0)
7235
  if (oh_count + or_count + n_count == 0)
7324
    fg[fg_alkene - 1] = true;
7236
    fg[fg_alkene - 1] = true;
7325
}
7237
}
7326
 
7238
 
7327
static void chk_n_o_dbl (a1, a2)
7239
static void chk_n_o_dbl(int a1,int a2)
7328
     int a1, a2;
-
 
7329
{
7240
{
7330
  int i;
7241
  int i;
7331
  neighbor_rec nb;
7242
  neighbor_rec nb;
7332
  str2 nb_el;
7243
  str2 nb_el;
7333
  int or_count = 0, n_count = 0, c_count = 0;
7244
  int or_count = 0, n_count = 0, c_count = 0;
Line 7384... Line 7295...
7384
  /*    fg[fg_n_oxide] := true; */
7295
  /*    fg[fg_n_oxide] := true; */
7385
  /*  end; */
7296
  /*  end; */
7386
  /* new approach in v0.3k */
7297
  /* new approach in v0.3k */
7387
  if (het_count == 0 && bo_sum > 2)     /* =O does not count! */
7298
  if (het_count == 0 && bo_sum > 2)     /* =O does not count! */
7388
    fg[fg_n_oxide - 1] = true;
7299
    fg[fg_n_oxide - 1] = true;
7389
}
7300
}
7390
 
7301
 
7391
static void chk_sulfoxide (a1, a2)
7302
static void chk_sulfoxide(int a1,int a2)
7392
     int a1, a2;
-
 
7393
{
7303
{
7394
  int i;
7304
  int i;
7395
  neighbor_rec nb;
7305
  neighbor_rec nb;
7396
  str2 nb_el;
7306
  str2 nb_el;
7397
  int o_count = 0, c_count = 0;
7307
  int o_count = 0, c_count = 0;
7398
  int FORLIM;
7308
  int FORLIM;
7399
 
7309
 
7400
  memset (nb, 0, sizeof (neighbor_rec));
7310
  memset (nb, 0, sizeof (neighbor_rec));
Line 7409... Line 7319...
7409
  }
7319
  }
7410
  if (o_count == 1 && c_count == 2)
7320
  if (o_count == 1 && c_count == 2)
7411
    fg[fg_sulfoxide - 1] = true;
7321
    fg[fg_sulfoxide - 1] = true;
7412
}
7322
}
7413
 
7323
 
7414
static void chk_double (a1, a2)
7324
static void chk_double(int a1,int a2)
7415
     int a1, a2;
-
 
7416
{
7325
{
7417
  str2 a1_el, a2_el;
7326
  str2 a1_el, a2_el;
7418
 
7327
 
7419
  strcpy (a1_el, atom[a1 - 1].element);
7328
  strcpy (a1_el, atom[a1 - 1].element);
7420
  strcpy (a2_el, atom[a2 - 1].element);
7329
  strcpy (a2_el, atom[a2 - 1].element);
Line 7453... Line 7362...
7453
    chk_n_o_dbl (a1, a2);
7362
    chk_n_o_dbl (a1, a2);
7454
  if (!strcmp (a1_el, "S ") && !strcmp (a2_el, "O "))
7363
  if (!strcmp (a1_el, "S ") && !strcmp (a2_el, "O "))
7455
    chk_sulfoxide (a1, a2);
7364
    chk_sulfoxide (a1, a2);
7456
}
7365
}
7457
 
7366
 
7458
static void chk_c_hal (a1, a2)
7367
static void chk_c_hal(int a1,int a2)
7459
     int a1, a2;
-
 
7460
{
7368
{
7461
  str2 a2_el;
7369
  str2 a2_el;
7462
 
7370
 
7463
  strcpy (a2_el, atom[a2 - 1].element);
7371
  strcpy (a2_el, atom[a2 - 1].element);
7464
  fg[fg_halogen_deriv - 1] = true;
7372
  fg[fg_halogen_deriv - 1] = true;
Line 7529... Line 7437...
7529
    fg[fg_thiocarbamic_acid_halide - 1] = true;
7437
    fg[fg_thiocarbamic_acid_halide - 1] = true;
7530
      /* end of non-aromatic halogen compounds */
7438
      /* end of non-aromatic halogen compounds */
7531
  }
7439
  }
7532
}
7440
}
7533
 
7441
 
7534
static void chk_c_o (a1, a2)
7442
static void chk_c_o(int a1,int a2)
7535
     int a1, a2;
-
 
7536
{
7443
{
7537
  /* ignore heteroaromatic rings (like furan, thiophene, etc.) */
7444
  /* ignore heteroaromatic rings (like furan, thiophene, etc.) */
7538
  if (bond[get_bond (a1, a2) - 1].arom == true)
7445
  if (bond[get_bond (a1, a2) - 1].arom == true)
7539
    return;
7446
    return;
7540
  if (is_true_alkyl (a2, a1) && is_hydroxy (a1, a2)) {
7447
  if (is_true_alkyl (a2, a1) && is_hydroxy (a1, a2)) {
Line 7572... Line 7479...
7572
    fg[fg_hydroxy - 1] = true;
7479
    fg[fg_hydroxy - 1] = true;
7573
    hydroxy_generic = true;
7480
    hydroxy_generic = true;
7574
  }
7481
  }
7575
}
7482
}
7576
 
7483
 
7577
static void chk_c_s (a1, a2)
7484
static void chk_c_s(int a1,int a2)
7578
     int a1, a2;
-
 
7579
{
7485
{
7580
  int i;
7486
  int i;
7581
  neighbor_rec nb;
7487
  neighbor_rec nb;
7582
  str2 nb_el;
7488
  str2 nb_el;
7583
  int o_count = 0, oh_count = 0, or_count = 0, n_count = 0, c_count = 0,
7489
  int o_count = 0, oh_count = 0, or_count = 0, n_count = 0, c_count = 0,
Line 7649... Line 7555...
7649
    fg[fg_sulfenic_acid_halide - 1] = true;
7555
    fg[fg_sulfenic_acid_halide - 1] = true;
7650
  if (n_count == 1)
7556
  if (n_count == 1)
7651
    fg[fg_sulfenic_acid_amide - 1] = true;
7557
    fg[fg_sulfenic_acid_amide - 1] = true;
7652
}
7558
}
7653
 
7559
 
7654
static void chk_c_n (a1, a2)
7560
static void chk_c_n(int a1,int a2)
7655
     int a1, a2;
-
 
7656
{
7561
{
7657
  /* ignore heteroaromatic rings (like furan, thiophene, pyrrol, etc.) */
7562
  /* ignore heteroaromatic rings (like furan, thiophene, pyrrol, etc.) */
7658
  if (atom[a2 - 1].arom == true)
7563
  if (atom[a2 - 1].arom == true)
7659
    return;
7564
    return;
7660
  if (is_true_alkyl (a2, a1) && is_amino (a1, a2)) {
7565
  if (is_true_alkyl (a2, a1) && is_amino (a1, a2)) {
Line 7717... Line 7622...
7717
    fg[fg_diazonium_salt - 1] = true;
7622
    fg[fg_diazonium_salt - 1] = true;
7718
  if ((is_alkyl (a2, a1) || is_aryl (a2, a1) || is_alkenyl (a2, a1) |
7623
  if ((is_alkyl (a2, a1) || is_aryl (a2, a1) || is_alkenyl (a2, a1) |
7719
       is_alkynyl (a2, a1)) && is_nitro (a1, a2))
7624
       is_alkynyl (a2, a1)) && is_nitro (a1, a2))
7720
    /* v0.3k */
7625
    /* v0.3k */
7721
    fg[fg_nitro_compound - 1] = true;
7626
    fg[fg_nitro_compound - 1] = true;
7722
  if (is_alkynyl (a2, a1) &
7627
  if (is_alkynyl (a2, a1) &&
7723
        (is_amino (a1, a2) || is_C_monosubst_amino (a1, a2) |
7628
        (is_amino (a1, a2) || is_C_monosubst_amino (a1, a2) |
7724
       (is_C_disubst_amino (a1, a2) && (!is_acylamino (a1, a2))))) {
7629
       (is_C_disubst_amino (a1, a2) && (!is_acylamino (a1, a2))))) {
7725
      fg[fg_amine - 1] = true;
7630
      fg[fg_amine - 1] = true;
7726
      amine_generic = true;
7631
      amine_generic = true;
7727
  }
7632
  }
7728
}
7633
}
7729
 
7634
 
7730
static void chk_c_c (a1, a2)
7635
static void chk_c_c(int a1,int a2)
7731
     int a1, a2;
-
 
7732
{
7636
{
7733
  int i;
7637
  int i;
7734
  neighbor_rec nb;
7638
  neighbor_rec nb;
7735
  int oh_count, nhr_count, FORLIM;
7639
  int oh_count, nhr_count, FORLIM;
7736
 
7640
 
Line 7806... Line 7710...
7806
    fg[fg_alpha_hydroxyacid - 1] = true;
7710
    fg[fg_alpha_hydroxyacid - 1] = true;
7807
  if ((oh_count == 1 && nhr_count == 1) && is_oxo_C (a2))
7711
  if ((oh_count == 1 && nhr_count == 1) && is_oxo_C (a2))
7808
    fg[fg_alpha_aminoacid - 1] = true;
7712
    fg[fg_alpha_aminoacid - 1] = true;
7809
}
7713
}
7810
 
7714
 
7811
static void chk_x_y_single (a_view, a_ref)
7715
static void chk_x_y_single (int a_view, int a_ref)
7812
     int a_view, a_ref;
-
 
7813
{
7716
{
7814
  if (!strcmp (atom[a_view - 1].atype, "O3 ") &&
7717
  if (!strcmp (atom[a_view - 1].atype, "O3 ") &&
7815
        !strcmp (atom[a_ref - 1].atype, "O3 ")) {
7718
        !strcmp (atom[a_ref - 1].atype, "O3 ")) {
7816
    if (is_hydroxy (a_ref, a_view) || is_hydroxy (a_view, a_ref))
7719
    if (is_hydroxy (a_ref, a_view) || is_hydroxy (a_view, a_ref))
7817
            fg[fg_hydroperoxide - 1] = true;
7720
            fg[fg_hydroperoxide - 1] = true;
Line 7840... Line 7743...
7840
              fg[fg_hydrazine - 1] = true;
7743
              fg[fg_hydrazine - 1] = true;
7841
  }
7744
  }
7842
  if (!strcmp (atom[a_view - 1].element, "N ") &&
7745
  if (!strcmp (atom[a_view - 1].element, "N ") &&
7843
      !strcmp (atom[a_ref - 1].atype, "O3 ")) {
7746
      !strcmp (atom[a_ref - 1].atype, "O3 ")) {
7844
    /* bond is in "opposite" direction */
7747
    /* bond is in "opposite" direction */
7845
    if ((is_alkoxy (a_view, a_ref) || is_aryloxy (a_view, a_ref)) &
7748
    if ((is_alkoxy (a_view, a_ref) || is_aryloxy (a_view, a_ref)) &&
7846
              is_nitro (a_ref, a_view))
7749
              is_nitro (a_ref, a_view))
7847
            fg[fg_nitrate - 1] = true;
7750
            fg[fg_nitrate - 1] = true;
7848
    if ((is_nitro (a_ref, a_view) == false
7751
    if ((is_nitro (a_ref, a_view) == false
7849
              && atom[a_view - 1].arom == false) && (is_amino (a_ref, a_view) |
7752
              && atom[a_view - 1].arom == false) && (is_amino (a_ref, a_view) |
7850
                    is_subst_amino (a_ref, a_view)) &
7753
                    is_subst_amino (a_ref, a_view)) &&
7851
              (is_acylamino (a_ref, a_view) == false))
7754
              (is_acylamino (a_ref, a_view) == false))
7852
            fg[fg_hydroxylamine - 1] = true;    /* new in v0.3c */
7755
            fg[fg_hydroxylamine - 1] = true;    /* new in v0.3c */
7853
  }
7756
  }
7854
  if (!strcmp (atom[a_view - 1].element, "S ") &&
7757
  if (!strcmp (atom[a_view - 1].element, "S ") &&
7855
      !strcmp (atom[a_ref - 1].element, "O "))
7758
      !strcmp (atom[a_ref - 1].element, "O "))
7856
    chk_sulfoxide (a_view, a_ref);
7759
    chk_sulfoxide (a_view, a_ref);
7857
}
7760
}
7858
 
7761
 
7859
static void chk_single (a1, a2)
7762
static void chk_single(int a1,int a2)
7860
     int a1, a2;
-
 
7861
{
7763
{
7862
  str2 a1_el, a2_el;
7764
  str2 a1_el, a2_el;
7863
 
7765
 
7864
  strcpy (a1_el, atom[a1 - 1].element);
7766
  strcpy (a1_el, atom[a1 - 1].element);
7865
  strcpy (a2_el, atom[a2 - 1].element);
7767
  strcpy (a2_el, atom[a2 - 1].element);
Line 7884... Line 7786...
7884
    chk_c_c (a1, a2);
7786
    chk_c_c (a1, a2);
7885
  if (strcmp (a1_el, "C ") && strcmp (a2_el, "C "))
7787
  if (strcmp (a1_el, "C ") && strcmp (a2_el, "C "))
7886
    chk_x_y_single (a1, a2);
7788
    chk_x_y_single (a1, a2);
7887
}
7789
}
7888
 
7790
 
7889
static void chk_carbonyl_deriv_sp3 (a_ref)
7791
static void chk_carbonyl_deriv_sp3 (int a_ref)
7890
     int a_ref;
-
 
7891
{
7792
{
7892
  int i;
7793
  int i;
7893
  neighbor_rec nb;
7794
  neighbor_rec nb;
7894
  int oh_count = 0, or_count = 0, n_count = 0, sh_count = 0, sr_count = 0;
7795
  int oh_count = 0, or_count = 0, n_count = 0, sh_count = 0, sr_count = 0;
7895
  int FORLIM;
7796
  int FORLIM;
Line 7925... Line 7826...
7925
    fg[fg_thiohemiaminal - 1] = true;
7826
    fg[fg_thiohemiaminal - 1] = true;
7926
  if (sr_count == 2 || (or_count == 1 && sr_count == 1))
7827
  if (sr_count == 2 || (or_count == 1 && sr_count == 1))
7927
    fg[fg_thioacetal - 1] = true;
7828
    fg[fg_thioacetal - 1] = true;
7928
}
7829
}
7929
 
7830
 
7930
static void chk_carboxyl_deriv_sp3 (a_ref)
7831
static void chk_carboxyl_deriv_sp3 (int a_ref)
7931
     int a_ref;
-
 
7932
{
7832
{
7933
  int i;
7833
  int i;
7934
  neighbor_rec nb;
7834
  neighbor_rec nb;
7935
  int or_count = 0, oh_count = 0, n_count = 0;  /* oh_count new in v0.3c */
7835
  int or_count = 0, oh_count = 0, n_count = 0;  /* oh_count new in v0.3c */
7936
  int electroneg_count = 0;     /* new in v0.3j */
7836
  int electroneg_count = 0;     /* new in v0.3j */
Line 7967... Line 7867...
7967
    fg[fg_carboxylic_acid_amide_acetal - 1] = true;
7867
    fg[fg_carboxylic_acid_amide_acetal - 1] = true;
7968
  if (oh_count > 0 && oh_count + or_count + n_count == 3)       /* new in v0.3c */
7868
  if (oh_count > 0 && oh_count + or_count + n_count == 3)       /* new in v0.3c */
7969
    fg[fg_orthocarboxylic_acid_deriv - 1] = true;
7869
    fg[fg_orthocarboxylic_acid_deriv - 1] = true;
7970
}
7870
}
7971
 
7871
 
7972
static void chk_anhydride (a_ref)
7872
static void chk_anhydride (int a_ref)
7973
     int a_ref;
-
 
7974
{
7873
{
7975
  int i;
7874
  int i;
7976
  neighbor_rec nb;
7875
  neighbor_rec nb;
7977
  int acyl_count = 0;
7876
  int acyl_count = 0;
7978
  int FORLIM;
7877
  int FORLIM;
Line 7988... Line 7887...
7988
    fg[fg_carboxylic_acid_deriv - 1] = true;
7887
    fg[fg_carboxylic_acid_deriv - 1] = true;
7989
    fg[fg_carboxylic_acid_anhydride - 1] = true;
7888
    fg[fg_carboxylic_acid_anhydride - 1] = true;
7990
  }
7889
  }
7991
}
7890
}
7992
 
7891
 
7993
static void chk_imide (a_ref)
7892
static void chk_imide (int a_ref)
7994
     int a_ref;
-
 
7995
{
7893
{
7996
  int i;
7894
  int i;
7997
  neighbor_rec nb;
7895
  neighbor_rec nb;
7998
  int acyl_count = 0;
7896
  int acyl_count = 0;
7999
  int FORLIM;
7897
  int FORLIM;
Line 8002... Line 7900...
8002
  get_neighbors (nb, a_ref);
7900
  get_neighbors (nb, a_ref);
8003
  FORLIM = atom[a_ref - 1].neighbor_count;
7901
  FORLIM = atom[a_ref - 1].neighbor_count;
8004
  for (i = 0; i < FORLIM; i++) {
7902
  for (i = 0; i < FORLIM; i++) {
8005
    if (is_acyl_gen (a_ref, nb[i]) || is_carbamoyl (a_ref, nb[i]))      /* v0.3j */
7903
    if (is_acyl_gen (a_ref, nb[i]) || is_carbamoyl (a_ref, nb[i]))      /* v0.3j */
8006
            acyl_count++;
7904
            acyl_count++;
8007
  }
7905
  }
8008
  if (acyl_count < 2 || strcmp (atom[a_ref - 1].element, "N "))
7906
  if (acyl_count < 2 || strcmp (atom[a_ref - 1].element, "N "))
8009
    /* v0.3j: accept also N-acyl-imides */
7907
    /* v0.3j: accept also N-acyl-imides */
8010
    return;
7908
    return;
8011
  fg[fg_carboxylic_acid_deriv - 1] = true;
7909
  fg[fg_carboxylic_acid_deriv - 1] = true;
8012
  fg[fg_carboxylic_acid_imide - 1] = true;
7910
  fg[fg_carboxylic_acid_imide - 1] = true;
Line 8014... Line 7912...
8014
    fg[fg_carboxylic_acid_unsubst_imide - 1] = true;
7912
    fg[fg_carboxylic_acid_unsubst_imide - 1] = true;
8015
  if (atom[a_ref - 1].neighbor_count == 3)
7913
  if (atom[a_ref - 1].neighbor_count == 3)
8016
    fg[fg_carboxylic_acid_subst_imide - 1] = true;
7914
    fg[fg_carboxylic_acid_subst_imide - 1] = true;
8017
}
7915
}
8018
 
7916
 
8019
static void chk_12diphenol (a_view, a_ref)
7917
static void chk_12diphenol (int a_view, int a_ref)
8020
     int a_view, a_ref;
-
 
8021
{
7918
{
8022
  int i;
7919
  int i;
8023
  neighbor_rec nb;
7920
  neighbor_rec nb;
8024
  int oh_count = 0;
7921
  int oh_count = 0;
8025
  int FORLIM;
7922
  int FORLIM;
Line 8044... Line 7941...
8044
  }
7941
  }
8045
  if (oh_count == 2)
7942
  if (oh_count == 2)
8046
    fg[fg_1_2_diphenol - 1] = true;
7943
    fg[fg_1_2_diphenol - 1] = true;
8047
}
7944
}
8048
 
7945
 
8049
static void chk_arom_fg (a1, a2)
7946
static void chk_arom_fg (int a1, int a2)
8050
     int a1, a2;
-
 
8051
{
7947
{
8052
  if ((hetbond_count (a1) == 1) && (hetbond_count (a2) == 1))
7948
  if ((hetbond_count (a1) == 1) && (hetbond_count (a2) == 1))
8053
    chk_12diphenol (a1, a2);
7949
    chk_12diphenol (a1, a2);
8054
}
7950
}
8055
 
7951
 
8056
static boolean is_arene (r_id)
7952
static boolean is_arene (int r_id)
8057
     int r_id;
-
 
8058
{
7953
{
8059
  int i, j;
7954
  int i, j;
8060
  boolean r = true;
7955
  boolean r = true;
8061
  ringpath_type testring;
7956
  ringpath_type testring;
8062
  int ring_size, a_prev, a_ref;
7957
  int ring_size, a_prev, a_ref;
Line 8080... Line 7975...
8080
    a_prev = a_ref;
7975
    a_prev = a_ref;
8081
  }
7976
  }
8082
  return r;
7977
  return r;
8083
}
7978
}
8084
 
7979
 
8085
static boolean is_heterocycle (r_id)
7980
static boolean is_heterocycle (int r_id)
8086
     int r_id;
-
 
8087
{
7981
{
8088
  int i, j;
7982
  int i, j;
8089
  boolean r = false;
7983
  boolean r = false;
8090
  ringpath_type testring;
7984
  ringpath_type testring;
8091
  int ring_size, a_ref;
7985
  int ring_size, a_ref;
Line 8106... Line 8000...
8106
            r = true;
8000
            r = true;
8107
  }
8001
  }
8108
  return r;
8002
  return r;
8109
}
8003
}
8110
 
8004
 
8111
static void chk_oxo_thioxo_imino_hetarene (r_id)
8005
static void chk_oxo_thioxo_imino_hetarene (int r_id)
8112
     int r_id;
-
 
8113
{
8006
{
8114
  int i, j;
8007
  int i, j;
8115
  ringpath_type testring;
8008
  ringpath_type testring;
8116
  int ring_size, a_ref;
8009
  int ring_size, a_ref;
8117
 
8010
 
Line 8135... Line 8028...
8135
    if (is_true_exocyclic_imino_C (a_ref, r_id))        /* v0.3j */
8028
    if (is_true_exocyclic_imino_C (a_ref, r_id))        /* v0.3j */
8136
            fg[fg_iminohetarene - 1] = true;
8029
            fg[fg_iminohetarene - 1] = true;
8137
  }
8030
  }
8138
}
8031
}
8139
 
8032
 
8140
static void chk_ion (a_ref)
8033
static void chk_ion (int a_ref)
8141
     int a_ref;
-
 
8142
{
8034
{
8143
  int i;
8035
  int i;
8144
  neighbor_rec nb;
8036
  neighbor_rec nb;
8145
  int charge, FORLIM;
8037
  int charge, FORLIM;
8146
 
8038
 
Line 10295... Line 10187...
10295
     if (chir_flag)
10187
     if (chir_flag)
10296
     rs_search = true;
10188
     rs_search = true;
10297
     }
10189
     }
10298
#endif
10190
#endif
10299
 
10191
 
10300
static void get_ringstat (r_id)
10192
static void get_ringstat (int r_id)
10301
     int r_id;
-
 
10302
{
10193
{
10303
  int i, j;
10194
  int i, j;
10304
  ringpath_type testring;
10195
  ringpath_type testring;
10305
  int ring_size, a_ref;
10196
  int ring_size, a_ref;
10306
  str2 elem;
10197
  str2 elem;
Line 10357... Line 10248...
10357
    molstat.n_rX++;
10248
    molstat.n_rX++;
10358
  /* general ringsize descriptors; v0.3m */
10249
  /* general ringsize descriptors; v0.3m */
10359
  switch (ring_size) {
10250
  switch (ring_size) {
10360
    case 3:
10251
    case 3:
10361
      molstat.n_r3++;
10252
      molstat.n_r3++;
10362
      break;
10253
      break;
10363
 
10254
 
10364
    case 4:
10255
    case 4:
10365
      molstat.n_r4++;
10256
      molstat.n_r4++;
10366
      break;
10257
      break;
10367
 
10258
 
10368
    case 5:
10259
    case 5:
Line 11035... Line 10926...
11035
          }
10926
          }
11036
  }
10927
  }
11037
  return entries;
10928
  return entries;
11038
}
10929
}
11039
 
10930
 
11040
static int cv_iterate (n_cv_prev)
10931
static int cv_iterate (int n_cv_prev)
11041
     int n_cv_prev;
-
 
11042
{
10932
{
11043
  /* new in v0.3j, modified in v0.3m */
10933
  /* new in v0.3j, modified in v0.3m */
11044
  int i, j;
10934
  int i, j;
11045
  neighbor_rec nb;
10935
  neighbor_rec nb;
11046
  int nnb, nsum, n_cv, FORLIM;
10936
  int nnb, nsum, n_cv, FORLIM;
Line 11130... Line 11020...
11130
     on e:Einvalidpointer do begin end;
11020
     on e:Einvalidpointer do begin end;
11131
     end; */
11021
     end; */
11132
  return Result;
11022
  return Result;
11133
}
11023
}
11134
 
11024
 
11135
static boolean atomtypes_OK_strict (ndl_a, hst_a)
11025
static boolean atomtypes_OK_strict (int ndl_a, int hst_a)
11136
     int ndl_a, hst_a;
-
 
11137
{
11026
{
11138
  /* new in v0.2f */
11027
  /* new in v0.2f */
11139
  str2 ndl_el;
11028
  str2 ndl_el;
11140
  str3 ndl_atype;
11029
  str3 ndl_atype;
11141
  str2 hst_el;
11030
  str2 hst_el;
Line 11204... Line 11093...
11204
            res = false;
11093
            res = false;
11205
  }
11094
  }
11206
  return res;
11095
  return res;
11207
}
11096
}
11208
 
11097
 
11209
static boolean atomtypes_OK (ndl_a, hst_a)
11098
static boolean atomtypes_OK (int ndl_a, int hst_a)
11210
     int ndl_a, hst_a;
-
 
11211
{
11099
{
11212
  str2 ndl_el, hst_el;
11100
  str2 ndl_el, hst_el;
11213
  int ndl_nbc, hst_nbc, ndl_Hexp, hst_Htot;
11101
  int ndl_nbc, hst_nbc, ndl_Hexp, hst_Htot;
11214
  boolean res = false;
11102
  boolean res = false;
11215
 
11103
 
Line 11313... Line 11201...
11313
     else debugoutput('atom types not OK ('+inttostr(ndl_a)+'/'+inttostr(hst_a)+')'); */
11201
     else debugoutput('atom types not OK ('+inttostr(ndl_a)+'/'+inttostr(hst_a)+')'); */
11314
  /*$ENDIF */
11202
  /*$ENDIF */
11315
  return res;
11203
  return res;
11316
}
11204
}
11317
 
11205
 
11318
static boolean bondtypes_OK_strict (ndl_b, hst_b)
11206
static boolean bondtypes_OK_strict (int ndl_b, int hst_b)
11319
     int ndl_b, hst_b;
-
 
11320
{
11207
{
11321
  boolean ndl_arom, hst_arom;
11208
  boolean ndl_arom, hst_arom;
11322
  char ndl_btype, hst_btype;
11209
  char ndl_btype, hst_btype;
11323
  int ndl_rc;                   /* new in v0.3d */
11210
  int ndl_rc;                   /* new in v0.3d */
11324
  int hst_rc;                   /* new in v0.3d */
11211
  int hst_rc;                   /* new in v0.3d */
Line 11408... Line 11295...
11408
       debugoutput('bond types not OK ('+inttostr(ndl_b)+':'+ndl_btype+na+'/'+inttostr(hst_b)+':'+hst_btype+ha+tstr+')'); */
11295
       debugoutput('bond types not OK ('+inttostr(ndl_b)+':'+ndl_btype+na+'/'+inttostr(hst_b)+':'+hst_btype+ha+tstr+')'); */
11409
    /*$ENDIF */
11296
    /*$ENDIF */
11410
  return res;
11297
  return res;
11411
}
11298
}
11412
 
11299
 
11413
static boolean bondtypes_OK (ndl_b, hst_b)
11300
static boolean bondtypes_OK (int ndl_b, int hst_b)
11414
     int ndl_b, hst_b;
-
 
11415
{
11301
{
11416
  boolean ndl_arom, hst_arom;
11302
  boolean ndl_arom, hst_arom;
11417
  char ndl_btype, hst_btype;
11303
  char ndl_btype, hst_btype;
11418
  int ndl_rc;                   /* new in v0.3d */
11304
  int ndl_rc;                   /* new in v0.3d */
11419
  int hst_rc;                   /* new in v0.3d */
11305
  int hst_rc;                   /* new in v0.3d */
Line 11514... Line 11400...
11514
       debugoutput('bond types not OK ('+inttostr(ndl_b)+':'+ndl_btype+na+'/'+inttostr(hst_b)+':'+hst_btype+ha+tstr+')'); */
11400
       debugoutput('bond types not OK ('+inttostr(ndl_b)+':'+ndl_btype+na+'/'+inttostr(hst_b)+':'+hst_btype+ha+tstr+')'); */
11515
    /*$ENDIF */
11401
    /*$ENDIF */
11516
  return res;
11402
  return res;
11517
}
11403
}
11518
 
11404
 
11519
static boolean matrix_OK (m, ndl_dim, hst_dim)
11405
static boolean matrix_OK (boolean (*m)[max_neighbors], int ndl_dim, int hst_dim)
11520
boolean (*m)[max_neighbors];
-
 
11521
     int ndl_dim, hst_dim;
-
 
11522
{
11406
{
11523
  /* new, recursive version in v0.2i: can handle up to max_neighbors substituents */
11407
  /* new, recursive version in v0.2i: can handle up to max_neighbors substituents */
11524
  boolean mr = false;
11408
  boolean mr = false;
11525
  matchmatrix lm;
11409
  matchmatrix lm;
11526
  int i, ii, j, lndl_dim, lhst_dim;
11410
  int i, ii, j, lndl_dim, lhst_dim;
Line 11556... Line 11440...
11556
          }
11440
          }
11557
  }
11441
  }
11558
  return false;
11442
  return false;
11559
}
11443
}
11560
 
11444
 
11561
static boolean is_flat (angle_deg)
11445
static boolean is_flat (double angle_deg)
11562
     double angle_deg;
-
 
11563
{
11446
{
11564
  /* new in v0.3j */
11447
  /* new in v0.3j */
11565
  if (fabs (angle_deg) > 5 && fabs (angle_deg) < 175)
11448
  if (fabs (angle_deg) > 5 && fabs (angle_deg) < 175)
11566
    return false;
11449
    return false;
11567
  else
11450
  else
11568
    return true;
11451
    return true;
11569
}
11452
}
11570
 
11453
 
11571
static boolean chirality_OK (ndl_cp, hst_cp)
11454
static boolean chirality_OK (int *ndl_cp, int *hst_cp)
11572
     int *ndl_cp, *hst_cp;
-
 
11573
{
11455
{
11574
  boolean res = true;
11456
  boolean res = true;
11575
  double ndl_ct, hst_ct, ndl_ct_deg, hst_ct_deg;
11457
  double ndl_ct, hst_ct, ndl_ct_deg, hst_ct_deg;
11576
  p_3d np1, np2, np3, np4, hp1, hp2, hp3, hp4;
11458
  p_3d np1, np2, np3, np4, hp1, hp2, hp3, hp4;
11577
  int level = 0;
11459
  int level = 0;
Line 11800... Line 11682...
11800
              res = false;
11682
              res = false;
11801
  }
11683
  }
11802
  return res;
11684
  return res;
11803
}
11685
}
11804
 
11686
 
11805
static boolean ndl_maybe_chiral (na)
11687
static boolean ndl_maybe_chiral (int na)
11806
     int na;
-
 
11807
{
11688
{
11808
  /* new in v0.3h */
11689
  /* new in v0.3h */
11809
  boolean res = false;
11690
  boolean res = false;
11810
  str2 el;
11691
  str2 el;
11811
  str3 at;
11692
  str3 at;
Line 11831... Line 11712...
11831
  if (ndl_hetatom_count (na) >= 2)      /* v0.3m; ignore phosphates etc. */
11712
  if (ndl_hetatom_count (na) >= 2)      /* v0.3m; ignore phosphates etc. */
11832
    res = false;
11713
    res = false;
11833
  return res;
11714
  return res;
11834
}
11715
}
11835
 
11716
 
11836
static boolean is_matching (ndl_xmp, hst_xmp)
11717
static boolean is_matching (int *ndl_xmp, int *hst_xmp)
11837
     int *ndl_xmp, *hst_xmp;
-
 
11838
{
11718
{
11839
  int i, j, k, l, m, ndl_n_nb, n_nb, ndl_a, hst_a;
11719
  int i, j, k, l, m, ndl_n_nb, n_nb, ndl_a, hst_a;
11840
  int ndl_b = 0, hst_b = 0, prev_ndl_a = 0, prev_hst_a = 0;
11720
  int ndl_b = 0, hst_b = 0, prev_ndl_a = 0, prev_hst_a = 0;
11841
  int next_ndl_a, next_hst_a;
11721
  int next_ndl_a, next_hst_a;
11842
  neighbor_rec ndl_nb, hst_nb;
11722
  neighbor_rec ndl_nb, hst_nb;
Line 12458... Line 12338...
12458
    for (i = 0; i < FORLIM; i++)
12338
    for (i = 0; i < FORLIM; i++)
12459
            bond[i].ring_count = 0;
12339
            bond[i].ring_count = 0;
12460
  }
12340
  }
12461
}
12341
}
12462
 
12342
 
12463
static int ring_lastpos (s)
12343
static int ring_lastpos (int *s)
12464
     int *s;
-
 
12465
{
12344
{
12466
  int i, rc;
12345
  int i, rc;
12467
  int rlp = 0;
12346
  int rlp = 0;
12468
  int FORLIM;
12347
  int FORLIM;
12469
  if (n_rings <= 0)
12348
  if (n_rings <= 0)
Line 12723... Line 12602...
12723
          }
12602
          }
12724
    progmode = pmCheckMol;
12603
    progmode = pmCheckMol;
12725
  }
12604
  }
12726
  if (argc == 1) {
12605
  if (argc == 1) {
12727
    show_usage ();
12606
    show_usage ();
12728
    exit (1);
12607
    exit (1);
12729
  }
12608
  }
12730
  init_globals ();
12609
  init_globals ();
12731
  init_molstat (&molstat);
12610
  init_molstat (&molstat);
12732
  parse_args (argc, argv);
12611
  parse_args (argc, argv);
12733
  if (ringsearch_mode == rs_sar)
12612
  if (ringsearch_mode == rs_sar)
12734
    max_vringsize = max_ringsize;
12613
    max_vringsize = max_ringsize;
Line 13107... Line 12986...
13107
  exit (0);
12986
  exit (0);
13108
}
12987
}
13109
 
12988
 
13110
#else
12989
#else
13111
 
12990
 
13112
static void init_globals_dll (void)
12991
static void init_globals_dll ( )
13113
{
12992
{
13114
 
12993
 
13115
//printf("init_globals_dll\n");
12994
//printf("init_globals_dll\n");
13116
 
12995
 
13117
  int i;
12996
  int i;
Line 13173... Line 13052...
13173
  tmfmismatch = false;          /* v0.3m */
13052
  tmfmismatch = false;          /* v0.3m */
13174
  auto_ssr = false;
13053
  auto_ssr = false;
13175
  recursion_depth = 0;
13054
  recursion_depth = 0;
13176
}
13055
}
13177
 
13056
 
13178
static void mm_init_mol (void)
13057
static void mm_init_mol ( )
13179
{
13058
{
13180
//printf("mm_init_mol\n");
13059
//printf("mm_init_mol\n");
13181
  init_globals_dll ();
13060
  init_globals_dll ();
13182
  init_molstat (&molstat);
13061
  init_molstat (&molstat);
13183
  if (opt_rs_dll == RPA_DEFAULT) {
13062
  if (opt_rs_dll == RPA_DEFAULT) {
Line 13268... Line 13147...
13268
    update_Htotal ();
13147
    update_Htotal ();
13269
  }
13148
  }
13270
  //printf("mm_elab_mol\n");
13149
  //printf("mm_elab_mol\n");
13271
}
13150
}
13272
 
13151
 
13273
DLLEXPORT void mm_set_current_mol_as_query (void)
13152
DLLEXPORT void mm_set_current_mol_as_query ()
13274
{
13153
{
13275
  //printf("mm_set_current_mol_as_query\n");
13154
  //printf("mm_set_current_mol_as_query\n");
13276
  zap_needle ();
13155
  zap_needle ();
13277
  //mm_ElabMol;
13156
  //mm_ElabMol;
13278
  copy_mol_to_needle ();
13157
  copy_mol_to_needle ();
Line 13304... Line 13183...
13304
  molbufindex = 0;
13183
  molbufindex = 0;
13305
  mol_count = 0;
13184
  mol_count = 0;
13306
  /*printf("mm_set_current_mol_as_query\n");*/
13185
  /*printf("mm_set_current_mol_as_query\n");*/
13307
}
13186
}
13308
 
13187
 
13309
DLLEXPORT int mm_get_rings (void)
13188
DLLEXPORT int mm_get_rings ()
13310
{
13189
{
13311
  return n_rings;
13190
  return n_rings;
13312
}
13191
}
13313
 
13192
 
13314
DLLEXPORT void xm_version (char *buffer)
13193
DLLEXPORT void xm_version (char *buffer)
13315
{
13194
{
13316
  buffer[0] = '\0';
13195
  buffer[0] = '\0';
13317
  strncpy (buffer, version, 255);
13196
  strncpy (buffer, version, 255);
13318
}
13197
}
13319
 
13198
 
13320
DLLEXPORT int mm_get_atom_ring (int atom_number)
13199
DLLEXPORT int mm_get_atom_ring (int atom_number)
13321
{
13200
{
13322
 
13201
 
13323
  int i, j, a1, pl;
13202
  int i, j, a1, pl;
13324
  int ret = 0;
13203
  int ret = 0;
Line 13424... Line 13303...
13424
{
13303
{
13425
  mm_set_mol_dll (st, false, true);
13304
  mm_set_mol_dll (st, false, true);
13426
}
13305
}
13427
 
13306
 
13428
DLLEXPORT void xm_set_strict_typing (int strict_typing)
13307
DLLEXPORT void xm_set_strict_typing (int strict_typing)
13429
{
13308
{
13430
  if (!yet_initialized)
13309
  if (!yet_initialized)
13431
    init_globals_dll ();
13310
    init_globals_dll ();
13432
  opt_strict = (strict_typing != FEATURE_OFF);
13311
  opt_strict = (strict_typing != FEATURE_OFF);
13433
  //opt_strict=false; //This never worked right and is harmful
13312
  //opt_strict=false; //This never worked right and is harmful
13434
}
13313
}
Line 13460... Line 13339...
13460
    init_globals_dll ();
13339
    init_globals_dll ();
13461
  opt_iso = (iso_check != FEATURE_OFF);
13340
  opt_iso = (iso_check != FEATURE_OFF);
13462
}
13341
}
13463
 
13342
 
13464
DLLEXPORT void mm_set_rad_check (int rad_check)
13343
DLLEXPORT void mm_set_rad_check (int rad_check)
13465
{
13344
{
13466
  if (!yet_initialized)
13345
  if (!yet_initialized)
13467
    init_globals_dll ();
13346
    init_globals_dll ();
13468
  opt_rad = (rad_check != FEATURE_OFF);
13347
  opt_rad = (rad_check != FEATURE_OFF);
13469
}
13348
}
13470
 
13349
 
Line 13753... Line 13632...
13753
    sprintf (tmp_buf, "n_chg%s%d%s", sep1, molstat.n_chg, sep2);
13632
    sprintf (tmp_buf, "n_chg%s%d%s", sep1, molstat.n_chg, sep2);
13754
    strcat (out_buffer, tmp_buf);
13633
    strcat (out_buffer, tmp_buf);
13755
  }
13634
  }
13756
  if (molstat.n_C1 > 0) {
13635
  if (molstat.n_C1 > 0) {
13757
    sprintf (tmp_buf, "n_C1%s%d%s", sep1, molstat.n_C1, sep2);
13636
    sprintf (tmp_buf, "n_C1%s%d%s", sep1, molstat.n_C1, sep2);
13758
    strcat (out_buffer, tmp_buf);
13637
    strcat (out_buffer, tmp_buf);
13759
  }
13638
  }
13760
  if (molstat.n_C2 > 0) {
13639
  if (molstat.n_C2 > 0) {
13761
    sprintf (tmp_buf, "n_C2%s%d%s", sep1, molstat.n_C2, sep2);
13640
    sprintf (tmp_buf, "n_C2%s%d%s", sep1, molstat.n_C2, sep2);
13762
    strcat (out_buffer, tmp_buf);
13641
    strcat (out_buffer, tmp_buf);
13763
  }
13642
  }
13764
 
13643
 
13765
  if (molstat.n_C > 0) {
13644
  if (molstat.n_C > 0) {
13766
    sprintf (tmp_buf, "n_C%s%d%s", sep1, molstat.n_C, sep2);
13645
    sprintf (tmp_buf, "n_C%s%d%s", sep1, molstat.n_C, sep2);
13767
    strcat (out_buffer, tmp_buf);
13646
    strcat (out_buffer, tmp_buf);
13768
  }
13647
  }
13769
  if (molstat.n_CHB1p > 0) {
13648
  if (molstat.n_CHB1p > 0) {
13770
    sprintf (tmp_buf, "n_CHB1p%s%d%s", sep1, molstat.n_CHB1p, sep2);
13649
    sprintf (tmp_buf, "n_CHB1p%s%d%s", sep1, molstat.n_CHB1p, sep2);
13771
    strcat (out_buffer, tmp_buf);
13650
    strcat (out_buffer, tmp_buf);
13772
  }
13651
  }
13773
  if (molstat.n_CHB2p > 0) {
13652
  if (molstat.n_CHB2p > 0) {
13774
    sprintf (tmp_buf, "n_CHB2p%s%d%s", sep1, molstat.n_CHB2p, sep2);
13653
    sprintf (tmp_buf, "n_CHB2p%s%d%s", sep1, molstat.n_CHB2p, sep2);
13775
    strcat (out_buffer, tmp_buf);
13654
    strcat (out_buffer, tmp_buf);
13776
  }
13655
  }
13777
  if (molstat.n_CHB3p > 0) {
13656
  if (molstat.n_CHB3p > 0) {
13778
    sprintf (tmp_buf, "n_CHB3p%s%d%s", sep1, molstat.n_CHB3p, sep2);
13657
    sprintf (tmp_buf, "n_CHB3p%s%d%s", sep1, molstat.n_CHB3p, sep2);
13779
    strcat (out_buffer, tmp_buf);
13658
    strcat (out_buffer, tmp_buf);
13780
  }
13659
  }
13781
  if (molstat.n_CHB4 > 0) {
13660
  if (molstat.n_CHB4 > 0) {
Line 13806... Line 13685...
13806
    sprintf (tmp_buf, "n_S%s%d%s", sep1, molstat.n_S, sep2);
13685
    sprintf (tmp_buf, "n_S%s%d%s", sep1, molstat.n_S, sep2);
13807
    strcat (out_buffer, tmp_buf);
13686
    strcat (out_buffer, tmp_buf);
13808
  }
13687
  }
13809
  if (molstat.n_SeTe > 0) {
13688
  if (molstat.n_SeTe > 0) {
13810
    sprintf (tmp_buf, "n_SeTe%s%d%s", sep1, molstat.n_SeTe, sep2);
13689
    sprintf (tmp_buf, "n_SeTe%s%d%s", sep1, molstat.n_SeTe, sep2);
13811
    strcat (out_buffer, tmp_buf);
13690
    strcat (out_buffer, tmp_buf);
13812
  }
13691
  }
13813
  if (molstat.n_F > 0) {
13692
  if (molstat.n_F > 0) {
13814
    sprintf (tmp_buf, "n_F%s%d%s", sep1, molstat.n_F, sep2);
13693
    sprintf (tmp_buf, "n_F%s%d%s", sep1, molstat.n_F, sep2);
13815
    strcat (out_buffer, tmp_buf);
13694
    strcat (out_buffer, tmp_buf);
13816
  }
13695
  }
13817
  if (molstat.n_Cl > 0) {
13696
  if (molstat.n_Cl > 0) {
Line 13842... Line 13721...
13842
    sprintf (tmp_buf, "n_X%s%d%s", sep1, molstat.n_X, sep2);
13721
    sprintf (tmp_buf, "n_X%s%d%s", sep1, molstat.n_X, sep2);
13843
    strcat (out_buffer, tmp_buf);
13722
    strcat (out_buffer, tmp_buf);
13844
  }
13723
  }
13845
  if (molstat.n_b1 > 0) {
13724
  if (molstat.n_b1 > 0) {
13846
    sprintf (tmp_buf, "n_b1%s%d%s", sep1, molstat.n_b1, sep2);
13725
    sprintf (tmp_buf, "n_b1%s%d%s", sep1, molstat.n_b1, sep2);
13847
    strcat (out_buffer, tmp_buf);
13726
    strcat (out_buffer, tmp_buf);
13848
  }
13727
  }
13849
  if (molstat.n_b2 > 0) {
13728
  if (molstat.n_b2 > 0) {
13850
    sprintf (tmp_buf, "n_b2%s%d%s", sep1, molstat.n_b2, sep2);
13729
    sprintf (tmp_buf, "n_b2%s%d%s", sep1, molstat.n_b2, sep2);
13851
    strcat (out_buffer, tmp_buf);
13730
    strcat (out_buffer, tmp_buf);
13852
  }
13731
  }
13853
  if (molstat.n_b3 > 0) {
13732
  if (molstat.n_b3 > 0) {
Line 13878... Line 13757...
13878
    sprintf (tmp_buf, "n_r3%s%d%s", sep1, molstat.n_r3, sep2);
13757
    sprintf (tmp_buf, "n_r3%s%d%s", sep1, molstat.n_r3, sep2);
13879
    strcat (out_buffer, tmp_buf);
13758
    strcat (out_buffer, tmp_buf);
13880
  }
13759
  }
13881
  if (molstat.n_r4 > 0) {
13760
  if (molstat.n_r4 > 0) {
13882
    sprintf (tmp_buf, "n_r4%s%d%s", sep1, molstat.n_r4, sep2);
13761
    sprintf (tmp_buf, "n_r4%s%d%s", sep1, molstat.n_r4, sep2);
13883
    strcat (out_buffer, tmp_buf);
13762
    strcat (out_buffer, tmp_buf);
13884
  }
13763
  }
13885
  if (molstat.n_r5 > 0) {
13764
  if (molstat.n_r5 > 0) {
13886
    sprintf (tmp_buf, "n_r5%s%d%s", sep1, molstat.n_r5, sep2);
13765
    sprintf (tmp_buf, "n_r5%s%d%s", sep1, molstat.n_r5, sep2);
13887
    strcat (out_buffer, tmp_buf);
13766
    strcat (out_buffer, tmp_buf);
13888
  }
13767
  }
13889
  if (molstat.n_r6 > 0) {
13768
  if (molstat.n_r6 > 0) {
13890
    sprintf (tmp_buf, "n_r6%s%d%s", sep1, molstat.n_r6, sep2);
13769
    sprintf (tmp_buf, "n_r6%s%d%s", sep1, molstat.n_r6, sep2);
13891
    strcat (out_buffer, tmp_buf);
13770
    strcat (out_buffer, tmp_buf);
13892
  }
13771
  }
13893
  if (molstat.n_r7 > 0) {
13772
  if (molstat.n_r7 > 0) {
13894
    sprintf (tmp_buf, "n_r7%s%d%s", sep1, molstat.n_r7, sep2);
13773
    sprintf (tmp_buf, "n_r7%s%d%s", sep1, molstat.n_r7, sep2);
13895
    strcat (out_buffer, tmp_buf);
13774
    strcat (out_buffer, tmp_buf);
13896
  }
13775
  }
13897
  if (molstat.n_r8 > 0) {
13776
  if (molstat.n_r8 > 0) {
13898
    sprintf (tmp_buf, "n_r8%s%d%s", sep1, molstat.n_r8, sep2);
13777
    sprintf (tmp_buf, "n_r8%s%d%s", sep1, molstat.n_r8, sep2);
13899
    strcat (out_buffer, tmp_buf);
13778
    strcat (out_buffer, tmp_buf);
13900
  }
13779
  }
13901
  if (molstat.n_r9 > 0) {
13780
  if (molstat.n_r9 > 0) {
13902
    sprintf (tmp_buf, "n_r9%s%d%s", sep1, molstat.n_r9, sep2);
13781
    sprintf (tmp_buf, "n_r9%s%d%s", sep1, molstat.n_r9, sep2);
13903
    strcat (out_buffer, tmp_buf);
13782
    strcat (out_buffer, tmp_buf);
13904
  }
13783
  }
13905
  if (molstat.n_r10 > 0) {
13784
  if (molstat.n_r10 > 0) {
13906
    sprintf (tmp_buf, "n_r10%s%d%s", sep1, molstat.n_r10, sep2);
13785
    sprintf (tmp_buf, "n_r10%s%d%s", sep1, molstat.n_r10, sep2);
13907
    strcat (out_buffer, tmp_buf);
13786
    strcat (out_buffer, tmp_buf);
13908
  }
13787
  }
13909
  if (molstat.n_r11 > 0) {
13788
  if (molstat.n_r11 > 0) {
13910
    sprintf (tmp_buf, "n_r11%s%d%s", sep1, molstat.n_r11, sep2);
13789
    sprintf (tmp_buf, "n_r11%s%d%s", sep1, molstat.n_r11, sep2);
13911
    strcat (out_buffer, tmp_buf);
13790
    strcat (out_buffer, tmp_buf);
13912
  }
13791
  }
13913
  if (molstat.n_r12 > 0) {
13792
  if (molstat.n_r12 > 0) {
13914
    sprintf (tmp_buf, "n_r12%s%d%s", sep1, molstat.n_r12, sep2);
13793
    sprintf (tmp_buf, "n_r12%s%d%s", sep1, molstat.n_r12, sep2);
13915
    strcat (out_buffer, tmp_buf);
13794
    strcat (out_buffer, tmp_buf);
13916
  }
13795
  }
13917
  if (molstat.n_r13p > 0) {
13796
  if (molstat.n_r13p > 0) {
13918
      sprintf (tmp_buf, "n_r13p%s%d%s", sep1, molstat.n_r13p, sep2);
13797
      sprintf (tmp_buf, "n_r13p%s%d%s", sep1, molstat.n_r13p, sep2);
13919
      strcat (out_buffer, tmp_buf);
13798
      strcat (out_buffer, tmp_buf);
13920
    }
13799
    }
13921
  if (molstat.n_rN > 0) {
13800
  if (molstat.n_rN > 0) {
13922
    sprintf (tmp_buf, "n_rN%s%d%s", sep1, molstat.n_rN, sep2);
13801
    sprintf (tmp_buf, "n_rN%s%d%s", sep1, molstat.n_rN, sep2);
13923
    strcat (out_buffer, tmp_buf);
13802
    strcat (out_buffer, tmp_buf);
13924
  }
13803
  }
13925
  if (molstat.n_rN1 > 0) {
13804
  if (molstat.n_rN1 > 0) {
13926
    sprintf (tmp_buf, "n_rN1%s%d%s", sep1, molstat.n_rN1, sep2);
13805
    sprintf (tmp_buf, "n_rN1%s%d%s", sep1, molstat.n_rN1, sep2);
13927
    strcat (out_buffer, tmp_buf);
13806
    strcat (out_buffer, tmp_buf);
13928
  }
13807
  }
Line 13954... Line 13833...
13954
    sprintf (tmp_buf, "n_rX%s%d%s", sep1, molstat.n_rX, sep2);
13833
    sprintf (tmp_buf, "n_rX%s%d%s", sep1, molstat.n_rX, sep2);
13955
    strcat (out_buffer, tmp_buf);
13834
    strcat (out_buffer, tmp_buf);
13956
  }
13835
  }
13957
  if (molstat.n_rAr > 0) {
13836
  if (molstat.n_rAr > 0) {
13958
    sprintf (tmp_buf, "n_rar%s%d%s", sep1, molstat.n_rAr, sep2);
13837
    sprintf (tmp_buf, "n_rar%s%d%s", sep1, molstat.n_rAr, sep2);
13959
    strcat (out_buffer, tmp_buf);
13838
    strcat (out_buffer, tmp_buf);
13960
  }
13839
  }
13961
 
13840
 
13962
  if (molstat.n_rBz > 0) {
13841
  if (molstat.n_rBz > 0) {
13963
    sprintf (tmp_buf, "n_rbz%s%d%s", sep1, molstat.n_rBz, sep2);
13842
    sprintf (tmp_buf, "n_rbz%s%d%s", sep1, molstat.n_rBz, sep2);
13964
    strcat (out_buffer, tmp_buf);
13843
    strcat (out_buffer, tmp_buf);
13965
  }
13844
  }
Line 13989... Line 13868...
13989
    strcat (out_buffer, tmp_buf);
13868
    strcat (out_buffer, tmp_buf);
13990
  }
13869
  }
13991
 
13870
 
13992
  if (molstat.n_psg15 > 0) {
13871
  if (molstat.n_psg15 > 0) {
13993
    sprintf (tmp_buf, "n_psg15%s%d%s", sep1, molstat.n_psg15, sep2);
13872
    sprintf (tmp_buf, "n_psg15%s%d%s", sep1, molstat.n_psg15, sep2);
13994
    strcat (out_buffer, tmp_buf);
13873
    strcat (out_buffer, tmp_buf);
13995
  }
13874
  }
13996
 
13875
 
13997
  if (molstat.n_psg16 > 0) {
13876
  if (molstat.n_psg16 > 0) {
13998
    sprintf (tmp_buf, "n_psg16%s%d%s", sep1, molstat.n_psg16, sep2);
13877
    sprintf (tmp_buf, "n_psg16%s%d%s", sep1, molstat.n_psg16, sep2);
13999
    strcat (out_buffer, tmp_buf);
13878
    strcat (out_buffer, tmp_buf);
14000
  }
13879
  }
14001
 
13880
 
14002
  if (molstat.n_psg17 > 0) {
13881
  if (molstat.n_psg17 > 0) {
14003
    sprintf (tmp_buf, "n_psg17%s%d%s", sep1, molstat.n_psg17, sep2);
13882
    sprintf (tmp_buf, "n_psg17%s%d%s", sep1, molstat.n_psg17, sep2);
14004
    strcat (out_buffer, tmp_buf);
13883
    strcat (out_buffer, tmp_buf);
14005
  }
13884
  }
14006
 
13885
 
14007
  if (molstat.n_psg18 > 0) {
13886
  if (molstat.n_psg18 > 0) {
14008
    sprintf (tmp_buf, "n_psg18%s%d%s", sep1, molstat.n_psg18, sep2);
13887
    sprintf (tmp_buf, "n_psg18%s%d%s", sep1, molstat.n_psg18, sep2);
14009
    strcat (out_buffer, tmp_buf);
13888
    strcat (out_buffer, tmp_buf);
14010
  }
13889
  }
14011
 
13890
 
14012
  if (molstat.n_pstm > 0) {
13891
  if (molstat.n_pstm > 0) {
14013
      sprintf (tmp_buf, "n_pstm%s%d%s", sep1, molstat.n_pstm, sep2);
13892
      sprintf (tmp_buf, "n_pstm%s%d%s", sep1, molstat.n_pstm, sep2);
14014
      strcat (out_buffer, tmp_buf);
13893
      strcat (out_buffer, tmp_buf);
14015
    }
13894
    }
14016
 
13895
 
14017
  if (molstat.n_psla > 0) {
13896
  if (molstat.n_psla > 0) {
14018
      sprintf (tmp_buf, "n_psla%s%d%s", sep1, molstat.n_psla, sep2);
13897
      sprintf (tmp_buf, "n_psla%s%d%s", sep1, molstat.n_psla, sep2);
14019
      strcat (out_buffer, tmp_buf);
13898
      strcat (out_buffer, tmp_buf);
14020
    }
13899
    }
Line 14028... Line 13907...
14028
    sprintf (tmp_buf, "n_rad%s%d%s", sep1, molstat.n_rad, sep2);
13907
    sprintf (tmp_buf, "n_rad%s%d%s", sep1, molstat.n_rad, sep2);
14029
    strcat (out_buffer, tmp_buf);
13908
    strcat (out_buffer, tmp_buf);
14030
  }
13909
  }
14031
}
13910
}
14032
 
13911
 
14033
static void
-
 
14034
write_fg_code_dll (char *out_buffer)
13912
static void write_fg_code_dll (char *out_buffer)
14035
{
13913
{
14036
  char tmp_buf[256];
13914
  char tmp_buf[256];
14037
  out_buffer[0] = '\0';
13915
  out_buffer[0] = '\0';
14038
  if (fg[fg_cation - 1]) {
13916
  if (fg[fg_cation - 1]) {
14039
    sprintf (tmp_buf, "000000T2;");
13917
    sprintf (tmp_buf, "000000T2;");
Line 14048... Line 13926...
14048
    sprintf (tmp_buf, "C2O1H000;");
13926
    sprintf (tmp_buf, "C2O1H000;");
14049
    strcat (out_buffer, tmp_buf);
13927
    strcat (out_buffer, tmp_buf);
14050
  }
13928
  }
14051
  if (fg[fg_ketone - 1]) {
13929
  if (fg[fg_ketone - 1]) {
14052
    sprintf (tmp_buf, "C2O1C000;");
13930
    sprintf (tmp_buf, "C2O1C000;");
14053
    strcat (out_buffer, tmp_buf);
13931
    strcat (out_buffer, tmp_buf);
14054
  }
13932
  }
14055
 
13933
 
14056
  if (fg[fg_thioaldehyde - 1]) {
13934
  if (fg[fg_thioaldehyde - 1]) {
14057
    sprintf (tmp_buf, "C2S1H000;");
13935
    sprintf (tmp_buf, "C2S1H000;");
14058
    strcat (out_buffer, tmp_buf);
13936
    strcat (out_buffer, tmp_buf);
Line 14341... Line 14219...
14341
    sprintf (tmp_buf, "C3ONN200;");
14219
    sprintf (tmp_buf, "C3ONN200;");
14342
    strcat (out_buffer, tmp_buf);
14220
    strcat (out_buffer, tmp_buf);
14343
  }
14221
  }
14344
  if (fg[fg_hydroxamic_acid - 1]) {
14222
  if (fg[fg_hydroxamic_acid - 1]) {
14345
    sprintf (tmp_buf, "C3ONOH00;");
14223
    sprintf (tmp_buf, "C3ONOH00;");
14346
    strcat (out_buffer, tmp_buf);
14224
    strcat (out_buffer, tmp_buf);
14347
  }
14225
  }
14348
  if (fg[fg_carboxylic_acid_amidine - 1]) {
14226
  if (fg[fg_carboxylic_acid_amidine - 1]) {
14349
    sprintf (tmp_buf, "C3N2H000;");
14227
    sprintf (tmp_buf, "C3N2H000;");
14350
    strcat (out_buffer, tmp_buf);
14228
    strcat (out_buffer, tmp_buf);
14351
  }
14229
  }
Line 14632... Line 14510...
14632
    sprintf (tmp_buf, "S5O00000;");
14510
    sprintf (tmp_buf, "S5O00000;");
14633
    strcat (out_buffer, tmp_buf);
14511
    strcat (out_buffer, tmp_buf);
14634
  }
14512
  }
14635
  if (fg[fg_sulfonic_acid - 1]) {
14513
  if (fg[fg_sulfonic_acid - 1]) {
14636
    sprintf (tmp_buf, "S5O3H000;");
14514
    sprintf (tmp_buf, "S5O3H000;");
14637
    strcat (out_buffer, tmp_buf);
14515
    strcat (out_buffer, tmp_buf);
14638
  }
14516
  }
14639
  if (fg[fg_sulfonic_acid_ester - 1]) {
14517
  if (fg[fg_sulfonic_acid_ester - 1]) {
14640
    sprintf (tmp_buf, "S5O3C000;");
14518
    sprintf (tmp_buf, "S5O3C000;");
14641
    strcat (out_buffer, tmp_buf);
14519
    strcat (out_buffer, tmp_buf);
14642
  }
14520
  }
14643
  if (fg[fg_sulfonamide - 1]) {
14521
  if (fg[fg_sulfonamide - 1]) {
Line 14926... Line 14804...
14926
  sprintf (tmpstr, "%d", n_bonds);
14804
  sprintf (tmpstr, "%d", n_bonds);
14927
  lblank (3L, tmpstr);
14805
  lblank (3L, tmpstr);
14928
  strcat (wline, tmpstr);
14806
  strcat (wline, tmpstr);
14929
  *tmpstr = '\0';               /* next 3 digits: number of bonds */
14807
  *tmpstr = '\0';               /* next 3 digits: number of bonds */
14930
  strcpy (tmpstr, "  0");
14808
  strcpy (tmpstr, "  0");
14931
  strcat (wline, tmpstr);
14809
  strcat (wline, tmpstr);
14932
  /* next 3 digits: number of atom lists (not used by us) */
14810
  /* next 3 digits: number of atom lists (not used by us) */
14933
  /* p2c: checkmol.pas, line 2388:
14811
  /* p2c: checkmol.pas, line 2388:
14934
  * Note: Turbo Pascal conditional compilation directive was ignored [218] */
14812
  * Note: Turbo Pascal conditional compilation directive was ignored [218] */
14935
#ifdef REDUCED_SAR
14813
#ifdef REDUCED_SAR
14936
  sprintf (tmpstr, "%d", n_countablerings);
14814
  sprintf (tmpstr, "%d", n_countablerings);
Line 14981... Line 14859...
14981
    strcat (out_buffer, wline);
14859
    strcat (out_buffer, wline);
14982
  }
14860
  }
14983
  FORLIM = n_bonds;
14861
  FORLIM = n_bonds;
14984
  for (i = 0; i < FORLIM; i++) {
14862
  for (i = 0; i < FORLIM; i++) {
14985
    *wline = '\0';
14863
    *wline = '\0';
14986
    *tmpstr = '\0';
14864
    *tmpstr = '\0';
14987
    sprintf (tmpstr, "%d", bond[i].a1);
14865
    sprintf (tmpstr, "%d", bond[i].a1);
14988
    lblank (3L, tmpstr);
14866
    lblank (3L, tmpstr);
14989
    strcat (wline, tmpstr);
14867
    strcat (wline, tmpstr);
14990
    sprintf (tmpstr, "%d", bond[i].a2);
14868
    sprintf (tmpstr, "%d", bond[i].a2);
14991
    lblank (3L, tmpstr);
14869
    lblank (3L, tmpstr);
Line 15035... Line 14913...
15035
            strcpy (wline, "M  CHG  1 ");
14913
            strcpy (wline, "M  CHG  1 ");
15036
            sprintf (tmpstr, "%d", i);
14914
            sprintf (tmpstr, "%d", i);
15037
            lblank (3L, tmpstr);
14915
            lblank (3L, tmpstr);
15038
            sprintf (wline + strlen (wline), "%s ", tmpstr);
14916
            sprintf (wline + strlen (wline), "%s ", tmpstr);
15039
            sprintf (tmpstr, "%d", a_chg);
14917
            sprintf (tmpstr, "%d", a_chg);
15040
            lblank (3L, tmpstr);
14918
            lblank (3L, tmpstr);
15041
            strcat (wline, tmpstr);
14919
            strcat (wline, tmpstr);
15042
            strcat (out_buffer, wline);
14920
            strcat (out_buffer, wline);
15043
            strcat (out_buffer, "\n");
14921
            strcat (out_buffer, "\n");
15044
          }
14922
          }
15045
  }
14923
  }
15046
  for (i = 1; i <= FORLIM; i++) /* 0.3x */ {
14924
  for (i = 1; i <= FORLIM; i++) /* 0.3x */ {
15047
    a_iso = atom[i - 1].nucleon_number;
14925
    a_iso = atom[i - 1].nucleon_number;
15048
    if (a_iso != 0) {
14926
    if (a_iso != 0) {
15049
            strcpy (wline, "M  ISO  1 ");
14927
            strcpy (wline, "M  ISO  1 ");
15050
            sprintf (tmpstr, "%d", i);
14928
            sprintf (tmpstr, "%d", i);
15051
            lblank (3L, tmpstr);
14929
            lblank (3L, tmpstr);
15052
            sprintf (wline + strlen (wline), "%s ", tmpstr);
14930
            sprintf (wline + strlen (wline), "%s ", tmpstr);
15053
            sprintf (tmpstr, "%d", a_iso);
14931
            sprintf (tmpstr, "%d", a_iso);
15054
            lblank (3L, tmpstr);
14932
            lblank (3L, tmpstr);
15055
            strcat (wline, tmpstr);
14933
            strcat (wline, tmpstr);
15056
            strcat (out_buffer, wline);
14934
            strcat (out_buffer, wline);
15057
            strcat (out_buffer, "\n");
14935
            strcat (out_buffer, "\n");
15058
          }
14936
          }
15059
  }
14937
  }
15060
  for (i = 1; i <= FORLIM; i++) /* 0.3x */ {
14938
  for (i = 1; i <= FORLIM; i++) /* 0.3x */ {
15061
    a_rad = atom[i - 1].radical_type;
14939
    a_rad = atom[i - 1].radical_type;
15062
    if (a_rad != 0) {
14940
    if (a_rad != 0) {
15063
            strcpy (wline, "M  RAD  1 ");
14941
            strcpy (wline, "M  RAD  1 ");
15064
            sprintf (tmpstr, "%d", i);
14942
            sprintf (tmpstr, "%d", i);
Line 15072... Line 14950...
15072
          }
14950
          }
15073
  }
14951
  }
15074
  strcat (out_buffer, "M  END\n");
14952
  strcat (out_buffer, "M  END\n");
15075
}
14953
}
15076
 
14954
 
15077
DLLEXPORT void
-
 
15078
cm_tweak_molfile (char *buf)
14955
DLLEXPORT void cm_tweak_molfile (char *buf)
15079
{
14956
{
15080
//chk_functionalgroups();
14957
//chk_functionalgroups();
15081
  write_MDLmolfile_dll (buf);
14958
  write_MDLmolfile_dll (buf);
15082
}
14959
}
15083
#endif
14960
#endif