Subversion Repositories wimsdev

Rev

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

Rev 5505 Rev 6785
Line 951... Line 951...
951
}
951
}
952
 
952
 
953
static void
953
static void
954
init_globals ()
954
init_globals ()
955
{
955
{
956
  int i;
956
  /*int i;*/
957
 
957
 
958
  opt_verbose = false;
958
  opt_verbose = false;
959
  opt_debug = false;
959
  opt_debug = false;
960
  opt_exact = false;
960
  opt_exact = false;
961
  opt_stdin = false;
961
  opt_stdin = false;
Line 1047... Line 1047...
1047
   */
1047
   */
1048
  memset (mstat, 0, sizeof (molstat_rec));      /* v0.3k */
1048
  memset (mstat, 0, sizeof (molstat_rec));      /* v0.3k */
1049
}
1049
}
1050
 
1050
 
1051
 
1051
 
-
 
1052
#if 0
1052
static void
1053
static void
1053
debugoutput (dstr)
1054
debugoutput (dstr)
1054
     char *dstr;
1055
     char *dstr;
1055
{
1056
{
1056
  if (opt_debug)
1057
  if (opt_debug)
1057
    printf ("%s\n", dstr);
1058
    printf ("%s\n", dstr);
1058
}
1059
}
1059
 
1060
#endif
1060
 
1061
 
1061
static void
1062
static void
1062
left_trim (trimstr)
1063
left_trim (trimstr)
1063
     char *trimstr;
1064
     char *trimstr;
1064
{
1065
{
Line 1072... Line 1073...
1072
     char *trimstr;
1073
     char *trimstr;
1073
{
1074
{
1074
  char numstr[256];
1075
  char numstr[256];
1075
  char auxstr[256];
1076
  char auxstr[256];
1076
  int auxint = 0;
1077
  int auxint = 0;
1077
  int code;
1078
 /* int code;*/
1078
  char STR1[256];
1079
  char STR1[256];
1079
 
1080
 
1080
  strcpy (numstr, "-+0123456789");
1081
  strcpy (numstr, "-+0123456789");
1081
  *auxstr = '\0';
1082
  *auxstr = '\0';
1082
  while (*trimstr != '\0' && (trimstr[0] == ' ' || trimstr[0] == TAB))
1083
  while (*trimstr != '\0' && (trimstr[0] == ' ' || trimstr[0] == TAB))
Line 1085... Line 1086...
1085
         (strpos2 (numstr, (sprintf (STR1, "%c", trimstr[0]), STR1), 1) > 0))
1086
         (strpos2 (numstr, (sprintf (STR1, "%c", trimstr[0]), STR1), 1) > 0))
1086
    {
1087
    {
1087
      sprintf (auxstr + strlen (auxstr), "%c", trimstr[0]);
1088
      sprintf (auxstr + strlen (auxstr), "%c", trimstr[0]);
1088
      strdelete (trimstr, 1, 1);
1089
      strdelete (trimstr, 1, 1);
1089
    }
1090
    }
1090
  code = (sscanf (auxstr, "%d", &auxint) == 0);
1091
 /* code = (sscanf (auxstr, "%d", &auxint) == 0);*/
1091
  return auxint;
1092
  return auxint;
1092
}
1093
}
1093
 
1094
 
1094
static int
1095
static int
1095
path_pos (int id, int *a_path)
1096
path_pos (int id, int *a_path)
Line 1125... Line 1126...
1125
  if (n_bonds <= 0)
1126
  if (n_bonds <= 0)
1126
    return b_id;
1127
    return b_id;
1127
  FORLIM = n_bonds;
1128
  FORLIM = n_bonds;
1128
  for (i = 1; i <= FORLIM; i++)
1129
  for (i = 1; i <= FORLIM; i++)
1129
    {
1130
    {
1130
      if (bond[i - 1].a1 == ba1 && bond[i - 1].a2 == ba2 ||
1131
      if ((bond[i - 1].a1 == ba1 && bond[i - 1].a2 == ba2) ||
1131
          bond[i - 1].a1 == ba2 && bond[i - 1].a2 == ba1)
1132
          (bond[i - 1].a1 == ba2 && bond[i - 1].a2 == ba1))
1132
        b_id = i;
1133
        b_id = i;
1133
    }
1134
    }
1134
  return b_id;
1135
  return b_id;
1135
}
1136
}
1136
 
1137
 
1137
static void
1138
static void
1138
clear_atom_tags ()
1139
clear_atom_tags ()
1139
{
1140
{
1140
  int i, FORLIM;
1141
  int i, FORLIM;
1141
 
1142
 
1142
  if (n_atoms > 0)
1143
  if (n_atoms > 0)
1143
    {
1144
    {
1144
      FORLIM = n_atoms;
1145
      FORLIM = n_atoms;
1145
      for (i = 0; i < FORLIM; i++)
1146
      for (i = 0; i < FORLIM; i++)
1146
        atom[i].tag = false;
1147
        atom[i].tag = false;
1147
    }
1148
    }
1148
}
1149
}
1149
 
1150
 
-
 
1151
#if 0
1150
static void
1152
static void
1151
set_atom_tags ()
1153
set_atom_tags ()
1152
{
1154
{
1153
  int i, FORLIM;
1155
  int i, FORLIM;
1154
 
1156
 
1155
  if (n_atoms > 0)
1157
  if (n_atoms > 0)
1156
    {
1158
    {
1157
      FORLIM = n_atoms;
1159
      FORLIM = n_atoms;
1158
      for (i = 0; i < FORLIM; i++)
1160
      for (i = 0; i < FORLIM; i++)
1159
        atom[i].tag = true;
1161
        atom[i].tag = true;
1160
    }
1162
    }
1161
}
1163
}
1162
 
1164
#endif
1163
static void
1165
static void
1164
order_ringpath (int *r_path)
1166
order_ringpath (int *r_path)
1165
{
1167
{
1166
  /* order should be: array starts with atom of lowest number, followed by neighbor atom with lower number */
1168
  /* order should be: array starts with atom of lowest number, followed by neighbor atom with lower number */
1167
  int i, pl, a_ref, a_left, a_right, a_tmp;
1169
  int i, pl, a_ref, a_left, a_right, a_tmp;
Line 1320... Line 1322...
1320
  p.y = p1.y + p2.y;
1322
  p.y = p1.y + p2.y;
1321
  p.z = p1.z + p2.z;
1323
  p.z = p1.z + p2.z;
1322
  return p;
1324
  return p;
1323
}
1325
}
1324
 
1326
 
1325
 
1327
#if 0
1326
static void
1328
static void
1327
vec2origin (p1, p2)
1329
vec2origin (p1, p2)
1328
     p_3d *p1, *p2;
1330
     p_3d *p1, *p2;
1329
{
1331
{
1330
  p_3d p;
1332
  p_3d p;
Line 1332... Line 1334...
1332
  p = subtract_3d (*p2, *p1);
1334
  p = subtract_3d (*p2, *p1);
1333
  *p2 = p;
1335
  *p2 = p;
1334
  p1->x = 0.0;
1336
  p1->x = 0.0;
1335
  p1->y = 0.0;
1337
  p1->y = 0.0;
1336
  p1->z = 0.0;
1338
  p1->z = 0.0;
1337
}
1339
}
1338
 
1340
#endif
1339
 
1341
 
1340
static double
1342
static double
1341
scalar_prod (p1, p2, p3)
1343
scalar_prod (p1, p2, p3)
1342
     p_3d p1, p2, p3;
1344
     p_3d p1, p2, p3;
1343
{
1345
{
1344
  p_3d p;
1346
  p_3d p;
1345
  double res;
1347
  double res;
1346
 
1348
 
1347
  p = subtract_3d (p2, p1);
1349
  p = subtract_3d (p2, p1);
1348
  p2 = p;
1350
  p2 = p;
1349
  p = subtract_3d (p3, p1);
1351
  p = subtract_3d (p3, p1);
1350
  p3 = p;
1352
  p3 = p;
1351
  p1.x = 0.0;
1353
  p1.x = 0.0;
1352
  p1.y = 0.0;
1354
  p1.y = 0.0;
Line 1356... Line 1358...
1356
}
1358
}
1357
 
1359
 
1358
 
1360
 
1359
static p_3d
1361
static p_3d
1360
cross_prod (p1, p2, p3)
1362
cross_prod (p1, p2, p3)
1361
     p_3d p1, p2, p3;
1363
     p_3d p1, p2, p3;
1362
{
1364
{
1363
  p_3d p, orig_p1;
1365
  p_3d p, orig_p1;
1364
 
1366
 
1365
  orig_p1 = p1;
1367
  orig_p1 = p1;
1366
  p = subtract_3d (p2, p1);
1368
  p = subtract_3d (p2, p1);
1367
  p2 = p;
1369
  p2 = p;
Line 1379... Line 1381...
1379
     p_3d p1, p2, p3;
1381
     p_3d p1, p2, p3;
1380
{
1382
{
1381
  p_3d lp1, lp2, lp3, p;
1383
  p_3d lp1, lp2, lp3, p;
1382
  double res = 0.0;
1384
  double res = 0.0;
1383
  double magn_1, magn_2, cos_phi;
1385
  double magn_1, magn_2, cos_phi;
1384
 
1386
 
1385
  lp1 = p1;
1387
  lp1 = p1;
1386
  lp2 = p2;
1388
  lp2 = p2;
1387
  lp3 = p3;
1389
  lp3 = p3;
1388
  p = subtract_3d (lp2, lp1);
1390
  p = subtract_3d (lp2, lp1);
1389
  lp2 = p;
1391
  lp2 = p;
Line 1663... Line 1665...
1663
  printf ("n_rad:      number of radicals\n");
1665
  printf ("n_rad:      number of radicals\n");
1664
  /*$ENDIF */
1666
  /*$ENDIF */
1665
}
1667
}
1666
 
1668
 
1667
 
1669
 
-
 
1670
#if 0
1668
/*static void parse_args()
1671
static void parse_args()
1669
{
1672
{
1670
  int p;
1673
  int p;
1671
  char parstr[256];
1674
  char parstr[256];
1672
  char tmpstr[256];
1675
  char tmpstr[256];
1673
  int l;
1676
  int l;
Line 1675... Line 1678...
1675
  *tmpstr = '\0';
1678
  *tmpstr = '\0';
1676
  opt_none = true;
1679
  opt_none = true;
1677
  if (progmode == pmCheckMol) {
1680
  if (progmode == pmCheckMol) {
1678
    for (p = 1; p < P_argc; p++) {
1681
    for (p = 1; p < P_argc; p++) {
1679
      strcpy(parstr, P_argv[p]);
1682
      strcpy(parstr, P_argv[p]);
1680
      if (!strcmp(parstr, "-l")) {   /* new in v0.3l
1683
      if (!strcmp(parstr, "-l")) {   /* new in v0.3l */
1681
        list_molstat_codes();
1684
        list_molstat_codes();
1682
        _Escape(0);
1685
        _Escape(0);
1683
      }
1686
      }
1684
      if (p < P_argc - 1) {
1687
      if (p < P_argc - 1) {
1685
        if (strpos2(parstr, "-", 1) == 1 && p < P_argc - 1) {
1688
        if (strpos2(parstr, "-", 1) == 1 && p < P_argc - 1) {
Line 1690... Line 1693...
1690
            l++;
1693
            l++;
1691
          if (strpos2(tmpstr, "D", 1) > 0)
1694
          if (strpos2(tmpstr, "D", 1) > 0)
1692
            l++;
1695
            l++;
1693
          if (strpos2(tmpstr, "r", 1) > 0)
1696
          if (strpos2(tmpstr, "r", 1) > 0)
1694
            l++;
1697
            l++;
1695
          if (strpos2(tmpstr, "M", 1) > 0)   /* new in v0.3
1698
          if (strpos2(tmpstr, "M", 1) > 0)   /* new in v0.3 */
1696
            l++;
1699
            l++;
1697
          if (strlen(tmpstr) > l + 2) {
1700
          if (strlen(tmpstr) > l + 2) {
1698
            show_usage();
1701
            show_usage();
1699
            _Escape(1);
1702
            _Escape(1);
1700
          }
1703
          }
Line 1702... Line 1705...
1702
          if (strpos2(tmpstr, "M", 1) > 0)
1705
          if (strpos2(tmpstr, "M", 1) > 0)
1703
            opt_metalrings = true;
1706
            opt_metalrings = true;
1704
          if (strpos2(tmpstr, "v", 1) > 0)
1707
          if (strpos2(tmpstr, "v", 1) > 0)
1705
            opt_verbose = true;
1708
            opt_verbose = true;
1706
/* p2c: checkmol.pas, line 1261:
1709
/* p2c: checkmol.pas, line 1261:
1707
 * Note: Turbo Pascal conditional compilation directive was ignored [218]
1710
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
1708
          /*$IFDEF debug
1711
          /*$IFDEF debug
1709
          if (strpos2(tmpstr, "D", 1) > 0)
1712
          if (strpos2(tmpstr, "D", 1) > 0)
1710
            opt_debug = true;
1713
            opt_debug = true;
1711
          /*$ENDIF
1714
          $ENDIF*/
1712
          if (strpos2(tmpstr, "e", 1) > 0)
1715
          if (strpos2(tmpstr, "e", 1) > 0)
1713
            opt_text = true;
1716
            opt_text = true;
1714
          else {
1717
          else {
1715
            if (strpos2(tmpstr, "d", 1) > 0)
1718
            if (strpos2(tmpstr, "d", 1) > 0)
1716
              opt_text_de = true;
1719
              opt_text_de = true;
Line 1776... Line 1779...
1776
/* p2c: checkmol.pas, line 1329:
1779
/* p2c: checkmol.pas, line 1329:
1777
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
1780
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
1778
          /*$IFDEF debug
1781
          /*$IFDEF debug
1779
             if (strpos2(parstr, "D", 1) > 1)
1782
             if (strpos2(parstr, "D", 1) > 1)
1780
             opt_debug = true;
1783
             opt_debug = true;
1781
             /*$ENDIF
1784
             $ENDIF*/
1782
             if (strpos2(parstr, "x", 1) > 1)
1785
             if (strpos2(parstr, "x", 1) > 1)
1783
             opt_exact = true;
1786
             opt_exact = true;
1784
             if (strpos2(parstr, "s", 1) > 1)   /* new in v0.2f
1787
             if (strpos2(parstr, "s", 1) > 1)   /* new in v0.2f */
1785
             opt_strict = true;
1788
             opt_strict = true;
1786
             if (strpos2(parstr, "m", 1) > 1)
1789
             if (strpos2(parstr, "m", 1) > 1)
1787
             opt_molout = true;
1790
             opt_molout = true;
1788
             if (strpos2(parstr, "r", 1) > 1)
1791
             if (strpos2(parstr, "r", 1) > 1)
1789
             opt_rs = rs_ssr;
1792
             opt_rs = rs_ssr;
1790
             if (strpos2(parstr, "M", 1) > 0)   /* new in v0.3
1793
             if (strpos2(parstr, "M", 1) > 0)   /* new in v0.3 */
1791
             opt_metalrings = true;
1794
             opt_metalrings = true;
1792
             if (strpos2(parstr, "g", 1) > 0)   /* new in v0.3d
1795
             if (strpos2(parstr, "g", 1) > 0)   /* new in v0.3d */
1793
             opt_geom = true;
1796
             opt_geom = true;
1794
             if (strpos2(parstr, "G", 1) > 0)   /* new in v0.3f
1797
             if (strpos2(parstr, "G", 1) > 0)   /* new in v0.3f */
1795
             opt_chiral = true;
1798
             opt_chiral = true;
1796
             if (strpos2(parstr, "f", 1) > 0) {   /* new in v0.3m
1799
             if (strpos2(parstr, "f", 1) > 0) {   /* new in v0.3m */
1797
             opt_fp = true;
1800
             opt_fp = true;
1798
             fpformat = fpf_boolean;
1801
             fpformat = fpf_boolean;
1799
             }
1802
             }
1800
             if (strpos2(parstr, "F", 1) > 0) {   /* new in v0.3m
1803
             if (strpos2(parstr, "F", 1) > 0) {   /* new in v0.3m */
1801
             opt_fp = true;
1804
             opt_fp = true;
1802
             fpformat = fpf_decimal;
1805
             fpformat = fpf_decimal;
1803
             }
1806
             }
1804
             if (strpos2(parstr, "h", 1) > 1) {
1807
             if (strpos2(parstr, "h", 1) > 1) {
1805
             show_usage();
1808
             show_usage();
Line 1815... Line 1818...
1815
             if (p == P_argc - 1) {
1818
             if (p == P_argc - 1) {
1816
             if (strcmp(parstr, "-"))
1819
             if (strcmp(parstr, "-"))
1817
             strcpy(molfilename, parstr);
1820
             strcpy(molfilename, parstr);
1818
             else
1821
             else
1819
             opt_stdin = true;
1822
             opt_stdin = true;
1820
             }
1823
             }
1821
             }
1824
             }
1822
             if (opt_geom)   /* v0.3d
1825
             if (opt_geom)   /* v0.3d */
1823
             ez_search = true;
1826
             ez_search = true;
1824
             if (opt_chiral)   /* v0.3f
1827
             if (opt_chiral)   /* v0.3f */
1825
             rs_search = true;
1828
             rs_search = true;
1826
             if (opt_chiral && opt_strict && (opt_exact || opt_fp))
1829
             if (opt_chiral && opt_strict && (opt_exact || opt_fp))
1827
             /* new in v0.3j, v0.3m
1830
             /* new in v0.3j, v0.3m */
1828
             rs_strict = true;
1831
             rs_strict = true;
1829
             if (opt_fp) {   /* v0.3m
1832
             if (opt_fp) {   /* v0.3m */
1830
             opt_molout = false;
1833
             opt_molout = false;
1831
             opt_exact = false;
1834
             opt_exact = false;
1832
             }
1835
             }
1833
             }  /* progmode = pmMatchMol
1836
             }  /* progmode = pmMatchMol */
1834
             ringsearch_mode = opt_rs;   /* v0.3i
1837
             ringsearch_mode = opt_rs;   /* v0.3i */
1835
             }
1838
             }
1836
           */
1839
#endif
1837
 
1840
 
1838
static void
1841
static void
1839
parse_args (int argc, char *argv[])
1842
parse_args (int argc, char *argv[])
1840
{
1843
{
1841
  short p;
1844
  short p;
Line 1846... Line 1849...
1846
  *tmpstr = '\0';
1849
  *tmpstr = '\0';
1847
  opt_none = true;
1850
  opt_none = true;
1848
  *molfilename = '\0';
1851
  *molfilename = '\0';
1849
  *ndl_molfilename = '\0';
1852
  *ndl_molfilename = '\0';
1850
  if (progmode == pmCheckMol)
1853
  if (progmode == pmCheckMol)
1851
    {
1854
    {
1852
      for (p = 1; p <= argc - 1; p++)
1855
      for (p = 1; p <= argc - 1; p++)
1853
        {
1856
        {
1854
          strcpy (parstr, argv[p]);
1857
          strcpy (parstr, argv[p]);
1855
          if (!strcmp (parstr, "-l"))
1858
          if (!strcmp (parstr, "-l"))
1856
            {                   /* new in v0.3l */
1859
            {                   /* new in v0.3l */
1857
              list_molstat_codes ();
1860
              list_molstat_codes ();
1858
              exit (0);
1861
              exit (0);
1859
            }
1862
            }
Line 1868... Line 1871...
1868
                    l++;
1871
                    l++;
1869
                  if (strpos2 (tmpstr, "D", 1) > 0)
1872
                  if (strpos2 (tmpstr, "D", 1) > 0)
1870
                    l++;
1873
                    l++;
1871
                  if (strpos2 (tmpstr, "r", 1) > 0)
1874
                  if (strpos2 (tmpstr, "r", 1) > 0)
1872
                    l++;
1875
                    l++;
1873
                  /*if (strpos2 (tmpstr, "a", 1) > 0)   /* 0.3x
1876
                  /*if (strpos2 (tmpstr, "a", 1) > 0)   // 0.3x
1874
                     l++; */
1877
                     l++; */
1875
                  if (strpos2 (tmpstr, "M", 1) > 0)     /* new in v0.3 */
1878
                  if (strpos2 (tmpstr, "M", 1) > 0)     /* new in v0.3 */
1876
                    l++;
1879
                    l++;
1877
                  if (strlen (tmpstr) > l + 2)
1880
                  if (strlen (tmpstr) > l + 2)
1878
                    {
1881
                    {
1879
                      show_usage ();
1882
                      show_usage ();
1880
                      exit (1);
1883
                      exit (1);
1881
                    }
1884
                    }
1882
                  opt_none = false;
1885
                  opt_none = false;
1883
                  if (strpos2 (tmpstr, "M", 1) > 0)
1886
                  if (strpos2 (tmpstr, "M", 1) > 0)
1884
                    opt_metalrings = true;
1887
                    opt_metalrings = true;
1885
                  if (strpos2 (tmpstr, "v", 1) > 0)
1888
                  if (strpos2 (tmpstr, "v", 1) > 0)
1886
                    opt_verbose = true;
1889
                    opt_verbose = true;
Line 1911... Line 1914...
1911
                      if (strpos2 (tmpstr, "x", 1) > 0)
1914
                      if (strpos2 (tmpstr, "x", 1) > 0)
1912
                        opt_molstat = true;
1915
                        opt_molstat = true;
1913
                      if (strpos2 (tmpstr, "r", 1) > 0)
1916
                      if (strpos2 (tmpstr, "r", 1) > 0)
1914
                        opt_rs = rs_ssr;
1917
                        opt_rs = rs_ssr;
1915
                      /* if (strpos2 (tmpstr, "a", 1) > 0)
1918
                      /* if (strpos2 (tmpstr, "a", 1) > 0)
1916
                         opt_chg = true; /* 0.3x  */
1919
                         opt_chg = true; */ /* 0.3x  */
1917
                      if (strpos2 (tmpstr, "X", 1) > 0)
1920
                      if (strpos2 (tmpstr, "X", 1) > 0)
1918
                        {
1921
                        {
1919
                          opt_molstat = true;
1922
                          opt_molstat = true;
1920
                          opt_molstat_X = true;
1923
                          opt_molstat_X = true;
1921
                        }
1924
                        }
Line 1929... Line 1932...
1929
                          opt_molstat = false;
1932
                          opt_molstat = false;
1930
                          opt_xmdlout = true;
1933
                          opt_xmdlout = true;
1931
                        }
1934
                        }
1932
                    }
1935
                    }
1933
                  strcpy (molfilename, tmpstr);
1936
                  strcpy (molfilename, tmpstr);
1934
                }
1937
                }
1935
            }
1938
            }
1936
          else
1939
          else
1937
            {
1940
            {
1938
              if (strpos2 (parstr, "-", 1) == 1)
1941
              if (strpos2 (parstr, "-", 1) == 1)
1939
                {
1942
                {
1940
                  if (strlen (parstr) > 1)
1943
                  if (strlen (parstr) > 1)
Line 2010... Line 2013...
2010
                }
2013
                }
2011
              else
2014
              else
2012
                strcpy (ndl_molfilename, parstr);
2015
                strcpy (ndl_molfilename, parstr);
2013
            }
2016
            }
2014
          if (p == argc - 2)
2017
          if (p == argc - 2)
2015
            {
2018
            {
2016
              if (strpos2 (parstr, "-", 1) != 1)
2019
              if (strpos2 (parstr, "-", 1) != 1)
2017
                strcpy (ndl_molfilename, parstr);
2020
                strcpy (ndl_molfilename, parstr);
2018
            }
2021
            }
2019
          if (p == argc - 1)
2022
          if (p == argc - 1)
2020
            {
2023
            {
Line 2036... Line 2039...
2036
          opt_molout = false;
2039
          opt_molout = false;
2037
          opt_exact = false;
2040
          opt_exact = false;
2038
        }
2041
        }
2039
    }                           /* progmode = pmMatchMol */
2042
    }                           /* progmode = pmMatchMol */
2040
  ringsearch_mode = opt_rs;     /* v0.3i */
2043
  ringsearch_mode = opt_rs;     /* v0.3i */
2041
}
2044
}
2042
 
2045
 
2043
/*============== input-related functions & procedures ===================== */
2046
/*============== input-related functions & procedures ===================== */
2044
 
2047
 
2045
static char *
2048
static char *
2046
get_filetype (Result, f)
2049
get_filetype (Result, f)
Line 2141... Line 2144...
2141
    {
2144
    {
2142
      free (ndl_atom);
2145
      free (ndl_atom);
2143
      ndl_atom = NULL;          /* added in v0.3j */
2146
      ndl_atom = NULL;          /* added in v0.3j */
2144
    }
2147
    }
2145
  if (ndl_bond != NULL)
2148
  if (ndl_bond != NULL)
2146
    {
2149
    {
2147
      free (ndl_bond);
2150
      free (ndl_bond);
2148
      ndl_bond = NULL;          /* added in v0.3j */
2151
      ndl_bond = NULL;          /* added in v0.3j */
2149
    }
2152
    }
2150
  if (ndl_ring != NULL)
2153
  if (ndl_ring != NULL)
2151
    {
2154
    {
Line 2163... Line 2166...
2163
  ndl_n_atoms = 0;
2166
  ndl_n_atoms = 0;
2164
  ndl_n_bonds = 0;
2167
  ndl_n_bonds = 0;
2165
  ndl_n_rings = 0;
2168
  ndl_n_rings = 0;
2166
}
2169
}
2167
 
2170
 
2168
 
2171
#if 0
2169
static void
2172
static void
2170
zap_tmp ()
2173
zap_tmp ()
2171
{
2174
{
2172
  /* try */
2175
  /* try */
2173
  if (tmp_atom != NULL)
2176
  if (tmp_atom != NULL)
2174
    {
2177
    {
2175
      free (tmp_atom);
2178
      free (tmp_atom);
2176
      tmp_atom = NULL;          /* added in v0.3j */
2179
      tmp_atom = NULL;          /* added in v0.3j */
2177
    }
2180
    }
2178
  if (tmp_bond != NULL)
2181
  if (tmp_bond != NULL)
2179
    {
2182
    {
2180
      free (tmp_bond);
2183
      free (tmp_bond);
2181
      tmp_bond = NULL;          /* added in v0.3j */
2184
      tmp_bond = NULL;          /* added in v0.3j */
2182
    }
2185
    }
Line 2194... Line 2197...
2194
     on e:Einvalidpointer do begin end;
2197
     on e:Einvalidpointer do begin end;
2195
     end; */
2198
     end; */
2196
  tmp_n_atoms = 0;
2199
  tmp_n_atoms = 0;
2197
  tmp_n_bonds = 0;
2200
  tmp_n_bonds = 0;
2198
  tmp_n_rings = 0;
2201
  tmp_n_rings = 0;
2199
}
2202
}
2200
 
2203
#endif
2201
 
2204
 
2202
static boolean
2205
static boolean
2203
is_heavyatom (id)
2206
is_heavyatom (id)
2204
     int id;
2207
     int id;
2205
{
2208
{
Line 2209... Line 2212...
2209
 
2212
 
2210
  if (!strcmp (el, "DU") || !strcmp (el, "LP"))
2213
  if (!strcmp (el, "DU") || !strcmp (el, "LP"))
2211
    return false;
2214
    return false;
2212
  /*if (progmode == pmCheckMol && !strcmp (el, "H ")
2215
  /*if (progmode == pmCheckMol && !strcmp (el, "H ")
2213
     && atom[id - 1].nucleon_number < 2)
2216
     && atom[id - 1].nucleon_number < 2)
2214
     return false;              /* 0.3x  */
2217
     return false;               0.3x  */
2215
  if (!strcmp (el, "H "))       /* 0.3 p */
2218
  if (!strcmp (el, "H "))       /* 0.3 p */
2216
    {
2219
    {
2217
      if (progmode == pmMatchMol && !opt_iso)
2220
      if (progmode == pmMatchMol && !opt_iso)
2218
        {
2221
        {
2219
          return false;
2222
          return false;
Line 2250... Line 2253...
2250
          if (!strcmp (ndl_atom[ba - 1].atype, "C2 ") &&
2253
          if (!strcmp (ndl_atom[ba - 1].atype, "C2 ") &&
2251
              !strcmp (ndl_atom[ba2 - 1].atype, "C2 ")
2254
              !strcmp (ndl_atom[ba2 - 1].atype, "C2 ")
2252
              && ndl_bond[i].btype == 'D' && ndl_bond[i].arom == false)
2255
              && ndl_bond[i].btype == 'D' && ndl_bond[i].arom == false)
2253
            res = true;
2256
            res = true;
2254
        }
2257
        }
2255
    }
2258
    }
2256
  return res;
2259
  return res;
2257
}
2260
}
2258
 
2261
 
2259
 
2262
 
2260
static boolean
2263
static boolean
Line 2292... Line 2295...
2292
  /* preliminary version; should be extended to element/atomtype */
2295
  /* preliminary version; should be extended to element/atomtype */
2293
  int res = 1;
2296
  int res = 1;
2294
 
2297
 
2295
  if (!strcmp (a_el, "H "))
2298
  if (!strcmp (a_el, "H "))
2296
    res = 1;
2299
    res = 1;
2297
  /*if (!strcmp (a_el, "D "))   /* v0.3n
2300
  /*if (!strcmp (a_el, "D "))   // v0.3n
2298
     res = 1; */
2301
     res = 1; */
2299
  if (!strcmp (a_el, "C "))
2302
  if (!strcmp (a_el, "C "))
2300
    res = 4;
2303
    res = 4;
2301
  if (!strcmp (a_el, "N "))
2304
  if (!strcmp (a_el, "N "))
2302
    res = 3;
2305
    res = 3;
Line 2541... Line 2544...
2541
{
2544
{
2542
  char elemstr[256];
2545
  char elemstr[256];
2543
 
2546
 
2544
  if (!strcmp (oldtype, "H   "))
2547
  if (!strcmp (oldtype, "H   "))
2545
    strcpy (elemstr, "H ");
2548
    strcpy (elemstr, "H ");
2546
  /* if (!strcmp (oldtype, "D   "))      /* v0.3n
2549
  /* if (!strcmp (oldtype, "D   "))  // v0.3n
2547
     strcpy (elemstr, "D "); */
2550
     strcpy (elemstr, "D "); */
2548
  if (!strcmp (oldtype, "CAR "))
2551
  if (!strcmp (oldtype, "CAR "))
2549
    strcpy (elemstr, "C ");
2552
    strcpy (elemstr, "C ");
2550
  if (!strcmp (oldtype, "C2  "))
2553
  if (!strcmp (oldtype, "C2  "))
2551
    strcpy (elemstr, "C ");
2554
    strcpy (elemstr, "C ");
Line 2664... Line 2667...
2664
    strcpy (elemstr, "??");
2667
    strcpy (elemstr, "??");
2665
  if (elemstr[0] == '*')
2668
  if (elemstr[0] == '*')
2666
    strcpy (elemstr, "??");
2669
    strcpy (elemstr, "??");
2667
  return strcpy (Result, elemstr);
2670
  return strcpy (Result, elemstr);
2668
}
2671
}
2669
 
-
 
2670
 
2672
 
2671
static void
2673
static void
2672
read_molfile (mfilename)
2674
read_molfile (mfilename)
2673
     char *mfilename;
2675
     char *mfilename;
2674
{
2676
{
Line 2677... Line 2679...
2677
  char rline[256], tmpstr[256];
2679
  char rline[256], tmpstr[256];
2678
  char xstr[256], ystr[256], zstr[256], chgstr[256];
2680
  char xstr[256], ystr[256], zstr[256], chgstr[256];
2679
  float xval, yval, zval, chgval;
2681
  float xval, yval, zval, chgval;
2680
  char a1str[256], a2str[256], elemstr[256];
2682
  char a1str[256], a2str[256], elemstr[256];
2681
  int a1val, a2val, ri;
2683
  int a1val, a2val, ri;
2682
  char STR1[256];
2684
  char STR1[256];
2683
  int FORLIM;
2685
  int FORLIM;
2684
  atom_rec *WITH;
2686
  atom_rec *WITH;
2685
  bond_rec *WITH1;
2687
  bond_rec *WITH1;
2686
 
2688
 
2687
  if (n_atoms > 0)
2689
  if (n_atoms > 0)
2688
    zap_molecule ();
2690
    zap_molecule ();
2689
  ri = li;
2691
  ri = li;
2690
  strcpy (rline, molbuf[ri - 1]);
2692
  strcpy (rline, molbuf[ri - 1]);
2691
  sprintf (tmpstr, "%.5s", rline);
2693
  sprintf (tmpstr, "%.5s", rline);
Line 2979... Line 2981...
2979
static void
2981
static void
2980
read_charges (chgstring_)
2982
read_charges (chgstring_)
2981
     char *chgstring_;
2983
     char *chgstring_;
2982
{
2984
{
2983
  char chgstring[256];
2985
  char chgstring[256];
2984
  int a_id, a_chg, n_chrg;
2986
  int a_id, a_chg;
-
 
2987
  /* int n_chrg;*/
2985
 
2988
 
2986
  /* typical example: a molecule with 2 cations + 1 anion */
2989
  /* typical example: a molecule with 2 cations + 1 anion */
2987
  /* M  CHG  3   8   1  10   1  11  -1 */
2990
  /* M  CHG  3   8   1  10   1  11  -1 */
2988
  strcpy (chgstring, chgstring_);
2991
  strcpy (chgstring, chgstring_);
2989
  if (strpos2 (chgstring, "M  CHG", 1) <= 0)
2992
  if (strpos2 (chgstring, "M  CHG", 1) <= 0)
2990
    return;
2993
    return;
2991
  strdelete (chgstring, 1, 6);
2994
  strdelete (chgstring, 1, 6);
2992
  left_trim (chgstring);
2995
  left_trim (chgstring);
2993
  n_chrg = left_int (chgstring);
2996
 /* n_chrg = left_int (chgstring);*/
2994
  /* this assignment must be kept also in non-debug mode! */
2997
  /* this assignment must be kept also in non-debug mode! */
2995
/* p2c: checkmol.pas, line 2077:
2998
/* p2c: checkmol.pas, line 2077:
2996
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
2999
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
2997
  /*$IFDEF debug */
3000
  /*$IFDEF debug */
2998
  /*if (n_chrg == 0)
3001
  /*if (n_chrg == 0)
Line 3010... Line 3013...
3010
 
3013
 
3011
static void
3014
static void
3012
read_isotopes (char *isotopestring_)
3015
read_isotopes (char *isotopestring_)
3013
{
3016
{
3014
  char isotopestring[256];
3017
  char isotopestring[256];
3015
  int a_id, a_nucleon_number, n_isotopes;
3018
  int a_id, a_nucleon_number;
-
 
3019
  /* int n_isotopes;*/
3016
 
3020
 
3017
  /* typical example: a molecule with 2 cations + 1 anion */
3021
  /* typical example: a molecule with 2 cations + 1 anion */
3018
  /* M  CHG  3   8   1  10   1  11  -1 */
3022
  /* M  CHG  3   8   1  10   1  11  -1 */
3019
  strcpy (isotopestring, isotopestring_);
3023
  strcpy (isotopestring, isotopestring_);
3020
  if (strpos2 (isotopestring, "M  ISO", 1) <= 0)
3024
  if (strpos2 (isotopestring, "M  ISO", 1) <= 0)
3021
    return;
3025
    return;
3022
  strdelete (isotopestring, 1, 6);
3026
  strdelete (isotopestring, 1, 6);
3023
  left_trim (isotopestring);
3027
  left_trim (isotopestring);
3024
  n_isotopes = left_int (isotopestring);
3028
  /*n_isotopes = left_int (isotopestring);*/
3025
  /* this assignment must be kept also in non-debug mode! */
3029
  /* this assignment must be kept also in non-debug mode! */
3026
/* p2c: checkmol.pas, line 2077:
3030
/* p2c: checkmol.pas, line 2077:
3027
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
3031
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
3028
  /*$IFDEF debug */
3032
  /*$IFDEF debug */
3029
  /*if (n_chrg == 0)
3033
  /*if (n_chrg == 0)
Line 3092... Line 3096...
3092
  int a1val, a2val, ri, rc, bt, bs;
3096
  int a1val, a2val, ri, rc, bt, bs;
3093
  int sepcount = 0;
3097
  int sepcount = 0;
3094
  int i;                        /* v0.3j */
3098
  int i;                        /* v0.3j */
3095
  boolean clearcharges = true;  /* v0.3j */
3099
  boolean clearcharges = true;  /* v0.3j */
3096
  char STR1[256];
3100
  char STR1[256];
3097
  int FORLIM;
3101
/*  int FORLIM;*/
3098
  atom_rec *WITH;
3102
  atom_rec *WITH;
3099
  bond_rec *WITH1;
3103
  bond_rec *WITH1;
3100
 
3104
 
3101
  /* v0.3j */
3105
  /* v0.3j */
3102
  if (n_atoms > 0)
3106
  if (n_atoms > 0)
Line 3477... Line 3481...
3477
  char wline[256];
3481
  char wline[256];
3478
  int a_chg;
3482
  int a_chg;
3479
  int a_iso;
3483
  int a_iso;
3480
  int a_rad;
3484
  int a_rad;
3481
  char tmflabel[256];           /* v0.3m */
3485
  char tmflabel[256];           /* v0.3m */
3482
  char STR1[256], STR7[256];
3486
  char STR1[256];
-
 
3487
  /*char STR7[256];*/
3483
  int FORLIM;
3488
  int FORLIM;
3484
 
3489
 
3485
  sprintf (tmflabel, "%d", (int) tweaklevel);   /* v0.3m */
3490
  sprintf (tmflabel, "%d", (int) tweaklevel);   /* v0.3m */
3486
  while (strlen (tmflabel) < 2) /* v0.3m */
3491
  while (strlen (tmflabel) < 2) /* v0.3m */
3487
    sprintf (tmflabel, "0%s", strcpy (STR1, tmflabel));
3492
    sprintf (tmflabel, "0%s", strcpy (STR1, tmflabel));
Line 3748... Line 3753...
3748
        }
3753
        }
3749
      if (bond[i].a2 == id && atom[bond[i].a1 - 1].heavy
3754
      if (bond[i].a2 == id && atom[bond[i].a1 - 1].heavy
3750
          && nb_count < max_neighbors)
3755
          && nb_count < max_neighbors)
3751
        {
3756
        {
3752
          Result[nb_count++] = bond[i].a1;
3757
          Result[nb_count++] = bond[i].a1;
3753
        }
3758
        }
3754
    }
3759
    }
3755
  //return memcpy (Result, nb_tmp, sizeof (neighbor_rec));
3760
  //return memcpy (Result, nb_tmp, sizeof (neighbor_rec));
3756
}
3761
}
3757
 
3762
 
3758
 
3763
 
3759
static void
3764
static void
Line 3799... Line 3804...
3799
  FORLIM = n_bonds;
3804
  FORLIM = n_bonds;
3800
  for (i = 0; i < FORLIM; i++)
3805
  for (i = 0; i < FORLIM; i++)
3801
    {
3806
    {
3802
      if (bond[i].a1 == id && bond[i].a2 != prev_id &&
3807
      if (bond[i].a1 == id && bond[i].a2 != prev_id &&
3803
          nb_count < max_neighbors && atom[bond[i].a2 - 1].heavy)
3808
          nb_count < max_neighbors && atom[bond[i].a2 - 1].heavy)
3804
        {
3809
        {
3805
          nb_count++;
3810
          nb_count++;
3806
          nb_tmp[nb_count - 1] = bond[i].a2;
3811
          nb_tmp[nb_count - 1] = bond[i].a2;
3807
        }
3812
        }
3808
      if (bond[i].a2 == id && bond[i].a1 != prev_id &&
3813
      if (bond[i].a2 == id && bond[i].a1 != prev_id &&
3809
          nb_count < max_neighbors && atom[bond[i].a1 - 1].heavy)
3814
          nb_count < max_neighbors && atom[bond[i].a1 - 1].heavy)
3810
        {
3815
        {
Line 3843... Line 3848...
3843
        }
3848
        }
3844
    }
3849
    }
3845
  return memcpy (Result, nb_tmp, sizeof (neighbor_rec));
3850
  return memcpy (Result, nb_tmp, sizeof (neighbor_rec));
3846
}
3851
}
3847
 
3852
 
3848
 
3853
#if 0
3849
  /*static int path_pos (id, a_path) int id;
3854
static int path_pos (id, a_path) int id;
3850
     int *a_path;
3855
     int *a_path;
3851
     {
3856
     {
3852
     /* new version in v0.3l
3857
     /* new version in v0.3l */
3853
     int i;
3858
     int i;
3854
     int pp = 0;
3859
     int pp = 0;
3855
 
3860
 
3856
     for (i = 1; i <= max_ringsize; i++)
3861
     for (i = 1; i <= max_ringsize; i++)
3857
     {
3862
     {
3858
     if (a_path[i - 1] == id)
3863
     if (a_path[i - 1] == id)
3859
     {
3864
     {
3860
     pp = i;
3865
     pp = i;
3861
     /* p2c: checkmol.pas, line 2620:
3866
     /* p2c: checkmol.pas, line 2620:
3862
     * Warning: Expected a '(', found a semicolon [227]
3867
     * Warning: Expected a '(', found a semicolon [227]  */
3863
     /* p2c: checkmol.pas, line 2620:
3868
     /* p2c: checkmol.pas, line 2620:
3864
     * Warning: Expected an expression, found a semicolon [227]
3869
     * Warning: Expected an expression, found a semicolon [227] */
3865
     fflush (0);
3870
     fflush (0);
3866
     P_ioresult = 0;
3871
     P_ioresult = 0;
3867
     }
3872
     }
3868
     }
3873
     }
3869
     return pp;
3874
     return pp;
3870
     } */
3875
     }
-
 
3876
#endif
3871
 
3877
 
3872
static int
3878
static int
3873
matchpath_pos (int id, int *a_path)
3879
matchpath_pos (int id, int *a_path)
3874
{
3880
{
3875
  int i;
3881
  int i;
Line 3903... Line 3909...
3903
  if (ndl_n_bonds <= 0)
3909
  if (ndl_n_bonds <= 0)
3904
    return b_id;
3910
    return b_id;
3905
  FORLIM = ndl_n_bonds;
3911
  FORLIM = ndl_n_bonds;
3906
  for (i = 1; i <= FORLIM; i++)
3912
  for (i = 1; i <= FORLIM; i++)
3907
    {
3913
    {
3908
      if (ndl_bond[i - 1].a1 == ba1 && ndl_bond[i - 1].a2 == ba2 ||
3914
      if ((ndl_bond[i - 1].a1 == ba1 && ndl_bond[i - 1].a2 == ba2) ||
3909
          ndl_bond[i - 1].a1 == ba2 && ndl_bond[i - 1].a2 == ba1)
3915
          (ndl_bond[i - 1].a1 == ba2 && ndl_bond[i - 1].a2 == ba1))
3910
        b_id = i;
3916
        b_id = i;
3911
    }
3917
    }
3912
  return b_id;
3918
  return b_id;
3913
}
3919
}
3914
 
3920
 
3915
static int
3921
static int
3916
ringcompare (int *rp1, int *rp2)
3922
ringcompare (int *rp1, int *rp2)
3917
{
3923
{
3918
  int i, j;
3924
  int i, j;
3919
  int rc = 0;
3925
  int rc = 0;
3920
  int rs1, rs2;
3926
  int rs1, rs2;
3921
  int n_common = 0;
3927
  int n_common = 0;
3922
  int max_cra;
3928
  int max_cra;
Line 3965... Line 3971...
3965
}
3971
}
3966
 
3972
 
3967
 
3973
 
3968
static boolean
3974
static boolean
3969
rc_1in2 (int rc_int)
3975
rc_1in2 (int rc_int)
3970
{
3976
{
3971
  if (rc_int & 1)
3977
  if (rc_int & 1)
3972
    return true;
3978
    return true;
3973
  else
3979
  else
3974
    return false;
3980
    return false;
3975
}
3981
}
3976
 
3982
 
3977
 
3983
 
3978
static boolean
3984
static boolean
3979
rc_2in1 (int rc_int)
3985
rc_2in1 (int rc_int)
3980
{
3986
{
3981
  rc_int /= 2;
3987
  rc_int /= 2;
3982
  if (rc_int & 1)
3988
  if (rc_int & 1)
3983
    return true;
3989
    return true;
3984
  else
3990
  else
3985
    return false;
3991
    return false;
3986
}
3992
}
3987
 
3993
 
3988
 
3994
 
-
 
3995
#if 0
3989
static boolean
3996
static boolean
3990
rc_different (int rc_int)
3997
rc_different (int rc_int)
3991
{
3998
{
3992
  rc_int /= 4;
3999
  rc_int /= 4;
3993
  if (rc_int & 1)
4000
  if (rc_int & 1)
3994
    return true;
4001
    return true;
3995
  else
4002
  else
3996
    return false;
4003
    return false;
3997
}
4004
}
3998
 
4005
#endif
3999
 
4006
#if 0
4000
static boolean
4007
static boolean
4001
rc_independent (int rc_int)
4008
rc_independent (int rc_int)
4002
{
4009
{
4003
  rc_int /= 8;
4010
  rc_int /= 8;
4004
  if (rc_int & 1)
4011
  if (rc_int & 1)
4005
    return true;
4012
    return true;
4006
  else
4013
  else
4007
    return false;
4014
    return false;
4008
}
4015
}
4009
 
4016
#endif
4010
 
4017
 
4011
static boolean
4018
static boolean
4012
is_newring (int *n_path)
4019
is_newring (int *n_path)
4013
{
4020
{
4014
  int i, j;
4021
  int i, j;
Line 4091... Line 4098...
4091
  int j = 0;
4098
  int j = 0;
4092
  int k, s, pl;
4099
  int k, s, pl;
4093
/* p2c: checkmol.pas, line 2862:
4100
/* p2c: checkmol.pas, line 2862:
4094
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
4101
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
4095
  /*$IFDEF debug */
4102
  /*$IFDEF debug */
4096
  char dstr[256];
4103
  /*char dstr[256];*/
4097
  int FORLIM;
4104
  int FORLIM;
4098
 
4105
 
4099
  /*$ENDIF */
4106
  /*$ENDIF */
4100
  pl = path_length (n_path);
4107
  pl = path_length (n_path);
4101
 
4108
 
Line 4107... Line 4114...
4107
 
4114
 
4108
/* p2c: checkmol.pas, line 2906:
4115
/* p2c: checkmol.pas, line 2906:
4109
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
4116
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
4110
      /*$IFDEF debug
4117
      /*$IFDEF debug
4111
         debugoutput ("max_rings exceeded!");
4118
         debugoutput ("max_rings exceeded!");
4112
         /*$ENDIF */
4119
         $ENDIF */
4113
      return;
4120
      return;
4114
    }
4121
    }
4115
  n_rings++;
4122
  n_rings++;
4116
 
4123
 
4117
/* p2c: checkmol.pas, line 2871:
4124
/* p2c: checkmol.pas, line 2871:
Line 4149... Line 4156...
4149
      /*inc(atom^[(n_path[i])].ring_count); */
4156
      /*inc(atom^[(n_path[i])].ring_count); */
4150
    }
4157
    }
4151
}
4158
}
4152
 
4159
 
4153
 
4160
 
-
 
4161
#if 0
4154
  /* static boolean is_ringpath (s_path) int *s_path;
4162
 static boolean is_ringpath (s_path) int *s_path;
4155
     {
4163
     {
4156
     boolean Result;
4164
     boolean Result;
4157
     int i, j;
4165
     int i, j;
4158
     neighbor_rec nb;
4166
     neighbor_rec nb;
4159
     boolean rp = false;
4167
     boolean rp = false;
4160
     boolean new_atom;
4168
     boolean new_atom;
4161
     int a_last, pl;
4169
     int a_last, pl;
4162
     ringpath_type l_path;
4170
     ringpath_type l_path;
4163
     int FORLIM;
4171
     int FORLIM;
4164
 
4172
 
4165
     /* p2c: checkmol.pas: Note: Eliminated unused assignment statement [338]
4173
     /* p2c: checkmol.pas: Note: Eliminated unused assignment statement [338] */
4166
     memset (nb, 0, sizeof (neighbor_rec));
4174
     memset (nb, 0, sizeof (neighbor_rec));
4167
     memset (l_path, 0, sizeof (ringpath_type));
4175
     memset (l_path, 0, sizeof (ringpath_type));
4168
     pl = path_length (s_path);
4176
     pl = path_length (s_path);
4169
     if (pl < 1)
4177
     if (pl < 1)
4170
     {
4178
     {
4171
     /* p2c: checkmol.pas, line 2928:
4179
     /* p2c: checkmol.pas, line 2928:
4172
     * Note: Turbo Pascal conditional compilation directive was ignored [218]
4180
     * Note: Turbo Pascal conditional compilation directive was ignored [218] */
4173
     /*$IFDEF debug
4181
     /*$IFDEF debug
4174
     debugoutput ("Oops! Got zero-length s_path!");
4182
     debugoutput ("Oops! Got zero-length s_path!");
4175
     /*$ENDIF
4183
     $ENDIF */
4176
     return Result;
4184
     return Result;
4177
     }
4185
     }
4178
     for (i = 0; i < pl; i++)
4186
     for (i = 0; i < pl; i++)
4179
     l_path[i] = s_path[i];
4187
     l_path[i] = s_path[i];
4180
     /* check if the last atom is a metal and stop if opt_metalrings is not set (v0.3)
4188
     /* check if the last atom is a metal and stop if opt_metalrings is not set (v0.3) */
4181
     if (opt_metalrings == false)
4189
     if (opt_metalrings == false)
4182
     {
4190
     {
4183
     if (atom[l_path[pl - 1] - 1].metal)
4191
     if (atom[l_path[pl - 1] - 1].metal)
4184
     {
4192
     {
4185
     /* p2c: checkmol.pas, line 2942:
4193
     /* p2c: checkmol.pas, line 2942:
4186
     * Note: Turbo Pascal conditional compilation directive was ignored [218]
4194
     * Note: Turbo Pascal conditional compilation directive was ignored [218] */
4187
     /*$IFDEF debug
4195
     /*$IFDEF debug
4188
     debugoutput ("skipping metal in ring search");
4196
     debugoutput ("skipping metal in ring search");
4189
     /*$ENDIF
4197
     $ENDIF */
4190
     return false;
4198
     return false;
4191
     }
4199
     }
4192
     }
4200
     }
4193
     /* check if ring is already closed
4201
     /* check if ring is already closed */
4194
     if (pl > 2 && l_path[pl - 1] == l_path[0])
4202
     if (pl > 2 && l_path[pl - 1] == l_path[0])
4195
     {
4203
     {
4196
     l_path[pl - 1] = 0;        /* remove last entry (redundant!)
4204
     l_path[pl - 1] = 0;        /* remove last entry (redundant!) */
4197
     order_ringpath (l_path);
4205
     order_ringpath (l_path);
4198
     if (is_newring (l_path))
4206
     if (is_newring (l_path))
4199
     {
4207
     {
4200
     if (n_rings >= max_rings)
4208
     if (n_rings >= max_rings)
4201
     {
4209
     {
4202
     /* p2c: checkmol.pas, line 2958:
4210
     /* p2c: checkmol.pas, line 2958:
4203
     * Note: Turbo Pascal conditional compilation directive was ignored [218]
4211
     * Note: Turbo Pascal conditional compilation directive was ignored [218] */
4204
     /*$IFDEF debug
4212
     /*$IFDEF debug
4205
     debugoutput ("maximum number of rings exceeded!");
4213
     debugoutput ("maximum number of rings exceeded!");
4206
     /*$ENDIF
4214
     $ENDIF */
4207
     return false;
4215
     return false;
4208
     }
4216
     }
4209
     add_ring (l_path);
4217
     add_ring (l_path);
4210
     }
4218
     }
4211
     /* p2c: checkmol.pas: Note: Eliminated unused assignment statement [338]
4219
     /* p2c: checkmol.pas: Note: Eliminated unused assignment statement [338] */
4212
     return true;
4220
     return true;
4213
     }
4221
     }
4214
     /* any other case: ring is not (yet) closed
4222
     /* any other case: ring is not (yet) closed */
4215
     a_last = l_path[pl - 1];
4223
     a_last = l_path[pl - 1];
4216
     get_neighbors (nb, a_last);
4224
     get_neighbors (nb, a_last);
4217
     if (atom[a_last - 1].neighbor_count <= 1)
4225
     if (atom[a_last - 1].neighbor_count <= 1)
4218
     return false;
4226
     return false;
4219
     if (n_rings >= max_rings)
4227
     if (n_rings >= max_rings)
4220
     /* added in v0.2: check if max_rings is reached *
4228
     /* added in v0.2: check if max_rings is reached **/
4221
     {                          /* if ring is not closed, continue searching
4229
     {                          /* if ring is not closed, continue searching */
4222
     return false;
4230
     return false;
4223
     }
4231
     }
4224
     FORLIM = atom[a_last - 1].neighbor_count;
4232
     FORLIM = atom[a_last - 1].neighbor_count;
4225
     for (i = 0; i < FORLIM; i++)
4233
     for (i = 0; i < FORLIM; i++)
4226
     {
4234
     {
4227
     new_atom = true;
4235
     new_atom = true;
4228
     for (j = 1; j < pl; j++)
4236
     for (j = 1; j < pl; j++)
4229
     {
4237
     {
4230
     if (nb[i] == l_path[j])
4238
     if (nb[i] == l_path[j])
4231
     {                    /* v0.3k
4239
     {                    /* v0.3k */
4232
     new_atom = false;
4240
     new_atom = false;
4233
     /* p2c: checkmol.pas, line 2982:
4241
     /* p2c: checkmol.pas, line 2982:
4234
     * Warning: Expected a '(', found a semicolon [227] *
4242
     * Warning: Expected a '(', found a semicolon [227] */
4235
     /* p2c: checkmol.pas, line 2982:
4243
     /* p2c: checkmol.pas, line 2982:
4236
     * Warning: Expected an expression, found a semicolon [227]
4244
     * Warning: Expected an expression, found a semicolon [227] */
4237
     fflush (0);
4245
     fflush (0);
4238
     P_ioresult = 0;      /* v0.3k *
4246
     P_ioresult = 0;      /* v0.3k */
4239
     }
4247
     }
4240
     }
4248
     }
4241
 
-
 
4242
     /* added in v0.1a: check if max_rings not yet reached
4249
     /* added in v0.1a: check if max_rings not yet reached */
4243
     /* added in v0.2:  limit ring size to max_vringsize instead of max_ringsize
4250
     /* added in v0.2:  limit ring size to max_vringsize instead of max_ringsize */
4244
     if (new_atom && pl < max_vringsize && n_rings < max_rings)
4251
     if (new_atom && pl < max_vringsize && n_rings < max_rings)
4245
     {
4252
     {
4246
     l_path[pl] = nb[i];
4253
     l_path[pl] = nb[i];
4247
     if (pl < max_ringsize - 1)   /* just to be sure
4254
     if (pl < max_ringsize - 1)   /* just to be sure */
4248
     l_path[pl + 1] = 0;
4255
     l_path[pl + 1] = 0;
4249
     if (is_ringpath (l_path))
4256
     if (is_ringpath (l_path))
4250
     rp = true;
4257
     rp = true;
4251
     }
4258
     }
4252
     }
4259
     }
4253
     return rp;
4260
     return rp;
4254
     } */
4261
     }
-
 
4262
#endif
4255
 
4263
 
4256
static boolean
4264
static boolean
4257
is_ringpath (int *s_path)
4265
is_ringpath (int *s_path)
4258
{
4266
{
4259
  int i, j;
4267
  int i, j;
Line 4261... Line 4269...
4261
  boolean rp = false;
4269
  boolean rp = false;
4262
  boolean new_atom;
4270
  boolean new_atom;
4263
  int a_last, pl;
4271
  int a_last, pl;
4264
  ringpath_type l_path;
4272
  ringpath_type l_path;
4265
  int FORLIM, pl_prev, pl_next, max_ringsize_dec;
4273
  int FORLIM, pl_prev, pl_next, max_ringsize_dec;
4266
 
4274
 
4267
/* p2c: checkmol.pas: Note: Eliminated unused assignment statement [338] */
4275
/* p2c: checkmol.pas: Note: Eliminated unused assignment statement [338] */
4268
  memset ((void *) nb, 0, sizeof (neighbor_rec));
4276
  memset ((void *) nb, 0, sizeof (neighbor_rec));
4269
  memset ((void *) l_path, 0, sizeof (ringpath_type));
4277
  memset ((void *) l_path, 0, sizeof (ringpath_type));
4270
  pl = path_length (s_path);
4278
  pl = path_length (s_path);
4271
  if (pl < 1)
4279
  if (pl < 1)
Line 4352... Line 4360...
4352
                   max_ringpath_recursion_depth);
4360
                   max_ringpath_recursion_depth);
4353
              n_rings = max_rings;
4361
              n_rings = max_rings;
4354
              return false;
4362
              return false;
4355
            }
4363
            }
4356
 
4364
 
4357
          //printf("%i\n",recursion_depth);
4365
          /*printf("%i\n",recursion_depth);
4358
          //fflush(stdout);
4366
          fflush(stdout);*/
4359
 
4367
 
4360
          if (is_ringpath (l_path))
4368
          if (is_ringpath (l_path))
4361
            rp = true;
4369
            rp = true;
4362
          //return true;
4370
          /*return true;*/
4363
        }
4371
        }
4364
    }
4372
    }
4365
  return rp;
4373
  return rp;
4366
}
4374
}
4367
 
4375
 
Line 4395... Line 4403...
4395
            rb = true;
4403
            rb = true;
4396
          //return true;
4404
          //return true;
4397
        }
4405
        }
4398
    }
4406
    }
4399
  return rb;
4407
  return rb;
4400
}
4408
}
4401
 
4409
 
4402
 
4410
 
4403
static void
4411
static void
4404
chk_ringbonds ()
4412
chk_ringbonds ()
4405
{
4413
{
4406
  int i, a1rc, a2rc;
4414
  int i, a1rc, a2rc;
4407
 
4415
 
4408
  if (n_bonds < 1)
4416
  if (n_bonds < 1)
4409
    return;
4417
    return;
4410
 
4418
 
4411
  for (i = 0; i < n_bonds; i++)
4419
  for (i = 0; i < n_bonds; i++)
4412
    {
4420
    {
4413
      a1rc = atom[bond[i].a1 - 1].ring_count;
4421
      a1rc = atom[bond[i].a1 - 1].ring_count;
4414
      a2rc = atom[bond[i].a2 - 1].ring_count;
4422
      a2rc = atom[bond[i].a2 - 1].ring_count;
4415
      if (n_rings == 0 || a1rc < n_rings && a2rc < n_rings)
4423
      if (n_rings == 0 || (a1rc < n_rings && a2rc < n_rings))
4416
        {
4424
        {
4417
          is_ringbond (i + 1);
4425
          is_ringbond (i + 1);
4418
          /*inc(bond^[i].ring_count); */
4426
          /*inc(bond^[i].ring_count); */
4419
        }
4427
        }
4420
    }
4428
    }
4421
}
4429
}
4422
 
4430
 
4423
 
4431
 
4424
/* v0.3d: moved procedure update_ringcount a bit down */
4432
/* v0.3d: moved procedure update_ringcount a bit down */
4425
 
4433
 
4426
 
4434
 
4427
static int
4435
static int
4428
raw_hetbond_count (int a)
4436
raw_hetbond_count (int a)
4429
{
4437
{
4430
  /* new in v0.2j, ignores bond order */
4438
  /* new in v0.2j, ignores bond order */
4431
  int i;
4439
  int i;
Line 4433... Line 4441...
4433
  str2 nb_el;
4441
  str2 nb_el;
4434
  int hbc = 0;
4442
  int hbc = 0;
4435
  int FORLIM;
4443
  int FORLIM;
4436
 
4444
 
4437
  if (a <= 0 || a > n_atoms)
4445
  if (a <= 0 || a > n_atoms)
4438
    return hbc;
4446
    return hbc;
4439
  memset (nb, 0, sizeof (neighbor_rec));
4447
  memset (nb, 0, sizeof (neighbor_rec));
4440
  get_neighbors (nb, a);
4448
  get_neighbors (nb, a);
4441
  if (atom[a - 1].neighbor_count <= 0)
4449
  if (atom[a - 1].neighbor_count <= 0)
4442
    return hbc;
4450
    return hbc;
4443
  FORLIM = atom[a - 1].neighbor_count;
4451
  FORLIM = atom[a - 1].neighbor_count;
Line 4446... Line 4454...
4446
      strcpy (nb_el, atom[nb[i] - 1].element);
4454
      strcpy (nb_el, atom[nb[i] - 1].element);
4447
      if (strcmp (nb_el, "C ") && strcmp (nb_el, "A ") && strcmp (nb_el, "H ")  /* &&  strcmp (nb_el, "D ") */
4455
      if (strcmp (nb_el, "C ") && strcmp (nb_el, "A ") && strcmp (nb_el, "H ")  /* &&  strcmp (nb_el, "D ") */
4448
          && strcmp (nb_el, "LP") && strcmp (nb_el, "DU"))
4456
          && strcmp (nb_el, "LP") && strcmp (nb_el, "DU"))
4449
        /* added 'D ' in v0.3n */
4457
        /* added 'D ' in v0.3n */
4450
        hbc++;
4458
        hbc++;
4451
    }
4459
    }
4452
  return hbc;
4460
  return hbc;
4453
}
4461
}
4454
 
4462
 
4455
 
4463
 
4456
static int
4464
static int
Line 4515... Line 4523...
4515
        hac++;
4523
        hac++;
4516
    }
4524
    }
4517
  return hac;
4525
  return hac;
4518
}
4526
}
4519
 
4527
 
4520
 
4528
#if 0
4521
static int
4529
static int
4522
ndl_hetbond_count (int a)
4530
ndl_hetbond_count (int a)
4523
{
4531
{
4524
  int i;
4532
  int i;
4525
  neighbor_rec nb;
4533
  neighbor_rec nb;
4526
  str2 nb_el;
4534
  str2 nb_el;
4527
  float hbc = 0.0;
4535
  float hbc = 0.0;
4528
  int FORLIM;
4536
  int FORLIM;
4529
 
4537
 
4530
  if (a <= 0 || a > n_atoms)
4538
  if (a <= 0 || a > n_atoms)
4531
    return ((int) floor (hbc + 0.5));
4539
    return ((int) floor (hbc + 0.5));
4532
  memset (nb, 0, sizeof (neighbor_rec));
4540
  memset (nb, 0, sizeof (neighbor_rec));
4533
  get_ndl_neighbors (nb, a);
4541
  get_ndl_neighbors (nb, a);
4534
  if (ndl_atom[a - 1].neighbor_count <= 0)
4542
  if (ndl_atom[a - 1].neighbor_count <= 0)
4535
    return ((int) floor (hbc + 0.5));
4543
    return ((int) floor (hbc + 0.5));
4536
  FORLIM = ndl_atom[a - 1].neighbor_count;
4544
  FORLIM = ndl_atom[a - 1].neighbor_count;
Line 4551... Line 4559...
4551
            hbc += 3.0;
4559
            hbc += 3.0;
4552
        }
4560
        }
4553
    }
4561
    }
4554
  return ((int) floor (hbc + 0.5));
4562
  return ((int) floor (hbc + 0.5));
4555
}
4563
}
4556
 
4564
#endif
4557
 
4565
 
4558
static int
4566
static int
4559
ndl_hetatom_count (int a)
4567
ndl_hetatom_count (int a)
4560
{
4568
{
4561
  int i;
4569
  int i;
Line 4578... Line 4586...
4578
          && strcmp (nb_el, "LP") && strcmp (nb_el, "DU"))
4586
          && strcmp (nb_el, "LP") && strcmp (nb_el, "DU"))
4579
        /* added 'D ' in v0.3n */
4587
        /* added 'D ' in v0.3n */
4580
        hac++;
4588
        hac++;
4581
    }
4589
    }
4582
  return hac;
4590
  return hac;
4583
}
4591
}
4584
 
4592
 
4585
 
4593
 
4586
static boolean
4594
static boolean
4587
is_oxo_C (int id)
4595
is_oxo_C (int id)
4588
{
4596
{
4589
  boolean Result;
4597
  boolean Result;
Line 4606... Line 4614...
4606
        /* no N, amidines are different... */
4614
        /* no N, amidines are different... */
4607
        r = true;
4615
        r = true;
4608
      /* or
4616
      /* or
4609
         (atom^[(nb[i])].element = 'S ')  or
4617
         (atom^[(nb[i])].element = 'S ')  or
4610
         (atom^[(nb[i])].element = 'SE') */
4618
         (atom^[(nb[i])].element = 'SE') */
4611
    }
4619
    }
4612
  return r;
4620
  return r;
4613
}
4621
}
4614
 
4622
 
4615
 
4623
 
4616
static boolean
4624
static boolean
Line 4633... Line 4641...
4633
    {
4641
    {
4634
      if (bond[get_bond (id, nb[i]) - 1].btype == 'D' &&
4642
      if (bond[get_bond (id, nb[i]) - 1].btype == 'D' &&
4635
          (!strcmp (atom[nb[i] - 1].element, "S ") ||
4643
          (!strcmp (atom[nb[i] - 1].element, "S ") ||
4636
           !strcmp (atom[nb[i] - 1].element, "SE")))
4644
           !strcmp (atom[nb[i] - 1].element, "SE")))
4637
        /* no N, amidines are different... */
4645
        /* no N, amidines are different... */
4638
        r = true;
4646
        r = true;
4639
    }
4647
    }
4640
  return r;
4648
  return r;
4641
}
4649
}
4642
 
4650
 
4643
 
4651
 
4644
static boolean
4652
static boolean
4645
is_imino_C (int id)
4653
is_imino_C (int id)
4646
{
4654
{
4647
  boolean Result;
4655
  boolean Result;
4648
  int i;
4656
  int i;
4649
  boolean r = false;
4657
  boolean r = false;
4650
  neighbor_rec nb;
4658
  neighbor_rec nb;
4651
  int FORLIM;
4659
  int FORLIM;
4652
 
4660
 
4653
  memset (nb, 0, sizeof (neighbor_rec));
4661
  memset (nb, 0, sizeof (neighbor_rec));
4654
  if (id < 1 || id > n_atoms)
4662
  if (id < 1 || id > n_atoms)
4655
    return Result;
4663
    return Result;
4656
  get_neighbors (nb, id);
4664
  get_neighbors (nb, id);
4657
  if (strcmp (atom[id - 1].element, "C ") || atom[id - 1].neighbor_count <= 0)
4665
  if (strcmp (atom[id - 1].element, "C ") || atom[id - 1].neighbor_count <= 0)
4658
    return false;
4666
    return false;
4659
  FORLIM = atom[id - 1].neighbor_count;
4667
  FORLIM = atom[id - 1].neighbor_count;
4660
  for (i = 0; i < FORLIM; i++)
4668
  for (i = 0; i < FORLIM; i++)
4661
    {
4669
    {
4662
      if (bond[get_bond (id, nb[i]) - 1].btype == 'D' &&
4670
      if (bond[get_bond (id, nb[i]) - 1].btype == 'D' &&
4663
          !strcmp (atom[nb[i] - 1].element, "N "))
4671
          !strcmp (atom[nb[i] - 1].element, "N "))
4664
        r = true;
4672
        r = true;
4665
    }
4673
    }
4666
  return r;
4674
  return r;
4667
}
4675
}
4668
 
4676
 
4669
 
4677
 
4670
static boolean
4678
static boolean
4671
is_true_imino_C (int id)
4679
is_true_imino_C (int id)
4672
{
4680
{
4673
  boolean Result;
4681
  boolean Result;
4674
  int i;
4682
  int i;
Line 4678... Line 4686...
4678
  int a_n = 0;
4686
  int a_n = 0;
4679
  int b;                        /* v0.3j */
4687
  int b;                        /* v0.3j */
4680
  int FORLIM;
4688
  int FORLIM;
4681
 
4689
 
4682
/* p2c: checkmol.pas: Note: Eliminated unused assignment statement [338] */
4690
/* p2c: checkmol.pas: Note: Eliminated unused assignment statement [338] */
4683
  memset (nb, 0, sizeof (neighbor_rec));
4691
  memset (nb, 0, sizeof (neighbor_rec));
4684
  if (id < 1 || id > n_atoms)
4692
  if (id < 1 || id > n_atoms)
4685
    return Result;
4693
    return Result;
4686
  get_neighbors (nb, id);
4694
  get_neighbors (nb, id);
4687
  if (strcmp (atom[id - 1].element, "C ") || atom[id - 1].neighbor_count <= 0)
4695
  if (strcmp (atom[id - 1].element, "C ") || atom[id - 1].neighbor_count <= 0)
4688
    return false;
4696
    return false;
4689
  FORLIM = atom[id - 1].neighbor_count;
4697
  FORLIM = atom[id - 1].neighbor_count;
4690
  for (i = 0; i < FORLIM; i++)
4698
  for (i = 0; i < FORLIM; i++)
4691
    {
4699
    {
4692
      b = get_bond (id, nb[i]); /* v0.3j */
4700
      b = get_bond (id, nb[i]); /* v0.3j */
4693
      if (bond[b - 1].btype == 'D' && bond[b - 1].arom == false &&
4701
      if (bond[b - 1].btype == 'D' && bond[b - 1].arom == false &&
4694
          !strcmp (atom[nb[i] - 1].element, "N "))
4702
          !strcmp (atom[nb[i] - 1].element, "N "))
4695
        /* v0.3j */
4703
        /* v0.3j */
4696
        a_n = nb[i];
4704
        a_n = nb[i];
4697
    }
4705
    }
4698
  if (a_n <= 0)
4706
  if (a_n <= 0)
4699
    return false;
4707
    return false;
4700
  memset (nb, 0, sizeof (neighbor_rec));
4708
  memset (nb, 0, sizeof (neighbor_rec));
4701
  get_neighbors (nb, a_n);
4709
  get_neighbors (nb, a_n);
4702
  FORLIM = atom[a_n - 1].neighbor_count;
4710
  FORLIM = atom[a_n - 1].neighbor_count;
Line 4709... Line 4717...
4709
        r = false;
4717
        r = false;
4710
    }
4718
    }
4711
  return r;
4719
  return r;
4712
}
4720
}
4713
 
4721
 
4714
 
4722
 
4715
static boolean
4723
static boolean
4716
is_true_exocyclic_imino_C (int id, int r_id)
4724
is_true_exocyclic_imino_C (int id, int r_id)
4717
{
4725
{
4718
  /* v0.3j */
4726
  /* v0.3j */
4719
  boolean Result;
4727
  boolean Result;
4720
  int i, j;
4728
  int i, j;
4721
  boolean r = false;
4729
  boolean r = false;
4722
  neighbor_rec nb;
4730
  neighbor_rec nb;
Line 4736... Line 4744...
4736
  FORLIM = atom[id - 1].neighbor_count;
4744
  FORLIM = atom[id - 1].neighbor_count;
4737
  for (i = 0; i < FORLIM; i++)
4745
  for (i = 0; i < FORLIM; i++)
4738
    {
4746
    {
4739
      b = get_bond (id, nb[i]);
4747
      b = get_bond (id, nb[i]);
4740
      if (bond[b - 1].btype == 'D' && bond[b - 1].arom == false &&
4748
      if (bond[b - 1].btype == 'D' && bond[b - 1].arom == false &&
4741
          !strcmp (atom[nb[i] - 1].element, "N "))
4749
          !strcmp (atom[nb[i] - 1].element, "N "))
4742
        {
4750
        {
4743
          r = true;
4751
          r = true;
4744
          for (j = 0; j < ring_size; j++)
4752
          for (j = 0; j < ring_size; j++)
4745
            {
4753
            {
4746
              if (nb[i] == ring[r_id - 1][j])
4754
              if (nb[i] == ring[r_id - 1][j])
4747
                r = false;
4755
                r = false;
4748
            }
4756
            }
4749
        }
4757
        }
4750
    }
4758
    }
4751
  return r;
4759
  return r;
4752
}
4760
}
4753
 
4761
 
4754
 
4762
 
4755
static boolean
4763
static boolean
4756
is_exocyclic_imino_C (int id, int r_id)
4764
is_exocyclic_imino_C (int id, int r_id)
4757
{
4765
{
4758
  boolean Result;
4766
  boolean Result;
4759
  int i, j;
4767
  int i, j;
Line 4763... Line 4771...
4763
  int ring_size, FORLIM;
4771
  int ring_size, FORLIM;
4764
 
4772
 
4765
  memset (nb, 0, sizeof (neighbor_rec));
4773
  memset (nb, 0, sizeof (neighbor_rec));
4766
  if (id < 1 || id > n_atoms)
4774
  if (id < 1 || id > n_atoms)
4767
    return Result;
4775
    return Result;
4768
  get_neighbors (nb, id);
4776
  get_neighbors (nb, id);
4769
  memset (testring, 0, sizeof (ringpath_type));
4777
  memset (testring, 0, sizeof (ringpath_type));
4770
  ring_size = ringprop[r_id - 1].size;  /* v0.3j */
4778
  ring_size = ringprop[r_id - 1].size;  /* v0.3j */
4771
  for (j = 0; j < ring_size; j++)       /* v0.3j */
4779
  for (j = 0; j < ring_size; j++)       /* v0.3j */
4772
    testring[j] = ring[r_id - 1][j];
4780
    testring[j] = ring[r_id - 1][j];
4773
  if (strcmp (atom[id - 1].element, "C ") || atom[id - 1].neighbor_count <= 0)
4781
  if (strcmp (atom[id - 1].element, "C ") || atom[id - 1].neighbor_count <= 0)
4774
    return false;
4782
    return false;
Line 4844... Line 4852...
4844
}
4852
}
4845
 
4853
 
4846
 
4854
 
4847
static boolean
4855
static boolean
4848
is_sulfanyl (int a_view, int a_ref)
4856
is_sulfanyl (int a_view, int a_ref)
4849
{
4857
{
4850
  boolean r = false;
4858
  boolean r = false;
4851
 
4859
 
4852
  if (atom[a_view - 1].
4860
  if (atom[a_view - 1].
4853
      heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S'))
4861
      heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S'))
4854
    {
4862
    {
4855
      if (!strcmp (atom[a_ref - 1].atype, "S3 ") &&
4863
      if (!strcmp (atom[a_ref - 1].atype, "S3 ") &&
4856
          atom[a_ref - 1].neighbor_count == 1)
4864
          atom[a_ref - 1].neighbor_count == 1)
4857
        r = true;
4865
        r = true;
4858
    }
4866
    }
4859
  return r;
4867
  return r;
4860
}
4868
}
4861
 
4869
 
4862
 
4870
 
4863
static boolean
4871
static boolean
4864
is_amino (int a_view, int a_ref)
4872
is_amino (int a_view, int a_ref)
4865
{
4873
{
4866
  boolean r = false;
4874
  boolean r = false;
Line 4870... Line 4878...
4870
    {
4878
    {
4871
      if ((!strcmp (atom[a_ref - 1].atype, "N3 ") ||
4879
      if ((!strcmp (atom[a_ref - 1].atype, "N3 ") ||
4872
           !strcmp (atom[a_ref - 1].atype, "N3+")) &&
4880
           !strcmp (atom[a_ref - 1].atype, "N3+")) &&
4873
          atom[a_ref - 1].neighbor_count == 1)
4881
          atom[a_ref - 1].neighbor_count == 1)
4874
        r = true;
4882
        r = true;
4875
    }
4883
    }
4876
  return r;
4884
  return r;
4877
}
4885
}
4878
 
4886
 
4879
 
4887
 
4880
static boolean
4888
static boolean
4881
is_alkyl (int a_view, int a_ref)
4889
is_alkyl (int a_view, int a_ref)
4882
{
4890
{
4883
  int i;
4891
  int i;
4884
  boolean r = false;
4892
  boolean r = false;
4885
  neighbor_rec nb;
4893
  neighbor_rec nb;
4886
  str2 nb_el;
4894
  str2 nb_el;
4887
  int het_count = 0;
4895
  int het_count = 0;
4888
  int FORLIM;
4896
  int FORLIM;
4889
 
4897
 
4890
  memset (nb, 0, sizeof (neighbor_rec));
4898
  memset (nb, 0, sizeof (neighbor_rec));
4891
  if (!
4899
  if (!
4892
      (atom[a_view - 1].
4900
      (atom[a_view - 1].
4893
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S'))
4901
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S'))
4894
      || strcmp (atom[a_ref - 1].atype, "C3 ")
4902
      || strcmp (atom[a_ref - 1].atype, "C3 ")
4895
      || atom[a_ref - 1].arom != false)
4903
      || atom[a_ref - 1].arom != false)
4896
    return false;
4904
    return false;
4897
  get_nextneighbors (nb, a_ref, a_view);
4905
  get_nextneighbors (nb, a_ref, a_view);
4898
  FORLIM = atom[a_ref - 1].neighbor_count - 2;
4906
  FORLIM = atom[a_ref - 1].neighbor_count - 2;
4899
  for (i = 0; i <= FORLIM; i++)
4907
  for (i = 0; i <= FORLIM; i++)
4900
    {
4908
    {
4901
      strcpy (nb_el, atom[nb[i] - 1].element);
4909
      strcpy (nb_el, atom[nb[i] - 1].element);
4902
      if (strcmp (nb_el, "C ") && strcmp (nb_el, "H ")
4910
      if (strcmp (nb_el, "C ") && strcmp (nb_el, "H ")
4903
          /*&&  strcmp (nb_el, "D ") */  && strcmp (nb_el, "DU")
4911
          /*&&  strcmp (nb_el, "D ") */  && strcmp (nb_el, "DU")
4904
          && strcmp (nb_el, "LP"))
4912
          && strcmp (nb_el, "LP"))
4905
        /* added 'D ' in v0.3n */
4913
        /* added 'D ' in v0.3n */
4906
        het_count++;
4914
        het_count++;
Line 4917... Line 4925...
4917
  int i;
4925
  int i;
4918
  boolean r = false;
4926
  boolean r = false;
4919
  neighbor_rec nb;
4927
  neighbor_rec nb;
4920
  str2 nb_el;
4928
  str2 nb_el;
4921
  int het_count = 0;
4929
  int het_count = 0;
4922
  int FORLIM;
4930
  int FORLIM;
4923
 
4931
 
4924
  memset (nb, 0, sizeof (neighbor_rec));
4932
  memset (nb, 0, sizeof (neighbor_rec));
4925
  if (!
4933
  if (!
4926
      (atom[a_view - 1].
4934
      (atom[a_view - 1].
4927
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S'))
4935
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S'))
4928
      || strcmp (atom[a_ref - 1].atype, "C3 ")
4936
      || strcmp (atom[a_ref - 1].atype, "C3 ")
4929
      || atom[a_ref - 1].arom != false)
4937
      || atom[a_ref - 1].arom != false)
4930
    return false;
4938
    return false;
4931
  get_nextneighbors (nb, a_ref, a_view);
4939
  get_nextneighbors (nb, a_ref, a_view);
4932
  FORLIM = atom[a_ref - 1].neighbor_count - 2;
4940
  FORLIM = atom[a_ref - 1].neighbor_count - 2;
Line 4944... Line 4952...
4944
}
4952
}
4945
 
4953
 
4946
 
4954
 
4947
static boolean
4955
static boolean
4948
is_alkenyl (int a_view, int a_ref)
4956
is_alkenyl (int a_view, int a_ref)
4949
{
4957
{
4950
  /* new in v0.3j */
4958
  /* new in v0.3j */
4951
  int i;
4959
  int i;
4952
  boolean r = false;
4960
  boolean r = false;
4953
  neighbor_rec nb;
4961
  neighbor_rec nb;
4954
  str2 nb_el;
4962
  str2 nb_el;
4955
  str3 nb_at;
4963
  str3 nb_at;
4956
  int c2_count = 0, het_count = 0;
4964
  int c2_count = 0, het_count = 0;
4957
  int FORLIM;
4965
  int FORLIM;
4958
 
4966
 
Line 5031... Line 5039...
5031
  return r;
5039
  return r;
5032
}
5040
}
5033
 
5041
 
5034
 
5042
 
5035
static boolean
5043
static boolean
5036
is_alkoxy (int a_view, int a_ref)
5044
is_alkoxy (int a_view, int a_ref)
-
 
5045
{
-
 
5046
  boolean r = false;
-
 
5047
  neighbor_rec nb;
-
 
5048
 
-
 
5049
  memset (nb, 0, sizeof (neighbor_rec));
-
 
5050
  if (!
-
 
5051
      (atom[a_view - 1].
-
 
5052
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
-
 
5053
    return false;
-
 
5054
  if (strcmp (atom[a_ref - 1].atype, "O3 ")
-
 
5055
      || atom[a_ref - 1].neighbor_count != 2)
-
 
5056
    return false;
-
 
5057
  get_nextneighbors (nb, a_ref, a_view);
-
 
5058
  if (is_alkyl (a_ref, nb[0]))
-
 
5059
    r = true;
-
 
5060
  return r;
-
 
5061
}
-
 
5062
 
-
 
5063
 
-
 
5064
static boolean
-
 
5065
is_siloxy (int a_view, int a_ref)
5037
{
5066
{
5038
  boolean r = false;
5067
  boolean r = false;
5039
  neighbor_rec nb;
5068
  neighbor_rec nb;
5040
 
5069
 
5041
  memset (nb, 0, sizeof (neighbor_rec));
5070
  memset (nb, 0, sizeof (neighbor_rec));
5042
  if (!
5071
  if (!
5043
      (atom[a_view - 1].
5072
      (atom[a_view - 1].
5044
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5073
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5045
    return false;
5074
    return false;
5046
  if (strcmp (atom[a_ref - 1].atype, "O3 ")
5075
  if (strcmp (atom[a_ref - 1].atype, "O3 ")
5047
      || atom[a_ref - 1].neighbor_count != 2)
5076
      || atom[a_ref - 1].neighbor_count != 2)
5048
    return false;
5077
    return false;
5049
  get_nextneighbors (nb, a_ref, a_view);
5078
  get_nextneighbors (nb, a_ref, a_view);
5050
  if (is_alkyl (a_ref, nb[0]))
5079
  if (!strcmp (atom[nb[0] - 1].element, "SI"))
5051
    r = true;
5080
    r = true;
5052
  return r;
5081
  return r;
5053
}
5082
}
5054
 
5083
 
5055
 
5084
 
5056
static boolean
5085
static boolean
5057
is_siloxy (int a_view, int a_ref)
5086
is_true_alkoxy (int a_view, int a_ref)
5058
{
5087
{
5059
  boolean r = false;
5088
  boolean r = false;
5060
  neighbor_rec nb;
5089
  neighbor_rec nb;
5061
 
5090
 
5062
  memset (nb, 0, sizeof (neighbor_rec));
5091
  memset (nb, 0, sizeof (neighbor_rec));
Line 5066... Line 5095...
5066
    return false;
5095
    return false;
5067
  if (strcmp (atom[a_ref - 1].atype, "O3 ")
5096
  if (strcmp (atom[a_ref - 1].atype, "O3 ")
5068
      || atom[a_ref - 1].neighbor_count != 2)
5097
      || atom[a_ref - 1].neighbor_count != 2)
5069
    return false;
5098
    return false;
5070
  get_nextneighbors (nb, a_ref, a_view);
5099
  get_nextneighbors (nb, a_ref, a_view);
5071
  if (!strcmp (atom[nb[0] - 1].element, "SI"))
5100
  if (is_true_alkyl (a_ref, nb[0]))
5072
    r = true;
5101
    r = true;
5073
  return r;
5102
  return r;
5074
}
5103
}
5075
 
5104
 
5076
 
5105
 
5077
static boolean
5106
static boolean
5078
is_true_alkoxy (int a_view, int a_ref)
5107
is_aryloxy (int a_view, int a_ref)
5079
{
5108
{
5080
  boolean r = false;
5109
  boolean r = false;
5081
  neighbor_rec nb;
5110
  neighbor_rec nb;
5082
 
5111
 
5083
  memset (nb, 0, sizeof (neighbor_rec));
5112
  memset (nb, 0, sizeof (neighbor_rec));
Line 5087... Line 5116...
5087
    return false;
5116
    return false;
5088
  if (strcmp (atom[a_ref - 1].atype, "O3 ")
5117
  if (strcmp (atom[a_ref - 1].atype, "O3 ")
5089
      || atom[a_ref - 1].neighbor_count != 2)
5118
      || atom[a_ref - 1].neighbor_count != 2)
5090
    return false;
5119
    return false;
5091
  get_nextneighbors (nb, a_ref, a_view);
5120
  get_nextneighbors (nb, a_ref, a_view);
5092
  if (is_true_alkyl (a_ref, nb[0]))
5121
  if (is_aryl (a_ref, nb[0]))
5093
    r = true;
5122
    r = true;
5094
  return r;
5123
  return r;
5095
}
5124
}
5096
 
5125
 
5097
 
5126
 
5098
static boolean
-
 
5099
is_aryloxy (int a_view, int a_ref)
-
 
5100
{
-
 
5101
  boolean r = false;
-
 
5102
  neighbor_rec nb;
-
 
5103
 
-
 
5104
  memset (nb, 0, sizeof (neighbor_rec));
-
 
5105
  if (!
-
 
5106
      (atom[a_view - 1].
-
 
5107
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
-
 
5108
    return false;
-
 
5109
  if (strcmp (atom[a_ref - 1].atype, "O3 ")
-
 
5110
      || atom[a_ref - 1].neighbor_count != 2)
-
 
5111
    return false;
-
 
5112
  get_nextneighbors (nb, a_ref, a_view);
-
 
5113
  if (is_aryl (a_ref, nb[0]))
-
 
5114
    r = true;
-
 
5115
  return r;
-
 
5116
}
-
 
5117
 
-
 
5118
 
-
 
5119
static boolean
5127
static boolean
5120
is_alkenyloxy (int a_view, int a_ref)
5128
is_alkenyloxy (int a_view, int a_ref)
5121
{
5129
{
5122
  /* v0.3j */
5130
  /* v0.3j */
5123
  boolean r = false;
5131
  boolean r = false;
Line 5134... Line 5142...
5134
  get_nextneighbors (nb, a_ref, a_view);
5142
  get_nextneighbors (nb, a_ref, a_view);
5135
  if (is_alkenyl (a_ref, nb[0]))
5143
  if (is_alkenyl (a_ref, nb[0]))
5136
    r = true;
5144
    r = true;
5137
  return r;
5145
  return r;
5138
}
5146
}
5139
 
5147
 
5140
 
5148
 
5141
static boolean
5149
static boolean
5142
is_alkynyloxy (int a_view, int a_ref)
5150
is_alkynyloxy (int a_view, int a_ref)
5143
{
5151
{
5144
  /* v0.3j */
5152
  /* v0.3j */
5145
  boolean r = false;
5153
  boolean r = false;
5146
  neighbor_rec nb;
5154
  neighbor_rec nb;
5147
 
5155
 
5148
  memset (nb, 0, sizeof (neighbor_rec));
5156
  memset (nb, 0, sizeof (neighbor_rec));
5149
  if (!
5157
  if (!
5150
      (atom[a_view - 1].
5158
      (atom[a_view - 1].
5151
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5159
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5152
    return false;
5160
    return false;
5153
  if (strcmp (atom[a_ref - 1].atype, "O3 ")
5161
  if (strcmp (atom[a_ref - 1].atype, "O3 ")
5154
      || atom[a_ref - 1].neighbor_count != 2)
5162
      || atom[a_ref - 1].neighbor_count != 2)
5155
    return false;
5163
    return false;
5156
  get_nextneighbors (nb, a_ref, a_view);
5164
  get_nextneighbors (nb, a_ref, a_view);
Line 5160... Line 5168...
5160
}
5168
}
5161
 
5169
 
5162
 
5170
 
5163
static boolean
5171
static boolean
5164
is_alkylsulfanyl (int a_view, int a_ref)
5172
is_alkylsulfanyl (int a_view, int a_ref)
5165
{
5173
{
5166
  boolean r = false;
5174
  boolean r = false;
5167
  neighbor_rec nb;
5175
  neighbor_rec nb;
5168
 
5176
 
5169
  memset (nb, 0, sizeof (neighbor_rec));
5177
  memset (nb, 0, sizeof (neighbor_rec));
5170
  if (!
5178
  if (!
5171
      (atom[a_view - 1].
5179
      (atom[a_view - 1].
5172
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5180
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5173
    return false;
5181
    return false;
5174
  if (strcmp (atom[a_ref - 1].atype, "S3 ")
5182
  if (strcmp (atom[a_ref - 1].atype, "S3 ")
5175
      || atom[a_ref - 1].neighbor_count != 2)
5183
      || atom[a_ref - 1].neighbor_count != 2)
5176
    return false;
5184
    return false;
5177
  get_nextneighbors (nb, a_ref, a_view);
5185
  get_nextneighbors (nb, a_ref, a_view);
Line 5216... Line 5224...
5216
  if (strcmp (atom[a_ref - 1].atype, "S3 ")
5224
  if (strcmp (atom[a_ref - 1].atype, "S3 ")
5217
      || atom[a_ref - 1].neighbor_count != 2)
5225
      || atom[a_ref - 1].neighbor_count != 2)
5218
    return false;
5226
    return false;
5219
  get_nextneighbors (nb, a_ref, a_view);
5227
  get_nextneighbors (nb, a_ref, a_view);
5220
  if (is_aryl (a_ref, nb[0]))
5228
  if (is_aryl (a_ref, nb[0]))
5221
    r = true;
5229
    r = true;
5222
  return r;
5230
  return r;
5223
}
5231
}
5224
 
5232
 
5225
 
5233
 
5226
static boolean
5234
static boolean
5227
is_alkenylsulfanyl (a_view, a_ref)
5235
is_alkenylsulfanyl (a_view, a_ref)
5228
     int a_view, a_ref;
5236
     int a_view, a_ref;
5229
{
5237
{
5230
  /* v0.3j */
5238
  /* v0.3j */
Line 5269... Line 5277...
5269
}
5277
}
5270
 
5278
 
5271
 
5279
 
5272
static boolean
5280
static boolean
5273
is_alkylamino (a_view, a_ref)
5281
is_alkylamino (a_view, a_ref)
5274
     int a_view, a_ref;
5282
     int a_view, a_ref;
5275
{
5283
{
5276
  boolean r = false;
5284
  boolean r = false;
5277
  neighbor_rec nb;
5285
  neighbor_rec nb;
5278
  int alkyl_count = 0;
5286
  int alkyl_count = 0;
5279
 
5287
 
5280
  memset (nb, 0, sizeof (neighbor_rec));
5288
  memset (nb, 0, sizeof (neighbor_rec));
5281
  if (!
5289
  if (!
5282
      (atom[a_view - 1].
5290
      (atom[a_view - 1].
5283
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5291
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
Line 5291... Line 5299...
5291
  if (alkyl_count == 1)
5299
  if (alkyl_count == 1)
5292
    r = true;
5300
    r = true;
5293
  return r;
5301
  return r;
5294
}
5302
}
5295
 
5303
 
5296
 
5304
 
5297
static boolean
5305
static boolean
5298
is_dialkylamino (a_view, a_ref)
5306
is_dialkylamino (a_view, a_ref)
5299
     int a_view, a_ref;
5307
     int a_view, a_ref;
5300
{
5308
{
5301
  int i;
5309
  int i;
5302
  boolean r = false;
5310
  boolean r = false;
5303
  neighbor_rec nb;
5311
  neighbor_rec nb;
5304
  int alkyl_count = 0;
5312
  int alkyl_count = 0;
Line 5316... Line 5324...
5316
    {
5324
    {
5317
      if (is_alkyl (a_ref, nb[i]))
5325
      if (is_alkyl (a_ref, nb[i]))
5318
        alkyl_count++;
5326
        alkyl_count++;
5319
    }
5327
    }
5320
  if (alkyl_count == 2)
5328
  if (alkyl_count == 2)
5321
    r = true;
5329
    r = true;
5322
  return r;
5330
  return r;
5323
}
5331
}
5324
 
5332
 
5325
 
5333
 
5326
static boolean
5334
static boolean
5327
is_arylamino (a_view, a_ref)
5335
is_arylamino (a_view, a_ref)
5328
     int a_view, a_ref;
5336
     int a_view, a_ref;
5329
{
5337
{
5330
  boolean r = false;
5338
  boolean r = false;
5331
  neighbor_rec nb;
5339
  neighbor_rec nb;
Line 5333... Line 5341...
5333
 
5341
 
5334
  memset (nb, 0, sizeof (neighbor_rec));
5342
  memset (nb, 0, sizeof (neighbor_rec));
5335
  if (!
5343
  if (!
5336
      (atom[a_view - 1].
5344
      (atom[a_view - 1].
5337
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5345
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5338
    return false;
5346
    return false;
5339
  if (strcmp (atom[a_ref - 1].element, "N ")
5347
  if (strcmp (atom[a_ref - 1].element, "N ")
5340
      || atom[a_ref - 1].neighbor_count != 2)
5348
      || atom[a_ref - 1].neighbor_count != 2)
5341
    return false;
5349
    return false;
5342
  get_nextneighbors (nb, a_ref, a_view);
5350
  get_nextneighbors (nb, a_ref, a_view);
5343
  if (is_aryl (a_ref, nb[0]))
5351
  if (is_aryl (a_ref, nb[0]))
5344
    aryl_count++;
5352
    aryl_count++;
5345
  if (aryl_count == 1)
5353
  if (aryl_count == 1)
5346
    r = true;
5354
    r = true;
5347
  return r;
5355
  return r;
5348
}
5356
}
5349
 
5357
 
5350
 
5358
 
5351
static boolean
5359
static boolean
5352
is_diarylamino (a_view, a_ref)
5360
is_diarylamino (a_view, a_ref)
5353
     int a_view, a_ref;
5361
     int a_view, a_ref;
5354
{
5362
{
5355
  int i;
5363
  int i;
5356
  boolean r = false;
5364
  boolean r = false;
Line 5359... Line 5367...
5359
 
5367
 
5360
  memset (nb, 0, sizeof (neighbor_rec));
5368
  memset (nb, 0, sizeof (neighbor_rec));
5361
  if (!
5369
  if (!
5362
      (atom[a_view - 1].
5370
      (atom[a_view - 1].
5363
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5371
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5364
    return false;
5372
    return false;
5365
  if (strcmp (atom[a_ref - 1].element, "N ")
5373
  if (strcmp (atom[a_ref - 1].element, "N ")
5366
      || atom[a_ref - 1].neighbor_count != 3)
5374
      || atom[a_ref - 1].neighbor_count != 3)
5367
    return false;
5375
    return false;
5368
  get_nextneighbors (nb, a_ref, a_view);
5376
  get_nextneighbors (nb, a_ref, a_view);
5369
  for (i = 0; i <= 1; i++)
5377
  for (i = 0; i <= 1; i++)
5370
    {
5378
    {
5371
      if (is_aryl (a_ref, nb[i]))
5379
      if (is_aryl (a_ref, nb[i]))
5372
        aryl_count++;
5380
        aryl_count++;
5373
    }
5381
    }
5374
  if (aryl_count == 2)
5382
  if (aryl_count == 2)
5375
    r = true;
5383
    r = true;
5376
  return r;
5384
  return r;
5377
}
5385
}
5378
 
5386
 
5379
 
5387
 
5380
static boolean
5388
static boolean
5381
is_alkylarylamino (a_view, a_ref)
5389
is_alkylarylamino (a_view, a_ref)
5382
     int a_view, a_ref;
5390
     int a_view, a_ref;
Line 5420... Line 5428...
5420
  memset (nb, 0, sizeof (neighbor_rec));
5428
  memset (nb, 0, sizeof (neighbor_rec));
5421
  if (!
5429
  if (!
5422
      (atom[a_view - 1].
5430
      (atom[a_view - 1].
5423
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5431
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5424
    return false;
5432
    return false;
5425
  if (strcmp (atom[a_ref - 1].atype, "N3 ")
5433
  if ((strcmp (atom[a_ref - 1].atype, "N3 ")
5426
      && strcmp (atom[a_ref - 1].atype, "NAM")
5434
      && strcmp (atom[a_ref - 1].atype, "NAM"))
5427
      || atom[a_ref - 1].neighbor_count != 2)
5435
      || atom[a_ref - 1].neighbor_count != 2)
5428
    return false;
5436
    return false;
5429
  get_nextneighbors (nb, a_ref, a_view);
5437
  get_nextneighbors (nb, a_ref, a_view);
5430
  if (!strcmp (atom[nb[0] - 1].element, "C "))
5438
  if (!strcmp (atom[nb[0] - 1].element, "C "))
5431
    c_count++;
5439
    c_count++;
Line 5449... Line 5457...
5449
  b = get_bond (a_view, a_ref);
5457
  b = get_bond (a_view, a_ref);
5450
  memset (nb, 0, sizeof (neighbor_rec));
5458
  memset (nb, 0, sizeof (neighbor_rec));
5451
  if (!(atom[a_view - 1].heavy && bond[b - 1].btype == 'S' &&
5459
  if (!(atom[a_view - 1].heavy && bond[b - 1].btype == 'S' &&
5452
        bond[b - 1].arom == false))
5460
        bond[b - 1].arom == false))
5453
    return false;
5461
    return false;
5454
  if (strcmp (atom[a_ref - 1].atype, "N3 ")
5462
  if ((strcmp (atom[a_ref - 1].atype, "N3 ")
5455
      && strcmp (atom[a_ref - 1].atype, "NAM")
5463
      && strcmp (atom[a_ref - 1].atype, "NAM"))
5456
      || atom[a_ref - 1].neighbor_count != 3)
5464
      || atom[a_ref - 1].neighbor_count != 3)
5457
    return false;
5465
    return false;
5458
  get_nextneighbors (nb, a_ref, a_view);
5466
  get_nextneighbors (nb, a_ref, a_view);
5459
  for (i = 0; i <= 1; i++)
5467
  for (i = 0; i <= 1; i++)
5460
    {
5468
    {
Line 5481... Line 5489...
5481
}
5489
}
5482
 
5490
 
5483
 
5491
 
5484
static boolean
5492
static boolean
5485
is_true_alkylamino (a_view, a_ref)
5493
is_true_alkylamino (a_view, a_ref)
5486
     int a_view, a_ref;
5494
     int a_view, a_ref;
5487
{
5495
{
5488
  boolean r = false;
5496
  boolean r = false;
5489
  neighbor_rec nb;
5497
  neighbor_rec nb;
5490
  int alkyl_count = 0;
5498
  int alkyl_count = 0;
5491
 
5499
 
5492
  memset (nb, 0, sizeof (neighbor_rec));
5500
  memset (nb, 0, sizeof (neighbor_rec));
5493
  if (!
5501
  if (!
5494
      (atom[a_view - 1].
5502
      (atom[a_view - 1].
5495
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5503
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5496
    return false;
5504
    return false;
5497
  if (strcmp (atom[a_ref - 1].atype, "N3 ")
5505
  if ((strcmp (atom[a_ref - 1].atype, "N3 ")
5498
      && strcmp (atom[a_ref - 1].atype, "N3+")
5506
      && strcmp (atom[a_ref - 1].atype, "N3+"))
5499
      || atom[a_ref - 1].neighbor_count != 2)
5507
      || atom[a_ref - 1].neighbor_count != 2)
5500
    return false;
5508
    return false;
5501
  get_nextneighbors (nb, a_ref, a_view);
5509
  get_nextneighbors (nb, a_ref, a_view);
5502
  if (is_true_alkyl (a_ref, nb[0]))
5510
  if (is_true_alkyl (a_ref, nb[0]))
5503
    alkyl_count++;
5511
    alkyl_count++;
5504
  if (alkyl_count == 1)
5512
  if (alkyl_count == 1)
5505
    r = true;
5513
    r = true;
5506
  return r;
5514
  return r;
5507
}
5515
}
5508
 
5516
 
5509
 
5517
 
5510
static boolean
5518
static boolean
5511
is_true_dialkylamino (a_view, a_ref)
5519
is_true_dialkylamino (a_view, a_ref)
5512
     int a_view, a_ref;
5520
     int a_view, a_ref;
5513
{
5521
{
5514
  int i;
5522
  int i;
5515
  boolean r = false;
5523
  boolean r = false;
5516
  neighbor_rec nb;
5524
  neighbor_rec nb;
5517
  int alkyl_count = 0;
5525
  int alkyl_count = 0;
5518
 
5526
 
5519
  memset (nb, 0, sizeof (neighbor_rec));
5527
  memset (nb, 0, sizeof (neighbor_rec));
5520
  if (!
5528
  if (!
5521
      (atom[a_view - 1].
5529
      (atom[a_view - 1].
5522
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5530
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5523
    return false;
5531
    return false;
5524
  if (strcmp (atom[a_ref - 1].atype, "N3 ")
5532
  if ((strcmp (atom[a_ref - 1].atype, "N3 ")
5525
      && strcmp (atom[a_ref - 1].atype, "N3+")
5533
      && strcmp (atom[a_ref - 1].atype, "N3+"))
5526
      || atom[a_ref - 1].neighbor_count != 3)
5534
      || atom[a_ref - 1].neighbor_count != 3)
5527
    return false;
5535
    return false;
5528
  get_nextneighbors (nb, a_ref, a_view);
5536
  get_nextneighbors (nb, a_ref, a_view);
5529
  for (i = 0; i <= 1; i++)
5537
  for (i = 0; i <= 1; i++)
5530
    {
5538
    {
5531
      if (is_true_alkyl (a_ref, nb[i]))
5539
      if (is_true_alkyl (a_ref, nb[i]))
5532
        alkyl_count++;
5540
        alkyl_count++;
5533
    }
5541
    }
5534
  if (alkyl_count == 2)
5542
  if (alkyl_count == 2)
5535
    r = true;
5543
    r = true;
5536
  return r;
5544
  return r;
5537
}
5545
}
5538
 
5546
 
5539
 
5547
#if 0
5540
static boolean
5548
static boolean
5541
is_true_alkylarylamino (a_view, a_ref)
5549
is_true_alkylarylamino (a_view, a_ref)
5542
     int a_view, a_ref;
5550
     int a_view, a_ref;
5543
{
5551
{
5544
  int i;
5552
  int i;
Line 5549... Line 5557...
5549
  memset (nb, 0, sizeof (neighbor_rec));
5557
  memset (nb, 0, sizeof (neighbor_rec));
5550
  if (!
5558
  if (!
5551
      (atom[a_view - 1].
5559
      (atom[a_view - 1].
5552
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5560
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5553
    return false;
5561
    return false;
5554
  if (strcmp (atom[a_ref - 1].atype, "N3 ")
5562
  if ((strcmp (atom[a_ref - 1].atype, "N3 ")
5555
      && strcmp (atom[a_ref - 1].atype, "N3+")
5563
      && strcmp (atom[a_ref - 1].atype, "N3+"))
5556
      || atom[a_ref - 1].neighbor_count != 3)
5564
      || atom[a_ref - 1].neighbor_count != 3)
5557
    return false;
5565
    return false;
5558
  get_nextneighbors (nb, a_ref, a_view);
5566
  get_nextneighbors (nb, a_ref, a_view);
5559
  for (i = 0; i <= 1; i++)
5567
  for (i = 0; i <= 1; i++)
5560
    {
5568
    {
Line 5565... Line 5573...
5565
    }
5573
    }
5566
  if (alkyl_count == 1 && aryl_count == 1)
5574
  if (alkyl_count == 1 && aryl_count == 1)
5567
    r = true;
5575
    r = true;
5568
  return r;
5576
  return r;
5569
}
5577
}
5570
 
5578
#endif
5571
 
5579
 
5572
static boolean
5580
static boolean
5573
is_hydroxylamino (a_view, a_ref)
5581
is_hydroxylamino (a_view, a_ref)
5574
     int a_view, a_ref;
5582
     int a_view, a_ref;
5575
{
5583
{
Line 5919... Line 5927...
5919
}
5927
}
5920
 
5928
 
5921
 
5929
 
5922
static boolean
5930
static boolean
5923
is_aryloxythiocarbonyl (a_view, a_ref)
5931
is_aryloxythiocarbonyl (a_view, a_ref)
5924
     int a_view, a_ref;
5932
     int a_view, a_ref;
5925
{
5933
{
5926
  int i;
5934
  int i;
5927
  boolean r = false;
5935
  boolean r = false;
5928
  neighbor_rec nb;
5936
  neighbor_rec nb;
5929
 
5937
 
5930
  memset (nb, 0, sizeof (neighbor_rec));
5938
  memset (nb, 0, sizeof (neighbor_rec));
5931
  if (!
5939
  if (!
5932
      (atom[a_view - 1].
5940
      (atom[a_view - 1].
Line 5941... Line 5949...
5941
        r = true;
5949
        r = true;
5942
    }
5950
    }
5943
  return r;
5951
  return r;
5944
}
5952
}
5945
 
5953
 
5946
 
5954
 
5947
static boolean
5955
static boolean
5948
is_thiocarbamoyl (a_view, a_ref)
5956
is_thiocarbamoyl (a_view, a_ref)
5949
     int a_view, a_ref;
5957
     int a_view, a_ref;
5950
{
5958
{
5951
  int i;
5959
  int i;
5952
  boolean r = false;
5960
  boolean r = false;
5953
  neighbor_rec nb;
5961
  neighbor_rec nb;
5954
 
5962
 
5955
  memset (nb, 0, sizeof (neighbor_rec));
5963
  memset (nb, 0, sizeof (neighbor_rec));
5956
  if (!
5964
  if (!
5957
      (atom[a_view - 1].
5965
      (atom[a_view - 1].
5958
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5966
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5959
    return false;
5967
    return false;
Line 5967... Line 5975...
5967
        r = true;
5975
        r = true;
5968
    }
5976
    }
5969
  return r;
5977
  return r;
5970
}
5978
}
5971
 
5979
 
5972
 
5980
 
5973
static boolean
5981
static boolean
5974
is_alkanoyl (a_view, a_ref)
5982
is_alkanoyl (a_view, a_ref)
5975
     int a_view, a_ref;
5983
     int a_view, a_ref;
5976
{
5984
{
5977
  int i;
5985
  int i;
5978
  boolean r = false;
5986
  boolean r = false;
5979
  neighbor_rec nb;
5987
  neighbor_rec nb;
5980
 
5988
 
5981
  memset (nb, 0, sizeof (neighbor_rec));
5989
  memset (nb, 0, sizeof (neighbor_rec));
5982
  if (!
5990
  if (!
5983
      (atom[a_view - 1].
5991
      (atom[a_view - 1].
5984
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5992
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5985
    return false;
5993
    return false;
5986
  if (!(is_oxo_C (a_ref) && atom[a_ref - 1].neighbor_count == 3))
5994
  if (!(is_oxo_C (a_ref) && atom[a_ref - 1].neighbor_count == 3))
Line 5992... Line 6000...
5992
        r = true;
6000
        r = true;
5993
    }
6001
    }
5994
  return r;
6002
  return r;
5995
}
6003
}
5996
 
6004
 
5997
 
6005
 
5998
static boolean
6006
static boolean
5999
is_aroyl (a_view, a_ref)
6007
is_aroyl (a_view, a_ref)
6000
     int a_view, a_ref;
6008
     int a_view, a_ref;
6001
{
6009
{
6002
  int i;
6010
  int i;
6003
  boolean r = false;
6011
  boolean r = false;
6004
  neighbor_rec nb;
6012
  neighbor_rec nb;
6005
 
6013
 
6006
  memset (nb, 0, sizeof (neighbor_rec));
6014
  memset (nb, 0, sizeof (neighbor_rec));
6007
  if (!
6015
  if (!
6008
      (atom[a_view - 1].
6016
      (atom[a_view - 1].
6009
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
6017
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
6010
    return false;
6018
    return false;
6011
  if (!(is_oxo_C (a_ref) && atom[a_ref - 1].neighbor_count == 3))
6019
  if (!(is_oxo_C (a_ref) && atom[a_ref - 1].neighbor_count == 3))
6012
    return false;
6020
    return false;
Line 6031... Line 6039...
6031
  return r;
6039
  return r;
6032
}
6040
}
6033
 
6041
 
6034
 
6042
 
6035
static boolean
6043
static boolean
6036
is_acyl_gen (a_view, a_ref)
6044
is_acyl_gen (a_view, a_ref)
-
 
6045
     int a_view, a_ref;
-
 
6046
{
-
 
6047
  /* new in v0.3j */
-
 
6048
  boolean r = false;
-
 
6049
 
-
 
6050
  if (is_oxo_C (a_ref))
-
 
6051
    r = true;
-
 
6052
  return r;
-
 
6053
}
-
 
6054
 
-
 
6055
 
-
 
6056
static boolean
-
 
6057
is_acylamino (a_view, a_ref)
6037
     int a_view, a_ref;
6058
     int a_view, a_ref;
6038
{
6059
{
6039
  /* new in v0.3j */
-
 
6040
  boolean r = false;
6060
  boolean r = false;
-
 
6061
  neighbor_rec nb;
-
 
6062
  int acyl_count = 0;
6041
 
6063
 
6042
  if (is_oxo_C (a_ref))
-
 
6043
    r = true;
-
 
6044
  return r;
-
 
6045
}
-
 
6046
 
-
 
6047
 
-
 
6048
static boolean
-
 
6049
is_acylamino (a_view, a_ref)
-
 
6050
     int a_view, a_ref;
-
 
6051
{
-
 
6052
  boolean r = false;
-
 
6053
  neighbor_rec nb;
-
 
6054
  int acyl_count = 0;
-
 
6055
 
-
 
6056
  memset (nb, 0, sizeof (neighbor_rec));
6064
  memset (nb, 0, sizeof (neighbor_rec));
6057
  if (!
6065
  if (!
6058
      (atom[a_view - 1].
6066
      (atom[a_view - 1].
6059
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
6067
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
6060
    return false;
6068
    return false;
6061
  if (strcmp (atom[a_ref - 1].element, "N ")
6069
  if (strcmp (atom[a_ref - 1].element, "N ")
6062
      || atom[a_ref - 1].neighbor_count != 2)
6070
      || atom[a_ref - 1].neighbor_count != 2)
6063
    return false;
6071
    return false;
6064
  get_nextneighbors (nb, a_ref, a_view);
6072
  get_nextneighbors (nb, a_ref, a_view);
6065
  if (is_acyl (a_ref, nb[0]))
6073
  if (is_acyl (a_ref, nb[0]))
Line 6077... Line 6085...
6077
  /* may be substituted _or_ unsubstituted acylamino group! */
6085
  /* may be substituted _or_ unsubstituted acylamino group! */
6078
  int i;
6086
  int i;
6079
  boolean r = false;
6087
  boolean r = false;
6080
  neighbor_rec nb;
6088
  neighbor_rec nb;
6081
  int acyl_count = 0;
6089
  int acyl_count = 0;
6082
  int FORLIM;
6090
  int FORLIM;
6083
 
6091
 
6084
  memset (nb, 0, sizeof (neighbor_rec));
6092
  memset (nb, 0, sizeof (neighbor_rec));
6085
  if (!
6093
  if (!
6086
      (atom[a_view - 1].
6094
      (atom[a_view - 1].
6087
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
6095
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
6088
    return false;
6096
    return false;
6089
  if (strcmp (atom[a_ref - 1].element, "N ")
6097
  if (strcmp (atom[a_ref - 1].element, "N ")
6090
      || atom[a_ref - 1].neighbor_count < 2)
6098
      || atom[a_ref - 1].neighbor_count < 2)
6091
    return false;
6099
    return false;
Line 6133... Line 6141...
6133
}
6141
}
6134
 
6142
 
6135
 
6143
 
6136
static boolean
6144
static boolean
6137
is_nitroso (a_view, a_ref)
6145
is_nitroso (a_view, a_ref)
6138
     int a_view, a_ref;
6146
     int a_view, a_ref;
6139
{
6147
{
6140
  /* new in v0.3j */
6148
  /* new in v0.3j */
6141
  boolean r = false;
6149
  boolean r = false;
6142
  neighbor_rec nb;
6150
  neighbor_rec nb;
6143
  int o_count = 0;
6151
  int o_count = 0;
6144
  int a2;
6152
  int a2;
Line 6511... Line 6519...
6511
              if (total_bonds > 3)
6519
              if (total_bonds > 3)
6512
                {
6520
                {
6513
                  if (O_count == 0)
6521
                  if (O_count == 0)
6514
                    {
6522
                    {
6515
                      if (single_count > 3 ||
6523
                      if (single_count > 3 ||
6516
                          single_count == 2 && double_count == 1
6524
                          (single_count == 2 && double_count == 1
6517
                          && C_count >= 2)
6525
                          && C_count >= 2))
6518
                        atom[i].formal_charge = 1;
6526
                        atom[i].formal_charge = 1;
6519
                    }
6527
                    }
6520
                  else
6528
                  else
6521
                    {
6529
                    {
6522
                      if (O_count == 1 && atom[i].formal_charge == 0)   /* v0.3m */
6530
                      if (O_count == 1 && atom[i].formal_charge == 0)   /* v0.3m */
Line 6531... Line 6539...
6531
                      /* the rest is left empty, so far.... */
6539
                      /* the rest is left empty, so far.... */
6532
                    }
6540
                    }
6533
                }
6541
                }
6534
              /* could be an N-oxide -> should be found elsewhere  */
6542
              /* could be an N-oxide -> should be found elsewhere  */
6535
              if (triple_count == 1 ||
6543
              if (triple_count == 1 ||
6536
                  double_count == 2 && atom[i].neighbor_count == 2)
6544
                  (double_count == 2 && atom[i].neighbor_count == 2))
6537
                /* v0.3n */
6545
                /* v0.3n */
6538
                strcpy (atom[i].atype, "N1 ");
6546
                strcpy (atom[i].atype, "N1 ");
6539
              if (double_count == 1)
6547
              if (double_count == 1)
6540
                {
6548
                {
6541
                  /*if NdC_count > 0 then atom^[i].atype := 'N2 '; */
6549
                  /*if NdC_count > 0 then atom^[i].atype := 'N2 '; */
Line 6638... Line 6646...
6638
                n_ar++;
6646
                n_ar++;
6639
              if (bt_fw != 'A' && bt_bk == bt_fw)
6647
              if (bt_fw != 'A' && bt_bk == bt_fw)
6640
                cumul = true;
6648
                cumul = true;
6641
              a_prev = a_ref;
6649
              a_prev = a_ref;
6642
            }
6650
            }
6643
          if (n_ar == 6 || n_sb == 3 && n_db == 3 && cumul == false)
6651
          if (n_ar == 6 || (n_sb == 3 && n_db == 3 && cumul == false))
6644
            {                   /* this ring is aromatic */
6652
            {                   /* this ring is aromatic */
6645
              a_prev = testring[ring_size - 1];
6653
              a_prev = testring[ring_size - 1];
6646
              for (j = 0; j < ring_size; j++)
6654
              for (j = 0; j < ring_size; j++)
6647
                {
6655
                {
6648
                  a_ref = testring[j];
6656
                  a_ref = testring[j];
Line 6758... Line 6766...
6758
                    }
6766
                    }
6759
                  else
6767
                  else
6760
                    {
6768
                    {
6761
                      pi_count++;       /* v0.3j; adjustment for bridgehead N: see below */
6769
                      pi_count++;       /* v0.3j; adjustment for bridgehead N: see below */
6762
                      if (bt_bk == 'S' && bt_fw == 'S' &&
6770
                      if (bt_bk == 'S' && bt_fw == 'S' &&
6763
                          (ar_bk == true && ar_fw == false ||
6771
                          ((ar_bk == true && ar_fw == false) ||
6764
                           ar_bk == false && ar_fw == true))
6772
                           (ar_bk == false && ar_fw == true)))
6765
                        {
6773
                        {
6766
                          /* v0.3j; if a bridgehead N were not aromatic, it could  */
6774
                          /* v0.3j; if a bridgehead N were not aromatic, it could  */
6767
                          /* contribute 2 pi electrons --> try also this variant */
6775
                          /* contribute 2 pi electrons --> try also this variant */
6768
                          /* (example: CAS 32278-54-9) */
6776
                          /* (example: CAS 32278-54-9) */
6769
                          if (!strcmp (atom[a_ref - 1].element, "N "))
6777
                          if (!strcmp (atom[a_ref - 1].element, "N "))
Line 7332... Line 7340...
7332
    fg[fg_quart_ammonium - 1] = true;
7340
    fg[fg_quart_ammonium - 1] = true;
7333
  if (het_count != 1 || atom[a_ref - 1].neighbor_count < 3)
7341
  if (het_count != 1 || atom[a_ref - 1].neighbor_count < 3)
7334
    return;
7342
    return;
7335
  if (o_count == 1 && or_count == 0 && bo_sum > 3)
7343
  if (o_count == 1 && or_count == 0 && bo_sum > 3)
7336
    fg[fg_n_oxide - 1] = true;  /* finds only aliphatic N-oxides! */
7344
    fg[fg_n_oxide - 1] = true;  /* finds only aliphatic N-oxides! */
7337
  if ((o_count == 1 && or_count == 1 || o_count == 0) &&
7345
  if (((o_count == 1 && or_count == 1) || o_count == 0) &&
7338
      atom[a_ref - 1].arom == true)
7346
      atom[a_ref - 1].arom == true)
7339
    fg[fg_quart_ammonium - 1] = true;
7347
    fg[fg_quart_ammonium - 1] = true;
7340
}
7348
}
7341
 
7349
 
7342
 
7350
 
Line 8896... Line 8904...
8896
    fg[fg_hemiaminal - 1] = true;
8904
    fg[fg_hemiaminal - 1] = true;
8897
  if (n_count == 2)
8905
  if (n_count == 2)
8898
    fg[fg_aminal - 1] = true;
8906
    fg[fg_aminal - 1] = true;
8899
  if ((sh_count == 1 || sr_count == 1) && n_count == 1)
8907
  if ((sh_count == 1 || sr_count == 1) && n_count == 1)
8900
    fg[fg_thiohemiaminal - 1] = true;
8908
    fg[fg_thiohemiaminal - 1] = true;
8901
  if (sr_count == 2 || or_count == 1 && sr_count == 1)
8909
  if (sr_count == 2 || (or_count == 1 && sr_count == 1))
8902
    fg[fg_thioacetal - 1] = true;
8910
    fg[fg_thioacetal - 1] = true;
8903
}
8911
}
8904
 
8912
 
8905
 
8913
 
8906
static void
8914
static void
Line 9543... Line 9551...
9543
    printf ("isocyanate\n");
9551
    printf ("isocyanate\n");
9544
  if (fg[fg_thiocyanate - 1])
9552
  if (fg[fg_thiocyanate - 1])
9545
    printf ("thiocyanate\n");
9553
    printf ("thiocyanate\n");
9546
  if (fg[fg_isothiocyanate - 1])
9554
  if (fg[fg_isothiocyanate - 1])
9547
    printf ("isothiocyanate\n");
9555
    printf ("isothiocyanate\n");
9548
  if (fg[fg_carbodiimide - 1])
9556
  if (fg[fg_carbodiimide - 1])
9549
    printf ("carbodiimide\n");
9557
    printf ("carbodiimide\n");
9550
  if (fg[fg_nitroso_compound - 1])
9558
  if (fg[fg_nitroso_compound - 1])
9551
    printf ("nitroso compound\n");
9559
    printf ("nitroso compound\n");
9552
  if (fg[fg_nitro_compound - 1])
9560
  if (fg[fg_nitro_compound - 1])
9553
    printf ("nitro compound\n");
9561
    printf ("nitro compound\n");
Line 9747... Line 9755...
9747
    printf ("Peroxid\n");
9755
    printf ("Peroxid\n");
9748
  if (fg[fg_hydroperoxide - 1])
9756
  if (fg[fg_hydroperoxide - 1])
9749
    printf ("Hydroperoxid\n");
9757
    printf ("Hydroperoxid\n");
9750
  if (fg[fg_hydrazine - 1])
9758
  if (fg[fg_hydrazine - 1])
9751
    printf ("Hydrazin-Derivat\n");
9759
    printf ("Hydrazin-Derivat\n");
9752
  if (fg[fg_hydroxylamine - 1])
9760
  if (fg[fg_hydroxylamine - 1])
9753
    printf ("Hydroxylamin\n");
9761
    printf ("Hydroxylamin\n");
9754
  if (fg[fg_amine - 1] && amine_generic)
9762
  if (fg[fg_amine - 1] && amine_generic)
9755
    printf ("Amin\n");
9763
    printf ("Amin\n");
9756
  if (fg[fg_prim_amine - 1])
9764
  if (fg[fg_prim_amine - 1])
9757
    printf ("prim\344res Amin\n");
9765
    printf ("prim\344res Amin\n");
Line 10566... Line 10574...
10566
#undef sc
10574
#undef sc
10567
 
10575
 
10568
 
10576
 
10569
static void
10577
static void
10570
write_fg_binary ()
10578
write_fg_binary ()
10571
{
10579
{
10572
  int i, n;
10580
  int i, n;
10573
  char o;
10581
  char o;
10574
 
10582
 
10575
  for (i = 1; i <= max_fg / 8; i++)
10583
  for (i = 1; i <= max_fg / 8; i++)
10576
    {
10584
    {
Line 10591... Line 10599...
10591
        n += 64;
10599
        n += 64;
10592
      if (fg[i * 8 - 8])
10600
      if (fg[i * 8 - 8])
10593
        n += 128;
10601
        n += 128;
10594
      o = (char) n;
10602
      o = (char) n;
10595
      putchar (o);
10603
      putchar (o);
10596
    }
10604
    }
10597
}
10605
}
10598
 
10606
 
10599
 
10607
 
10600
static void
10608
static void
10601
write_fg_bitstring ()
10609
write_fg_bitstring ()
10602
{
10610
{
10603
  int i;
10611
  int i;
10604
 
10612
 
Line 10610... Line 10618...
10610
        putchar ('0');
10618
        putchar ('0');
10611
    }
10619
    }
10612
}
10620
}
10613
 
10621
 
10614
 
10622
 
-
 
10623
#if 0
10615
  /*static void readinputfile (molfilename) char *molfilename;
10624
static void readinputfile (molfilename) char *molfilename;
10616
     {
10625
     {
10617
     /* new version in v0.2g
10626
     /* new version in v0.2g */
10618
     char rline[256];
10627
     char rline[256];
10619
     char *TEMP;
10628
     char *TEMP;
10620
 
10629
 
10621
     molbufindex = 0;
10630
     molbufindex = 0;
10622
     if (!opt_stdin)
10631
     if (!opt_stdin)
10623
     {
10632
     {
10624
     if (!rfile_is_open)
10633
     if (!rfile_is_open)
10625
     {
10634
     {
10626
     assign (rfile, molfilename);
10635
     assign (rfile, molfilename);
10627
     rewind (rfile);
10636
     rewind (rfile);
10628
     rfile_is_open = true;
10637
     rfile_is_open = true;
10629
     }
10638
     }
10630
     /* p2c: checkmol.pas, line 7733: Warning:
10639
     /* p2c: checkmol.pas, line 7733: Warning:
10631
     * Don't know how to ASSIGN to a non-explicit file variable [207]
10640
     * Don't know how to ASSIGN to a non-explicit file variable [207] */
10632
     *rline = '\0';
10641
     *rline = '\0';
10633
     mol_in_queue = false;
10642
     mol_in_queue = false;
10634
     while ((!P_eof (rfile)) && (strpos2 (rline, "$$$$", 1) == 0))
10643
     while ((!P_eof (rfile)) && (strpos2 (rline, "$$$$", 1) == 0))
10635
     {
10644
     {
10636
     fgets (rline, 256, rfile);
10645
     fgets (rline, 256, rfile);
10637
     TEMP = strchr (rline, '\n');
10646
     TEMP = strchr (rline, '\n');
10638
     if (TEMP != NULL)
10647
     if (TEMP != NULL)
10639
     *TEMP = 0;
10648
     *TEMP = 0;
10640
     /*mol_in_queue := false;
10649
     /*mol_in_queue := false; */
10641
     if (molbufindex >= max_atoms + max_bonds + 64)
10650
     if (molbufindex >= max_atoms + max_bonds + 64)
10642
     {
10651
     {
10643
     printf ("Not enough memory for molfile! %12ld\n",
10652
     printf ("Not enough memory for molfile! %12ld\n",
10644
     molbufindex);
10653
     molbufindex);
10645
     if (rfile != NULL)
10654
     if (rfile != NULL)
10646
     fclose (rfile);
10655
     fclose (rfile);
10647
     rfile = NULL;
10656
     rfile = NULL;
10648
     _Escape (1);
10657
     _Escape (1);
10649
     }
10658
     }
10650
     molbufindex++;
10659
     molbufindex++;
10651
     strcpy (molbuf[molbufindex - 1], rline);
10660
     strcpy (molbuf[molbufindex - 1], rline);
10652
     if (strpos2 (rline, "$$$$", 1) > 0)
10661
     if (strpos2 (rline, "$$$$", 1) > 0)
10653
     mol_in_queue = true;
10662
     mol_in_queue = true;
10654
     }
10663
     }
10655
     if (!P_eof (rfile))
10664
     if (!P_eof (rfile))
Line 10678... Line 10687...
10678
     mol_in_queue = true;
10687
     mol_in_queue = true;
10679
     /* read from standard input
10688
     /* read from standard input
10680
     }
10689
     }
10681
     }
10690
     }
10682
     } */
10691
     } */
-
 
10692
#endif
10683
 
10693
 
10684
static void
10694
static void
10685
readinputfile (char *molfilename)
10695
readinputfile (char *molfilename)
10686
{
10696
{
10687
  /* new version in v0.2g */
10697
  /* new version in v0.2g */
Line 10694... Line 10704...
10694
      if (!rfile_is_open)
10704
      if (!rfile_is_open)
10695
        {
10705
        {
10696
          rfile = fopen (molfilename, "r");
10706
          rfile = fopen (molfilename, "r");
10697
          rewind (rfile);
10707
          rewind (rfile);
10698
          rfile_is_open = true;
10708
          rfile_is_open = true;
10699
        }
10709
        }
10700
/* p2c: checkmol.pas, line 7226: Warning:
10710
/* p2c: checkmol.pas, line 7226: Warning:
10701
 * Don't know how to ASSIGN to a non-explicit file variable [207] */
10711
 * Don't know how to ASSIGN to a non-explicit file variable [207] */
10702
      *rline = '\0';
10712
      *rline = '\0';
10703
      mol_in_queue = false;
10713
      mol_in_queue = false;
10704
      while ((fgets (rline, 256, rfile) != NULL)
10714
      while ((fgets (rline, 256, rfile) != NULL)
Line 10754... Line 10764...
10754
        }
10764
        }
10755
    }
10765
    }
10756
  while (strstr (rline, "$$$$") == NULL);
10766
  while (strstr (rline, "$$$$") == NULL);
10757
}
10767
}
10758
 
10768
 
10759
 
-
 
10760
 
10769
#if 0
10761
/* static void copy_mol_to_needle()
10770
static void copy_mol_to_needle()
10762
{
10771
{
10763
  int i, j, FORLIM;
10772
  int i, j, FORLIM;
10764
 
10773
 
10765
  if (n_atoms == 0)
10774
  if (n_atoms == 0)
10766
    return;
10775
    return;
10767
  /* try
10776
  /* try */
10768
  ndl_atom = (atom_rec *)safe_malloc(n_atoms * sizeof(atom_rec));
10777
  ndl_atom = (atom_rec *)safe_malloc(n_atoms * sizeof(atom_rec));
10769
  ndl_bond = (bond_rec *)safe_malloc(n_bonds * sizeof(bond_rec));
10778
  ndl_bond = (bond_rec *)safe_malloc(n_bonds * sizeof(bond_rec));
10770
  ndl_ring = (ringpath_type *)safe_malloc(sizeof(ringlist));
10779
  ndl_ring = (ringpath_type *)safe_malloc(sizeof(ringlist));
10771
  ndl_ringprop = (ringprop_rec *)safe_malloc(sizeof(ringprop_type));
10780
  ndl_ringprop = (ringprop_rec *)safe_malloc(sizeof(ringprop_type));
10772
  /* except
10781
  /* except*/
10773
    on e:Eoutofmemory do
10782
    on e:Eoutofmemory do
10774
      begin
10783
      begin
10775
        writeln('Not enough memory');
10784
        writeln('Not enough memory');
10776
        halt(4);
10785
        halt(4);
10777
      end;
10786
      end;
10778
  end;
10787
  end;
10779
  ndl_n_atoms = n_atoms;
10788
  ndl_n_atoms = n_atoms;
10780
  ndl_n_bonds = n_bonds;
10789
  ndl_n_bonds = n_bonds;
10781
  ndl_n_rings = n_rings;
10790
  ndl_n_rings = n_rings;
10782
  ndl_n_heavyatoms = n_heavyatoms;
10791
  ndl_n_heavyatoms = n_heavyatoms;
10783
  ndl_n_heavybonds = n_heavybonds;
10792
  ndl_n_heavybonds = n_heavybonds;
10784
  strcpy(ndl_molname, molname);
10793
  strcpy(ndl_molname, molname);
10785
  ndl_n_Ctot = n_Ctot;
10794
  ndl_n_Ctot = n_Ctot;
10786
  ndl_n_Otot = n_Otot;
10795
  ndl_n_Otot = n_Otot;
10787
  ndl_n_Ntot = n_Ntot;
10796
  ndl_n_Ntot = n_Ntot;
Line 10798... Line 10807...
10798
    ndl_atom[i].Htot = atom[i].Htot;
10807
    ndl_atom[i].Htot = atom[i].Htot;
10799
    ndl_atom[i].neighbor_count = atom[i].neighbor_count;
10808
    ndl_atom[i].neighbor_count = atom[i].neighbor_count;
10800
    ndl_atom[i].ring_count = atom[i].ring_count;
10809
    ndl_atom[i].ring_count = atom[i].ring_count;
10801
    ndl_atom[i].arom = atom[i].arom;
10810
    ndl_atom[i].arom = atom[i].arom;
10802
    ndl_atom[i].stereo_care = atom[i].stereo_care;
10811
    ndl_atom[i].stereo_care = atom[i].stereo_care;
10803
    ndl_atom[i].heavy = atom[i].heavy;   /* v0.3l
10812
    ndl_atom[i].heavy = atom[i].heavy;   /* v0.3l */
10804
    ndl_atom[i].metal = atom[i].metal;   /* v0.3l
10813
    ndl_atom[i].metal = atom[i].metal;   /* v0.3l */
10805
  ndl_atom[i].tag = atom[i].tag;        /* v0.3o
10814
    ndl_atom[i].tag = atom[i].tag;      /* v0.3o */
10806
                                           }
10815
                                           }
10807
                                           if (n_bonds > 0) {
10816
                                           if (n_bonds > 0) {
10808
                                           FORLIM = n_bonds;
10817
                                           FORLIM = n_bonds;
10809
                                           for (i = 0; i < FORLIM; i++) {
10818
                                           for (i = 0; i < FORLIM; i++) {
10810
                                           ndl_bond[i].a1 = bond[i].a1;
10819
                                           ndl_bond[i].a1 = bond[i].a1;
10811
                                           ndl_bond[i].a2 = bond[i].a2;
10820
                                           ndl_bond[i].a2 = bond[i].a2;
10812
                                           ndl_bond[i].btype = bond[i].btype;
10821
                                           ndl_bond[i].btype = bond[i].btype;
10813
                                           ndl_bond[i].arom = bond[i].arom;
10822
                                           ndl_bond[i].arom = bond[i].arom;
10814
                                           ndl_bond[i].ring_count = bond[i].ring_count;   /* new in v0.3d
10823
                                           ndl_bond[i].ring_count = bond[i].ring_count;   /* new in v0.3d */
10815
                                           ndl_bond[i].topo = bond[i].topo;   /* new in v0.3d
10824
                                           ndl_bond[i].topo = bond[i].topo;   /* new in v0.3d */
10816
                                           ndl_bond[i].stereo = bond[i].stereo;   /* new in v0.3d
10825
                                           ndl_bond[i].stereo = bond[i].stereo;   /* new in v0.3d */
10817
                                           }
10826
                                           }
10818
                                           }
10827
                                           }
10819
                                           if (n_rings > 0) {
10828
                                           if (n_rings > 0) {
10820
                                           FORLIM = n_rings;
10829
                                           FORLIM = n_rings;
10821
                                           for (i = 0; i < FORLIM; i++) {
10830
                                           for (i = 0; i < FORLIM; i++) {
10822
                                           for (j = 0; j < max_ringsize; j++)
10831
                                           for (j = 0; j < max_ringsize; j++)
10823
                                           ndl_ring[i][j] = ring[i][j];
10832
                                           ndl_ring[i][j] = ring[i][j];
10824
                                           }
10833
                                           }
10825
                                           for (i = 0; i < max_rings; i++) {   /* new in v0.3
10834
                                           for (i = 0; i < max_rings; i++) {   /* new in v0.3 */
10826
                                           ndl_ringprop[i].size = ringprop[i].size;
10835
                                           ndl_ringprop[i].size = ringprop[i].size;
10827
                                           ndl_ringprop[i].arom = ringprop[i].arom;
10836
                                           ndl_ringprop[i].arom = ringprop[i].arom;
10828
                                           ndl_ringprop[i].envelope = ringprop[i].envelope;
10837
                                           ndl_ringprop[i].envelope = ringprop[i].envelope;
10829
                                           }
10838
                                           }
10830
                                           }
10839
                                           }
Line 10880... Line 10889...
10880
                                           ndl_molstat.n_rO1 = molstat.n_rO1;
10889
                                           ndl_molstat.n_rO1 = molstat.n_rO1;
10881
                                           ndl_molstat.n_rO2p = molstat.n_rO2p;
10890
                                           ndl_molstat.n_rO2p = molstat.n_rO2p;
10882
                                           ndl_molstat.n_rS = molstat.n_rS;
10891
                                           ndl_molstat.n_rS = molstat.n_rS;
10883
                                           ndl_molstat.n_rX = molstat.n_rX;
10892
                                           ndl_molstat.n_rX = molstat.n_rX;
10884
                                           ndl_molstat.n_rAr = molstat.n_rAr;
10893
                                           ndl_molstat.n_rAr = molstat.n_rAr;
10885
                                           ndl_molstat.n_rBz = molstat.n_rBz;   /* v0.3l
10894
                                           ndl_molstat.n_rBz = molstat.n_rBz;   /* v0.3l */
10886
                                           ndl_molstat.n_br2p = molstat.n_br2p;   /* v0.3n
10895
                                           ndl_molstat.n_br2p = molstat.n_br2p;   /* v0.3n */
10887
                                           /* p2c: checkmol.pas, line 7875:
10896
                                           /* p2c: checkmol.pas, line 7875:
10888
                                           * Note: Turbo Pascal conditional compilation directive was ignored [218]
10897
                                           * Note: Turbo Pascal conditional compilation directive was ignored [218] */
10889
                                           /*$IFDEF extended_molstat
10898
                                           /*$IFDEF extended_molstat
10890
                                           /* v0.3m
10899
                                            v0.3m */
10891
                                           ndl_molstat.n_psg01 = molstat.n_psg01;
10900
                                           ndl_molstat.n_psg01 = molstat.n_psg01;
10892
                                           ndl_molstat.n_psg02 = molstat.n_psg02;
10901
                                           ndl_molstat.n_psg02 = molstat.n_psg02;
10893
                                           ndl_molstat.n_psg13 = molstat.n_psg13;
10902
                                           ndl_molstat.n_psg13 = molstat.n_psg13;
10894
                                           ndl_molstat.n_psg14 = molstat.n_psg14;
10903
                                           ndl_molstat.n_psg14 = molstat.n_psg14;
10895
                                           ndl_molstat.n_psg15 = molstat.n_psg15;
10904
                                           ndl_molstat.n_psg15 = molstat.n_psg15;
10896
                                           ndl_molstat.n_psg16 = molstat.n_psg16;
10905
                                           ndl_molstat.n_psg16 = molstat.n_psg16;
10897
                                           ndl_molstat.n_psg17 = molstat.n_psg17;
10906
                                           ndl_molstat.n_psg17 = molstat.n_psg17;
10898
                                           ndl_molstat.n_psg18 = molstat.n_psg18;
10907
                                           ndl_molstat.n_psg18 = molstat.n_psg18;
10899
                                           ndl_molstat.n_pstm = molstat.n_pstm;
10908
                                           ndl_molstat.n_pstm = molstat.n_pstm;
10900
                                           ndl_molstat.n_psla = molstat.n_psla;
10909
                                           ndl_molstat.n_psla = molstat.n_psla;
10901
                                           /*$ENDIF
10910
                                           $ENDIF*/
10902
                                           /* make sure some modes can be switched on only by the query file
10911
                                           /* make sure some modes can be switched on only by the query file *M*/
10903
                                           /* and not by subsequent haystack file(s)
10912
                                           /* and not by subsequent haystack file(s) */
10904
                                           if (ez_flag)   /* new in v0.3f
10913
                                           if (ez_flag)   /* new in v0.3f */
10905
                                           ez_search = true;
10914
                                           ez_search = true;
10906
                                           if (chir_flag)   /* new in v0.3f
10915
                                           if (chir_flag)   /* new in v0.3f */
10907
                                           rs_search = true;
10916
                                           rs_search = true;
10908
                                           } */
10917
                                           }
-
 
10918
#endif
10909
 
10919
 
10910
 
10920
 
10911
static void
10921
static void
10912
copy_mol_to_needle ()
10922
copy_mol_to_needle ()
10913
{
10923
{
10914
  //int i, j, FORLIM;
10924
  //int i, j, FORLIM;
10915
 
10925
 
10916
  /*if (n_atoms == 0)
10926
  /*if (n_atoms == 0)
10917
     return; *///If a NoStruct is read, this leads to madness and illegal memory access
10927
     return; *///If a NoStruct is read, this leads to madness and illegal memory access
10918
 
10928
 
10919
 
10929
 
10920
  ndl_atom = (atom_rec *) safe_calloc (n_atoms, sizeof (atom_rec));
10930
  ndl_atom = (atom_rec *) safe_calloc (n_atoms, sizeof (atom_rec));
10921
  ndl_bond = (bond_rec *) safe_calloc (n_bonds, sizeof (bond_rec));
10931
  ndl_bond = (bond_rec *) safe_calloc (n_bonds, sizeof (bond_rec));
10922
  ndl_ring = (ringpath_type *) safe_calloc (1, sizeof (ringlist));
10932
  ndl_ring = (ringpath_type *) safe_calloc (1, sizeof (ringlist));
10923
  ndl_ringprop = (ringprop_rec *) safe_calloc (1, sizeof (ringprop_type));
10933
  ndl_ringprop = (ringprop_rec *) safe_calloc (1, sizeof (ringprop_type));
Line 10963... Line 10973...
10963
{
10973
{
10964
  //int i, j, FORLIM;
10974
  //int i, j, FORLIM;
10965
 
10975
 
10966
  /*if (n_atoms == 0)
10976
  /*if (n_atoms == 0)
10967
     return; *///If a NoStruct is read, this leads to madness and illegal memory access
10977
     return; *///If a NoStruct is read, this leads to madness and illegal memory access
10968
 
10978
 
10969
 
10979
 
10970
  tmp_atom = (atom_rec *) safe_calloc (n_atoms, sizeof (atom_rec));
10980
  tmp_atom = (atom_rec *) safe_calloc (n_atoms, sizeof (atom_rec));
10971
  tmp_bond = (bond_rec *) safe_calloc (n_bonds, sizeof (bond_rec));
10981
  tmp_bond = (bond_rec *) safe_calloc (n_bonds, sizeof (bond_rec));
10972
  tmp_ring = (ringpath_type *) safe_calloc (1, sizeof (ringlist));
10982
  tmp_ring = (ringpath_type *) safe_calloc (1, sizeof (ringlist));
10973
  tmp_ringprop = (ringprop_rec *) safe_calloc (1, sizeof (ringprop_type));
10983
  tmp_ringprop = (ringprop_rec *) safe_calloc (1, sizeof (ringprop_type));
10974
 
10984
 
10975
 
10985
 
10976
  tmp_n_atoms = n_atoms;
10986
  tmp_n_atoms = n_atoms;
10977
  tmp_n_bonds = n_bonds;
10987
  tmp_n_bonds = n_bonds;
10978
  tmp_n_rings = n_rings;
10988
  tmp_n_rings = n_rings;
10979
  tmp_n_heavyatoms = n_heavyatoms;
10989
  tmp_n_heavyatoms = n_heavyatoms;
10980
  tmp_n_heavybonds = n_heavybonds;
10990
  tmp_n_heavybonds = n_heavybonds;
Line 10989... Line 10999...
10989
 
10999
 
10990
  if (n_rings > 0)
11000
  if (n_rings > 0)
10991
    {
11001
    {
10992
      memcpy (tmp_ring, ring, sizeof (ringlist));
11002
      memcpy (tmp_ring, ring, sizeof (ringlist));
10993
      memcpy (tmp_ringprop, ringprop, sizeof (ringprop_type));
11003
      memcpy (tmp_ringprop, ringprop, sizeof (ringprop_type));
10994
    }
11004
    }
10995
 
11005
 
10996
  memcpy (&tmp_molstat, &molstat, sizeof (molstat));
11006
  memcpy (&tmp_molstat, &molstat, sizeof (molstat));
10997
 
11007
 
10998
 
11008
 
10999
  // make sure some modes can be switched on only by the query file 
11009
  // make sure some modes can be switched on only by the query file 
11000
  // and not by subsequent haystack file(s) 
11010
  // and not by subsequent haystack file(s) 
11001
  if (ez_flag)                  // new in v0.3f 
11011
  if (ez_flag)                  // new in v0.3f 
11002
    ez_search = true;
11012
    ez_search = true;
11003
 
-
 
11004
  if (chir_flag)                // new in v0.3f 
-
 
11005
    rs_search = true;
-
 
11006
 
11013
 
11007
  ndl_querymol = found_querymol;        /* 0.3p */
11014
  if (chir_flag)                // new in v0.3f 
-
 
11015
    rs_search = true;
11008
 
11016
 
11009
}
-
 
-
 
11017
  ndl_querymol = found_querymol;        /* 0.3p */
11010
 
11018
 
-
 
11019
}
-
 
11020
 
-
 
11021
#if 0
11011
/* static void copy_mol_to_tmp()
11022
static void copy_mol_to_tmp()
11012
{
11023
{
11013
  int i, j, FORLIM;
11024
  int i, j, FORLIM;
11014
 
11025
 
11015
  if (n_atoms == 0)
11026
  if (n_atoms == 0)
11016
    return;
11027
    return;
11017
  /* try
11028
  /* try */
11018
  tmp_atom = (atom_rec *)safe_malloc(n_atoms * sizeof(atom_rec));
11029
  tmp_atom = (atom_rec *)safe_malloc(n_atoms * sizeof(atom_rec));
11019
  tmp_bond = (bond_rec *)safe_malloc(n_bonds * sizeof(bond_rec));
11030
  tmp_bond = (bond_rec *)safe_malloc(n_bonds * sizeof(bond_rec));
11020
  tmp_ring = (ringpath_type *)safe_malloc(sizeof(ringlist));
11031
  tmp_ring = (ringpath_type *)safe_malloc(sizeof(ringlist));
11021
  tmp_ringprop = (ringprop_rec *)safe_malloc(sizeof(ringprop_type));
11032
  tmp_ringprop = (ringprop_rec *)safe_malloc(sizeof(ringprop_type));
11022
  /* except
11033
  /* except */
11023
    on e:Eoutofmemory do
11034
    on e:Eoutofmemory do
11024
      begin
11035
      begin
11025
        writeln('Not enough memory');
11036
        writeln('Not enough memory');
11026
        halt(4);
11037
        halt(4);
11027
      end;
11038
      end;
Line 11048... Line 11059...
11048
    tmp_atom[i].Htot = atom[i].Htot;
11059
    tmp_atom[i].Htot = atom[i].Htot;
11049
    tmp_atom[i].neighbor_count = atom[i].neighbor_count;
11060
    tmp_atom[i].neighbor_count = atom[i].neighbor_count;
11050
    tmp_atom[i].ring_count = atom[i].ring_count;
11061
    tmp_atom[i].ring_count = atom[i].ring_count;
11051
    tmp_atom[i].arom = atom[i].arom;
11062
    tmp_atom[i].arom = atom[i].arom;
11052
    tmp_atom[i].stereo_care = atom[i].stereo_care;
11063
    tmp_atom[i].stereo_care = atom[i].stereo_care;
11053
    tmp_atom[i].heavy = atom[i].heavy;   /* v0.3l
11064
    tmp_atom[i].heavy = atom[i].heavy;   /* v0.3l */
11054
    tmp_atom[i].metal = atom[i].metal;   /* v0.3l
11065
    tmp_atom[i].metal = atom[i].metal;   /* v0.3l */
11055
    tmp_atom[i].tag = atom[i].tag;   /* v0.3o
11066
    tmp_atom[i].tag = atom[i].tag;   /* v0.3o */
11056
  }
11067
  }
11057
  if (n_bonds > 0) {
11068
  if (n_bonds > 0) {
11058
    FORLIM = n_bonds;
11069
    FORLIM = n_bonds;
11059
    for (i = 0; i < FORLIM; i++) {
11070
    for (i = 0; i < FORLIM; i++) {
11060
      tmp_bond[i].a1 = bond[i].a1;
11071
      tmp_bond[i].a1 = bond[i].a1;
11061
      tmp_bond[i].a2 = bond[i].a2;
11072
      tmp_bond[i].a2 = bond[i].a2;
11062
      tmp_bond[i].btype = bond[i].btype;
11073
      tmp_bond[i].btype = bond[i].btype;
11063
      tmp_bond[i].arom = bond[i].arom;
11074
      tmp_bond[i].arom = bond[i].arom;
11064
      tmp_bond[i].ring_count = bond[i].ring_count;   /* new in v0.3d
11075
      tmp_bond[i].ring_count = bond[i].ring_count;   /* new in v0.3d */
11065
      tmp_bond[i].topo = bond[i].topo;   /* new in v0.3d
11076
      tmp_bond[i].topo = bond[i].topo;   /* new in v0.3d */
11066
      tmp_bond[i].stereo = bond[i].stereo;   /* new in v0.3d
11077
      tmp_bond[i].stereo = bond[i].stereo;   /* new in v0.3d */
11067
    }
11078
    }
11068
  }
11079
  }
11069
  if (n_rings > 0) {
11080
  if (n_rings > 0) {
11070
    FORLIM = n_rings;
11081
    FORLIM = n_rings;
11071
    for (i = 0; i < FORLIM; i++) {
11082
    for (i = 0; i < FORLIM; i++) {
11072
      for (j = 0; j < max_ringsize; j++)
11083
      for (j = 0; j < max_ringsize; j++)
11073
        tmp_ring[i][j] = ring[i][j];
11084
        tmp_ring[i][j] = ring[i][j];
11074
    }
11085
    }
11075
    for (i = 0; i < max_rings; i++) {   /* new in v0.3
11086
    for (i = 0; i < max_rings; i++) {   /* new in v0.3 */
11076
      tmp_ringprop[i].size = ringprop[i].size;
11087
      tmp_ringprop[i].size = ringprop[i].size;
11077
      tmp_ringprop[i].arom = ringprop[i].arom;
11088
      tmp_ringprop[i].arom = ringprop[i].arom;
11078
      tmp_ringprop[i].envelope = ringprop[i].envelope;
11089
      tmp_ringprop[i].envelope = ringprop[i].envelope;
11079
    }
11090
    }
11080
  }
11091
  }
Line 11130... Line 11141...
11130
  tmp_molstat.n_rO1 = molstat.n_rO1;
11141
  tmp_molstat.n_rO1 = molstat.n_rO1;
11131
  tmp_molstat.n_rO2p = molstat.n_rO2p;
11142
  tmp_molstat.n_rO2p = molstat.n_rO2p;
11132
  tmp_molstat.n_rS = molstat.n_rS;
11143
  tmp_molstat.n_rS = molstat.n_rS;
11133
  tmp_molstat.n_rX = molstat.n_rX;
11144
  tmp_molstat.n_rX = molstat.n_rX;
11134
  tmp_molstat.n_rAr = molstat.n_rAr;
11145
  tmp_molstat.n_rAr = molstat.n_rAr;
11135
  tmp_molstat.n_rBz = molstat.n_rBz;   /* v0.3l
11146
  tmp_molstat.n_rBz = molstat.n_rBz;   /* v0.3l */
11136
  tmp_molstat.n_br2p = molstat.n_br2p;   /* v0.3n
11147
  tmp_molstat.n_br2p = molstat.n_br2p;   /* v0.3n */
11137
/* p2c: checkmol.pas, line 8022:
11148
/* p2c: checkmol.pas, line 8022:
11138
 * Note: Turbo Pascal conditional compilation directive was ignored [218]
11149
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11139
  /*$IFDEF extended_molstat
11150
  /*$IFDEF extended_molstat
11140
  /* v0.3m
11151
   v0.3m
11141
  tmp_molstat.n_psg01 = molstat.n_psg01;
11152
  tmp_molstat.n_psg01 = molstat.n_psg01;
11142
  tmp_molstat.n_psg02 = molstat.n_psg02;
11153
  tmp_molstat.n_psg02 = molstat.n_psg02;
11143
  tmp_molstat.n_psg13 = molstat.n_psg13;
11154
  tmp_molstat.n_psg13 = molstat.n_psg13;
11144
  tmp_molstat.n_psg14 = molstat.n_psg14;
11155
  tmp_molstat.n_psg14 = molstat.n_psg14;
11145
  tmp_molstat.n_psg15 = molstat.n_psg15;
11156
  tmp_molstat.n_psg15 = molstat.n_psg15;
11146
  tmp_molstat.n_psg16 = molstat.n_psg16;
11157
  tmp_molstat.n_psg16 = molstat.n_psg16;
11147
  tmp_molstat.n_psg17 = molstat.n_psg17;
11158
  tmp_molstat.n_psg17 = molstat.n_psg17;
11148
  tmp_molstat.n_psg18 = molstat.n_psg18;
11159
  tmp_molstat.n_psg18 = molstat.n_psg18;
11149
  tmp_molstat.n_pstm = molstat.n_pstm;
11160
  tmp_molstat.n_pstm = molstat.n_pstm;
11150
  tmp_molstat.n_psla = molstat.n_psla;
11161
  tmp_molstat.n_psla = molstat.n_psla;
11151
  /*$ENDIF
11162
  $ENDIF*/
11152
  /* make sure some modes can be switched on only by the query file
11163
  /* make sure some modes can be switched on only by the query file */
11153
  /* and not by subsequent haystack file(s)
11164
  /* and not by subsequent haystack file(s) */
11154
  if (ez_flag)   /* new in v0.3f
11165
  if (ez_flag)   /* new in v0.3f */
11155
    ez_search = true;
11166
    ez_search = true;
11156
  if (chir_flag)   /* new in v0.3f
11167
  if (chir_flag)   /* new in v0.3f */
11157
    rs_search = true;
11168
    rs_search = true;
11158
} */
11169
}
-
 
11170
#endif
11159
 
11171
 
11160
static void
11172
static void
11161
copy_tmp_to_mol ()
11173
copy_tmp_to_mol ()
11162
{
11174
{
11163
  //int i, j, FORLIM;
11175
  //int i, j, FORLIM;
11164
 
11176
 
11165
  /*if (n_atoms == 0)
11177
  /*if (n_atoms == 0)
11166
     return; *///If a NoStruct is read, this leads to madness and illegal memory access
11178
     return; *///If a NoStruct is read, this leads to madness and illegal memory access
11167
 
11179
 
11168
 
11180
 
11169
  atom = (atom_rec *) safe_calloc (n_atoms, sizeof (atom_rec));
11181
  atom = (atom_rec *) safe_calloc (n_atoms, sizeof (atom_rec));
11170
  bond = (bond_rec *) safe_calloc (n_bonds, sizeof (bond_rec));
11182
  bond = (bond_rec *) safe_calloc (n_bonds, sizeof (bond_rec));
11171
  ring = (ringpath_type *) safe_calloc (1, sizeof (ringlist));
11183
  ring = (ringpath_type *) safe_calloc (1, sizeof (ringlist));
11172
  ringprop = (ringprop_rec *) safe_calloc (1, sizeof (ringprop_type));
11184
  ringprop = (ringprop_rec *) safe_calloc (1, sizeof (ringprop_type));
11173
 
11185
 
11174
 
11186
 
11175
  n_atoms = tmp_n_atoms;
11187
  n_atoms = tmp_n_atoms;
11176
  n_bonds = tmp_n_bonds;
11188
  n_bonds = tmp_n_bonds;
11177
  n_rings = tmp_n_rings;
11189
  n_rings = tmp_n_rings;
11178
  n_heavyatoms = tmp_n_heavyatoms;
11190
  n_heavyatoms = tmp_n_heavyatoms;
11179
  n_heavybonds = tmp_n_heavybonds;
11191
  n_heavybonds = tmp_n_heavybonds;
11180
  strcpy (molname, tmp_molname);
11192
  strcpy (molname, tmp_molname);
11181
  n_Ctot = tmp_n_Ctot;
11193
  n_Ctot = tmp_n_Ctot;
Line 11192... Line 11204...
11192
      memcpy (ringprop, tmp_ringprop, sizeof (ringprop_type));
11204
      memcpy (ringprop, tmp_ringprop, sizeof (ringprop_type));
11193
    }
11205
    }
11194
 
11206
 
11195
  memcpy (&molstat, &tmp_molstat, sizeof (tmp_molstat));
11207
  memcpy (&molstat, &tmp_molstat, sizeof (tmp_molstat));
11196
 
11208
 
11197
 
11209
 
11198
  // make sure some modes can be switched on only by the query file 
11210
  // make sure some modes can be switched on only by the query file 
11199
  // and not by subsequent haystack file(s) 
11211
  // and not by subsequent haystack file(s) 
11200
  if (ez_flag)                  // new in v0.3f 
11212
  if (ez_flag)                  // new in v0.3f 
11201
    ez_search = true;
11213
    ez_search = true;
11202
 
11214
 
11203
  if (chir_flag)                // new in v0.3f 
11215
  if (chir_flag)                // new in v0.3f 
11204
    rs_search = true;
11216
    rs_search = true;
11205
 
11217
 
11206
}
11218
}
11207
 
11219
 
-
 
11220
#if 0
11208
/*static void copy_tmp_to_mol()
11221
static void copy_tmp_to_mol()
11209
{
11222
{
11210
  int i, j, FORLIM;
11223
  int i, j, FORLIM;
11211
 
11224
 
11212
  if (tmp_n_atoms == 0)
11225
  if (tmp_n_atoms == 0)
11213
    return;
11226
    return;
Line 11218... Line 11231...
11218
  n_heavybonds = tmp_n_heavybonds;
11231
  n_heavybonds = tmp_n_heavybonds;
11219
  strcpy(molname, tmp_molname);
11232
  strcpy(molname, tmp_molname);
11220
  n_Ctot = tmp_n_Ctot;
11233
  n_Ctot = tmp_n_Ctot;
11221
  n_Otot = tmp_n_Otot;
11234
  n_Otot = tmp_n_Otot;
11222
  n_Ntot = tmp_n_Ntot;
11235
  n_Ntot = tmp_n_Ntot;
11223
  /* try
11236
  /* try */
11224
  atom = (atom_rec *)safe_malloc(n_atoms * sizeof(atom_rec));
11237
  atom = (atom_rec *)safe_malloc(n_atoms * sizeof(atom_rec));
11225
  bond = (bond_rec *)safe_malloc(n_bonds * sizeof(bond_rec));
11238
  bond = (bond_rec *)safe_malloc(n_bonds * sizeof(bond_rec));
11226
  ring = (ringpath_type *)safe_malloc(sizeof(ringlist));
11239
  ring = (ringpath_type *)safe_malloc(sizeof(ringlist));
11227
  ringprop = (ringprop_rec *)safe_malloc(sizeof(ringprop_type));
11240
  ringprop = (ringprop_rec *)safe_malloc(sizeof(ringprop_type));
11228
  FORLIM = tmp_n_atoms;
11241
  FORLIM = tmp_n_atoms;
11229
  /* except
11242
  /* except*/
11230
    on e:Eoutofmemory do
11243
    on e:Eoutofmemory do
11231
      begin
11244
      begin
11232
        writeln('Not enough memory');
11245
        writeln('Not enough memory');
11233
        halt(4);
11246
        halt(4);
11234
      end;
11247
      end;
Line 11245... Line 11258...
11245
    atom[i].Htot = tmp_atom[i].Htot;
11258
    atom[i].Htot = tmp_atom[i].Htot;
11246
    atom[i].neighbor_count = tmp_atom[i].neighbor_count;
11259
    atom[i].neighbor_count = tmp_atom[i].neighbor_count;
11247
    atom[i].ring_count = tmp_atom[i].ring_count;
11260
    atom[i].ring_count = tmp_atom[i].ring_count;
11248
    atom[i].arom = tmp_atom[i].arom;
11261
    atom[i].arom = tmp_atom[i].arom;
11249
    atom[i].stereo_care = tmp_atom[i].stereo_care;
11262
    atom[i].stereo_care = tmp_atom[i].stereo_care;
11250
    atom[i].heavy = tmp_atom[i].heavy;   /* v0.3l
11263
    atom[i].heavy = tmp_atom[i].heavy;   /* v0.3l */
11251
    atom[i].metal = tmp_atom[i].metal;   /* v0.3l
11264
    atom[i].metal = tmp_atom[i].metal;   /* v0.3l */
11252
    atom[i].tag = tmp_atom[i].tag;   /* v0.3o
11265
    atom[i].tag = tmp_atom[i].tag;   /* v0.3o */
11253
  }
11266
  }
11254
  if (tmp_n_bonds > 0) {
11267
  if (tmp_n_bonds > 0) {
11255
    FORLIM = tmp_n_bonds;
11268
    FORLIM = tmp_n_bonds;
11256
    for (i = 0; i < FORLIM; i++) {
11269
    for (i = 0; i < FORLIM; i++) {
11257
      bond[i].a1 = tmp_bond[i].a1;
11270
      bond[i].a1 = tmp_bond[i].a1;
11258
      bond[i].a2 = tmp_bond[i].a2;
11271
      bond[i].a2 = tmp_bond[i].a2;
11259
      bond[i].btype = tmp_bond[i].btype;
11272
      bond[i].btype = tmp_bond[i].btype;
11260
      bond[i].arom = tmp_bond[i].arom;
11273
      bond[i].arom = tmp_bond[i].arom;
11261
      bond[i].ring_count = tmp_bond[i].ring_count;   /* new in v0.3d
11274
      bond[i].ring_count = tmp_bond[i].ring_count;   /* new in v0.3d */
11262
      bond[i].topo = tmp_bond[i].topo;   /* new in v0.3d
11275
      bond[i].topo = tmp_bond[i].topo;   /* new in v0.3d */
11263
      bond[i].stereo = tmp_bond[i].stereo;   /* new in v0.3d
11276
      bond[i].stereo = tmp_bond[i].stereo;   /* new in v0.3d */
11264
    }
11277
    }
11265
  }
11278
  }
11266
  if (tmp_n_rings > 0) {
11279
  if (tmp_n_rings > 0) {
11267
    FORLIM = tmp_n_rings;
11280
    FORLIM = tmp_n_rings;
11268
    for (i = 0; i < FORLIM; i++) {
11281
    for (i = 0; i < FORLIM; i++) {
11269
      for (j = 0; j < max_ringsize; j++)
11282
      for (j = 0; j < max_ringsize; j++)
11270
        ring[i][j] = tmp_ring[i][j];
11283
        ring[i][j] = tmp_ring[i][j];
11271
    }
11284
    }
11272
    for (i = 0; i < max_rings; i++) {   /* new in v0.3
11285
    for (i = 0; i < max_rings; i++) {   /* new in v0.3 */
11273
      ringprop[i].size = tmp_ringprop[i].size;
11286
      ringprop[i].size = tmp_ringprop[i].size;
11274
      ringprop[i].arom = tmp_ringprop[i].arom;
11287
      ringprop[i].arom = tmp_ringprop[i].arom;
11275
      ringprop[i].envelope = tmp_ringprop[i].envelope;
11288
      ringprop[i].envelope = tmp_ringprop[i].envelope;
11276
    }
11289
    }
11277
  }
11290
  }
Line 11327... Line 11340...
11327
  molstat.n_rO1 = tmp_molstat.n_rO1;
11340
  molstat.n_rO1 = tmp_molstat.n_rO1;
11328
  molstat.n_rO2p = tmp_molstat.n_rO2p;
11341
  molstat.n_rO2p = tmp_molstat.n_rO2p;
11329
  molstat.n_rS = tmp_molstat.n_rS;
11342
  molstat.n_rS = tmp_molstat.n_rS;
11330
  molstat.n_rX = tmp_molstat.n_rX;
11343
  molstat.n_rX = tmp_molstat.n_rX;
11331
  molstat.n_rAr = tmp_molstat.n_rAr;
11344
  molstat.n_rAr = tmp_molstat.n_rAr;
11332
  molstat.n_rBz = tmp_molstat.n_rBz;   /* v0.3l
11345
  molstat.n_rBz = tmp_molstat.n_rBz;   /* v0.3l */
11333
  molstat.n_br2p = tmp_molstat.n_br2p;   /* v0.3n
11346
  molstat.n_br2p = tmp_molstat.n_br2p;   /* v0.3n */
11334
/* p2c: checkmol.pas, line 8169:
11347
/* p2c: checkmol.pas, line 8169:
11335
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11348
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11336
  /*$IFDEF extended_molstat
11349
  /*$IFDEF extended_molstat
11337
     molstat.n_psg01 = tmp_molstat.n_psg01;
11350
     molstat.n_psg01 = tmp_molstat.n_psg01;
11338
     molstat.n_psg02 = tmp_molstat.n_psg02;
11351
     molstat.n_psg02 = tmp_molstat.n_psg02;
Line 11342... Line 11355...
11342
     molstat.n_psg16 = tmp_molstat.n_psg16;
11355
     molstat.n_psg16 = tmp_molstat.n_psg16;
11343
     molstat.n_psg17 = tmp_molstat.n_psg17;
11356
     molstat.n_psg17 = tmp_molstat.n_psg17;
11344
     molstat.n_psg18 = tmp_molstat.n_psg18;
11357
     molstat.n_psg18 = tmp_molstat.n_psg18;
11345
     molstat.n_pstm = tmp_molstat.n_pstm;
11358
     molstat.n_pstm = tmp_molstat.n_pstm;
11346
     molstat.n_psla = tmp_molstat.n_psla;
11359
     molstat.n_psla = tmp_molstat.n_psla;
11347
     /*$ENDIF */
11360
     $ENDIF */
11348
  /* make sure some modes can be switched on only by the query file */
11361
  /* make sure some modes can be switched on only by the query file */
11349
  /* and not by subsequent haystack file(s)
11362
  /* and not by subsequent haystack file(s) */
11350
     if (ez_flag)
11363
     if (ez_flag)
11351
     ez_search = true;
11364
     ez_search = true;
11352
     if (chir_flag)
11365
     if (chir_flag)
11353
     rs_search = true;
11366
     rs_search = true;
11354
     } */
11367
     }
-
 
11368
#endif
11355
 
11369
 
11356
 
11370
 
11357
 
11371
 
11358
 
11372
 
11359
 
11373
 
Line 11504... Line 11518...
11504
          if (!strcmp (atype, "O3 "))
11518
          if (!strcmp (atype, "O3 "))
11505
            molstat.n_O3++;
11519
            molstat.n_O3++;
11506
          if (!strcmp (atype, "N1 "))
11520
          if (!strcmp (atype, "N1 "))
11507
            molstat.n_N1++;
11521
            molstat.n_N1++;
11508
          if (!strcmp (atype, "N2 ") || !strcmp (atype, "NAR") ||
11522
          if (!strcmp (atype, "N2 ") || !strcmp (atype, "NAR") ||
11509
              !strcmp (atype, "NAM") && atom[i].arom == true)
11523
              (!strcmp (atype, "NAM") && atom[i].arom == true))
11510
            /* v0.3n */
11524
            /* v0.3n */
11511
            molstat.n_N2++;
11525
            molstat.n_N2++;
11512
          if (!strcmp (atype, "N3 ") || !strcmp (atype, "NPL") ||
11526
          if (!strcmp (atype, "N3 ") || !strcmp (atype, "NPL") ||
11513
              !strcmp (atype, "N3+") ||
11527
              !strcmp (atype, "N3+") ||
11514
              !strcmp (atype, "NAM") && atom[i].arom == false)
11528
              (!strcmp (atype, "NAM") && atom[i].arom == false))
11515
            /* v0.3n */
11529
            /* v0.3n */
11516
            molstat.n_N3++;
11530
            molstat.n_N3++;
11517
          if (!strcmp (elem, "A "))     /* query atom */
11531
          if (!strcmp (elem, "A "))     /* query atom */
11518
            molstat.n_QA++;
11532
            molstat.n_QA++;
11519
          if (!strcmp (elem, "Q "))     /* query atom */
11533
          if (!strcmp (elem, "Q "))     /* query atom */
Line 11676... Line 11690...
11676
                molstat.n_b2++;
11690
                molstat.n_b2++;
11677
              if (btype == 'T')
11691
              if (btype == 'T')
11678
                molstat.n_b3++;
11692
                molstat.n_b3++;
11679
            }
11693
            }
11680
          /* v0.3n: ignore bonds to (explicit) hydrogens */
11694
          /* v0.3n: ignore bonds to (explicit) hydrogens */
11681
          if (!strcmp (a1el, "C ") && !strcmp (a2el, "O ") ||
11695
          if ((!strcmp (a1el, "C ") && !strcmp (a2el, "O ")) ||
11682
              !strcmp (a1el, "O ") && !strcmp (a2el, "C "))
11696
              (!strcmp (a1el, "O ") && !strcmp (a2el, "C ")))
11683
            {
11697
            {
11684
              if (btype == 'S')
11698
              if (btype == 'S')
11685
                molstat.n_C1O++;
11699
                molstat.n_C1O++;
11686
              if (btype == 'D')
11700
              if (btype == 'D')
11687
                molstat.n_C2O++;
11701
                molstat.n_C2O++;
11688
            }
11702
            }
11689
          if (!strcmp (a1el, "C ") && !strcmp (a2el, "N ") ||
11703
          if ((!strcmp (a1el, "C ") && !strcmp (a2el, "N ")) ||
11690
              !strcmp (a1el, "N ") && !strcmp (a2el, "C "))
11704
              (!strcmp (a1el, "N ") && !strcmp (a2el, "C ")))
11691
            molstat.n_CN++;
11705
            molstat.n_CN++;
11692
          if (strcmp (a1el, "C ") && atom[a1 - 1].heavy
11706
          if (strcmp (a1el, "C ") && atom[a1 - 1].heavy
11693
              && strcmp (a2el, "C ") && atom[a2 - 1].heavy)
11707
              && strcmp (a2el, "C ") && atom[a2 - 1].heavy)
11694
            molstat.n_XY++;
11708
            molstat.n_XY++;
11695
          /* new in v0.3n: number of bonds belonging to more than one ring */
11709
          /* new in v0.3n: number of bonds belonging to more than one ring */
Line 12468... Line 12482...
12468
  int ndl_btopo;                /* new in v0.3d */
12482
  int ndl_btopo;                /* new in v0.3d */
12469
  boolean res = false;
12483
  boolean res = false;
12470
/* p2c: checkmol.pas, line 8960:
12484
/* p2c: checkmol.pas, line 8960:
12471
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
12485
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
12472
  /*$IFDEF debug */
12486
  /*$IFDEF debug */
12473
  char na[256], ha[256];
12487
  /*char na[256]; char ha[256];*/
12474
  char tstr[256];
12488
  char tstr[256];
12475
 
12489
 
12476
  /*$ENDIF */
12490
  /*$ENDIF */
12477
/* p2c: checkmol.pas, line 8966:
12491
/* p2c: checkmol.pas, line 8966:
12478
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
12492
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
Line 12571... Line 12585...
12571
  int ndl_btopo;                /* new in v0.3d */
12585
  int ndl_btopo;                /* new in v0.3d */
12572
  boolean res = false;
12586
  boolean res = false;
12573
/* p2c: checkmol.pas, line 9032:
12587
/* p2c: checkmol.pas, line 9032:
12574
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
12588
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
12575
  /*$IFDEF debug */
12589
  /*$IFDEF debug */
12576
  char na[256], ha[256];
12590
  /*char na[256], ha[256];*/
12577
  char tstr[256];
12591
  char tstr[256];
12578
  /*$ENDIF */
12592
  /*$ENDIF */
12579
  int a1, a2;
12593
  int a1, a2;
12580
  str2 a1_el, a2_el;
12594
  str2 a1_el, a2_el;
12581
 
12595
 
Line 13466... Line 13480...
13466
quick_match ()
13480
quick_match ()
13467
{
13481
{
13468
  /* added in v0.2c */
13482
  /* added in v0.2c */
13469
  int i;
13483
  int i;
13470
  boolean res = true;
13484
  boolean res = true;
13471
  str3 ndl_atype;
13485
 /* str3 ndl_atype;*/
13472
  str2 ndl_el;                  /* v0.3l */
13486
  str2 ndl_el;                  /* v0.3l */
13473
  int ndl_chg;                  /* v0.3l */
13487
  int ndl_chg;                  /* v0.3l */
13474
  int ndl_rad;                  /* v0.3x */
13488
  int ndl_rad;                  /* v0.3x */
13475
  int ndl_iso;                  /* v0.3x */
13489
  int ndl_iso;                  /* v0.3x */
13476
 
13490
 
Line 13502... Line 13516...
13502
 
13516
 
13503
 
13517
 
13504
          if (opt_chg)
13518
          if (opt_chg)
13505
            {
13519
            {
13506
              if (ndl_atom[i].formal_charge != atom[i].formal_charge)
13520
              if (ndl_atom[i].formal_charge != atom[i].formal_charge)
13507
                return false;
13521
                return false;
13508
            }
13522
            }
13509
/*  else
13523
/*  else
13510
    {
13524
    {
13511
      if (ndl_atom[i].formal_charge != 0 &&
13525
      if (ndl_atom[i].formal_charge != 0 &&
13512
          atom[i].formal_charge != 0 &&
13526
          atom[i].formal_charge != 0 &&
13513
          ndl_atom[i].formal_charge != atom[i].formal_charge)
13527
          ndl_atom[i].formal_charge != atom[i].formal_charge)
13514
        return false;
13528
        return false;
Line 13620... Line 13634...
13620
                res=false;
13634
                res=false;
13621
            }    
13635
            }    
13622
        }
13636
        }
13623
    }
13637
    }
13624
/* p2c: checkmol.pas, line 9828:
13638
/* p2c: checkmol.pas, line 9828:
13625
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
13639
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
13626
  /*$IFDEF debug */
13640
  /*$IFDEF debug */
13627
  //if (res)
13641
  //if (res)
13628
  //  debugoutput (" ==> quick_match succeeded");
13642
  //  debugoutput (" ==> quick_match succeeded");
13629
  //else
13643
  //else
13630
  //  debugoutput (" ==> quick_match failed (2)");
13644
  //  debugoutput (" ==> quick_match failed (2)");
13631
  /*$ENDIF */
13645
  /*$ENDIF */
Line 13936... Line 13950...
13936
        }
13950
        }
13937
    }
13951
    }
13938
  return res;                   /* v0.3m (return true if any change was made */
13952
  return res;                   /* v0.3m (return true if any change was made */
13939
}
13953
}
13940
 
13954
 
-
 
13955
#if 0
13941
static void
13956
static void
13942
chk_wildcard_rings ()           // new in v0.3p
13957
chk_wildcard_rings ()           // new in v0.3p
13943
// checks if there are any wildcard atom types or bond types
13958
// checks if there are any wildcard atom types or bond types
13944
// in a ring of the needle; if yes ==> set the q_arom flag in the
13959
// in a ring of the needle; if yes ==> set the q_arom flag in the
13945
// atom and bond record of all ring members in order to perform the 
13960
// atom and bond record of all ring members in order to perform the 
Line 14029... Line 14044...
14029
        }
14044
        }
14030
    }
14045
    }
14031
  // some further refinement would be necessary here in order to unflag everything
14046
  // some further refinement would be necessary here in order to unflag everything
14032
  // which contains a wildcard but which definitely cannot be aromatic
14047
  // which contains a wildcard but which definitely cannot be aromatic
14033
}
14048
}
-
 
14049
#endif
14034
 
14050
 
14035
#ifndef MAKE_SHARED_LIBRARY
14051
#ifndef MAKE_SHARED_LIBRARY
14036
 
14052
 
14037
int
14053
int
14038
main (int argc, char *argv[])
14054
main (int argc, char *argv[])
Line 14079... Line 14095...
14079
 
14095
 
14080
          show_usage ();
14096
          show_usage ();
14081
          exit (2);             /* new in v0.2k */
14097
          exit (2);             /* new in v0.2k */
14082
        }
14098
        }
14083
      if (!(file_exists (ndl_molfilename)) && !opt_stdin)
14099
      if (!(file_exists (ndl_molfilename)) && !opt_stdin)
14084
        {                       /*not  fileexists(ndl_molfilename) REPLACE!!!
14100
        {                       /*not  fileexists(ndl_molfilename) REPLACE!!! */
14085
                                   printf("2");
14101
                                   printf("2");
14086
                                   /* p2c: checkmol.pas, line 10128:
14102
                                   /* p2c: checkmol.pas, line 10128:
14087
                                   * Warning: Expected an expression, found a ')' [227] */
14103
                                   * Warning: Expected an expression, found a ')' [227] */
14088
          if (strlen (ndl_molfilename) > 1 && ndl_molfilename[0] == '-')
14104
          if (strlen (ndl_molfilename) > 1 && ndl_molfilename[0] == '-')
14089
            show_usage ();
14105
            show_usage ();
Line 14147... Line 14163...
14147
         if (!found_arominfo)
14163
         if (!found_arominfo)
14148
         debugoutput
14164
         debugoutput
14149
         ("no aromaticity information found - checking myself...");
14165
         ("no aromaticity information found - checking myself...");
14150
         else
14166
         else
14151
         debugoutput ("performing full aromaticity check");
14167
         debugoutput ("performing full aromaticity check");
14152
         /* new in v0.3d */
14168
         // new in v0.3d
14153
      /*$ENDIF */
14169
      $ENDIF */
14154
      chk_ringbonds ();
14170
      chk_ringbonds ();
14155
      if (ringsearch_mode == rs_ssr)
14171
      if (ringsearch_mode == rs_ssr)
14156
        remove_redundant_rings ();
14172
        remove_redundant_rings ();
14157
      if (n_rings >= max_rings)
14173
      if (n_rings >= max_rings)
14158
        {
14174
        {
Line 14191... Line 14207...
14191
    {                           /* v0.3k */
14207
    {                           /* v0.3k */
14192
/* p2c: checkmol.pas, line 10206:
14208
/* p2c: checkmol.pas, line 10206:
14193
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
14209
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
14194
      /*$IFDEF debug
14210
      /*$IFDEF debug
14195
         debugoutput ("found aromaticity information in input file");
14211
         debugoutput ("found aromaticity information in input file");
14196
         /*$ENDIF */
14212
         $ENDIF */
14197
      if (!opt_xmdlout)
14213
      if (!opt_xmdlout)
14198
        normalize_ionic_bonds ();
14214
        normalize_ionic_bonds ();
14199
      update_atypes ();         /* added in v0.2f */
14215
      update_atypes ();         /* added in v0.2f */
14200
      update_Htotal ();         /* end v0.2b snippet */
14216
      update_Htotal ();         /* end v0.2b snippet */
14201
    }
14217
    }
Line 14288... Line 14304...
14288
                read_MDLmolfile (molfilename);
14304
                read_MDLmolfile (molfilename);
14289
              mol_count++;
14305
              mol_count++;
14290
              fpindex++;
14306
              fpindex++;
14291
              count_neighbors ();
14307
              count_neighbors ();
14292
              /*if (not mol_OK) or (n_atoms < 1) then writeln(mol_count,':no valid structure found') else */
14308
              /*if (not mol_OK) or (n_atoms < 1) then writeln(mol_count,':no valid structure found') else */
14293
              if (!mol_OK || n_atoms < 1
14309
              if (!mol_OK || (n_atoms < 1
14294
                  && !(opt_fp && fpformat == fpf_decimal))
14310
                  && !(opt_fp && fpformat == fpf_decimal)))
14295
                printf ("%i:F\n", mol_count);
14311
                printf ("%i:F\n", mol_count);
14296
              else
14312
              else
14297
                {
14313
                {
14298
                  if (opt_exact
14314
                  if (opt_exact
14299
                      && (n_Ctot != ndl_n_Ctot || n_Otot != ndl_n_Otot
14315
                      && (n_Ctot != ndl_n_Ctot || n_Otot != ndl_n_Otot
Line 14302... Line 14318...
14302
                      if (!opt_molout && !(opt_fp && fpformat == fpf_decimal))
14318
                      if (!opt_molout && !(opt_fp && fpformat == fpf_decimal))
14303
                        printf ("%i:F\n", mol_count);
14319
                        printf ("%i:F\n", mol_count);
14304
                    }
14320
                    }
14305
                  else
14321
                  else
14306
                    {
14322
                    {
14307
                      if (!found_arominfo || opt_strict && tmfmismatch)
14323
                      if (!found_arominfo || (opt_strict && tmfmismatch))
14308
                        {       /* added in v0.3m */
14324
                        {       /* added in v0.3m */
14309
/* p2c: checkmol.pas, line 10294:
14325
/* p2c: checkmol.pas, line 10294:
14310
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
14326
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
14311
                          /*$IFDEF debug
14327
                          /*$IFDEF debug
14312
                             debugoutput
14328
                             debugoutput
14313
                             ("no aromaticity information found (or tweak mismatch) - checking myself...");
14329
                             ("no aromaticity information found (or tweak mismatch) - checking myself...");
14314
                             /*$ENDIF */
14330
                            *$ENDIF */
14315
                          chk_ringbonds ();
14331
                          chk_ringbonds ();
14316
                          if (ringsearch_mode == rs_ssr)
14332
                          if (ringsearch_mode == rs_ssr)
14317
                            remove_redundant_rings ();
14333
                            remove_redundant_rings ();
14318
                          if (n_rings == max_rings)
14334
                          if (n_rings == max_rings)
14319
                            {
14335
                            {
Line 14347... Line 14363...
14347
/* p2c: checkmol.pas, line 10322:
14363
/* p2c: checkmol.pas, line 10322:
14348
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
14364
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
14349
                          /*$IFDEF debug
14365
                          /*$IFDEF debug
14350
                             debugoutput
14366
                             debugoutput
14351
                             ("found aromaticity information in input file");
14367
                             ("found aromaticity information in input file");
14352
                             /*$ENDIF */
14368
                             $ENDIF */
14353
                          if (opt_strict)
14369
                          if (opt_strict)
14354
                            update_atypes ();
14370
                            update_atypes ();
14355
                          update_Htotal ();
14371
                          update_Htotal ();
14356
                        }
14372
                        }
14357
                      init_molstat (&ndl_molstat);
14373
                      init_molstat (&ndl_molstat);
Line 14442... Line 14458...
14442
                            }
14458
                            }
14443
                        }
14459
                        }
14444
                      else
14460
                      else
14445
                        {
14461
                        {
14446
                          if (!
14462
                          if (!
14447
                              (opt_molout || opt_fp
14463
                              (opt_molout || (opt_fp
14448
                               && fpformat == fpf_decimal))
14464
                               && fpformat == fpf_decimal)))
14449
                            /* inttostr(mol_count), REPLACE!!! */
14465
                            /* inttostr(mol_count), REPLACE!!! */
14450
                            printf ("%i:F\n", mol_count);
14466
                            printf ("%i:F\n", mol_count);
14451
                        }
14467
                        }
14452
                      if (opt_fp && fpformat == fpf_decimal
14468
                      if (opt_fp && fpformat == fpf_decimal
14453
                          && fpindex == fp_blocksize)
14469
                          && fpindex == fp_blocksize)
Line 14558... Line 14574...
14558
  fp_exactblock = false;        /* v0.3m */
14574
  fp_exactblock = false;        /* v0.3m */
14559
  tmfcode = 0;                  /* v0.3m */
14575
  tmfcode = 0;                  /* v0.3m */
14560
  tmfmismatch = false;          /* v0.3m */
14576
  tmfmismatch = false;          /* v0.3m */
14561
  auto_ssr = false;
14577
  auto_ssr = false;
14562
  recursion_depth = 0;
14578
  recursion_depth = 0;
14563
}
14579
}
14564
 
14580
 
14565
static void
14581
static void
14566
mm_init_mol (void)
14582
mm_init_mol (void)
14567
{
14583
{
14568
 
14584
 
Line 14616... Line 14632...
14616
  if (strcmp (filetype, "sybyl") == 0)
14632
  if (strcmp (filetype, "sybyl") == 0)
14617
    read_mol2file (ndl_molfilename);
14633
    read_mol2file (ndl_molfilename);
14618
  if (strcmp (filetype, "mdl") == 0)
14634
  if (strcmp (filetype, "mdl") == 0)
14619
    read_MDLmolfile (ndl_molfilename);
14635
    read_MDLmolfile (ndl_molfilename);
14620
  if (checkmol_mode)
14636
  if (checkmol_mode)
14621
    {
14637
    {
14622
      if (found_querymol)
14638
      if (found_querymol)
14623
        {
14639
        {
14624
          printf
14640
          printf
14625
            ("Warning: Input structure contains query atom or query bond.\n");
14641
            ("Warning: Input structure contains query atom or query bond.\n");
14626
        }
14642
        }
Line 14674... Line 14690...
14674
    }
14690
    }
14675
 
14691
 
14676
 
14692
 
14677
 
14693
 
14678
//printf("mm_elab_mol\n");
14694
//printf("mm_elab_mol\n");
14679
}
14695
}
14680
 
14696
 
14681
DLLEXPORT void
14697
DLLEXPORT void
14682
mm_set_current_mol_as_query (void)
14698
mm_set_current_mol_as_query (void)
14683
{
14699
{
14684
//printf("mm_set_current_mol_as_query\n");
14700
//printf("mm_set_current_mol_as_query\n");
Line 14692... Line 14708...
14692
  else if (!ez_flag && ez_search)
14708
  else if (!ez_flag && ez_search)
14693
    ez_search = false;          //chir_flag initialized in read_MDLmolfile, otherwise we lose that info
14709
    ez_search = false;          //chir_flag initialized in read_MDLmolfile, otherwise we lose that info
14694
  if (opt_chiral)
14710
  if (opt_chiral)
14695
    {                           /* v0.3f */
14711
    {                           /* v0.3f */
14696
      rs_search = true;
14712
      rs_search = true;
14697
 
14713
 
14698
      //printf("%i\n",rs_search);
14714
      //printf("%i\n",rs_search);
14699
    }
14715
    }
14700
  else if (!chir_flag && rs_search)
14716
  else if (!chir_flag && rs_search)
14701
    {
14717
    {
14702
      rs_search = false;        //chir_flag initialized in read_MDLmolfile, otherwise we lose that info
14718
      rs_search = false;        //chir_flag initialized in read_MDLmolfile, otherwise we lose that info
14703
      //printf("%i\n",rs_search);
14719
      //printf("%i\n",rs_search);
14704
    }
14720
    }
14705
  if (opt_chiral && opt_strict && opt_exact)    /* new in v0.3j */
14721
  if (opt_chiral && opt_strict && opt_exact)    /* new in v0.3j */
14706
    rs_strict = true;
14722
    rs_strict = true;
14707
  else
14723
  else
14708
    rs_strict = false;
14724
    rs_strict = false;
14709
  /* if (rs_strict)              /* v0.3j
14725
  /* if (rs_strict)              // v0.3j
14710
     ndl_ref_atom = find_ndl_ref_atom_cv ();
14726
     ndl_ref_atom = find_ndl_ref_atom_cv ();
14711
     //ndl_ref_atom = find_ndl_ref_atom ();
14727
     //ndl_ref_atom = find_ndl_ref_atom ();
14712
     else
14728
     else
14713
     ndl_ref_atom = find_ndl_ref_atom (); */
14729
     ndl_ref_atom = find_ndl_ref_atom (); */
14714
 
14730
 
14715
 
14731
 
14716
 
14732
 
14717
  molbufindex = 0;
14733
  molbufindex = 0;
14718
  mol_count = 0;
14734
  mol_count = 0;
14719
//printf("mm_set_current_mol_as_query\n");
14735
/*printf("mm_set_current_mol_as_query\n");*/
14720
}
14736
}
14721
 
14737
 
14722
DLLEXPORT int
14738
DLLEXPORT int
14723
mm_get_rings (void)
14739
mm_get_rings (void)
14724
{
14740
{