Subversion Repositories wimsdev

Rev

Rev 17891 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 17891 Rev 18544
Line 581... Line 581...
581
#define fg_heterocycle  202
581
#define fg_heterocycle  202
582
#define fg_alpha_aminoacid  203
582
#define fg_alpha_aminoacid  203
583
#define fg_alpha_hydroxyacid  204
583
#define fg_alpha_hydroxyacid  204
584
 
584
 
585
typedef enum
585
typedef enum
586
  { false = 0, true } boolean;
586
  { isfalse = 0, istrue } boolean;
587
 
587
 
588
typedef char str2[3];
588
typedef char str2[3];
589
 
589
 
590
typedef char str3[4];
590
typedef char str3[4];
591
 
591
 
Line 703... Line 703...
703
} p_3d;
703
} p_3d;
704
 
704
 
705
typedef int chirpath_type[4];  /* new in v0.3f */
705
typedef int chirpath_type[4];  /* new in v0.3f */
706
 
706
 
707
#ifdef MAKE_SHARED_LIBRARY
707
#ifdef MAKE_SHARED_LIBRARY
708
static boolean yet_initialized = false;
708
static boolean yet_initialized = isfalse;
709
#endif
709
#endif
710
 
710
 
711
typedef struct connval_rec
711
typedef struct connval_rec
712
{
712
{
713
  /* new in v0.3j */
713
  /* new in v0.3j */
Line 834... Line 834...
834
static boolean
834
static boolean
835
file_exists (const char *fileName)
835
file_exists (const char *fileName)
836
{
836
{
837
  struct stat filestat;
837
  struct stat filestat;
838
 
838
 
839
  return stat (fileName, &filestat) == 0 ? true : false;
839
  return stat (fileName, &filestat) == 0 ? istrue : isfalse;
840
}
840
}
841
 
841
 
842
static void lblank (int cols, char *nstr)
842
static void lblank (int cols, char *nstr)
843
{
843
{
844
  /* inserts leading blanks up to a given number of total characters */
844
  /* inserts leading blanks up to a given number of total characters */
Line 931... Line 931...
931
 
931
 
932
static void init_globals ()
932
static void init_globals ()
933
{
933
{
934
  /*int i;*/
934
  /*int i;*/
935
 
935
 
936
  opt_verbose = false;
936
  opt_verbose = isfalse;
937
  opt_debug = false;
937
  opt_debug = isfalse;
938
  opt_exact = false;
938
  opt_exact = isfalse;
939
  opt_stdin = false;
939
  opt_stdin = isfalse;
940
  opt_text = false;
940
  opt_text = isfalse;
941
  opt_code = false;
941
  opt_code = isfalse;
942
  opt_bin = false;
942
  opt_bin = isfalse;
943
  opt_bitstring = false;
943
  opt_bitstring = isfalse;
944
  opt_molout = false;
944
  opt_molout = isfalse;
945
  opt_molstat = false;
945
  opt_molstat = isfalse;
946
  opt_molstat_X = false;
946
  opt_molstat_X = isfalse;
947
  opt_xmdlout = false;
947
  opt_xmdlout = isfalse;
948
  opt_strict = false; /* new in v0.2f */
948
  opt_strict = isfalse; /* new in v0.2f */
949
  opt_metalrings = false;  /* new in v0.3 */
949
  opt_metalrings = isfalse;  /* new in v0.3 */
950
  opt_geom = false;   /* new in v0.3d */
950
  opt_geom = isfalse;   /* new in v0.3d */
951
  opt_chiral = false; /* new in v0.3f */
951
  opt_chiral = isfalse; /* new in v0.3f */
952
  opt_fp = false;     /* new in v0.3m */
952
  opt_fp = isfalse;     /* new in v0.3m */
953
  opt_iso = false;    /* new in v0.3x */
953
  opt_iso = isfalse;    /* new in v0.3x */
954
  opt_chg = false;    /* new in v0.3x */
954
  opt_chg = isfalse;    /* new in v0.3x */
955
  opt_rad = false;    /* new in v0.3x */
955
  opt_rad = isfalse;    /* new in v0.3x */
956
  /*cm_mdlmolfile   := false; */
956
  /*cm_mdlmolfile   := isfalse; */
957
  found_arominfo = false;
957
  found_arominfo = isfalse;
958
  found_querymol = false;
958
  found_querymol = isfalse;
959
  ndl_querymol = false;
959
  ndl_querymol = isfalse;
960
  opt_rs = rs_sar;    /* v0.3i */
960
  opt_rs = rs_sar;    /* v0.3i */
961
  /*ringsearch_mode := rs_sar; */
961
  /*ringsearch_mode := rs_sar; */
962
  rfile_is_open = false;/* new in v0.2g */
962
  rfile_is_open = isfalse;/* new in v0.2g */
963
  ez_search = false;    /* new in v0.3d */
963
  ez_search = isfalse;    /* new in v0.3d */
964
  rs_search = false;    /* new in v0.3f */
964
  rs_search = isfalse;    /* new in v0.3f */
965
  ez_flag = false;      /* new in v0.3f */
965
  ez_flag = isfalse;      /* new in v0.3f */
966
  chir_flag = false;    /* new in v0.3f */
966
  chir_flag = isfalse;    /* new in v0.3f */
967
  rs_strict = false;    /* new in v0.3j */
967
  rs_strict = isfalse;    /* new in v0.3j */
968
  n_Ctot = 0;
968
  n_Ctot = 0;
969
  n_Otot = 0;
969
  n_Otot = 0;
970
  n_Ntot = 0;      /* new in v0.3g */
970
  n_Ntot = 0;      /* new in v0.3g */
971
  ndl_n_Ctot = 0;
971
  ndl_n_Ctot = 0;
972
  ndl_n_Otot = 0;
972
  ndl_n_Otot = 0;
973
  ndl_n_Ntot = 0;   /* new in v0.3g */
973
  ndl_n_Ntot = 0;   /* new in v0.3g */
974
  //for (i = 0; i < max_fg; i++)
974
  //for (i = 0; i < max_fg; i++)
975
  //  fg[i] = false;
975
  //  fg[i] = isfalse;
976
  memset (fg, 0, sizeof (fglist));
976
  memset (fg, 0, sizeof (fglist));
977
  /*try */
977
  /*try */
978
  molbuf = safe_malloc (sizeof (molbuftype));
978
  molbuf = safe_malloc (sizeof (molbuftype));
979
  /*except
979
  /*except
980
     on e:Eoutofmemory do
980
     on e:Eoutofmemory do
981
     begin
981
     begin
982
     writeln('Not enough memory');
982
     writeln('Not enough memory');
983
     halt(4);
983
     halt(4);
984
     end;
984
     end;
985
     end; */
985
     end; */
986
  ether_generic = false;  /* v0.3j */
986
  ether_generic = isfalse;  /* v0.3j */
987
  amine_generic = false;  /* v0.3j */
987
  amine_generic = isfalse;  /* v0.3j */
988
  hydroxy_generic = false;/* v0.3j */
988
  hydroxy_generic = isfalse;/* v0.3j */
989
  fpformat = fpf_decimal; /* v0.3m */
989
  fpformat = fpf_decimal; /* v0.3m */
990
  fpindex = 0;            /* v0.3m */
990
  fpindex = 0;            /* v0.3m */
991
  fp_exacthit = false;    /* v0.3m */
991
  fp_exacthit = isfalse;    /* v0.3m */
992
  fp_exactblock = false;  /* v0.3m */
992
  fp_exactblock = isfalse;  /* v0.3m */
993
  tmfcode = 0;            /* v0.3m */
993
  tmfcode = 0;            /* v0.3m */
994
  tmfmismatch = false;    /* v0.3m */
994
  tmfmismatch = isfalse;    /* v0.3m */
995
  auto_ssr = false;       /* v0.3n */
995
  auto_ssr = isfalse;       /* v0.3n */
996
  recursion_depth = 0;
996
  recursion_depth = 0;
997
}
997
}
998
 
998
 
999
static inline void init_molstat (molstat_rec *mstat)
999
static inline void init_molstat (molstat_rec *mstat)
1000
{
1000
{
Line 1094... Line 1094...
1094
  int i, FORLIM;
1094
  int i, FORLIM;
1095
 
1095
 
1096
  if (n_atoms > 0) {
1096
  if (n_atoms > 0) {
1097
    FORLIM = n_atoms;
1097
    FORLIM = n_atoms;
1098
    for (i = 0; i < FORLIM; i++)
1098
    for (i = 0; i < FORLIM; i++)
1099
      atom[i].tag = false;
1099
      atom[i].tag = isfalse;
1100
  }
1100
  }
1101
}
1101
}
1102
 
1102
 
1103
#if 0
1103
#if 0
1104
static void set_atom_tags ()
1104
static void set_atom_tags ()
Line 1106... Line 1106...
1106
  int i, FORLIM;
1106
  int i, FORLIM;
1107
 
1107
 
1108
  if (n_atoms > 0){
1108
  if (n_atoms > 0){
1109
    FORLIM = n_atoms;
1109
    FORLIM = n_atoms;
1110
    for (i = 0; i < FORLIM; i++)
1110
    for (i = 0; i < FORLIM; i++)
1111
      atom[i].tag = true;
1111
      atom[i].tag = istrue;
1112
  }
1112
  }
1113
}
1113
}
1114
#endif
1114
#endif
1115
static void order_ringpath (int *r_path)
1115
static void order_ringpath (int *r_path)
1116
{
1116
{
Line 1167... Line 1167...
1167
{
1167
{
1168
  int i;
1168
  int i;
1169
 
1169
 
1170
  if (ndl_n_atoms > 0){
1170
  if (ndl_n_atoms > 0){
1171
    for (i = 0; i < ndl_n_atoms; i++)
1171
    for (i = 0; i < ndl_n_atoms; i++)
1172
      ndl_atom[i].tag = false;
1172
      ndl_atom[i].tag = isfalse;
1173
  }
1173
  }
1174
}
1174
}
1175
 
1175
 
1176
static void set_ndl_atom_tags ()
1176
static void set_ndl_atom_tags ()
1177
{
1177
{
1178
  int i;
1178
  int i;
1179
 
1179
 
1180
  if (ndl_n_atoms > 0){
1180
  if (ndl_n_atoms > 0){
1181
    for (i = 0; i < ndl_n_atoms; i++)
1181
    for (i = 0; i < ndl_n_atoms; i++)
1182
     ndl_atom[i].tag = true;
1182
     ndl_atom[i].tag = istrue;
1183
  }
1183
  }
1184
}
1184
}
1185
 
1185
 
1186
static int count_tagged_ndl_heavyatoms ()
1186
static int count_tagged_ndl_heavyatoms ()
1187
{
1187
{
Line 1216... Line 1216...
1216
var                         (* just a simple, distance-based estimation
1216
var                         (* just a simple, distance-based estimation
1217
  total_dist  : double;     (* instead of calculating the dihedral angle
1217
  total_dist  : double;     (* instead of calculating the dihedral angle
1218
  direct_dist : double;
1218
  direct_dist : double;
1219
  res         : boolean;
1219
  res         : boolean;
1220
begin
1220
begin
1221
  res := false;
1221
  res := isfalse;
1222
  total_dist  := dist3d(p1,p2) + dist3d(p2,p3) + dist3d(p3,p4);
1222
  total_dist  := dist3d(p1,p2) + dist3d(p2,p3) + dist3d(p3,p4);
1223
  direct_dist := dist3d(p1,p4);
1223
  direct_dist := dist3d(p1,p4);
1224
  if (direct_dist < 0.78 * total_dist) then res := true;  (* cutoff value of 0.78 was
1224
  if (direct_dist < 0.78 * total_dist) then res := istrue;  (* cutoff value of 0.78 was
1225
  is_cis := res;                                          (* experimentally determined
1225
  is_cis := res;                                          (* experimentally determined
1226
end;
1226
end;
1227
*/
1227
*/
1228
/* function is_cis was replaced by a new one in v0.3h */
1228
/* function is_cis was replaced by a new one in v0.3h */
1229
 
1229
 
Line 1391... Line 1391...
1391
 
1391
 
1392
static boolean is_cis (p_3d p1, p_3d p2, p_3d p3, p_3d p4)
1392
static boolean is_cis (p_3d p1, p_3d p2, p_3d p3, p_3d p4)
1393
{
1393
{
1394
  /* new in v0.3h, uses the dihedral angle */
1394
  /* new in v0.3h, uses the dihedral angle */
1395
  double phi;
1395
  double phi;
1396
  boolean res = false;
1396
  boolean res = isfalse;
1397
 
1397
 
1398
  phi = torsion (p1, p2, p3, p4);
1398
  phi = torsion (p1, p2, p3, p4);
1399
  if (fabs (phi) < M_PI / 2)
1399
  if (fabs (phi) < M_PI / 2)
1400
    res = true;
1400
    res = istrue;
1401
  return res;
1401
  return res;
1402
}
1402
}
1403
 
1403
 
1404
/*====================== end of geometry functions ========================== */
1404
/*====================== end of geometry functions ========================== */
1405
 
1405
 
Line 1543... Line 1543...
1543
  char parstr[256];
1543
  char parstr[256];
1544
  char tmpstr[256];
1544
  char tmpstr[256];
1545
  int l;
1545
  int l;
1546
 
1546
 
1547
  *tmpstr = '\0';
1547
  *tmpstr = '\0';
1548
  opt_none = true;
1548
  opt_none = istrue;
1549
  if (progmode == pmCheckMol) {
1549
  if (progmode == pmCheckMol) {
1550
    for (p = 1; p < P_argc; p++) {
1550
    for (p = 1; p < P_argc; p++) {
1551
      strcpy(parstr, P_argv[p]);
1551
      strcpy(parstr, P_argv[p]);
1552
      if (!strcmp(parstr, "-l")) {   /* new in v0.3l */
1552
      if (!strcmp(parstr, "-l")) {   /* new in v0.3l */
1553
        list_molstat_codes();
1553
        list_molstat_codes();
Line 1568... Line 1568...
1568
            l++;
1568
            l++;
1569
          if (strlen(tmpstr) > l + 2) {
1569
          if (strlen(tmpstr) > l + 2) {
1570
            show_usage();
1570
            show_usage();
1571
            _Escape(1);
1571
            _Escape(1);
1572
          }
1572
          }
1573
          opt_none = false;
1573
          opt_none = isfalse;
1574
          if (strpos2(tmpstr, "M", 1) > 0)
1574
          if (strpos2(tmpstr, "M", 1) > 0)
1575
            opt_metalrings = true;
1575
            opt_metalrings = istrue;
1576
          if (strpos2(tmpstr, "v", 1) > 0)
1576
          if (strpos2(tmpstr, "v", 1) > 0)
1577
            opt_verbose = true;
1577
            opt_verbose = istrue;
1578
            /* p2c: checkmol.pas, line 1261:
1578
            /* p2c: checkmol.pas, line 1261:
1579
            * Note: Turbo Pascal conditional compilation directive was ignored [218] */
1579
            * Note: Turbo Pascal conditional compilation directive was ignored [218] */
1580
            /*$IFDEF debug
1580
            /*$IFDEF debug
1581
            if (strpos2(tmpstr, "D", 1) > 0)
1581
            if (strpos2(tmpstr, "D", 1) > 0)
1582
              opt_debug = true;
1582
              opt_debug = istrue;
1583
            $ENDIF*/
1583
            $ENDIF*/
1584
          if (strpos2(tmpstr, "e", 1) > 0)
1584
          if (strpos2(tmpstr, "e", 1) > 0)
1585
            opt_text = true;
1585
            opt_text = istrue;
1586
          else {
1586
          else {
1587
            if (strpos2(tmpstr, "d", 1) > 0)
1587
            if (strpos2(tmpstr, "d", 1) > 0)
1588
              opt_text_de = true;
1588
              opt_text_de = istrue;
1589
            else {
1589
            else {
1590
              if (strpos2(tmpstr, "c", 1) > 0)
1590
              if (strpos2(tmpstr, "c", 1) > 0)
1591
                opt_code = true;
1591
                opt_code = istrue;
1592
              else {
1592
              else {
1593
                if (strpos2(tmpstr, "b", 1) > 0)
1593
                if (strpos2(tmpstr, "b", 1) > 0)
1594
                  opt_bin = true;
1594
                  opt_bin = istrue;
1595
                else {
1595
                else {
1596
                  if (strpos2(tmpstr, "s", 1) > 0)
1596
                  if (strpos2(tmpstr, "s", 1) > 0)
1597
                    opt_bitstring = true;
1597
                    opt_bitstring = istrue;
1598
                }
1598
                }
1599
              }
1599
              }
1600
            }
1600
            }
1601
            if (strpos2(tmpstr, "x", 1) > 0)
1601
            if (strpos2(tmpstr, "x", 1) > 0)
1602
              opt_molstat = true;
1602
              opt_molstat = istrue;
1603
            if (strpos2(tmpstr, "r", 1) > 0)
1603
            if (strpos2(tmpstr, "r", 1) > 0)
1604
              opt_rs = rs_ssr;
1604
              opt_rs = rs_ssr;
1605
            if (strpos2(tmpstr, "X", 1) > 0) {
1605
            if (strpos2(tmpstr, "X", 1) > 0) {
1606
              opt_molstat = true;
1606
              opt_molstat = istrue;
1607
              opt_molstat_X = true;
1607
              opt_molstat_X = istrue;
1608
            }
1608
            }
1609
            if (strpos2(tmpstr, "m", 1) > 0) {
1609
            if (strpos2(tmpstr, "m", 1) > 0) {
1610
              opt_text = false;
1610
              opt_text = isfalse;
1611
              opt_text_de = false;
1611
              opt_text_de = isfalse;
1612
              opt_bin = false;
1612
              opt_bin = isfalse;
1613
              opt_bitstring = false;
1613
              opt_bitstring = isfalse;
1614
              opt_code = false;
1614
              opt_code = isfalse;
1615
              opt_molstat = false;
1615
              opt_molstat = isfalse;
1616
              opt_xmdlout = true;
1616
              opt_xmdlout = istrue;
1617
                  }
1617
                  }
1618
          }
1618
          }
1619
        strcpy(molfilename, tmpstr);
1619
        strcpy(molfilename, tmpstr);
1620
      }
1620
      }
1621
    } else {
1621
    } else {
1622
      if (strpos2(parstr, "-", 1) == 1) {
1622
      if (strpos2(parstr, "-", 1) == 1) {
1623
        if (strlen(parstr) > 1) {
1623
        if (strlen(parstr) > 1) {
1624
          show_usage();
1624
          show_usage();
1625
          _Escape(1);
1625
          _Escape(1);
1626
        }
1626
        }
1627
        opt_stdin = true;
1627
        opt_stdin = istrue;
1628
      } else {
1628
      } else {
1629
      opt_stdin = false;
1629
      opt_stdin = isfalse;
1630
      strcpy(molfilename, parstr);
1630
      strcpy(molfilename, parstr);
1631
      }
1631
      }
1632
        }
1632
        }
1633
    }
1633
    }
1634
    if (opt_text == false && opt_text_de == false && opt_code == false &&
1634
    if (opt_text == isfalse && opt_text_de == isfalse && opt_code == isfalse &&
1635
        opt_bin == false && opt_bitstring == false && opt_molstat == false &&
1635
        opt_bin == isfalse && opt_bitstring == isfalse && opt_molstat == isfalse &&
1636
        opt_molstat_X == false && opt_xmdlout == false)
1636
        opt_molstat_X == isfalse && opt_xmdlout == isfalse)
1637
      opt_none = true;
1637
      opt_none = istrue;
1638
  }
1638
  }
1639
  if (progmode == pmMatchMol) {
1639
  if (progmode == pmMatchMol) {
1640
    *ndl_molfilename = '\0';
1640
    *ndl_molfilename = '\0';
1641
    *molfilename = '\0';
1641
    *molfilename = '\0';
1642
    for (p = 1; p < P_argc; p++) {
1642
    for (p = 1; p < P_argc; p++) {
1643
        strcpy(parstr, P_argv[p]);
1643
        strcpy(parstr, P_argv[p]);
1644
      if (p == 1) {
1644
      if (p == 1) {
1645
        if (strpos2(parstr, "-", 1) == 1) {
1645
        if (strpos2(parstr, "-", 1) == 1) {
1646
          if (strpos2(parstr, "v", 1) > 1)
1646
          if (strpos2(parstr, "v", 1) > 1)
1647
            opt_verbose = true;
1647
            opt_verbose = istrue;
1648
            /* p2c: checkmol.pas, line 1329:
1648
            /* p2c: checkmol.pas, line 1329:
1649
             * Note: Turbo Pascal conditional compilation directive was ignored [218] */
1649
             * Note: Turbo Pascal conditional compilation directive was ignored [218] */
1650
            /*$IFDEF debug
1650
            /*$IFDEF debug
1651
                if (strpos2(parstr, "D", 1) > 1)
1651
                if (strpos2(parstr, "D", 1) > 1)
1652
                  opt_debug = true;
1652
                  opt_debug = istrue;
1653
               $ENDIF*/
1653
               $ENDIF*/
1654
          if (strpos2(parstr, "x", 1) > 1)
1654
          if (strpos2(parstr, "x", 1) > 1)
1655
            opt_exact = true;
1655
            opt_exact = istrue;
1656
          if (strpos2(parstr, "s", 1) > 1)   /* new in v0.2f */
1656
          if (strpos2(parstr, "s", 1) > 1)   /* new in v0.2f */
1657
            opt_strict = true;
1657
            opt_strict = istrue;
1658
          if (strpos2(parstr, "m", 1) > 1)
1658
          if (strpos2(parstr, "m", 1) > 1)
1659
           opt_molout = true;
1659
           opt_molout = istrue;
1660
          if (strpos2(parstr, "r", 1) > 1)
1660
          if (strpos2(parstr, "r", 1) > 1)
1661
            opt_rs = rs_ssr;
1661
            opt_rs = rs_ssr;
1662
          if (strpos2(parstr, "M", 1) > 0)   /* new in v0.3 */
1662
          if (strpos2(parstr, "M", 1) > 0)   /* new in v0.3 */
1663
            opt_metalrings = true;
1663
            opt_metalrings = istrue;
1664
          if (strpos2(parstr, "g", 1) > 0)   /* new in v0.3d */
1664
          if (strpos2(parstr, "g", 1) > 0)   /* new in v0.3d */
1665
            opt_geom = true;
1665
            opt_geom = istrue;
1666
          if (strpos2(parstr, "G", 1) > 0)   /* new in v0.3f */
1666
          if (strpos2(parstr, "G", 1) > 0)   /* new in v0.3f */
1667
            opt_chiral = true;
1667
            opt_chiral = istrue;
1668
          if (strpos2(parstr, "f", 1) > 0) {   /* new in v0.3m */
1668
          if (strpos2(parstr, "f", 1) > 0) {   /* new in v0.3m */
1669
            opt_fp = true;
1669
            opt_fp = istrue;
1670
          fpformat = fpf_boolean;
1670
          fpformat = fpf_boolean;
1671
        }
1671
        }
1672
        if (strpos2(parstr, "F", 1) > 0) {   /* new in v0.3m */
1672
        if (strpos2(parstr, "F", 1) > 0) {   /* new in v0.3m */
1673
          opt_fp = true;
1673
          opt_fp = istrue;
1674
          fpformat = fpf_decimal;
1674
          fpformat = fpf_decimal;
1675
        }
1675
        }
1676
        if (strpos2(parstr, "h", 1) > 1) {
1676
        if (strpos2(parstr, "h", 1) > 1) {
1677
          show_usage();
1677
          show_usage();
1678
          _Escape(0);
1678
          _Escape(0);
Line 1686... Line 1686...
1686
    }
1686
    }
1687
    if (p == P_argc - 1) {
1687
    if (p == P_argc - 1) {
1688
      if (strcmp(parstr, "-"))
1688
      if (strcmp(parstr, "-"))
1689
        strcpy(molfilename, parstr);
1689
        strcpy(molfilename, parstr);
1690
      else
1690
      else
1691
        opt_stdin = true;
1691
        opt_stdin = istrue;
1692
      }
1692
      }
1693
    }
1693
    }
1694
    if (opt_geom)   /* v0.3d */
1694
    if (opt_geom)   /* v0.3d */
1695
      ez_search = true;
1695
      ez_search = istrue;
1696
    if (opt_chiral)   /* v0.3f */
1696
    if (opt_chiral)   /* v0.3f */
1697
      rs_search = true;
1697
      rs_search = istrue;
1698
    if (opt_chiral && opt_strict && (opt_exact || opt_fp))
1698
    if (opt_chiral && opt_strict && (opt_exact || opt_fp))
1699
        /* new in v0.3j, v0.3m */
1699
        /* new in v0.3j, v0.3m */
1700
      rs_strict = true;
1700
      rs_strict = istrue;
1701
    if (opt_fp) {   /* v0.3m */
1701
    if (opt_fp) {   /* v0.3m */
1702
        opt_molout = false;
1702
        opt_molout = isfalse;
1703
        opt_exact = false;
1703
        opt_exact = isfalse;
1704
    }
1704
    }
1705
  }  /* progmode = pmMatchMol */
1705
  }  /* progmode = pmMatchMol */
1706
  ringsearch_mode = opt_rs;   /* v0.3i */
1706
  ringsearch_mode = opt_rs;   /* v0.3i */
1707
}
1707
}
1708
#endif
1708
#endif
Line 1713... Line 1713...
1713
  char parstr[256];
1713
  char parstr[256];
1714
  char tmpstr[256];
1714
  char tmpstr[256];
1715
  short l;
1715
  short l;
1716
 
1716
 
1717
  *tmpstr = '\0';
1717
  *tmpstr = '\0';
1718
  opt_none = true;
1718
  opt_none = istrue;
1719
  *molfilename = '\0';
1719
  *molfilename = '\0';
1720
  *ndl_molfilename = '\0';
1720
  *ndl_molfilename = '\0';
1721
  if (progmode == pmCheckMol) {
1721
  if (progmode == pmCheckMol) {
1722
    for (p = 1; p <= argc - 1; p++) {
1722
    for (p = 1; p <= argc - 1; p++) {
1723
            strcpy (parstr, argv[p]);
1723
            strcpy (parstr, argv[p]);
Line 1742... Line 1742...
1742
                        l++;
1742
                        l++;
1743
                      if (strlen (tmpstr) > l + 2) {
1743
                      if (strlen (tmpstr) > l + 2) {
1744
                        show_usage ();
1744
                        show_usage ();
1745
                        exit (1);
1745
                        exit (1);
1746
                      }
1746
                      }
1747
                      opt_none = false;
1747
                      opt_none = isfalse;
1748
                      if (strpos2 (tmpstr, "M", 1) > 0)
1748
                      if (strpos2 (tmpstr, "M", 1) > 0)
1749
                        opt_metalrings = true;
1749
                        opt_metalrings = istrue;
1750
                      if (strpos2 (tmpstr, "v", 1) > 0)
1750
                      if (strpos2 (tmpstr, "v", 1) > 0)
1751
                        opt_verbose = true;
1751
                        opt_verbose = istrue;
1752
                      /*{$IFDEF debug
1752
                      /*{$IFDEF debug
1753
                         if pos('D',tmpstr)>0 then opt_debug       := true;
1753
                         if pos('D',tmpstr)>0 then opt_debug       := istrue;
1754
                         {$ENDIF */
1754
                         {$ENDIF */
1755
                      if (strpos2 (tmpstr, "e", 1) > 0)
1755
                      if (strpos2 (tmpstr, "e", 1) > 0)
1756
                        opt_text = true;
1756
                        opt_text = istrue;
1757
                      else {
1757
                      else {
1758
                        if (strpos2 (tmpstr, "d", 1) > 0)
1758
                        if (strpos2 (tmpstr, "d", 1) > 0)
1759
                                 opt_text_de = true;
1759
                                 opt_text_de = istrue;
1760
                        else {
1760
                        else {
1761
                                if (strpos2 (tmpstr, "c", 1) > 0)
1761
                                if (strpos2 (tmpstr, "c", 1) > 0)
1762
                                  opt_code = true;
1762
                                  opt_code = istrue;
1763
                                else {
1763
                                else {
1764
                                  if (strpos2 (tmpstr, "b", 1) > 0)
1764
                                  if (strpos2 (tmpstr, "b", 1) > 0)
1765
                                    opt_bin = true;
1765
                                    opt_bin = istrue;
1766
                                  else {
1766
                                  else {
1767
                                    if (strpos2 (tmpstr, "s", 1) > 0)
1767
                                    if (strpos2 (tmpstr, "s", 1) > 0)
1768
                                      opt_bitstring = true;
1768
                                      opt_bitstring = istrue;
1769
                                  }
1769
                                  }
1770
                                }
1770
                                }
1771
                              }
1771
                              }
1772
                        if (strpos2 (tmpstr, "x", 1) > 0)
1772
                        if (strpos2 (tmpstr, "x", 1) > 0)
1773
                                opt_molstat = true;
1773
                                opt_molstat = istrue;
1774
                        if (strpos2 (tmpstr, "r", 1) > 0)
1774
                        if (strpos2 (tmpstr, "r", 1) > 0)
1775
                                opt_rs = rs_ssr;
1775
                                opt_rs = rs_ssr;
1776
                          /* if (strpos2 (tmpstr, "a", 1) > 0)
1776
                          /* if (strpos2 (tmpstr, "a", 1) > 0)
1777
                            opt_chg = true; */ /* 0.3x  */
1777
                            opt_chg = istrue; */ /* 0.3x  */
1778
                        if (strpos2 (tmpstr, "X", 1) > 0) {
1778
                        if (strpos2 (tmpstr, "X", 1) > 0) {
1779
                                opt_molstat = true;
1779
                                opt_molstat = istrue;
1780
                                opt_molstat_X = true;
1780
                                opt_molstat_X = istrue;
1781
                              }
1781
                              }
1782
                        if (strpos2 (tmpstr, "m", 1) > 0) {
1782
                        if (strpos2 (tmpstr, "m", 1) > 0) {
1783
                                opt_text = false;
1783
                                opt_text = isfalse;
1784
                                opt_text_de = false;
1784
                                opt_text_de = isfalse;
1785
                                opt_bin = false;
1785
                                opt_bin = isfalse;
1786
                                opt_bitstring = false;
1786
                                opt_bitstring = isfalse;
1787
                                opt_code = false;
1787
                                opt_code = isfalse;
1788
                                opt_molstat = false;
1788
                                opt_molstat = isfalse;
1789
                                opt_xmdlout = true;
1789
                                opt_xmdlout = istrue;
1790
                              }
1790
                              }
1791
                      }
1791
                      }
1792
                      strcpy (molfilename, tmpstr);
1792
                      strcpy (molfilename, tmpstr);
1793
              }
1793
              }
1794
            }
1794
            }
Line 1796... Line 1796...
1796
              if (strpos2 (parstr, "-", 1) == 1) {
1796
              if (strpos2 (parstr, "-", 1) == 1) {
1797
                if (strlen (parstr) > 1) {
1797
                if (strlen (parstr) > 1) {
1798
                  show_usage ();
1798
                  show_usage ();
1799
                  exit (1);
1799
                  exit (1);
1800
                }
1800
                }
1801
                opt_stdin = true;
1801
                opt_stdin = istrue;
1802
              } else {
1802
              } else {
1803
                      opt_stdin = false;
1803
                      opt_stdin = isfalse;
1804
                      strcpy (molfilename, parstr);
1804
                      strcpy (molfilename, parstr);
1805
                    }
1805
                    }
1806
            }
1806
            }
1807
          }
1807
          }
1808
    if (opt_text == false && opt_text_de == false && opt_code == false &&
1808
    if (opt_text == isfalse && opt_text_de == isfalse && opt_code == isfalse &&
1809
                opt_bin == false && opt_bitstring == false && opt_molstat == false
1809
                opt_bin == isfalse && opt_bitstring == isfalse && opt_molstat == isfalse
1810
                && opt_molstat_X == false && opt_xmdlout == false
1810
                && opt_molstat_X == isfalse && opt_xmdlout == isfalse
1811
                && opt_chg == false)
1811
                && opt_chg == isfalse)
1812
              opt_none = true;  /* 0.3x */
1812
              opt_none = istrue;        /* 0.3x */
1813
  }
1813
  }
1814
  if (progmode == pmMatchMol) {
1814
  if (progmode == pmMatchMol) {
1815
    for (p = 1; p <= argc - 1; p++) {
1815
    for (p = 1; p <= argc - 1; p++) {
1816
      strcpy (parstr, argv[p]);
1816
      strcpy (parstr, argv[p]);
1817
      if (p == 1) {
1817
      if (p == 1) {
1818
        if (strpos2 (parstr, "-", 1) == 1) {
1818
        if (strpos2 (parstr, "-", 1) == 1) {
1819
          if (strpos2 (parstr, "v", 1) > 1)
1819
          if (strpos2 (parstr, "v", 1) > 1)
1820
            opt_verbose = true;
1820
            opt_verbose = istrue;
1821
            /*{$IFDEF debug
1821
            /*{$IFDEF debug
1822
               if pos('D',parstr)>1 then opt_debug       := true;
1822
               if pos('D',parstr)>1 then opt_debug       := istrue;
1823
               {$ENDIF */
1823
               {$ENDIF */
1824
          if (strpos2 (parstr, "x", 1) > 1)
1824
          if (strpos2 (parstr, "x", 1) > 1)
1825
            opt_exact = true;
1825
            opt_exact = istrue;
1826
          if (strpos2 (parstr, "s", 1) > 1)     /* new in v0.2f */
1826
          if (strpos2 (parstr, "s", 1) > 1)     /* new in v0.2f */
1827
            opt_strict = true;
1827
            opt_strict = istrue;
1828
          if (strpos2 (parstr, "m", 1) > 1)
1828
          if (strpos2 (parstr, "m", 1) > 1)
1829
            opt_molout = true;
1829
            opt_molout = istrue;
1830
          if (strpos2 (parstr, "r", 1) > 1)
1830
          if (strpos2 (parstr, "r", 1) > 1)
1831
            opt_rs = rs_ssr;
1831
            opt_rs = rs_ssr;
1832
          if (strpos2 (parstr, "a", 1) > 0)
1832
          if (strpos2 (parstr, "a", 1) > 0)
1833
                    opt_chg = true;     /* 0.3x */
1833
                    opt_chg = istrue;   /* 0.3x */
1834
          if (strpos2 (parstr, "i", 1) > 0)
1834
          if (strpos2 (parstr, "i", 1) > 0)
1835
            opt_iso = true;     /* 0.3x */
1835
            opt_iso = istrue;   /* 0.3x */
1836
          if (strpos2 (parstr, "d", 1) > 0)
1836
          if (strpos2 (parstr, "d", 1) > 0)
1837
            opt_rad = true;     /* 0.3x */
1837
            opt_rad = istrue;   /* 0.3x */
1838
          if (strpos2 (parstr, "M", 1) > 0)     /* new in v0.3 */
1838
          if (strpos2 (parstr, "M", 1) > 0)     /* new in v0.3 */
1839
            opt_metalrings = true;
1839
            opt_metalrings = istrue;
1840
          if (strpos2 (parstr, "g", 1) > 0)     /* new in v0.3d */
1840
          if (strpos2 (parstr, "g", 1) > 0)     /* new in v0.3d */
1841
            opt_geom = true;
1841
            opt_geom = istrue;
1842
          if (strpos2 (parstr, "G", 1) > 0)     /* new in v0.3f */
1842
          if (strpos2 (parstr, "G", 1) > 0)     /* new in v0.3f */
1843
            opt_chiral = true;
1843
            opt_chiral = istrue;
1844
          if (strpos2 (parstr, "f", 1) > 0) {           /* new in v0.3m */
1844
          if (strpos2 (parstr, "f", 1) > 0) {           /* new in v0.3m */
1845
            opt_fp = true;
1845
            opt_fp = istrue;
1846
            fpformat = fpf_boolean;
1846
            fpformat = fpf_boolean;
1847
          }
1847
          }
1848
          if (strpos2 (parstr, "F", 1) > 0) {           /* new in v0.3m */
1848
          if (strpos2 (parstr, "F", 1) > 0) {           /* new in v0.3m */
1849
            opt_fp = true;
1849
            opt_fp = istrue;
1850
            fpformat = fpf_decimal;
1850
            fpformat = fpf_decimal;
1851
          }
1851
          }
1852
          if (strpos2 (parstr, "h", 1) > 1) {
1852
          if (strpos2 (parstr, "h", 1) > 1) {
1853
            show_usage ();
1853
            show_usage ();
1854
            exit (0);
1854
            exit (0);
Line 1862... Line 1862...
1862
              }
1862
              }
1863
            if (p == argc - 1) {
1863
            if (p == argc - 1) {
1864
              if (strcmp (parstr, "-"))
1864
              if (strcmp (parstr, "-"))
1865
                strcpy (molfilename, parstr);
1865
                strcpy (molfilename, parstr);
1866
              else
1866
              else
1867
                opt_stdin = true;
1867
                opt_stdin = istrue;
1868
            }
1868
            }
1869
          }
1869
          }
1870
    if (opt_geom)               /* v0.3d */
1870
    if (opt_geom)               /* v0.3d */
1871
            ez_search = true;
1871
            ez_search = istrue;
1872
    if (opt_chiral)             /* v0.3f */
1872
    if (opt_chiral)             /* v0.3f */
1873
            rs_search = true;
1873
            rs_search = istrue;
1874
    if (opt_chiral && opt_strict && (opt_exact || opt_fp))
1874
    if (opt_chiral && opt_strict && (opt_exact || opt_fp))
1875
            /* new in v0.3j, v0.3m  */
1875
            /* new in v0.3j, v0.3m  */
1876
            rs_strict = true;
1876
            rs_strict = istrue;
1877
    if (opt_fp) {                       /* v0.3m */
1877
    if (opt_fp) {                       /* v0.3m */
1878
            opt_molout = false;
1878
            opt_molout = isfalse;
1879
            opt_exact = false;
1879
            opt_exact = isfalse;
1880
          }
1880
          }
1881
  }                             /* progmode = pmMatchMol */
1881
  }                             /* progmode = pmMatchMol */
1882
  ringsearch_mode = opt_rs;     /* v0.3i */
1882
  ringsearch_mode = opt_rs;     /* v0.3i */
1883
}
1883
}
1884
 
1884
 
Line 1887... Line 1887...
1887
static char *get_filetype (char *Result, char *f)
1887
static char *get_filetype (char *Result, char *f)
1888
{
1888
{
1889
  char rline[256];
1889
  char rline[256];
1890
  char auxstr[256];
1890
  char auxstr[256];
1891
  int i;
1891
  int i;
1892
  boolean mdl1 = false;
1892
  boolean mdl1 = isfalse;
1893
  int ri;
1893
  int ri;
1894
  int sepcount = 0;
1894
  int sepcount = 0;
1895
  char STR1[256], STR6[256], STR7[256];
1895
  char STR1[256], STR6[256], STR7[256];
1896
 
1896
 
1897
  strcpy (auxstr, "unknown");
1897
  strcpy (auxstr, "unknown");
Line 1906... Line 1906...
1906
              (strcmp (strsub (STR6, rline, 20, 5), "BONDS") == 0) &&
1906
              (strcmp (strsub (STR6, rline, 20, 5), "BONDS") == 0) &&
1907
              (strcmp (strsub (STR7, rline, 33, 7), "CHARGES") == 0))
1907
              (strcmp (strsub (STR7, rline, 33, 7), "CHARGES") == 0))
1908
            strcpy (auxstr, "alchemy");
1908
            strcpy (auxstr, "alchemy");
1909
    if ((i == li + 3) && (strcmp (strsub (STR1, rline, 35, 5), "V2000") == 0))
1909
    if ((i == li + 3) && (strcmp (strsub (STR1, rline, 35, 5), "V2000") == 0))
1910
            /* and (copy(rline,31,3)='999') */
1910
            /* and (copy(rline,31,3)='999') */
1911
            mdl1 = true;
1911
            mdl1 = istrue;
1912
    if ((i == li + 1) && (strcmp (strsub (STR1, rline, 3, 6), "-ISIS-") == 0))
1912
    if ((i == li + 1) && (strcmp (strsub (STR1, rline, 3, 6), "-ISIS-") == 0))
1913
            mdl1 = true;
1913
            mdl1 = istrue;
1914
    if ((i == li + 1) && (strcmp (strsub (STR1, rline, 3, 8), "WLViewer") == 0))
1914
    if ((i == li + 1) && (strcmp (strsub (STR1, rline, 3, 8), "WLViewer") == 0))
1915
            mdl1 = true;
1915
            mdl1 = istrue;
1916
    if ((i == li + 1) && (strcmp (strsub (STR1, rline, 3, 8), "CheckMol") == 0))
1916
    if ((i == li + 1) && (strcmp (strsub (STR1, rline, 3, 8), "CheckMol") == 0))
1917
            mdl1 = true;
1917
            mdl1 = istrue;
1918
    if ((i == li + 1) && (strcmp (strsub (STR1, rline, 3, 8), "CATALYST") == 0)) {
1918
    if ((i == li + 1) && (strcmp (strsub (STR1, rline, 3, 8), "CATALYST") == 0)) {
1919
            mdl1 = true;
1919
            mdl1 = istrue;
1920
            strcpy (auxstr, "mdl");
1920
            strcpy (auxstr, "mdl");
1921
          }
1921
          }
1922
    if (strpos2 (rline, "M  END", 1) == 1 || mdl1)
1922
    if (strpos2 (rline, "M  END", 1) == 1 || mdl1)
1923
            strcpy (auxstr, "mdl");
1923
            strcpy (auxstr, "mdl");
1924
    if (strpos2 (rline, "@<TRIPOS>MOLECULE", 1) > 0)
1924
    if (strpos2 (rline, "@<TRIPOS>MOLECULE", 1) > 0)
Line 2019... Line 2019...
2019
  str2 el;
2019
  str2 el;
2020
 
2020
 
2021
  strcpy (el, atom[id - 1].element);
2021
  strcpy (el, atom[id - 1].element);
2022
 
2022
 
2023
  if (!strcmp (el, "DU") || !strcmp (el, "LP"))
2023
  if (!strcmp (el, "DU") || !strcmp (el, "LP"))
2024
    return false;
2024
    return isfalse;
2025
  /*if (progmode == pmCheckMol && !strcmp (el, "H ")
2025
  /*if (progmode == pmCheckMol && !strcmp (el, "H ")
2026
     && atom[id - 1].nucleon_number < 2)
2026
     && atom[id - 1].nucleon_number < 2)
2027
     return false;               0.3x  */
2027
     return isfalse;               0.3x  */
2028
  if (!strcmp (el, "H "))       /* 0.3 p */ {
2028
  if (!strcmp (el, "H "))       /* 0.3 p */ {
2029
    if (progmode == pmMatchMol && !opt_iso) {
2029
    if (progmode == pmMatchMol && !opt_iso) {
2030
            return false;
2030
            return isfalse;
2031
          }
2031
          }
2032
    else {
2032
    else {
2033
          if (atom[id - 1].nucleon_number < 2)
2033
          if (atom[id - 1].nucleon_number < 2)
2034
            return false;
2034
            return isfalse;
2035
          }
2035
          }
2036
  }
2036
  }
2037
  return true;
2037
  return istrue;
2038
}
2038
}
2039
 
2039
 
2040
static boolean ndl_alkene_C (int ba)
2040
static boolean ndl_alkene_C (int ba)
2041
{
2041
{
2042
  /* new in v0.3f */
2042
  /* new in v0.3f */
2043
  boolean res = false;
2043
  boolean res = isfalse;
2044
  int i, ba2, FORLIM;
2044
  int i, ba2, FORLIM;
2045
 
2045
 
2046
  if (ndl_n_atoms <= 0 || ndl_n_bonds <= 0)
2046
  if (ndl_n_atoms <= 0 || ndl_n_bonds <= 0)
2047
    return false;
2047
    return isfalse;
2048
  FORLIM = ndl_n_bonds;
2048
  FORLIM = ndl_n_bonds;
2049
  for (i = 0; i < FORLIM; i++) {
2049
  for (i = 0; i < FORLIM; i++) {
2050
    if (ndl_bond[i].a1 == ba || ndl_bond[i].a2 == ba) {
2050
    if (ndl_bond[i].a1 == ba || ndl_bond[i].a2 == ba) {
2051
            if (ndl_bond[i].a1 == ba)
2051
            if (ndl_bond[i].a1 == ba)
2052
              ba2 = ndl_bond[i].a2;
2052
              ba2 = ndl_bond[i].a2;
2053
            else
2053
            else
2054
              ba2 = ndl_bond[i].a1;
2054
              ba2 = ndl_bond[i].a1;
2055
          if (!strcmp (ndl_atom[ba - 1].atype, "C2 ") &&
2055
          if (!strcmp (ndl_atom[ba - 1].atype, "C2 ") &&
2056
              !strcmp (ndl_atom[ba2 - 1].atype, "C2 ")
2056
              !strcmp (ndl_atom[ba2 - 1].atype, "C2 ")
2057
              && ndl_bond[i].btype == 'D' && ndl_bond[i].arom == false)
2057
              && ndl_bond[i].btype == 'D' && ndl_bond[i].arom == isfalse)
2058
            res = true;
2058
            res = istrue;
2059
          }
2059
          }
2060
  }
2060
  }
2061
  return res;
2061
  return res;
2062
}
2062
}
2063
 
2063
 
2064
static boolean is_metal (int id)
2064
static boolean is_metal (int id)
2065
{
2065
{
2066
  boolean r = false;
2066
  boolean r = isfalse;
2067
  str2 el;
2067
  str2 el;
2068
 
2068
 
2069
  strcpy (el, atom[id - 1].element);
2069
  strcpy (el, atom[id - 1].element);
2070
  if (!strcmp (el, "LI") || !strcmp (el, "NA") || !strcmp (el, "K ") ||
2070
  if (!strcmp (el, "LI") || !strcmp (el, "NA") || !strcmp (el, "K ") ||
2071
      !strcmp (el, "RB") || !strcmp (el, "CS") || !strcmp (el, "BE") ||
2071
      !strcmp (el, "RB") || !strcmp (el, "CS") || !strcmp (el, "BE") ||
Line 2079... Line 2079...
2079
      !strcmp (el, "AL") || !strcmp (el, "SN") || !strcmp (el, "PB") ||
2079
      !strcmp (el, "AL") || !strcmp (el, "SN") || !strcmp (el, "PB") ||
2080
      !strcmp (el, "SB") || !strcmp (el, "BI"))
2080
      !strcmp (el, "SB") || !strcmp (el, "BI"))
2081
  /* p2c: checkmol.pas, line 1577:
2081
  /* p2c: checkmol.pas, line 1577:
2082
  * Note: Line breaker spent 0.0 seconds, 5000 tries on line 1686 [251] */
2082
  * Note: Line breaker spent 0.0 seconds, 5000 tries on line 1686 [251] */
2083
    /* etc. etc. */
2083
    /* etc. etc. */
2084
    r = true;
2084
    r = istrue;
2085
  return r;
2085
  return r;
2086
}
2086
}
2087
 
2087
 
2088
static int get_nvalences (char *a_el)
2088
static int get_nvalences (char *a_el)
2089
{
2089
{
Line 2512... Line 2512...
2512
    WITH->y = yval;
2512
    WITH->y = yval;
2513
    WITH->z = zval;
2513
    WITH->z = zval;
2514
    WITH->real_charge = chgval;
2514
    WITH->real_charge = chgval;
2515
    if (is_heavyatom (n)) {
2515
    if (is_heavyatom (n)) {
2516
            n_heavyatoms++;
2516
            n_heavyatoms++;
2517
            WITH->heavy = true;
2517
            WITH->heavy = istrue;
2518
            if (is_metal (n))
2518
            if (is_metal (n))
2519
              WITH->metal = true;
2519
              WITH->metal = istrue;
2520
          }
2520
          }
2521
    WITH->nvalences = get_nvalences (WITH->element);    /* v0.3m   */
2521
    WITH->nvalences = get_nvalences (WITH->element);    /* v0.3m   */
2522
  }
2522
  }
2523
  /*
2523
  /*
2524
     with atom^[n] do
2524
     with atom^[n] do
Line 2528... Line 2528...
2528
     real_charge    := 0;
2528
     real_charge    := 0;
2529
     Hexp           := 0;
2529
     Hexp           := 0;
2530
     Htot           := 0;
2530
     Htot           := 0;
2531
     neighbor_count := 0;
2531
     neighbor_count := 0;
2532
     ring_count     := 0;
2532
     ring_count     := 0;
2533
     arom           := false;
2533
     arom           := isfalse;
2534
     stereo_care    := false;
2534
     stereo_care    := isfalse;
2535
     heavy          := false;
2535
     heavy          := isfalse;
2536
     metal          := false;
2536
     metal          := isfalse;
2537
     tag            := false;
2537
     tag            := isfalse;
2538
     end;
2538
     end;
2539
   */
2539
   */
2540
  FORLIM = n_bonds;
2540
  FORLIM = n_bonds;
2541
  for (n = 0; n < FORLIM; n++) {
2541
  for (n = 0; n < FORLIM; n++) {
2542
    ri++;
2542
    ri++;
Line 2548... Line 2548...
2548
    WITH1 = &bond[n];
2548
    WITH1 = &bond[n];
2549
    WITH1->a1 = a1val;
2549
    WITH1->a1 = a1val;
2550
    WITH1->a2 = a2val;
2550
    WITH1->a2 = a2val;
2551
    WITH1->btype = rline[19];
2551
    WITH1->btype = rline[19];
2552
    WITH1->ring_count = 0;
2552
    WITH1->ring_count = 0;
2553
    WITH1->arom = false;
2553
    WITH1->arom = isfalse;
2554
    WITH1->topo = btopo_any;
2554
    WITH1->topo = btopo_any;
2555
    WITH1->stereo = bstereo_any;
2555
    WITH1->stereo = bstereo_any;
2556
    WITH1->mdl_stereo = 0;      /* v0.3n */
2556
    WITH1->mdl_stereo = 0;      /* v0.3n */
2557
    if (atom[a1val - 1].heavy && atom[a2val - 1].heavy)
2557
    if (atom[a1val - 1].heavy && atom[a2val - 1].heavy)
2558
            n_heavybonds++;
2558
            n_heavybonds++;
2559
  }
2559
  }
2560
  memset (ring, 0, sizeof (ringlist));
2560
  memset (ring, 0, sizeof (ringlist));
2561
  for (n = 0; n < max_rings; n++) {                             /* new in v0.3 */
2561
  for (n = 0; n < max_rings; n++) {                             /* new in v0.3 */
2562
    ringprop[n].size = 0;
2562
    ringprop[n].size = 0;
2563
    ringprop[n].arom = false;
2563
    ringprop[n].arom = isfalse;
2564
    ringprop[n].envelope = false;
2564
    ringprop[n].envelope = isfalse;
2565
  }
2565
  }
2566
  li = ri + 1;
2566
  li = ri + 1;
2567
}
2567
}
2568
 
2568
 
2569
static void read_mol2file (char *mfilename)
2569
static void read_mol2file (char *mfilename)
Line 2632... Line 2632...
2632
      real_charge    := 0;
2632
      real_charge    := 0;
2633
      Hexp           := 0;
2633
      Hexp           := 0;
2634
      Htot           := 0;
2634
      Htot           := 0;
2635
      neighbor_count := 0;
2635
      neighbor_count := 0;
2636
      ring_count     := 0;
2636
      ring_count     := 0;
2637
      arom           := false;
2637
      arom           := isfalse;
2638
      stereo_care    := false;
2638
      stereo_care    := isfalse;
2639
      heavy          := false;
2639
      heavy          := isfalse;
2640
      metal          := false;
2640
      metal          := isfalse;
2641
      tag            := false;
2641
      tag            := isfalse;
2642
      end;
2642
      end;
2643
    */
2643
    */
2644
    if (ri < molbufindex) {
2644
    if (ri < molbufindex) {
2645
            ri++;
2645
            ri++;
2646
            strcpy (rline, molbuf[ri - 1]);
2646
            strcpy (rline, molbuf[ri - 1]);
Line 2669... Line 2669...
2669
    WITH->y = yval;
2669
    WITH->y = yval;
2670
    WITH->z = zval;
2670
    WITH->z = zval;
2671
    WITH->real_charge = chgval;
2671
    WITH->real_charge = chgval;
2672
    if (is_heavyatom (n)) {
2672
    if (is_heavyatom (n)) {
2673
            n_heavyatoms++;
2673
            n_heavyatoms++;
2674
            WITH->heavy = true;
2674
            WITH->heavy = istrue;
2675
            if (is_metal (n))
2675
            if (is_metal (n))
2676
              WITH->metal = true;
2676
              WITH->metal = istrue;
2677
          }
2677
          }
2678
    WITH->nvalences = get_nvalences (WITH->element);    /* v0.3m   */
2678
    WITH->nvalences = get_nvalences (WITH->element);    /* v0.3m   */
2679
  }
2679
  }
2680
  while ((ri < molbufindex) && (strpos2 (rline, "@<TRIPOS>BOND", 1) == 0)) {
2680
  while ((ri < molbufindex) && (strpos2 (rline, "@<TRIPOS>BOND", 1) == 0)) {
2681
    ri++;
2681
    ri++;
Line 2705... Line 2705...
2705
    if (rline[17] == '3')
2705
    if (rline[17] == '3')
2706
            WITH1->btype = 'T';
2706
            WITH1->btype = 'T';
2707
    if (rline[17] == 'a')
2707
    if (rline[17] == 'a')
2708
            WITH1->btype = 'A';
2708
            WITH1->btype = 'A';
2709
    WITH1->ring_count = 0;
2709
    WITH1->ring_count = 0;
2710
    WITH1->arom = false;
2710
    WITH1->arom = isfalse;
2711
    WITH1->topo = btopo_any;
2711
    WITH1->topo = btopo_any;
2712
    WITH1->stereo = bstereo_any;
2712
    WITH1->stereo = bstereo_any;
2713
    WITH1->mdl_stereo = 0;      /* v0.3n */
2713
    WITH1->mdl_stereo = 0;      /* v0.3n */
2714
    if (atom[a1val - 1].heavy && atom[a2val - 1].heavy)
2714
    if (atom[a1val - 1].heavy && atom[a2val - 1].heavy)
2715
            n_heavybonds++;
2715
            n_heavybonds++;
2716
  }
2716
  }
2717
  memset (ring, 0, sizeof (ringlist));
2717
  memset (ring, 0, sizeof (ringlist));
2718
  for (n = 0; n < max_rings; n++) {                             /* new in v0.3 */
2718
  for (n = 0; n < max_rings; n++) {                             /* new in v0.3 */
2719
    ringprop[n].size = 0;
2719
    ringprop[n].size = 0;
2720
    ringprop[n].arom = false;
2720
    ringprop[n].arom = isfalse;
2721
    ringprop[n].envelope = false;
2721
    ringprop[n].envelope = isfalse;
2722
  }
2722
  }
2723
  li = ri + 1;
2723
  li = ri + 1;
2724
}
2724
}
2725
 
2725
 
2726
static void read_charges (char *chgstring_)
2726
static void read_charges (char *chgstring_)
Line 2772... Line 2772...
2772
    a_id = left_int (isotopestring);
2772
    a_id = left_int (isotopestring);
2773
    a_nucleon_number = left_int (isotopestring);
2773
    a_nucleon_number = left_int (isotopestring);
2774
    if (a_id != 0 && a_nucleon_number != 0) {
2774
    if (a_id != 0 && a_nucleon_number != 0) {
2775
            atom[a_id - 1].nucleon_number = a_nucleon_number;
2775
            atom[a_id - 1].nucleon_number = a_nucleon_number;
2776
            if (!strcmp (atom[a_id - 1].element, "H ")) {
2776
            if (!strcmp (atom[a_id - 1].element, "H ")) {
2777
              atom[a_id - 1].heavy = true;
2777
              atom[a_id - 1].heavy = istrue;
2778
              n_heavyatoms++;
2778
              n_heavyatoms++;
2779
              strcpy (atom[a_id - 1].atype, "DU ");
2779
              strcpy (atom[a_id - 1].atype, "DU ");
2780
            }
2780
            }
2781
          }
2781
          }
2782
    //printf ("ISO %i, %i\n", a_id, a_nucleon_number);
2782
    //printf ("ISO %i, %i\n", a_id, a_nucleon_number);
Line 2821... Line 2821...
2821
  float xval, yval, zval, chgval;
2821
  float xval, yval, zval, chgval;
2822
  char a1str[256], a2str[256], elemstr[256];
2822
  char a1str[256], a2str[256], elemstr[256];
2823
  int a1val, a2val, ri, rc, bt, bs;
2823
  int a1val, a2val, ri, rc, bt, bs;
2824
  int sepcount = 0;
2824
  int sepcount = 0;
2825
  int i;                        /* v0.3j */
2825
  int i;                        /* v0.3j */
2826
  boolean clearcharges = true;  /* v0.3j */
2826
  boolean clearcharges = istrue;        /* v0.3j */
2827
  char STR1[256];
2827
  char STR1[256];
2828
  /*  int FORLIM;*/
2828
  /*  int FORLIM;*/
2829
  atom_rec *WITH;
2829
  atom_rec *WITH;
2830
  bond_rec *WITH1;
2830
  bond_rec *WITH1;
2831
 
2831
 
2832
  /* v0.3j */
2832
  /* v0.3j */
2833
  if (n_atoms > 0)
2833
  if (n_atoms > 0)
2834
    zap_molecule ();
2834
    zap_molecule ();
2835
  /*cm_mdlmolfile := false; */
2835
  /*cm_mdlmolfile := isfalse; */
2836
  *rline = '\0';
2836
  *rline = '\0';
2837
  ri = li;
2837
  ri = li;
2838
  strcpy (molname, molbuf[ri - 1]);     /* line 1 */
2838
  strcpy (molname, molbuf[ri - 1]);     /* line 1 */
2839
  if (ri < molbufindex)         /* line 2 */
2839
  if (ri < molbufindex)         /* line 2 */
2840
    ri++;
2840
    ri++;
2841
  strcpy (rline, molbuf[ri - 1]);
2841
  strcpy (rline, molbuf[ri - 1]);
2842
  if (strpos2 (rline, "CheckMol", 1) == 3) {
2842
  if (strpos2 (rline, "CheckMol", 1) == 3) {
2843
    /*cm_mdlmolfile := true; */
2843
    /*cm_mdlmolfile := istrue; */
2844
    found_arominfo = true;
2844
    found_arominfo = istrue;
2845
    tmfcode = 1;                /* v0.3m (begin) */
2845
    tmfcode = 1;                /* v0.3m (begin) */
2846
    code = 0;
2846
    code = 0;
2847
    if ((strlen (rline) >= 39) && (strpos2 (rline, "TMF", 1) == 35)) {
2847
    if ((strlen (rline) >= 39) && (strpos2 (rline, "TMF", 1) == 35)) {
2848
      /* v0.3m; encoding of tweaklevel */
2848
      /* v0.3m; encoding of tweaklevel */
2849
            strsub (tmpstr, rline, 38, 2);
2849
            strsub (tmpstr, rline, 38, 2);
2850
            code = (sscanf (tmpstr, "%d", &tmfcode) == 0);
2850
            code = (sscanf (tmpstr, "%d", &tmfcode) == 0);
2851
          }
2851
          }
2852
    if (code != 0 || tmfcode != tweaklevel)
2852
    if (code != 0 || tmfcode != tweaklevel)
2853
            tmfmismatch = true;
2853
            tmfmismatch = istrue;
2854
    else
2854
    else
2855
            tmfmismatch = false;
2855
            tmfmismatch = isfalse;
2856
      if ((strpos2 (rline, ":r0", 1) >= 40 && ringsearch_mode != rs_sar) ||
2856
      if ((strpos2 (rline, ":r0", 1) >= 40 && ringsearch_mode != rs_sar) ||
2857
                (strpos2 (rline, ":r1", 1) >= 40 && ringsearch_mode != rs_ssr))
2857
                (strpos2 (rline, ":r1", 1) >= 40 && ringsearch_mode != rs_ssr))
2858
              tmfmismatch = true;
2858
              tmfmismatch = istrue;
2859
      if ((strpos2 (rline, ":m0", 1) >= 40 && opt_metalrings == true) ||
2859
      if ((strpos2 (rline, ":m0", 1) >= 40 && opt_metalrings == istrue) ||
2860
                (strpos2 (rline, ":m1", 1) >= 40 && opt_metalrings == false))
2860
                (strpos2 (rline, ":m1", 1) >= 40 && opt_metalrings == isfalse))
2861
              tmfmismatch = true;
2861
              tmfmismatch = istrue;
2862
      /* p2c: checkmol.pas, line 2128:
2862
      /* p2c: checkmol.pas, line 2128:
2863
       * Note: Turbo Pascal conditional compilation directive was ignored [218] */
2863
       * Note: Turbo Pascal conditional compilation directive was ignored [218] */
2864
            /*$IFDEF debug */
2864
            /*$IFDEF debug */
2865
            //if (tmfmismatch)
2865
            //if (tmfmismatch)
2866
            //printf ("\"tweaked\" molfile: version mismatch!\n");
2866
            //printf ("\"tweaked\" molfile: version mismatch!\n");
Line 2920... Line 2920...
2920
      exit;
2920
      exit;
2921
      end;
2921
      end;
2922
      end; */
2922
      end; */
2923
      /* check for the chirality flag */
2923
      /* check for the chirality flag */
2924
      if (strlen (rline) > 14 && rline[14] == '1')      /* new in v0.3f */
2924
      if (strlen (rline) > 14 && rline[14] == '1')      /* new in v0.3f */
2925
        chir_flag = true;
2925
        chir_flag = istrue;
2926
      n_heavyatoms = 0;
2926
      n_heavyatoms = 0;
2927
      n_heavybonds = 0;
2927
      n_heavybonds = 0;
2928
      n_Ctot = 0;                       /* v0.3g */
2928
      n_Ctot = 0;                       /* v0.3g */
2929
      n_Otot = 0;                       /* v0.3g */
2929
      n_Otot = 0;                       /* v0.3g */
2930
      n_Ntot = 0;                       /* v0.3g */
2930
      n_Ntot = 0;                       /* v0.3g */
Line 2943... Line 2943...
2943
                real_charge    := 0;
2943
                real_charge    := 0;
2944
                Hexp           := 0;
2944
                Hexp           := 0;
2945
                Htot           := 0;
2945
                Htot           := 0;
2946
                neighbor_count := 0;
2946
                neighbor_count := 0;
2947
                ring_count     := 0;
2947
                ring_count     := 0;
2948
                arom           := false;
2948
                arom           := isfalse;
2949
                stereo_care    := false;
2949
                stereo_care    := isfalse;
2950
                metal          := false;
2950
                metal          := isfalse;
2951
                heavy          := false;
2951
                heavy          := isfalse;
2952
                tag            := false;
2952
                tag            := isfalse;
2953
                end;
2953
                end;
2954
                */
2954
                */
2955
                /* replaced by fillchar() after getmem() (see above); v0.3l */
2955
                /* replaced by fillchar() after getmem() (see above); v0.3l */
2956
                ri++;
2956
                ri++;
2957
                strcpy (rline, molbuf[ri - 1]);
2957
                strcpy (rline, molbuf[ri - 1]);
Line 2985... Line 2985...
2985
                WITH = &atom[v - 1];
2985
                WITH = &atom[v - 1];
2986
                strcpy (WITH->element, elemstr);
2986
                strcpy (WITH->element, elemstr);
2987
                if (!strcmp (elemstr, "A ") || !strcmp (elemstr, "Q ") ||
2987
                if (!strcmp (elemstr, "A ") || !strcmp (elemstr, "Q ") ||
2988
                    !strcmp (elemstr, "X "))
2988
                    !strcmp (elemstr, "X "))
2989
                  /* 'X ' added in v0.3n */
2989
                  /* 'X ' added in v0.3n */
2990
                  found_querymol = true;
2990
                  found_querymol = istrue;
2991
 
2991
 
2992
                strcpy (WITH->atype, newatomtype);
2992
                strcpy (WITH->atype, newatomtype);
2993
 
2993
 
2994
                if (!strcmp (elemstr, "D ")) {
2994
                if (!strcmp (elemstr, "D ")) {
2995
                  strcpy (WITH->element, "H ");
2995
                  strcpy (WITH->element, "H ");
Line 3005... Line 3005...
3005
                WITH->z = zval;
3005
                WITH->z = zval;
3006
                WITH->formal_charge = (long) floor (chgval + 0.5);
3006
                WITH->formal_charge = (long) floor (chgval + 0.5);
3007
                WITH->real_charge = 0.0;        /* v0.3j */
3007
                WITH->real_charge = 0.0;        /* v0.3j */
3008
                /* read aromaticity flag from CheckMol-tweaked MDL molfile */
3008
                /* read aromaticity flag from CheckMol-tweaked MDL molfile */
3009
                if (strlen (rline) > 37 && rline[37] == '0') {
3009
                if (strlen (rline) > 37 && rline[37] == '0') {
3010
                  WITH->arom = true;
3010
                  WITH->arom = istrue;
3011
                  found_arominfo = true;
3011
                  found_arominfo = istrue;
3012
                }
3012
                }
3013
                /* new in v0.3d: read stereo care flag */
3013
                /* new in v0.3d: read stereo care flag */
3014
                if (strlen (rline) > 47 && rline[47] == '1')
3014
                if (strlen (rline) > 47 && rline[47] == '1')
3015
                  WITH->stereo_care = true;
3015
                  WITH->stereo_care = istrue;
3016
                if (is_heavyatom (n)) {
3016
                if (is_heavyatom (n)) {
3017
                  n_heavyatoms++;
3017
                  n_heavyatoms++;
3018
                  WITH->heavy = true;
3018
                  WITH->heavy = istrue;
3019
                  if (is_metal (n))
3019
                  if (is_metal (n))
3020
                          WITH->metal = true;
3020
                          WITH->metal = istrue;
3021
                }
3021
                }
3022
                WITH->nvalences = get_nvalences (WITH->element);
3022
                WITH->nvalences = get_nvalences (WITH->element);
3023
                /* v0.3m                 */
3023
                /* v0.3m                 */
3024
              }
3024
              }
3025
      }                         /* if (n_atoms > 0)... */
3025
      }                         /* if (n_atoms > 0)... */
Line 3059... Line 3059...
3059
                  WITH1->btype = 'd';
3059
                  WITH1->btype = 'd';
3060
                if (rline[8] == '8')    /* any */
3060
                if (rline[8] == '8')    /* any */
3061
                  WITH1->btype = 'a';
3061
                  WITH1->btype = 'a';
3062
                sprintf (STR1, "%c", WITH1->btype);
3062
                sprintf (STR1, "%c", WITH1->btype);
3063
                if (strpos2 ("lsda", STR1, 1) > 0)
3063
                if (strpos2 ("lsda", STR1, 1) > 0)
3064
                  found_querymol = true;
3064
                  found_querymol = istrue;
3065
                WITH1->arom = false;
3065
                WITH1->arom = isfalse;
3066
                WITH1->q_arom = false;  /* 0.3p */
3066
                WITH1->q_arom = isfalse;        /* 0.3p */
3067
                /* read aromaticity flag from CheckMol-tweaked MDL molfile */
3067
                /* read aromaticity flag from CheckMol-tweaked MDL molfile */
3068
                if (WITH1->btype == 'A' || rline[7] == '0') {
3068
                if (WITH1->btype == 'A' || rline[7] == '0') {
3069
                  WITH1->arom = true;
3069
                  WITH1->arom = istrue;
3070
                  if (rline[7] == '0')
3070
                  if (rline[7] == '0')
3071
                          found_arominfo = true;
3071
                          found_arominfo = istrue;
3072
                }
3072
                }
3073
                strsub (tmpstr, rline, 13, 3);
3073
                strsub (tmpstr, rline, 13, 3);
3074
                /* new in v0.3d: read ring_count from tweaked molfile */
3074
                /* new in v0.3d: read ring_count from tweaked molfile */
3075
                code = (sscanf (tmpstr, "%d", &rc) == 0);
3075
                code = (sscanf (tmpstr, "%d", &rc) == 0);
3076
                if (code != 0 || rc < 0 || progmode == pmCheckMol || tmfmismatch)
3076
                if (code != 0 || rc < 0 || progmode == pmCheckMol || tmfmismatch)
Line 3094... Line 3094...
3094
          WITH1->stereo = bstereo_any;
3094
          WITH1->stereo = bstereo_any;
3095
          if (WITH1->btype == 'D') {
3095
          if (WITH1->btype == 'D') {
3096
            if (atom[WITH1->a1 - 1].stereo_care
3096
            if (atom[WITH1->a1 - 1].stereo_care
3097
                && atom[WITH1->a2 - 1].stereo_care) {           /* this is the MDL-conformant encoding, */
3097
                && atom[WITH1->a2 - 1].stereo_care) {           /* this is the MDL-conformant encoding, */
3098
              WITH1->stereo = bstereo_xyz;      /* for an alternative see below */
3098
              WITH1->stereo = bstereo_xyz;      /* for an alternative see below */
3099
              ez_flag = true;   /* v0.3f */
3099
              ez_flag = istrue; /* v0.3f */
3100
            }
3100
            }
3101
                  else {                /* this extended feature is encoded by a leading zero */
3101
                  else {                /* this extended feature is encoded by a leading zero */
3102
                          strsub (tmpstr, rline, 10, 3);
3102
                          strsub (tmpstr, rline, 10, 3);
3103
                          /* new in v0.3d: read bond stereo specification; */
3103
                          /* new in v0.3d: read bond stereo specification; */
3104
                          code = (sscanf (tmpstr, "%d", &bs) == 0);
3104
                          code = (sscanf (tmpstr, "%d", &bs) == 0);
Line 3109... Line 3109...
3109
                            WITH1->stereo = bstereo_xyz;
3109
                            WITH1->stereo = bstereo_xyz;
3110
                          if (tmpstr[1] == '0')
3110
                          if (tmpstr[1] == '0')
3111
                            WITH1->stereo = bstereo_xyz;
3111
                            WITH1->stereo = bstereo_xyz;
3112
                        }
3112
                        }
3113
                }
3113
                }
3114
                /*if stereo <> bstereo_any then ez_search := true; */
3114
                /*if stereo <> bstereo_any then ez_search := istrue; */
3115
                if (WITH1->stereo != bstereo_any)       /* changed in v0.3f */
3115
                if (WITH1->stereo != bstereo_any)       /* changed in v0.3f */
3116
                  ez_flag = true;
3116
                  ez_flag = istrue;
3117
                if (WITH1->btype == 'S' && strlen (rline) > 11 && rline[11] == '1')
3117
                if (WITH1->btype == 'S' && strlen (rline) > 11 && rline[11] == '1')
3118
                  WITH1->stereo = bstereo_up;
3118
                  WITH1->stereo = bstereo_up;
3119
                if (WITH1->btype == 'S' && strlen (rline) > 11 && rline[11] == '6')
3119
                if (WITH1->btype == 'S' && strlen (rline) > 11 && rline[11] == '6')
3120
                  WITH1->stereo = bstereo_down;
3120
                  WITH1->stereo = bstereo_down;
3121
                if (WITH1->btype == 'S' && strlen (rline) > 11 && rline[11] == '4')
3121
                if (WITH1->btype == 'S' && strlen (rline) > 11 && rline[11] == '4')
Line 3140... Line 3140...
3140
 
3140
 
3141
              for (i = 0; i < n_atoms; i++)
3141
              for (i = 0; i < n_atoms; i++)
3142
                atom[i].formal_charge = 0;
3142
                atom[i].formal_charge = 0;
3143
            }
3143
            }
3144
            read_charges (rline);
3144
            read_charges (rline);
3145
            clearcharges = false;
3145
            clearcharges = isfalse;
3146
            /* subsequent "M  CHG" lines must not clear previous values */
3146
            /* subsequent "M  CHG" lines must not clear previous values */
3147
          }
3147
          }
3148
 
3148
 
3149
    if (strpos2 (rline, "M  ISO", 1) > 0)
3149
    if (strpos2 (rline, "M  ISO", 1) > 0)
3150
            read_isotopes (rline);      /* 0.3x */
3150
            read_isotopes (rline);      /* 0.3x */
Line 3153... Line 3153...
3153
            read_radicals (rline);      /* 0.3x */
3153
            read_radicals (rline);      /* 0.3x */
3154
 
3154
 
3155
    if (strpos2 (rline, "$$$$", 1) > 0) {
3155
    if (strpos2 (rline, "$$$$", 1) > 0) {
3156
            sepcount++;
3156
            sepcount++;
3157
            if (molbufindex > ri + 2)   /* we assume this is an SDF file */
3157
            if (molbufindex > ri + 2)   /* we assume this is an SDF file */
3158
              mol_in_queue = true;
3158
              mol_in_queue = istrue;
3159
          }
3159
          }
3160
  }
3160
  }
3161
  memset (ring, 0, sizeof (ringlist));
3161
  memset (ring, 0, sizeof (ringlist));
3162
  for (n = 0; n < max_rings; n++) {                             /* new in v0.3 */
3162
  for (n = 0; n < max_rings; n++) {                             /* new in v0.3 */
3163
    ringprop[n].size = 0;
3163
    ringprop[n].size = 0;
3164
    ringprop[n].arom = false;
3164
    ringprop[n].arom = isfalse;
3165
    ringprop[n].envelope = false;
3165
    ringprop[n].envelope = isfalse;
3166
  }
3166
  }
3167
  li = ri + 1;
3167
  li = ri + 1;
3168
}
3168
}
3169
 
3169
 
3170
static void write_MDLmolfile ()
3170
static void write_MDLmolfile ()
Line 3354... Line 3354...
3354
/*============= chemical processing functions && procedures ============ */
3354
/*============= chemical processing functions && procedures ============ */
3355
 
3355
 
3356
static boolean is_electroneg (char *a_el)
3356
static boolean is_electroneg (char *a_el)
3357
{
3357
{
3358
  /* new in v0.3j */
3358
  /* new in v0.3j */
3359
  boolean res = false;
3359
  boolean res = isfalse;
3360
 
3360
 
3361
  if (!strcmp (a_el, "N "))
3361
  if (!strcmp (a_el, "N "))
3362
    res = true;
3362
    res = istrue;
3363
  if (!strcmp (a_el, "P "))
3363
  if (!strcmp (a_el, "P "))
3364
    res = true;
3364
    res = istrue;
3365
  if (!strcmp (a_el, "O "))
3365
  if (!strcmp (a_el, "O "))
3366
    res = true;
3366
    res = istrue;
3367
  if (!strcmp (a_el, "S "))
3367
  if (!strcmp (a_el, "S "))
3368
    res = true;
3368
    res = istrue;
3369
  if (!strcmp (a_el, "SE"))
3369
  if (!strcmp (a_el, "SE"))
3370
    res = true;
3370
    res = istrue;
3371
  if (!strcmp (a_el, "TE"))
3371
  if (!strcmp (a_el, "TE"))
3372
    res = true;
3372
    res = istrue;
3373
  if (!strcmp (a_el, "F "))
3373
  if (!strcmp (a_el, "F "))
3374
    res = true;
3374
    res = istrue;
3375
  if (!strcmp (a_el, "CL"))
3375
  if (!strcmp (a_el, "CL"))
3376
    res = true;
3376
    res = istrue;
3377
  if (!strcmp (a_el, "BR"))
3377
  if (!strcmp (a_el, "BR"))
3378
    res = true;
3378
    res = istrue;
3379
  if (!strcmp (a_el, "I "))
3379
  if (!strcmp (a_el, "I "))
3380
    res = true;
3380
    res = istrue;
3381
  if (!strcmp (a_el, "AT"))
3381
  if (!strcmp (a_el, "AT"))
3382
    res = true;
3382
    res = istrue;
3383
  return res;
3383
  return res;
3384
}
3384
}
3385
 
3385
 
3386
static void count_neighbors ()
3386
static void count_neighbors ()
3387
{
3387
{
Line 3401... Line 3401...
3401
    if (!strcmp (atom[bond[i].a2 - 1].element, "H "))
3401
    if (!strcmp (atom[bond[i].a2 - 1].element, "H "))
3402
            atom[bond[i].a1 - 1].Hexp++;
3402
            atom[bond[i].a1 - 1].Hexp++;
3403
    /* plausibility check (new in v02.i) */
3403
    /* plausibility check (new in v02.i) */
3404
    if (atom[bond[i].a1 - 1].neighbor_count > max_neighbors ||
3404
    if (atom[bond[i].a1 - 1].neighbor_count > max_neighbors ||
3405
              atom[bond[i].a2 - 1].neighbor_count > max_neighbors) {
3405
              atom[bond[i].a2 - 1].neighbor_count > max_neighbors) {
3406
            mol_OK = false;
3406
            mol_OK = isfalse;
3407
            /*writeln('invalid molecule!'); */
3407
            /*writeln('invalid molecule!'); */
3408
          }
3408
          }
3409
  }
3409
  }
3410
}
3410
}
3411
 
3411
 
Line 3606... Line 3606...
3606
}
3606
}
3607
 
3607
 
3608
static boolean rc_identical (int rc_int)
3608
static boolean rc_identical (int rc_int)
3609
{
3609
{
3610
  if (rc_int == 0)
3610
  if (rc_int == 0)
3611
    return true;
3611
    return istrue;
3612
  else
3612
  else
3613
    return false;
3613
    return isfalse;
3614
}
3614
}
3615
 
3615
 
3616
static boolean rc_1in2 (int rc_int)
3616
static boolean rc_1in2 (int rc_int)
3617
{
3617
{
3618
  if (rc_int & 1)
3618
  if (rc_int & 1)
3619
    return true;
3619
    return istrue;
3620
  else
3620
  else
3621
    return false;
3621
    return isfalse;
3622
}
3622
}
3623
 
3623
 
3624
static boolean rc_2in1 (int rc_int)
3624
static boolean rc_2in1 (int rc_int)
3625
{
3625
{
3626
  rc_int /= 2;
3626
  rc_int /= 2;
3627
  if (rc_int & 1)
3627
  if (rc_int & 1)
3628
    return true;
3628
    return istrue;
3629
  else
3629
  else
3630
    return false;
3630
    return isfalse;
3631
}
3631
}
3632
 
3632
 
3633
#if 0
3633
#if 0
3634
static boolean rc_different (int rc_int)
3634
static boolean rc_different (int rc_int)
3635
{
3635
{
3636
  rc_int /= 4;
3636
  rc_int /= 4;
3637
  if (rc_int & 1)
3637
  if (rc_int & 1)
3638
    return true;
3638
    return istrue;
3639
  else
3639
  else
3640
    return false;
3640
    return isfalse;
3641
}
3641
}
3642
#endif
3642
#endif
3643
#if 0
3643
#if 0
3644
static boolean rc_independent (int rc_int)
3644
static boolean rc_independent (int rc_int)
3645
{
3645
{
3646
  rc_int /= 8;
3646
  rc_int /= 8;
3647
  if (rc_int & 1)
3647
  if (rc_int & 1)
3648
    return true;
3648
    return istrue;
3649
  else
3649
  else
3650
    return false;
3650
    return isfalse;
3651
}
3651
}
3652
#endif
3652
#endif
3653
 
3653
 
3654
static boolean is_newring (int *n_path)
3654
static boolean is_newring (int *n_path)
3655
{
3655
{
3656
  int i, j;
3656
  int i, j;
3657
  boolean nr = true;
3657
  boolean nr = istrue;
3658
  boolean same_ring;
3658
  boolean same_ring;
3659
  ringpath_type tmp_path;
3659
  ringpath_type tmp_path;
3660
  int rc_result;
3660
  int rc_result;
3661
  boolean found_ring;
3661
  boolean found_ring;
3662
  int pl;                       /* new in v0.3 */
3662
  int pl;                       /* new in v0.3 */
3663
  int FORLIM;
3663
  int FORLIM;
3664
 
3664
 
3665
  pl = path_length (n_path);    /* new in v0.3 */
3665
  pl = path_length (n_path);    /* new in v0.3 */
3666
  if (n_rings <= 0)
3666
  if (n_rings <= 0)
3667
    return true;
3667
    return istrue;
3668
  switch (ringsearch_mode) {
3668
  switch (ringsearch_mode) {
3669
    case rs_sar:
3669
    case rs_sar:
3670
      found_ring = false;
3670
      found_ring = isfalse;
3671
      i = 0;
3671
      i = 0;
3672
      while (i < n_rings && !found_ring) {
3672
      while (i < n_rings && !found_ring) {
3673
              i++;
3673
              i++;
3674
              if (pl != ringprop[i - 1].size)   /* compare only rings of same size */
3674
              if (pl != ringprop[i - 1].size)   /* compare only rings of same size */
3675
                continue;
3675
                continue;
3676
              same_ring = true;
3676
              same_ring = istrue;
3677
              for (j = 0; j < max_ringsize; j++) {
3677
              for (j = 0; j < max_ringsize; j++) {
3678
                if (ring[i - 1][j] != n_path[j])
3678
                if (ring[i - 1][j] != n_path[j])
3679
                        same_ring = false;
3679
                        same_ring = isfalse;
3680
              }
3680
              }
3681
              if (same_ring) {
3681
              if (same_ring) {
3682
                nr = false;
3682
                nr = isfalse;
3683
                found_ring = true;
3683
                found_ring = istrue;
3684
              }
3684
              }
3685
            }
3685
            }
3686
      break;
3686
      break;
3687
 
3687
 
3688
    case rs_ssr:
3688
    case rs_ssr:
Line 3690... Line 3690...
3690
      for (i = 0; i < FORLIM; i++) {
3690
      for (i = 0; i < FORLIM; i++) {
3691
              for (j = 0; j < max_ringsize; j++)
3691
              for (j = 0; j < max_ringsize; j++)
3692
                tmp_path[j] = ring[i][j];
3692
                tmp_path[j] = ring[i][j];
3693
              rc_result = ringcompare (n_path, tmp_path);
3693
              rc_result = ringcompare (n_path, tmp_path);
3694
              if (rc_identical (rc_result))
3694
              if (rc_identical (rc_result))
3695
                nr = false;
3695
                nr = isfalse;
3696
              if (rc_1in2 (rc_result)) {
3696
              if (rc_1in2 (rc_result)) {
3697
              /* exchange existing ring by smaller one */
3697
              /* exchange existing ring by smaller one */
3698
                for (j = 0; j < max_ringsize; j++)
3698
                for (j = 0; j < max_ringsize; j++)
3699
                        ring[i][j] = n_path[j];
3699
                        ring[i][j] = n_path[j];
3700
                /* update ring property record (new in v0.3) */
3700
                /* update ring property record (new in v0.3) */
3701
                ringprop[i].size = pl;
3701
                ringprop[i].size = pl;
3702
                nr = false;
3702
                nr = isfalse;
3703
        /* p2c: checkmol.pas, line 2841:
3703
        /* p2c: checkmol.pas, line 2841:
3704
        * Note: Turbo Pascal conditional compilation directive was ignored [218] */
3704
        * Note: Turbo Pascal conditional compilation directive was ignored [218] */
3705
              /*$IFDEF debug */
3705
              /*$IFDEF debug */
3706
              /* debugoutput('replacing ring '+inttostr(i)+' by smaller one (ringsize: '+inttostr(path_length(n_path))+')'); */
3706
              /* debugoutput('replacing ring '+inttostr(i)+' by smaller one (ringsize: '+inttostr(path_length(n_path))+')'); */
3707
              /*$ENDIF */
3707
              /*$ENDIF */
3708
        }
3708
        }
3709
        if (rc_2in1 (rc_result)) {
3709
        if (rc_2in1 (rc_result)) {
3710
                  /* new ring contains existing one, but is larger ==> discard */
3710
                  /* new ring contains existing one, but is larger ==> discard */
3711
                nr = false;
3711
                nr = isfalse;
3712
              }
3712
              }
3713
            }
3713
            }
3714
    break;
3714
    break;
3715
  }
3715
  }
3716
  return nr;
3716
  return nr;
Line 3779... Line 3779...
3779
static boolean is_ringpath (s_path) int *s_path;
3779
static boolean is_ringpath (s_path) int *s_path;
3780
   {
3780
   {
3781
   boolean Result;
3781
   boolean Result;
3782
   int i, j;
3782
   int i, j;
3783
   neighbor_rec nb;
3783
   neighbor_rec nb;
3784
   boolean rp = false;
3784
   boolean rp = isfalse;
3785
   boolean new_atom;
3785
   boolean new_atom;
3786
   int a_last, pl;
3786
   int a_last, pl;
3787
   ringpath_type l_path;
3787
   ringpath_type l_path;
3788
   int FORLIM;
3788
   int FORLIM;
3789
 
3789
 
Line 3800... Line 3800...
3800
     return Result;
3800
     return Result;
3801
    }
3801
    }
3802
    for (i = 0; i < pl; i++)
3802
    for (i = 0; i < pl; i++)
3803
      l_path[i] = s_path[i];
3803
      l_path[i] = s_path[i];
3804
    /* check if the last atom is a metal and stop if opt_metalrings is not set (v0.3) */
3804
    /* check if the last atom is a metal and stop if opt_metalrings is not set (v0.3) */
3805
    if (opt_metalrings == false) {
3805
    if (opt_metalrings == isfalse) {
3806
      if (atom[l_path[pl - 1] - 1].metal){
3806
      if (atom[l_path[pl - 1] - 1].metal){
3807
        /* p2c: checkmol.pas, line 2942:
3807
        /* p2c: checkmol.pas, line 2942:
3808
        * Note: Turbo Pascal conditional compilation directive was ignored [218] */
3808
        * Note: Turbo Pascal conditional compilation directive was ignored [218] */
3809
        /*$IFDEF debug
3809
        /*$IFDEF debug
3810
        debugoutput ("skipping metal in ring search");
3810
        debugoutput ("skipping metal in ring search");
3811
         $ENDIF */
3811
         $ENDIF */
3812
        return false;
3812
        return isfalse;
3813
      }
3813
      }
3814
    }
3814
    }
3815
    /* check if ring is already closed */
3815
    /* check if ring is already closed */
3816
    if (pl > 2 && l_path[pl - 1] == l_path[0]) {
3816
    if (pl > 2 && l_path[pl - 1] == l_path[0]) {
3817
    l_path[pl - 1] = 0;        /* remove last entry (redundant!) */
3817
    l_path[pl - 1] = 0;        /* remove last entry (redundant!) */
Line 3821... Line 3821...
3821
        /* p2c: checkmol.pas, line 2958:
3821
        /* p2c: checkmol.pas, line 2958:
3822
        * Note: Turbo Pascal conditional compilation directive was ignored [218] */
3822
        * Note: Turbo Pascal conditional compilation directive was ignored [218] */
3823
        /*$IFDEF debug
3823
        /*$IFDEF debug
3824
        debugoutput ("maximum number of rings exceeded!");
3824
        debugoutput ("maximum number of rings exceeded!");
3825
        $ENDIF */
3825
        $ENDIF */
3826
        return false;
3826
        return isfalse;
3827
      }
3827
      }
3828
      add_ring (l_path);
3828
      add_ring (l_path);
3829
    }
3829
    }
3830
    /* p2c: checkmol.pas: Note: Eliminated unused assignment statement [338] */
3830
    /* p2c: checkmol.pas: Note: Eliminated unused assignment statement [338] */
3831
    return true;
3831
    return istrue;
3832
  }
3832
  }
3833
  /* any other case: ring is not (yet) closed */
3833
  /* any other case: ring is not (yet) closed */
3834
  a_last = l_path[pl - 1];
3834
  a_last = l_path[pl - 1];
3835
  get_neighbors (nb, a_last);
3835
  get_neighbors (nb, a_last);
3836
  if (atom[a_last - 1].neighbor_count <= 1)
3836
  if (atom[a_last - 1].neighbor_count <= 1)
3837
    return false;
3837
    return isfalse;
3838
  if (n_rings >= max_rings)
3838
  if (n_rings >= max_rings)
3839
    /* added in v0.2: check if max_rings is reached **/
3839
    /* added in v0.2: check if max_rings is reached **/
3840
  {                          /* if ring is not closed, continue searching */
3840
  {                          /* if ring is not closed, continue searching */
3841
    return false;
3841
    return isfalse;
3842
  }
3842
  }
3843
  FORLIM = atom[a_last - 1].neighbor_count;
3843
  FORLIM = atom[a_last - 1].neighbor_count;
3844
  for (i = 0; i < FORLIM; i++) {
3844
  for (i = 0; i < FORLIM; i++) {
3845
    new_atom = true;
3845
    new_atom = istrue;
3846
     for (j = 1; j < pl; j++) {
3846
     for (j = 1; j < pl; j++) {
3847
      if (nb[i] == l_path[j]) {                    /* v0.3k */
3847
      if (nb[i] == l_path[j]) {                    /* v0.3k */
3848
       new_atom = false;
3848
       new_atom = isfalse;
3849
       /* p2c: checkmol.pas, line 2982:
3849
       /* p2c: checkmol.pas, line 2982:
3850
       * Warning: Expected a '(', found a semicolon [227] */
3850
       * Warning: Expected a '(', found a semicolon [227] */
3851
       /* p2c: checkmol.pas, line 2982:
3851
       /* p2c: checkmol.pas, line 2982:
3852
       * Warning: Expected an expression, found a semicolon [227] */
3852
       * Warning: Expected an expression, found a semicolon [227] */
3853
       fflush (0);
3853
       fflush (0);
Line 3859... Line 3859...
3859
    if (new_atom && pl < max_vringsize && n_rings < max_rings) {
3859
    if (new_atom && pl < max_vringsize && n_rings < max_rings) {
3860
      l_path[pl] = nb[i];
3860
      l_path[pl] = nb[i];
3861
      if (pl < max_ringsize - 1)   /* just to be sure */
3861
      if (pl < max_ringsize - 1)   /* just to be sure */
3862
      l_path[pl + 1] = 0;
3862
      l_path[pl + 1] = 0;
3863
      if (is_ringpath (l_path))
3863
      if (is_ringpath (l_path))
3864
       rp = true;
3864
       rp = istrue;
3865
    }
3865
    }
3866
  }
3866
  }
3867
  return rp;
3867
  return rp;
3868
}
3868
}
3869
#endif
3869
#endif
3870
 
3870
 
3871
static boolean is_ringpath (int *s_path)
3871
static boolean is_ringpath (int *s_path)
3872
{
3872
{
3873
  int i, j;
3873
  int i, j;
3874
  neighbor_rec nb;
3874
  neighbor_rec nb;
3875
  boolean rp = false;
3875
  boolean rp = isfalse;
3876
  boolean new_atom;
3876
  boolean new_atom;
3877
  int a_last, pl;
3877
  int a_last, pl;
3878
  ringpath_type l_path;
3878
  ringpath_type l_path;
3879
  int FORLIM, pl_prev, pl_next, max_ringsize_dec;
3879
  int FORLIM, pl_prev, pl_next, max_ringsize_dec;
3880
 
3880
 
Line 3884... Line 3884...
3884
  pl = path_length (s_path);
3884
  pl = path_length (s_path);
3885
  if (pl < 1) {
3885
  if (pl < 1) {
3886
    /* p2c: checkmol.pas, line 2524:
3886
    /* p2c: checkmol.pas, line 2524:
3887
    * Note: Turbo Pascal conditional compilation directive was ignored [218] */
3887
    * Note: Turbo Pascal conditional compilation directive was ignored [218] */
3888
 
3888
 
3889
      return false;
3889
      return isfalse;
3890
    }
3890
    }
3891
 
3891
 
3892
  pl_prev = pl - 1;
3892
  pl_prev = pl - 1;
3893
  //memcpy (l_path, s_path, sizeof (ringpath_type));
3893
  //memcpy (l_path, s_path, sizeof (ringpath_type));
3894
  memcpy (l_path, s_path, pl * sizeof (int));
3894
  memcpy (l_path, s_path, pl * sizeof (int));
3895
 
3895
 
3896
  /* check if the last atom is a metal and stop if opt_metalrings is not set (v0.3) */
3896
  /* check if the last atom is a metal and stop if opt_metalrings is not set (v0.3) */
3897
  if (opt_metalrings == false) {
3897
  if (opt_metalrings == isfalse) {
3898
    if (atom[l_path[pl_prev] - 1].metal) {
3898
    if (atom[l_path[pl_prev] - 1].metal) {
3899
    /* p2c: checkmol.pas, line 2538:
3899
    /* p2c: checkmol.pas, line 2538:
3900
     * Note: Turbo Pascal conditional compilation directive was ignored [218] */
3900
     * Note: Turbo Pascal conditional compilation directive was ignored [218] */
3901
          return false;
3901
          return isfalse;
3902
          }
3902
          }
3903
  }
3903
  }
3904
  /* check if ring is already closed */
3904
  /* check if ring is already closed */
3905
  if (pl > 2 && l_path[pl_prev] == l_path[0]) {
3905
  if (pl > 2 && l_path[pl_prev] == l_path[0]) {
3906
    l_path[pl_prev] = 0;        /* remove last entry (redundant!) */
3906
    l_path[pl_prev] = 0;        /* remove last entry (redundant!) */
3907
    order_ringpath (l_path);
3907
    order_ringpath (l_path);
3908
    if (is_newring (l_path)) {
3908
    if (is_newring (l_path)) {
3909
            if (n_rings >= max_rings) {
3909
            if (n_rings >= max_rings) {
3910
        /* p2c: checkmol.pas, line 2554:
3910
        /* p2c: checkmol.pas, line 2554:
3911
        * Note: Turbo Pascal conditional compilation directive was ignored [218] */
3911
        * Note: Turbo Pascal conditional compilation directive was ignored [218] */
3912
              return false;
3912
              return isfalse;
3913
            }
3913
            }
3914
            add_ring (l_path);
3914
            add_ring (l_path);
3915
          }
3915
          }
3916
    /* p2c: checkmol.pas: Note: Eliminated unused assignment statement [338] */
3916
    /* p2c: checkmol.pas: Note: Eliminated unused assignment statement [338] */
3917
      return true;
3917
      return istrue;
3918
  }
3918
  }
3919
  /* any other case: ring is not (yet) closed */
3919
  /* any other case: ring is not (yet) closed */
3920
  a_last = l_path[pl_prev];
3920
  a_last = l_path[pl_prev];
3921
  get_neighbors (nb, a_last);
3921
  get_neighbors (nb, a_last);
3922
  if (atom[a_last - 1].neighbor_count <= 1)
3922
  if (atom[a_last - 1].neighbor_count <= 1)
3923
    return false;
3923
    return isfalse;
3924
  if (n_rings >= max_rings)
3924
  if (n_rings >= max_rings)
3925
    /* added in v0.2: check if max_rings is reached */ {                                /* if ring is not closed, continue searching */
3925
    /* added in v0.2: check if max_rings is reached */ {                                /* if ring is not closed, continue searching */
3926
    return false;
3926
    return isfalse;
3927
  }
3927
  }
3928
  FORLIM = atom[a_last - 1].neighbor_count;
3928
  FORLIM = atom[a_last - 1].neighbor_count;
3929
  pl_next = pl + 1;
3929
  pl_next = pl + 1;
3930
  max_ringsize_dec = max_ringsize - 1;
3930
  max_ringsize_dec = max_ringsize - 1;
3931
  for (i = 0; i < FORLIM; i++) {
3931
  for (i = 0; i < FORLIM; i++) {
3932
    new_atom = true;
3932
    new_atom = istrue;
3933
    for (j = 1; j < pl; j++) {
3933
    for (j = 1; j < pl; j++) {
3934
            if (nb[i] == l_path[j]) {
3934
            if (nb[i] == l_path[j]) {
3935
              new_atom = false;
3935
              new_atom = isfalse;
3936
              break;
3936
              break;
3937
            }
3937
            }
3938
          }
3938
          }
3939
    /* added in v0.1a: check if max_rings not yet reached */
3939
    /* added in v0.1a: check if max_rings not yet reached */
3940
    /* added in v0.2:  limit ring size to max_vringsize instead of max_ringsize */
3940
    /* added in v0.2:  limit ring size to max_vringsize instead of max_ringsize */
Line 3949... Line 3949...
3949
              if (opt_verbose)
3949
              if (opt_verbose)
3950
#endif
3950
#endif
3951
                    printf ("Warning: max. number of ringpath recursions (%i) reached\n",
3951
                    printf ("Warning: max. number of ringpath recursions (%i) reached\n",
3952
                    max_ringpath_recursion_depth);
3952
                    max_ringpath_recursion_depth);
3953
              n_rings = max_rings;
3953
              n_rings = max_rings;
3954
              return false;
3954
              return isfalse;
3955
            }
3955
            }
3956
 
3956
 
3957
            /*printf("%i\n",recursion_depth);
3957
            /*printf("%i\n",recursion_depth);
3958
            fflush(stdout);*/
3958
            fflush(stdout);*/
3959
 
3959
 
3960
            if (is_ringpath (l_path))
3960
            if (is_ringpath (l_path))
3961
              rp = true;
3961
              rp = istrue;
3962
            /*return true;*/
3962
            /*return istrue;*/
3963
          }
3963
          }
3964
  }
3964
  }
3965
  return rp;
3965
  return rp;
3966
}
3966
}
3967
 
3967
 
3968
static boolean is_ringbond (int b_id)
3968
static boolean is_ringbond (int b_id)
3969
{
3969
{
3970
  int i, ra1, ra2;
3970
  int i, ra1, ra2;
3971
  neighbor_rec nb;
3971
  neighbor_rec nb;
3972
  ringpath_type search_path;
3972
  ringpath_type search_path;
3973
  boolean rb = false;
3973
  boolean rb = isfalse;
3974
  int FORLIM;
3974
  int FORLIM;
3975
 
3975
 
3976
  recursion_depth = 0;
3976
  recursion_depth = 0;
3977
 
3977
 
3978
  ra1 = bond[b_id - 1].a1;
3978
  ra1 = bond[b_id - 1].a1;
3979
  ra2 = bond[b_id - 1].a2;
3979
  ra2 = bond[b_id - 1].a2;
3980
  memset (nb, 0, sizeof (neighbor_rec));
3980
  memset (nb, 0, sizeof (neighbor_rec));
3981
  memset (search_path, 0, sizeof (ringpath_type));
3981
  memset (search_path, 0, sizeof (ringpath_type));
3982
  get_neighbors (nb, ra2);
3982
  get_neighbors (nb, ra2);
3983
  if (atom[ra2 - 1].neighbor_count <= 1 || atom[ra1 - 1].neighbor_count <= 1)
3983
  if (atom[ra2 - 1].neighbor_count <= 1 || atom[ra1 - 1].neighbor_count <= 1)
3984
    return false;
3984
    return isfalse;
3985
  search_path[0] = ra1;
3985
  search_path[0] = ra1;
3986
  search_path[1] = ra2;
3986
  search_path[1] = ra2;
3987
  FORLIM = atom[ra2 - 1].neighbor_count;
3987
  FORLIM = atom[ra2 - 1].neighbor_count;
3988
  for (i = 0; i < FORLIM; i++) {
3988
  for (i = 0; i < FORLIM; i++) {
3989
    if (nb[i] != ra1 && atom[nb[i] - 1].heavy) {
3989
    if (nb[i] != ra1 && atom[nb[i] - 1].heavy) {
3990
            search_path[2] = nb[i];
3990
            search_path[2] = nb[i];
3991
            if (is_ringpath (search_path))
3991
            if (is_ringpath (search_path))
3992
              rb = true;
3992
              rb = istrue;
3993
            //return true;
3993
            //return istrue;
3994
          }
3994
          }
3995
  }
3995
  }
3996
  return rb;
3996
  return rb;
3997
}
3997
}
3998
 
3998
 
Line 4160... Line 4160...
4160
}
4160
}
4161
 
4161
 
4162
static boolean is_oxo_C (int id)
4162
static boolean is_oxo_C (int id)
4163
{
4163
{
4164
  int i;
4164
  int i;
4165
  boolean r = false;
4165
  boolean r = isfalse;
4166
  neighbor_rec nb;
4166
  neighbor_rec nb;
4167
  int FORLIM;
4167
  int FORLIM;
4168
 
4168
 
4169
  memset (nb, 0, sizeof (neighbor_rec));
4169
  memset (nb, 0, sizeof (neighbor_rec));
4170
  if (id < 1 || id > n_atoms)
4170
  if (id < 1 || id > n_atoms)
4171
    return false;
4171
    return isfalse;
4172
  get_neighbors (nb, id);
4172
  get_neighbors (nb, id);
4173
  if (strcmp (atom[id - 1].element, "C ") || atom[id - 1].neighbor_count <= 0)
4173
  if (strcmp (atom[id - 1].element, "C ") || atom[id - 1].neighbor_count <= 0)
4174
    return false;
4174
    return isfalse;
4175
  FORLIM = atom[id - 1].neighbor_count;
4175
  FORLIM = atom[id - 1].neighbor_count;
4176
  for (i = 0; i < FORLIM; i++) {
4176
  for (i = 0; i < FORLIM; i++) {
4177
    if (bond[get_bond (id, nb[i]) - 1].btype == 'D' &&
4177
    if (bond[get_bond (id, nb[i]) - 1].btype == 'D' &&
4178
              !strcmp (atom[nb[i] - 1].element, "O "))
4178
              !strcmp (atom[nb[i] - 1].element, "O "))
4179
            /* no N, amidines are different... */
4179
            /* no N, amidines are different... */
4180
            r = true;
4180
            r = istrue;
4181
      /* or
4181
      /* or
4182
         (atom^[(nb[i])].element = 'S ')  or
4182
         (atom^[(nb[i])].element = 'S ')  or
4183
         (atom^[(nb[i])].element = 'SE') */
4183
         (atom^[(nb[i])].element = 'SE') */
4184
  }
4184
  }
4185
  return r;
4185
  return r;
4186
}
4186
}
4187
 
4187
 
4188
static boolean is_thioxo_C (int id)
4188
static boolean is_thioxo_C (int id)
4189
{
4189
{
4190
  int i;
4190
  int i;
4191
  boolean r = false;
4191
  boolean r = isfalse;
4192
  neighbor_rec nb;
4192
  neighbor_rec nb;
4193
  int FORLIM;
4193
  int FORLIM;
4194
 
4194
 
4195
  memset (nb, 0, sizeof (neighbor_rec));
4195
  memset (nb, 0, sizeof (neighbor_rec));
4196
  if (id < 1 || id > n_atoms)
4196
  if (id < 1 || id > n_atoms)
4197
    return false;
4197
    return isfalse;
4198
  get_neighbors (nb, id);
4198
  get_neighbors (nb, id);
4199
  if (strcmp (atom[id - 1].element, "C ") || atom[id - 1].neighbor_count <= 0)
4199
  if (strcmp (atom[id - 1].element, "C ") || atom[id - 1].neighbor_count <= 0)
4200
    return false;
4200
    return isfalse;
4201
  FORLIM = atom[id - 1].neighbor_count;
4201
  FORLIM = atom[id - 1].neighbor_count;
4202
  for (i = 0; i < FORLIM; i++) {
4202
  for (i = 0; i < FORLIM; i++) {
4203
    if (bond[get_bond (id, nb[i]) - 1].btype == 'D' &&
4203
    if (bond[get_bond (id, nb[i]) - 1].btype == 'D' &&
4204
              (!strcmp (atom[nb[i] - 1].element, "S ") ||
4204
              (!strcmp (atom[nb[i] - 1].element, "S ") ||
4205
              !strcmp (atom[nb[i] - 1].element, "SE")))
4205
              !strcmp (atom[nb[i] - 1].element, "SE")))
4206
            /* no N, amidines are different... */
4206
            /* no N, amidines are different... */
4207
          r = true;
4207
          r = istrue;
4208
  }
4208
  }
4209
  return r;
4209
  return r;
4210
}
4210
}
4211
 
4211
 
4212
static boolean is_imino_C (int id)
4212
static boolean is_imino_C (int id)
4213
{
4213
{
4214
  int i;
4214
  int i;
4215
  boolean r = false;
4215
  boolean r = isfalse;
4216
  neighbor_rec nb;
4216
  neighbor_rec nb;
4217
  int FORLIM;
4217
  int FORLIM;
4218
 
4218
 
4219
  memset (nb, 0, sizeof (neighbor_rec));
4219
  memset (nb, 0, sizeof (neighbor_rec));
4220
  if (id < 1 || id > n_atoms)
4220
  if (id < 1 || id > n_atoms)
4221
    return false;
4221
    return isfalse;
4222
  get_neighbors (nb, id);
4222
  get_neighbors (nb, id);
4223
  if (strcmp (atom[id - 1].element, "C ") || atom[id - 1].neighbor_count <= 0)
4223
  if (strcmp (atom[id - 1].element, "C ") || atom[id - 1].neighbor_count <= 0)
4224
    return false;
4224
    return isfalse;
4225
  FORLIM = atom[id - 1].neighbor_count;
4225
  FORLIM = atom[id - 1].neighbor_count;
4226
  for (i = 0; i < FORLIM; i++) {
4226
  for (i = 0; i < FORLIM; i++) {
4227
    if (bond[get_bond (id, nb[i]) - 1].btype == 'D' &&
4227
    if (bond[get_bond (id, nb[i]) - 1].btype == 'D' &&
4228
              !strcmp (atom[nb[i] - 1].element, "N "))
4228
              !strcmp (atom[nb[i] - 1].element, "N "))
4229
            r = true;
4229
            r = istrue;
4230
  }
4230
  }
4231
  return r;
4231
  return r;
4232
}
4232
}
4233
 
4233
 
4234
static boolean is_true_imino_C (int id)
4234
static boolean is_istrue_imino_C (int id)
4235
{
4235
{
4236
  int i;
4236
  int i;
4237
  boolean r = true;
4237
  boolean r = istrue;
4238
  neighbor_rec nb;
4238
  neighbor_rec nb;
4239
  str2 nb_el;
4239
  str2 nb_el;
4240
  int a_n = 0;
4240
  int a_n = 0;
4241
  int b;                        /* v0.3j */
4241
  int b;                        /* v0.3j */
4242
  int FORLIM;
4242
  int FORLIM;
4243
 
4243
 
4244
/* p2c: checkmol.pas: Note: Eliminated unused assignment statement [338] */
4244
/* p2c: checkmol.pas: Note: Eliminated unused assignment statement [338] */
4245
  memset (nb, 0, sizeof (neighbor_rec));
4245
  memset (nb, 0, sizeof (neighbor_rec));
4246
  if (id < 1 || id > n_atoms)
4246
  if (id < 1 || id > n_atoms)
4247
    return false;
4247
    return isfalse;
4248
  get_neighbors (nb, id);
4248
  get_neighbors (nb, id);
4249
  if (strcmp (atom[id - 1].element, "C ") || atom[id - 1].neighbor_count <= 0)
4249
  if (strcmp (atom[id - 1].element, "C ") || atom[id - 1].neighbor_count <= 0)
4250
    return false;
4250
    return isfalse;
4251
  FORLIM = atom[id - 1].neighbor_count;
4251
  FORLIM = atom[id - 1].neighbor_count;
4252
  for (i = 0; i < FORLIM; i++) {
4252
  for (i = 0; i < FORLIM; i++) {
4253
    b = get_bond (id, nb[i]);   /* v0.3j */
4253
    b = get_bond (id, nb[i]);   /* v0.3j */
4254
    if (bond[b - 1].btype == 'D' && bond[b - 1].arom == false &&
4254
    if (bond[b - 1].btype == 'D' && bond[b - 1].arom == isfalse &&
4255
              !strcmp (atom[nb[i] - 1].element, "N "))
4255
              !strcmp (atom[nb[i] - 1].element, "N "))
4256
        /* v0.3j */
4256
        /* v0.3j */
4257
            a_n = nb[i];
4257
            a_n = nb[i];
4258
  }
4258
  }
4259
  if (a_n <= 0)
4259
  if (a_n <= 0)
4260
    return false;
4260
    return isfalse;
4261
  memset (nb, 0, sizeof (neighbor_rec));
4261
  memset (nb, 0, sizeof (neighbor_rec));
4262
  get_neighbors (nb, a_n);
4262
  get_neighbors (nb, a_n);
4263
  FORLIM = atom[a_n - 1].neighbor_count;
4263
  FORLIM = atom[a_n - 1].neighbor_count;
4264
  for (i = 0; i < FORLIM; i++) {
4264
  for (i = 0; i < FORLIM; i++) {
4265
    strcpy (nb_el, atom[nb[i] - 1].element);
4265
    strcpy (nb_el, atom[nb[i] - 1].element);
4266
    if (strcmp (nb_el, "C ") && strcmp (nb_el, "H ")
4266
    if (strcmp (nb_el, "C ") && strcmp (nb_el, "H ")
4267
            /*&&  strcmp (nb_el, "D ") */ )
4267
            /*&&  strcmp (nb_el, "D ") */ )
4268
            /* v0.3n: D */
4268
            /* v0.3n: D */
4269
            r = false;
4269
            r = isfalse;
4270
  }
4270
  }
4271
  return r;
4271
  return r;
4272
}
4272
}
4273
 
4273
 
4274
static boolean is_true_exocyclic_imino_C (int id, int r_id)
4274
static boolean is_istrue_exocyclic_imino_C (int id, int r_id)
4275
{
4275
{
4276
  /* v0.3j */
4276
  /* v0.3j */
4277
  int i, j;
4277
  int i, j;
4278
  boolean r = false;
4278
  boolean r = isfalse;
4279
  neighbor_rec nb;
4279
  neighbor_rec nb;
4280
  ringpath_type testring;
4280
  ringpath_type testring;
4281
  int ring_size, b, FORLIM;
4281
  int ring_size, b, FORLIM;
4282
 
4282
 
4283
  memset (nb, 0, sizeof (neighbor_rec));
4283
  memset (nb, 0, sizeof (neighbor_rec));
4284
  if (id < 1 || id > n_atoms)
4284
  if (id < 1 || id > n_atoms)
4285
    return false;
4285
    return isfalse;
4286
  get_neighbors (nb, id);
4286
  get_neighbors (nb, id);
4287
  memset (testring, 0, sizeof (ringpath_type));
4287
  memset (testring, 0, sizeof (ringpath_type));
4288
  ring_size = ringprop[r_id - 1].size;  /* v0.3j */
4288
  ring_size = ringprop[r_id - 1].size;  /* v0.3j */
4289
  for (j = 0; j < ring_size; j++)       /* v0.3j */
4289
  for (j = 0; j < ring_size; j++)       /* v0.3j */
4290
    testring[j] = ring[r_id - 1][j];
4290
    testring[j] = ring[r_id - 1][j];
4291
  if (strcmp (atom[id - 1].element, "C ") || atom[id - 1].neighbor_count <= 0)
4291
  if (strcmp (atom[id - 1].element, "C ") || atom[id - 1].neighbor_count <= 0)
4292
    return false;
4292
    return isfalse;
4293
  FORLIM = atom[id - 1].neighbor_count;
4293
  FORLIM = atom[id - 1].neighbor_count;
4294
  for (i = 0; i < FORLIM; i++) {
4294
  for (i = 0; i < FORLIM; i++) {
4295
    b = get_bond (id, nb[i]);
4295
    b = get_bond (id, nb[i]);
4296
    if (bond[b - 1].btype == 'D' && bond[b - 1].arom == false &&
4296
    if (bond[b - 1].btype == 'D' && bond[b - 1].arom == isfalse &&
4297
              !strcmp (atom[nb[i] - 1].element, "N ")) {
4297
              !strcmp (atom[nb[i] - 1].element, "N ")) {
4298
            r = true;
4298
            r = istrue;
4299
            for (j = 0; j < ring_size; j++) {
4299
            for (j = 0; j < ring_size; j++) {
4300
              if (nb[i] == ring[r_id - 1][j])
4300
              if (nb[i] == ring[r_id - 1][j])
4301
                      r = false;
4301
                      r = isfalse;
4302
            }
4302
            }
4303
          }
4303
          }
4304
  }
4304
  }
4305
  return r;
4305
  return r;
4306
}
4306
}
4307
 
4307
 
4308
static boolean is_exocyclic_imino_C (int id, int r_id)
4308
static boolean is_exocyclic_imino_C (int id, int r_id)
4309
{
4309
{
4310
  int i, j;
4310
  int i, j;
4311
  boolean r = false;
4311
  boolean r = isfalse;
4312
  neighbor_rec nb;
4312
  neighbor_rec nb;
4313
  ringpath_type testring;
4313
  ringpath_type testring;
4314
  int ring_size, FORLIM;
4314
  int ring_size, FORLIM;
4315
 
4315
 
4316
  memset (nb, 0, sizeof (neighbor_rec));
4316
  memset (nb, 0, sizeof (neighbor_rec));
4317
  if (id < 1 || id > n_atoms)
4317
  if (id < 1 || id > n_atoms)
4318
    return false;
4318
    return isfalse;
4319
  get_neighbors (nb, id);
4319
  get_neighbors (nb, id);
4320
  memset (testring, 0, sizeof (ringpath_type));
4320
  memset (testring, 0, sizeof (ringpath_type));
4321
  ring_size = ringprop[r_id - 1].size;  /* v0.3j */
4321
  ring_size = ringprop[r_id - 1].size;  /* v0.3j */
4322
  for (j = 0; j < ring_size; j++)       /* v0.3j */
4322
  for (j = 0; j < ring_size; j++)       /* v0.3j */
4323
    testring[j] = ring[r_id - 1][j];
4323
    testring[j] = ring[r_id - 1][j];
4324
  if (strcmp (atom[id - 1].element, "C ") || atom[id - 1].neighbor_count <= 0)
4324
  if (strcmp (atom[id - 1].element, "C ") || atom[id - 1].neighbor_count <= 0)
4325
    return false;
4325
    return isfalse;
4326
  FORLIM = atom[id - 1].neighbor_count;
4326
  FORLIM = atom[id - 1].neighbor_count;
4327
  for (i = 0; i < FORLIM; i++) {
4327
  for (i = 0; i < FORLIM; i++) {
4328
    if (bond[get_bond (id, nb[i]) - 1].btype == 'D' &&
4328
    if (bond[get_bond (id, nb[i]) - 1].btype == 'D' &&
4329
              !strcmp (atom[nb[i] - 1].element, "N ")) {
4329
              !strcmp (atom[nb[i] - 1].element, "N ")) {
4330
            r = true;
4330
            r = istrue;
4331
            for (j = 0; j < ring_size; j++) {
4331
            for (j = 0; j < ring_size; j++) {
4332
              if (nb[i] == ring[r_id - 1][j])
4332
              if (nb[i] == ring[r_id - 1][j])
4333
                      r = false;
4333
                      r = isfalse;
4334
            }
4334
            }
4335
          }
4335
          }
4336
  }
4336
  }
4337
  return r;
4337
  return r;
4338
}
4338
}
Line 4370... Line 4370...
4370
  return r;
4370
  return r;
4371
}
4371
}
4372
 
4372
 
4373
static boolean is_hydroxy (int a_view, int a_ref)
4373
static boolean is_hydroxy (int a_view, int a_ref)
4374
{
4374
{
4375
  boolean r = false;
4375
  boolean r = isfalse;
4376
 
4376
 
4377
  if (atom[a_view - 1]. heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')) {
4377
  if (atom[a_view - 1]. heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')) {
4378
    if (!strcmp (atom[a_ref - 1].atype, "O3 ") &&
4378
    if (!strcmp (atom[a_ref - 1].atype, "O3 ") &&
4379
              atom[a_ref - 1].neighbor_count == 1)
4379
              atom[a_ref - 1].neighbor_count == 1)
4380
            r = true;
4380
            r = istrue;
4381
  }
4381
  }
4382
  return r;
4382
  return r;
4383
}
4383
}
4384
 
4384
 
4385
static boolean is_sulfanyl (int a_view, int a_ref)
4385
static boolean is_sulfanyl (int a_view, int a_ref)
4386
{
4386
{
4387
  boolean r = false;
4387
  boolean r = isfalse;
4388
 
4388
 
4389
  if (atom[a_view - 1].
4389
  if (atom[a_view - 1].
4390
      heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')) {
4390
      heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')) {
4391
    if (!strcmp (atom[a_ref - 1].atype, "S3 ") &&
4391
    if (!strcmp (atom[a_ref - 1].atype, "S3 ") &&
4392
              atom[a_ref - 1].neighbor_count == 1)
4392
              atom[a_ref - 1].neighbor_count == 1)
4393
            r = true;
4393
            r = istrue;
4394
  }
4394
  }
4395
  return r;
4395
  return r;
4396
}
4396
}
4397
 
4397
 
4398
static boolean is_amino (int a_view, int a_ref)
4398
static boolean is_amino (int a_view, int a_ref)
4399
{
4399
{
4400
  boolean r = false;
4400
  boolean r = isfalse;
4401
 
4401
 
4402
  if (atom[a_view - 1].
4402
  if (atom[a_view - 1].
4403
      heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')) {
4403
      heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')) {
4404
    if ((!strcmp (atom[a_ref - 1].atype, "N3 ") ||
4404
    if ((!strcmp (atom[a_ref - 1].atype, "N3 ") ||
4405
              !strcmp (atom[a_ref - 1].atype, "N3+")) &&
4405
              !strcmp (atom[a_ref - 1].atype, "N3+")) &&
4406
              atom[a_ref - 1].neighbor_count == 1)
4406
              atom[a_ref - 1].neighbor_count == 1)
4407
            r = true;
4407
            r = istrue;
4408
    }
4408
    }
4409
  return r;
4409
  return r;
4410
}
4410
}
4411
 
4411
 
4412
static boolean is_alkyl (int a_view, int a_ref)
4412
static boolean is_alkyl (int a_view, int a_ref)
4413
{
4413
{
4414
  int i;
4414
  int i;
4415
  boolean r = false;
4415
  boolean r = isfalse;
4416
  neighbor_rec nb;
4416
  neighbor_rec nb;
4417
  str2 nb_el;
4417
  str2 nb_el;
4418
  int het_count = 0;
4418
  int het_count = 0;
4419
  int FORLIM;
4419
  int FORLIM;
4420
 
4420
 
4421
  memset (nb, 0, sizeof (neighbor_rec));
4421
  memset (nb, 0, sizeof (neighbor_rec));
4422
  if (! (atom[a_view - 1].
4422
  if (! (atom[a_view - 1].
4423
      heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S'))
4423
      heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S'))
4424
      || strcmp (atom[a_ref - 1].atype, "C3 ")
4424
      || strcmp (atom[a_ref - 1].atype, "C3 ")
4425
      || atom[a_ref - 1].arom != false)
4425
      || atom[a_ref - 1].arom != isfalse)
4426
    return false;
4426
    return isfalse;
4427
  get_nextneighbors (nb, a_ref, a_view);
4427
  get_nextneighbors (nb, a_ref, a_view);
4428
  FORLIM = atom[a_ref - 1].neighbor_count - 2;
4428
  FORLIM = atom[a_ref - 1].neighbor_count - 2;
4429
  for (i = 0; i <= FORLIM; i++) {
4429
  for (i = 0; i <= FORLIM; i++) {
4430
    strcpy (nb_el, atom[nb[i] - 1].element);
4430
    strcpy (nb_el, atom[nb[i] - 1].element);
4431
    if (strcmp (nb_el, "C ") && strcmp (nb_el, "H ")
4431
    if (strcmp (nb_el, "C ") && strcmp (nb_el, "H ")
Line 4433... Line 4433...
4433
              && strcmp (nb_el, "LP"))
4433
              && strcmp (nb_el, "LP"))
4434
            /* added 'D ' in v0.3n */
4434
            /* added 'D ' in v0.3n */
4435
            het_count++;
4435
            het_count++;
4436
  }
4436
  }
4437
  if (het_count <= 1)           /* we consider (e.g.) alkoxyalkyl groups as alkyl */
4437
  if (het_count <= 1)           /* we consider (e.g.) alkoxyalkyl groups as alkyl */
4438
    r = true;
4438
    r = istrue;
4439
  return r;
4439
  return r;
4440
}
4440
}
4441
 
4441
 
4442
static boolean is_true_alkyl (int a_view, int a_ref)
4442
static boolean is_istrue_alkyl (int a_view, int a_ref)
4443
{
4443
{
4444
  int i;
4444
  int i;
4445
  boolean r = false;
4445
  boolean r = isfalse;
4446
  neighbor_rec nb;
4446
  neighbor_rec nb;
4447
  str2 nb_el;
4447
  str2 nb_el;
4448
  int het_count = 0;
4448
  int het_count = 0;
4449
  int FORLIM;
4449
  int FORLIM;
4450
 
4450
 
4451
  memset (nb, 0, sizeof (neighbor_rec));
4451
  memset (nb, 0, sizeof (neighbor_rec));
4452
  if (!(atom[a_view - 1].
4452
  if (!(atom[a_view - 1].
4453
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S'))
4453
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S'))
4454
      || strcmp (atom[a_ref - 1].atype, "C3 ")
4454
      || strcmp (atom[a_ref - 1].atype, "C3 ")
4455
      || atom[a_ref - 1].arom != false)
4455
      || atom[a_ref - 1].arom != isfalse)
4456
    return false;
4456
    return isfalse;
4457
  get_nextneighbors (nb, a_ref, a_view);
4457
  get_nextneighbors (nb, a_ref, a_view);
4458
  FORLIM = atom[a_ref - 1].neighbor_count - 2;
4458
  FORLIM = atom[a_ref - 1].neighbor_count - 2;
4459
  for (i = 0; i <= FORLIM; i++) {
4459
  for (i = 0; i <= FORLIM; i++) {
4460
    strcpy (nb_el, atom[nb[i] - 1].element);
4460
    strcpy (nb_el, atom[nb[i] - 1].element);
4461
    if (strcmp (nb_el, "C ") && strcmp (nb_el, "H ")
4461
    if (strcmp (nb_el, "C ") && strcmp (nb_el, "H ")
4462
             /*&&  strcmp (nb_el, "D ") */  && strcmp (nb_el, "DU"))
4462
             /*&&  strcmp (nb_el, "D ") */  && strcmp (nb_el, "DU"))
4463
             /* added 'D ' in v0.3n */
4463
             /* added 'D ' in v0.3n */
4464
             het_count++;
4464
             het_count++;
4465
  }
4465
  }
4466
  if (het_count == 0)           /* */
4466
  if (het_count == 0)           /* */
4467
    r = true;
4467
    r = istrue;
4468
  return r;
4468
  return r;
4469
}
4469
}
4470
 
4470
 
4471
static boolean is_alkenyl (int a_view, int a_ref)
4471
static boolean is_alkenyl (int a_view, int a_ref)
4472
{
4472
{
4473
  /* new in v0.3j */
4473
  /* new in v0.3j */
4474
  int i;
4474
  int i;
4475
  boolean r = false;
4475
  boolean r = isfalse;
4476
  neighbor_rec nb;
4476
  neighbor_rec nb;
4477
  str2 nb_el;
4477
  str2 nb_el;
4478
  str3 nb_at;
4478
  str3 nb_at;
4479
  int c2_count = 0, het_count = 0;
4479
  int c2_count = 0, het_count = 0;
4480
  int FORLIM;
4480
  int FORLIM;
4481
 
4481
 
4482
  memset (nb, 0, sizeof (neighbor_rec));
4482
  memset (nb, 0, sizeof (neighbor_rec));
4483
  if (! (atom[a_view - 1].
4483
  if (! (atom[a_view - 1].
4484
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S'))
4484
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S'))
4485
      || strcmp (atom[a_ref - 1].atype, "C2 ")
4485
      || strcmp (atom[a_ref - 1].atype, "C2 ")
4486
      || atom[a_ref - 1].arom != false) {
4486
      || atom[a_ref - 1].arom != isfalse) {
4487
    return false;
4487
    return isfalse;
4488
  }                             /* v0.3k: changed c2_count = 1 into c2_count >= 1 */
4488
  }                             /* v0.3k: changed c2_count = 1 into c2_count >= 1 */
4489
  get_nextneighbors (nb, a_ref, a_view);
4489
  get_nextneighbors (nb, a_ref, a_view);
4490
  FORLIM = atom[a_ref - 1].neighbor_count - 2;
4490
  FORLIM = atom[a_ref - 1].neighbor_count - 2;
4491
  for (i = 0; i <= FORLIM; i++) {
4491
  for (i = 0; i <= FORLIM; i++) {
4492
    strcpy (nb_el, atom[nb[i] - 1].element);
4492
    strcpy (nb_el, atom[nb[i] - 1].element);
Line 4499... Line 4499...
4499
    if (!strcmp (nb_at, "C2 "))
4499
    if (!strcmp (nb_at, "C2 "))
4500
            c2_count++;
4500
            c2_count++;
4501
  }
4501
  }
4502
  if (c2_count >= 1 && het_count <= 1)
4502
  if (c2_count >= 1 && het_count <= 1)
4503
    /* we consider (e.g.) alkoxyalkenyl groups as alkenyl */
4503
    /* we consider (e.g.) alkoxyalkenyl groups as alkenyl */
4504
    r = true;
4504
    r = istrue;
4505
  return r;
4505
  return r;
4506
}
4506
}
4507
 
4507
 
4508
static boolean is_alkynyl (int a_view, int a_ref)
4508
static boolean is_alkynyl (int a_view, int a_ref)
4509
{
4509
{
4510
  /* new in v0.3j */
4510
  /* new in v0.3j */
4511
  int i;
4511
  int i;
4512
  boolean r = false;
4512
  boolean r = isfalse;
4513
  neighbor_rec nb;
4513
  neighbor_rec nb;
4514
  str3 nb_at;
4514
  str3 nb_at;
4515
  int c1_count = 0;
4515
  int c1_count = 0;
4516
  int FORLIM;
4516
  int FORLIM;
4517
 
4517
 
4518
  memset (nb, 0, sizeof (neighbor_rec));
4518
  memset (nb, 0, sizeof (neighbor_rec));
4519
  if (!(atom[a_view - 1].
4519
  if (!(atom[a_view - 1].
4520
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S'))
4520
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S'))
4521
      || strcmp (atom[a_ref - 1].atype, "C1 ")
4521
      || strcmp (atom[a_ref - 1].atype, "C1 ")
4522
      || atom[a_ref - 1].arom != false)
4522
      || atom[a_ref - 1].arom != isfalse)
4523
    return false;
4523
    return isfalse;
4524
  get_nextneighbors (nb, a_ref, a_view);
4524
  get_nextneighbors (nb, a_ref, a_view);
4525
  FORLIM = atom[a_ref - 1].neighbor_count - 2;
4525
  FORLIM = atom[a_ref - 1].neighbor_count - 2;
4526
  for (i = 0; i <= FORLIM; i++) {
4526
  for (i = 0; i <= FORLIM; i++) {
4527
    strcpy (nb_at, atom[nb[i] - 1].atype);
4527
    strcpy (nb_at, atom[nb[i] - 1].atype);
4528
    if (!strcmp (nb_at, "C1 "))
4528
    if (!strcmp (nb_at, "C1 "))
4529
            c1_count++;
4529
            c1_count++;
4530
  }
4530
  }
4531
  if (c1_count == 1)
4531
  if (c1_count == 1)
4532
    r = true;
4532
    r = istrue;
4533
  return r;
4533
  return r;
4534
}
4534
}
4535
 
4535
 
4536
static boolean is_aryl (int a_view, int a_ref)
4536
static boolean is_aryl (int a_view, int a_ref)
4537
{
4537
{
4538
  boolean r = false;
4538
  boolean r = isfalse;
4539
 
4539
 
4540
  if ((atom[a_view - 1].
4540
  if ((atom[a_view - 1].
4541
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S'))
4541
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S'))
4542
      && !strcmp (atom[a_ref - 1].element, "C ")
4542
      && !strcmp (atom[a_ref - 1].element, "C ")
4543
      && atom[a_ref - 1].arom == true)
4543
      && atom[a_ref - 1].arom == istrue)
4544
    r = true;
4544
    r = istrue;
4545
  return r;
4545
  return r;
4546
}
4546
}
4547
 
4547
 
4548
static boolean is_alkoxy (int a_view, int a_ref)
4548
static boolean is_alkoxy (int a_view, int a_ref)
4549
{
4549
{
4550
  boolean r = false;
4550
  boolean r = isfalse;
4551
  neighbor_rec nb;
4551
  neighbor_rec nb;
4552
 
4552
 
4553
  memset (nb, 0, sizeof (neighbor_rec));
4553
  memset (nb, 0, sizeof (neighbor_rec));
4554
  if (!(atom[a_view - 1].
4554
  if (!(atom[a_view - 1].
4555
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
4555
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
4556
    return false;
4556
    return isfalse;
4557
  if (strcmp (atom[a_ref - 1].atype, "O3 ")
4557
  if (strcmp (atom[a_ref - 1].atype, "O3 ")
4558
      || atom[a_ref - 1].neighbor_count != 2)
4558
      || atom[a_ref - 1].neighbor_count != 2)
4559
    return false;
4559
    return isfalse;
4560
  get_nextneighbors (nb, a_ref, a_view);
4560
  get_nextneighbors (nb, a_ref, a_view);
4561
  if (is_alkyl (a_ref, nb[0]))
4561
  if (is_alkyl (a_ref, nb[0]))
4562
    r = true;
4562
    r = istrue;
4563
  return r;
4563
  return r;
4564
}
4564
}
4565
 
4565
 
4566
static boolean is_siloxy (int a_view, int a_ref)
4566
static boolean is_siloxy (int a_view, int a_ref)
4567
{
4567
{
4568
  boolean r = false;
4568
  boolean r = isfalse;
4569
  neighbor_rec nb;
4569
  neighbor_rec nb;
4570
 
4570
 
4571
  memset (nb, 0, sizeof (neighbor_rec));
4571
  memset (nb, 0, sizeof (neighbor_rec));
4572
  if (!(atom[a_view - 1].
4572
  if (!(atom[a_view - 1].
4573
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
4573
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
4574
    return false;
4574
    return isfalse;
4575
  if (strcmp (atom[a_ref - 1].atype, "O3 ")
4575
  if (strcmp (atom[a_ref - 1].atype, "O3 ")
4576
      || atom[a_ref - 1].neighbor_count != 2)
4576
      || atom[a_ref - 1].neighbor_count != 2)
4577
    return false;
4577
    return isfalse;
4578
  get_nextneighbors (nb, a_ref, a_view);
4578
  get_nextneighbors (nb, a_ref, a_view);
4579
  if (!strcmp (atom[nb[0] - 1].element, "SI"))
4579
  if (!strcmp (atom[nb[0] - 1].element, "SI"))
4580
    r = true;
4580
    r = istrue;
4581
  return r;
4581
  return r;
4582
}
4582
}
4583
 
4583
 
4584
static boolean is_true_alkoxy (int a_view, int a_ref)
4584
static boolean is_istrue_alkoxy (int a_view, int a_ref)
4585
{
4585
{
4586
  boolean r = false;
4586
  boolean r = isfalse;
4587
  neighbor_rec nb;
4587
  neighbor_rec nb;
4588
 
4588
 
4589
  memset (nb, 0, sizeof (neighbor_rec));
4589
  memset (nb, 0, sizeof (neighbor_rec));
4590
  if (!(atom[a_view - 1].
4590
  if (!(atom[a_view - 1].
4591
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
4591
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
4592
    return false;
4592
    return isfalse;
4593
  if (strcmp (atom[a_ref - 1].atype, "O3 ")
4593
  if (strcmp (atom[a_ref - 1].atype, "O3 ")
4594
      || atom[a_ref - 1].neighbor_count != 2)
4594
      || atom[a_ref - 1].neighbor_count != 2)
4595
    return false;
4595
    return isfalse;
4596
  get_nextneighbors (nb, a_ref, a_view);
4596
  get_nextneighbors (nb, a_ref, a_view);
4597
  if (is_true_alkyl (a_ref, nb[0]))
4597
  if (is_istrue_alkyl (a_ref, nb[0]))
4598
    r = true;
4598
    r = istrue;
4599
  return r;
4599
  return r;
4600
}
4600
}
4601
 
4601
 
4602
static boolean is_aryloxy (int a_view, int a_ref)
4602
static boolean is_aryloxy (int a_view, int a_ref)
4603
{
4603
{
4604
  boolean r = false;
4604
  boolean r = isfalse;
4605
  neighbor_rec nb;
4605
  neighbor_rec nb;
4606
 
4606
 
4607
  memset (nb, 0, sizeof (neighbor_rec));
4607
  memset (nb, 0, sizeof (neighbor_rec));
4608
  if (!(atom[a_view - 1].
4608
  if (!(atom[a_view - 1].
4609
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
4609
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
4610
    return false;
4610
    return isfalse;
4611
  if (strcmp (atom[a_ref - 1].atype, "O3 ")
4611
  if (strcmp (atom[a_ref - 1].atype, "O3 ")
4612
      || atom[a_ref - 1].neighbor_count != 2)
4612
      || atom[a_ref - 1].neighbor_count != 2)
4613
    return false;
4613
    return isfalse;
4614
  get_nextneighbors (nb, a_ref, a_view);
4614
  get_nextneighbors (nb, a_ref, a_view);
4615
  if (is_aryl (a_ref, nb[0]))
4615
  if (is_aryl (a_ref, nb[0]))
4616
    r = true;
4616
    r = istrue;
4617
  return r;
4617
  return r;
4618
}
4618
}
4619
 
4619
 
4620
static boolean is_alkenyloxy (int a_view, int a_ref) {
4620
static boolean is_alkenyloxy (int a_view, int a_ref) {
4621
  /* v0.3j */
4621
  /* v0.3j */
4622
  boolean r = false;
4622
  boolean r = isfalse;
4623
  neighbor_rec nb;
4623
  neighbor_rec nb;
4624
 
4624
 
4625
  memset (nb, 0, sizeof (neighbor_rec));
4625
  memset (nb, 0, sizeof (neighbor_rec));
4626
  if (!(atom[a_view - 1].
4626
  if (!(atom[a_view - 1].
4627
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
4627
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
4628
    return false;
4628
    return isfalse;
4629
  if (strcmp (atom[a_ref - 1].atype, "O3 ")
4629
  if (strcmp (atom[a_ref - 1].atype, "O3 ")
4630
      || atom[a_ref - 1].neighbor_count != 2)
4630
      || atom[a_ref - 1].neighbor_count != 2)
4631
    return false;
4631
    return isfalse;
4632
  get_nextneighbors (nb, a_ref, a_view);
4632
  get_nextneighbors (nb, a_ref, a_view);
4633
  if (is_alkenyl (a_ref, nb[0]))
4633
  if (is_alkenyl (a_ref, nb[0]))
4634
    r = true;
4634
    r = istrue;
4635
  return r;
4635
  return r;
4636
}
4636
}
4637
 
4637
 
4638
static boolean is_alkynyloxy (int a_view, int a_ref)
4638
static boolean is_alkynyloxy (int a_view, int a_ref)
4639
{
4639
{
4640
  /* v0.3j */
4640
  /* v0.3j */
4641
  boolean r = false;
4641
  boolean r = isfalse;
4642
  neighbor_rec nb;
4642
  neighbor_rec nb;
4643
 
4643
 
4644
  memset (nb, 0, sizeof (neighbor_rec));
4644
  memset (nb, 0, sizeof (neighbor_rec));
4645
  if (!(atom[a_view - 1].
4645
  if (!(atom[a_view - 1].
4646
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
4646
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
4647
    return false;
4647
    return isfalse;
4648
  if (strcmp (atom[a_ref - 1].atype, "O3 ")
4648
  if (strcmp (atom[a_ref - 1].atype, "O3 ")
4649
      || atom[a_ref - 1].neighbor_count != 2)
4649
      || atom[a_ref - 1].neighbor_count != 2)
4650
    return false;
4650
    return isfalse;
4651
  get_nextneighbors (nb, a_ref, a_view);
4651
  get_nextneighbors (nb, a_ref, a_view);
4652
  if (is_alkynyl (a_ref, nb[0]))
4652
  if (is_alkynyl (a_ref, nb[0]))
4653
    r = true;
4653
    r = istrue;
4654
  return r;
4654
  return r;
4655
}
4655
}
4656
 
4656
 
4657
static boolean is_alkylsulfanyl (int a_view, int a_ref)
4657
static boolean is_alkylsulfanyl (int a_view, int a_ref)
4658
{
4658
{
4659
  boolean r = false;
4659
  boolean r = isfalse;
4660
  neighbor_rec nb;
4660
  neighbor_rec nb;
4661
 
4661
 
4662
  memset (nb, 0, sizeof (neighbor_rec));
4662
  memset (nb, 0, sizeof (neighbor_rec));
4663
  if (!(atom[a_view - 1].
4663
  if (!(atom[a_view - 1].
4664
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
4664
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
4665
    return false;
4665
    return isfalse;
4666
  if (strcmp (atom[a_ref - 1].atype, "S3 ")
4666
  if (strcmp (atom[a_ref - 1].atype, "S3 ")
4667
      || atom[a_ref - 1].neighbor_count != 2)
4667
      || atom[a_ref - 1].neighbor_count != 2)
4668
    return false;
4668
    return isfalse;
4669
  get_nextneighbors (nb, a_ref, a_view);
4669
  get_nextneighbors (nb, a_ref, a_view);
4670
  if (is_alkyl (a_ref, nb[0]))
4670
  if (is_alkyl (a_ref, nb[0]))
4671
    r = true;
4671
    r = istrue;
4672
  return r;
4672
  return r;
4673
}
4673
}
4674
 
4674
 
4675
static boolean is_true_alkylsulfanyl (int a_view, int a_ref)
4675
static boolean is_istrue_alkylsulfanyl (int a_view, int a_ref)
4676
{
4676
{
4677
  boolean r = false;
4677
  boolean r = isfalse;
4678
  neighbor_rec nb;
4678
  neighbor_rec nb;
4679
 
4679
 
4680
  memset (nb, 0, sizeof (neighbor_rec));
4680
  memset (nb, 0, sizeof (neighbor_rec));
4681
  if (!(atom[a_view - 1].
4681
  if (!(atom[a_view - 1].
4682
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
4682
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
4683
    return false;
4683
    return isfalse;
4684
  if (strcmp (atom[a_ref - 1].atype, "S3 ")
4684
  if (strcmp (atom[a_ref - 1].atype, "S3 ")
4685
      || atom[a_ref - 1].neighbor_count != 2)
4685
      || atom[a_ref - 1].neighbor_count != 2)
4686
    return false;
4686
    return isfalse;
4687
  get_nextneighbors (nb, a_ref, a_view);
4687
  get_nextneighbors (nb, a_ref, a_view);
4688
  if (is_true_alkyl (a_ref, nb[0]))
4688
  if (is_istrue_alkyl (a_ref, nb[0]))
4689
    r = true;
4689
    r = istrue;
4690
  return r;
4690
  return r;
4691
}
4691
}
4692
 
4692
 
4693
static boolean is_arylsulfanyl (int a_view, int a_ref)
4693
static boolean is_arylsulfanyl (int a_view, int a_ref)
4694
{
4694
{
4695
  boolean r = false;
4695
  boolean r = isfalse;
4696
  neighbor_rec nb;
4696
  neighbor_rec nb;
4697
 
4697
 
4698
  memset (nb, 0, sizeof (neighbor_rec));
4698
  memset (nb, 0, sizeof (neighbor_rec));
4699
  if (!(atom[a_view - 1].
4699
  if (!(atom[a_view - 1].
4700
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
4700
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
4701
    return false;
4701
    return isfalse;
4702
  if (strcmp (atom[a_ref - 1].atype, "S3 ")
4702
  if (strcmp (atom[a_ref - 1].atype, "S3 ")
4703
      || atom[a_ref - 1].neighbor_count != 2)
4703
      || atom[a_ref - 1].neighbor_count != 2)
4704
    return false;
4704
    return isfalse;
4705
  get_nextneighbors (nb, a_ref, a_view);
4705
  get_nextneighbors (nb, a_ref, a_view);
4706
  if (is_aryl (a_ref, nb[0]))
4706
  if (is_aryl (a_ref, nb[0]))
4707
    r = true;
4707
    r = istrue;
4708
  return r;
4708
  return r;
4709
}
4709
}
4710
 
4710
 
4711
static boolean is_alkenylsulfanyl (int a_view, int a_ref)
4711
static boolean is_alkenylsulfanyl (int a_view, int a_ref)
4712
{
4712
{
4713
  /* v0.3j */
4713
  /* v0.3j */
4714
  boolean r = false;
4714
  boolean r = isfalse;
4715
  neighbor_rec nb;
4715
  neighbor_rec nb;
4716
 
4716
 
4717
  memset (nb, 0, sizeof (neighbor_rec));
4717
  memset (nb, 0, sizeof (neighbor_rec));
4718
  if (!(atom[a_view - 1].
4718
  if (!(atom[a_view - 1].
4719
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
4719
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
4720
    return false;
4720
    return isfalse;
4721
  if (strcmp (atom[a_ref - 1].atype, "S3 ")
4721
  if (strcmp (atom[a_ref - 1].atype, "S3 ")
4722
      || atom[a_ref - 1].neighbor_count != 2)
4722
      || atom[a_ref - 1].neighbor_count != 2)
4723
    return false;
4723
    return isfalse;
4724
  get_nextneighbors (nb, a_ref, a_view);
4724
  get_nextneighbors (nb, a_ref, a_view);
4725
  if (is_alkenyl (a_ref, nb[0]))
4725
  if (is_alkenyl (a_ref, nb[0]))
4726
    r = true;
4726
    r = istrue;
4727
  return r;
4727
  return r;
4728
}
4728
}
4729
 
4729
 
4730
static boolean is_alkynylsulfanyl (int a_view, int a_ref)
4730
static boolean is_alkynylsulfanyl (int a_view, int a_ref)
4731
{
4731
{
4732
  /* v0.3j */
4732
  /* v0.3j */
4733
  boolean r = false;
4733
  boolean r = isfalse;
4734
  neighbor_rec nb;
4734
  neighbor_rec nb;
4735
 
4735
 
4736
  memset (nb, 0, sizeof (neighbor_rec));
4736
  memset (nb, 0, sizeof (neighbor_rec));
4737
  if (!(atom[a_view - 1].
4737
  if (!(atom[a_view - 1].
4738
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
4738
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
4739
    return false;
4739
    return isfalse;
4740
  if (strcmp (atom[a_ref - 1].atype, "S3 ")
4740
  if (strcmp (atom[a_ref - 1].atype, "S3 ")
4741
      || atom[a_ref - 1].neighbor_count != 2)
4741
      || atom[a_ref - 1].neighbor_count != 2)
4742
    return false;
4742
    return isfalse;
4743
  get_nextneighbors (nb, a_ref, a_view);
4743
  get_nextneighbors (nb, a_ref, a_view);
4744
  if (is_alkynyl (a_ref, nb[0]))
4744
  if (is_alkynyl (a_ref, nb[0]))
4745
    r = true;
4745
    r = istrue;
4746
  return r;
4746
  return r;
4747
}
4747
}
4748
 
4748
 
4749
static boolean is_alkylamino (int a_view, int a_ref)
4749
static boolean is_alkylamino (int a_view, int a_ref)
4750
{
4750
{
4751
  boolean r = false;
4751
  boolean r = isfalse;
4752
  neighbor_rec nb;
4752
  neighbor_rec nb;
4753
  int alkyl_count = 0;
4753
  int alkyl_count = 0;
4754
 
4754
 
4755
  memset (nb, 0, sizeof (neighbor_rec));
4755
  memset (nb, 0, sizeof (neighbor_rec));
4756
  if (!(atom[a_view - 1].
4756
  if (!(atom[a_view - 1].
4757
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
4757
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
4758
    return false;
4758
    return isfalse;
4759
  if (strcmp (atom[a_ref - 1].element, "N ")
4759
  if (strcmp (atom[a_ref - 1].element, "N ")
4760
      || atom[a_ref - 1].neighbor_count != 2)
4760
      || atom[a_ref - 1].neighbor_count != 2)
4761
    return false;
4761
    return isfalse;
4762
  get_nextneighbors (nb, a_ref, a_view);
4762
  get_nextneighbors (nb, a_ref, a_view);
4763
  if (is_alkyl (a_ref, nb[0]))
4763
  if (is_alkyl (a_ref, nb[0]))
4764
    alkyl_count++;
4764
    alkyl_count++;
4765
  if (alkyl_count == 1)
4765
  if (alkyl_count == 1)
4766
    r = true;
4766
    r = istrue;
4767
  return r;
4767
  return r;
4768
}
4768
}
4769
 
4769
 
4770
static boolean is_dialkylamino (int a_view, int a_ref)
4770
static boolean is_dialkylamino (int a_view, int a_ref)
4771
{
4771
{
4772
  int i;
4772
  int i;
4773
  boolean r = false;
4773
  boolean r = isfalse;
4774
  neighbor_rec nb;
4774
  neighbor_rec nb;
4775
  int alkyl_count = 0;
4775
  int alkyl_count = 0;
4776
 
4776
 
4777
  memset (nb, 0, sizeof (neighbor_rec));
4777
  memset (nb, 0, sizeof (neighbor_rec));
4778
  if (!(atom[a_view - 1].
4778
  if (!(atom[a_view - 1].
4779
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
4779
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
4780
    return false;
4780
    return isfalse;
4781
  if (strcmp (atom[a_ref - 1].element, "N ")
4781
  if (strcmp (atom[a_ref - 1].element, "N ")
4782
      || atom[a_ref - 1].neighbor_count != 3)
4782
      || atom[a_ref - 1].neighbor_count != 3)
4783
    return false;
4783
    return isfalse;
4784
  get_nextneighbors (nb, a_ref, a_view);
4784
  get_nextneighbors (nb, a_ref, a_view);
4785
  for (i = 0; i <= 1; i++) {
4785
  for (i = 0; i <= 1; i++) {
4786
    if (is_alkyl (a_ref, nb[i]))
4786
    if (is_alkyl (a_ref, nb[i]))
4787
            alkyl_count++;
4787
            alkyl_count++;
4788
  }
4788
  }
4789
  if (alkyl_count == 2)
4789
  if (alkyl_count == 2)
4790
    r = true;
4790
    r = istrue;
4791
  return r;
4791
  return r;
4792
}
4792
}
4793
 
4793
 
4794
static boolean is_arylamino (int a_view, int a_ref)
4794
static boolean is_arylamino (int a_view, int a_ref)
4795
{
4795
{
4796
  boolean r = false;
4796
  boolean r = isfalse;
4797
  neighbor_rec nb;
4797
  neighbor_rec nb;
4798
  int aryl_count = 0;
4798
  int aryl_count = 0;
4799
 
4799
 
4800
  memset (nb, 0, sizeof (neighbor_rec));
4800
  memset (nb, 0, sizeof (neighbor_rec));
4801
  if (!(atom[a_view - 1].
4801
  if (!(atom[a_view - 1].
4802
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
4802
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
4803
    return false;
4803
    return isfalse;
4804
  if (strcmp (atom[a_ref - 1].element, "N ")
4804
  if (strcmp (atom[a_ref - 1].element, "N ")
4805
      || atom[a_ref - 1].neighbor_count != 2)
4805
      || atom[a_ref - 1].neighbor_count != 2)
4806
    return false;
4806
    return isfalse;
4807
  get_nextneighbors (nb, a_ref, a_view);
4807
  get_nextneighbors (nb, a_ref, a_view);
4808
  if (is_aryl (a_ref, nb[0]))
4808
  if (is_aryl (a_ref, nb[0]))
4809
    aryl_count++;
4809
    aryl_count++;
4810
  if (aryl_count == 1)
4810
  if (aryl_count == 1)
4811
    r = true;
4811
    r = istrue;
4812
  return r;
4812
  return r;
4813
}
4813
}
4814
 
4814
 
4815
static boolean is_diarylamino (int a_view, int a_ref)
4815
static boolean is_diarylamino (int a_view, int a_ref)
4816
{
4816
{
4817
  int i;
4817
  int i;
4818
  boolean r = false;
4818
  boolean r = isfalse;
4819
  neighbor_rec nb;
4819
  neighbor_rec nb;
4820
  int aryl_count = 0;
4820
  int aryl_count = 0;
4821
 
4821
 
4822
  memset (nb, 0, sizeof (neighbor_rec));
4822
  memset (nb, 0, sizeof (neighbor_rec));
4823
  if (!(atom[a_view - 1].
4823
  if (!(atom[a_view - 1].
4824
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
4824
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
4825
    return false;
4825
    return isfalse;
4826
  if (strcmp (atom[a_ref - 1].element, "N ")
4826
  if (strcmp (atom[a_ref - 1].element, "N ")
4827
      || atom[a_ref - 1].neighbor_count != 3)
4827
      || atom[a_ref - 1].neighbor_count != 3)
4828
    return false;
4828
    return isfalse;
4829
  get_nextneighbors (nb, a_ref, a_view);
4829
  get_nextneighbors (nb, a_ref, a_view);
4830
  for (i = 0; i <= 1; i++) {
4830
  for (i = 0; i <= 1; i++) {
4831
    if (is_aryl (a_ref, nb[i]))
4831
    if (is_aryl (a_ref, nb[i]))
4832
            aryl_count++;
4832
            aryl_count++;
4833
  }
4833
  }
4834
  if (aryl_count == 2)
4834
  if (aryl_count == 2)
4835
    r = true;
4835
    r = istrue;
4836
  return r;
4836
  return r;
4837
}
4837
}
4838
 
4838
 
4839
static boolean is_alkylarylamino (int a_view, int a_ref)
4839
static boolean is_alkylarylamino (int a_view, int a_ref)
4840
{
4840
{
4841
  int i;
4841
  int i;
4842
  boolean r = false;
4842
  boolean r = isfalse;
4843
  neighbor_rec nb;
4843
  neighbor_rec nb;
4844
  int alkyl_count = 0, aryl_count = 0;
4844
  int alkyl_count = 0, aryl_count = 0;
4845
 
4845
 
4846
  memset (nb, 0, sizeof (neighbor_rec));
4846
  memset (nb, 0, sizeof (neighbor_rec));
4847
  if (!(atom[a_view - 1].
4847
  if (!(atom[a_view - 1].
4848
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
4848
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
4849
    return false;
4849
    return isfalse;
4850
  if (strcmp (atom[a_ref - 1].element, "N ")
4850
  if (strcmp (atom[a_ref - 1].element, "N ")
4851
      || atom[a_ref - 1].neighbor_count != 3)
4851
      || atom[a_ref - 1].neighbor_count != 3)
4852
    return false;
4852
    return isfalse;
4853
  get_nextneighbors (nb, a_ref, a_view);
4853
  get_nextneighbors (nb, a_ref, a_view);
4854
  for (i = 0; i <= 1; i++) {
4854
  for (i = 0; i <= 1; i++) {
4855
    if (is_alkyl (a_ref, nb[i]))
4855
    if (is_alkyl (a_ref, nb[i]))
4856
            alkyl_count++;
4856
            alkyl_count++;
4857
    if (is_aryl (a_ref, nb[i]))
4857
    if (is_aryl (a_ref, nb[i]))
4858
            aryl_count++;
4858
            aryl_count++;
4859
  }
4859
  }
4860
  if (alkyl_count == 1 && aryl_count == 1)
4860
  if (alkyl_count == 1 && aryl_count == 1)
4861
    r = true;
4861
    r = istrue;
4862
  return r;
4862
  return r;
4863
}
4863
}
4864
 
4864
 
4865
static boolean is_C_monosubst_amino (int a_view, int a_ref)
4865
static boolean is_C_monosubst_amino (int a_view, int a_ref)
4866
{
4866
{
4867
  /* new in v0.3j */
4867
  /* new in v0.3j */
4868
  boolean r = false;
4868
  boolean r = isfalse;
4869
  neighbor_rec nb;
4869
  neighbor_rec nb;
4870
  int c_count = 0;
4870
  int c_count = 0;
4871
 
4871
 
4872
  memset (nb, 0, sizeof (neighbor_rec));
4872
  memset (nb, 0, sizeof (neighbor_rec));
4873
  if (! (atom[a_view - 1].
4873
  if (! (atom[a_view - 1].
4874
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
4874
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
4875
    return false;
4875
    return isfalse;
4876
  if ((strcmp (atom[a_ref - 1].atype, "N3 ")
4876
  if ((strcmp (atom[a_ref - 1].atype, "N3 ")
4877
      && strcmp (atom[a_ref - 1].atype, "NAM"))
4877
      && strcmp (atom[a_ref - 1].atype, "NAM"))
4878
      || atom[a_ref - 1].neighbor_count != 2)
4878
      || atom[a_ref - 1].neighbor_count != 2)
4879
    return false;
4879
    return isfalse;
4880
  get_nextneighbors (nb, a_ref, a_view);
4880
  get_nextneighbors (nb, a_ref, a_view);
4881
  if (!strcmp (atom[nb[0] - 1].element, "C "))
4881
  if (!strcmp (atom[nb[0] - 1].element, "C "))
4882
    c_count++;
4882
    c_count++;
4883
  if (c_count == 1)
4883
  if (c_count == 1)
4884
    r = true;
4884
    r = istrue;
4885
  return r;
4885
  return r;
4886
}
4886
}
4887
 
4887
 
4888
static boolean is_C_disubst_amino (int a_view, int a_ref)
4888
static boolean is_C_disubst_amino (int a_view, int a_ref)
4889
{
4889
{
4890
  /* new in v0.3j */
4890
  /* new in v0.3j */
4891
  int i;
4891
  int i;
4892
  boolean r = false;
4892
  boolean r = isfalse;
4893
  neighbor_rec nb;
4893
  neighbor_rec nb;
4894
  int b;
4894
  int b;
4895
  int c_count = 0;
4895
  int c_count = 0;
4896
 
4896
 
4897
  b = get_bond (a_view, a_ref);
4897
  b = get_bond (a_view, a_ref);
4898
  memset (nb, 0, sizeof (neighbor_rec));
4898
  memset (nb, 0, sizeof (neighbor_rec));
4899
  if (!(atom[a_view - 1].heavy && bond[b - 1].btype == 'S' &&
4899
  if (!(atom[a_view - 1].heavy && bond[b - 1].btype == 'S' &&
4900
            bond[b - 1].arom == false))
4900
            bond[b - 1].arom == isfalse))
4901
    return false;
4901
    return isfalse;
4902
  if ((strcmp (atom[a_ref - 1].atype, "N3 ")
4902
  if ((strcmp (atom[a_ref - 1].atype, "N3 ")
4903
      && strcmp (atom[a_ref - 1].atype, "NAM"))
4903
      && strcmp (atom[a_ref - 1].atype, "NAM"))
4904
      || atom[a_ref - 1].neighbor_count != 3)
4904
      || atom[a_ref - 1].neighbor_count != 3)
4905
    return false;
4905
    return isfalse;
4906
  get_nextneighbors (nb, a_ref, a_view);
4906
  get_nextneighbors (nb, a_ref, a_view);
4907
  for (i = 0; i <= 1; i++) {
4907
  for (i = 0; i <= 1; i++) {
4908
    if (!strcmp (atom[nb[i] - 1].element, "C "))
4908
    if (!strcmp (atom[nb[i] - 1].element, "C "))
4909
            c_count++;
4909
            c_count++;
4910
  }
4910
  }
4911
  if (c_count == 2)
4911
  if (c_count == 2)
4912
    r = true;
4912
    r = istrue;
4913
  return r;
4913
  return r;
4914
}
4914
}
4915
 
4915
 
4916
static boolean is_subst_amino (int a_view, int a_ref)
4916
static boolean is_subst_amino (int a_view, int a_ref)
4917
{
4917
{
4918
  boolean r = false;
4918
  boolean r = isfalse;
4919
 
4919
 
4920
  if (is_amino (a_view, a_ref) || is_alkylamino (a_view, a_ref) |
4920
  if (is_amino (a_view, a_ref) || is_alkylamino (a_view, a_ref) |
4921
      is_arylamino (a_view, a_ref) || is_dialkylamino (a_view, a_ref) |
4921
      is_arylamino (a_view, a_ref) || is_dialkylamino (a_view, a_ref) |
4922
      is_alkylarylamino (a_view, a_ref) || is_diarylamino (a_view, a_ref))
4922
      is_alkylarylamino (a_view, a_ref) || is_diarylamino (a_view, a_ref))
4923
    r = true;
4923
    r = istrue;
4924
  return r;
4924
  return r;
4925
}
4925
}
4926
 
4926
 
4927
static boolean is_true_alkylamino (int a_view, int a_ref)
4927
static boolean is_istrue_alkylamino (int a_view, int a_ref)
4928
{
4928
{
4929
  boolean r = false;
4929
  boolean r = isfalse;
4930
  neighbor_rec nb;
4930
  neighbor_rec nb;
4931
  int alkyl_count = 0;
4931
  int alkyl_count = 0;
4932
 
4932
 
4933
  memset (nb, 0, sizeof (neighbor_rec));
4933
  memset (nb, 0, sizeof (neighbor_rec));
4934
  if (!(atom[a_view - 1].
4934
  if (!(atom[a_view - 1].
4935
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
4935
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
4936
    return false;
4936
    return isfalse;
4937
  if ((strcmp (atom[a_ref - 1].atype, "N3 ")
4937
  if ((strcmp (atom[a_ref - 1].atype, "N3 ")
4938
      && strcmp (atom[a_ref - 1].atype, "N3+"))
4938
      && strcmp (atom[a_ref - 1].atype, "N3+"))
4939
      || atom[a_ref - 1].neighbor_count != 2)
4939
      || atom[a_ref - 1].neighbor_count != 2)
4940
    return false;
4940
    return isfalse;
4941
  get_nextneighbors (nb, a_ref, a_view);
4941
  get_nextneighbors (nb, a_ref, a_view);
4942
  if (is_true_alkyl (a_ref, nb[0]))
4942
  if (is_istrue_alkyl (a_ref, nb[0]))
4943
    alkyl_count++;
4943
    alkyl_count++;
4944
  if (alkyl_count == 1)
4944
  if (alkyl_count == 1)
4945
    r = true;
4945
    r = istrue;
4946
  return r;
4946
  return r;
4947
}
4947
}
4948
 
4948
 
4949
static boolean is_true_dialkylamino (int a_view, int a_ref)
4949
static boolean is_istrue_dialkylamino (int a_view, int a_ref)
4950
{
4950
{
4951
  int i;
4951
  int i;
4952
  boolean r = false;
4952
  boolean r = isfalse;
4953
  neighbor_rec nb;
4953
  neighbor_rec nb;
4954
  int alkyl_count = 0;
4954
  int alkyl_count = 0;
4955
 
4955
 
4956
  memset (nb, 0, sizeof (neighbor_rec));
4956
  memset (nb, 0, sizeof (neighbor_rec));
4957
  if (!(atom[a_view - 1].
4957
  if (!(atom[a_view - 1].
4958
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
4958
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
4959
    return false;
4959
    return isfalse;
4960
  if ((strcmp (atom[a_ref - 1].atype, "N3 ")
4960
  if ((strcmp (atom[a_ref - 1].atype, "N3 ")
4961
      && strcmp (atom[a_ref - 1].atype, "N3+"))
4961
      && strcmp (atom[a_ref - 1].atype, "N3+"))
4962
      || atom[a_ref - 1].neighbor_count != 3)
4962
      || atom[a_ref - 1].neighbor_count != 3)
4963
    return false;
4963
    return isfalse;
4964
  get_nextneighbors (nb, a_ref, a_view);
4964
  get_nextneighbors (nb, a_ref, a_view);
4965
  for (i = 0; i <= 1; i++) {
4965
  for (i = 0; i <= 1; i++) {
4966
    if (is_true_alkyl (a_ref, nb[i]))
4966
    if (is_istrue_alkyl (a_ref, nb[i]))
4967
            alkyl_count++;
4967
            alkyl_count++;
4968
  }
4968
  }
4969
  if (alkyl_count == 2)
4969
  if (alkyl_count == 2)
4970
    r = true;
4970
    r = istrue;
4971
  return r;
4971
  return r;
4972
}
4972
}
4973
 
4973
 
4974
#if 0
4974
#if 0
4975
static boolean is_true_alkylarylamino (int a_view, int a_ref)
4975
static boolean is_istrue_alkylarylamino (int a_view, int a_ref)
4976
{
4976
{
4977
  int i;
4977
  int i;
4978
  boolean r = false;
4978
  boolean r = isfalse;
4979
  neighbor_rec nb;
4979
  neighbor_rec nb;
4980
  int alkyl_count = 0, aryl_count = 0;
4980
  int alkyl_count = 0, aryl_count = 0;
4981
 
4981
 
4982
  memset (nb, 0, sizeof (neighbor_rec));
4982
  memset (nb, 0, sizeof (neighbor_rec));
4983
  if (!(atom[a_view - 1].
4983
  if (!(atom[a_view - 1].
4984
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
4984
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
4985
    return false;
4985
    return isfalse;
4986
  if ((strcmp (atom[a_ref - 1].atype, "N3 ")
4986
  if ((strcmp (atom[a_ref - 1].atype, "N3 ")
4987
      && strcmp (atom[a_ref - 1].atype, "N3+"))
4987
      && strcmp (atom[a_ref - 1].atype, "N3+"))
4988
      || atom[a_ref - 1].neighbor_count != 3)
4988
      || atom[a_ref - 1].neighbor_count != 3)
4989
    return false;
4989
    return isfalse;
4990
  get_nextneighbors (nb, a_ref, a_view);
4990
  get_nextneighbors (nb, a_ref, a_view);
4991
  for (i = 0; i <= 1; i++) {
4991
  for (i = 0; i <= 1; i++) {
4992
    if (is_true_alkyl (a_ref, nb[i]))
4992
    if (is_istrue_alkyl (a_ref, nb[i]))
4993
            alkyl_count++;
4993
            alkyl_count++;
4994
    if (is_aryl (a_ref, nb[i]))
4994
    if (is_aryl (a_ref, nb[i]))
4995
            aryl_count++;
4995
            aryl_count++;
4996
  }
4996
  }
4997
  if (alkyl_count == 1 && aryl_count == 1)
4997
  if (alkyl_count == 1 && aryl_count == 1)
4998
    r = true;
4998
    r = istrue;
4999
  return r;
4999
  return r;
5000
}
5000
}
5001
#endif
5001
#endif
5002
 
5002
 
5003
static boolean is_hydroxylamino (int a_view, int a_ref)
5003
static boolean is_hydroxylamino (int a_view, int a_ref)
5004
{
5004
{
5005
  int i;
5005
  int i;
5006
  boolean r = false;
5006
  boolean r = isfalse;
5007
  neighbor_rec nb;
5007
  neighbor_rec nb;
5008
  int oh_count = 0, het_count = 0;      /* v0.3k */
5008
  int oh_count = 0, het_count = 0;      /* v0.3k */
5009
  str2 nb_el;                   /* v0.3k */
5009
  str2 nb_el;                   /* v0.3k */
5010
  int FORLIM;
5010
  int FORLIM;
5011
 
5011
 
5012
  memset (nb, 0, sizeof (neighbor_rec));
5012
  memset (nb, 0, sizeof (neighbor_rec));
5013
  if (!(atom[a_view - 1].
5013
  if (!(atom[a_view - 1].
5014
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5014
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5015
    return false;
5015
    return isfalse;
5016
  if (strcmp (atom[a_ref - 1].element, "N ")
5016
  if (strcmp (atom[a_ref - 1].element, "N ")
5017
      || atom[a_ref - 1].neighbor_count < 2)
5017
      || atom[a_ref - 1].neighbor_count < 2)
5018
    /* v0.3c */
5018
    /* v0.3c */
5019
    return false;
5019
    return isfalse;
5020
  get_nextneighbors (nb, a_ref, a_view);
5020
  get_nextneighbors (nb, a_ref, a_view);
5021
  FORLIM = atom[a_ref - 1].neighbor_count - 2;
5021
  FORLIM = atom[a_ref - 1].neighbor_count - 2;
5022
  for (i = 0; i <= FORLIM; i++) {                               /* v0.3c */
5022
  for (i = 0; i <= FORLIM; i++) {                               /* v0.3c */
5023
    if (is_hydroxy (a_ref, nb[i]))
5023
    if (is_hydroxy (a_ref, nb[i]))
5024
            oh_count++;
5024
            oh_count++;
Line 5029... Line 5029...
5029
              /* v0.3k */
5029
              /* v0.3k */
5030
            het_count++;
5030
            het_count++;
5031
      /* v0.3n: D */
5031
      /* v0.3n: D */
5032
  }
5032
  }
5033
  if (oh_count == 1 && het_count == 1)
5033
  if (oh_count == 1 && het_count == 1)
5034
    r = true;
5034
    r = istrue;
5035
  return r;
5035
  return r;
5036
}
5036
}
5037
 
5037
 
5038
static boolean is_nitro (int a_view, int a_ref)
5038
static boolean is_nitro (int a_view, int a_ref)
5039
{
5039
{
5040
  int i;
5040
  int i;
5041
  boolean r = false;
5041
  boolean r = isfalse;
5042
  neighbor_rec nb;
5042
  neighbor_rec nb;
5043
  int o_count = 0, bond_count = 0;
5043
  int o_count = 0, bond_count = 0;
5044
 
5044
 
5045
  memset (nb, 0, sizeof (neighbor_rec));
5045
  memset (nb, 0, sizeof (neighbor_rec));
5046
  if (!(atom[a_view - 1].
5046
  if (!(atom[a_view - 1].
5047
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5047
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5048
    return false;
5048
    return isfalse;
5049
  if (strcmp (atom[a_ref - 1].element, "N ")
5049
  if (strcmp (atom[a_ref - 1].element, "N ")
5050
      || atom[a_ref - 1].neighbor_count != 3)
5050
      || atom[a_ref - 1].neighbor_count != 3)
5051
    return false;
5051
    return isfalse;
5052
  get_nextneighbors (nb, a_ref, a_view);
5052
  get_nextneighbors (nb, a_ref, a_view);
5053
  for (i = 0; i <= 1; i++) {
5053
  for (i = 0; i <= 1; i++) {
5054
    if (!strcmp (atom[nb[i] - 1].element, "O "))
5054
    if (!strcmp (atom[nb[i] - 1].element, "O "))
5055
            o_count++;
5055
            o_count++;
5056
    if (bond[get_bond (a_ref, nb[i]) - 1].btype == 'S')
5056
    if (bond[get_bond (a_ref, nb[i]) - 1].btype == 'S')
5057
            bond_count++;
5057
            bond_count++;
5058
    if (bond[get_bond (a_ref, nb[i]) - 1].btype == 'D')
5058
    if (bond[get_bond (a_ref, nb[i]) - 1].btype == 'D')
5059
            bond_count += 2;
5059
            bond_count += 2;
5060
  }
5060
  }
5061
  if (o_count == 2 && bond_count >= 3)
5061
  if (o_count == 2 && bond_count >= 3)
5062
    r = true;
5062
    r = istrue;
5063
  return r;
5063
  return r;
5064
}
5064
}
5065
 
5065
 
5066
static boolean is_azido (int a_view, int a_ref)
5066
static boolean is_azido (int a_view, int a_ref)
5067
{
5067
{
5068
  boolean r = false;
5068
  boolean r = isfalse;
5069
  neighbor_rec nb;
5069
  neighbor_rec nb;
5070
  int bond_count = 0, n1 = 0, n2 = 0, n3 = 0;
5070
  int bond_count = 0, n1 = 0, n2 = 0, n3 = 0;
5071
 
5071
 
5072
  if (!(atom[a_view - 1].
5072
  if (!(atom[a_view - 1].
5073
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5073
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5074
    return false;
5074
    return isfalse;
5075
  if (strcmp (atom[a_ref - 1].element, "N ")
5075
  if (strcmp (atom[a_ref - 1].element, "N ")
5076
      || atom[a_ref - 1].neighbor_count != 2)
5076
      || atom[a_ref - 1].neighbor_count != 2)
5077
    return false;
5077
    return isfalse;
5078
  n1 = a_ref;
5078
  n1 = a_ref;
5079
  memset (nb, 0, sizeof (neighbor_rec));
5079
  memset (nb, 0, sizeof (neighbor_rec));
5080
  get_nextneighbors (nb, n1, a_view);
5080
  get_nextneighbors (nb, n1, a_view);
5081
  if (!strcmp (atom[nb[0] - 1].element, "N ")) {
5081
  if (!strcmp (atom[nb[0] - 1].element, "N ")) {
5082
    n2 = nb[0];
5082
    n2 = nb[0];
Line 5100... Line 5100...
5100
              bond_count += 3;
5100
              bond_count += 3;
5101
          }
5101
          }
5102
  }
5102
  }
5103
  if (n1 > 0 && n2 > 0 && n3 > 0 && atom[n3 - 1].neighbor_count == 1 &&
5103
  if (n1 > 0 && n2 > 0 && n3 > 0 && atom[n3 - 1].neighbor_count == 1 &&
5104
      bond_count > 3)
5104
      bond_count > 3)
5105
    r = true;
5105
    r = istrue;
5106
  return r;
5106
  return r;
5107
}
5107
}
5108
 
5108
 
5109
static boolean is_diazonium (int a_view, int a_ref)
5109
static boolean is_diazonium (int a_view, int a_ref)
5110
{
5110
{
5111
  boolean r = false;
5111
  boolean r = isfalse;
5112
  neighbor_rec nb;
5112
  neighbor_rec nb;
5113
  int bond_count = 0, chg_count = 0, n1 = 0, n2 = 0;
5113
  int bond_count = 0, chg_count = 0, n1 = 0, n2 = 0;
5114
 
5114
 
5115
  if (!(atom[a_view - 1].
5115
  if (!(atom[a_view - 1].
5116
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5116
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5117
    return false;
5117
    return isfalse;
5118
  if (strcmp (atom[a_ref - 1].element, "N ")
5118
  if (strcmp (atom[a_ref - 1].element, "N ")
5119
      || atom[a_ref - 1].neighbor_count != 2)
5119
      || atom[a_ref - 1].neighbor_count != 2)
5120
    return false;
5120
    return isfalse;
5121
  n1 = a_ref;
5121
  n1 = a_ref;
5122
  chg_count = atom[n1 - 1].formal_charge;
5122
  chg_count = atom[n1 - 1].formal_charge;
5123
  memset (nb, 0, sizeof (neighbor_rec));
5123
  memset (nb, 0, sizeof (neighbor_rec));
5124
  get_nextneighbors (nb, n1, a_view);
5124
  get_nextneighbors (nb, n1, a_view);
5125
  if (!strcmp (atom[nb[0] - 1].element, "N ")) {
5125
  if (!strcmp (atom[nb[0] - 1].element, "N ")) {
Line 5132... Line 5132...
5132
    if (bond[get_bond (n1, n2) - 1].btype == 'T')
5132
    if (bond[get_bond (n1, n2) - 1].btype == 'T')
5133
            bond_count += 3;
5133
            bond_count += 3;
5134
  }
5134
  }
5135
  if (n1 > 0 && n2 > 0 && atom[n2 - 1].neighbor_count == 1
5135
  if (n1 > 0 && n2 > 0 && atom[n2 - 1].neighbor_count == 1
5136
      && bond_count >= 2 && chg_count > 0)
5136
      && bond_count >= 2 && chg_count > 0)
5137
    r = true;
5137
    r = istrue;
5138
  return r;
5138
  return r;
5139
}
5139
}
5140
 
5140
 
5141
static boolean is_hydroximino_C (int id)
5141
static boolean is_hydroximino_C (int id)
5142
{
5142
{
5143
  int i;
5143
  int i;
5144
  boolean r = false;
5144
  boolean r = isfalse;
5145
  neighbor_rec nb;
5145
  neighbor_rec nb;
5146
  int a_het = 0;
5146
  int a_het = 0;
5147
  int FORLIM;
5147
  int FORLIM;
5148
 
5148
 
5149
  memset (nb, 0, sizeof (neighbor_rec));
5149
  memset (nb, 0, sizeof (neighbor_rec));
5150
  if (id < 1 || id > n_atoms)
5150
  if (id < 1 || id > n_atoms)
5151
    return false;
5151
    return isfalse;
5152
  get_neighbors (nb, id);
5152
  get_neighbors (nb, id);
5153
  if (strcmp (atom[id - 1].element, "C ") || atom[id - 1].neighbor_count <= 0)
5153
  if (strcmp (atom[id - 1].element, "C ") || atom[id - 1].neighbor_count <= 0)
5154
    return false;
5154
    return isfalse;
5155
  FORLIM = atom[id - 1].neighbor_count;
5155
  FORLIM = atom[id - 1].neighbor_count;
5156
  for (i = 0; i < FORLIM; i++) {
5156
  for (i = 0; i < FORLIM; i++) {
5157
    if ((bond[get_bond (id, nb[i]) - 1].btype == 'D' &&
5157
    if ((bond[get_bond (id, nb[i]) - 1].btype == 'D' &&
5158
              !strcmp (atom[nb[i] - 1].element, "N ")) && (hetbond_count (nb[i]) == 3))
5158
              !strcmp (atom[nb[i] - 1].element, "N ")) && (hetbond_count (nb[i]) == 3))
5159
            a_het = nb[i];
5159
            a_het = nb[i];
5160
  }
5160
  }
5161
  if (a_het <= 0)
5161
  if (a_het <= 0)
5162
    return false;
5162
    return isfalse;
5163
  memset (nb, 0, sizeof (neighbor_rec));
5163
  memset (nb, 0, sizeof (neighbor_rec));
5164
  get_neighbors (nb, a_het);
5164
  get_neighbors (nb, a_het);
5165
  if (strcmp (atom[a_het - 1].element, "N ")
5165
  if (strcmp (atom[a_het - 1].element, "N ")
5166
      || atom[a_het - 1].neighbor_count <= 0)
5166
      || atom[a_het - 1].neighbor_count <= 0)
5167
    return false;
5167
    return isfalse;
5168
  FORLIM = atom[a_het - 1].neighbor_count;
5168
  FORLIM = atom[a_het - 1].neighbor_count;
5169
  for (i = 0; i < FORLIM; i++) {
5169
  for (i = 0; i < FORLIM; i++) {
5170
    if (is_hydroxy (a_het, nb[i]))
5170
    if (is_hydroxy (a_het, nb[i]))
5171
          r = true;
5171
          r = istrue;
5172
  }
5172
  }
5173
  return r;
5173
  return r;
5174
}
5174
}
5175
 
5175
 
5176
static boolean is_hydrazono_C (int id)
5176
static boolean is_hydrazono_C (int id)
5177
{
5177
{
5178
  int i;
5178
  int i;
5179
  boolean r = false;
5179
  boolean r = isfalse;
5180
  neighbor_rec nb;
5180
  neighbor_rec nb;
5181
  int a_het = 0;
5181
  int a_het = 0;
5182
  int FORLIM;
5182
  int FORLIM;
5183
 
5183
 
5184
  memset (nb, 0, sizeof (neighbor_rec));
5184
  memset (nb, 0, sizeof (neighbor_rec));
5185
  if (id < 1 || id > n_atoms)
5185
  if (id < 1 || id > n_atoms)
5186
    return false;
5186
    return isfalse;
5187
  get_neighbors (nb, id);
5187
  get_neighbors (nb, id);
5188
  if (strcmp (atom[id - 1].element, "C ") || atom[id - 1].neighbor_count <= 0)
5188
  if (strcmp (atom[id - 1].element, "C ") || atom[id - 1].neighbor_count <= 0)
5189
    return false;
5189
    return isfalse;
5190
  FORLIM = atom[id - 1].neighbor_count;
5190
  FORLIM = atom[id - 1].neighbor_count;
5191
  for (i = 0; i < FORLIM; i++) {
5191
  for (i = 0; i < FORLIM; i++) {
5192
    if (bond[get_bond (id, nb[i]) - 1].btype == 'D' &&
5192
    if (bond[get_bond (id, nb[i]) - 1].btype == 'D' &&
5193
              !strcmp (atom[nb[i] - 1].element, "N ")) {
5193
              !strcmp (atom[nb[i] - 1].element, "N ")) {
5194
          /* and
5194
          /* and
5195
             (hetbond_count(nb[i]) = 3)  */
5195
             (hetbond_count(nb[i]) = 3)  */
5196
          a_het = nb[i];
5196
          a_het = nb[i];
5197
          }
5197
          }
5198
  }
5198
  }
5199
  if (a_het <= 0)
5199
  if (a_het <= 0)
5200
    return false;
5200
    return isfalse;
5201
  memset (nb, 0, sizeof (neighbor_rec));
5201
  memset (nb, 0, sizeof (neighbor_rec));
5202
  get_neighbors (nb, a_het);
5202
  get_neighbors (nb, a_het);
5203
  if (strcmp (atom[a_het - 1].element, "N ")
5203
  if (strcmp (atom[a_het - 1].element, "N ")
5204
      || atom[a_het - 1].neighbor_count <= 0)
5204
      || atom[a_het - 1].neighbor_count <= 0)
5205
    return false;
5205
    return isfalse;
5206
  FORLIM = atom[a_het - 1].neighbor_count;
5206
  FORLIM = atom[a_het - 1].neighbor_count;
5207
  for (i = 0; i < FORLIM; i++) {
5207
  for (i = 0; i < FORLIM; i++) {
5208
    if (is_amino (a_het, nb[i]) || is_alkylamino (a_het, nb[i]) |
5208
    if (is_amino (a_het, nb[i]) || is_alkylamino (a_het, nb[i]) |
5209
              is_alkylarylamino (a_het, nb[i]) || is_arylamino (a_het, nb[i]) |
5209
              is_alkylarylamino (a_het, nb[i]) || is_arylamino (a_het, nb[i]) |
5210
              is_dialkylamino (a_het, nb[i]) || is_diarylamino (a_het, nb[i]))
5210
              is_dialkylamino (a_het, nb[i]) || is_diarylamino (a_het, nb[i]))
5211
            r = true;
5211
            r = istrue;
5212
  }
5212
  }
5213
  return r;
5213
  return r;
5214
}
5214
}
5215
 
5215
 
5216
static boolean is_alkoxycarbonyl (int a_view, int a_ref)
5216
static boolean is_alkoxycarbonyl (int a_view, int a_ref)
5217
{
5217
{
5218
  int i;
5218
  int i;
5219
  boolean r = false;
5219
  boolean r = isfalse;
5220
  neighbor_rec nb;
5220
  neighbor_rec nb;
5221
 
5221
 
5222
  memset (nb, 0, sizeof (neighbor_rec));
5222
  memset (nb, 0, sizeof (neighbor_rec));
5223
  if (!(atom[a_view - 1].heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5223
  if (!(atom[a_view - 1].heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5224
    return false;
5224
    return isfalse;
5225
  if (!(is_oxo_C (a_ref) && atom[a_ref - 1].neighbor_count == 3))
5225
  if (!(is_oxo_C (a_ref) && atom[a_ref - 1].neighbor_count == 3))
5226
    return false;
5226
    return isfalse;
5227
  get_nextneighbors (nb, a_ref, a_view);
5227
  get_nextneighbors (nb, a_ref, a_view);
5228
  for (i = 0; i <= 1; i++) {
5228
  for (i = 0; i <= 1; i++) {
5229
    if (is_alkoxy (a_ref, nb[i]))
5229
    if (is_alkoxy (a_ref, nb[i]))
5230
            r = true;
5230
            r = istrue;
5231
  }
5231
  }
5232
  return r;
5232
  return r;
5233
}
5233
}
5234
 
5234
 
5235
static boolean is_aryloxycarbonyl (int a_view, int a_ref)
5235
static boolean is_aryloxycarbonyl (int a_view, int a_ref)
5236
{
5236
{
5237
  int i;
5237
  int i;
5238
  boolean r = false;
5238
  boolean r = isfalse;
5239
  neighbor_rec nb;
5239
  neighbor_rec nb;
5240
 
5240
 
5241
  memset (nb, 0, sizeof (neighbor_rec));
5241
  memset (nb, 0, sizeof (neighbor_rec));
5242
  if (!(atom[a_view - 1].
5242
  if (!(atom[a_view - 1].
5243
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5243
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5244
    return false;
5244
    return isfalse;
5245
  if (!(is_oxo_C (a_ref) && atom[a_ref - 1].neighbor_count == 3))
5245
  if (!(is_oxo_C (a_ref) && atom[a_ref - 1].neighbor_count == 3))
5246
    return false;
5246
    return isfalse;
5247
  get_nextneighbors (nb, a_ref, a_view);
5247
  get_nextneighbors (nb, a_ref, a_view);
5248
  for (i = 0; i <= 1; i++) {
5248
  for (i = 0; i <= 1; i++) {
5249
    if (is_aryloxy (a_ref, nb[i]))
5249
    if (is_aryloxy (a_ref, nb[i]))
5250
            r = true;
5250
            r = istrue;
5251
  }
5251
  }
5252
  return r;
5252
  return r;
5253
}
5253
}
5254
 
5254
 
5255
static boolean is_carbamoyl (int a_view, int a_ref)
5255
static boolean is_carbamoyl (int a_view, int a_ref)
5256
{
5256
{
5257
  int i;
5257
  int i;
5258
  boolean r = false;
5258
  boolean r = isfalse;
5259
  neighbor_rec nb;
5259
  neighbor_rec nb;
5260
 
5260
 
5261
  memset (nb, 0, sizeof (neighbor_rec));
5261
  memset (nb, 0, sizeof (neighbor_rec));
5262
  if (!(atom[a_view - 1].
5262
  if (!(atom[a_view - 1].
5263
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5263
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5264
    return false;
5264
    return isfalse;
5265
  if (!(is_oxo_C (a_ref) && atom[a_ref - 1].neighbor_count == 3))
5265
  if (!(is_oxo_C (a_ref) && atom[a_ref - 1].neighbor_count == 3))
5266
    return false;
5266
    return isfalse;
5267
  get_nextneighbors (nb, a_ref, a_view);
5267
  get_nextneighbors (nb, a_ref, a_view);
5268
  for (i = 0; i <= 1; i++) {
5268
  for (i = 0; i <= 1; i++) {
5269
    if (!strcmp (atom[nb[i] - 1].atype, "N3 ") || !strcmp (atom[nb[i] - 1].atype, "NAM"))
5269
    if (!strcmp (atom[nb[i] - 1].atype, "N3 ") || !strcmp (atom[nb[i] - 1].atype, "NAM"))
5270
            r = true;
5270
            r = istrue;
5271
  }
5271
  }
5272
  return r;
5272
  return r;
5273
}
5273
}
5274
 
5274
 
5275
static boolean is_alkoxythiocarbonyl (int a_view, int a_ref)
5275
static boolean is_alkoxythiocarbonyl (int a_view, int a_ref)
5276
{
5276
{
5277
  int i;
5277
  int i;
5278
  boolean r = false;
5278
  boolean r = isfalse;
5279
  neighbor_rec nb;
5279
  neighbor_rec nb;
5280
 
5280
 
5281
  memset (nb, 0, sizeof (neighbor_rec));
5281
  memset (nb, 0, sizeof (neighbor_rec));
5282
  if (!(atom[a_view - 1].heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5282
  if (!(atom[a_view - 1].heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5283
    return false;
5283
    return isfalse;
5284
  if (!(is_thioxo_C (a_ref) && atom[a_ref - 1].neighbor_count == 3))
5284
  if (!(is_thioxo_C (a_ref) && atom[a_ref - 1].neighbor_count == 3))
5285
    return false;
5285
    return isfalse;
5286
  get_nextneighbors (nb, a_ref, a_view);
5286
  get_nextneighbors (nb, a_ref, a_view);
5287
  for (i = 0; i <= 1; i++) {
5287
  for (i = 0; i <= 1; i++) {
5288
    if (is_alkoxy (a_ref, nb[i]))
5288
    if (is_alkoxy (a_ref, nb[i]))
5289
            r = true;
5289
            r = istrue;
5290
  }
5290
  }
5291
  return r;
5291
  return r;
5292
}
5292
}
5293
 
5293
 
5294
static boolean is_aryloxythiocarbonyl (int a_view, int a_ref)
5294
static boolean is_aryloxythiocarbonyl (int a_view, int a_ref)
5295
{
5295
{
5296
  int i;
5296
  int i;
5297
  boolean r = false;
5297
  boolean r = isfalse;
5298
  neighbor_rec nb;
5298
  neighbor_rec nb;
5299
 
5299
 
5300
  memset (nb, 0, sizeof (neighbor_rec));
5300
  memset (nb, 0, sizeof (neighbor_rec));
5301
  if (!(atom[a_view - 1].heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5301
  if (!(atom[a_view - 1].heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5302
    return false;
5302
    return isfalse;
5303
  if (!(is_thioxo_C (a_ref) && atom[a_ref - 1].neighbor_count == 3))
5303
  if (!(is_thioxo_C (a_ref) && atom[a_ref - 1].neighbor_count == 3))
5304
    return false;
5304
    return isfalse;
5305
  get_nextneighbors (nb, a_ref, a_view);
5305
  get_nextneighbors (nb, a_ref, a_view);
5306
  for (i = 0; i <= 1; i++) {
5306
  for (i = 0; i <= 1; i++) {
5307
    if (is_aryloxy (a_ref, nb[i]))
5307
    if (is_aryloxy (a_ref, nb[i]))
5308
            r = true;
5308
            r = istrue;
5309
  }
5309
  }
5310
  return r;
5310
  return r;
5311
}
5311
}
5312
 
5312
 
5313
static boolean is_thiocarbamoyl (int a_view, int a_ref)
5313
static boolean is_thiocarbamoyl (int a_view, int a_ref)
5314
{
5314
{
5315
  int i;
5315
  int i;
5316
  boolean r = false;
5316
  boolean r = isfalse;
5317
  neighbor_rec nb;
5317
  neighbor_rec nb;
5318
 
5318
 
5319
  memset (nb, 0, sizeof (neighbor_rec));
5319
  memset (nb, 0, sizeof (neighbor_rec));
5320
  if (!(atom[a_view - 1].
5320
  if (!(atom[a_view - 1].
5321
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5321
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5322
    return false;
5322
    return isfalse;
5323
  if (!(is_thioxo_C (a_ref) && atom[a_ref - 1].neighbor_count == 3))
5323
  if (!(is_thioxo_C (a_ref) && atom[a_ref - 1].neighbor_count == 3))
5324
    return false;
5324
    return isfalse;
5325
  get_nextneighbors (nb, a_ref, a_view);
5325
  get_nextneighbors (nb, a_ref, a_view);
5326
  for (i = 0; i <= 1; i++) {
5326
  for (i = 0; i <= 1; i++) {
5327
    if (!strcmp (atom[nb[i] - 1].atype, "N3 ") ||
5327
    if (!strcmp (atom[nb[i] - 1].atype, "N3 ") ||
5328
              !strcmp (atom[nb[i] - 1].atype, "NAM"))
5328
              !strcmp (atom[nb[i] - 1].atype, "NAM"))
5329
            r = true;
5329
            r = istrue;
5330
  }
5330
  }
5331
  return r;
5331
  return r;
5332
}
5332
}
5333
 
5333
 
5334
static boolean is_alkanoyl (int a_view, int a_ref)
5334
static boolean is_alkanoyl (int a_view, int a_ref)
5335
{
5335
{
5336
  int i;
5336
  int i;
5337
  boolean r = false;
5337
  boolean r = isfalse;
5338
  neighbor_rec nb;
5338
  neighbor_rec nb;
5339
 
5339
 
5340
  memset (nb, 0, sizeof (neighbor_rec));
5340
  memset (nb, 0, sizeof (neighbor_rec));
5341
  if (!(atom[a_view - 1].
5341
  if (!(atom[a_view - 1].
5342
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5342
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5343
    return false;
5343
    return isfalse;
5344
  if (!(is_oxo_C (a_ref) && atom[a_ref - 1].neighbor_count == 3))
5344
  if (!(is_oxo_C (a_ref) && atom[a_ref - 1].neighbor_count == 3))
5345
    return false;
5345
    return isfalse;
5346
  get_nextneighbors (nb, a_ref, a_view);
5346
  get_nextneighbors (nb, a_ref, a_view);
5347
  for (i = 0; i <= 1; i++) {
5347
  for (i = 0; i <= 1; i++) {
5348
    if (is_alkyl (a_ref, nb[i]))
5348
    if (is_alkyl (a_ref, nb[i]))
5349
            r = true;
5349
            r = istrue;
5350
  }
5350
  }
5351
  return r;
5351
  return r;
5352
}
5352
}
5353
 
5353
 
5354
static boolean is_aroyl (int a_view, int a_ref)
5354
static boolean is_aroyl (int a_view, int a_ref)
5355
{
5355
{
5356
  int i;
5356
  int i;
5357
  boolean r = false;
5357
  boolean r = isfalse;
5358
  neighbor_rec nb;
5358
  neighbor_rec nb;
5359
 
5359
 
5360
  memset (nb, 0, sizeof (neighbor_rec));
5360
  memset (nb, 0, sizeof (neighbor_rec));
5361
  if (!(atom[a_view - 1].
5361
  if (!(atom[a_view - 1].
5362
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5362
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5363
    return false;
5363
    return isfalse;
5364
  if (!(is_oxo_C (a_ref) && atom[a_ref - 1].neighbor_count == 3))
5364
  if (!(is_oxo_C (a_ref) && atom[a_ref - 1].neighbor_count == 3))
5365
    return false;
5365
    return isfalse;
5366
  get_nextneighbors (nb, a_ref, a_view);
5366
  get_nextneighbors (nb, a_ref, a_view);
5367
  for (i = 0; i <= 1; i++) {
5367
  for (i = 0; i <= 1; i++) {
5368
    if (is_aryl (a_ref, nb[i]))
5368
    if (is_aryl (a_ref, nb[i]))
5369
            r = true;
5369
            r = istrue;
5370
  }
5370
  }
5371
  return r;
5371
  return r;
5372
}
5372
}
5373
 
5373
 
5374
static boolean is_acyl (int a_view, int a_ref)
5374
static boolean is_acyl (int a_view, int a_ref)
5375
{
5375
{
5376
  boolean r = false;
5376
  boolean r = isfalse;
5377
 
5377
 
5378
  if (is_alkanoyl (a_view, a_ref) || is_aroyl (a_view, a_ref))
5378
  if (is_alkanoyl (a_view, a_ref) || is_aroyl (a_view, a_ref))
5379
    r = true;
5379
    r = istrue;
5380
  return r;
5380
  return r;
5381
}
5381
}
5382
 
5382
 
5383
static boolean is_acyl_gen (int a_view, int a_ref)
5383
static boolean is_acyl_gen (int a_view, int a_ref)
5384
{
5384
{
5385
  /* new in v0.3j */
5385
  /* new in v0.3j */
5386
  boolean r = false;
5386
  boolean r = isfalse;
5387
 
5387
 
5388
  if (is_oxo_C (a_ref))
5388
  if (is_oxo_C (a_ref))
5389
    r = true;
5389
    r = istrue;
5390
  return r;
5390
  return r;
5391
}
5391
}
5392
 
5392
 
5393
static boolean is_acylamino (int a_view, int a_ref)
5393
static boolean is_acylamino (int a_view, int a_ref)
5394
{
5394
{
5395
  boolean r = false;
5395
  boolean r = isfalse;
5396
  neighbor_rec nb;
5396
  neighbor_rec nb;
5397
  int acyl_count = 0;
5397
  int acyl_count = 0;
5398
 
5398
 
5399
  memset (nb, 0, sizeof (neighbor_rec));
5399
  memset (nb, 0, sizeof (neighbor_rec));
5400
  if (!(atom[a_view - 1].
5400
  if (!(atom[a_view - 1].
5401
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5401
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5402
    return false;
5402
    return isfalse;
5403
  if (strcmp (atom[a_ref - 1].element, "N ")
5403
  if (strcmp (atom[a_ref - 1].element, "N ")
5404
      || atom[a_ref - 1].neighbor_count != 2)
5404
      || atom[a_ref - 1].neighbor_count != 2)
5405
    return false;
5405
    return isfalse;
5406
  get_nextneighbors (nb, a_ref, a_view);
5406
  get_nextneighbors (nb, a_ref, a_view);
5407
  if (is_acyl (a_ref, nb[0]))
5407
  if (is_acyl (a_ref, nb[0]))
5408
    acyl_count++;
5408
    acyl_count++;
5409
  if (acyl_count == 1)
5409
  if (acyl_count == 1)
5410
    r = true;
5410
    r = istrue;
5411
  return r;
5411
  return r;
5412
}
5412
}
5413
 
5413
 
5414
static boolean is_subst_acylamino (int a_view, int a_ref)
5414
static boolean is_subst_acylamino (int a_view, int a_ref)
5415
{
5415
{
5416
  /* may be substituted _or_ unsubstituted acylamino group! */
5416
  /* may be substituted _or_ unsubstituted acylamino group! */
5417
  int i;
5417
  int i;
5418
  boolean r = false;
5418
  boolean r = isfalse;
5419
  neighbor_rec nb;
5419
  neighbor_rec nb;
5420
  int acyl_count = 0;
5420
  int acyl_count = 0;
5421
  int FORLIM;
5421
  int FORLIM;
5422
 
5422
 
5423
  memset (nb, 0, sizeof (neighbor_rec));
5423
  memset (nb, 0, sizeof (neighbor_rec));
5424
  if (!(atom[a_view - 1].
5424
  if (!(atom[a_view - 1].
5425
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5425
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5426
    return false;
5426
    return isfalse;
5427
  if (strcmp (atom[a_ref - 1].element, "N ")
5427
  if (strcmp (atom[a_ref - 1].element, "N ")
5428
      || atom[a_ref - 1].neighbor_count < 2)
5428
      || atom[a_ref - 1].neighbor_count < 2)
5429
    return false;
5429
    return isfalse;
5430
  get_nextneighbors (nb, a_ref, a_view);
5430
  get_nextneighbors (nb, a_ref, a_view);
5431
  FORLIM = atom[a_ref - 1].neighbor_count - 2;
5431
  FORLIM = atom[a_ref - 1].neighbor_count - 2;
5432
  for (i = 0; i <= FORLIM; i++) {
5432
  for (i = 0; i <= FORLIM; i++) {
5433
    if (is_acyl_gen (a_ref, nb[i]))     /* v0.3j */
5433
    if (is_acyl_gen (a_ref, nb[i]))     /* v0.3j */
5434
            acyl_count++;
5434
            acyl_count++;
5435
  }
5435
  }
5436
  if (acyl_count > 0)
5436
  if (acyl_count > 0)
5437
    r = true;
5437
    r = istrue;
5438
  return r;
5438
  return r;
5439
}
5439
}
5440
 
5440
 
5441
static boolean is_hydrazino (int a_view, int a_ref)
5441
static boolean is_hydrazino (int a_view, int a_ref)
5442
{
5442
{
5443
  int i;
5443
  int i;
5444
  boolean r = false;
5444
  boolean r = isfalse;
5445
  neighbor_rec nb;
5445
  neighbor_rec nb;
5446
  int nr_count = 0;
5446
  int nr_count = 0;
5447
  int FORLIM;
5447
  int FORLIM;
5448
 
5448
 
5449
  memset (nb, 0, sizeof (neighbor_rec));
5449
  memset (nb, 0, sizeof (neighbor_rec));
5450
  if (!(atom[a_view - 1].
5450
  if (!(atom[a_view - 1].
5451
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5451
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5452
    return false;
5452
    return isfalse;
5453
  if (strcmp (atom[a_ref - 1].element, "N ")
5453
  if (strcmp (atom[a_ref - 1].element, "N ")
5454
      || atom[a_ref - 1].neighbor_count < 2)
5454
      || atom[a_ref - 1].neighbor_count < 2)
5455
    return false;
5455
    return isfalse;
5456
  get_nextneighbors (nb, a_ref, a_view);
5456
  get_nextneighbors (nb, a_ref, a_view);
5457
  FORLIM = atom[a_ref - 1].neighbor_count - 2;
5457
  FORLIM = atom[a_ref - 1].neighbor_count - 2;
5458
  for (i = 0; i <= FORLIM; i++) {                               /* fixed in v0.3c */
5458
  for (i = 0; i <= FORLIM; i++) {                               /* fixed in v0.3c */
5459
    if (is_amino (a_ref, nb[i]) || is_subst_amino (a_ref, nb[i]))
5459
    if (is_amino (a_ref, nb[i]) || is_subst_amino (a_ref, nb[i]))
5460
            nr_count++;
5460
            nr_count++;
5461
  }
5461
  }
5462
  if (nr_count == 1)
5462
  if (nr_count == 1)
5463
    r = true;
5463
    r = istrue;
5464
  return r;
5464
  return r;
5465
}
5465
}
5466
 
5466
 
5467
static boolean is_nitroso (int a_view, int a_ref)
5467
static boolean is_nitroso (int a_view, int a_ref)
5468
{
5468
{
5469
  /* new in v0.3j */
5469
  /* new in v0.3j */
5470
  boolean r = false;
5470
  boolean r = isfalse;
5471
  neighbor_rec nb;
5471
  neighbor_rec nb;
5472
  int o_count = 0;
5472
  int o_count = 0;
5473
  int a2;
5473
  int a2;
5474
 
5474
 
5475
  memset (nb, 0, sizeof (neighbor_rec));
5475
  memset (nb, 0, sizeof (neighbor_rec));
5476
  if (!(atom[a_view - 1].
5476
  if (!(atom[a_view - 1].
5477
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5477
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5478
    return false;
5478
    return isfalse;
5479
  if (strcmp (atom[a_ref - 1].element, "N ")
5479
  if (strcmp (atom[a_ref - 1].element, "N ")
5480
      || atom[a_ref - 1].neighbor_count != 2)
5480
      || atom[a_ref - 1].neighbor_count != 2)
5481
    return false;
5481
    return isfalse;
5482
  get_nextneighbors (nb, a_ref, a_view);
5482
  get_nextneighbors (nb, a_ref, a_view);
5483
  a2 = nb[0];
5483
  a2 = nb[0];
5484
  if ((strcmp (atom[a2 - 1].element, "O ") == 0) &&
5484
  if ((strcmp (atom[a2 - 1].element, "O ") == 0) &&
5485
      (bond[get_bond (a_ref, a2) - 1].btype == 'D'))
5485
      (bond[get_bond (a_ref, a2) - 1].btype == 'D'))
5486
    o_count++;
5486
    o_count++;
5487
  if (o_count == 1)
5487
  if (o_count == 1)
5488
    r = true;
5488
    r = istrue;
5489
  return r;
5489
  return r;
5490
}
5490
}
5491
 
5491
 
5492
static boolean is_subst_hydrazino (int a_view, int a_ref)
5492
static boolean is_subst_hydrazino (int a_view, int a_ref)
5493
{
5493
{
5494
  int i;
5494
  int i;
5495
  boolean r = false;
5495
  boolean r = isfalse;
5496
  neighbor_rec nb;
5496
  neighbor_rec nb;
5497
  int nr_count = 0;
5497
  int nr_count = 0;
5498
  int a2, FORLIM;
5498
  int a2, FORLIM;
5499
 
5499
 
5500
  memset (nb, 0, sizeof (neighbor_rec));
5500
  memset (nb, 0, sizeof (neighbor_rec));
5501
  if (!(atom[a_view - 1].
5501
  if (!(atom[a_view - 1].
5502
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5502
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5503
    return false;
5503
    return isfalse;
5504
  if (strcmp (atom[a_ref - 1].element, "N ")
5504
  if (strcmp (atom[a_ref - 1].element, "N ")
5505
      || atom[a_ref - 1].neighbor_count < 2)
5505
      || atom[a_ref - 1].neighbor_count < 2)
5506
    return false;
5506
    return isfalse;
5507
  get_nextneighbors (nb, a_ref, a_view);
5507
  get_nextneighbors (nb, a_ref, a_view);
5508
  FORLIM = atom[a_ref - 1].neighbor_count - 2;
5508
  FORLIM = atom[a_ref - 1].neighbor_count - 2;
5509
  for (i = 0; i <= FORLIM; i++) {
5509
  for (i = 0; i <= FORLIM; i++) {
5510
    a2 = nb[i];
5510
    a2 = nb[i];
5511
    if ((strcmp (atom[a2 - 1].element, "N ") == 0) && (!is_nitroso (a_ref, a2)))
5511
    if ((strcmp (atom[a2 - 1].element, "N ") == 0) && (!is_nitroso (a_ref, a2)))
5512
            /* v0.3j */
5512
            /* v0.3j */
5513
            nr_count++;
5513
            nr_count++;
5514
  }
5514
  }
5515
  if (nr_count == 1)
5515
  if (nr_count == 1)
5516
    r = true;
5516
    r = istrue;
5517
  return r;
5517
  return r;
5518
}
5518
}
5519
 
5519
 
5520
static boolean is_cyano (int a_view, int a_ref)
5520
static boolean is_cyano (int a_view, int a_ref)
5521
{
5521
{
5522
  boolean r = false;
5522
  boolean r = isfalse;
5523
 
5523
 
5524
  if (((strcmp (atom[a_view - 1].atype, "C1 ") == 0) &&
5524
  if (((strcmp (atom[a_view - 1].atype, "C1 ") == 0) &&
5525
      (bond[get_bond (a_view, a_ref) - 1].btype == 'T')) &&
5525
      (bond[get_bond (a_view, a_ref) - 1].btype == 'T')) &&
5526
      !strcmp (atom[a_ref - 1].atype, "N1 ") &&
5526
      !strcmp (atom[a_ref - 1].atype, "N1 ") &&
5527
      atom[a_ref - 1].neighbor_count == 1)
5527
      atom[a_ref - 1].neighbor_count == 1)
5528
    r = true;
5528
    r = istrue;
5529
  return r;
5529
  return r;
5530
}
5530
}
5531
 
5531
 
5532
static boolean is_cyano_c (int a_ref)
5532
static boolean is_cyano_c (int a_ref)
5533
{
5533
{
5534
  int i;
5534
  int i;
5535
  boolean r = false;
5535
  boolean r = isfalse;
5536
  neighbor_rec nb;
5536
  neighbor_rec nb;
5537
  int FORLIM;
5537
  int FORLIM;
5538
 
5538
 
5539
  memset (nb, 0, sizeof (neighbor_rec));
5539
  memset (nb, 0, sizeof (neighbor_rec));
5540
  if (strcmp (atom[a_ref - 1].atype, "C1 ")
5540
  if (strcmp (atom[a_ref - 1].atype, "C1 ")
5541
      || atom[a_ref - 1].neighbor_count <= 0)
5541
      || atom[a_ref - 1].neighbor_count <= 0)
5542
    return false;
5542
    return isfalse;
5543
  get_neighbors (nb, a_ref);
5543
  get_neighbors (nb, a_ref);
5544
  FORLIM = atom[a_ref - 1].neighbor_count;
5544
  FORLIM = atom[a_ref - 1].neighbor_count;
5545
  for (i = 0; i < FORLIM; i++) {
5545
  for (i = 0; i < FORLIM; i++) {
5546
    if (is_cyano (a_ref, nb[i]))
5546
    if (is_cyano (a_ref, nb[i]))
5547
            r = true;
5547
            r = istrue;
5548
  }
5548
  }
5549
  return r;
5549
  return r;
5550
}
5550
}
5551
 
5551
 
5552
static boolean is_nitrile (int a_view, int a_ref)
5552
static boolean is_nitrile (int a_view, int a_ref)
5553
{
5553
{
5554
  boolean r = false;
5554
  boolean r = isfalse;
5555
  neighbor_rec nb;
5555
  neighbor_rec nb;
5556
  str2 nb_el;
5556
  str2 nb_el;
5557
 
5557
 
5558
  if (!is_cyano (a_view, a_ref))
5558
  if (!is_cyano (a_view, a_ref))
5559
    return false;
5559
    return isfalse;
5560
  if (atom[a_view - 1].neighbor_count == 1
5560
  if (atom[a_view - 1].neighbor_count == 1
5561
      && atom[a_view - 1].formal_charge == 0)
5561
      && atom[a_view - 1].formal_charge == 0)
5562
    return true;
5562
    return istrue;
5563
/* p2c: checkmol.pas: Note: Eliminated unused assignment statement [338] */
5563
/* p2c: checkmol.pas: Note: Eliminated unused assignment statement [338] */
5564
  get_nextneighbors (nb, a_view, a_ref);
5564
  get_nextneighbors (nb, a_view, a_ref);
5565
  strcpy (nb_el, atom[nb[0] - 1].element);
5565
  strcpy (nb_el, atom[nb[0] - 1].element);
5566
  if (!strcmp (nb_el, "C ")
5566
  if (!strcmp (nb_el, "C ")
5567
      || !strcmp (nb_el, "H ") /*|| !strcmp (nb_el, "D ") */ )
5567
      || !strcmp (nb_el, "H ") /*|| !strcmp (nb_el, "D ") */ )
5568
    /* v0.3n: D */
5568
    /* v0.3n: D */
5569
    r = true;
5569
    r = istrue;
5570
  /* HCN is also a nitrile! */
5570
  /* HCN is also a nitrile! */
5571
  return r;
5571
  return r;
5572
}
5572
}
5573
 
5573
 
5574
static boolean is_isonitrile (int a_view, int a_ref)
5574
static boolean is_isonitrile (int a_view, int a_ref)
5575
{
5575
{
5576
  /* only recognized with CN triple bond! */
5576
  /* only recognized with CN triple bond! */
5577
  boolean r = false;
5577
  boolean r = isfalse;
5578
 
5578
 
5579
  if (((strcmp (atom[a_view - 1].atype, "C1 ") == 0) &&
5579
  if (((strcmp (atom[a_view - 1].atype, "C1 ") == 0) &&
5580
       (bond[get_bond (a_view, a_ref) - 1].btype == 'T')) &&
5580
       (bond[get_bond (a_view, a_ref) - 1].btype == 'T')) &&
5581
      !strcmp (atom[a_ref - 1].atype, "N1 ") &&
5581
      !strcmp (atom[a_ref - 1].atype, "N1 ") &&
5582
      atom[a_ref - 1].neighbor_count == 2
5582
      atom[a_ref - 1].neighbor_count == 2
5583
      && atom[a_view - 1].neighbor_count == 1)
5583
      && atom[a_view - 1].neighbor_count == 1)
5584
    r = true;
5584
    r = istrue;
5585
  return r;
5585
  return r;
5586
}
5586
}
5587
 
5587
 
5588
static boolean is_cyanate (int a_view, int a_ref)
5588
static boolean is_cyanate (int a_view, int a_ref)
5589
{
5589
{
5590
  boolean r = false;
5590
  boolean r = isfalse;
5591
  neighbor_rec nb;
5591
  neighbor_rec nb;
5592
 
5592
 
5593
  if (!is_cyano (a_view, a_ref))
5593
  if (!is_cyano (a_view, a_ref))
5594
    return false;
5594
    return isfalse;
5595
  if (atom[a_view - 1].neighbor_count != 2)
5595
  if (atom[a_view - 1].neighbor_count != 2)
5596
    return false;
5596
    return isfalse;
5597
  get_nextneighbors (nb, a_view, a_ref);
5597
  get_nextneighbors (nb, a_view, a_ref);
5598
  if (is_alkoxy (a_view, nb[0]) || is_aryloxy (a_view, nb[0]))
5598
  if (is_alkoxy (a_view, nb[0]) || is_aryloxy (a_view, nb[0]))
5599
    r = true;
5599
    r = istrue;
5600
  return r;
5600
  return r;
5601
}
5601
}
5602
 
5602
 
5603
static boolean is_thiocyanate (int a_view, int a_ref)
5603
static boolean is_thiocyanate (int a_view, int a_ref)
5604
{
5604
{
5605
  boolean r = false;
5605
  boolean r = isfalse;
5606
  neighbor_rec nb;
5606
  neighbor_rec nb;
5607
 
5607
 
5608
  if (!is_cyano (a_view, a_ref))
5608
  if (!is_cyano (a_view, a_ref))
5609
    return false;
5609
    return isfalse;
5610
  if (atom[a_view - 1].neighbor_count != 2)
5610
  if (atom[a_view - 1].neighbor_count != 2)
5611
    return false;
5611
    return isfalse;
5612
  get_nextneighbors (nb, a_view, a_ref);
5612
  get_nextneighbors (nb, a_view, a_ref);
5613
  if (is_alkylsulfanyl (a_view, nb[0]) || is_arylsulfanyl (a_view, nb[0]))
5613
  if (is_alkylsulfanyl (a_view, nb[0]) || is_arylsulfanyl (a_view, nb[0]))
5614
    r = true;
5614
    r = istrue;
5615
  return r;
5615
  return r;
5616
}
5616
}
5617
 
5617
 
5618
static void update_Htotal ()
5618
static void update_Htotal ()
5619
{
5619
{
5620
  int i, j, b_id;
5620
  int i, j, b_id;
5621
  neighbor_rec nb;
5621
  neighbor_rec nb;
5622
  int single_count, double_count, triple_count, arom_count, total_bonds,
5622
  int single_count, double_count, triple_count, arom_count, total_bonds,
5623
    Htotal, nval;
5623
    Htotal, nval;
5624
  /* new in v0.3 */
5624
  /* new in v0.3 */
5625
  boolean diazon = false;       /* new in v0.3j */
5625
  boolean diazon = isfalse;     /* new in v0.3j */
5626
  neighbor_rec nb2;             /* new in v0.3j */
5626
  neighbor_rec nb2;             /* new in v0.3j */
5627
  int a1, a2, a3;               /* new in v0.3j */
5627
  int a1, a2, a3;               /* new in v0.3j */
5628
  int FORLIM, FORLIM1;
5628
  int FORLIM, FORLIM1;
5629
 
5629
 
5630
  if (n_atoms < 1)
5630
  if (n_atoms < 1)
Line 5661... Line 5661...
5661
            if (!strcmp (atom[a1 - 1].element, "N ") && !strcmp (atom[a2 - 1].element, "N ")) {
5661
            if (!strcmp (atom[a1 - 1].element, "N ") && !strcmp (atom[a2 - 1].element, "N ")) {
5662
              if (atom[a2 - 1].neighbor_count == 2) {
5662
              if (atom[a2 - 1].neighbor_count == 2) {
5663
                      get_nextneighbors (nb2, a2, a1);
5663
                      get_nextneighbors (nb2, a2, a1);
5664
                      a3 = nb2[0];
5664
                      a3 = nb2[0];
5665
                      if ((strcmp (atom[a3 - 1].element, "C ") == 0) && is_diazonium (a3, a2))
5665
                      if ((strcmp (atom[a3 - 1].element, "C ") == 0) && is_diazonium (a3, a2))
5666
                        diazon = true;
5666
                        diazon = istrue;
5667
                  }
5667
                  }
5668
            }
5668
            }
5669
          }
5669
          }
5670
    total_bonds = single_count + double_count * 2 + triple_count * 3 + (int) (1.5 * arom_count);
5670
    total_bonds = single_count + double_count * 2 + triple_count * 3 + (int) (1.5 * arom_count);
5671
      /* calculate number of total hydrogens per atom */
5671
      /* calculate number of total hydrogens per atom */
Line 5816... Line 5816...
5816
                      /* N-oxide is N3 except in hetarene etc. */
5816
                      /* N-oxide is N3 except in hetarene etc. */
5817
                      else
5817
                      else
5818
                        strcpy (atom[i].atype, "N2 ");
5818
                        strcpy (atom[i].atype, "N2 ");
5819
                    }
5819
                    }
5820
              /* fallback, added in v0.3g  */
5820
              /* fallback, added in v0.3g  */
5821
              if (arom_count > 1 || atom[i].arom == true)       /* v0.3n */
5821
              if (arom_count > 1 || atom[i].arom == istrue)     /* v0.3n */
5822
                      strcpy (atom[i].atype, "NAR");
5822
                      strcpy (atom[i].atype, "NAR");
5823
              if (triple_count == 0 && double_count == 0) {
5823
              if (triple_count == 0 && double_count == 0) {
5824
                      if (atom[i].formal_charge == 0) {
5824
                      if (atom[i].formal_charge == 0) {
5825
                        if (acyl_count == 0)
5825
                        if (acyl_count == 0)
5826
                                strcpy (atom[i].atype, "N3 ");
5826
                                strcpy (atom[i].atype, "N3 ");
Line 5876... Line 5876...
5876
    ring_size = ringprop[i].size;
5876
    ring_size = ringprop[i].size;
5877
    if (ring_size == 6) {
5877
    if (ring_size == 6) {
5878
            memset (testring, 0, sizeof (ringpath_type));
5878
            memset (testring, 0, sizeof (ringpath_type));
5879
            for (j = 0; j < ring_size; j++)
5879
            for (j = 0; j < ring_size; j++)
5880
              testring[j] = ring[i][j];
5880
              testring[j] = ring[i][j];
5881
            cumul = false;
5881
            cumul = isfalse;
5882
            n_sb = 0;
5882
            n_sb = 0;
5883
            n_db = 0;
5883
            n_db = 0;
5884
            n_ar = 0;
5884
            n_ar = 0;
5885
            a_prev = testring[ring_size - 1];
5885
            a_prev = testring[ring_size - 1];
5886
            for (j = 1; j <= ring_size; j++) {
5886
            for (j = 1; j <= ring_size; j++) {
Line 5898... Line 5898...
5898
              if (bt_fw == 'D')
5898
              if (bt_fw == 'D')
5899
                n_db++;
5899
                n_db++;
5900
              if (bt_fw == 'A')
5900
              if (bt_fw == 'A')
5901
                      n_ar++;
5901
                      n_ar++;
5902
              if (bt_fw != 'A' && bt_bk == bt_fw)
5902
              if (bt_fw != 'A' && bt_bk == bt_fw)
5903
                      cumul = true;
5903
                      cumul = istrue;
5904
              a_prev = a_ref;
5904
              a_prev = a_ref;
5905
            }
5905
            }
5906
            if (n_ar == 6 || (n_sb == 3 && n_db == 3 && cumul == false)) {
5906
            if (n_ar == 6 || (n_sb == 3 && n_db == 3 && cumul == isfalse)) {
5907
              /* this ring is aromatic */
5907
              /* this ring is aromatic */
5908
              a_prev = testring[ring_size - 1];
5908
              a_prev = testring[ring_size - 1];
5909
              for (j = 0; j < ring_size; j++) {
5909
              for (j = 0; j < ring_size; j++) {
5910
                      a_ref = testring[j];
5910
                      a_ref = testring[j];
5911
                      b_bk = get_bond (a_prev, a_ref);
5911
                      b_bk = get_bond (a_prev, a_ref);
5912
                      bond[b_bk - 1].arom = true;
5912
                      bond[b_bk - 1].arom = istrue;
5913
                      a_prev = a_ref;
5913
                      a_prev = a_ref;
5914
                    }
5914
                    }
5915
              ringprop[i].arom = true;
5915
              ringprop[i].arom = istrue;
5916
            }
5916
            }
5917
          }
5917
          }
5918
  }
5918
  }
5919
  FORLIM = n_rings;
5919
  FORLIM = n_rings;
5920
  for (i = 1; i <= FORLIM; i++) {
5920
  for (i = 1; i <= FORLIM; i++) {
5921
    if (ringprop[i - 1].arom == false) {
5921
    if (ringprop[i - 1].arom == isfalse) {
5922
            /* do the hard work only for those rings which are not yet flagged aromatic */
5922
            /* do the hard work only for those rings which are not yet flagged aromatic */
5923
            memset (testring, 0, sizeof (ringpath_type));
5923
            memset (testring, 0, sizeof (ringpath_type));
5924
            ring_size = ringprop[i - 1].size;   /* v0.3j */
5924
            ring_size = ringprop[i - 1].size;   /* v0.3j */
5925
            for (j = 0; j < ring_size; j++)     /* v0.3j */
5925
            for (j = 0; j < ring_size; j++)     /* v0.3j */
5926
              testring[j] = ring[i - 1][j];
5926
              testring[j] = ring[i - 1][j];
5927
            pi_count = 0;
5927
            pi_count = 0;
5928
            arom_pi_diff = 0;   /* v0.3j */
5928
            arom_pi_diff = 0;   /* v0.3j */
5929
      /* p2c: checkmol.pas: Note: Eliminated unused assignment statement [338] */
5929
      /* p2c: checkmol.pas: Note: Eliminated unused assignment statement [338] */
5930
            ko = false;
5930
            ko = isfalse;
5931
            a_prev = testring[ring_size - 1];
5931
            a_prev = testring[ring_size - 1];
5932
            for (j = 1; j <= ring_size; j++) {
5932
            for (j = 1; j <= ring_size; j++) {
5933
              a_ref = testring[j - 1];
5933
              a_ref = testring[j - 1];
5934
              if (j < ring_size)
5934
              if (j < ring_size)
5935
                a_next = testring[j];
5935
                a_next = testring[j];
Line 5939... Line 5939...
5939
              b_fw = get_bond (a_ref, a_next);
5939
              b_fw = get_bond (a_ref, a_next);
5940
              bt_bk = bond[b_bk - 1].btype;
5940
              bt_bk = bond[b_bk - 1].btype;
5941
              bt_fw = bond[b_fw - 1].btype;
5941
              bt_fw = bond[b_fw - 1].btype;
5942
              ar_bk = bond[b_bk - 1].arom;
5942
              ar_bk = bond[b_bk - 1].arom;
5943
              ar_fw = bond[b_fw - 1].arom;
5943
              ar_fw = bond[b_fw - 1].arom;
5944
              if (bt_bk == 'S' && bt_fw == 'S' && ar_bk == false && ar_fw == false) {
5944
              if (bt_bk == 'S' && bt_fw == 'S' && ar_bk == isfalse && ar_fw == isfalse) {
5945
                /* first, assume the worst case (interrupted conjugation) */
5945
                /* first, assume the worst case (interrupted conjugation) */
5946
                conj_intr = true;
5946
                conj_intr = istrue;
5947
                /* conjugation can be restored by hetero atoms */
5947
                /* conjugation can be restored by hetero atoms */
5948
                if (!strcmp (atom[a_ref - 1].atype, "O3 ") ||
5948
                if (!strcmp (atom[a_ref - 1].atype, "O3 ") ||
5949
                    !strcmp (atom[a_ref - 1].atype, "S3 ") ||
5949
                    !strcmp (atom[a_ref - 1].atype, "S3 ") ||
5950
                          !strcmp (atom[a_ref - 1].element, "N ") ||
5950
                          !strcmp (atom[a_ref - 1].element, "N ") ||
5951
                          !strcmp (atom[a_ref - 1].element, "SE")) {
5951
                          !strcmp (atom[a_ref - 1].element, "SE")) {
5952
                        conj_intr = false;
5952
                        conj_intr = isfalse;
5953
                        pi_count += 2;  /* lone pair adds for 2 pi electrons */
5953
                        pi_count += 2;  /* lone pair adds for 2 pi electrons */
5954
                      }
5954
                      }
5955
                      /* conjugation can be restored by a formal charge at a methylene group */
5955
                      /* conjugation can be restored by a formal charge at a methylene group */
5956
                      if (!strcmp (atom[a_ref - 1].element, "C ") &&
5956
                      if (!strcmp (atom[a_ref - 1].element, "C ") &&
5957
                          atom[a_ref - 1].formal_charge != 0) {
5957
                          atom[a_ref - 1].formal_charge != 0) {
5958
                          conj_intr = false;
5958
                          conj_intr = isfalse;
5959
                          pi_count -= atom[a_ref - 1].formal_charge;
5959
                          pi_count -= atom[a_ref - 1].formal_charge;
5960
                          /* neg. charge increases pi_count! */
5960
                          /* neg. charge increases pi_count! */
5961
                      }
5961
                      }
5962
                      /* conjugation can be restored by carbonyl groups etc. */
5962
                      /* conjugation can be restored by carbonyl groups etc. */
5963
                      if (is_oxo_C (a_ref) || is_thioxo_C (a_ref) |
5963
                      if (is_oxo_C (a_ref) || is_thioxo_C (a_ref) |
5964
                          is_exocyclic_imino_C (a_ref, i))
5964
                          is_exocyclic_imino_C (a_ref, i))
5965
                        conj_intr = false;
5965
                        conj_intr = isfalse;
5966
                      /* conjugation can be restored by exocyclic C=C double bond, */
5966
                      /* conjugation can be restored by exocyclic C=C double bond, */
5967
                      /* adds 2 pi electrons to 5-membered rings, not to 7-membered rings (CAUTION!) */
5967
                      /* adds 2 pi electrons to 5-membered rings, not to 7-membered rings (CAUTION!) */
5968
                      /* apply only to non-aromatic exocyclic C=C bonds */
5968
                      /* apply only to non-aromatic exocyclic C=C bonds */
5969
                      exo_mC = find_exocyclic_methylene_C (a_ref, i);   /* v0.3j */
5969
                      exo_mC = find_exocyclic_methylene_C (a_ref, i);   /* v0.3j */
5970
                      if (exo_mC > 0 && (ring_size & 1)) {              /* v0.3j */
5970
                      if (exo_mC > 0 && (ring_size & 1)) {              /* v0.3j */
5971
                          b_exo = get_bond (a_ref, exo_mC);     /* v0.3j  */
5971
                          b_exo = get_bond (a_ref, exo_mC);     /* v0.3j  */
5972
                          ar_exo = bond[b_exo - 1].arom;
5972
                          ar_exo = bond[b_exo - 1].arom;
5973
                        if (((ring_size - 1) & 3) == 0) {       /* 5-membered rings and related */
5973
                        if (((ring_size - 1) & 3) == 0) {       /* 5-membered rings and related */
5974
                                conj_intr = false;
5974
                                conj_intr = isfalse;
5975
                                pi_count += 2;
5975
                                pi_count += 2;
5976
                              }
5976
                              }
5977
                        else {
5977
                        else {
5978
                                if (!ar_exo)
5978
                                if (!ar_exo)
5979
                                  conj_intr = false;
5979
                                  conj_intr = isfalse;
5980
                              }
5980
                              }
5981
                      }
5981
                      }
5982
                      /* 7-membered rings and related */
5982
                      /* 7-membered rings and related */
5983
                      /* if conjugation is still interrupted ==> knock-out */
5983
                      /* if conjugation is still interrupted ==> knock-out */
5984
                      if (conj_intr)
5984
                      if (conj_intr)
5985
                        ko = true;
5985
                        ko = istrue;
5986
                    }
5986
                    }
5987
              else {
5987
              else {
5988
                      if (bt_bk == 'S' && bt_fw == 'S' && ar_bk == true && ar_fw == true) {
5988
                      if (bt_bk == 'S' && bt_fw == 'S' && ar_bk == istrue && ar_fw == istrue) {
5989
                        if (!strcmp (atom[a_ref - 1].atype, "O3 ") ||
5989
                        if (!strcmp (atom[a_ref - 1].atype, "O3 ") ||
5990
                                  !strcmp (atom[a_ref - 1].atype, "S3 ") ||
5990
                                  !strcmp (atom[a_ref - 1].atype, "S3 ") ||
5991
                                  !strcmp (atom[a_ref - 1].element, "N ") ||
5991
                                  !strcmp (atom[a_ref - 1].element, "N ") ||
5992
                                  !strcmp (atom[a_ref - 1].element, "SE"))
5992
                                  !strcmp (atom[a_ref - 1].element, "SE"))
5993
                                pi_count += 2;  /* lone pair adds for 2 pi electrons */
5993
                                pi_count += 2;  /* lone pair adds for 2 pi electrons */
Line 6004... Line 6004...
6004
                                  pi_count += 2;
6004
                                  pi_count += 2;
6005
                              }
6005
                              }
6006
                      }
6006
                      }
6007
                      else {
6007
                      else {
6008
                  pi_count++;   /* v0.3j; adjustment for bridgehead N: see below */
6008
                  pi_count++;   /* v0.3j; adjustment for bridgehead N: see below */
6009
                  if (bt_bk == 'S' && bt_fw == 'S' && ((ar_bk == true && ar_fw == false) ||
6009
                  if (bt_bk == 'S' && bt_fw == 'S' && ((ar_bk == istrue && ar_fw == isfalse) ||
6010
                                  (ar_bk == false && ar_fw == true))) {
6010
                                  (ar_bk == isfalse && ar_fw == istrue))) {
6011
                                /* v0.3j; if a bridgehead N were not aromatic, it could  */
6011
                                /* v0.3j; if a bridgehead N were not aromatic, it could  */
6012
                                /* contribute 2 pi electrons --> try also this variant */
6012
                                /* contribute 2 pi electrons --> try also this variant */
6013
                                /* (example: CAS 32278-54-9) */
6013
                                /* (example: CAS 32278-54-9) */
6014
                                if (!strcmp (atom[a_ref - 1].element, "N ")) {
6014
                                if (!strcmp (atom[a_ref - 1].element, "N ")) {
6015
                                  arom_pi_diff++;
6015
                                  arom_pi_diff++;
Line 6027... Line 6027...
6027
              /* v0.3j; odd pi_count might be compensated by arom_pi_diff */
6027
              /* v0.3j; odd pi_count might be compensated by arom_pi_diff */
6028
                          /* apply Hueckel's rule */
6028
                          /* apply Hueckel's rule */
6029
              if (labs (ring_size - pi_count) < 2 &&
6029
              if (labs (ring_size - pi_count) < 2 &&
6030
                        (((pi_count - 2) & 3) == 0 || ((pi_count + arom_pi_diff - 2) & 3) == 0)) {
6030
                        (((pi_count - 2) & 3) == 0 || ((pi_count + arom_pi_diff - 2) & 3) == 0)) {
6031
                      /* this ring is aromatic */
6031
                      /* this ring is aromatic */
6032
                      ringprop[i - 1].arom = true;
6032
                      ringprop[i - 1].arom = istrue;
6033
                      /* now mark _all_ bonds in the ring as aromatic */
6033
                      /* now mark _all_ bonds in the ring as aromatic */
6034
                      a_prev = testring[ring_size - 1];
6034
                      a_prev = testring[ring_size - 1];
6035
                      for (j = 0; j < ring_size; j++) {
6035
                      for (j = 0; j < ring_size; j++) {
6036
                        a_ref = testring[j];
6036
                        a_ref = testring[j];
6037
                        bond[get_bond (a_prev, a_ref) - 1].arom = true;
6037
                        bond[get_bond (a_prev, a_ref) - 1].arom = istrue;
6038
                        a_prev = a_ref;
6038
                        a_prev = a_ref;
6039
                      }
6039
                      }
6040
                    }
6040
                    }
6041
            }
6041
            }
6042
          }
6042
          }
Line 6045... Line 6045...
6045
  /* finally, mark all involved atoms as aromatic */
6045
  /* finally, mark all involved atoms as aromatic */
6046
  for (i = 0; i < FORLIM; i++) {
6046
  for (i = 0; i < FORLIM; i++) {
6047
    if (bond[i].arom) {
6047
    if (bond[i].arom) {
6048
            a1 = bond[i].a1;    /* v0.3n */
6048
            a1 = bond[i].a1;    /* v0.3n */
6049
            a2 = bond[i].a2;    /* v0.3n */
6049
            a2 = bond[i].a2;    /* v0.3n */
6050
            atom[a1 - 1].arom = true;
6050
            atom[a1 - 1].arom = istrue;
6051
            atom[a2 - 1].arom = true;
6051
            atom[a2 - 1].arom = istrue;
6052
            /* v0.3n: update atom types if applicable (C and N) */
6052
            /* v0.3n: update atom types if applicable (C and N) */
6053
            if (!strcmp (atom[a1 - 1].element, "C "))
6053
            if (!strcmp (atom[a1 - 1].element, "C "))
6054
              strcpy (atom[a1 - 1].atype, "CAR");
6054
              strcpy (atom[a1 - 1].atype, "CAR");
6055
            if (!strcmp (atom[a2 - 1].element, "C "))
6055
            if (!strcmp (atom[a2 - 1].element, "C "))
6056
              strcpy (atom[a2 - 1].atype, "CAR");
6056
              strcpy (atom[a2 - 1].atype, "CAR");
Line 6065... Line 6065...
6065
  /* new in v0.3n: accept rings as aromatic if all bonds are of type 'A' */
6065
  /* new in v0.3n: accept rings as aromatic if all bonds are of type 'A' */
6066
  for (i = 0; i < FORLIM; i++) {
6066
  for (i = 0; i < FORLIM; i++) {
6067
    memcpy (testring, ring[i], sizeof (ringpath_type));
6067
    memcpy (testring, ring[i], sizeof (ringpath_type));
6068
    /*ring_size := path_length(testring); */
6068
    /*ring_size := path_length(testring); */
6069
    ring_size = ringprop[i].size;       /* v0.3j */
6069
    ring_size = ringprop[i].size;       /* v0.3j */
6070
    aromatic = true;
6070
    aromatic = istrue;
6071
    aromatic_bt = true; /* v0.3n */
6071
    aromatic_bt = istrue;       /* v0.3n */
6072
    a_prev = testring[ring_size - 1];
6072
    a_prev = testring[ring_size - 1];
6073
    for (j = 0; j < ring_size; j++) {
6073
    for (j = 0; j < ring_size; j++) {
6074
            a_ref = testring[j];
6074
            a_ref = testring[j];
6075
            b = get_bond (a_prev, a_ref);       /* v0.3n */
6075
            b = get_bond (a_prev, a_ref);       /* v0.3n */
6076
            if (!bond[b - 1].arom)
6076
            if (!bond[b - 1].arom)
6077
              aromatic = false;
6077
              aromatic = isfalse;
6078
            if (bond[b - 1].btype != 'A')       /* v0.3n */
6078
            if (bond[b - 1].btype != 'A')       /* v0.3n */
6079
              aromatic_bt = false;
6079
              aromatic_bt = isfalse;
6080
            a_prev = a_ref;
6080
            a_prev = a_ref;
6081
          }
6081
          }
6082
    if (aromatic_bt && !aromatic) {                     /* v0.3n: update aromaticity flag */
6082
    if (aromatic_bt && !aromatic) {                     /* v0.3n: update aromaticity flag */
6083
            a_prev = testring[ring_size - 1];
6083
            a_prev = testring[ring_size - 1];
6084
            for (j = 0; j < ring_size; j++) {
6084
            for (j = 0; j < ring_size; j++) {
6085
              a_ref = testring[j];
6085
              a_ref = testring[j];
6086
              b = get_bond (a_prev, a_ref);
6086
              b = get_bond (a_prev, a_ref);
6087
              bond[b - 1].arom = true;
6087
              bond[b - 1].arom = istrue;
6088
              if (!strcmp (atom[a_ref - 1].element, "C "))
6088
              if (!strcmp (atom[a_ref - 1].element, "C "))
6089
                      strcpy (atom[a_ref - 1].atype, "CAR");
6089
                      strcpy (atom[a_ref - 1].atype, "CAR");
6090
              if (!strcmp (atom[a_ref - 1].element, "N "))
6090
              if (!strcmp (atom[a_ref - 1].element, "N "))
6091
                      strcpy (atom[a_ref - 1].atype, "NAR");
6091
                      strcpy (atom[a_ref - 1].atype, "NAR");
6092
              a_prev = a_ref;
6092
              a_prev = a_ref;
6093
            }
6093
            }
6094
            aromatic = true;
6094
            aromatic = istrue;
6095
          }                     /* end v0.3n block   */
6095
          }                     /* end v0.3n block   */
6096
    if (aromatic)
6096
    if (aromatic)
6097
            ringprop[i].arom = true;
6097
            ringprop[i].arom = istrue;
6098
    else
6098
    else
6099
            ringprop[i].arom = false;
6099
            ringprop[i].arom = isfalse;
6100
  }
6100
  }
6101
}
6101
}
6102
 
6102
 
6103
static void write_mol ()
6103
static void write_mol ()
6104
{
6104
{
Line 6146... Line 6146...
6146
  if (n_rings <= 0)
6146
  if (n_rings <= 0)
6147
    return;
6147
    return;
6148
  FORLIM = n_rings;
6148
  FORLIM = n_rings;
6149
  for (i = 0; i < FORLIM; i++) {
6149
  for (i = 0; i < FORLIM; i++) {
6150
    printf ("ring %d: ", i + 1);
6150
    printf ("ring %d: ", i + 1);
6151
    /*aromatic := true; */
6151
    /*aromatic := istrue; */
6152
    memset (testring, 0, sizeof (ringpath_type));
6152
    memset (testring, 0, sizeof (ringpath_type));
6153
    ring_size = ringprop[i].size;       /* v0.3j */
6153
    ring_size = ringprop[i].size;       /* v0.3j */
6154
    /*for j := 1 to max_ringsize do if ring^[i,j] > 0 then testring[j] := ring^[i,j]; */
6154
    /*for j := 1 to max_ringsize do if ring^[i,j] > 0 then testring[j] := ring^[i,j]; */
6155
    for (j = 0; j < ring_size; j++)     /* v0.3j */
6155
    for (j = 0; j < ring_size; j++)     /* v0.3j */
6156
            testring[j] = ring[i][j];
6156
            testring[j] = ring[i][j];
6157
    /*ring_size := path_length(testring); */
6157
    /*ring_size := path_length(testring); */
6158
    /*a_prev := testring[ring_size]; */
6158
    /*a_prev := testring[ring_size]; */
6159
    for (j = 0; j < ring_size; j++) {
6159
    for (j = 0; j < ring_size; j++) {
6160
            printf ("%d ", testring[j]);
6160
            printf ("%d ", testring[j]);
6161
            /*a_ref := testring[j]; */
6161
            /*a_ref := testring[j]; */
6162
            /*if (not bond^[get_bond(a_prev,a_ref)].arom) then aromatic := false; */
6162
            /*if (not bond^[get_bond(a_prev,a_ref)].arom) then aromatic := isfalse; */
6163
            /*a_prev := a_ref; */
6163
            /*a_prev := a_ref; */
6164
          }
6164
          }
6165
    /*if aromatic then write(' (aromatic)'); */
6165
    /*if aromatic then write(' (aromatic)'); */
6166
    if (ringprop[i].arom) printf (" (aromatic)");
6166
    if (ringprop[i].arom) printf (" (aromatic)");
6167
    if (ringprop[i].envelope) printf (" (env)");
6167
    if (ringprop[i].envelope) printf (" (env)");
Line 6215... Line 6215...
6215
  }
6215
  }
6216
  if (ndl_n_rings <= 0)
6216
  if (ndl_n_rings <= 0)
6217
    return;
6217
    return;
6218
  FORLIM = ndl_n_rings;
6218
  FORLIM = ndl_n_rings;
6219
  for (i = 0; i < FORLIM; i++) {
6219
  for (i = 0; i < FORLIM; i++) {
6220
    aromatic = true;
6220
    aromatic = istrue;
6221
    memset (testring, 0, sizeof (ringpath_type));
6221
    memset (testring, 0, sizeof (ringpath_type));
6222
    for (j = 0; j < max_ringsize; j++) {
6222
    for (j = 0; j < max_ringsize; j++) {
6223
            if (ndl_ring[i][j] > 0)
6223
            if (ndl_ring[i][j] > 0)
6224
              testring[j] = ndl_ring[i][j];
6224
              testring[j] = ndl_ring[i][j];
6225
          }
6225
          }
Line 6228... Line 6228...
6228
    a_prev = testring[ring_size - 1];
6228
    a_prev = testring[ring_size - 1];
6229
    for (j = 0; j < ring_size; j++) {
6229
    for (j = 0; j < ring_size; j++) {
6230
            printf ("%d ", testring[j]);
6230
            printf ("%d ", testring[j]);
6231
            a_ref = testring[j];
6231
            a_ref = testring[j];
6232
            if (!ndl_bond[get_ndl_bond (a_prev, a_ref) - 1].arom)       /* v0.3k */
6232
            if (!ndl_bond[get_ndl_bond (a_prev, a_ref) - 1].arom)       /* v0.3k */
6233
              aromatic = false;
6233
              aromatic = isfalse;
6234
            a_prev = a_ref;
6234
            a_prev = a_ref;
6235
          }
6235
          }
6236
    if (aromatic) printf (" (aromatic)");
6236
    if (aromatic) printf (" (aromatic)");
6237
    putchar ('\n');
6237
    putchar ('\n');
6238
  }
6238
  }
Line 6274... Line 6274...
6274
                || !strcmp (nb_el, "AT"))
6274
                || !strcmp (nb_el, "AT"))
6275
              hal_count++;
6275
              hal_count++;
6276
          }
6276
          }
6277
  }
6277
  }
6278
  if (het_count == 2) {                                 /* sulfuric acid derivative */
6278
  if (het_count == 2) {                                 /* sulfuric acid derivative */
6279
    fg[fg_sulfuric_acid_deriv - 1] = true;
6279
    fg[fg_sulfuric_acid_deriv - 1] = istrue;
6280
    if (o_count == 2) {
6280
    if (o_count == 2) {
6281
            if (or_count == 0)
6281
            if (or_count == 0)
6282
              fg[fg_sulfuric_acid - 1] = true;
6282
              fg[fg_sulfuric_acid - 1] = istrue;
6283
            if (or_count == 1)
6283
            if (or_count == 1)
6284
              fg[fg_sulfuric_acid_monoester - 1] = true;
6284
              fg[fg_sulfuric_acid_monoester - 1] = istrue;
6285
            if (or_count == 2)
6285
            if (or_count == 2)
6286
              fg[fg_sulfuric_acid_diester - 1] = true;
6286
              fg[fg_sulfuric_acid_diester - 1] = istrue;
6287
          }
6287
          }
6288
    if (o_count == 1) {
6288
    if (o_count == 1) {
6289
            if (or_count == 1 && n_count == 1)
6289
            if (or_count == 1 && n_count == 1)
6290
              fg[fg_sulfuric_acid_amide_ester - 1] = true;
6290
              fg[fg_sulfuric_acid_amide_ester - 1] = istrue;
6291
            if (or_count == 0 && n_count == 1)
6291
            if (or_count == 0 && n_count == 1)
6292
              fg[fg_sulfuric_acid_amide - 1] = true;
6292
              fg[fg_sulfuric_acid_amide - 1] = istrue;
6293
          }
6293
          }
6294
    if (n_count == 2)
6294
    if (n_count == 2)
6295
            fg[fg_sulfuric_acid_diamide - 1] = true;
6295
            fg[fg_sulfuric_acid_diamide - 1] = istrue;
6296
    if (hal_count > 0)
6296
    if (hal_count > 0)
6297
            fg[fg_sulfuryl_halide - 1] = true;
6297
            fg[fg_sulfuryl_halide - 1] = istrue;
6298
  }
6298
  }
6299
  if (het_count == 1 && c_count == 1) {                                 /* sulfonic acid derivative */
6299
  if (het_count == 1 && c_count == 1) {                                 /* sulfonic acid derivative */
6300
    fg[fg_sulfonic_acid_deriv - 1] = true;
6300
    fg[fg_sulfonic_acid_deriv - 1] = istrue;
6301
    if (o_count == 1 && or_count == 0)
6301
    if (o_count == 1 && or_count == 0)
6302
            fg[fg_sulfonic_acid - 1] = true;
6302
            fg[fg_sulfonic_acid - 1] = istrue;
6303
    if (o_count == 1 && or_count == 1)
6303
    if (o_count == 1 && or_count == 1)
6304
            fg[fg_sulfonic_acid_ester - 1] = true;
6304
            fg[fg_sulfonic_acid_ester - 1] = istrue;
6305
    if (n_count == 1)
6305
    if (n_count == 1)
6306
            fg[fg_sulfonamide - 1] = true;
6306
            fg[fg_sulfonamide - 1] = istrue;
6307
    if (hal_count == 1)
6307
    if (hal_count == 1)
6308
            fg[fg_sulfonyl_halide - 1] = true;
6308
            fg[fg_sulfonyl_halide - 1] = istrue;
6309
  }
6309
  }
6310
  if (het_count == 0 && c_count == 2)   /* sulfone */
6310
  if (het_count == 0 && c_count == 2)   /* sulfone */
6311
    fg[fg_sulfone - 1] = true;
6311
    fg[fg_sulfone - 1] = istrue;
6312
}
6312
}
6313
 
6313
 
6314
static void chk_p_deriv (int a_ref)
6314
static void chk_p_deriv (int a_ref)
6315
{
6315
{
6316
  int i;
6316
  int i;
Line 6349... Line 6349...
6349
  het_count = oh_count + or_count + hal_count + n_count;
6349
  het_count = oh_count + or_count + hal_count + n_count;
6350
  if (!strcmp (atom[a_ref - 1].atype, "P3D") ||
6350
  if (!strcmp (atom[a_ref - 1].atype, "P3D") ||
6351
      !strcmp (atom[a_ref - 1].atype, "P4 ")) {
6351
      !strcmp (atom[a_ref - 1].atype, "P4 ")) {
6352
    if (!strcmp (dbl_het, "O ")) {
6352
    if (!strcmp (dbl_het, "O ")) {
6353
            if (c_count == 0) {
6353
            if (c_count == 0) {
6354
              fg[fg_phosphoric_acid_deriv - 1] = true;
6354
              fg[fg_phosphoric_acid_deriv - 1] = istrue;
6355
              if (oh_count == 3)
6355
              if (oh_count == 3)
6356
                fg[fg_phosphoric_acid - 1] = true;
6356
                fg[fg_phosphoric_acid - 1] = istrue;
6357
              if (or_count > 0)
6357
              if (or_count > 0)
6358
                fg[fg_phosphoric_acid_ester - 1] = true;
6358
                fg[fg_phosphoric_acid_ester - 1] = istrue;
6359
              if (hal_count > 0)
6359
              if (hal_count > 0)
6360
                fg[fg_phosphoric_acid_halide - 1] = true;
6360
                fg[fg_phosphoric_acid_halide - 1] = istrue;
6361
              if (n_count > 0)
6361
              if (n_count > 0)
6362
                fg[fg_phosphoric_acid_amide - 1] = true;
6362
                fg[fg_phosphoric_acid_amide - 1] = istrue;
6363
            }
6363
            }
6364
            if (c_count == 1) {
6364
            if (c_count == 1) {
6365
              fg[fg_phosphonic_acid_deriv - 1] = true;
6365
              fg[fg_phosphonic_acid_deriv - 1] = istrue;
6366
              if (oh_count == 2)
6366
              if (oh_count == 2)
6367
                fg[fg_phosphonic_acid - 1] = true;
6367
                fg[fg_phosphonic_acid - 1] = istrue;
6368
              if (or_count > 0)
6368
              if (or_count > 0)
6369
                fg[fg_phosphonic_acid_ester - 1] = true;
6369
                fg[fg_phosphonic_acid_ester - 1] = istrue;
6370
              /*if (hal_count > 0)  then fg[fg_phosphonic_acid_halide] := true;             */
6370
              /*if (hal_count > 0)  then fg[fg_phosphonic_acid_halide] := istrue;             */
6371
              /*if (n_count > 0)    then fg[fg_phosphonic_acid_amide]  := true; */
6371
              /*if (n_count > 0)    then fg[fg_phosphonic_acid_amide]  := istrue; */
6372
            }
6372
            }
6373
            if (c_count == 3)
6373
            if (c_count == 3)
6374
              fg[fg_phosphinoxide - 1] = true;
6374
              fg[fg_phosphinoxide - 1] = istrue;
6375
          }
6375
          }
6376
    if (!strcmp (dbl_het, "S ")) {
6376
    if (!strcmp (dbl_het, "S ")) {
6377
      if (c_count == 0) {
6377
      if (c_count == 0) {
6378
        fg[fg_thiophosphoric_acid_deriv - 1] = true;
6378
        fg[fg_thiophosphoric_acid_deriv - 1] = istrue;
6379
        if (oh_count == 3)
6379
        if (oh_count == 3)
6380
            fg[fg_thiophosphoric_acid - 1] = true;
6380
            fg[fg_thiophosphoric_acid - 1] = istrue;
6381
        if (or_count > 0)
6381
        if (or_count > 0)
6382
            fg[fg_thiophosphoric_acid_ester - 1] = true;
6382
            fg[fg_thiophosphoric_acid_ester - 1] = istrue;
6383
        if (hal_count > 0)
6383
        if (hal_count > 0)
6384
            fg[fg_thiophosphoric_acid_halide - 1] = true;
6384
            fg[fg_thiophosphoric_acid_halide - 1] = istrue;
6385
        if (n_count > 0)
6385
        if (n_count > 0)
6386
            fg[fg_thiophosphoric_acid_amide - 1] = true;
6386
            fg[fg_thiophosphoric_acid_amide - 1] = istrue;
6387
      }
6387
      }
6388
    }
6388
    }
6389
  }
6389
  }
6390
  /*  if (atom^[a_ref].atype = 'P4 ') then fg[fg_phosphoric_acid_deriv] := true; */
6390
  /*  if (atom^[a_ref].atype = 'P4 ') then fg[fg_phosphoric_acid_deriv] := istrue; */
6391
  if (strcmp (atom[a_ref - 1].atype, "P3 "))    /* changed P3D into P3 in v0.3b */
6391
  if (strcmp (atom[a_ref - 1].atype, "P3 "))    /* changed P3D into P3 in v0.3b */
6392
    return;
6392
    return;
6393
  if (c_count == 3 && het_count == 0)
6393
  if (c_count == 3 && het_count == 0)
6394
    fg[fg_phosphine - 1] = true;
6394
    fg[fg_phosphine - 1] = istrue;
6395
  if (c_count == 3 && oh_count == 1)
6395
  if (c_count == 3 && oh_count == 1)
6396
    fg[fg_phosphinoxide - 1] = true;
6396
    fg[fg_phosphinoxide - 1] = istrue;
6397
}
6397
}
6398
 
6398
 
6399
static void chk_b_deriv (int a_ref)
6399
static void chk_b_deriv (int a_ref)
6400
{
6400
{
6401
  int i;
6401
  int i;
Line 6434... Line 6434...
6434
  }
6434
  }
6435
  het_count = oh_count + or_count + hal_count + n_count;
6435
  het_count = oh_count + or_count + hal_count + n_count;
6436
  /* fixed in v0.3b */
6436
  /* fixed in v0.3b */
6437
  if (c_count != 1 || het_count != 2)
6437
  if (c_count != 1 || het_count != 2)
6438
    return;
6438
    return;
6439
  fg[fg_boronic_acid_deriv - 1] = true;
6439
  fg[fg_boronic_acid_deriv - 1] = istrue;
6440
  if (oh_count == 2)
6440
  if (oh_count == 2)
6441
    fg[fg_boronic_acid - 1] = true;
6441
    fg[fg_boronic_acid - 1] = istrue;
6442
  if (or_count > 0)
6442
  if (or_count > 0)
6443
    fg[fg_boronic_acid_ester - 1] = true;
6443
    fg[fg_boronic_acid_ester - 1] = istrue;
6444
}
6444
}
6445
 
6445
 
6446
static void chk_ammon (int a_ref)
6446
static void chk_ammon (int a_ref)
6447
{
6447
{
6448
  int i;
6448
  int i;
Line 6497... Line 6497...
6497
          }
6497
          }
6498
    if (bt == 'A' && ha)
6498
    if (bt == 'A' && ha)
6499
            bo_sum += 1.5;
6499
            bo_sum += 1.5;
6500
  }                             /* v0.3k: corrected end of "for ..." loop */
6500
  }                             /* v0.3k: corrected end of "for ..." loop */
6501
  if (het_count == 0 && r_count == 4)
6501
  if (het_count == 0 && r_count == 4)
6502
    fg[fg_quart_ammonium - 1] = true;
6502
    fg[fg_quart_ammonium - 1] = istrue;
6503
  if (het_count != 1 || atom[a_ref - 1].neighbor_count < 3)
6503
  if (het_count != 1 || atom[a_ref - 1].neighbor_count < 3)
6504
    return;
6504
    return;
6505
  if (o_count == 1 && or_count == 0 && bo_sum > 3)
6505
  if (o_count == 1 && or_count == 0 && bo_sum > 3)
6506
    fg[fg_n_oxide - 1] = true;  /* finds only aliphatic N-oxides! */
6506
    fg[fg_n_oxide - 1] = istrue;        /* finds only aliphatic N-oxides! */
6507
  if (((o_count == 1 && or_count == 1) || o_count == 0) &&
6507
  if (((o_count == 1 && or_count == 1) || o_count == 0) &&
6508
      atom[a_ref - 1].arom == true)
6508
      atom[a_ref - 1].arom == istrue)
6509
    fg[fg_quart_ammonium - 1] = true;
6509
    fg[fg_quart_ammonium - 1] = istrue;
6510
}
6510
}
6511
 
6511
 
6512
static void swap_atoms (int *a1, int *a2)
6512
static void swap_atoms (int *a1, int *a2)
6513
{
6513
{
6514
  int a_tmp;
6514
  int a_tmp;
Line 6557... Line 6557...
6557
  int het_count = 0, c_count = 0, o_count = 0;  /* v0.3k */
6557
  int het_count = 0, c_count = 0, o_count = 0;  /* v0.3k */
6558
  int FORLIM;
6558
  int FORLIM;
6559
 
6559
 
6560
  /* v0.3k */
6560
  /* v0.3k */
6561
  if (atom[a_view - 1].neighbor_count == 1) {
6561
  if (atom[a_view - 1].neighbor_count == 1) {
6562
      if (atom[a_ref - 1].arom == false)
6562
      if (atom[a_ref - 1].arom == isfalse)
6563
        fg[fg_imine - 1] = true;
6563
        fg[fg_imine - 1] = istrue;
6564
      return;
6564
      return;
6565
    }
6565
    }
6566
  memset (nb, 0, sizeof (neighbor_rec));
6566
  memset (nb, 0, sizeof (neighbor_rec));
6567
  get_neighbors (nb, a_view);
6567
  get_neighbors (nb, a_view);
6568
  if (atom[a_view - 1].neighbor_count <= 1)
6568
  if (atom[a_view - 1].neighbor_count <= 1)
Line 6579... Line 6579...
6579
              a_het = nb[i];
6579
              a_het = nb[i];
6580
              het_count++;
6580
              het_count++;
6581
            }
6581
            }
6582
            if ((!strcmp (nb_el, "O ")
6582
            if ((!strcmp (nb_el, "O ")
6583
               && atom[nb[i] - 1].neighbor_count ==
6583
               && atom[nb[i] - 1].neighbor_count ==
6584
               1) && (bond[get_bond (a_view, nb[i]) - 1].arom == false))
6584
               1) && (bond[get_bond (a_view, nb[i]) - 1].arom == isfalse))
6585
              /* v0.3k */
6585
              /* v0.3k */
6586
              o_count++;
6586
              o_count++;
6587
          }
6587
          }
6588
    if ((nb[i] != a_ref) && (bond[get_bond (a_view, nb[i]) - 1].btype == 'D')){
6588
    if ((nb[i] != a_ref) && (bond[get_bond (a_view, nb[i]) - 1].btype == 'D')){
6589
      /* v0.3k; make sure we do not count nitro groups in "azi" form etc. */
6589
      /* v0.3k; make sure we do not count nitro groups in "azi" form etc. */
Line 6592... Line 6592...
6592
              a_het = nb[i];    /* v0.3m */
6592
              a_het = nb[i];    /* v0.3m */
6593
              het_count++;
6593
              het_count++;
6594
            }
6594
            }
6595
            if ((!strcmp (nb_el, "O ")
6595
            if ((!strcmp (nb_el, "O ")
6596
                && atom[nb[i] - 1].neighbor_count == 1) &&
6596
                && atom[nb[i] - 1].neighbor_count == 1) &&
6597
                  (bond[get_bond (a_view, nb[i]) - 1].arom == false))
6597
                  (bond[get_bond (a_view, nb[i]) - 1].arom == isfalse))
6598
              /* v0.3k */
6598
              /* v0.3k */
6599
              o_count++;
6599
              o_count++;
6600
          }
6600
          }
6601
  }
6601
  }
6602
  if (c_count == 1) {
6602
  if (c_count == 1) {
6603
    if ((is_alkyl (a_view, a_c) || is_aryl (a_view, a_c) |
6603
    if ((is_alkyl (a_view, a_c) || is_aryl (a_view, a_c) |
6604
              is_alkenyl (a_view, a_c) || is_alkynyl (a_view, a_c))
6604
              is_alkenyl (a_view, a_c) || is_alkynyl (a_view, a_c))
6605
              && atom[a_ref - 1].arom == false && het_count == 0)
6605
              && atom[a_ref - 1].arom == isfalse && het_count == 0)
6606
            /* v0.3k */
6606
            /* v0.3k */
6607
            fg[fg_imine - 1] = true;
6607
            fg[fg_imine - 1] = istrue;
6608
  }
6608
  }
6609
  if (het_count == 1) {
6609
  if (het_count == 1) {
6610
    strcpy (nb_el, atom[a_het - 1].element);
6610
    strcpy (nb_el, atom[a_het - 1].element);
6611
    if (!strcmp (nb_el, "O ")) {
6611
    if (!strcmp (nb_el, "O ")) {
6612
            if (is_hydroxy (a_view, a_het))
6612
            if (is_hydroxy (a_view, a_het))
6613
              fg[fg_oxime - 1] = true;
6613
              fg[fg_oxime - 1] = istrue;
6614
          if (is_alkoxy (a_view, a_het) || is_aryloxy (a_view, a_het) |
6614
          if (is_alkoxy (a_view, a_het) || is_aryloxy (a_view, a_het) |
6615
              is_alkenyloxy (a_view, a_het) || is_alkynyloxy (a_view, a_het))
6615
              is_alkenyloxy (a_view, a_het) || is_alkynyloxy (a_view, a_het))
6616
            fg[fg_oxime_ether - 1] = true;
6616
            fg[fg_oxime_ether - 1] = istrue;
6617
          }
6617
          }
6618
    if (!strcmp (nb_el, "N ")) {
6618
    if (!strcmp (nb_el, "N ")) {
6619
            if (is_amino (a_view, a_het) || is_alkylamino (a_view, a_het) |
6619
            if (is_amino (a_view, a_het) || is_alkylamino (a_view, a_het) |
6620
                is_dialkylamino (a_view, a_het) || is_alkylarylamino (a_view,a_het) |
6620
                is_dialkylamino (a_view, a_het) || is_alkylarylamino (a_view,a_het) |
6621
                is_arylamino (a_view, a_het) || is_diarylamino (a_view, a_het))
6621
                is_arylamino (a_view, a_het) || is_diarylamino (a_view, a_het))
6622
              fg[fg_hydrazone - 1] = true;
6622
              fg[fg_hydrazone - 1] = istrue;
6623
            else {
6623
            else {
6624
              memset (nb, 0, sizeof (neighbor_rec));
6624
              memset (nb, 0, sizeof (neighbor_rec));
6625
              get_neighbors (nb, a_het);
6625
              get_neighbors (nb, a_het);
6626
              if (atom[a_het - 1].neighbor_count > 1) {
6626
              if (atom[a_het - 1].neighbor_count > 1) {
6627
                      FORLIM = atom[a_het - 1].neighbor_count;
6627
                      FORLIM = atom[a_het - 1].neighbor_count;
6628
                      for (i = 0; i < FORLIM; i++) {
6628
                      for (i = 0; i < FORLIM; i++) {
6629
                        if (nb[i] != a_view) {
6629
                        if (nb[i] != a_view) {
6630
                                if (is_carbamoyl (a_het, nb[i]))
6630
                                if (is_carbamoyl (a_het, nb[i]))
6631
                                  fg[fg_semicarbazone - 1] = true;
6631
                                  fg[fg_semicarbazone - 1] = istrue;
6632
                                if (is_thiocarbamoyl (a_het, nb[i]))
6632
                                if (is_thiocarbamoyl (a_het, nb[i]))
6633
                                  fg[fg_thiosemicarbazone - 1] = true;
6633
                                  fg[fg_thiosemicarbazone - 1] = istrue;
6634
                              }
6634
                              }
6635
                      }
6635
                      }
6636
                    }
6636
                    }
6637
            }
6637
            }
6638
          }
6638
          }
6639
  }                             /* v0.3k: nitro groups in "azi" form */
6639
  }                             /* v0.3k: nitro groups in "azi" form */
6640
  /* check for semicarbazone or thiosemicarbazone */
6640
  /* check for semicarbazone or thiosemicarbazone */
6641
  if (het_count == 2 && o_count == 2)
6641
  if (het_count == 2 && o_count == 2)
6642
    fg[fg_nitro_compound - 1] = true;
6642
    fg[fg_nitro_compound - 1] = istrue;
6643
}
6643
}
6644
 
6644
 
6645
static void chk_carbonyl_deriv (int a_view, int a_ref)
6645
static void chk_carbonyl_deriv (int a_view, int a_ref)
6646
{
6646
{
6647
  /* a_view = C */
6647
  /* a_view = C */
Line 6673... Line 6673...
6673
              n_db++;
6673
              n_db++;
6674
          }
6674
          }
6675
  }
6675
  }
6676
  /* new in v0.3b */
6676
  /* new in v0.3b */
6677
  if (is_oxo_C (a_view)) {
6677
  if (is_oxo_C (a_view)) {
6678
    fg[fg_carbonyl - 1] = true;
6678
    fg[fg_carbonyl - 1] = istrue;
6679
    if (c_count + cn_count < 2) {                       /* new in v0.3b (detection of ketenes) */
6679
    if (c_count + cn_count < 2) {                       /* new in v0.3b (detection of ketenes) */
6680
            if (n_db <= 1)
6680
            if (n_db <= 1)
6681
              fg[fg_aldehyde - 1] = true;
6681
              fg[fg_aldehyde - 1] = istrue;
6682
            else
6682
            else
6683
              fg[fg_ketene - 1] = true;
6683
              fg[fg_ketene - 1] = istrue;
6684
          }
6684
          }
6685
    if (c_count == 2) {
6685
    if (c_count == 2) {
6686
            if (atom[a_view - 1].arom)
6686
            if (atom[a_view - 1].arom)
6687
              fg[fg_oxohetarene - 1] = true;
6687
              fg[fg_oxohetarene - 1] = istrue;
6688
            else
6688
            else
6689
              fg[fg_ketone - 1] = true;
6689
              fg[fg_ketone - 1] = istrue;
6690
          }
6690
          }
6691
    if (cn_count > 0)
6691
    if (cn_count > 0)
6692
            fg[fg_acyl_cyanide - 1] = true;
6692
            fg[fg_acyl_cyanide - 1] = istrue;
6693
  }
6693
  }
6694
  if (is_thioxo_C (a_view)) {
6694
  if (is_thioxo_C (a_view)) {
6695
    fg[fg_thiocarbonyl - 1] = true;
6695
    fg[fg_thiocarbonyl - 1] = istrue;
6696
    if (c_count < 2)
6696
    if (c_count < 2)
6697
            fg[fg_thioaldehyde - 1] = true;
6697
            fg[fg_thioaldehyde - 1] = istrue;
6698
    if (c_count == 2) {
6698
    if (c_count == 2) {
6699
            if (atom[a_view - 1].arom)
6699
            if (atom[a_view - 1].arom)
6700
              fg[fg_thioxohetarene - 1] = true;
6700
              fg[fg_thioxohetarene - 1] = istrue;
6701
            else
6701
            else
6702
              fg[fg_thioketone - 1] = true;
6702
              fg[fg_thioketone - 1] = istrue;
6703
          }
6703
          }
6704
  }
6704
  }
6705
  if (is_imino_C (a_view))
6705
  if (is_imino_C (a_view))
6706
    chk_imine (a_view, a_ref);
6706
    chk_imine (a_view, a_ref);
6707
}
6707
}
Line 6736... Line 6736...
6736
            }
6736
            }
6737
          }
6737
          }
6738
  }
6738
  }
6739
  if (is_oxo_C (a_view)) {
6739
  if (is_oxo_C (a_view)) {
6740
    if (o_count == 1) {                 /* anhydride is checked somewhere else */
6740
    if (o_count == 1) {                 /* anhydride is checked somewhere else */
6741
            if (bond[get_bond (a_view, a_o) - 1].arom == false)
6741
            if (bond[get_bond (a_view, a_o) - 1].arom == isfalse)
6742
              fg[fg_carboxylic_acid_deriv - 1] = true;
6742
              fg[fg_carboxylic_acid_deriv - 1] = istrue;
6743
            if (is_hydroxy (a_view, a_o)) {
6743
            if (is_hydroxy (a_view, a_o)) {
6744
              if (atom[a_o - 1].formal_charge == 0)
6744
              if (atom[a_o - 1].formal_charge == 0)
6745
                      fg[fg_carboxylic_acid - 1] = true;
6745
                      fg[fg_carboxylic_acid - 1] = istrue;
6746
              if (atom[a_o - 1].formal_charge == -1)
6746
              if (atom[a_o - 1].formal_charge == -1)
6747
                      fg[fg_carboxylic_acid_salt - 1] = true;
6747
                      fg[fg_carboxylic_acid_salt - 1] = istrue;
6748
            }
6748
            }
6749
            if (is_alkoxy (a_view, a_o) || is_aryloxy (a_view, a_o) |
6749
            if (is_alkoxy (a_view, a_o) || is_aryloxy (a_view, a_o) |
6750
                is_alkenyloxy (a_view, a_o) || is_alkynyloxy (a_view, a_o)) {
6750
                is_alkenyloxy (a_view, a_o) || is_alkynyloxy (a_view, a_o)) {
6751
              if (bond[get_bond (a_view, a_o) - 1].arom == false)
6751
              if (bond[get_bond (a_view, a_o) - 1].arom == isfalse)
6752
                      fg[fg_carboxylic_acid_ester - 1] = true;
6752
                      fg[fg_carboxylic_acid_ester - 1] = istrue;
6753
              if (bond[get_bond (a_view, a_o) - 1].ring_count > 0) {
6753
              if (bond[get_bond (a_view, a_o) - 1].ring_count > 0) {
6754
                      if (bond[get_bond (a_view, a_o) - 1].arom == true) {
6754
                      if (bond[get_bond (a_view, a_o) - 1].arom == istrue) {
6755
                        /*fg[fg_lactone_heteroarom] := true else fg[fg_lactone] := true; */
6755
                        /*fg[fg_lactone_heteroarom] := istrue else fg[fg_lactone] := istrue; */
6756
                        fg[fg_oxohetarene - 1] = true;
6756
                        fg[fg_oxohetarene - 1] = istrue;
6757
                      }
6757
                      }
6758
                    else
6758
                    else
6759
                      fg[fg_lactone - 1] = true;
6759
                      fg[fg_lactone - 1] = istrue;
6760
                    }
6760
                    }
6761
            }
6761
            }
6762
          }
6762
          }
6763
    if (n_count == 1) {
6763
    if (n_count == 1) {
6764
            if (bond[get_bond (a_view, a_n) - 1].arom == false)
6764
            if (bond[get_bond (a_view, a_n) - 1].arom == isfalse)
6765
              fg[fg_carboxylic_acid_deriv - 1] = true;
6765
              fg[fg_carboxylic_acid_deriv - 1] = istrue;
6766
            else {
6766
            else {
6767
              /*fg[fg_lactam_heteroarom] := true;  (* catches also pyridazines, 1,2,3-triazines, etc. */
6767
              /*fg[fg_lactam_heteroarom] := istrue;  (* catches also pyridazines, 1,2,3-triazines, etc. */
6768
              fg[fg_oxohetarene - 1] = true;
6768
              fg[fg_oxohetarene - 1] = istrue;
6769
            }
6769
            }
6770
            if (is_amino (a_view, a_n) || (!strcmp (atom[a_n - 1].atype, "NAM")
6770
            if (is_amino (a_view, a_n) || (!strcmp (atom[a_n - 1].atype, "NAM")
6771
                      && atom[a_n - 1].neighbor_count == 1)) {
6771
                      && atom[a_n - 1].neighbor_count == 1)) {
6772
              fg[fg_carboxylic_acid_amide - 1] = true;
6772
              fg[fg_carboxylic_acid_amide - 1] = istrue;
6773
              fg[fg_carboxylic_acid_prim_amide - 1] = true;
6773
              fg[fg_carboxylic_acid_prim_amide - 1] = istrue;
6774
            }
6774
            }
6775
            /*if (is_alkylamino(a_view,a_n)) or (is_arylamino(a_view,a_n)) then  */
6775
            /*if (is_alkylamino(a_view,a_n)) or (is_arylamino(a_view,a_n)) then  */
6776
            if (is_C_monosubst_amino (a_view, a_n) &&
6776
            if (is_C_monosubst_amino (a_view, a_n) &&
6777
                (!is_subst_acylamino (a_view, a_n))) {                  /* v0.3j */
6777
                (!is_subst_acylamino (a_view, a_n))) {                  /* v0.3j */
6778
              if (bond[get_bond (a_view, a_n) - 1].arom == false)
6778
              if (bond[get_bond (a_view, a_n) - 1].arom == isfalse)
6779
                      fg[fg_carboxylic_acid_amide - 1] = true;
6779
                      fg[fg_carboxylic_acid_amide - 1] = istrue;
6780
              if (bond[get_bond (a_view, a_n) - 1].arom == false)
6780
              if (bond[get_bond (a_view, a_n) - 1].arom == isfalse)
6781
                      fg[fg_carboxylic_acid_sec_amide - 1] = true;
6781
                      fg[fg_carboxylic_acid_sec_amide - 1] = istrue;
6782
              if (bond[get_bond (a_view, a_n) - 1].ring_count > 0) {
6782
              if (bond[get_bond (a_view, a_n) - 1].ring_count > 0) {
6783
                      if (bond[get_bond (a_view, a_n) - 1].arom == true) {
6783
                      if (bond[get_bond (a_view, a_n) - 1].arom == istrue) {
6784
                        /*fg[fg_lactam_heteroarom]    := true else  */
6784
                        /*fg[fg_lactam_heteroarom]    := istrue else  */
6785
                        fg[fg_oxohetarene - 1] = true;
6785
                        fg[fg_oxohetarene - 1] = istrue;
6786
                      }
6786
                      }
6787
                      else
6787
                      else
6788
                        fg[fg_lactam - 1] = true;
6788
                        fg[fg_lactam - 1] = istrue;
6789
                    }
6789
                    }
6790
            }
6790
            }
6791
            /*if (is_dialkylamino(a_view,a_n)) or (is_alkylarylamino(a_view,a_n)) or */
6791
            /*if (is_dialkylamino(a_view,a_n)) or (is_alkylarylamino(a_view,a_n)) or */
6792
            /*   (is_diarylamino(a_view,a_n)) then  */
6792
            /*   (is_diarylamino(a_view,a_n)) then  */
6793
            if (is_C_disubst_amino (a_view, a_n) & (!is_subst_acylamino (a_view, a_n))) {
6793
            if (is_C_disubst_amino (a_view, a_n) & (!is_subst_acylamino (a_view, a_n))) {
6794
              /* v0.3j */
6794
              /* v0.3j */
6795
              if (bond[get_bond (a_view, a_n) - 1].arom == false)
6795
              if (bond[get_bond (a_view, a_n) - 1].arom == isfalse)
6796
                fg[fg_carboxylic_acid_amide - 1] = true;
6796
                fg[fg_carboxylic_acid_amide - 1] = istrue;
6797
              if (bond[get_bond (a_view, a_n) - 1].arom == false)
6797
              if (bond[get_bond (a_view, a_n) - 1].arom == isfalse)
6798
                fg[fg_carboxylic_acid_tert_amide - 1] = true;
6798
                fg[fg_carboxylic_acid_tert_amide - 1] = istrue;
6799
              if (bond[get_bond (a_view, a_n) - 1].ring_count > 0) {
6799
              if (bond[get_bond (a_view, a_n) - 1].ring_count > 0) {
6800
                if (bond[get_bond (a_view, a_n) - 1].arom == true) {
6800
                if (bond[get_bond (a_view, a_n) - 1].arom == istrue) {
6801
                        /*fg[fg_lactam_heteroarom]    := true else  */
6801
                        /*fg[fg_lactam_heteroarom]    := istrue else  */
6802
                        fg[fg_oxohetarene - 1] = true;
6802
                        fg[fg_oxohetarene - 1] = istrue;
6803
                      }
6803
                      }
6804
                      else
6804
                      else
6805
                        fg[fg_lactam - 1] = true;
6805
                        fg[fg_lactam - 1] = istrue;
6806
                    }
6806
                    }
6807
            }
6807
            }
6808
            if (is_hydroxylamino (a_view, a_n))
6808
            if (is_hydroxylamino (a_view, a_n))
6809
              fg[fg_hydroxamic_acid - 1] = true;
6809
              fg[fg_hydroxamic_acid - 1] = istrue;
6810
            if (is_hydrazino (a_view, a_n))
6810
            if (is_hydrazino (a_view, a_n))
6811
              fg[fg_carboxylic_acid_hydrazide - 1] = true;
6811
              fg[fg_carboxylic_acid_hydrazide - 1] = istrue;
6812
            if (is_azido (a_view, a_n))
6812
            if (is_azido (a_view, a_n))
6813
              fg[fg_carboxylic_acid_azide - 1] = true;
6813
              fg[fg_carboxylic_acid_azide - 1] = istrue;
6814
          }
6814
          }
6815
    if (s_count == 1) {                 /* anhydride is checked somewhere else */
6815
    if (s_count == 1) {                 /* anhydride is checked somewhere else */
6816
            if (bond[get_bond (a_view, a_s) - 1].arom == false)
6816
            if (bond[get_bond (a_view, a_s) - 1].arom == isfalse)
6817
              fg[fg_thiocarboxylic_acid_deriv - 1] = true;
6817
              fg[fg_thiocarboxylic_acid_deriv - 1] = istrue;
6818
            if (is_sulfanyl (a_view, a_s))
6818
            if (is_sulfanyl (a_view, a_s))
6819
              fg[fg_thiocarboxylic_acid - 1] = true;
6819
              fg[fg_thiocarboxylic_acid - 1] = istrue;
6820
            if (is_alkylsulfanyl (a_view, a_s) || is_arylsulfanyl (a_view, a_s)) {
6820
            if (is_alkylsulfanyl (a_view, a_s) || is_arylsulfanyl (a_view, a_s)) {
6821
              if (bond[get_bond (a_view, a_s) - 1].arom == false)
6821
              if (bond[get_bond (a_view, a_s) - 1].arom == isfalse)
6822
                      fg[fg_thiocarboxylic_acid_ester - 1] = true;
6822
                      fg[fg_thiocarboxylic_acid_ester - 1] = istrue;
6823
              if (bond[get_bond (a_view, a_s) - 1].ring_count > 0) {
6823
              if (bond[get_bond (a_view, a_s) - 1].ring_count > 0) {
6824
                      if (bond[get_bond (a_view, a_s) - 1].arom == true) {
6824
                      if (bond[get_bond (a_view, a_s) - 1].arom == istrue) {
6825
                        /*fg[fg_thiolactone_heteroarom] := true else fg[fg_thiolactone] := true; */
6825
                        /*fg[fg_thiolactone_heteroarom] := istrue else fg[fg_thiolactone] := istrue; */
6826
                        fg[fg_oxohetarene - 1] = true;
6826
                        fg[fg_oxohetarene - 1] = istrue;
6827
                      }
6827
                      }
6828
                      else
6828
                      else
6829
                        fg[fg_thiolactone - 1] = true;
6829
                        fg[fg_thiolactone - 1] = istrue;
6830
                    }
6830
                    }
6831
            }
6831
            }
6832
          }
6832
          }
6833
  }                             /* end Oxo-C */
6833
  }                             /* end Oxo-C */
6834
  if (is_thioxo_C (a_view)) {
6834
  if (is_thioxo_C (a_view)) {
6835
    /* fg[fg_thiocarboxylic_acid_deriv]  := true; */
6835
    /* fg[fg_thiocarboxylic_acid_deriv]  := istrue; */
6836
    if (o_count == 1) {                 /* anhydride is checked somewhere else */
6836
    if (o_count == 1) {                 /* anhydride is checked somewhere else */
6837
            if (bond[get_bond (a_view, a_o) - 1].arom == false)
6837
            if (bond[get_bond (a_view, a_o) - 1].arom == isfalse)
6838
              fg[fg_thiocarboxylic_acid_deriv - 1] = true;
6838
              fg[fg_thiocarboxylic_acid_deriv - 1] = istrue;
6839
            if (is_hydroxy (a_view, a_o))
6839
            if (is_hydroxy (a_view, a_o))
6840
              fg[fg_thiocarboxylic_acid - 1] = true;    /* fixed in v0.3c */
6840
              fg[fg_thiocarboxylic_acid - 1] = istrue;  /* fixed in v0.3c */
6841
            if (is_alkoxy (a_view, a_o) || is_aryloxy (a_view, a_o)) {
6841
            if (is_alkoxy (a_view, a_o) || is_aryloxy (a_view, a_o)) {
6842
              if (bond[get_bond (a_view, a_s) - 1].arom == false)
6842
              if (bond[get_bond (a_view, a_s) - 1].arom == isfalse)
6843
                      fg[fg_thiocarboxylic_acid_ester - 1] = true;
6843
                      fg[fg_thiocarboxylic_acid_ester - 1] = istrue;
6844
              if (bond[get_bond (a_view, a_o) - 1].ring_count > 0) {
6844
              if (bond[get_bond (a_view, a_o) - 1].ring_count > 0) {
6845
                      if (bond[get_bond (a_view, a_o) - 1].arom == true) {
6845
                      if (bond[get_bond (a_view, a_o) - 1].arom == istrue) {
6846
                        /*fg[fg_thiolactone_heteroarom] := true else fg[fg_thiolactone] := true; */
6846
                        /*fg[fg_thiolactone_heteroarom] := istrue else fg[fg_thiolactone] := istrue; */
6847
                        fg[fg_thioxohetarene - 1] = true;
6847
                        fg[fg_thioxohetarene - 1] = istrue;
6848
                      }
6848
                      }
6849
                      else
6849
                      else
6850
                        fg[fg_thiolactone - 1] = true;
6850
                        fg[fg_thiolactone - 1] = istrue;
6851
                    }
6851
                    }
6852
            }
6852
            }
6853
          }
6853
          }
6854
    if (n_count == 1) {
6854
    if (n_count == 1) {
6855
            if (bond[get_bond (a_view, a_n) - 1].arom == false)
6855
            if (bond[get_bond (a_view, a_n) - 1].arom == isfalse)
6856
              fg[fg_thiocarboxylic_acid_deriv - 1] = true;
6856
              fg[fg_thiocarboxylic_acid_deriv - 1] = istrue;
6857
            else {
6857
            else {
6858
              /*fg[fg_thiolactam_heteroarom] := true;  (* catches also pyridazines, 1,2,3-triazines, etc. */
6858
              /*fg[fg_thiolactam_heteroarom] := istrue;  (* catches also pyridazines, 1,2,3-triazines, etc. */
6859
              fg[fg_thioxohetarene - 1] = true;
6859
              fg[fg_thioxohetarene - 1] = istrue;
6860
            }
6860
            }
6861
            /* catches also pyridazines, 1,2,3-triazines, etc. */
6861
            /* catches also pyridazines, 1,2,3-triazines, etc. */
6862
            if (is_amino (a_view, a_n)){
6862
            if (is_amino (a_view, a_n)){
6863
              fg[fg_thiocarboxylic_acid_amide - 1] = true;
6863
              fg[fg_thiocarboxylic_acid_amide - 1] = istrue;
6864
              /* fg[fg_thiocarboxylic_acid_prim_amide] := true; */
6864
              /* fg[fg_thiocarboxylic_acid_prim_amide] := istrue; */
6865
            }
6865
            }
6866
            /*if (is_alkylamino(a_view,a_n)) or (is_arylamino(a_view,a_n)) then  */
6866
            /*if (is_alkylamino(a_view,a_n)) or (is_arylamino(a_view,a_n)) then  */
6867
            if (is_C_monosubst_amino (a_view, a_n) & (!is_subst_acylamino (a_view, a_n))) {
6867
            if (is_C_monosubst_amino (a_view, a_n) & (!is_subst_acylamino (a_view, a_n))) {
6868
              /* v0.3j */
6868
              /* v0.3j */
6869
              if (bond[get_bond (a_view, a_n) - 1].arom == false)
6869
              if (bond[get_bond (a_view, a_n) - 1].arom == isfalse)
6870
                      fg[fg_thiocarboxylic_acid_amide - 1] = true;
6870
                      fg[fg_thiocarboxylic_acid_amide - 1] = istrue;
6871
              /*fg[fg_thiocarboxylic_acid_sec_amide]  := true; */
6871
              /*fg[fg_thiocarboxylic_acid_sec_amide]  := istrue; */
6872
              if (bond[get_bond (a_view, a_n) - 1].ring_count > 0) {
6872
              if (bond[get_bond (a_view, a_n) - 1].ring_count > 0) {
6873
                      if (bond[get_bond (a_view, a_n) - 1].arom == true) {
6873
                      if (bond[get_bond (a_view, a_n) - 1].arom == istrue) {
6874
                        /*fg[fg_thiolactam_heteroarom] := true else fg[fg_thiolactam] := true; */
6874
                        /*fg[fg_thiolactam_heteroarom] := istrue else fg[fg_thiolactam] := istrue; */
6875
                        fg[fg_thioxohetarene - 1] = true;
6875
                        fg[fg_thioxohetarene - 1] = istrue;
6876
                    }
6876
                    }
6877
                    else
6877
                    else
6878
                      fg[fg_thiolactam - 1] = true;
6878
                      fg[fg_thiolactam - 1] = istrue;
6879
                  }
6879
                  }
6880
          }
6880
          }
6881
          /*if (is_dialkylamino(a_view,a_n)) or (is_alkylarylamino(a_view,a_n)) or */
6881
          /*if (is_dialkylamino(a_view,a_n)) or (is_alkylarylamino(a_view,a_n)) or */
6882
          /*   (is_diarylamino(a_view,a_n)) then  */
6882
          /*   (is_diarylamino(a_view,a_n)) then  */
6883
          if (is_C_disubst_amino (a_view, a_n) & (!is_subst_acylamino (a_view, a_n))) {
6883
          if (is_C_disubst_amino (a_view, a_n) & (!is_subst_acylamino (a_view, a_n))) {
6884
            /* v0.3j */
6884
            /* v0.3j */
6885
            if (bond[get_bond (a_view, a_n) - 1].arom == false)
6885
            if (bond[get_bond (a_view, a_n) - 1].arom == isfalse)
6886
                    fg[fg_thiocarboxylic_acid_amide - 1] = true;
6886
                    fg[fg_thiocarboxylic_acid_amide - 1] = istrue;
6887
              /*fg[fg_thiocarboxylic_acid_tert_amide] := true; */
6887
              /*fg[fg_thiocarboxylic_acid_tert_amide] := istrue; */
6888
            if (bond[get_bond (a_view, a_n) - 1].ring_count > 0) {
6888
            if (bond[get_bond (a_view, a_n) - 1].ring_count > 0) {
6889
                    if (bond[get_bond (a_view, a_n) - 1].arom == true) {
6889
                    if (bond[get_bond (a_view, a_n) - 1].arom == istrue) {
6890
                      /*fg[fg_thiolactam_heteroarom] := true else fg[fg_thiolactam] := true; */
6890
                      /*fg[fg_thiolactam_heteroarom] := istrue else fg[fg_thiolactam] := istrue; */
6891
                      fg[fg_thioxohetarene - 1] = true;
6891
                      fg[fg_thioxohetarene - 1] = istrue;
6892
                    }
6892
                    }
6893
                    else
6893
                    else
6894
                      fg[fg_thiolactam - 1] = true;
6894
                      fg[fg_thiolactam - 1] = istrue;
6895
                  }
6895
                  }
6896
          }
6896
          }
6897
        }
6897
        }
6898
  if (s_count == 1) {                   /* anhydride is checked somewhere else */
6898
  if (s_count == 1) {                   /* anhydride is checked somewhere else */
6899
          if (bond[get_bond (a_view, a_s) - 1].arom == false)
6899
          if (bond[get_bond (a_view, a_s) - 1].arom == isfalse)
6900
            fg[fg_thiocarboxylic_acid_deriv - 1] = true;
6900
            fg[fg_thiocarboxylic_acid_deriv - 1] = istrue;
6901
          if (is_sulfanyl (a_view, a_s))
6901
          if (is_sulfanyl (a_view, a_s))
6902
            fg[fg_thiocarboxylic_acid - 1] = true;
6902
            fg[fg_thiocarboxylic_acid - 1] = istrue;
6903
          if (is_alkylsulfanyl (a_view, a_s) || is_arylsulfanyl (a_view, a_s)) {
6903
          if (is_alkylsulfanyl (a_view, a_s) || is_arylsulfanyl (a_view, a_s)) {
6904
      if (bond[get_bond (a_view, a_s) - 1].arom == false)
6904
      if (bond[get_bond (a_view, a_s) - 1].arom == isfalse)
6905
                    fg[fg_thiocarboxylic_acid_ester - 1] = true;
6905
                    fg[fg_thiocarboxylic_acid_ester - 1] = istrue;
6906
              if (bond[get_bond (a_view, a_s) - 1].ring_count > 0) {
6906
              if (bond[get_bond (a_view, a_s) - 1].ring_count > 0) {
6907
                      if (bond[get_bond (a_view, a_s) - 1].arom == true) {
6907
                      if (bond[get_bond (a_view, a_s) - 1].arom == istrue) {
6908
                        /*fg[fg_thiolactone_heteroarom] := true else fg[fg_thiolactone] := true; */
6908
                        /*fg[fg_thiolactone_heteroarom] := istrue else fg[fg_thiolactone] := istrue; */
6909
                        fg[fg_thioxohetarene - 1] = true;
6909
                        fg[fg_thioxohetarene - 1] = istrue;
6910
                      }
6910
                      }
6911
                      else
6911
                      else
6912
                        fg[fg_thiolactone - 1] = true;
6912
                        fg[fg_thiolactone - 1] = istrue;
6913
                    }
6913
                    }
6914
            }
6914
            }
6915
          }
6915
          }
6916
  }                             /* end Thioxo-C */
6916
  }                             /* end Thioxo-C */
6917
  if (is_true_imino_C (a_view)) {
6917
  if (is_istrue_imino_C (a_view)) {
6918
    if (o_count == 1) {
6918
    if (o_count == 1) {
6919
            if (bond[get_bond (a_view, a_o) - 1].arom == false)
6919
            if (bond[get_bond (a_view, a_o) - 1].arom == isfalse)
6920
              fg[fg_carboxylic_acid_deriv - 1] = true;
6920
              fg[fg_carboxylic_acid_deriv - 1] = istrue;
6921
            if (is_alkoxy (a_view, a_o) || is_aryloxy (a_view, a_o)) {
6921
            if (is_alkoxy (a_view, a_o) || is_aryloxy (a_view, a_o)) {
6922
              if (bond[get_bond (a_view, a_o) - 1].arom == false)
6922
              if (bond[get_bond (a_view, a_o) - 1].arom == isfalse)
6923
                      fg[fg_imido_ester - 1] = true;
6923
                      fg[fg_imido_ester - 1] = istrue;
6924
            }
6924
            }
6925
          }
6925
          }
6926
    if ((n_count == 1) && (bond[get_bond (a_view, a_n) - 1].arom == false)) {
6926
    if ((n_count == 1) && (bond[get_bond (a_view, a_n) - 1].arom == isfalse)) {
6927
            if (bond[get_bond (a_view, a_n) - 1].arom == false)
6927
            if (bond[get_bond (a_view, a_n) - 1].arom == isfalse)
6928
              fg[fg_carboxylic_acid_deriv - 1] = true;
6928
              fg[fg_carboxylic_acid_deriv - 1] = istrue;
6929
            if (is_amino (a_view, a_n) || is_subst_amino (a_view, a_n)) {
6929
            if (is_amino (a_view, a_n) || is_subst_amino (a_view, a_n)) {
6930
              if (bond[get_bond (a_view, a_n) - 1].arom == false)
6930
              if (bond[get_bond (a_view, a_n) - 1].arom == isfalse)
6931
                      fg[fg_carboxylic_acid_deriv - 1] = true;
6931
                      fg[fg_carboxylic_acid_deriv - 1] = istrue;
6932
              fg[fg_carboxylic_acid_amidine - 1] = true;
6932
              fg[fg_carboxylic_acid_amidine - 1] = istrue;
6933
            }
6933
            }
6934
            if (is_hydrazino (a_view, a_n)) {
6934
            if (is_hydrazino (a_view, a_n)) {
6935
              if (bond[get_bond (a_view, a_n) - 1].arom == false)
6935
              if (bond[get_bond (a_view, a_n) - 1].arom == isfalse)
6936
                      fg[fg_carboxylic_acid_amidrazone - 1] = true;
6936
                      fg[fg_carboxylic_acid_amidrazone - 1] = istrue;
6937
            }
6937
            }
6938
          }
6938
          }
6939
    if ((n_count == 1) && (bond[get_bond (a_view, a_n) - 1].arom == true))
6939
    if ((n_count == 1) && (bond[get_bond (a_view, a_n) - 1].arom == istrue))
6940
            /* catches also pyridazines, 1,2,3-triazines, etc. */
6940
            /* catches also pyridazines, 1,2,3-triazines, etc. */
6941
          fg[fg_iminohetarene - 1] = true;
6941
          fg[fg_iminohetarene - 1] = istrue;
6942
    if (s_count == 1) {
6942
    if (s_count == 1) {
6943
            if (bond[get_bond (a_view, a_s) - 1].arom == false)
6943
            if (bond[get_bond (a_view, a_s) - 1].arom == isfalse)
6944
              fg[fg_carboxylic_acid_deriv - 1] = true;
6944
              fg[fg_carboxylic_acid_deriv - 1] = istrue;
6945
            if (is_alkylsulfanyl (a_view, a_s) || is_arylsulfanyl (a_view, a_s)) {
6945
            if (is_alkylsulfanyl (a_view, a_s) || is_arylsulfanyl (a_view, a_s)) {
6946
              if (bond[get_bond (a_view, a_s) - 1].arom == false)
6946
              if (bond[get_bond (a_view, a_s) - 1].arom == isfalse)
6947
                 fg[fg_imido_thioester - 1] = true;
6947
                 fg[fg_imido_thioester - 1] = istrue;
6948
            }
6948
            }
6949
          }
6949
          }
6950
  }
6950
  }
6951
  if (is_hydroximino_C (a_view)) {
6951
  if (is_hydroximino_C (a_view)) {
6952
    if (bond[get_bond (a_view, a_n) - 1].arom == false)
6952
    if (bond[get_bond (a_view, a_n) - 1].arom == isfalse)
6953
            fg[fg_carboxylic_acid_deriv - 1] = true;
6953
            fg[fg_carboxylic_acid_deriv - 1] = istrue;
6954
      if (o_count == 1) {
6954
      if (o_count == 1) {
6955
              if (is_hydroxy (a_view, a_o))
6955
              if (is_hydroxy (a_view, a_o))
6956
                fg[fg_hydroxamic_acid - 1] = true;
6956
                fg[fg_hydroxamic_acid - 1] = istrue;
6957
            }
6957
            }
6958
    }
6958
    }
6959
    if (!is_hydrazono_C (a_view))
6959
    if (!is_hydrazono_C (a_view))
6960
      return;
6960
      return;
6961
    if (bond[get_bond (a_view, a_n) - 1].arom == false)
6961
    if (bond[get_bond (a_view, a_n) - 1].arom == isfalse)
6962
      fg[fg_carboxylic_acid_deriv - 1] = true;
6962
      fg[fg_carboxylic_acid_deriv - 1] = istrue;
6963
    if (n_count == 1) {
6963
    if (n_count == 1) {
6964
        if (is_amino (a_view, a_n) || is_subst_amino (a_view, a_n))
6964
        if (is_amino (a_view, a_n) || is_subst_amino (a_view, a_n))
6965
          fg[fg_carboxylic_acid_amidrazone - 1] = true;
6965
          fg[fg_carboxylic_acid_amidrazone - 1] = istrue;
6966
  }
6966
  }
6967
}
6967
}
6968
 
6968
 
6969
static void chk_co2_sp2 (int a_view, int a_ref)
6969
static void chk_co2_sp2 (int a_view, int a_ref)
6970
{
6970
{
Line 7004... Line 7004...
7004
            }
7004
            }
7005
          }
7005
          }
7006
  }
7006
  }
7007
  if (is_oxo_C (a_view)) {
7007
  if (is_oxo_C (a_view)) {
7008
      if (o_count == 2) {
7008
      if (o_count == 2) {
7009
              fg[fg_carbonic_acid_deriv - 1] = true;
7009
              fg[fg_carbonic_acid_deriv - 1] = istrue;
7010
              if (or_count == 1)
7010
              if (or_count == 1)
7011
                fg[fg_carbonic_acid_monoester - 1] = true;
7011
                fg[fg_carbonic_acid_monoester - 1] = istrue;
7012
              if (or_count == 2)
7012
              if (or_count == 2)
7013
                fg[fg_carbonic_acid_diester - 1] = true;
7013
                fg[fg_carbonic_acid_diester - 1] = istrue;
7014
            }
7014
            }
7015
      if (o_count == 1 && s_count == 1) {
7015
      if (o_count == 1 && s_count == 1) {
7016
              fg[fg_thiocarbonic_acid_deriv - 1] = true;
7016
              fg[fg_thiocarbonic_acid_deriv - 1] = istrue;
7017
              if (or_count + sr_count == 1)
7017
              if (or_count + sr_count == 1)
7018
                fg[fg_thiocarbonic_acid_monoester - 1] = true;
7018
                fg[fg_thiocarbonic_acid_monoester - 1] = istrue;
7019
              if (or_count + sr_count == 2)
7019
              if (or_count + sr_count == 2)
7020
                fg[fg_thiocarbonic_acid_diester - 1] = true;
7020
                fg[fg_thiocarbonic_acid_diester - 1] = istrue;
7021
            }
7021
            }
7022
      if (s_count == 2) {
7022
      if (s_count == 2) {
7023
              fg[fg_thiocarbonic_acid_deriv - 1] = true;
7023
              fg[fg_thiocarbonic_acid_deriv - 1] = istrue;
7024
              if (sr_count == 1)
7024
              if (sr_count == 1)
7025
                fg[fg_thiocarbonic_acid_monoester - 1] = true;
7025
                fg[fg_thiocarbonic_acid_monoester - 1] = istrue;
7026
              if (sr_count == 2)
7026
              if (sr_count == 2)
7027
                fg[fg_thiocarbonic_acid_diester - 1] = true;
7027
                fg[fg_thiocarbonic_acid_diester - 1] = istrue;
7028
            }
7028
            }
7029
      if (o_count == 1 && n_count == 1) {
7029
      if (o_count == 1 && n_count == 1) {
7030
              fg[fg_carbamic_acid_deriv - 1] = true;
7030
              fg[fg_carbamic_acid_deriv - 1] = istrue;
7031
              if (or_count == 0)
7031
              if (or_count == 0)
7032
                fg[fg_carbamic_acid - 1] = true;
7032
                fg[fg_carbamic_acid - 1] = istrue;
7033
              if (or_count == 1)
7033
              if (or_count == 1)
7034
                fg[fg_carbamic_acid_ester - 1] = true;
7034
                fg[fg_carbamic_acid_ester - 1] = istrue;
7035
            }
7035
            }
7036
      if (s_count == 1 && n_count == 1) {
7036
      if (s_count == 1 && n_count == 1) {
7037
              fg[fg_thiocarbamic_acid_deriv - 1] = true;
7037
              fg[fg_thiocarbamic_acid_deriv - 1] = istrue;
7038
              if (sr_count == 0)
7038
              if (sr_count == 0)
7039
                fg[fg_thiocarbamic_acid - 1] = true;
7039
                fg[fg_thiocarbamic_acid - 1] = istrue;
7040
              if (sr_count == 1)
7040
              if (sr_count == 1)
7041
                fg[fg_thiocarbamic_acid_ester - 1] = true;
7041
                fg[fg_thiocarbamic_acid_ester - 1] = istrue;
7042
            }
7042
            }
7043
      if (n_count == 2) {
7043
      if (n_count == 2) {
7044
            if (nn_count == 1)
7044
            if (nn_count == 1)
7045
              fg[fg_semicarbazide - 1] = true;
7045
              fg[fg_semicarbazide - 1] = istrue;
7046
            else {
7046
            else {
7047
              if (nnx_count == 0)       /* excludes semicarbazones */
7047
              if (nnx_count == 0)       /* excludes semicarbazones */
7048
                      fg[fg_urea - 1] = true;
7048
                      fg[fg_urea - 1] = istrue;
7049
            }
7049
            }
7050
          }
7050
          }
7051
  }                             /* end Oxo-C */
7051
  }                             /* end Oxo-C */
7052
  if (is_thioxo_C (a_view)) {
7052
  if (is_thioxo_C (a_view)) {
7053
      if (o_count == 2) {
7053
      if (o_count == 2) {
7054
              fg[fg_thiocarbonic_acid_deriv - 1] = true;
7054
              fg[fg_thiocarbonic_acid_deriv - 1] = istrue;
7055
              if (or_count == 1)
7055
              if (or_count == 1)
7056
                fg[fg_thiocarbonic_acid_monoester - 1] = true;
7056
                fg[fg_thiocarbonic_acid_monoester - 1] = istrue;
7057
              if (or_count == 2)
7057
              if (or_count == 2)
7058
                fg[fg_thiocarbonic_acid_diester - 1] = true;
7058
                fg[fg_thiocarbonic_acid_diester - 1] = istrue;
7059
            }
7059
            }
7060
      if (o_count == 1 && s_count == 1) {
7060
      if (o_count == 1 && s_count == 1) {
7061
              fg[fg_thiocarbonic_acid_deriv - 1] = true;
7061
              fg[fg_thiocarbonic_acid_deriv - 1] = istrue;
7062
              if (or_count + sr_count == 1)
7062
              if (or_count + sr_count == 1)
7063
                fg[fg_thiocarbonic_acid_monoester - 1] = true;
7063
                fg[fg_thiocarbonic_acid_monoester - 1] = istrue;
7064
              if (or_count + sr_count == 2)
7064
              if (or_count + sr_count == 2)
7065
                fg[fg_thiocarbonic_acid_diester - 1] = true;
7065
                fg[fg_thiocarbonic_acid_diester - 1] = istrue;
7066
            }
7066
            }
7067
      if (s_count == 2) {
7067
      if (s_count == 2) {
7068
              fg[fg_thiocarbonic_acid_deriv - 1] = true;
7068
              fg[fg_thiocarbonic_acid_deriv - 1] = istrue;
7069
              if (sr_count == 1)
7069
              if (sr_count == 1)
7070
                fg[fg_thiocarbonic_acid_monoester - 1] = true;
7070
                fg[fg_thiocarbonic_acid_monoester - 1] = istrue;
7071
              if (sr_count == 2)
7071
              if (sr_count == 2)
7072
                fg[fg_thiocarbonic_acid_diester - 1] = true;
7072
                fg[fg_thiocarbonic_acid_diester - 1] = istrue;
7073
            }
7073
            }
7074
      if (o_count == 1 && n_count == 1) {
7074
      if (o_count == 1 && n_count == 1) {
7075
              fg[fg_thiocarbamic_acid_deriv - 1] = true;
7075
              fg[fg_thiocarbamic_acid_deriv - 1] = istrue;
7076
              if (or_count == 0)
7076
              if (or_count == 0)
7077
                fg[fg_thiocarbamic_acid - 1] = true;
7077
                fg[fg_thiocarbamic_acid - 1] = istrue;
7078
              if (or_count == 1)
7078
              if (or_count == 1)
7079
                fg[fg_thiocarbamic_acid_ester - 1] = true;
7079
                fg[fg_thiocarbamic_acid_ester - 1] = istrue;
7080
            }
7080
            }
7081
      if (s_count == 1 && n_count == 1) {
7081
      if (s_count == 1 && n_count == 1) {
7082
              fg[fg_thiocarbamic_acid_deriv - 1] = true;
7082
              fg[fg_thiocarbamic_acid_deriv - 1] = istrue;
7083
              if (sr_count == 0)
7083
              if (sr_count == 0)
7084
                fg[fg_thiocarbamic_acid - 1] = true;
7084
                fg[fg_thiocarbamic_acid - 1] = istrue;
7085
              if (sr_count == 1)
7085
              if (sr_count == 1)
7086
                fg[fg_thiocarbamic_acid_ester - 1] = true;
7086
                fg[fg_thiocarbamic_acid_ester - 1] = istrue;
7087
            }
7087
            }
7088
      if (n_count == 2) {
7088
      if (n_count == 2) {
7089
            if (nn_count == 1)
7089
            if (nn_count == 1)
7090
              fg[fg_thiosemicarbazide - 1] = true;
7090
              fg[fg_thiosemicarbazide - 1] = istrue;
7091
            else {
7091
            else {
7092
              if (nnx_count == 0)       /* excludes thiosemicarbazones */
7092
              if (nnx_count == 0)       /* excludes thiosemicarbazones */
7093
                      fg[fg_thiourea - 1] = true;
7093
                      fg[fg_thiourea - 1] = istrue;
7094
            }
7094
            }
7095
          }
7095
          }
7096
  }                             /* end Thioxo-C */
7096
  }                             /* end Thioxo-C */
7097
  if (!(is_true_imino_C (a_view) &&
7097
  if (!(is_istrue_imino_C (a_view) &&
7098
       (bond[get_bond (a_view, a_ref) - 1].arom == false))) {
7098
       (bond[get_bond (a_view, a_ref) - 1].arom == isfalse))) {
7099
      return;
7099
      return;
7100
  }                             /* end Imino-C */
7100
  }                             /* end Imino-C */
7101
  if (o_count == 1 && n_count == 1)
7101
  if (o_count == 1 && n_count == 1)
7102
    fg[fg_isourea - 1] = true;
7102
    fg[fg_isourea - 1] = istrue;
7103
  if (s_count == 1 && n_count == 1)
7103
  if (s_count == 1 && n_count == 1)
7104
    fg[fg_isothiourea - 1] = true;
7104
    fg[fg_isothiourea - 1] = istrue;
7105
  if (n_count == 2)
7105
  if (n_count == 2)
7106
    fg[fg_guanidine - 1] = true;
7106
    fg[fg_guanidine - 1] = istrue;
7107
}
7107
}
7108
 
7108
 
7109
static void chk_co2_sp (int a_view, int a_ref)
7109
static void chk_co2_sp (int a_view, int a_ref)
7110
{
7110
{
7111
  int i;
7111
  int i;
Line 7129... Line 7129...
7129
                      s_count++;
7129
                      s_count++;
7130
            }
7130
            }
7131
          }
7131
          }
7132
  }
7132
  }
7133
  if (o_count + s_count == 2)   /* new in v0.3b */
7133
  if (o_count + s_count == 2)   /* new in v0.3b */
7134
    fg[fg_co2_deriv - 1] = true;
7134
    fg[fg_co2_deriv - 1] = istrue;
7135
  if (o_count == 1 && n_count == 1)
7135
  if (o_count == 1 && n_count == 1)
7136
    fg[fg_isocyanate - 1] = true;
7136
    fg[fg_isocyanate - 1] = istrue;
7137
  if (s_count == 1 && n_count == 1)
7137
  if (s_count == 1 && n_count == 1)
7138
    fg[fg_isothiocyanate - 1] = true;
7138
    fg[fg_isothiocyanate - 1] = istrue;
7139
  if (n_count == 2)
7139
  if (n_count == 2)
7140
    fg[fg_carbodiimide - 1] = true;
7140
    fg[fg_carbodiimide - 1] = istrue;
7141
}
7141
}
7142
 
7142
 
7143
static void chk_triple(int a1,int a2)
7143
static void chk_triple(int a1,int a2)
7144
{
7144
{
7145
  str2 a1_el, a2_el;
7145
  str2 a1_el, a2_el;
7146
 
7146
 
7147
  strcpy (a1_el, atom[a1 - 1].element);
7147
  strcpy (a1_el, atom[a1 - 1].element);
7148
  strcpy (a2_el, atom[a2 - 1].element);
7148
  strcpy (a2_el, atom[a2 - 1].element);
7149
  if ((!strcmp (a1_el, "C ") && !strcmp (a2_el, "C ")) &&
7149
  if ((!strcmp (a1_el, "C ") && !strcmp (a2_el, "C ")) &&
7150
      (bond[get_bond (a1, a2) - 1].arom == false))
7150
      (bond[get_bond (a1, a2) - 1].arom == isfalse))
7151
    fg[fg_alkyne - 1] = true;
7151
    fg[fg_alkyne - 1] = istrue;
7152
  if (is_nitrile (a1, a2))
7152
  if (is_nitrile (a1, a2))
7153
    fg[fg_nitrile - 1] = true;
7153
    fg[fg_nitrile - 1] = istrue;
7154
  if (is_isonitrile (a1, a2))
7154
  if (is_isonitrile (a1, a2))
7155
    fg[fg_isonitrile - 1] = true;
7155
    fg[fg_isonitrile - 1] = istrue;
7156
  if (is_cyanate (a1, a2))
7156
  if (is_cyanate (a1, a2))
7157
    fg[fg_cyanate - 1] = true;
7157
    fg[fg_cyanate - 1] = istrue;
7158
  if (is_thiocyanate (a1, a2))
7158
  if (is_thiocyanate (a1, a2))
7159
    fg[fg_thiocyanate - 1] = true;
7159
    fg[fg_thiocyanate - 1] = istrue;
7160
}
7160
}
7161
 
7161
 
7162
static void chk_ccx (int a_view, int a_ref)
7162
static void chk_ccx (int a_view, int a_ref)
7163
{
7163
{
7164
  int i;
7164
  int i;
Line 7180... Line 7180...
7180
              !strcmp (atom[nb[i] - 1].atype, "NAM"))
7180
              !strcmp (atom[nb[i] - 1].atype, "NAM"))
7181
            n_count++;
7181
            n_count++;
7182
          }
7182
          }
7183
  }
7183
  }
7184
  if (oh_count == 1)
7184
  if (oh_count == 1)
7185
    fg[fg_enol - 1] = true;
7185
    fg[fg_enol - 1] = istrue;
7186
  if (or_count == 1)
7186
  if (or_count == 1)
7187
    fg[fg_enolether - 1] = true;
7187
    fg[fg_enolether - 1] = istrue;
7188
  if (n_count == 1)
7188
  if (n_count == 1)
7189
    fg[fg_enamine - 1] = true;
7189
    fg[fg_enamine - 1] = istrue;
7190
  /* new in v0.2f   (regard anything else as an alkene) */
7190
  /* new in v0.2f   (regard anything else as an alkene) */
7191
  if (oh_count + or_count + n_count == 0)
7191
  if (oh_count + or_count + n_count == 0)
7192
    fg[fg_alkene - 1] = true;
7192
    fg[fg_alkene - 1] = istrue;
7193
}
7193
}
7194
 
7194
 
7195
static void chk_xccx (int a_view, int a_ref)
7195
static void chk_xccx (int a_view, int a_ref)
7196
{
7196
{
7197
  int i;
7197
  int i;
Line 7228... Line 7228...
7228
                !strcmp (atom[nb[i] - 1].atype, "NAM"))
7228
                !strcmp (atom[nb[i] - 1].atype, "NAM"))
7229
              n_count++;
7229
              n_count++;
7230
          }
7230
          }
7231
  }
7231
  }
7232
  if (oh_count == 2)
7232
  if (oh_count == 2)
7233
    fg[fg_enediol - 1] = true;
7233
    fg[fg_enediol - 1] = istrue;
7234
  /* new in v0.2f   (regard anything else as an alkene) */
7234
  /* new in v0.2f   (regard anything else as an alkene) */
7235
  if (oh_count + or_count + n_count == 0)
7235
  if (oh_count + or_count + n_count == 0)
7236
    fg[fg_alkene - 1] = true;
7236
    fg[fg_alkene - 1] = istrue;
7237
}
7237
}
7238
 
7238
 
7239
static void chk_n_o_dbl(int a1,int a2)
7239
static void chk_n_o_dbl(int a1,int a2)
7240
{
7240
{
7241
  int i;
7241
  int i;
Line 7258... Line 7258...
7258
            b = get_bond (a1, nb[i]);   /* v0.3j */
7258
            b = get_bond (a1, nb[i]);   /* v0.3j */
7259
            strcpy (nb_el, atom[nb[i] - 1].element);
7259
            strcpy (nb_el, atom[nb[i] - 1].element);
7260
            bt = bond[b - 1].btype;     /* v0.3k */
7260
            bt = bond[b - 1].btype;     /* v0.3k */
7261
            if (strcmp (nb_el, "C ") && strcmp (nb_el, "H ")
7261
            if (strcmp (nb_el, "C ") && strcmp (nb_el, "H ")
7262
                /*&&  strcmp (nb_el, "D ") */  && strcmp (nb_el, "DU")
7262
                /*&&  strcmp (nb_el, "D ") */  && strcmp (nb_el, "DU")
7263
                && strcmp (nb_el, "LP") && bond[b - 1].arom == false)
7263
                && strcmp (nb_el, "LP") && bond[b - 1].arom == isfalse)
7264
                /* added 'D ' in v0.3n */
7264
                /* added 'D ' in v0.3n */
7265
              het_count++;
7265
              het_count++;
7266
            /* v0.3k: ignore hetero atoms */
7266
            /* v0.3k: ignore hetero atoms */
7267
            /* in aromatic rings like isoxazole  */
7267
            /* in aromatic rings like isoxazole  */
7268
            if (bt == 'S')
7268
            if (bt == 'S')
Line 7281... Line 7281...
7281
          }
7281
          }
7282
  }
7282
  }
7283
  if (or_count + n_count + c_count == 1 && atom[a1 - 1].neighbor_count == 2) {
7283
  if (or_count + n_count + c_count == 1 && atom[a1 - 1].neighbor_count == 2) {
7284
    /* excludes nitro etc. */
7284
    /* excludes nitro etc. */
7285
    if (or_count == 1)
7285
    if (or_count == 1)
7286
            fg[fg_nitrite - 1] = true;
7286
            fg[fg_nitrite - 1] = istrue;
7287
    if (c_count == 1)
7287
    if (c_count == 1)
7288
            fg[fg_nitroso_compound - 1] = true;
7288
            fg[fg_nitroso_compound - 1] = istrue;
7289
    if (n_count == 1)           /* instead of nitrosamine  v0.3j */
7289
    if (n_count == 1)           /* instead of nitrosamine  v0.3j */
7290
            fg[fg_nitroso_compound - 1] = true;
7290
            fg[fg_nitroso_compound - 1] = istrue;
7291
    /*if (n_count = 1) then fg[fg_nitrosamine]   := true;  (* still missing */
7291
    /*if (n_count = 1) then fg[fg_nitrosamine]   := istrue;  (* still missing */
7292
  }
7292
  }
7293
  /*if ((c_count > 1) and (or_count = 0) and (n_count = 0)) then */
7293
  /*if ((c_count > 1) and (or_count = 0) and (n_count = 0)) then */
7294
  /*  begin */
7294
  /*  begin */
7295
  /*    fg[fg_n_oxide] := true; */
7295
  /*    fg[fg_n_oxide] := istrue; */
7296
  /*  end; */
7296
  /*  end; */
7297
  /* new approach in v0.3k */
7297
  /* new approach in v0.3k */
7298
  if (het_count == 0 && bo_sum > 2)     /* =O does not count! */
7298
  if (het_count == 0 && bo_sum > 2)     /* =O does not count! */
7299
    fg[fg_n_oxide - 1] = true;
7299
    fg[fg_n_oxide - 1] = istrue;
7300
}
7300
}
7301
 
7301
 
7302
static void chk_sulfoxide(int a1,int a2)
7302
static void chk_sulfoxide(int a1,int a2)
7303
{
7303
{
7304
  int i;
7304
  int i;
Line 7316... Line 7316...
7316
            o_count++;
7316
            o_count++;
7317
    if (is_alkyl (a1, nb[i]) || is_aryl (a1, nb[i]))
7317
    if (is_alkyl (a1, nb[i]) || is_aryl (a1, nb[i]))
7318
            c_count++;
7318
            c_count++;
7319
  }
7319
  }
7320
  if (o_count == 1 && c_count == 2)
7320
  if (o_count == 1 && c_count == 2)
7321
    fg[fg_sulfoxide - 1] = true;
7321
    fg[fg_sulfoxide - 1] = istrue;
7322
}
7322
}
7323
 
7323
 
7324
static void chk_double(int a1,int a2)
7324
static void chk_double(int a1,int a2)
7325
{
7325
{
7326
  str2 a1_el, a2_el;
7326
  str2 a1_el, a2_el;
7327
 
7327
 
7328
  strcpy (a1_el, atom[a1 - 1].element);
7328
  strcpy (a1_el, atom[a1 - 1].element);
7329
  strcpy (a2_el, atom[a2 - 1].element);
7329
  strcpy (a2_el, atom[a2 - 1].element);
7330
  if ((!strcmp (a1_el, "C ") && strcmp (a2_el, "C ")) &&
7330
  if ((!strcmp (a1_el, "C ") && strcmp (a2_el, "C ")) &&
7331
      (bond[get_bond (a1, a2) - 1].arom == false)) {
7331
      (bond[get_bond (a1, a2) - 1].arom == isfalse)) {
7332
    if (hetbond_count (a1) == 2)
7332
    if (hetbond_count (a1) == 2)
7333
            chk_carbonyl_deriv (a1, a2);
7333
            chk_carbonyl_deriv (a1, a2);
7334
    if (hetbond_count (a1) == 3)
7334
    if (hetbond_count (a1) == 3)
7335
            chk_carboxyl_deriv (a1, a2);
7335
            chk_carboxyl_deriv (a1, a2);
7336
    if (hetbond_count (a1) == 4) {
7336
    if (hetbond_count (a1) == 4) {
Line 7340... Line 7340...
7340
              chk_co2_sp (a1, a2);
7340
              chk_co2_sp (a1, a2);
7341
          }
7341
          }
7342
  }                             /* end C=X */
7342
  }                             /* end C=X */
7343
  if ((!strcmp (atom[a1 - 1].atype, "C2 ")
7343
  if ((!strcmp (atom[a1 - 1].atype, "C2 ")
7344
       && !strcmp (atom[a2 - 1].atype,
7344
       && !strcmp (atom[a2 - 1].atype,
7345
                   "C2 ")) && (bond[get_bond (a1, a2) - 1].arom == false)) {
7345
                   "C2 ")) && (bond[get_bond (a1, a2) - 1].arom == isfalse)) {
7346
    if ((hetbond_count (a1) == 0) && (hetbond_count (a2) == 2))
7346
    if ((hetbond_count (a1) == 0) && (hetbond_count (a2) == 2))
7347
            fg[fg_ketene_acetal_deriv - 1] = true;
7347
            fg[fg_ketene_acetal_deriv - 1] = istrue;
7348
    if ((hetbond_count (a1) == 0) && (hetbond_count (a2) == 1))
7348
    if ((hetbond_count (a1) == 0) && (hetbond_count (a2) == 1))
7349
            chk_ccx (a1, a2);
7349
            chk_ccx (a1, a2);
7350
    if ((hetbond_count (a1) == 1) && (hetbond_count (a2) == 1))
7350
    if ((hetbond_count (a1) == 1) && (hetbond_count (a2) == 1))
7351
            chk_xccx (a1, a2);
7351
            chk_xccx (a1, a2);
7352
    if (((hetbond_count (a1) == 0) && (hetbond_count (a2) == 0)) &&
7352
    if (((hetbond_count (a1) == 0) && (hetbond_count (a2) == 0)) &&
7353
              atom[a1 - 1].arom == false && atom[a2 - 1].arom == false)
7353
              atom[a1 - 1].arom == isfalse && atom[a2 - 1].arom == isfalse)
7354
            fg[fg_alkene - 1] = true;
7354
            fg[fg_alkene - 1] = istrue;
7355
  }
7355
  }
7356
  if (((!strcmp (a1_el, "N ") && !strcmp (a2_el, "N "))
7356
  if (((!strcmp (a1_el, "N ") && !strcmp (a2_el, "N "))
7357
      && (hetbond_count (a1) == 2) && (hetbond_count (a2) == 2)
7357
      && (hetbond_count (a1) == 2) && (hetbond_count (a2) == 2)
7358
      && (bond[get_bond (a1, a2) - 1].arom == false))
7358
      && (bond[get_bond (a1, a2) - 1].arom == isfalse))
7359
      && atom[a1 - 1].neighbor_count == 2 && atom[a2 - 1].neighbor_count == 2)
7359
      && atom[a1 - 1].neighbor_count == 2 && atom[a2 - 1].neighbor_count == 2)
7360
    fg[fg_azo_compound - 1] = true;
7360
    fg[fg_azo_compound - 1] = istrue;
7361
  if (!strcmp (a1_el, "N ") && !strcmp (a2_el, "O "))
7361
  if (!strcmp (a1_el, "N ") && !strcmp (a2_el, "O "))
7362
    chk_n_o_dbl (a1, a2);
7362
    chk_n_o_dbl (a1, a2);
7363
  if (!strcmp (a1_el, "S ") && !strcmp (a2_el, "O "))
7363
  if (!strcmp (a1_el, "S ") && !strcmp (a2_el, "O "))
7364
    chk_sulfoxide (a1, a2);
7364
    chk_sulfoxide (a1, a2);
7365
}
7365
}
Line 7367... Line 7367...
7367
static void chk_c_hal(int a1,int a2)
7367
static void chk_c_hal(int a1,int a2)
7368
{
7368
{
7369
  str2 a2_el;
7369
  str2 a2_el;
7370
 
7370
 
7371
  strcpy (a2_el, atom[a2 - 1].element);
7371
  strcpy (a2_el, atom[a2 - 1].element);
7372
  fg[fg_halogen_deriv - 1] = true;
7372
  fg[fg_halogen_deriv - 1] = istrue;
7373
  if (atom[a1 - 1].arom) {
7373
  if (atom[a1 - 1].arom) {
7374
    fg[fg_aryl_halide - 1] = true;
7374
    fg[fg_aryl_halide - 1] = istrue;
7375
    if (!strcmp (a2_el, "F "))
7375
    if (!strcmp (a2_el, "F "))
7376
            fg[fg_aryl_fluoride - 1] = true;
7376
            fg[fg_aryl_fluoride - 1] = istrue;
7377
    if (!strcmp (a2_el, "CL"))
7377
    if (!strcmp (a2_el, "CL"))
7378
            fg[fg_aryl_chloride - 1] = true;
7378
            fg[fg_aryl_chloride - 1] = istrue;
7379
    if (!strcmp (a2_el, "BR"))
7379
    if (!strcmp (a2_el, "BR"))
7380
            fg[fg_aryl_bromide - 1] = true;
7380
            fg[fg_aryl_bromide - 1] = istrue;
7381
    if (!strcmp (a2_el, "I "))
7381
    if (!strcmp (a2_el, "I "))
7382
            fg[fg_aryl_iodide - 1] = true;
7382
            fg[fg_aryl_iodide - 1] = istrue;
7383
    return;
7383
    return;
7384
  }
7384
  }
7385
  if ((strcmp (atom[a1 - 1].atype, "C3 ") == 0) && (hetbond_count (a1) <= 2)) {
7385
  if ((strcmp (atom[a1 - 1].atype, "C3 ") == 0) && (hetbond_count (a1) <= 2)) {
7386
    /* alkyl halides */
7386
    /* alkyl halides */
7387
    fg[fg_alkyl_halide - 1] = true;
7387
    fg[fg_alkyl_halide - 1] = istrue;
7388
    if (!strcmp (a2_el, "F "))
7388
    if (!strcmp (a2_el, "F "))
7389
            fg[fg_alkyl_fluoride - 1] = true;
7389
            fg[fg_alkyl_fluoride - 1] = istrue;
7390
    if (!strcmp (a2_el, "CL"))
7390
    if (!strcmp (a2_el, "CL"))
7391
            fg[fg_alkyl_chloride - 1] = true;
7391
            fg[fg_alkyl_chloride - 1] = istrue;
7392
    if (!strcmp (a2_el, "BR"))
7392
    if (!strcmp (a2_el, "BR"))
7393
            fg[fg_alkyl_bromide - 1] = true;
7393
            fg[fg_alkyl_bromide - 1] = istrue;
7394
    if (!strcmp (a2_el, "I "))
7394
    if (!strcmp (a2_el, "I "))
7395
            fg[fg_alkyl_iodide - 1] = true;
7395
            fg[fg_alkyl_iodide - 1] = istrue;
7396
  }
7396
  }
7397
  if ((strcmp (atom[a1 - 1].atype, "C2 ") == 0) && (hetbond_count (a1) == 3)) {
7397
  if ((strcmp (atom[a1 - 1].atype, "C2 ") == 0) && (hetbond_count (a1) == 3)) {
7398
    /* acyl halides and related compounds */
7398
    /* acyl halides and related compounds */
7399
    if (is_oxo_C (a1)) {
7399
    if (is_oxo_C (a1)) {
7400
            fg[fg_acyl_halide - 1] = true;
7400
            fg[fg_acyl_halide - 1] = istrue;
7401
            if (!strcmp (a2_el, "F "))
7401
            if (!strcmp (a2_el, "F "))
7402
              fg[fg_acyl_fluoride - 1] = true;
7402
              fg[fg_acyl_fluoride - 1] = istrue;
7403
            if (!strcmp (a2_el, "CL"))
7403
            if (!strcmp (a2_el, "CL"))
7404
              fg[fg_acyl_chloride - 1] = true;
7404
              fg[fg_acyl_chloride - 1] = istrue;
7405
            if (!strcmp (a2_el, "BR"))
7405
            if (!strcmp (a2_el, "BR"))
7406
              fg[fg_acyl_bromide - 1] = true;
7406
              fg[fg_acyl_bromide - 1] = istrue;
7407
            if (!strcmp (a2_el, "I "))
7407
            if (!strcmp (a2_el, "I "))
7408
              fg[fg_acyl_iodide - 1] = true;
7408
              fg[fg_acyl_iodide - 1] = istrue;
7409
          }
7409
          }
7410
    if (is_thioxo_C (a1))
7410
    if (is_thioxo_C (a1))
7411
            fg[fg_thiocarboxylic_acid_deriv - 1] = true;
7411
            fg[fg_thiocarboxylic_acid_deriv - 1] = istrue;
7412
    if (is_imino_C (a1))
7412
    if (is_imino_C (a1))
7413
            fg[fg_imidoyl_halide - 1] = true;
7413
            fg[fg_imidoyl_halide - 1] = istrue;
7414
  }
7414
  }
7415
  if (!((strcmp (atom[a1 - 1].atype, "C2 ") == 0)
7415
  if (!((strcmp (atom[a1 - 1].atype, "C2 ") == 0)
7416
       && (hetbond_count (a1) == 4)))
7416
       && (hetbond_count (a1) == 4)))
7417
    /* chloroformates etc. */
7417
    /* chloroformates etc. */
7418
    return;
7418
    return;
7419
  /* still missing: polyhalogen compounds (-CX2H, -CX3) */
7419
  /* still missing: polyhalogen compounds (-CX2H, -CX3) */
7420
  fg[fg_co2_deriv - 1] = true;
7420
  fg[fg_co2_deriv - 1] = istrue;
7421
  if (is_oxo_C (a1)) {
7421
  if (is_oxo_C (a1)) {
7422
      fg[fg_carbonic_acid_deriv - 1] = true;
7422
      fg[fg_carbonic_acid_deriv - 1] = istrue;
7423
    if (is_alkoxycarbonyl (a2, a1) || is_aryloxycarbonyl (a2, a1))
7423
    if (is_alkoxycarbonyl (a2, a1) || is_aryloxycarbonyl (a2, a1))
7424
            fg[fg_carbonic_acid_ester_halide - 1] = true;
7424
            fg[fg_carbonic_acid_ester_halide - 1] = istrue;
7425
    if (is_carbamoyl (a2, a1)) {
7425
    if (is_carbamoyl (a2, a1)) {
7426
            fg[fg_carbamic_acid_deriv - 1] = true;
7426
            fg[fg_carbamic_acid_deriv - 1] = istrue;
7427
            fg[fg_carbamic_acid_halide - 1] = true;
7427
            fg[fg_carbamic_acid_halide - 1] = istrue;
7428
          }
7428
          }
7429
  }
7429
  }
7430
  if (!is_thioxo_C (a1))
7430
  if (!is_thioxo_C (a1))
7431
    return;
7431
    return;
7432
  fg[fg_thiocarbonic_acid_deriv - 1] = true;
7432
  fg[fg_thiocarbonic_acid_deriv - 1] = istrue;
7433
  if (is_alkoxythiocarbonyl (a2, a1) || is_aryloxythiocarbonyl (a2, a1))
7433
  if (is_alkoxythiocarbonyl (a2, a1) || is_aryloxythiocarbonyl (a2, a1))
7434
    fg[fg_thiocarbonic_acid_ester_halide - 1] = true;
7434
    fg[fg_thiocarbonic_acid_ester_halide - 1] = istrue;
7435
  if (is_thiocarbamoyl (a2, a1)) {
7435
  if (is_thiocarbamoyl (a2, a1)) {
7436
    fg[fg_thiocarbamic_acid_deriv - 1] = true;
7436
    fg[fg_thiocarbamic_acid_deriv - 1] = istrue;
7437
    fg[fg_thiocarbamic_acid_halide - 1] = true;
7437
    fg[fg_thiocarbamic_acid_halide - 1] = istrue;
7438
      /* end of non-aromatic halogen compounds */
7438
      /* end of non-aromatic halogen compounds */
7439
  }
7439
  }
7440
}
7440
}
7441
 
7441
 
7442
static void chk_c_o(int a1,int a2)
7442
static void chk_c_o(int a1,int a2)
7443
{
7443
{
7444
  /* ignore heteroaromatic rings (like furan, thiophene, etc.) */
7444
  /* ignore heteroaromatic rings (like furan, thiophene, etc.) */
7445
  if (bond[get_bond (a1, a2) - 1].arom == true)
7445
  if (bond[get_bond (a1, a2) - 1].arom == istrue)
7446
    return;
7446
    return;
7447
  if (is_true_alkyl (a2, a1) && is_hydroxy (a1, a2)) {
7447
  if (is_istrue_alkyl (a2, a1) && is_hydroxy (a1, a2)) {
7448
    fg[fg_hydroxy - 1] = true;
7448
    fg[fg_hydroxy - 1] = istrue;
7449
    fg[fg_alcohol - 1] = true;
7449
    fg[fg_alcohol - 1] = istrue;
7450
    if (atom[a1 - 1].neighbor_count <= 2)
7450
    if (atom[a1 - 1].neighbor_count <= 2)
7451
            fg[fg_prim_alcohol - 1] = true;
7451
            fg[fg_prim_alcohol - 1] = istrue;
7452
    if (atom[a1 - 1].neighbor_count == 3)
7452
    if (atom[a1 - 1].neighbor_count == 3)
7453
            fg[fg_sec_alcohol - 1] = true;
7453
            fg[fg_sec_alcohol - 1] = istrue;
7454
    if (atom[a1 - 1].neighbor_count == 4)
7454
    if (atom[a1 - 1].neighbor_count == 4)
7455
            fg[fg_tert_alcohol - 1] = true;
7455
            fg[fg_tert_alcohol - 1] = istrue;
7456
  }
7456
  }
7457
  if (is_aryl (a2, a1) && is_hydroxy (a1, a2)) {
7457
  if (is_aryl (a2, a1) && is_hydroxy (a1, a2)) {
7458
    fg[fg_hydroxy - 1] = true;
7458
    fg[fg_hydroxy - 1] = istrue;
7459
    fg[fg_phenol - 1] = true;
7459
    fg[fg_phenol - 1] = istrue;
7460
  }
7460
  }
7461
  if (is_true_alkyl (a2, a1) && is_true_alkoxy (a1, a2)) {
7461
  if (is_istrue_alkyl (a2, a1) && is_istrue_alkoxy (a1, a2)) {
7462
    fg[fg_ether - 1] = true;
7462
    fg[fg_ether - 1] = istrue;
7463
    fg[fg_dialkylether - 1] = true;
7463
    fg[fg_dialkylether - 1] = istrue;
7464
  }
7464
  }
7465
  if ((is_true_alkyl (a2, a1) && is_aryloxy (a1, a2)) ||
7465
  if ((is_istrue_alkyl (a2, a1) && is_aryloxy (a1, a2)) ||
7466
      (is_aryl (a2, a1) && is_true_alkoxy (a1, a2))) {
7466
      (is_aryl (a2, a1) && is_istrue_alkoxy (a1, a2))) {
7467
    fg[fg_ether - 1] = true;
7467
    fg[fg_ether - 1] = istrue;
7468
    fg[fg_alkylarylether - 1] = true;
7468
    fg[fg_alkylarylether - 1] = istrue;
7469
  }
7469
  }
7470
  if (is_aryl (a2, a1) && is_aryloxy (a1, a2)) {
7470
  if (is_aryl (a2, a1) && is_aryloxy (a1, a2)) {
7471
    fg[fg_ether - 1] = true;
7471
    fg[fg_ether - 1] = istrue;
7472
    fg[fg_diarylether - 1] = true;
7472
    fg[fg_diarylether - 1] = istrue;
7473
  }
7473
  }
7474
  if ((is_true_alkyl (a2, a1) || is_aryl (a2, a1)) && is_alkynyloxy (a1, a2)) {
7474
  if ((is_istrue_alkyl (a2, a1) || is_aryl (a2, a1)) && is_alkynyloxy (a1, a2)) {
7475
    fg[fg_ether - 1] = true;
7475
    fg[fg_ether - 1] = istrue;
7476
    ether_generic = true;
7476
    ether_generic = istrue;
7477
  }
7477
  }
7478
  if (is_alkynyl (a2, a1) && is_hydroxy (a1, a2)) {
7478
  if (is_alkynyl (a2, a1) && is_hydroxy (a1, a2)) {
7479
    fg[fg_hydroxy - 1] = true;
7479
    fg[fg_hydroxy - 1] = istrue;
7480
    hydroxy_generic = true;
7480
    hydroxy_generic = istrue;
7481
  }
7481
  }
7482
}
7482
}
7483
 
7483
 
7484
static void chk_c_s(int a1,int a2)
7484
static void chk_c_s(int a1,int a2)
7485
{
7485
{
Line 7489... Line 7489...
7489
  int o_count = 0, oh_count = 0, or_count = 0, n_count = 0, c_count = 0,
7489
  int o_count = 0, oh_count = 0, or_count = 0, n_count = 0, c_count = 0,
7490
    hal_count = 0;
7490
    hal_count = 0;
7491
  int FORLIM;
7491
  int FORLIM;
7492
 
7492
 
7493
  /* ignore heteroaromatic rings (like furan, thiophene, etc.) */
7493
  /* ignore heteroaromatic rings (like furan, thiophene, etc.) */
7494
  if (bond[get_bond (a1, a2) - 1].arom == true)
7494
  if (bond[get_bond (a1, a2) - 1].arom == istrue)
7495
    return;
7495
    return;
7496
  if (is_alkyl (a2, a1) && is_sulfanyl (a1, a2)) {
7496
  if (is_alkyl (a2, a1) && is_sulfanyl (a1, a2)) {
7497
    fg[fg_thiol - 1] = true;
7497
    fg[fg_thiol - 1] = istrue;
7498
    fg[fg_alkylthiol - 1] = true;
7498
    fg[fg_alkylthiol - 1] = istrue;
7499
  }
7499
  }
7500
  if (is_aryl (a2, a1) && is_sulfanyl (a1, a2)) {
7500
  if (is_aryl (a2, a1) && is_sulfanyl (a1, a2)) {
7501
    fg[fg_thiol - 1] = true;
7501
    fg[fg_thiol - 1] = istrue;
7502
    fg[fg_arylthiol - 1] = true;
7502
    fg[fg_arylthiol - 1] = istrue;
7503
  }
7503
  }
7504
  if (is_true_alkyl (a2, a1) && is_true_alkylsulfanyl (a1, a2))
7504
  if (is_istrue_alkyl (a2, a1) && is_istrue_alkylsulfanyl (a1, a2))
7505
    fg[fg_thioether - 1] = true;
7505
    fg[fg_thioether - 1] = istrue;
7506
  if ((is_true_alkyl (a2, a1) && is_arylsulfanyl (a1, a2)) ||
7506
  if ((is_istrue_alkyl (a2, a1) && is_arylsulfanyl (a1, a2)) ||
7507
        (is_aryl (a2, a1) && is_true_alkylsulfanyl (a1, a2)))
7507
        (is_aryl (a2, a1) && is_istrue_alkylsulfanyl (a1, a2)))
7508
    fg[fg_thioether - 1] = true;
7508
    fg[fg_thioether - 1] = istrue;
7509
  if (is_aryl (a2, a1) && is_arylsulfanyl (a1, a2))
7509
  if (is_aryl (a2, a1) && is_arylsulfanyl (a1, a2))
7510
    fg[fg_thioether - 1] = true;
7510
    fg[fg_thioether - 1] = istrue;
7511
  /* check for sulfinic/sulfenic acid derivatives */
7511
  /* check for sulfinic/sulfenic acid derivatives */
7512
  memset (nb, 0, sizeof (neighbor_rec));
7512
  memset (nb, 0, sizeof (neighbor_rec));
7513
  get_neighbors (nb, a2);
7513
  get_neighbors (nb, a2);
7514
  FORLIM = atom[a2 - 1].neighbor_count;
7514
  FORLIM = atom[a2 - 1].neighbor_count;
7515
  for (i = 0; i < FORLIM; i++) {
7515
  for (i = 0; i < FORLIM; i++) {
Line 7530... Line 7530...
7530
  }
7530
  }
7531
  if (c_count != 1)
7531
  if (c_count != 1)
7532
    return;
7532
    return;
7533
  if (atom[a2 - 1].neighbor_count == 3 && o_count - oh_count - or_count == 1) {
7533
  if (atom[a2 - 1].neighbor_count == 3 && o_count - oh_count - or_count == 1) {
7534
    /* sulfinic acid && derivs */
7534
    /* sulfinic acid && derivs */
7535
    fg[fg_sulfinic_acid_deriv - 1] = true;
7535
    fg[fg_sulfinic_acid_deriv - 1] = istrue;
7536
    if (oh_count == 1)
7536
    if (oh_count == 1)
7537
            fg[fg_sulfinic_acid - 1] = true;
7537
            fg[fg_sulfinic_acid - 1] = istrue;
7538
    if (or_count == 1)
7538
    if (or_count == 1)
7539
            fg[fg_sulfinic_acid_ester - 1] = true;
7539
            fg[fg_sulfinic_acid_ester - 1] = istrue;
7540
    if (hal_count == 1)
7540
    if (hal_count == 1)
7541
            fg[fg_sulfinic_acid_halide - 1] = true;
7541
            fg[fg_sulfinic_acid_halide - 1] = istrue;
7542
    if (n_count == 1)
7542
    if (n_count == 1)
7543
            fg[fg_sulfinic_acid_amide - 1] = true;
7543
            fg[fg_sulfinic_acid_amide - 1] = istrue;
7544
  }
7544
  }
7545
  if (atom[a2 - 1].neighbor_count != 2 || o_count - oh_count - or_count != 0)
7545
  if (atom[a2 - 1].neighbor_count != 2 || o_count - oh_count - or_count != 0)
7546
    /* sulfenic acid && derivs */
7546
    /* sulfenic acid && derivs */
7547
    return;
7547
    return;
7548
 
7548
 
7549
  fg[fg_sulfenic_acid_deriv - 1] = true;
7549
  fg[fg_sulfenic_acid_deriv - 1] = istrue;
7550
  if (oh_count == 1)
7550
  if (oh_count == 1)
7551
    fg[fg_sulfenic_acid - 1] = true;
7551
    fg[fg_sulfenic_acid - 1] = istrue;
7552
  if (or_count == 1)
7552
  if (or_count == 1)
7553
    fg[fg_sulfenic_acid_ester - 1] = true;
7553
    fg[fg_sulfenic_acid_ester - 1] = istrue;
7554
  if (hal_count == 1)
7554
  if (hal_count == 1)
7555
    fg[fg_sulfenic_acid_halide - 1] = true;
7555
    fg[fg_sulfenic_acid_halide - 1] = istrue;
7556
  if (n_count == 1)
7556
  if (n_count == 1)
7557
    fg[fg_sulfenic_acid_amide - 1] = true;
7557
    fg[fg_sulfenic_acid_amide - 1] = istrue;
7558
}
7558
}
7559
 
7559
 
7560
static void chk_c_n(int a1,int a2)
7560
static void chk_c_n(int a1,int a2)
7561
{
7561
{
7562
  /* ignore heteroaromatic rings (like furan, thiophene, pyrrol, etc.) */
7562
  /* ignore heteroaromatic rings (like furan, thiophene, pyrrol, etc.) */
7563
  if (atom[a2 - 1].arom == true)
7563
  if (atom[a2 - 1].arom == istrue)
7564
    return;
7564
    return;
7565
  if (is_true_alkyl (a2, a1) && is_amino (a1, a2)) {
7565
  if (is_istrue_alkyl (a2, a1) && is_amino (a1, a2)) {
7566
    fg[fg_amine - 1] = true;
7566
    fg[fg_amine - 1] = istrue;
7567
    fg[fg_prim_amine - 1] = true;
7567
    fg[fg_prim_amine - 1] = istrue;
7568
    fg[fg_prim_aliph_amine - 1] = true;
7568
    fg[fg_prim_aliph_amine - 1] = istrue;
7569
    }
7569
    }
7570
  if (is_aryl (a2, a1) && is_amino (a1, a2)) {
7570
  if (is_aryl (a2, a1) && is_amino (a1, a2)) {
7571
    fg[fg_amine - 1] = true;
7571
    fg[fg_amine - 1] = istrue;
7572
    fg[fg_prim_amine - 1] = true;
7572
    fg[fg_prim_amine - 1] = istrue;
7573
    fg[fg_prim_arom_amine - 1] = true;
7573
    fg[fg_prim_arom_amine - 1] = istrue;
7574
  }
7574
  }
7575
  if (is_true_alkyl (a2, a1) && is_true_alkylamino (a1, a2)) {
7575
  if (is_istrue_alkyl (a2, a1) && is_istrue_alkylamino (a1, a2)) {
7576
    fg[fg_amine - 1] = true;
7576
    fg[fg_amine - 1] = istrue;
7577
    fg[fg_sec_amine - 1] = true;
7577
    fg[fg_sec_amine - 1] = istrue;
7578
    fg[fg_sec_aliph_amine - 1] = true;
7578
    fg[fg_sec_aliph_amine - 1] = istrue;
7579
  }
7579
  }
7580
  if (is_aryl (a2, a1) && is_true_alkylamino (a1, a2)) {
7580
  if (is_aryl (a2, a1) && is_istrue_alkylamino (a1, a2)) {
7581
    fg[fg_amine - 1] = true;
7581
    fg[fg_amine - 1] = istrue;
7582
    fg[fg_sec_amine - 1] = true;
7582
    fg[fg_sec_amine - 1] = istrue;
7583
    fg[fg_sec_mixed_amine - 1] = true;
7583
    fg[fg_sec_mixed_amine - 1] = istrue;
7584
  }
7584
  }
7585
  if (is_aryl (a2, a1) && is_arylamino (a1, a2)) {
7585
  if (is_aryl (a2, a1) && is_arylamino (a1, a2)) {
7586
    fg[fg_amine - 1] = true;
7586
    fg[fg_amine - 1] = istrue;
7587
    fg[fg_sec_amine - 1] = true;
7587
    fg[fg_sec_amine - 1] = istrue;
7588
    fg[fg_sec_arom_amine - 1] = true;
7588
    fg[fg_sec_arom_amine - 1] = istrue;
7589
  }
7589
  }
7590
  if (is_true_alkyl (a2, a1) && is_true_dialkylamino (a1, a2)) {
7590
  if (is_istrue_alkyl (a2, a1) && is_istrue_dialkylamino (a1, a2)) {
7591
    fg[fg_amine - 1] = true;
7591
    fg[fg_amine - 1] = istrue;
7592
    fg[fg_tert_amine - 1] = true;
7592
    fg[fg_tert_amine - 1] = istrue;
7593
    fg[fg_tert_aliph_amine - 1] = true;
7593
    fg[fg_tert_aliph_amine - 1] = istrue;
7594
  }
7594
  }
7595
  if ((is_true_alkyl (a2, a1) && is_diarylamino (a1, a2)) ||
7595
  if ((is_istrue_alkyl (a2, a1) && is_diarylamino (a1, a2)) ||
7596
      (is_aryl (a2, a1) && is_true_dialkylamino (a1, a2))) {
7596
      (is_aryl (a2, a1) && is_istrue_dialkylamino (a1, a2))) {
7597
    fg[fg_amine - 1] = true;
7597
    fg[fg_amine - 1] = istrue;
7598
    fg[fg_tert_amine - 1] = true;
7598
    fg[fg_tert_amine - 1] = istrue;
7599
    fg[fg_tert_mixed_amine - 1] = true;
7599
    fg[fg_tert_mixed_amine - 1] = istrue;
7600
  }
7600
  }
7601
  if (is_aryl (a2, a1) && is_diarylamino (a1, a2)) {
7601
  if (is_aryl (a2, a1) && is_diarylamino (a1, a2)) {
7602
    fg[fg_amine - 1] = true;
7602
    fg[fg_amine - 1] = istrue;
7603
    fg[fg_tert_amine - 1] = true;
7603
    fg[fg_tert_amine - 1] = istrue;
7604
    fg[fg_tert_arom_amine - 1] = true;
7604
    fg[fg_tert_arom_amine - 1] = istrue;
7605
  }
7605
  }
7606
  if ((is_alkyl (a2, a1) || is_aryl (a2, a1) || is_alkenyl (a2, a1) ||
7606
  if ((is_alkyl (a2, a1) || is_aryl (a2, a1) || is_alkenyl (a2, a1) ||
7607
       is_alkynyl (a2, a1)) && is_hydroxylamino (a1, a2) && (is_acyl_gen (a2, a1) == false))
7607
       is_alkynyl (a2, a1)) && is_hydroxylamino (a1, a2) && (is_acyl_gen (a2, a1) == isfalse))
7608
    /* v0.3k */
7608
    /* v0.3k */
7609
    fg[fg_hydroxylamine - 1] = true;
7609
    fg[fg_hydroxylamine - 1] = istrue;
7610
  /* v0.3k */
7610
  /* v0.3k */
7611
  /* v0.3k  */
7611
  /* v0.3k  */
7612
  if ((is_alkyl (a2, a1) || is_aryl (a2, a1) || is_acyl (a2, a1) ||
7612
  if ((is_alkyl (a2, a1) || is_aryl (a2, a1) || is_acyl (a2, a1) ||
7613
       is_alkenyl (a2, a1) || is_alkynyl (a2, a1)) && is_hydrazino (a1, a2))
7613
       is_alkenyl (a2, a1) || is_alkynyl (a2, a1)) && is_hydrazino (a1, a2))
7614
    fg[fg_hydrazine - 1] = true;
7614
    fg[fg_hydrazine - 1] = istrue;
7615
  if ((is_alkyl (a2, a1) || is_aryl (a2, a1) || is_alkenyl (a2, a1) ||
7615
  if ((is_alkyl (a2, a1) || is_aryl (a2, a1) || is_alkenyl (a2, a1) ||
7616
       is_alkynyl (a2, a1)) && is_azido (a1, a2))
7616
       is_alkynyl (a2, a1)) && is_azido (a1, a2))
7617
    /* v0.3k */
7617
    /* v0.3k */
7618
    fg[fg_azide - 1] = true;
7618
    fg[fg_azide - 1] = istrue;
7619
  if ((is_alkyl (a2, a1) || is_aryl (a2, a1) || is_alkenyl (a2, a1) ||
7619
  if ((is_alkyl (a2, a1) || is_aryl (a2, a1) || is_alkenyl (a2, a1) ||
7620
       is_alkynyl (a2, a1)) && is_diazonium (a1, a2))
7620
       is_alkynyl (a2, a1)) && is_diazonium (a1, a2))
7621
    /* v0.3k */
7621
    /* v0.3k */
7622
    fg[fg_diazonium_salt - 1] = true;
7622
    fg[fg_diazonium_salt - 1] = istrue;
7623
  if ((is_alkyl (a2, a1) || is_aryl (a2, a1) || is_alkenyl (a2, a1) |
7623
  if ((is_alkyl (a2, a1) || is_aryl (a2, a1) || is_alkenyl (a2, a1) |
7624
       is_alkynyl (a2, a1)) && is_nitro (a1, a2))
7624
       is_alkynyl (a2, a1)) && is_nitro (a1, a2))
7625
    /* v0.3k */
7625
    /* v0.3k */
7626
    fg[fg_nitro_compound - 1] = true;
7626
    fg[fg_nitro_compound - 1] = istrue;
7627
  if (is_alkynyl (a2, a1) &&
7627
  if (is_alkynyl (a2, a1) &&
7628
        (is_amino (a1, a2) || is_C_monosubst_amino (a1, a2) |
7628
        (is_amino (a1, a2) || is_C_monosubst_amino (a1, a2) |
7629
       (is_C_disubst_amino (a1, a2) && (!is_acylamino (a1, a2))))) {
7629
       (is_C_disubst_amino (a1, a2) && (!is_acylamino (a1, a2))))) {
7630
      fg[fg_amine - 1] = true;
7630
      fg[fg_amine - 1] = istrue;
7631
      amine_generic = true;
7631
      amine_generic = istrue;
7632
  }
7632
  }
7633
}
7633
}
7634
 
7634
 
7635
static void chk_c_c(int a1,int a2)
7635
static void chk_c_c(int a1,int a2)
7636
{
7636
{
7637
  int i;
7637
  int i;
7638
  neighbor_rec nb;
7638
  neighbor_rec nb;
7639
  int oh_count, nhr_count, FORLIM;
7639
  int oh_count, nhr_count, FORLIM;
7640
 
7640
 
7641
  /* ignore aromatic rings */
7641
  /* ignore aromatic rings */
7642
  if (atom[a2 - 1].arom == true)
7642
  if (atom[a2 - 1].arom == istrue)
7643
    return;
7643
    return;
7644
  /*check for 1,2-diols and 1,2-aminoalcoholes */
7644
  /*check for 1,2-diols and 1,2-aminoalcoholes */
7645
  if (!strcmp (atom[a1 - 1].atype, "C3 ")
7645
  if (!strcmp (atom[a1 - 1].atype, "C3 ")
7646
        && !strcmp (atom[a2 - 1].atype, "C3 ")) {
7646
        && !strcmp (atom[a2 - 1].atype, "C3 ")) {
7647
      if ((hetbond_count (a1) == 1) && (hetbond_count (a2) == 1)) {
7647
      if ((hetbond_count (a1) == 1) && (hetbond_count (a2) == 1)) {
Line 7670... Line 7670...
7670
                          is_arylamino (a2, nb[i]))
7670
                          is_arylamino (a2, nb[i]))
7671
                        nhr_count++;
7671
                        nhr_count++;
7672
                    }
7672
                    }
7673
            }
7673
            }
7674
            if (oh_count == 2)
7674
            if (oh_count == 2)
7675
              fg[fg_1_2_diol - 1] = true;
7675
              fg[fg_1_2_diol - 1] = istrue;
7676
            if (oh_count == 1 && nhr_count == 1)
7676
            if (oh_count == 1 && nhr_count == 1)
7677
              fg[fg_1_2_aminoalcohol - 1] = true;
7677
              fg[fg_1_2_aminoalcohol - 1] = istrue;
7678
          }
7678
          }
7679
  }
7679
  }
7680
  /* check for alpha-aminoacids and alpha-hydroxyacids */
7680
  /* check for alpha-aminoacids and alpha-hydroxyacids */
7681
  if (strcmp (atom[a1 - 1].atype, "C3 ")
7681
  if (strcmp (atom[a1 - 1].atype, "C3 ")
7682
      || strcmp (atom[a2 - 1].atype, "C2 "))
7682
      || strcmp (atom[a2 - 1].atype, "C2 "))
Line 7705... Line 7705...
7705
            if (is_hydroxy (a2, nb[i]))
7705
            if (is_hydroxy (a2, nb[i]))
7706
              oh_count++;
7706
              oh_count++;
7707
          }
7707
          }
7708
  }
7708
  }
7709
  if ((oh_count == 2) && is_oxo_C (a2))
7709
  if ((oh_count == 2) && is_oxo_C (a2))
7710
    fg[fg_alpha_hydroxyacid - 1] = true;
7710
    fg[fg_alpha_hydroxyacid - 1] = istrue;
7711
  if ((oh_count == 1 && nhr_count == 1) && is_oxo_C (a2))
7711
  if ((oh_count == 1 && nhr_count == 1) && is_oxo_C (a2))
7712
    fg[fg_alpha_aminoacid - 1] = true;
7712
    fg[fg_alpha_aminoacid - 1] = istrue;
7713
}
7713
}
7714
 
7714
 
7715
static void chk_x_y_single (int a_view, int a_ref)
7715
static void chk_x_y_single (int a_view, int a_ref)
7716
{
7716
{
7717
  if (!strcmp (atom[a_view - 1].atype, "O3 ") &&
7717
  if (!strcmp (atom[a_view - 1].atype, "O3 ") &&
7718
        !strcmp (atom[a_ref - 1].atype, "O3 ")) {
7718
        !strcmp (atom[a_ref - 1].atype, "O3 ")) {
7719
    if (is_hydroxy (a_ref, a_view) || is_hydroxy (a_view, a_ref))
7719
    if (is_hydroxy (a_ref, a_view) || is_hydroxy (a_view, a_ref))
7720
            fg[fg_hydroperoxide - 1] = true;
7720
            fg[fg_hydroperoxide - 1] = istrue;
7721
    if ((is_alkoxy (a_ref, a_view) || is_aryloxy (a_ref, a_view) |
7721
    if ((is_alkoxy (a_ref, a_view) || is_aryloxy (a_ref, a_view) |
7722
              is_siloxy (a_ref, a_view)) && (is_alkoxy (a_view,a_ref) |
7722
              is_siloxy (a_ref, a_view)) && (is_alkoxy (a_view,a_ref) |
7723
                        is_aryloxy (a_view, a_ref) |
7723
                        is_aryloxy (a_view, a_ref) |
7724
                        is_siloxy (a_view, a_ref)))
7724
                        is_siloxy (a_view, a_ref)))
7725
            fg[fg_peroxide - 1] = true;
7725
            fg[fg_peroxide - 1] = istrue;
7726
  }                             /* still missing: peracid */
7726
  }                             /* still missing: peracid */
7727
  if (!strcmp (atom[a_view - 1].atype, "S3 ") &&
7727
  if (!strcmp (atom[a_view - 1].atype, "S3 ") &&
7728
      !strcmp (atom[a_ref - 1].atype, "S3 ")) {
7728
      !strcmp (atom[a_ref - 1].atype, "S3 ")) {
7729
      if (atom[a_view - 1].neighbor_count == 2 &&
7729
      if (atom[a_view - 1].neighbor_count == 2 &&
7730
          atom[a_ref - 1].neighbor_count == 2)
7730
          atom[a_ref - 1].neighbor_count == 2)
7731
          fg[fg_disulfide - 1] = true;
7731
          fg[fg_disulfide - 1] = istrue;
7732
  }
7732
  }
7733
  if ((!strcmp (atom[a_view - 1].element, "N ") &&
7733
  if ((!strcmp (atom[a_view - 1].element, "N ") &&
7734
       !strcmp (atom[a_ref - 1].element, "N ")) && (hetbond_count (a_view) == 1)
7734
       !strcmp (atom[a_ref - 1].element, "N ")) && (hetbond_count (a_view) == 1)
7735
      && (hetbond_count (a_ref) == 1)) {
7735
      && (hetbond_count (a_ref) == 1)) {
7736
      /*if ((is_amino(a_ref,a_view)) or  */
7736
      /*if ((is_amino(a_ref,a_view)) or  */
7737
      /*    (is_subst_amino(a_ref,a_view)) or */
7737
      /*    (is_subst_amino(a_ref,a_view)) or */
7738
      /*    (is_acylamino(a_ref,a_view))) and */
7738
      /*    (is_acylamino(a_ref,a_view))) and */
7739
      /*   ((is_amino(a_view,a_ref)) or  */
7739
      /*   ((is_amino(a_view,a_ref)) or  */
7740
      /*    (is_subst_amino(a_view,a_ref)) or */
7740
      /*    (is_subst_amino(a_view,a_ref)) or */
7741
      /*    (is_acylamino(a_ref,a_view))) then  */
7741
      /*    (is_acylamino(a_ref,a_view))) then  */
7742
      if (bond[get_bond (a_view, a_ref) - 1].arom == false)
7742
      if (bond[get_bond (a_view, a_ref) - 1].arom == isfalse)
7743
              fg[fg_hydrazine - 1] = true;
7743
              fg[fg_hydrazine - 1] = istrue;
7744
  }
7744
  }
7745
  if (!strcmp (atom[a_view - 1].element, "N ") &&
7745
  if (!strcmp (atom[a_view - 1].element, "N ") &&
7746
      !strcmp (atom[a_ref - 1].atype, "O3 ")) {
7746
      !strcmp (atom[a_ref - 1].atype, "O3 ")) {
7747
    /* bond is in "opposite" direction */
7747
    /* bond is in "opposite" direction */
7748
    if ((is_alkoxy (a_view, a_ref) || is_aryloxy (a_view, a_ref)) &&
7748
    if ((is_alkoxy (a_view, a_ref) || is_aryloxy (a_view, a_ref)) &&
7749
              is_nitro (a_ref, a_view))
7749
              is_nitro (a_ref, a_view))
7750
            fg[fg_nitrate - 1] = true;
7750
            fg[fg_nitrate - 1] = istrue;
7751
    if ((is_nitro (a_ref, a_view) == false
7751
    if ((is_nitro (a_ref, a_view) == isfalse
7752
              && atom[a_view - 1].arom == false) && (is_amino (a_ref, a_view) |
7752
              && atom[a_view - 1].arom == isfalse) && (is_amino (a_ref, a_view) |
7753
                    is_subst_amino (a_ref, a_view)) &&
7753
                    is_subst_amino (a_ref, a_view)) &&
7754
              (is_acylamino (a_ref, a_view) == false))
7754
              (is_acylamino (a_ref, a_view) == isfalse))
7755
            fg[fg_hydroxylamine - 1] = true;    /* new in v0.3c */
7755
            fg[fg_hydroxylamine - 1] = istrue;  /* new in v0.3c */
7756
  }
7756
  }
7757
  if (!strcmp (atom[a_view - 1].element, "S ") &&
7757
  if (!strcmp (atom[a_view - 1].element, "S ") &&
7758
      !strcmp (atom[a_ref - 1].element, "O "))
7758
      !strcmp (atom[a_ref - 1].element, "O "))
7759
    chk_sulfoxide (a_view, a_ref);
7759
    chk_sulfoxide (a_view, a_ref);
7760
}
7760
}
Line 7773... Line 7773...
7773
    chk_c_o (a1, a2);
7773
    chk_c_o (a1, a2);
7774
  if (!strcmp (a1_el, "C ") && !strcmp (a2_el, "S "))
7774
  if (!strcmp (a1_el, "C ") && !strcmp (a2_el, "S "))
7775
    chk_c_s (a1, a2);
7775
    chk_c_s (a1, a2);
7776
  if (!strcmp (a1_el, "C ") && !strcmp (a2_el, "N "))
7776
  if (!strcmp (a1_el, "C ") && !strcmp (a2_el, "N "))
7777
    chk_c_n (a1, a2);
7777
    chk_c_n (a1, a2);
7778
  if ((strcmp (a1_el, "C ") == 0) && atom[a2 - 1].metal && (is_cyano_c (a1) == false)) {
7778
  if ((strcmp (a1_el, "C ") == 0) && atom[a2 - 1].metal && (is_cyano_c (a1) == isfalse)) {
7779
      fg[fg_organometallic - 1] = true;
7779
      fg[fg_organometallic - 1] = istrue;
7780
      if (!strcmp (a2_el, "LI"))
7780
      if (!strcmp (a2_el, "LI"))
7781
              fg[fg_organolithium - 1] = true;
7781
              fg[fg_organolithium - 1] = istrue;
7782
      if (!strcmp (a2_el, "MG"))
7782
      if (!strcmp (a2_el, "MG"))
7783
              fg[fg_organomagnesium - 1] = true;
7783
              fg[fg_organomagnesium - 1] = istrue;
7784
  }
7784
  }
7785
  if (!strcmp (a1_el, "C ") && !strcmp (a2_el, "C "))
7785
  if (!strcmp (a1_el, "C ") && !strcmp (a2_el, "C "))
7786
    chk_c_c (a1, a2);
7786
    chk_c_c (a1, a2);
7787
  if (strcmp (a1_el, "C ") && strcmp (a2_el, "C "))
7787
  if (strcmp (a1_el, "C ") && strcmp (a2_el, "C "))
7788
    chk_x_y_single (a1, a2);
7788
    chk_x_y_single (a1, a2);
Line 7811... Line 7811...
7811
            sr_count++;
7811
            sr_count++;
7812
    if (!strcmp (atom[nb[i] - 1].atype, "N3 ") || !strcmp (atom[nb[i] - 1].atype, "NAM"))
7812
    if (!strcmp (atom[nb[i] - 1].atype, "N3 ") || !strcmp (atom[nb[i] - 1].atype, "NAM"))
7813
            n_count++;
7813
            n_count++;
7814
  }
7814
  }
7815
  if (oh_count == 2)
7815
  if (oh_count == 2)
7816
    fg[fg_carbonyl_hydrate - 1] = true;
7816
    fg[fg_carbonyl_hydrate - 1] = istrue;
7817
  if (oh_count == 1 && or_count == 1)
7817
  if (oh_count == 1 && or_count == 1)
7818
    fg[fg_hemiacetal - 1] = true;
7818
    fg[fg_hemiacetal - 1] = istrue;
7819
  if (or_count == 2)
7819
  if (or_count == 2)
7820
    fg[fg_acetal - 1] = true;
7820
    fg[fg_acetal - 1] = istrue;
7821
  if ((oh_count == 1 || or_count == 1) && n_count == 1)
7821
  if ((oh_count == 1 || or_count == 1) && n_count == 1)
7822
    fg[fg_hemiaminal - 1] = true;
7822
    fg[fg_hemiaminal - 1] = istrue;
7823
  if (n_count == 2)
7823
  if (n_count == 2)
7824
    fg[fg_aminal - 1] = true;
7824
    fg[fg_aminal - 1] = istrue;
7825
  if ((sh_count == 1 || sr_count == 1) && n_count == 1)
7825
  if ((sh_count == 1 || sr_count == 1) && n_count == 1)
7826
    fg[fg_thiohemiaminal - 1] = true;
7826
    fg[fg_thiohemiaminal - 1] = istrue;
7827
  if (sr_count == 2 || (or_count == 1 && sr_count == 1))
7827
  if (sr_count == 2 || (or_count == 1 && sr_count == 1))
7828
    fg[fg_thioacetal - 1] = true;
7828
    fg[fg_thioacetal - 1] = istrue;
7829
}
7829
}
7830
 
7830
 
7831
static void chk_carboxyl_deriv_sp3 (int a_ref)
7831
static void chk_carboxyl_deriv_sp3 (int a_ref)
7832
{
7832
{
7833
  int i;
7833
  int i;
Line 7856... Line 7856...
7856
            oh_count++;
7856
            oh_count++;
7857
    if (!strcmp (atom[nb[i] - 1].atype, "N3 ") ||
7857
    if (!strcmp (atom[nb[i] - 1].atype, "N3 ") ||
7858
              !strcmp (atom[nb[i] - 1].atype, "NAM"))
7858
              !strcmp (atom[nb[i] - 1].atype, "NAM"))
7859
            n_count++;
7859
            n_count++;
7860
  }
7860
  }
7861
  /*if (or_count + n_count > 1) then fg[fg_orthocarboxylic_acid_deriv] := true;  (* until v0.3i */
7861
  /*if (or_count + n_count > 1) then fg[fg_orthocarboxylic_acid_deriv] := istrue;  (* until v0.3i */
7862
  if (electroneg_count == 3 && hal_count < 3)   /* v0.3j */
7862
  if (electroneg_count == 3 && hal_count < 3)   /* v0.3j */
7863
    fg[fg_orthocarboxylic_acid_deriv - 1] = true;
7863
    fg[fg_orthocarboxylic_acid_deriv - 1] = istrue;
7864
  if (or_count == 3)
7864
  if (or_count == 3)
7865
    fg[fg_carboxylic_acid_orthoester - 1] = true;
7865
    fg[fg_carboxylic_acid_orthoester - 1] = istrue;
7866
  if (or_count == 2 && n_count == 1)
7866
  if (or_count == 2 && n_count == 1)
7867
    fg[fg_carboxylic_acid_amide_acetal - 1] = true;
7867
    fg[fg_carboxylic_acid_amide_acetal - 1] = istrue;
7868
  if (oh_count > 0 && oh_count + or_count + n_count == 3)       /* new in v0.3c */
7868
  if (oh_count > 0 && oh_count + or_count + n_count == 3)       /* new in v0.3c */
7869
    fg[fg_orthocarboxylic_acid_deriv - 1] = true;
7869
    fg[fg_orthocarboxylic_acid_deriv - 1] = istrue;
7870
}
7870
}
7871
 
7871
 
7872
static void chk_anhydride (int a_ref)
7872
static void chk_anhydride (int a_ref)
7873
{
7873
{
7874
  int i;
7874
  int i;
Line 7882... Line 7882...
7882
  for (i = 0; i < FORLIM; i++) {
7882
  for (i = 0; i < FORLIM; i++) {
7883
    if (is_acyl (a_ref, nb[i]) || is_carbamoyl (a_ref, nb[i]))
7883
    if (is_acyl (a_ref, nb[i]) || is_carbamoyl (a_ref, nb[i]))
7884
            acyl_count++;
7884
            acyl_count++;
7885
  }
7885
  }
7886
  if (acyl_count == 2 && !strcmp (atom[a_ref - 1].atype, "O3 ")) {
7886
  if (acyl_count == 2 && !strcmp (atom[a_ref - 1].atype, "O3 ")) {
7887
    fg[fg_carboxylic_acid_deriv - 1] = true;
7887
    fg[fg_carboxylic_acid_deriv - 1] = istrue;
7888
    fg[fg_carboxylic_acid_anhydride - 1] = true;
7888
    fg[fg_carboxylic_acid_anhydride - 1] = istrue;
7889
  }
7889
  }
7890
}
7890
}
7891
 
7891
 
7892
static void chk_imide (int a_ref)
7892
static void chk_imide (int a_ref)
7893
{
7893
{
Line 7904... Line 7904...
7904
            acyl_count++;
7904
            acyl_count++;
7905
  }
7905
  }
7906
  if (acyl_count < 2 || strcmp (atom[a_ref - 1].element, "N "))
7906
  if (acyl_count < 2 || strcmp (atom[a_ref - 1].element, "N "))
7907
    /* v0.3j: accept also N-acyl-imides */
7907
    /* v0.3j: accept also N-acyl-imides */
7908
    return;
7908
    return;
7909
  fg[fg_carboxylic_acid_deriv - 1] = true;
7909
  fg[fg_carboxylic_acid_deriv - 1] = istrue;
7910
  fg[fg_carboxylic_acid_imide - 1] = true;
7910
  fg[fg_carboxylic_acid_imide - 1] = istrue;
7911
  if (atom[a_ref - 1].neighbor_count == 2)
7911
  if (atom[a_ref - 1].neighbor_count == 2)
7912
    fg[fg_carboxylic_acid_unsubst_imide - 1] = true;
7912
    fg[fg_carboxylic_acid_unsubst_imide - 1] = istrue;
7913
  if (atom[a_ref - 1].neighbor_count == 3)
7913
  if (atom[a_ref - 1].neighbor_count == 3)
7914
    fg[fg_carboxylic_acid_subst_imide - 1] = true;
7914
    fg[fg_carboxylic_acid_subst_imide - 1] = istrue;
7915
}
7915
}
7916
 
7916
 
7917
static void chk_12diphenol (int a_view, int a_ref)
7917
static void chk_12diphenol (int a_view, int a_ref)
7918
{
7918
{
7919
  int i;
7919
  int i;
Line 7938... Line 7938...
7938
            if (is_hydroxy (a_ref, nb[i]))
7938
            if (is_hydroxy (a_ref, nb[i]))
7939
              oh_count++;
7939
              oh_count++;
7940
          }
7940
          }
7941
  }
7941
  }
7942
  if (oh_count == 2)
7942
  if (oh_count == 2)
7943
    fg[fg_1_2_diphenol - 1] = true;
7943
    fg[fg_1_2_diphenol - 1] = istrue;
7944
}
7944
}
7945
 
7945
 
7946
static void chk_arom_fg (int a1, int a2)
7946
static void chk_arom_fg (int a1, int a2)
7947
{
7947
{
7948
  if ((hetbond_count (a1) == 1) && (hetbond_count (a2) == 1))
7948
  if ((hetbond_count (a1) == 1) && (hetbond_count (a2) == 1))
Line 7950... Line 7950...
7950
}
7950
}
7951
 
7951
 
7952
static boolean is_arene (int r_id)
7952
static boolean is_arene (int r_id)
7953
{
7953
{
7954
  int i, j;
7954
  int i, j;
7955
  boolean r = true;
7955
  boolean r = istrue;
7956
  ringpath_type testring;
7956
  ringpath_type testring;
7957
  int ring_size, a_prev, a_ref;
7957
  int ring_size, a_prev, a_ref;
7958
 
7958
 
7959
/* p2c: checkmol.pas: Note: Eliminated unused assignment statement [338] */
7959
/* p2c: checkmol.pas: Note: Eliminated unused assignment statement [338] */
7960
  if (r_id < 1 || r_id > n_rings)
7960
  if (r_id < 1 || r_id > n_rings)
7961
    return false;
7961
    return isfalse;
7962
  memset (testring, 0, sizeof (ringpath_type));
7962
  memset (testring, 0, sizeof (ringpath_type));
7963
  ring_size = ringprop[r_id - 1].size;  /* v0.3j */
7963
  ring_size = ringprop[r_id - 1].size;  /* v0.3j */
7964
  /*for j := 1 to max_ringsize do if ring^[r_id,j] > 0 then testring[j] := ring^[r_id,j]; */
7964
  /*for j := 1 to max_ringsize do if ring^[r_id,j] > 0 then testring[j] := ring^[r_id,j]; */
7965
  for (j = 0; j < ring_size; j++)       /* v0.3j */
7965
  for (j = 0; j < ring_size; j++)       /* v0.3j */
7966
    testring[j] = ring[r_id - 1][j];
7966
    testring[j] = ring[r_id - 1][j];
7967
  /*ring_size := path_length(testring); */
7967
  /*ring_size := path_length(testring); */
7968
  if (ring_size <= 2)
7968
  if (ring_size <= 2)
7969
    return false;
7969
    return isfalse;
7970
  a_prev = testring[ring_size - 1];
7970
  a_prev = testring[ring_size - 1];
7971
  for (i = 0; i < ring_size; i++) {
7971
  for (i = 0; i < ring_size; i++) {
7972
    a_ref = testring[i];
7972
    a_ref = testring[i];
7973
    if (bond[get_bond (a_prev, a_ref) - 1].arom == false)
7973
    if (bond[get_bond (a_prev, a_ref) - 1].arom == isfalse)
7974
            r = false;
7974
            r = isfalse;
7975
    a_prev = a_ref;
7975
    a_prev = a_ref;
7976
  }
7976
  }
7977
  return r;
7977
  return r;
7978
}
7978
}
7979
 
7979
 
7980
static boolean is_heterocycle (int r_id)
7980
static boolean is_heterocycle (int r_id)
7981
{
7981
{
7982
  int i, j;
7982
  int i, j;
7983
  boolean r = false;
7983
  boolean r = isfalse;
7984
  ringpath_type testring;
7984
  ringpath_type testring;
7985
  int ring_size, a_ref;
7985
  int ring_size, a_ref;
7986
 
7986
 
7987
  if (r_id < 1 || r_id > n_rings)
7987
  if (r_id < 1 || r_id > n_rings)
7988
    return false;
7988
    return isfalse;
7989
  memset (testring, 0, sizeof (ringpath_type));
7989
  memset (testring, 0, sizeof (ringpath_type));
7990
  ring_size = ringprop[r_id - 1].size;  /* v0.3j */
7990
  ring_size = ringprop[r_id - 1].size;  /* v0.3j */
7991
  /*for j := 1 to max_ringsize do if ring^[r_id,j] > 0 then testring[j] := ring^[r_id,j]; */
7991
  /*for j := 1 to max_ringsize do if ring^[r_id,j] > 0 then testring[j] := ring^[r_id,j]; */
7992
  for (j = 0; j < ring_size; j++)       /* v0.3j */
7992
  for (j = 0; j < ring_size; j++)       /* v0.3j */
7993
    testring[j] = ring[r_id - 1][j];
7993
    testring[j] = ring[r_id - 1][j];
7994
  /*ring_size := path_length(testring); */
7994
  /*ring_size := path_length(testring); */
7995
  if (ring_size <= 2)
7995
  if (ring_size <= 2)
7996
    return false;
7996
    return isfalse;
7997
  for (i = 0; i < ring_size; i++) {
7997
  for (i = 0; i < ring_size; i++) {
7998
    a_ref = testring[i];
7998
    a_ref = testring[i];
7999
    if (strcmp (atom[a_ref - 1].element, "C "))
7999
    if (strcmp (atom[a_ref - 1].element, "C "))
8000
            r = true;
8000
            r = istrue;
8001
  }
8001
  }
8002
  return r;
8002
  return r;
8003
}
8003
}
8004
 
8004
 
8005
static void chk_oxo_thioxo_imino_hetarene (int r_id)
8005
static void chk_oxo_thioxo_imino_hetarene (int r_id)
Line 8014... Line 8014...
8014
  ring_size = ringprop[r_id - 1].size;  /* v0.3j */
8014
  ring_size = ringprop[r_id - 1].size;  /* v0.3j */
8015
  /*for j := 1 to max_ringsize do if ring^[r_id,j] > 0 then testring[j] := ring^[r_id,j]; */
8015
  /*for j := 1 to max_ringsize do if ring^[r_id,j] > 0 then testring[j] := ring^[r_id,j]; */
8016
  for (j = 0; j < ring_size; j++)       /* v0.3j */
8016
  for (j = 0; j < ring_size; j++)       /* v0.3j */
8017
    testring[j] = ring[r_id - 1][j];
8017
    testring[j] = ring[r_id - 1][j];
8018
  /*ring_size := path_length(testring); */
8018
  /*ring_size := path_length(testring); */
8019
  /*if (is_arene(r_id)) and (odd(ring_size) = false) then */
8019
  /*if (is_arene(r_id)) and (odd(ring_size) = isfalse) then */
8020
  if (!is_arene (r_id))         /* v0.3j */
8020
  if (!is_arene (r_id))         /* v0.3j */
8021
    return;
8021
    return;
8022
  for (i = 0; i < ring_size; i++) {
8022
  for (i = 0; i < ring_size; i++) {
8023
    a_ref = testring[i];
8023
    a_ref = testring[i];
8024
    if (is_oxo_C (a_ref))
8024
    if (is_oxo_C (a_ref))
8025
            fg[fg_oxohetarene - 1] = true;
8025
            fg[fg_oxohetarene - 1] = istrue;
8026
    if (is_thioxo_C (a_ref))
8026
    if (is_thioxo_C (a_ref))
8027
            fg[fg_thioxohetarene - 1] = true;
8027
            fg[fg_thioxohetarene - 1] = istrue;
8028
    if (is_true_exocyclic_imino_C (a_ref, r_id))        /* v0.3j */
8028
    if (is_istrue_exocyclic_imino_C (a_ref, r_id))      /* v0.3j */
8029
            fg[fg_iminohetarene - 1] = true;
8029
            fg[fg_iminohetarene - 1] = istrue;
8030
  }
8030
  }
8031
}
8031
}
8032
 
8032
 
8033
static void chk_ion (int a_ref)
8033
static void chk_ion (int a_ref)
8034
{
8034
{
Line 8044... Line 8044...
8044
    return;
8044
    return;
8045
  FORLIM = atom[a_ref - 1].neighbor_count;
8045
  FORLIM = atom[a_ref - 1].neighbor_count;
8046
  for (i = 0; i < FORLIM; i++)
8046
  for (i = 0; i < FORLIM; i++)
8047
    charge += atom[nb[i] - 1].formal_charge;
8047
    charge += atom[nb[i] - 1].formal_charge;
8048
  if (charge > 0)
8048
  if (charge > 0)
8049
    fg[fg_cation - 1] = true;
8049
    fg[fg_cation - 1] = istrue;
8050
  if (charge < 0)
8050
  if (charge < 0)
8051
    fg[fg_anion - 1] = true;
8051
    fg[fg_anion - 1] = istrue;
8052
}
8052
}
8053
 
8053
 
8054
static void chk_functionalgroups ()
8054
static void chk_functionalgroups ()
8055
{
8055
{
8056
  int i, a1, a2;
8056
  int i, a1, a2;
Line 8062... Line 8062...
8062
    return;
8062
    return;
8063
  FORLIM = n_atoms;
8063
  FORLIM = n_atoms;
8064
  for (i = 1; i <= FORLIM; i++) {                               /* a few groups are best discovered in the atom list */
8064
  for (i = 1; i <= FORLIM; i++) {                               /* a few groups are best discovered in the atom list */
8065
    if (!strcmp (atom[i - 1].atype, "SO2"))
8065
    if (!strcmp (atom[i - 1].atype, "SO2"))
8066
            chk_so2_deriv (i);
8066
            chk_so2_deriv (i);
8067
    /*if (atom^[i].atype = 'SO ') then fg[fg_sulfoxide] := true;  (* do another check in the bond list!! */
8067
    /*if (atom^[i].atype = 'SO ') then fg[fg_sulfoxide] := istrue;  (* do another check in the bond list!! */
8068
    if (!strcmp (atom[i - 1].element, "P "))
8068
    if (!strcmp (atom[i - 1].element, "P "))
8069
            chk_p_deriv (i);
8069
            chk_p_deriv (i);
8070
    if (!strcmp (atom[i - 1].element, "B "))
8070
    if (!strcmp (atom[i - 1].element, "B "))
8071
            chk_b_deriv (i);
8071
            chk_b_deriv (i);
8072
    if (!strcmp (atom[i - 1].atype, "N3+") || atom[i - 1].formal_charge > 0)
8072
    if (!strcmp (atom[i - 1].atype, "N3+") || atom[i - 1].formal_charge > 0)
Line 8106... Line 8106...
8106
  if (n_rings > 0) {
8106
  if (n_rings > 0) {
8107
    FORLIM = n_rings;
8107
    FORLIM = n_rings;
8108
    for (i = 1; i <= FORLIM; i++) {
8108
    for (i = 1; i <= FORLIM; i++) {
8109
            chk_oxo_thioxo_imino_hetarene (i);
8109
            chk_oxo_thioxo_imino_hetarene (i);
8110
            if (is_arene (i))
8110
            if (is_arene (i))
8111
              fg[fg_aromatic - 1] = true;
8111
              fg[fg_aromatic - 1] = istrue;
8112
            if (is_heterocycle (i))
8112
            if (is_heterocycle (i))
8113
              fg[fg_heterocycle - 1] = true;
8113
              fg[fg_heterocycle - 1] = istrue;
8114
          }
8114
          }
8115
  }
8115
  }
8116
  if (pos_chg + neg_chg > 0)
8116
  if (pos_chg + neg_chg > 0)
8117
    fg[fg_cation - 1] = true;
8117
    fg[fg_cation - 1] = istrue;
8118
  if (pos_chg + neg_chg < 0)
8118
  if (pos_chg + neg_chg < 0)
8119
    fg[fg_anion - 1] = true;
8119
    fg[fg_anion - 1] = istrue;
8120
}
8120
}
8121
 
8121
 
8122
static void write_fg_text ()
8122
static void write_fg_text ()
8123
{
8123
{
8124
  if (fg[fg_cation - 1])
8124
  if (fg[fg_cation - 1])
Line 9480... Line 9480...
9480
  {
9480
  {
9481
  if (!rfile_is_open)
9481
  if (!rfile_is_open)
9482
  {
9482
  {
9483
  assign (rfile, molfilename);
9483
  assign (rfile, molfilename);
9484
  rewind (rfile);
9484
  rewind (rfile);
9485
  rfile_is_open = true;
9485
  rfile_is_open = istrue;
9486
  }
9486
  }
9487
  /* p2c: checkmol.pas, line 7733: Warning:
9487
  /* p2c: checkmol.pas, line 7733: Warning:
9488
  * Don't know how to ASSIGN to a non-explicit file variable [207] */
9488
  * Don't know how to ASSIGN to a non-explicit file variable [207] */
9489
  *rline = '\0';
9489
  *rline = '\0';
9490
  mol_in_queue = false;
9490
  mol_in_queue = isfalse;
9491
  while ((!P_eof (rfile)) && (strpos2 (rline, "$$$$", 1) == 0))
9491
  while ((!P_eof (rfile)) && (strpos2 (rline, "$$$$", 1) == 0))
9492
  {
9492
  {
9493
  fgets (rline, 256, rfile);
9493
  fgets (rline, 256, rfile);
9494
  TEMP = strchr (rline, '\n');
9494
  TEMP = strchr (rline, '\n');
9495
  if (TEMP != NULL)
9495
  if (TEMP != NULL)
9496
  *TEMP = 0;
9496
  *TEMP = 0;
9497
  /*mol_in_queue := false; */
9497
  /*mol_in_queue := isfalse; */
9498
  if (molbufindex >= max_atoms + max_bonds + 64)
9498
  if (molbufindex >= max_atoms + max_bonds + 64)
9499
  {
9499
  {
9500
  printf ("Not enough memory for molfile! %12ld\n",
9500
  printf ("Not enough memory for molfile! %12ld\n",
9501
  molbufindex);
9501
  molbufindex);
9502
  if (rfile != NULL)
9502
  if (rfile != NULL)
Line 9505... Line 9505...
9505
  _Escape (1);
9505
  _Escape (1);
9506
  }
9506
  }
9507
  molbufindex++;
9507
  molbufindex++;
9508
  strcpy (molbuf[molbufindex - 1], rline);
9508
  strcpy (molbuf[molbufindex - 1], rline);
9509
  if (strpos2 (rline, "$$$$", 1) > 0)
9509
  if (strpos2 (rline, "$$$$", 1) > 0)
9510
  mol_in_queue = true;
9510
  mol_in_queue = istrue;
9511
  }
9511
  }
9512
  if (!P_eof (rfile))
9512
  if (!P_eof (rfile))
9513
  return;
9513
  return;
9514
  if (rfile != NULL)
9514
  if (rfile != NULL)
9515
  fclose (rfile);
9515
  fclose (rfile);
9516
  rfile = NULL;
9516
  rfile = NULL;
9517
  rfile_is_open = false;
9517
  rfile_is_open = isfalse;
9518
  mol_in_queue = false;
9518
  mol_in_queue = isfalse;
9519
  return;
9519
  return;
9520
  }
9520
  }
9521
  *rline = '\0';
9521
  *rline = '\0';
9522
  mol_in_queue = false;
9522
  mol_in_queue = isfalse;
9523
  while ((!P_eof (stdin)) && (strpos2 (rline, "$$$$", 1) == 0))
9523
  while ((!P_eof (stdin)) && (strpos2 (rline, "$$$$", 1) == 0))
9524
  {
9524
  {
9525
  gets (rline);
9525
  gets (rline);
9526
  if (molbufindex >= max_atoms + max_bonds + 64)
9526
  if (molbufindex >= max_atoms + max_bonds + 64)
9527
  {
9527
  {
Line 9530... Line 9530...
9530
  }
9530
  }
9531
  molbufindex++;
9531
  molbufindex++;
9532
  strcpy (molbuf[molbufindex - 1], rline);
9532
  strcpy (molbuf[molbufindex - 1], rline);
9533
  if (strpos2 (rline, "$$$$", 1) > 0)
9533
  if (strpos2 (rline, "$$$$", 1) > 0)
9534
  {
9534
  {
9535
  mol_in_queue = true;
9535
  mol_in_queue = istrue;
9536
  /* read from standard input
9536
  /* read from standard input
9537
  }
9537
  }
9538
  }
9538
  }
9539
  } */
9539
  } */
9540
#endif
9540
#endif
Line 9548... Line 9548...
9548
  molbufindex = 0;
9548
  molbufindex = 0;
9549
  if (!opt_stdin) {
9549
  if (!opt_stdin) {
9550
    if (!rfile_is_open) {
9550
    if (!rfile_is_open) {
9551
            rfile = fopen (molfilename, "r");
9551
            rfile = fopen (molfilename, "r");
9552
            rewind (rfile);
9552
            rewind (rfile);
9553
            rfile_is_open = true;
9553
            rfile_is_open = istrue;
9554
          }
9554
          }
9555
    /* p2c: checkmol.pas, line 7226: Warning:
9555
    /* p2c: checkmol.pas, line 7226: Warning:
9556
     * Don't know how to ASSIGN to a non-explicit file variable [207] */
9556
     * Don't know how to ASSIGN to a non-explicit file variable [207] */
9557
    *rline = '\0';
9557
    *rline = '\0';
9558
    mol_in_queue = false;
9558
    mol_in_queue = isfalse;
9559
    while ((fgets (rline, 256, rfile) != NULL) && (strstr (rline, "$$$$") == NULL)) {
9559
    while ((fgets (rline, 256, rfile) != NULL) && (strstr (rline, "$$$$") == NULL)) {
9560
            TEMP = strchr (rline, '\n');
9560
            TEMP = strchr (rline, '\n');
9561
            if (TEMP != NULL)
9561
            if (TEMP != NULL)
9562
              *TEMP = 0;
9562
              *TEMP = 0;
9563
            /*mol_in_queue := false; */
9563
            /*mol_in_queue := isfalse; */
9564
            if (molbufindex >= max_atoms + max_bonds + 64) {
9564
            if (molbufindex >= max_atoms + max_bonds + 64) {
9565
              printf ("Not enough memory for molfile! %d\n", molbufindex);
9565
              printf ("Not enough memory for molfile! %d\n", molbufindex);
9566
              if (rfile != NULL)
9566
              if (rfile != NULL)
9567
                      fclose (rfile);
9567
                      fclose (rfile);
9568
              rfile = NULL;
9568
              rfile = NULL;
9569
              exit (1);
9569
              exit (1);
9570
            }
9570
            }
9571
            //molbufindex++;
9571
            //molbufindex++;
9572
            strcpy (molbuf[molbufindex++], rline);
9572
            strcpy (molbuf[molbufindex++], rline);
9573
            if (strstr (rline, "$$$$") != NULL)
9573
            if (strstr (rline, "$$$$") != NULL)
9574
              mol_in_queue = true;
9574
              mol_in_queue = istrue;
9575
          }
9575
          }
9576
    if (!feof (rfile))
9576
    if (!feof (rfile))
9577
            return;
9577
            return;
9578
    if (rfile != NULL)
9578
    if (rfile != NULL)
9579
            fclose (rfile);
9579
            fclose (rfile);
9580
    rfile = NULL;
9580
    rfile = NULL;
9581
    rfile_is_open = false;
9581
    rfile_is_open = isfalse;
9582
    mol_in_queue = false;
9582
    mol_in_queue = isfalse;
9583
    return;
9583
    return;
9584
  }
9584
  }
9585
  *rline = '\0';
9585
  *rline = '\0';
9586
  mol_in_queue = false;
9586
  mol_in_queue = isfalse;
9587
  do {
9587
  do {
9588
    if(fgets (rline, 256, stdin)==NULL || feof (stdin))
9588
    if(fgets (rline, 256, stdin)==NULL || feof (stdin))
9589
            return;
9589
            return;
9590
    TEMP = strchr (rline, '\n');
9590
    TEMP = strchr (rline, '\n');
9591
    if (TEMP != NULL)
9591
    if (TEMP != NULL)
Line 9595... Line 9595...
9595
            exit (1);
9595
            exit (1);
9596
          }
9596
          }
9597
    //molbufindex++;
9597
    //molbufindex++;
9598
    strcpy (molbuf[molbufindex++], rline);
9598
    strcpy (molbuf[molbufindex++], rline);
9599
    if (strstr (rline, "$$$$") != NULL) {
9599
    if (strstr (rline, "$$$$") != NULL) {
9600
            mol_in_queue = true;
9600
            mol_in_queue = istrue;
9601
            /* read from standard input */
9601
            /* read from standard input */
9602
          }
9602
          }
9603
  }
9603
  }
9604
  while (strstr (rline, "$$$$") == NULL);
9604
  while (strstr (rline, "$$$$") == NULL);
9605
}
9605
}
Line 9747... Line 9747...
9747
        ndl_molstat.n_psla = molstat.n_psla;
9747
        ndl_molstat.n_psla = molstat.n_psla;
9748
        $ENDIF*/
9748
        $ENDIF*/
9749
  /* make sure some modes can be switched on only by the query file *M*/
9749
  /* make sure some modes can be switched on only by the query file *M*/
9750
  /* and not by subsequent haystack file(s) */
9750
  /* and not by subsequent haystack file(s) */
9751
  if (ez_flag)   /* new in v0.3f */
9751
  if (ez_flag)   /* new in v0.3f */
9752
   ez_search = true;
9752
   ez_search = istrue;
9753
  if (chir_flag)   /* new in v0.3f */
9753
  if (chir_flag)   /* new in v0.3f */
9754
    rs_search = true;
9754
    rs_search = istrue;
9755
}
9755
}
9756
#endif
9756
#endif
9757
 
9757
 
9758
static void copy_mol_to_needle ()
9758
static void copy_mol_to_needle ()
9759
{
9759
{
Line 9789... Line 9789...
9789
  memcpy (&ndl_molstat, &molstat, sizeof (molstat));
9789
  memcpy (&ndl_molstat, &molstat, sizeof (molstat));
9790
 
9790
 
9791
  // make sure some modes can be switched on only by the query file
9791
  // make sure some modes can be switched on only by the query file
9792
  // and not by subsequent haystack file(s)
9792
  // and not by subsequent haystack file(s)
9793
  if (ez_flag)                  // new in v0.3f
9793
  if (ez_flag)                  // new in v0.3f
9794
    ez_search = true;
9794
    ez_search = istrue;
9795
 
9795
 
9796
  if (chir_flag)                // new in v0.3f
9796
  if (chir_flag)                // new in v0.3f
9797
    rs_search = true;
9797
    rs_search = istrue;
9798
 
9798
 
9799
  ndl_querymol = found_querymol;        /* 0.3p */
9799
  ndl_querymol = found_querymol;        /* 0.3p */
9800
 
9800
 
9801
}
9801
}
9802
 
9802
 
Line 9834... Line 9834...
9834
  memcpy (&tmp_molstat, &molstat, sizeof (molstat));
9834
  memcpy (&tmp_molstat, &molstat, sizeof (molstat));
9835
 
9835
 
9836
  // make sure some modes can be switched on only by the query file
9836
  // make sure some modes can be switched on only by the query file
9837
  // and not by subsequent haystack file(s)
9837
  // and not by subsequent haystack file(s)
9838
  if (ez_flag)                  // new in v0.3f
9838
  if (ez_flag)                  // new in v0.3f
9839
    ez_search = true;
9839
    ez_search = istrue;
9840
 
9840
 
9841
  if (chir_flag)                // new in v0.3f
9841
  if (chir_flag)                // new in v0.3f
9842
    rs_search = true;
9842
    rs_search = istrue;
9843
 
9843
 
9844
  ndl_querymol = found_querymol;        /* 0.3p */
9844
  ndl_querymol = found_querymol;        /* 0.3p */
9845
 
9845
 
9846
}
9846
}
9847
 
9847
 
Line 9988... Line 9988...
9988
  tmp_molstat.n_psla = molstat.n_psla;
9988
  tmp_molstat.n_psla = molstat.n_psla;
9989
  $ENDIF*/
9989
  $ENDIF*/
9990
  /* make sure some modes can be switched on only by the query file */
9990
  /* make sure some modes can be switched on only by the query file */
9991
  /* and not by subsequent haystack file(s) */
9991
  /* and not by subsequent haystack file(s) */
9992
  if (ez_flag)   /* new in v0.3f */
9992
  if (ez_flag)   /* new in v0.3f */
9993
    ez_search = true;
9993
    ez_search = istrue;
9994
  if (chir_flag)   /* new in v0.3f */
9994
  if (chir_flag)   /* new in v0.3f */
9995
    rs_search = true;
9995
    rs_search = istrue;
9996
}
9996
}
9997
#endif
9997
#endif
9998
 
9998
 
9999
static void copy_tmp_to_mol ()
9999
static void copy_tmp_to_mol ()
10000
{
10000
{
Line 10030... Line 10030...
10030
  memcpy (&molstat, &tmp_molstat, sizeof (tmp_molstat));
10030
  memcpy (&molstat, &tmp_molstat, sizeof (tmp_molstat));
10031
 
10031
 
10032
  // make sure some modes can be switched on only by the query file
10032
  // make sure some modes can be switched on only by the query file
10033
  // and not by subsequent haystack file(s)
10033
  // and not by subsequent haystack file(s)
10034
  if (ez_flag)                  // new in v0.3f
10034
  if (ez_flag)                  // new in v0.3f
10035
    ez_search = true;
10035
    ez_search = istrue;
10036
 
10036
 
10037
  if (chir_flag)                // new in v0.3f
10037
  if (chir_flag)                // new in v0.3f
10038
    rs_search = true;
10038
    rs_search = istrue;
10039
 
10039
 
10040
}
10040
}
10041
 
10041
 
10042
#if 0
10042
#if 0
10043
static void copy_tmp_to_mol()
10043
static void copy_tmp_to_mol()
Line 10181... Line 10181...
10181
     molstat.n_psla = tmp_molstat.n_psla;
10181
     molstat.n_psla = tmp_molstat.n_psla;
10182
     $ENDIF */
10182
     $ENDIF */
10183
  /* make sure some modes can be switched on only by the query file */
10183
  /* make sure some modes can be switched on only by the query file */
10184
  /* and not by subsequent haystack file(s) */
10184
  /* and not by subsequent haystack file(s) */
10185
     if (ez_flag)
10185
     if (ez_flag)
10186
     ez_search = true;
10186
     ez_search = istrue;
10187
     if (chir_flag)
10187
     if (chir_flag)
10188
     rs_search = true;
10188
     rs_search = istrue;
10189
     }
10189
     }
10190
#endif
10190
#endif
10191
 
10191
 
10192
static void get_ringstat (int r_id)
10192
static void get_ringstat (int r_id)
10193
{
10193
{
Line 10204... Line 10204...
10204
  for (j = 0; j < ring_size; j++)       /* v0.3j */
10204
  for (j = 0; j < ring_size; j++)       /* v0.3j */
10205
    testring[j] = ring[r_id - 1][j];
10205
    testring[j] = ring[r_id - 1][j];
10206
    /* p2c: checkmol.pas, line 8238:
10206
    /* p2c: checkmol.pas, line 8238:
10207
    * Note: Turbo Pascal conditional compilation directive was ignored [218] */
10207
    * Note: Turbo Pascal conditional compilation directive was ignored [218] */
10208
#ifdef reduced_SAR
10208
#ifdef reduced_SAR
10209
  if (ring_size <= 2 || ringprop[r_id - 1].envelope != false)
10209
  if (ring_size <= 2 || ringprop[r_id - 1].envelope != isfalse)
10210
    /* v0.3n: ignore envelope rings */
10210
    /* v0.3n: ignore envelope rings */
10211
    return;
10211
    return;
10212
#else
10212
#else
10213
  if (ring_size <= 2)
10213
  if (ring_size <= 2)
10214
    return;
10214
    return;
Line 10324... Line 10324...
10324
            if (!strcmp (atype, "O3 "))
10324
            if (!strcmp (atype, "O3 "))
10325
              molstat.n_O3++;
10325
              molstat.n_O3++;
10326
            if (!strcmp (atype, "N1 "))
10326
            if (!strcmp (atype, "N1 "))
10327
              molstat.n_N1++;
10327
              molstat.n_N1++;
10328
            if (!strcmp (atype, "N2 ") || !strcmp (atype, "NAR") ||
10328
            if (!strcmp (atype, "N2 ") || !strcmp (atype, "NAR") ||
10329
                (!strcmp (atype, "NAM") && atom[i].arom == true))
10329
                (!strcmp (atype, "NAM") && atom[i].arom == istrue))
10330
              /* v0.3n */
10330
              /* v0.3n */
10331
              molstat.n_N2++;
10331
              molstat.n_N2++;
10332
            if (!strcmp (atype, "N3 ") || !strcmp (atype, "NPL") ||
10332
            if (!strcmp (atype, "N3 ") || !strcmp (atype, "NPL") ||
10333
                !strcmp (atype, "N3+") ||
10333
                !strcmp (atype, "N3+") ||
10334
                (!strcmp (atype, "NAM") && atom[i].arom == false))
10334
                (!strcmp (atype, "NAM") && atom[i].arom == isfalse))
10335
              /* v0.3n */
10335
              /* v0.3n */
10336
              molstat.n_N3++;
10336
              molstat.n_N3++;
10337
            if (!strcmp (elem, "A "))   /* query atom */
10337
            if (!strcmp (elem, "A "))   /* query atom */
10338
              molstat.n_QA++;
10338
              molstat.n_QA++;
10339
            if (!strcmp (elem, "Q "))   /* query atom */
10339
            if (!strcmp (elem, "Q "))   /* query atom */
Line 10514... Line 10514...
10514
  }                             /* rings */
10514
  }                             /* rings */
10515
  /* v0.3n */
10515
  /* v0.3n */
10516
  n_countablerings = 0;         /* v0.3n */
10516
  n_countablerings = 0;         /* v0.3n */
10517
  FORLIM = n_rings;
10517
  FORLIM = n_rings;
10518
  for (i = 1; i <= FORLIM; i++) {
10518
  for (i = 1; i <= FORLIM; i++) {
10519
    if (ringprop[i - 1].envelope == false)      /* v0.3n */
10519
    if (ringprop[i - 1].envelope == isfalse)    /* v0.3n */
10520
            n_countablerings++;
10520
            n_countablerings++;
10521
    if (is_arene (i) && ringprop[i - 1].envelope == false) {
10521
    if (is_arene (i) && ringprop[i - 1].envelope == isfalse) {
10522
      /* v0.3n: ignore envelope rings */
10522
      /* v0.3n: ignore envelope rings */
10523
            molstat.n_rAr++;
10523
            molstat.n_rAr++;
10524
            if ((ringprop[i - 1].size == 6) && (is_heterocycle (i) == false))
10524
            if ((ringprop[i - 1].size == 6) && (is_heterocycle (i) == isfalse))
10525
              /* v0.3l */
10525
              /* v0.3l */
10526
              molstat.n_rBz++;
10526
              molstat.n_rBz++;
10527
          }
10527
          }
10528
    get_ringstat (i);
10528
    get_ringstat (i);
10529
    if (ringprop[i - 1].arom == true && ringprop[i - 1].envelope == false)
10529
    if (ringprop[i - 1].arom == istrue && ringprop[i - 1].envelope == isfalse)
10530
            /* new in v0.3n; replaces assignment below */
10530
            /* new in v0.3n; replaces assignment below */
10531
            n_b2formal++;
10531
            n_b2formal++;
10532
  }
10532
  }
10533
  /*n_b2formal := n_rar;  (* new in v0.2e; adds 1 formal double bond for each aromatic ring */
10533
  /*n_b2formal := n_rar;  (* new in v0.2e; adds 1 formal double bond for each aromatic ring */
10534
  /* in order to allow an isolated double bond in the needle */
10534
  /* in order to allow an isolated double bond in the needle */
Line 10840... Line 10840...
10840
  /* matchpath, regardless where the recursive search starts; */
10840
  /* matchpath, regardless where the recursive search starts; */
10841
  /* refined in v0.3f: exclude only alkene-C as reference atoms */
10841
  /* refined in v0.3f: exclude only alkene-C as reference atoms */
10842
  /* added in v0.3o: needle atom must be "tagged" in order to be */
10842
  /* added in v0.3o: needle atom must be "tagged" in order to be */
10843
  /* selected (prevents unconnected fragments from being overlooked) */
10843
  /* selected (prevents unconnected fragments from being overlooked) */
10844
  if (ndl_n_atoms == 0)
10844
  if (ndl_n_atoms == 0)
10845
    return false;
10845
    return isfalse;
10846
  if (ez_search && ndl_n_heavyatoms > 2) {
10846
  if (ez_search && ndl_n_heavyatoms > 2) {
10847
    FORLIM = ndl_n_atoms;
10847
    FORLIM = ndl_n_atoms;
10848
    for (i = 1; i <= FORLIM; i++) {                     /* ignore sp2-carbons if not aromatic */
10848
    for (i = 1; i <= FORLIM; i++) {                     /* ignore sp2-carbons if not aromatic */
10849
           /*if ((ndl_atom^[i].atype <> 'C2 ') or (ndl_atom^[i].arom = true)) then */
10849
           /*if ((ndl_atom^[i].atype <> 'C2 ') or (ndl_atom^[i].arom = istrue)) then */
10850
            if (ndl_alkene_C (i) == false && ndl_atom[i - 1].tag) {                     /* v0.3o */
10850
            if (ndl_alkene_C (i) == isfalse && ndl_atom[i - 1].tag) {                   /* v0.3o */
10851
              n_nb = ndl_atom[i - 1].neighbor_count;
10851
              n_nb = ndl_atom[i - 1].neighbor_count;
10852
              n_hc = ndl_hetatom_count (i);
10852
              n_hc = ndl_hetatom_count (i);
10853
              if (n_nb * 11 + n_hc * 7 > score && ndl_atom[i - 1].heavy) {
10853
              if (n_nb * 11 + n_hc * 7 > score && ndl_atom[i - 1].heavy) {
10854
                /* v0.3j */
10854
                /* v0.3j */
10855
                index = i;
10855
                index = i;
Line 10859... Line 10859...
10859
          }
10859
          }
10860
  }
10860
  }
10861
  /* it is possible that no suitable reference atom has been found here */
10861
  /* it is possible that no suitable reference atom has been found here */
10862
  /* (e.g., with "pure" polyenes), so we need a fallback option anyway */
10862
  /* (e.g., with "pure" polyenes), so we need a fallback option anyway */
10863
  if (index == 0) {
10863
  if (index == 0) {
10864
    ez_search = false;  /* just in case it was true */
10864
    ez_search = isfalse;        /* just in case it was istrue */
10865
    opt_geom = false;           /* just in case it was true */
10865
    opt_geom = isfalse;         /* just in case it was istrue */
10866
    FORLIM = ndl_n_atoms;
10866
    FORLIM = ndl_n_atoms;
10867
    for (i = 1; i <= FORLIM; i++) {
10867
    for (i = 1; i <= FORLIM; i++) {
10868
            n_nb = ndl_atom[i - 1].neighbor_count;
10868
            n_nb = ndl_atom[i - 1].neighbor_count;
10869
            n_hc = ndl_hetatom_count (i);
10869
            n_hc = ndl_hetatom_count (i);
10870
            if (n_nb * 11 + n_hc * 7 > score && ndl_atom[i - 1].heavy &&
10870
            if (n_nb * 11 + n_hc * 7 > score && ndl_atom[i - 1].heavy &&
Line 10907... Line 10907...
10907
  if (cv == NULL)
10907
  if (cv == NULL)
10908
    return 0;
10908
    return 0;
10909
  memset (cvlist, 0, sizeof (int) * max_atoms);
10909
  memset (cvlist, 0, sizeof (int) * max_atoms);
10910
  FORLIM = ndl_n_atoms;
10910
  FORLIM = ndl_n_atoms;
10911
  for (i = 0; i < FORLIM; i++) {
10911
  for (i = 0; i < FORLIM; i++) {
10912
    if (ndl_atom[i].heavy == true) {
10912
    if (ndl_atom[i].heavy == istrue) {
10913
            cvdef = cv[i].def;
10913
            cvdef = cv[i].def;
10914
            isnew = true;
10914
            isnew = istrue;
10915
            if (entries > 0) {
10915
            if (entries > 0) {
10916
              for (j = 0; j < entries; j++) {
10916
              for (j = 0; j < entries; j++) {
10917
                      if (cvlist[j] == cvdef)
10917
                      if (cvlist[j] == cvdef)
10918
                        isnew = false;
10918
                        isnew = isfalse;
10919
                    }
10919
                    }
10920
            }
10920
            }
10921
            if (isnew) {
10921
            if (isnew) {
10922
                entries++;
10922
                entries++;
10923
                cvlist[entries - 1] = cvdef;
10923
                cvlist[entries - 1] = cvdef;
Line 10934... Line 10934...
10934
  int i, j;
10934
  int i, j;
10935
  neighbor_rec nb;
10935
  neighbor_rec nb;
10936
  int nnb, nsum, n_cv, FORLIM;
10936
  int nnb, nsum, n_cv, FORLIM;
10937
 
10937
 
10938
  if (cv == NULL || ndl_n_atoms == 0)
10938
  if (cv == NULL || ndl_n_atoms == 0)
10939
    return false;
10939
    return isfalse;
10940
  FORLIM = ndl_n_atoms;
10940
  FORLIM = ndl_n_atoms;
10941
  /* update the connection values (Morgan algorithm) */
10941
  /* update the connection values (Morgan algorithm) */
10942
 
10942
 
10943
  memset (nb, 0, sizeof (neighbor_rec));
10943
  memset (nb, 0, sizeof (neighbor_rec));
10944
 
10944
 
10945
  for (i = 1; i <= FORLIM; i++) {
10945
  for (i = 1; i <= FORLIM; i++) {
10946
    if (ndl_atom[i - 1].heavy == true) {
10946
    if (ndl_atom[i - 1].heavy == istrue) {
10947
            get_ndl_neighbors (nb, i);
10947
            get_ndl_neighbors (nb, i);
10948
            nnb = ndl_atom[i - 1].neighbor_count;
10948
            nnb = ndl_atom[i - 1].neighbor_count;
10949
            nsum = 0;
10949
            nsum = 0;
10950
            if (nnb > 0) {
10950
            if (nnb > 0) {
10951
              for (j = 0; j < nnb; j++) {
10951
              for (j = 0; j < nnb; j++) {
10952
                if (ndl_atom[nb[j] - 1].heavy == true)
10952
                if (ndl_atom[nb[j] - 1].heavy == istrue)
10953
                  nsum += cv[nb[j] - 1].def;
10953
                  nsum += cv[nb[j] - 1].def;
10954
              }
10954
              }
10955
            }
10955
            }
10956
            cv[i - 1].tmp = nsum;
10956
            cv[i - 1].tmp = nsum;
10957
          }
10957
          }
Line 10970... Line 10970...
10970
  /* new in v0.3j, modified in v0.3m */
10970
  /* new in v0.3j, modified in v0.3m */
10971
  int Result, i;
10971
  int Result, i;
10972
  int res = 1, it = 0;
10972
  int res = 1, it = 0;
10973
  int n_cv;
10973
  int n_cv;
10974
  int n_cv_prev = 0;
10974
  int n_cv_prev = 0;
10975
  boolean finished = false;
10975
  boolean finished = isfalse;
10976
  int cvmax = 0;
10976
  int cvmax = 0;
10977
  int FORLIM;
10977
  int FORLIM;
10978
 
10978
 
10979
  if (ndl_n_atoms == 0)
10979
  if (ndl_n_atoms == 0)
10980
    return 0;
10980
    return 0;
Line 10992... Line 10992...
10992
  cv_init ();
10992
  cv_init ();
10993
  do {
10993
  do {
10994
    it++;                       /* iteration counter (a safeguard against infinite loops) */
10994
    it++;                       /* iteration counter (a safeguard against infinite loops) */
10995
    n_cv = cv_iterate (n_cv_prev);
10995
    n_cv = cv_iterate (n_cv_prev);
10996
    if (n_cv <= n_cv_prev)
10996
    if (n_cv <= n_cv_prev)
10997
            finished = true;
10997
            finished = istrue;
10998
    n_cv_prev = n_cv;
10998
    n_cv_prev = n_cv;
10999
  }
10999
  }
11000
  while (!(finished || it > 10000));
11000
  while (!(finished || it > 10000));
11001
  FORLIM = ndl_n_atoms;
11001
  FORLIM = ndl_n_atoms;
11002
  /* now that we have canonical connection values (Morgan algorithm), */
11002
  /* now that we have canonical connection values (Morgan algorithm), */
11003
  /* pick the atom with the highest value */
11003
  /* pick the atom with the highest value */
11004
  /* added in v0.3o: atom must be "tagged" */
11004
  /* added in v0.3o: atom must be "tagged" */
11005
  for (i = 1; i <= FORLIM; i++) {
11005
  for (i = 1; i <= FORLIM; i++) {
11006
      /*writeln('cv for atom ',i,': ',cv^[i].def); */
11006
      /*writeln('cv for atom ',i,': ',cv^[i].def); */
11007
    if (((cv[i - 1].def > cvmax) && (ndl_alkene_C (i) == false || ez_search == false))
11007
    if (((cv[i - 1].def > cvmax) && (ndl_alkene_C (i) == isfalse || ez_search == isfalse))
11008
              && ndl_atom[i - 1].tag) {                 /* v0.3o */
11008
              && ndl_atom[i - 1].tag) {                 /* v0.3o */
11009
            cvmax = cv[i - 1].def;
11009
            cvmax = cv[i - 1].def;
11010
            res = i;
11010
            res = i;
11011
          }
11011
          }
11012
  }
11012
  }
Line 11028... Line 11028...
11028
  str2 ndl_el;
11028
  str2 ndl_el;
11029
  str3 ndl_atype;
11029
  str3 ndl_atype;
11030
  str2 hst_el;
11030
  str2 hst_el;
11031
  str3 hst_atype;
11031
  str3 hst_atype;
11032
  int ndl_nbc, hst_nbc, ndl_Hexp, hst_Htot;
11032
  int ndl_nbc, hst_nbc, ndl_Hexp, hst_Htot;
11033
  boolean res = false;
11033
  boolean res = isfalse;
11034
 
11034
 
11035
  strcpy (ndl_el, ndl_atom[ndl_a - 1].element);
11035
  strcpy (ndl_el, ndl_atom[ndl_a - 1].element);
11036
  strcpy (ndl_atype, ndl_atom[ndl_a - 1].atype);
11036
  strcpy (ndl_atype, ndl_atom[ndl_a - 1].atype);
11037
  ndl_nbc = ndl_atom[ndl_a - 1].neighbor_count;
11037
  ndl_nbc = ndl_atom[ndl_a - 1].neighbor_count;
11038
  ndl_Hexp = ndl_atom[ndl_a - 1].Hexp;
11038
  ndl_Hexp = ndl_atom[ndl_a - 1].Hexp;
Line 11041... Line 11041...
11041
  hst_nbc = atom[hst_a - 1].neighbor_count;
11041
  hst_nbc = atom[hst_a - 1].neighbor_count;
11042
  hst_Htot = atom[hst_a - 1].Htot;
11042
  hst_Htot = atom[hst_a - 1].Htot;
11043
  /* v0.3o: formal charges must be the same */
11043
  /* v0.3o: formal charges must be the same */
11044
 
11044
 
11045
  if (ndl_atom[ndl_a - 1].formal_charge != atom[hst_a - 1].formal_charge)
11045
  if (ndl_atom[ndl_a - 1].formal_charge != atom[hst_a - 1].formal_charge)
11046
    return false;
11046
    return isfalse;
11047
 
11047
 
11048
  /* v0.3x: isotope nucleon numbers must be the same */
11048
  /* v0.3x: isotope nucleon numbers must be the same */
11049
 
11049
 
11050
  if (ndl_atom[ndl_a - 1].nucleon_number != atom[hst_a - 1].nucleon_number)
11050
  if (ndl_atom[ndl_a - 1].nucleon_number != atom[hst_a - 1].nucleon_number)
11051
    return false;
11051
    return isfalse;
11052
 
11052
 
11053
  /* v0.3x: radicals must be the same */
11053
  /* v0.3x: radicals must be the same */
11054
 
11054
 
11055
  if (ndl_atom[ndl_a - 1].radical_type != atom[hst_a - 1].radical_type)
11055
  if (ndl_atom[ndl_a - 1].radical_type != atom[hst_a - 1].radical_type)
11056
    return false;
11056
    return isfalse;
11057
 
11057
 
11058
  if (!strcmp (ndl_atype, hst_atype))
11058
  if (!strcmp (ndl_atype, hst_atype))
11059
    res = true;
11059
    res = istrue;
11060
  else {
11060
  else {
11061
    if (!strcmp (ndl_el, hst_el) && ndl_atom[ndl_a - 1].arom && atom[hst_a - 1].arom)
11061
    if (!strcmp (ndl_el, hst_el) && ndl_atom[ndl_a - 1].arom && atom[hst_a - 1].arom)
11062
            res = true;
11062
            res = istrue;
11063
    if (ndl_querymol && (ndl_atom[ndl_a - 1].q_arom && atom[hst_a - 1].arom))
11063
    if (ndl_querymol && (ndl_atom[ndl_a - 1].q_arom && atom[hst_a - 1].arom))
11064
            res = true;         /* 0.3 p */
11064
            res = istrue;               /* 0.3 p */
11065
  }
11065
  }
11066
  if (!strcmp (ndl_el, "A ") && atom[hst_a - 1].heavy)
11066
  if (!strcmp (ndl_el, "A ") && atom[hst_a - 1].heavy)
11067
    res = true;
11067
    res = istrue;
11068
  if (!strcmp (ndl_el, "Q ")) {
11068
  if (!strcmp (ndl_el, "Q ")) {
11069
    if (atom[hst_a - 1].heavy && strcmp (hst_el, "C "))
11069
    if (atom[hst_a - 1].heavy && strcmp (hst_el, "C "))
11070
            res = true;
11070
            res = istrue;
11071
  }
11071
  }
11072
  if (!strcmp (ndl_el, "X ")) {
11072
  if (!strcmp (ndl_el, "X ")) {
11073
    if (!strcmp (hst_el, "F ") || !strcmp (hst_el, "CL") ||
11073
    if (!strcmp (hst_el, "F ") || !strcmp (hst_el, "CL") ||
11074
            !strcmp (hst_el, "BR") || !strcmp (hst_el, "I ")
11074
            !strcmp (hst_el, "BR") || !strcmp (hst_el, "I ")
11075
            || !strcmp (hst_el, "AT"))
11075
            || !strcmp (hst_el, "AT"))
11076
          res = true;
11076
          res = istrue;
11077
  }
11077
  }
11078
  /* if needle atom has more substituents than haystack atom ==> no match */
11078
  /* if needle atom has more substituents than haystack atom ==> no match */
11079
  if (ndl_nbc > hst_nbc)
11079
  if (ndl_nbc > hst_nbc)
11080
    res = false;
11080
    res = isfalse;
11081
  /* check for explicit hydrogens */
11081
  /* check for explicit hydrogens */
11082
  if (ndl_Hexp > hst_Htot)
11082
  if (ndl_Hexp > hst_Htot)
11083
    res = false;
11083
    res = isfalse;
11084
    /* p2c: checkmol.pas, line 8859:
11084
    /* p2c: checkmol.pas, line 8859:
11085
    * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11085
    * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11086
    /*$IFDEF debug */
11086
    /*$IFDEF debug */
11087
    /* if res then debugoutput('atom types OK ('+inttostr(ndl_a)+'/'+inttostr(hst_a)+')')
11087
    /* if res then debugoutput('atom types OK ('+inttostr(ndl_a)+'/'+inttostr(hst_a)+')')
11088
     else debugoutput('atom types not OK ('+inttostr(ndl_a)+':'+ndl_atype+'/'+inttostr(hst_a)+':'+hst_atype+')'); */
11088
     else debugoutput('atom types not OK ('+inttostr(ndl_a)+':'+ndl_atype+'/'+inttostr(hst_a)+':'+hst_atype+')'); */
11089
    /*$ENDIF */
11089
    /*$ENDIF */
11090
    /* new in v0.3m: in "fingerprint mode", also query atom symbols must match */
11090
    /* new in v0.3m: in "fingerprint mode", also query atom symbols must match */
11091
  if (opt_fp) {
11091
  if (opt_fp) {
11092
    if (strcmp (ndl_el, hst_el))
11092
    if (strcmp (ndl_el, hst_el))
11093
            res = false;
11093
            res = isfalse;
11094
  }
11094
  }
11095
  return res;
11095
  return res;
11096
}
11096
}
11097
 
11097
 
11098
static boolean atomtypes_OK (int ndl_a, int hst_a)
11098
static boolean atomtypes_OK (int ndl_a, int hst_a)
11099
{
11099
{
11100
  str2 ndl_el, hst_el;
11100
  str2 ndl_el, hst_el;
11101
  int ndl_nbc, hst_nbc, ndl_Hexp, hst_Htot;
11101
  int ndl_nbc, hst_nbc, ndl_Hexp, hst_Htot;
11102
  boolean res = false;
11102
  boolean res = isfalse;
11103
 
11103
 
11104
  if (ndl_a < 1 || ndl_a > ndl_n_atoms || hst_a < 1 || hst_a > n_atoms)
11104
  if (ndl_a < 1 || ndl_a > ndl_n_atoms || hst_a < 1 || hst_a > n_atoms)
11105
    return false;
11105
    return isfalse;
11106
  /* check for opposite charges;  v0.3l, refined in v0.3o, 0.3x */
11106
  /* check for opposite charges;  v0.3l, refined in v0.3o, 0.3x */
11107
  /* except in strict mode, matching pairs of charged+uncharged atoms  */
11107
  /* except in strict mode, matching pairs of charged+uncharged atoms  */
11108
  /* are tolerated (this is a feature, not a bug) */
11108
  /* are tolerated (this is a feature, not a bug) */
11109
  if (opt_chg) {
11109
  if (opt_chg) {
11110
    if (ndl_atom[ndl_a - 1].formal_charge != atom[hst_a - 1].formal_charge)
11110
    if (ndl_atom[ndl_a - 1].formal_charge != atom[hst_a - 1].formal_charge)
11111
        return false;
11111
        return isfalse;
11112
  }
11112
  }
11113
  //  else
11113
  //  else
11114
  //    {
11114
  //    {
11115
  //      if (ndl_atom[ndl_a - 1].formal_charge != 0 &&
11115
  //      if (ndl_atom[ndl_a - 1].formal_charge != 0 &&
11116
  //        atom[hst_a - 1].formal_charge != 0 &&
11116
  //        atom[hst_a - 1].formal_charge != 0 &&
11117
  //        ndl_atom[ndl_a - 1].formal_charge != atom[hst_a - 1].formal_charge)
11117
  //        ndl_atom[ndl_a - 1].formal_charge != atom[hst_a - 1].formal_charge)
11118
  //      return false;
11118
  //      return isfalse;
11119
  //    }
11119
  //    }
11120
  //
11120
  //
11121
  //  /* v0.3x: isotopes must be the same */
11121
  //  /* v0.3x: isotopes must be the same */
11122
  if (opt_iso) {
11122
  if (opt_iso) {
11123
    if (ndl_atom[ndl_a - 1].nucleon_number != atom[hst_a - 1].nucleon_number)
11123
    if (ndl_atom[ndl_a - 1].nucleon_number != atom[hst_a - 1].nucleon_number)
11124
            return false;
11124
            return isfalse;
11125
  }
11125
  }
11126
  //  else
11126
  //  else
11127
  //    {
11127
  //    {
11128
  //      if (ndl_atom[ndl_a - 1].nucleon_number != 0 &&
11128
  //      if (ndl_atom[ndl_a - 1].nucleon_number != 0 &&
11129
  //        atom[hst_a - 1].nucleon_number != 0 &&
11129
  //        atom[hst_a - 1].nucleon_number != 0 &&
11130
  //        ndl_atom[ndl_a - 1].nucleon_number !=
11130
  //        ndl_atom[ndl_a - 1].nucleon_number !=
11131
  //        atom[hst_a - 1].nucleon_number)
11131
  //        atom[hst_a - 1].nucleon_number)
11132
  //      return false;
11132
  //      return isfalse;
11133
  //    }
11133
  //    }
11134
  //
11134
  //
11135
  //  /* v0.3x: radicals must be the same */
11135
  //  /* v0.3x: radicals must be the same */
11136
  if (opt_rad) {
11136
  if (opt_rad) {
11137
    if (ndl_atom[ndl_a - 1].radical_type != atom[hst_a - 1].radical_type)
11137
    if (ndl_atom[ndl_a - 1].radical_type != atom[hst_a - 1].radical_type)
11138
            return false;
11138
            return isfalse;
11139
  }
11139
  }
11140
  //  else
11140
  //  else
11141
  //    {
11141
  //    {
11142
  //      if (ndl_atom[ndl_a - 1].radical_type != 0 &&
11142
  //      if (ndl_atom[ndl_a - 1].radical_type != 0 &&
11143
  //        atom[hst_a - 1].radical_type != 0 &&
11143
  //        atom[hst_a - 1].radical_type != 0 &&
11144
  //        ndl_atom[ndl_a - 1].radical_type != atom[hst_a - 1].radical_type)
11144
  //        ndl_atom[ndl_a - 1].radical_type != atom[hst_a - 1].radical_type)
11145
  //      return false;
11145
  //      return isfalse;
11146
  //    }
11146
  //    }
11147
 
11147
 
11148
  /* in exact mode, check if (disconnected) fragment is already tagged; v0.3o */
11148
  /* in exact mode, check if (disconnected) fragment is already tagged; v0.3o */
11149
  if (opt_exact && atom[hst_a - 1].tag == true) {
11149
  if (opt_exact && atom[hst_a - 1].tag == istrue) {
11150
    /* p2c: checkmol.pas, line 8899:
11150
    /* p2c: checkmol.pas, line 8899:
11151
  * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11151
  * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11152
      /*$IFDEF debug */
11152
      /*$IFDEF debug */
11153
      /* debugoutput('fragmnet already tagged at '+inttostr(hst_a)); */
11153
      /* debugoutput('fragmnet already tagged at '+inttostr(hst_a)); */
11154
      /*$ENDIF */
11154
      /*$ENDIF */
11155
      return false;
11155
      return isfalse;
11156
  }
11156
  }
11157
  if (opt_strict)               /* new in v0.2f */
11157
  if (opt_strict)               /* new in v0.2f */
11158
    return (atomtypes_OK_strict (ndl_a, hst_a));
11158
    return (atomtypes_OK_strict (ndl_a, hst_a));
11159
  strcpy (ndl_el, ndl_atom[ndl_a - 1].element);
11159
  strcpy (ndl_el, ndl_atom[ndl_a - 1].element);
11160
  ndl_nbc = ndl_atom[ndl_a - 1].neighbor_count;
11160
  ndl_nbc = ndl_atom[ndl_a - 1].neighbor_count;
11161
  ndl_Hexp = ndl_atom[ndl_a - 1].Hexp;
11161
  ndl_Hexp = ndl_atom[ndl_a - 1].Hexp;
11162
  strcpy (hst_el, atom[hst_a - 1].element);
11162
  strcpy (hst_el, atom[hst_a - 1].element);
11163
  hst_nbc = atom[hst_a - 1].neighbor_count;
11163
  hst_nbc = atom[hst_a - 1].neighbor_count;
11164
  hst_Htot = atom[hst_a - 1].Htot;
11164
  hst_Htot = atom[hst_a - 1].Htot;
11165
  if (!strcmp (ndl_el, hst_el)) /* very simplified... */
11165
  if (!strcmp (ndl_el, hst_el)) /* very simplified... */
11166
    res = true;
11166
    res = istrue;
11167
  if (!strcmp (ndl_el, "A ") && atom[hst_a - 1].heavy)
11167
  if (!strcmp (ndl_el, "A ") && atom[hst_a - 1].heavy)
11168
    res = true;
11168
    res = istrue;
11169
  if (!strcmp (ndl_el, "Q ")) {
11169
  if (!strcmp (ndl_el, "Q ")) {
11170
    if (atom[hst_a - 1].heavy && strcmp (hst_el, "C "))
11170
    if (atom[hst_a - 1].heavy && strcmp (hst_el, "C "))
11171
            res = true;
11171
            res = istrue;
11172
  }
11172
  }
11173
  if (!strcmp (ndl_el, "X ")) {
11173
  if (!strcmp (ndl_el, "X ")) {
11174
    if (!strcmp (hst_el, "F ") || !strcmp (hst_el, "CL") ||
11174
    if (!strcmp (hst_el, "F ") || !strcmp (hst_el, "CL") ||
11175
              !strcmp (hst_el, "BR") || !strcmp (hst_el, "I ")
11175
              !strcmp (hst_el, "BR") || !strcmp (hst_el, "I ")
11176
              || !strcmp (hst_el, "AT"))
11176
              || !strcmp (hst_el, "AT"))
11177
            res = true;
11177
            res = istrue;
11178
  }
11178
  }
11179
  /* v0.3o: in exact mode, check for identical neighbor_count */
11179
  /* v0.3o: in exact mode, check for identical neighbor_count */
11180
  if (opt_exact) {
11180
  if (opt_exact) {
11181
    if (ndl_nbc != hst_nbc) {
11181
    if (ndl_nbc != hst_nbc) {
11182
          res = false;
11182
          res = isfalse;
11183
    /* p2c: checkmol.pas, line 8934:
11183
    /* p2c: checkmol.pas, line 8934:
11184
     * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11184
     * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11185
          /*$IFDEF debug */
11185
          /*$IFDEF debug */
11186
          //debugoutput
11186
          //debugoutput
11187
          //  ("exact match failed: different number of neighbor atoms");
11187
          //  ("exact match failed: different number of neighbor atoms");
11188
          /*$ENDIF */
11188
          /*$ENDIF */
11189
          }
11189
          }
11190
  }
11190
  }
11191
  /* if needle atom has more substituents than haystack atom ==> no match */
11191
  /* if needle atom has more substituents than haystack atom ==> no match */
11192
  if (ndl_nbc > hst_nbc)
11192
  if (ndl_nbc > hst_nbc)
11193
    res = false;
11193
    res = isfalse;
11194
  /* check for explicit hydrogens */
11194
  /* check for explicit hydrogens */
11195
  if (ndl_Hexp > hst_Htot)
11195
  if (ndl_Hexp > hst_Htot)
11196
    res = false;
11196
    res = isfalse;
11197
  /* p2c: checkmol.pas, line 8943:
11197
  /* p2c: checkmol.pas, line 8943:
11198
  * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11198
  * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11199
  /*$IFDEF debug */
11199
  /*$IFDEF debug */
11200
  /* if res then debugoutput('atom types OK ('+inttostr(ndl_a)+'/'+inttostr(hst_a)+')')
11200
  /* if res then debugoutput('atom types OK ('+inttostr(ndl_a)+'/'+inttostr(hst_a)+')')
11201
     else debugoutput('atom types not OK ('+inttostr(ndl_a)+'/'+inttostr(hst_a)+')'); */
11201
     else debugoutput('atom types not OK ('+inttostr(ndl_a)+'/'+inttostr(hst_a)+')'); */
Line 11208... Line 11208...
11208
  boolean ndl_arom, hst_arom;
11208
  boolean ndl_arom, hst_arom;
11209
  char ndl_btype, hst_btype;
11209
  char ndl_btype, hst_btype;
11210
  int ndl_rc;                   /* new in v0.3d */
11210
  int ndl_rc;                   /* new in v0.3d */
11211
  int hst_rc;                   /* new in v0.3d */
11211
  int hst_rc;                   /* new in v0.3d */
11212
  int ndl_btopo;                /* new in v0.3d */
11212
  int ndl_btopo;                /* new in v0.3d */
11213
  boolean res = false;
11213
  boolean res = isfalse;
11214
  /* p2c: checkmol.pas, line 8960:
11214
  /* p2c: checkmol.pas, line 8960:
11215
  * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11215
  * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11216
  /*$IFDEF debug */
11216
  /*$IFDEF debug */
11217
  /*char na[256]; char ha[256];*/
11217
  /*char na[256]; char ha[256];*/
11218
  char tstr[256];
11218
  char tstr[256];
Line 11240... Line 11240...
11240
   if (hst_arom)
11240
   if (hst_arom)
11241
     strcpy (ha, "(ar)");
11241
     strcpy (ha, "(ar)");
11242
   else
11242
   else
11243
     *ha = '\0';*/
11243
     *ha = '\0';*/
11244
   /*$ENDIF */
11244
   /*$ENDIF */
11245
  if (ndl_arom == true && hst_arom == true)
11245
  if (ndl_arom == istrue && hst_arom == istrue)
11246
    res = true;
11246
    res = istrue;
11247
  if (ndl_arom == false && hst_arom == false) {
11247
  if (ndl_arom == isfalse && hst_arom == isfalse) {
11248
    if (ndl_btype == hst_btype)
11248
    if (ndl_btype == hst_btype)
11249
            res = true;
11249
            res = istrue;
11250
    if (ndl_btype == 'l' && (hst_btype == 'S' || hst_btype == 'D'))
11250
    if (ndl_btype == 'l' && (hst_btype == 'S' || hst_btype == 'D'))
11251
            res = true;
11251
            res = istrue;
11252
    if (ndl_btype == 's' && hst_btype == 'S')
11252
    if (ndl_btype == 's' && hst_btype == 'S')
11253
            res = true;
11253
            res = istrue;
11254
    if (ndl_btype == 'd' && hst_btype == 'D')
11254
    if (ndl_btype == 'd' && hst_btype == 'D')
11255
            res = true;
11255
            res = istrue;
11256
  }
11256
  }
11257
  /* a little exception: */
11257
  /* a little exception: */
11258
  if (ndl_arom == false && hst_arom == true) {
11258
  if (ndl_arom == isfalse && hst_arom == istrue) {
11259
    if (ndl_btype == 'A')
11259
    if (ndl_btype == 'A')
11260
            res = true;
11260
            res = istrue;
11261
    if (ndl_btype == 's' || ndl_btype == 'd')
11261
    if (ndl_btype == 's' || ndl_btype == 'd')
11262
            res = true;
11262
            res = istrue;
11263
    if (ndl_bond[ndl_b - 1].q_arom)
11263
    if (ndl_bond[ndl_b - 1].q_arom)
11264
            res = true;         /* 0.3p */
11264
            res = istrue;               /* 0.3p */
11265
  }
11265
  }
11266
  if (ndl_btype == 'a')
11266
  if (ndl_btype == 'a')
11267
    res = true;
11267
    res = istrue;
11268
  /* new in v0.3d: strict comparison of topology (and even ring_count!) */
11268
  /* new in v0.3d: strict comparison of topology (and even ring_count!) */
11269
  if (ndl_btopo < btopo_always_any || ndl_btopo == btopo_exact_rc) {
11269
  if (ndl_btopo < btopo_always_any || ndl_btopo == btopo_exact_rc) {
11270
    if (ndl_rc != hst_rc) {
11270
    if (ndl_rc != hst_rc) {
11271
            res = false;                /* this excludes further ring annulations as well as */
11271
            res = isfalse;              /* this excludes further ring annulations as well as */
11272
      /* p2c: checkmol.pas, line 9001:
11272
      /* p2c: checkmol.pas, line 9001:
11273
      * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11273
      * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11274
            /*$IFDEF debug */
11274
            /*$IFDEF debug */
11275
            /* open-chains query structures to be found in rings */
11275
            /* open-chains query structures to be found in rings */
11276
            /*
11276
            /*
Line 11278... Line 11278...
11278
            /*$ENDIF */
11278
            /*$ENDIF */
11279
          }
11279
          }
11280
  }
11280
  }
11281
  else {
11281
  else {
11282
    if (ndl_btopo == btopo_excess_rc && hst_rc <= ndl_rc) {
11282
    if (ndl_btopo == btopo_excess_rc && hst_rc <= ndl_rc) {
11283
            res = false;
11283
            res = isfalse;
11284
    /* p2c: checkmol.pas, line 9010:
11284
    /* p2c: checkmol.pas, line 9010:
11285
    * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11285
    * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11286
          /*$IFDEF debug */
11286
          /*$IFDEF debug */
11287
          /* tstr := ' ringcount mismatch ('+inttostr(ndl_rc)+'/'+inttostr(hst_rc)+')'; */
11287
          /* tstr := ' ringcount mismatch ('+inttostr(ndl_rc)+'/'+inttostr(hst_rc)+')'; */
11288
          /*$ENDIF */
11288
          /*$ENDIF */
Line 11302... Line 11302...
11302
  boolean ndl_arom, hst_arom;
11302
  boolean ndl_arom, hst_arom;
11303
  char ndl_btype, hst_btype;
11303
  char ndl_btype, hst_btype;
11304
  int ndl_rc;                   /* new in v0.3d */
11304
  int ndl_rc;                   /* new in v0.3d */
11305
  int hst_rc;                   /* new in v0.3d */
11305
  int hst_rc;                   /* new in v0.3d */
11306
  int ndl_btopo;                /* new in v0.3d */
11306
  int ndl_btopo;                /* new in v0.3d */
11307
  boolean res = false;
11307
  boolean res = isfalse;
11308
  /* p2c: checkmol.pas, line 9032:
11308
  /* p2c: checkmol.pas, line 9032:
11309
  * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11309
  * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11310
  /*$IFDEF debug */
11310
  /*$IFDEF debug */
11311
  /*char na[256], ha[256];*/
11311
  /*char na[256], ha[256];*/
11312
  char tstr[256];
11312
  char tstr[256];
11313
  /*$ENDIF */
11313
  /*$ENDIF */
11314
  int a1, a2;
11314
  int a1, a2;
11315
  str2 a1_el, a2_el;
11315
  str2 a1_el, a2_el;
11316
 
11316
 
11317
  if (ndl_b < 1 || ndl_b > ndl_n_bonds || hst_b < 1 || hst_b > n_bonds)
11317
  if (ndl_b < 1 || ndl_b > ndl_n_bonds || hst_b < 1 || hst_b > n_bonds)
11318
    return false;
11318
    return isfalse;
11319
  if (opt_strict)               /* new in v0.2f */
11319
  if (opt_strict)               /* new in v0.2f */
11320
    return (bondtypes_OK_strict (ndl_b, hst_b));
11320
    return (bondtypes_OK_strict (ndl_b, hst_b));
11321
  /* p2c: checkmol.pas, line 9051:
11321
  /* p2c: checkmol.pas, line 9051:
11322
  * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11322
  * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11323
  /*$IFDEF debug */
11323
  /*$IFDEF debug */
Line 11340... Line 11340...
11340
  //  if (hst_arom)
11340
  //  if (hst_arom)
11341
  //    strcpy (ha, "(ar)");
11341
  //    strcpy (ha, "(ar)");
11342
  //  else
11342
  //  else
11343
  //    *ha = '\0';
11343
  //    *ha = '\0';
11344
  /*$ENDIF */
11344
  /*$ENDIF */
11345
  if (ndl_arom == true && hst_arom == true)
11345
  if (ndl_arom == istrue && hst_arom == istrue)
11346
    res = true;
11346
    res = istrue;
11347
  if (ndl_arom == false && hst_arom == false) {
11347
  if (ndl_arom == isfalse && hst_arom == isfalse) {
11348
    if (ndl_btype == hst_btype)
11348
    if (ndl_btype == hst_btype)
11349
            res = true;
11349
            res = istrue;
11350
    if (ndl_btype == 'l' && (hst_btype == 'S' || hst_btype == 'D'))
11350
    if (ndl_btype == 'l' && (hst_btype == 'S' || hst_btype == 'D'))
11351
            res = true;
11351
            res = istrue;
11352
    if (ndl_btype == 's' && hst_btype == 'S')
11352
    if (ndl_btype == 's' && hst_btype == 'S')
11353
            res = true;
11353
            res = istrue;
11354
    if (ndl_btype == 'd' && hst_btype == 'D')
11354
    if (ndl_btype == 'd' && hst_btype == 'D')
11355
            res = true;
11355
            res = istrue;
11356
  }
11356
  }
11357
  /* a little exception: */
11357
  /* a little exception: */
11358
  if (ndl_arom == false && hst_arom == true) {
11358
  if (ndl_arom == isfalse && hst_arom == istrue) {
11359
    if (ndl_btype == 'A')
11359
    if (ndl_btype == 'A')
11360
            res = true;
11360
            res = istrue;
11361
    if (ndl_btype == 's' || ndl_btype == 'd')
11361
    if (ndl_btype == 's' || ndl_btype == 'd')
11362
            res = true;
11362
            res = istrue;
11363
    if (ndl_btype == 'D') {                     /* added in 0.2d: do not accept C=O etc. as C-O/arom */
11363
    if (ndl_btype == 'D') {                     /* added in 0.2d: do not accept C=O etc. as C-O/arom */
11364
            a1 = ndl_bond[ndl_b - 1].a1;
11364
            a1 = ndl_bond[ndl_b - 1].a1;
11365
            a2 = ndl_bond[ndl_b - 1].a2;
11365
            a2 = ndl_bond[ndl_b - 1].a2;
11366
            strcpy (a1_el, ndl_atom[a1 - 1].element);
11366
            strcpy (a1_el, ndl_atom[a1 - 1].element);
11367
            strcpy (a2_el, ndl_atom[a2 - 1].element);
11367
            strcpy (a2_el, ndl_atom[a2 - 1].element);
11368
            if (strcmp (a1_el, "O ") && strcmp (a2_el, "O ")
11368
            if (strcmp (a1_el, "O ") && strcmp (a2_el, "O ")
11369
                && strcmp (a1_el, "S ") && strcmp (a2_el, "S ")
11369
                && strcmp (a1_el, "S ") && strcmp (a2_el, "S ")
11370
                && strcmp (a1_el, "SE") && strcmp (a2_el, "SE")
11370
                && strcmp (a1_el, "SE") && strcmp (a2_el, "SE")
11371
                && strcmp (a1_el, "TE") && strcmp (a2_el, "TE"))
11371
                && strcmp (a1_el, "TE") && strcmp (a2_el, "TE"))
11372
              res = true;
11372
              res = istrue;
11373
          }
11373
          }
11374
    if (ndl_bond[ndl_b - 1].q_arom)
11374
    if (ndl_bond[ndl_b - 1].q_arom)
11375
            res = true;         /* 0.3p */
11375
            res = istrue;               /* 0.3p */
11376
  }
11376
  }
11377
  if (ndl_btype == 'a')
11377
  if (ndl_btype == 'a')
11378
    res = true;
11378
    res = istrue;
11379
  /* new in v0.3d: obey topology requirements in query structure */
11379
  /* new in v0.3d: obey topology requirements in query structure */
11380
  if (ndl_btopo != btopo_any && ndl_btopo != btopo_always_any) {
11380
  if (ndl_btopo != btopo_any && ndl_btopo != btopo_always_any) {
11381
    if (ndl_btopo == btopo_ring && hst_rc == 0)
11381
    if (ndl_btopo == btopo_ring && hst_rc == 0)
11382
      res = false;
11382
      res = isfalse;
11383
    if (ndl_btopo == btopo_chain && hst_rc > 0)
11383
    if (ndl_btopo == btopo_chain && hst_rc > 0)
11384
      res = false;
11384
      res = isfalse;
11385
    if (ndl_btopo == btopo_excess_rc && hst_rc <= ndl_rc)
11385
    if (ndl_btopo == btopo_excess_rc && hst_rc <= ndl_rc)
11386
      res = false;
11386
      res = isfalse;
11387
    if (ndl_btopo == btopo_exact_rc && hst_rc != ndl_rc)
11387
    if (ndl_btopo == btopo_exact_rc && hst_rc != ndl_rc)
11388
      res = false;
11388
      res = isfalse;
11389
  }
11389
  }
11390
  /* p2c: checkmol.pas, line 9098:
11390
  /* p2c: checkmol.pas, line 9098:
11391
   * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11391
   * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11392
    /*$IFDEF debug */
11392
    /*$IFDEF debug */
11393
    /* if res = false then tstr := ' bond topology mismatch '+inttostr(ndl_rc)+'/'+inttostr(hst_rc); */
11393
    /* if res = isfalse then tstr := ' bond topology mismatch '+inttostr(ndl_rc)+'/'+inttostr(hst_rc); */
11394
    /*$ENDIF */
11394
    /*$ENDIF */
11395
  /* p2c: checkmol.pas, line 9102:
11395
  /* p2c: checkmol.pas, line 9102:
11396
   * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11396
   * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11397
    /*$IFDEF debug */
11397
    /*$IFDEF debug */
11398
    /*
11398
    /*
Line 11403... Line 11403...
11403
}
11403
}
11404
 
11404
 
11405
static boolean matrix_OK (boolean (*m)[max_neighbors], int ndl_dim, int hst_dim)
11405
static boolean matrix_OK (boolean (*m)[max_neighbors], int ndl_dim, int hst_dim)
11406
{
11406
{
11407
  /* new, recursive version in v0.2i: can handle up to max_neighbors substituents */
11407
  /* new, recursive version in v0.2i: can handle up to max_neighbors substituents */
11408
  boolean mr = false;
11408
  boolean mr = isfalse;
11409
  matchmatrix lm;
11409
  matchmatrix lm;
11410
  int i, ii, j, lndl_dim, lhst_dim;
11410
  int i, ii, j, lndl_dim, lhst_dim;
11411
 
11411
 
11412
  if (ndl_dim < 1 || ndl_dim > max_neighbors || hst_dim < 1 ||
11412
  if (ndl_dim < 1 || ndl_dim > max_neighbors || hst_dim < 1 ||
11413
      hst_dim > max_neighbors || ndl_dim > hst_dim)
11413
      hst_dim > max_neighbors || ndl_dim > hst_dim)
11414
    return false;
11414
    return isfalse;
11415
  if (ndl_dim == 1) {
11415
  if (ndl_dim == 1) {
11416
    for (i = 0; i < hst_dim; i++) {
11416
    for (i = 0; i < hst_dim; i++) {
11417
            if (m[0][i])
11417
            if (m[0][i])
11418
              mr = true;
11418
              mr = istrue;
11419
          }
11419
          }
11420
    return mr;
11420
    return mr;
11421
  }
11421
  }
11422
  for (i = 1; i <= hst_dim; i++) {
11422
  for (i = 1; i <= hst_dim; i++) {
11423
    if (m[0][i - 1]) {
11423
    if (m[0][i - 1]) {
11424
            /* write remaining fields into a new matchmatrix which is smaller by 1x1 */
11424
            /* write remaining fields into a new matchmatrix which is smaller by 1x1 */
11425
            memset (lm, false, sizeof (matchmatrix));
11425
            memset (lm, isfalse, sizeof (matchmatrix));
11426
            for (j = 2; j <= ndl_dim; j++) {
11426
            for (j = 2; j <= ndl_dim; j++) {
11427
              lhst_dim = 0;
11427
              lhst_dim = 0;
11428
              for (ii = 1; ii <= hst_dim; ii++) {
11428
              for (ii = 1; ii <= hst_dim; ii++) {
11429
                if (ii != i) {
11429
                if (ii != i) {
11430
                  lhst_dim++;
11430
                  lhst_dim++;
Line 11432... Line 11432...
11432
                }
11432
                }
11433
              }
11433
              }
11434
            }
11434
            }
11435
            lndl_dim = ndl_dim - 1;
11435
            lndl_dim = ndl_dim - 1;
11436
            if (matrix_OK (lm, lndl_dim, lhst_dim)) {                   /* recursive call to matrix_OK */
11436
            if (matrix_OK (lm, lndl_dim, lhst_dim)) {                   /* recursive call to matrix_OK */
11437
              return true;
11437
              return istrue;
11438
            /* stop any further work immediately */
11438
            /* stop any further work immediately */
11439
            }
11439
            }
11440
          }
11440
          }
11441
  }
11441
  }
11442
  return false;
11442
  return isfalse;
11443
}
11443
}
11444
 
11444
 
11445
static boolean is_flat (double angle_deg)
11445
static boolean is_flat (double angle_deg)
11446
{
11446
{
11447
  /* new in v0.3j */
11447
  /* new in v0.3j */
11448
  if (fabs (angle_deg) > 5 && fabs (angle_deg) < 175)
11448
  if (fabs (angle_deg) > 5 && fabs (angle_deg) < 175)
11449
    return false;
11449
    return isfalse;
11450
  else
11450
  else
11451
    return true;
11451
    return istrue;
11452
}
11452
}
11453
 
11453
 
11454
static boolean chirality_OK (int *ndl_cp, int *hst_cp)
11454
static boolean chirality_OK (int *ndl_cp, int *hst_cp)
11455
{
11455
{
11456
  boolean res = true;
11456
  boolean res = istrue;
11457
  double ndl_ct, hst_ct, ndl_ct_deg, hst_ct_deg;
11457
  double ndl_ct, hst_ct, ndl_ct_deg, hst_ct_deg;
11458
  p_3d np1, np2, np3, np4, hp1, hp2, hp3, hp4;
11458
  p_3d np1, np2, np3, np4, hp1, hp2, hp3, hp4;
11459
  int level = 0;
11459
  int level = 0;
11460
  int i;
11460
  int i;
11461
  boolean up = false, down = false, updown = false;
11461
  boolean up = isfalse, down = isfalse, updown = isfalse;
11462
  int ta1, ta2, ta3, ta4, ba1, ba2, FORLIM;
11462
  int ta1, ta2, ta3, ta4, ba1, ba2, FORLIM;
11463
 
11463
 
11464
  /* fill temporary atom variables */
11464
  /* fill temporary atom variables */
11465
  ta1 = ndl_cp[0];              /* this is the central atom */
11465
  ta1 = ndl_cp[0];              /* this is the central atom */
11466
  ta2 = ndl_cp[1];
11466
  ta2 = ndl_cp[1];
Line 11487... Line 11487...
11487
            if (ndl_bond[i].stereo == bstereo_up ||
11487
            if (ndl_bond[i].stereo == bstereo_up ||
11488
                  ndl_bond[i].stereo == bstereo_down) {
11488
                  ndl_bond[i].stereo == bstereo_down) {
11489
              ba1 = ndl_bond[i].a1;
11489
              ba1 = ndl_bond[i].a1;
11490
              ba2 = ndl_bond[i].a2;
11490
              ba2 = ndl_bond[i].a2;
11491
              if (ba1 == ta1 && ndl_bond[i].stereo == bstereo_up) {
11491
              if (ba1 == ta1 && ndl_bond[i].stereo == bstereo_up) {
11492
                      up = true;
11492
                      up = istrue;
11493
                      if (ba2 == ta2 || ba2 == ta3 || ba2 == ta4) {
11493
                      if (ba2 == ta2 || ba2 == ta3 || ba2 == ta4) {
11494
                        updown = true;
11494
                        updown = istrue;
11495
                        if (ba2 == ta2)
11495
                        if (ba2 == ta2)
11496
                                np1.z += 0.8;
11496
                                np1.z += 0.8;
11497
                        if (ba2 == ta3)
11497
                        if (ba2 == ta3)
11498
                                np3.z += 0.8;
11498
                                np3.z += 0.8;
11499
                        if (ba2 == ta4)
11499
                        if (ba2 == ta4)
Line 11501... Line 11501...
11501
                      }
11501
                      }
11502
                      else
11502
                      else
11503
                        level++;
11503
                        level++;
11504
                    }
11504
                    }
11505
              if (ba1 == ta1 && ndl_bond[i].stereo == bstereo_down) {
11505
              if (ba1 == ta1 && ndl_bond[i].stereo == bstereo_down) {
11506
                      down = true;
11506
                      down = istrue;
11507
                      if (ba2 == ta2 || ba2 == ta3 || ba2 == ta4) {
11507
                      if (ba2 == ta2 || ba2 == ta3 || ba2 == ta4) {
11508
                        updown = true;
11508
                        updown = istrue;
11509
                        if (ba2 == ta2)
11509
                        if (ba2 == ta2)
11510
                                np1.z -= 0.8;
11510
                                np1.z -= 0.8;
11511
                        if (ba2 == ta3)
11511
                        if (ba2 == ta3)
11512
                                np3.z -= 0.8;
11512
                                np3.z -= 0.8;
11513
                        if (ba2 == ta4)
11513
                        if (ba2 == ta4)
Line 11515... Line 11515...
11515
                      }
11515
                      }
11516
                      else
11516
                      else
11517
                        level--;
11517
                        level--;
11518
                    }
11518
                    }
11519
              if (ba2 == ta1 && ndl_bond[i].stereo == bstereo_up) {
11519
              if (ba2 == ta1 && ndl_bond[i].stereo == bstereo_up) {
11520
                      down = true;
11520
                      down = istrue;
11521
                      if (ba1 == ta2 || ba1 == ta3 || ba1 == ta4) {
11521
                      if (ba1 == ta2 || ba1 == ta3 || ba1 == ta4) {
11522
                        updown = true;
11522
                        updown = istrue;
11523
                        if (ba1 == ta2)
11523
                        if (ba1 == ta2)
11524
                          np1.z -= 0.8;
11524
                          np1.z -= 0.8;
11525
                        if (ba1 == ta3)
11525
                        if (ba1 == ta3)
11526
                          np3.z -= 0.8;
11526
                          np3.z -= 0.8;
11527
                        if (ba1 == ta4)
11527
                        if (ba1 == ta4)
Line 11529... Line 11529...
11529
                      }
11529
                      }
11530
                      else
11530
                      else
11531
                        level--;
11531
                        level--;
11532
                    }
11532
                    }
11533
              if (ba2 == ta1 && ndl_bond[i].stereo == bstereo_down) {
11533
              if (ba2 == ta1 && ndl_bond[i].stereo == bstereo_down) {
11534
                      up = true;
11534
                      up = istrue;
11535
                      if (ba1 == ta2 || ba1 == ta3 || ba1 == ta4) {
11535
                      if (ba1 == ta2 || ba1 == ta3 || ba1 == ta4) {
11536
                        updown = true;
11536
                        updown = istrue;
11537
                        if (ba1 == ta2)
11537
                        if (ba1 == ta2)
11538
                                np1.z += 0.8;
11538
                                np1.z += 0.8;
11539
                        if (ba1 == ta3)
11539
                        if (ba1 == ta3)
11540
                                np3.z += 0.8;
11540
                                np3.z += 0.8;
11541
                        if (ba1 == ta4)
11541
                        if (ba1 == ta4)
Line 11544... Line 11544...
11544
                      else
11544
                      else
11545
                        level++;
11545
                        level++;
11546
                    }
11546
                    }
11547
            }
11547
            }
11548
          }                     /* for i ... */
11548
          }                     /* for i ... */
11549
    if (updown == false && level != 0) {
11549
    if (updown == isfalse && level != 0) {
11550
            if (level > 0)
11550
            if (level > 0)
11551
              np2.z += 0.3;
11551
              np2.z += 0.3;
11552
            if (level < 0)
11552
            if (level < 0)
11553
              np2.z -= 0.3;
11553
              np2.z -= 0.3;
11554
          }
11554
          }
Line 11578... Line 11578...
11578
  hp4.x = atom[ta4 - 1].x;
11578
  hp4.x = atom[ta4 - 1].x;
11579
  hp4.y = atom[ta4 - 1].y;
11579
  hp4.y = atom[ta4 - 1].y;
11580
  hp4.z = atom[ta4 - 1].z;
11580
  hp4.z = atom[ta4 - 1].z;
11581
  /* now check all haystack bonds if we should care about up/down bonds */
11581
  /* now check all haystack bonds if we should care about up/down bonds */
11582
  level = 0;
11582
  level = 0;
11583
  updown = false;
11583
  updown = isfalse;
11584
  up = false;
11584
  up = isfalse;
11585
  down = false;
11585
  down = isfalse;
11586
  if (n_bonds > 0) {
11586
  if (n_bonds > 0) {
11587
    FORLIM = n_bonds;
11587
    FORLIM = n_bonds;
11588
    for (i = 0; i < FORLIM; i++) {
11588
    for (i = 0; i < FORLIM; i++) {
11589
            if (bond[i].stereo == bstereo_up || bond[i].stereo == bstereo_down) {
11589
            if (bond[i].stereo == bstereo_up || bond[i].stereo == bstereo_down) {
11590
              ba1 = bond[i].a1;
11590
              ba1 = bond[i].a1;
11591
              ba2 = bond[i].a2;
11591
              ba2 = bond[i].a2;
11592
              if (ba1 == ta1 && bond[i].stereo == bstereo_up) {
11592
              if (ba1 == ta1 && bond[i].stereo == bstereo_up) {
11593
                      up = true;
11593
                      up = istrue;
11594
                      if (ba2 == ta2 || ba2 == ta3 || ba2 == ta4) {
11594
                      if (ba2 == ta2 || ba2 == ta3 || ba2 == ta4) {
11595
                        updown = true;
11595
                        updown = istrue;
11596
                        if (ba2 == ta2)
11596
                        if (ba2 == ta2)
11597
                                hp1.z += 0.8;
11597
                                hp1.z += 0.8;
11598
                        if (ba2 == ta3)
11598
                        if (ba2 == ta3)
11599
                                hp3.z += 0.8;
11599
                                hp3.z += 0.8;
11600
                        if (ba2 == ta4)
11600
                        if (ba2 == ta4)
Line 11602... Line 11602...
11602
                      }
11602
                      }
11603
                      else
11603
                      else
11604
                        level++;
11604
                        level++;
11605
                    }
11605
                    }
11606
              if (ba1 == ta1 && bond[i].stereo == bstereo_down) {
11606
              if (ba1 == ta1 && bond[i].stereo == bstereo_down) {
11607
                      down = true;
11607
                      down = istrue;
11608
                      if (ba2 == ta2 || ba2 == ta3 || ba2 == ta4) {
11608
                      if (ba2 == ta2 || ba2 == ta3 || ba2 == ta4) {
11609
                        updown = true;
11609
                        updown = istrue;
11610
                        if (ba2 == ta2)
11610
                        if (ba2 == ta2)
11611
                              hp1.z -= 0.8;
11611
                              hp1.z -= 0.8;
11612
                        if (ba2 == ta3)
11612
                        if (ba2 == ta3)
11613
                                hp3.z -= 0.8;
11613
                                hp3.z -= 0.8;
11614
                        if (ba2 == ta4)
11614
                        if (ba2 == ta4)
Line 11616... Line 11616...
11616
                     }
11616
                     }
11617
                    else
11617
                    else
11618
                      level--;
11618
                      level--;
11619
                    }
11619
                    }
11620
              if (ba2 == ta1 && bond[i].stereo == bstereo_up) {
11620
              if (ba2 == ta1 && bond[i].stereo == bstereo_up) {
11621
                      down = true;
11621
                      down = istrue;
11622
                      if (ba1 == ta2 || ba1 == ta3 || ba1 == ta4) {
11622
                      if (ba1 == ta2 || ba1 == ta3 || ba1 == ta4) {
11623
                        updown = true;
11623
                        updown = istrue;
11624
                        if (ba1 == ta2)
11624
                        if (ba1 == ta2)
11625
                               hp1.z -= 0.8;
11625
                               hp1.z -= 0.8;
11626
                        if (ba1 == ta3)
11626
                        if (ba1 == ta3)
11627
                                hp3.z -= 0.8;
11627
                                hp3.z -= 0.8;
11628
                        if (ba1 == ta4)
11628
                        if (ba1 == ta4)
Line 11630... Line 11630...
11630
                      }
11630
                      }
11631
                      else
11631
                      else
11632
                        level--;
11632
                        level--;
11633
                    }
11633
                    }
11634
              if (ba2 == ta1 && bond[i].stereo == bstereo_down) {
11634
              if (ba2 == ta1 && bond[i].stereo == bstereo_down) {
11635
                      up = true;
11635
                      up = istrue;
11636
                      if (ba1 == ta2 || ba1 == ta3 || ba1 == ta4) {
11636
                      if (ba1 == ta2 || ba1 == ta3 || ba1 == ta4) {
11637
                        updown = true;
11637
                        updown = istrue;
11638
                        if (ba1 == ta2)
11638
                        if (ba1 == ta2)
11639
                                hp1.z += 0.8;
11639
                                hp1.z += 0.8;
11640
                        if (ba1 == ta3)
11640
                        if (ba1 == ta3)
11641
                                hp3.z += 0.8;
11641
                                hp3.z += 0.8;
11642
                        if (ba1 == ta4)
11642
                        if (ba1 == ta4)
Line 11645... Line 11645...
11645
                      else
11645
                      else
11646
                        level++;
11646
                        level++;
11647
                    }
11647
                    }
11648
            }
11648
            }
11649
          }                     /* for i ... */
11649
          }                     /* for i ... */
11650
    if (updown == false && level != 0) {
11650
    if (updown == isfalse && level != 0) {
11651
            if (level > 0)
11651
            if (level > 0)
11652
              hp2.z += 0.3;
11652
              hp2.z += 0.3;
11653
            if (level < 0)
11653
            if (level < 0)
11654
              hp2.z -= 0.3;
11654
              hp2.z -= 0.3;
11655
          }
11655
          }
Line 11668... Line 11668...
11668
  /* now do a plausibility check and finally check the sense */
11668
  /* now do a plausibility check and finally check the sense */
11669
  /* (clockwise or counterclockwise) */
11669
  /* (clockwise or counterclockwise) */
11670
  /*
11670
  /*
11671
     if (abs(ndl_ct_deg) > 5) and (abs(ndl_ct_deg) < 175) and
11671
     if (abs(ndl_ct_deg) > 5) and (abs(ndl_ct_deg) < 175) and
11672
     (abs(hst_ct_deg) > 5) and (abs(hst_ct_deg) < 175) and
11672
     (abs(hst_ct_deg) > 5) and (abs(hst_ct_deg) < 175) and
11673
     (ndl_ct_deg * hst_ct_deg < 0) then res := false;
11673
     (ndl_ct_deg * hst_ct_deg < 0) then res := isfalse;
11674
   */
11674
   */
11675
  if (((!is_flat (ndl_ct_deg)) && (!is_flat (hst_ct_deg))) &&
11675
  if (((!is_flat (ndl_ct_deg)) && (!is_flat (hst_ct_deg))) &&
11676
      ndl_ct_deg * hst_ct_deg < 0)
11676
      ndl_ct_deg * hst_ct_deg < 0)
11677
    res = false;
11677
    res = isfalse;
11678
  if (rs_strict) {
11678
  if (rs_strict) {
11679
      if (((is_flat (ndl_ct_deg) && (!is_flat (hst_ct_deg))) ||
11679
      if (((is_flat (ndl_ct_deg) && (!is_flat (hst_ct_deg))) ||
11680
                (is_flat (hst_ct_deg) && (!is_flat (ndl_ct_deg)))) ||
11680
                (is_flat (hst_ct_deg) && (!is_flat (ndl_ct_deg)))) ||
11681
                ndl_ct_deg * hst_ct_deg < 0)
11681
                ndl_ct_deg * hst_ct_deg < 0)
11682
              res = false;
11682
              res = isfalse;
11683
  }
11683
  }
11684
  return res;
11684
  return res;
11685
}
11685
}
11686
 
11686
 
11687
static boolean ndl_maybe_chiral (int na)
11687
static boolean ndl_maybe_chiral (int na)
11688
{
11688
{
11689
  /* new in v0.3h */
11689
  /* new in v0.3h */
11690
  boolean res = false;
11690
  boolean res = isfalse;
11691
  str2 el;
11691
  str2 el;
11692
  str3 at;
11692
  str3 at;
11693
  int n_nb;
11693
  int n_nb;
11694
 
11694
 
11695
  strcpy (el, ndl_atom[na - 1].element);
11695
  strcpy (el, ndl_atom[na - 1].element);
11696
  strcpy (at, ndl_atom[na - 1].atype);
11696
  strcpy (at, ndl_atom[na - 1].atype);
11697
  n_nb = ndl_atom[na - 1].neighbor_count;
11697
  n_nb = ndl_atom[na - 1].neighbor_count;
11698
  if (!strcmp (at, "C3 ") && n_nb > 2)
11698
  if (!strcmp (at, "C3 ") && n_nb > 2)
11699
    res = true;
11699
    res = istrue;
11700
  if (!strcmp (el, "N ")) {
11700
  if (!strcmp (el, "N ")) {
11701
    if (!strcmp (at, "N3+") && n_nb == 4)
11701
    if (!strcmp (at, "N3+") && n_nb == 4)
11702
            res = true;
11702
            res = istrue;
11703
  }
11703
  }
11704
  if (!strcmp (el, "S ")) {                             /* sulfoxide */
11704
  if (!strcmp (el, "S ")) {                             /* sulfoxide */
11705
    if ((n_nb == 3) && (ndl_hetatom_count (na) == 1))
11705
    if ((n_nb == 3) && (ndl_hetatom_count (na) == 1))
11706
            res = true;
11706
            res = istrue;
11707
  }
11707
  }
11708
  if (strcmp (el, "P ") && strcmp (el, "AS"))   /* "As" added in v0.3j */
11708
  if (strcmp (el, "P ") && strcmp (el, "AS"))   /* "As" added in v0.3j */
11709
    return res;
11709
    return res;
11710
  if (n_nb > 3)                 /* are we missing something here? */
11710
  if (n_nb > 3)                 /* are we missing something here? */
11711
    res = true;
11711
    res = istrue;
11712
  if (ndl_hetatom_count (na) >= 2)      /* v0.3m; ignore phosphates etc. */
11712
  if (ndl_hetatom_count (na) >= 2)      /* v0.3m; ignore phosphates etc. */
11713
    res = false;
11713
    res = isfalse;
11714
  return res;
11714
  return res;
11715
}
11715
}
11716
 
11716
 
11717
static boolean is_matching (int *ndl_xmp, int *hst_xmp)
11717
static boolean is_matching (int *ndl_xmp, int *hst_xmp)
11718
{
11718
{
Line 11758... Line 11758...
11758
  /* p2c: checkmol.pas, line 9451:
11758
  /* p2c: checkmol.pas, line 9451:
11759
  * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11759
  * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11760
      /*$IFDEF debug */
11760
      /*$IFDEF debug */
11761
      //debugoutput ("needle and haystack matchpaths are of different length");
11761
      //debugoutput ("needle and haystack matchpaths are of different length");
11762
      /*$ENDIF */
11762
      /*$ENDIF */
11763
    return false;
11763
    return isfalse;
11764
  }
11764
  }
11765
  ndl_a = ndl_mp[ndl_mp_len - 1];
11765
  ndl_a = ndl_mp[ndl_mp_len - 1];
11766
  hst_a = hst_mp[hst_mp_len - 1];
11766
  hst_a = hst_mp[hst_mp_len - 1];
11767
  ndl_atom[ndl_a - 1].tag = false;
11767
  ndl_atom[ndl_a - 1].tag = isfalse;
11768
  /* new in v0.3o: mark the last needle atom as "visited" */
11768
  /* new in v0.3o: mark the last needle atom as "visited" */
11769
  if (ndl_mp_len > 1) {
11769
  if (ndl_mp_len > 1) {
11770
    prev_ndl_a = ndl_mp[ndl_mp_len - 2];
11770
    prev_ndl_a = ndl_mp[ndl_mp_len - 2];
11771
    prev_hst_a = hst_mp[hst_mp_len - 2];
11771
    prev_hst_a = hst_mp[hst_mp_len - 2];
11772
    }
11772
    }
11773
  /* if geometry checking is on, check it here */
11773
  /* if geometry checking is on, check it here */
11774
  if (ez_search == true && ndl_mp_len > 3) {
11774
  if (ez_search == istrue && ndl_mp_len > 3) {
11775
    na1 = ndl_mp[ndl_mp_len - 1];
11775
    na1 = ndl_mp[ndl_mp_len - 1];
11776
    na2 = ndl_mp[ndl_mp_len - 2];
11776
    na2 = ndl_mp[ndl_mp_len - 2];
11777
    na3 = ndl_mp[ndl_mp_len - 3];
11777
    na3 = ndl_mp[ndl_mp_len - 3];
11778
    na4 = ndl_mp[ndl_mp_len - 4];
11778
    na4 = ndl_mp[ndl_mp_len - 4];
11779
    ha1 = hst_mp[hst_mp_len - 1];
11779
    ha1 = hst_mp[hst_mp_len - 1];
11780
    ha2 = hst_mp[hst_mp_len - 2];
11780
    ha2 = hst_mp[hst_mp_len - 2];
11781
    ha3 = hst_mp[hst_mp_len - 3];
11781
    ha3 = hst_mp[hst_mp_len - 3];
11782
    ha4 = hst_mp[hst_mp_len - 4];
11782
    ha4 = hst_mp[hst_mp_len - 4];
11783
    prev_ndl_b = get_ndl_bond (na2, na3);
11783
    prev_ndl_b = get_ndl_bond (na2, na3);
11784
    prev_hst_b = get_bond (ha2, ha3);
11784
    prev_hst_b = get_bond (ha2, ha3);
11785
    if (ndl_bond[prev_ndl_b - 1].btype == 'D' && bond[prev_hst_b - 1].arom == false
11785
    if (ndl_bond[prev_ndl_b - 1].btype == 'D' && bond[prev_hst_b - 1].arom == isfalse
11786
              && (ndl_bond[prev_ndl_b - 1].stereo != bstereo_double_either
11786
              && (ndl_bond[prev_ndl_b - 1].stereo != bstereo_double_either
11787
              && bond[prev_hst_b - 1].stereo != bstereo_double_either)
11787
              && bond[prev_hst_b - 1].stereo != bstereo_double_either)
11788
              /* 0.3x always match if needle and/or haystack bond is double_either */
11788
              /* 0.3x always match if needle and/or haystack bond is double_either */
11789
              && (!strcmp (atom[ha2 - 1].element, "C ")
11789
              && (!strcmp (atom[ha2 - 1].element, "C ")
11790
              || !strcmp (atom[ha2 - 1].element, "N "))
11790
              || !strcmp (atom[ha2 - 1].element, "N "))
Line 11823... Line 11823...
11823
        /* p2c: checkmol.pas, line 9501:
11823
        /* p2c: checkmol.pas, line 9501:
11824
        * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11824
        * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11825
              /*$IFDEF debug */
11825
              /*$IFDEF debug */
11826
              //debugoutput ("E/Z geometry mismatch");
11826
              //debugoutput ("E/Z geometry mismatch");
11827
              /*$ENDIF */
11827
              /*$ENDIF */
11828
              return false;
11828
              return isfalse;
11829
            }
11829
            }
11830
          }
11830
          }
11831
  }                             /* end of E/Z geometry check */
11831
  }                             /* end of E/Z geometry check */
11832
  /* check whatever can be checked as early as now: */
11832
  /* check whatever can be checked as early as now: */
11833
  /* e.g. different elements or more substituents on needle atom than on haystack */
11833
  /* e.g. different elements or more substituents on needle atom than on haystack */
11834
  if (!atomtypes_OK (ndl_a, hst_a))
11834
  if (!atomtypes_OK (ndl_a, hst_a))
11835
    return false;
11835
    return isfalse;
11836
  /* positive scenarios, e.g. one-atom fragments  (v0.3o) */
11836
  /* positive scenarios, e.g. one-atom fragments  (v0.3o) */
11837
  if (atom[hst_a - 1].neighbor_count == 0 && ndl_atom[ndl_a - 1].neighbor_count == 0) {
11837
  if (atom[hst_a - 1].neighbor_count == 0 && ndl_atom[ndl_a - 1].neighbor_count == 0) {
11838
    if (!atomtypes_OK (ndl_a, hst_a))
11838
    if (!atomtypes_OK (ndl_a, hst_a))
11839
            return false;
11839
            return isfalse;
11840
    /* p2c: checkmol.pas: Note: Eliminated unused assignment statement [338] */
11840
    /* p2c: checkmol.pas: Note: Eliminated unused assignment statement [338] */
11841
    atom[hst_a - 1].tag = true;
11841
    atom[hst_a - 1].tag = istrue;
11842
    return true;
11842
    return istrue;
11843
  }
11843
  }
11844
  /* and other possibilities: */
11844
  /* and other possibilities: */
11845
  ndl_b = get_ndl_bond (prev_ndl_a, ndl_a);
11845
  ndl_b = get_ndl_bond (prev_ndl_a, ndl_a);
11846
  hst_b = get_bond (prev_hst_a, hst_a);
11846
  hst_b = get_bond (prev_hst_a, hst_a);
11847
  /* p2c: checkmol.pas, line 9529:
11847
  /* p2c: checkmol.pas, line 9529:
Line 11856... Line 11856...
11856
      * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11856
      * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11857
            /*$IFDEF debug */
11857
            /*$IFDEF debug */
11858
            /*
11858
            /*
11859
             debugoutput('  failed match of bonds '+inttostr(ndl_b)+'/'+inttostr(hst_b)); */
11859
             debugoutput('  failed match of bonds '+inttostr(ndl_b)+'/'+inttostr(hst_b)); */
11860
           /*$ENDIF */
11860
           /*$ENDIF */
11861
            return false;
11861
            return isfalse;
11862
          }
11862
          }
11863
  }
11863
  }
11864
  /* a) we reached the end of our needle fragment (and atom/bond types match) */
11864
  /* a) we reached the end of our needle fragment (and atom/bond types match) */
11865
  if ((ndl_atom[ndl_a - 1].neighbor_count == 1) && atomtypes_OK (ndl_a, hst_a) &&
11865
  if ((ndl_atom[ndl_a - 1].neighbor_count == 1) && atomtypes_OK (ndl_a, hst_a) &&
11866
      bondtypes_OK (ndl_b, hst_b)) {
11866
      bondtypes_OK (ndl_b, hst_b)) {
11867
    return true;
11867
    return istrue;
11868
  /* p2c: checkmol.pas, line 9549:
11868
  /* p2c: checkmol.pas, line 9549:
11869
  * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11869
  * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11870
      /*$IFDEF debug */
11870
      /*$IFDEF debug */
11871
      /* debugoutput('  ==> end of needle fragment at atom '+inttostr(ndl_a)+' (match)'); */
11871
      /* debugoutput('  ==> end of needle fragment at atom '+inttostr(ndl_a)+' (match)'); */
11872
      /*$ENDIF */
11872
      /*$ENDIF */
11873
  }
11873
  }
11874
  /* a.1) haystack fragment forms a ring, but needle does not;  v0.3m */
11874
  /* a.1) haystack fragment forms a ring, but needle does not;  v0.3m */
11875
  if ((matchpath_pos (ndl_a, ndl_mp) == matchpath_length (ndl_mp)) &&
11875
  if ((matchpath_pos (ndl_a, ndl_mp) == matchpath_length (ndl_mp)) &&
11876
        (matchpath_pos (hst_a, hst_mp) < matchpath_length (hst_mp))) {
11876
        (matchpath_pos (hst_a, hst_mp) < matchpath_length (hst_mp))) {
11877
    return false;
11877
    return isfalse;
11878
    /* p2c: checkmol.pas, line 9559:
11878
    /* p2c: checkmol.pas, line 9559:
11879
    * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11879
    * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11880
      /*$IFDEF debug */
11880
      /*$IFDEF debug */
11881
      /*
11881
      /*
11882
         debugoutput('  haystack forms a ring and needle does not at '+inttostr(hst_a));
11882
         debugoutput('  haystack forms a ring and needle does not at '+inttostr(hst_a));
Line 11889... Line 11889...
11889
              atomtypes_OK (ndl_a, hst_a) && bondtypes_OK (ndl_b, hst_b)) {
11889
              atomtypes_OK (ndl_a, hst_a) && bondtypes_OK (ndl_b, hst_b)) {
11890
              /* 1st chirality check */
11890
              /* 1st chirality check */
11891
            if (!((matchpath_pos (ndl_a, ndl_mp) > 1 && (rs_search ||
11891
            if (!((matchpath_pos (ndl_a, ndl_mp) > 1 && (rs_search ||
11892
                                                       ndl_atom[ndl_a -1].stereo_care)) && ndl_maybe_chiral (ndl_a))) {
11892
                                                       ndl_atom[ndl_a -1].stereo_care)) && ndl_maybe_chiral (ndl_a))) {
11893
                                        /* new in v0.3h */
11893
                                        /* new in v0.3h */
11894
              return true;
11894
              return istrue;
11895
            }                   /* end of 1st chirality check */
11895
            }                   /* end of 1st chirality check */
11896
            na1 = ndl_a;                /* the (potential) chiral center (v0.3f) */
11896
            na1 = ndl_a;                /* the (potential) chiral center (v0.3f) */
11897
            na2 = ndl_mp[matchpath_pos (ndl_a, ndl_mp) - 2];
11897
            na2 = ndl_mp[matchpath_pos (ndl_a, ndl_mp) - 2];
11898
            na3 = ndl_mp[matchpath_pos (ndl_a, ndl_mp)];
11898
            na3 = ndl_mp[matchpath_pos (ndl_a, ndl_mp)];
11899
            na4 = ndl_mp[matchpath_length (ndl_mp) - 2];
11899
            na4 = ndl_mp[matchpath_length (ndl_mp) - 2];
Line 11915... Line 11915...
11915
        /* p2c: checkmol.pas, line 9589:
11915
        /* p2c: checkmol.pas, line 9589:
11916
         * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11916
         * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11917
                      /*$IFDEF debug */
11917
                      /*$IFDEF debug */
11918
                      //debugoutput ("chirality check failed at ring junction");
11918
                      //debugoutput ("chirality check failed at ring junction");
11919
                      /*$ENDIF */
11919
                      /*$ENDIF */
11920
        return false;
11920
        return isfalse;
11921
      }
11921
      }
11922
      /* p2c: checkmol.pas, line 9596:
11922
      /* p2c: checkmol.pas, line 9596:
11923
       * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11923
       * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11924
          /*$IFDEF debug */
11924
          /*$IFDEF debug */
11925
          //debugoutput ("chirality check succeeded at ring junction");
11925
          //debugoutput ("chirality check succeeded at ring junction");
11926
          /*$ENDIF */
11926
          /*$ENDIF */
11927
      return true;
11927
      return istrue;
11928
      /* p2c: checkmol.pas, line 9602:
11928
      /* p2c: checkmol.pas, line 9602:
11929
       * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11929
       * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11930
            /*$IFDEF debug */
11930
            /*$IFDEF debug */
11931
            /* debugoutput('matchpath forms ring at: '+inttostr(ndl_a)+' (match)'); */
11931
            /* debugoutput('matchpath forms ring at: '+inttostr(ndl_a)+' (match)'); */
11932
            /*$ENDIF */
11932
            /*$ENDIF */
11933
          }
11933
          }
11934
    else {
11934
    else {
11935
            return false;
11935
            return isfalse;
11936
      /* p2c: checkmol.pas, line 9609:
11936
      /* p2c: checkmol.pas, line 9609:
11937
      * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11937
      * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11938
            /*$IFDEF debug */
11938
            /*$IFDEF debug */
11939
            /*
11939
            /*
11940
               debugoutput('matchpath forms ring at: '+inttostr(ndl_a)+' (no match)'); */
11940
               debugoutput('matchpath forms ring at: '+inttostr(ndl_a)+' (no match)'); */
Line 11960... Line 11960...
11960
    get_ndl_nextneighbors (ndl_nb, ndl_a, prev_ndl_a);
11960
    get_ndl_nextneighbors (ndl_nb, ndl_a, prev_ndl_a);
11961
    get_nextneighbors (hst_nb, hst_a, prev_hst_a);
11961
    get_nextneighbors (hst_nb, hst_a, prev_hst_a);
11962
  }
11962
  }
11963
  /* v0.3o: mark all neighbor atoms as "visited" */
11963
  /* v0.3o: mark all neighbor atoms as "visited" */
11964
  for (i = 0; i < ndl_n_nb; i++)
11964
  for (i = 0; i < ndl_n_nb; i++)
11965
    ndl_atom[ndl_nb[i] - 1].tag = false;
11965
    ndl_atom[ndl_nb[i] - 1].tag = isfalse;
11966
  /* now that the neighbor-arrays are filled, get all */
11966
  /* now that the neighbor-arrays are filled, get all */
11967
  /* combinations of matches recursively; */
11967
  /* combinations of matches recursively; */
11968
  /* first, initialize the match matrix */
11968
  /* first, initialize the match matrix */
11969
  memset (mm, false, sizeof (matchmatrix));     /* new in v0.2i */
11969
  memset (mm, isfalse, sizeof (matchmatrix));   /* new in v0.2i */
11970
  /* make sure there are not too many neighbors (max. max_neighbors)   */
11970
  /* make sure there are not too many neighbors (max. max_neighbors)   */
11971
  if (ndl_n_nb > max_neighbors || n_nb > max_neighbors) {                               /* updated in v0.2i */
11971
  if (ndl_n_nb > max_neighbors || n_nb > max_neighbors) {                               /* updated in v0.2i */
11972
    /* p2c: checkmol.pas, line 9644:
11972
    /* p2c: checkmol.pas, line 9644:
11973
    * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11973
    * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11974
      /*$IFDEF debug */
11974
      /*$IFDEF debug */
11975
      //debugoutput ("too many neighbors - exiting");
11975
      //debugoutput ("too many neighbors - exiting");
11976
      /*$ENDIF */
11976
      /*$ENDIF */
11977
    return false;
11977
    return isfalse;
11978
  }
11978
  }
11979
  /* check if matchpath is not already filled up */
11979
  /* check if matchpath is not already filled up */
11980
  if (matchpath_length (ndl_mp) == max_matchpath_length) {
11980
  if (matchpath_length (ndl_mp) == max_matchpath_length) {
11981
    /* p2c: checkmol.pas, line 9653:
11981
    /* p2c: checkmol.pas, line 9653:
11982
    * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11982
    * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11983
      /*$IFDEF debug */
11983
      /*$IFDEF debug */
11984
      //debugoutput ("matchpath too int - exiting");
11984
      //debugoutput ("matchpath too int - exiting");
11985
      /*$ENDIF */
11985
      /*$ENDIF */
11986
    return false;
11986
    return isfalse;
11987
  }
11987
  }
11988
  /* next, check which chain of the needle matches which chain of the haystack  */
11988
  /* next, check which chain of the needle matches which chain of the haystack  */
11989
  for (i = 0; i < ndl_n_nb; i++) {
11989
  for (i = 0; i < ndl_n_nb; i++) {
11990
    emptyline = true;
11990
    emptyline = istrue;
11991
    next_ndl_a = ndl_nb[i];
11991
    next_ndl_a = ndl_nb[i];
11992
    for (j = 0; j < n_nb; j++) {
11992
    for (j = 0; j < n_nb; j++) {
11993
            next_hst_a = hst_nb[j];
11993
            next_hst_a = hst_nb[j];
11994
            ndl_mp[ndl_mp_len] = next_ndl_a;
11994
            ndl_mp[ndl_mp_len] = next_ndl_a;
11995
            hst_mp[hst_mp_len] = next_hst_a;
11995
            hst_mp[hst_mp_len] = next_hst_a;
Line 12001... Line 12001...
12001
#endif
12001
#endif
12002
                        printf
12002
                        printf
12003
                      ("Warning: max. number of match recursions (%i) reached, reverting to non-exhaustive match\n",
12003
                      ("Warning: max. number of match recursions (%i) reached, reverting to non-exhaustive match\n",
12004
                      max_match_recursion_depth);
12004
                      max_match_recursion_depth);
12005
                      //n_rings = max_rings;
12005
                      //n_rings = max_rings;
12006
                     return true;
12006
                     return istrue;
12007
                    }
12007
                    }
12008
              mm[i][j] = true;
12008
              mm[i][j] = istrue;
12009
              emptyline = false;
12009
              emptyline = isfalse;
12010
            }
12010
            }
12011
          }
12011
          }
12012
    /* if a needle substituent does not match any of the haystack substituents, */
12012
    /* if a needle substituent does not match any of the haystack substituents, */
12013
    /* stop any further work immediately */
12013
    /* stop any further work immediately */
12014
    if (emptyline)
12014
    if (emptyline)
12015
            return false;
12015
            return isfalse;
12016
  }
12016
  }
12017
  /* finally, check the content of the matrix */
12017
  /* finally, check the content of the matrix */
12018
  res = matrix_OK (mm, ndl_n_nb, n_nb);
12018
  res = matrix_OK (mm, ndl_n_nb, n_nb);
12019
  /* optional: chirality check */
12019
  /* optional: chirality check */
12020
  if (!((res && (rs_search || ndl_atom[ndl_a - 1].stereo_care)) && ndl_maybe_chiral (ndl_a)))
12020
  if (!((res && (rs_search || ndl_atom[ndl_a - 1].stereo_care)) && ndl_maybe_chiral (ndl_a)))
Line 12032... Line 12032...
12032
                    }
12032
                    }
12033
            }
12033
            }
12034
            if (n_hits == 1) {                  /* a unique match ==> kick out any other match at this pos. */
12034
            if (n_hits == 1) {                  /* a unique match ==> kick out any other match at this pos. */
12035
              for (m = 1; m <= max_neighbors; m++) {
12035
              for (m = 1; m <= max_neighbors; m++) {
12036
                      if (m != j)
12036
                      if (m != j)
12037
                        mm[l - 1][m - 1] = false;
12037
                        mm[l - 1][m - 1] = isfalse;
12038
                    }
12038
                    }
12039
            }
12039
            }
12040
          }
12040
          }
12041
  }
12041
  }
12042
  /* end of match matrix clean-up */
12042
  /* end of match matrix clean-up */
Line 12072... Line 12072...
12072
    /* p2c: checkmol.pas, line 9749:
12072
    /* p2c: checkmol.pas, line 9749:
12073
     * Note: Turbo Pascal conditional compilation directive was ignored [218] */
12073
     * Note: Turbo Pascal conditional compilation directive was ignored [218] */
12074
          /*$IFDEF debug */
12074
          /*$IFDEF debug */
12075
          //debugoutput ("chirality check failed");
12075
          //debugoutput ("chirality check failed");
12076
          /*$ENDIF */
12076
          /*$ENDIF */
12077
          res = false;
12077
          res = isfalse;
12078
  }
12078
  }
12079
  else {
12079
  else {
12080
/* p2c: checkmol.pas, line 9755:
12080
/* p2c: checkmol.pas, line 9755:
12081
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
12081
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
12082
      /*$IFDEF debug */
12082
      /*$IFDEF debug */
Line 12094... Line 12094...
12094
 
12094
 
12095
static boolean quick_match ()
12095
static boolean quick_match ()
12096
{
12096
{
12097
  /* added in v0.2c */
12097
  /* added in v0.2c */
12098
  int i;
12098
  int i;
12099
  boolean res = true;
12099
  boolean res = istrue;
12100
  /* str3 ndl_atype;*/
12100
  /* str3 ndl_atype;*/
12101
  str2 ndl_el;                  /* v0.3l */
12101
  str2 ndl_el;                  /* v0.3l */
12102
  int ndl_chg = 0;              /* v0.3l */
12102
  int ndl_chg = 0;              /* v0.3l */
12103
  int ndl_rad = 0;              /* v0.3x */
12103
  int ndl_rad = 0;              /* v0.3x */
12104
  int ndl_iso = 0;              /* v0.3x */
12104
  int ndl_iso = 0;              /* v0.3x */
12105
 
12105
 
12106
  if ((ez_search || rs_search) && ndl_n_heavyatoms > 3)
12106
  if ((ez_search || rs_search) && ndl_n_heavyatoms > 3)
12107
    /* v0.3f, v0.3m, v0.3o */
12107
    /* v0.3f, v0.3m, v0.3o */
12108
    return false;
12108
    return isfalse;
12109
  if (ndl_n_atoms < 1 || n_atoms < 1 || ndl_n_atoms > n_atoms ||
12109
  if (ndl_n_atoms < 1 || n_atoms < 1 || ndl_n_atoms > n_atoms ||
12110
        ndl_n_bonds > n_bonds) {                                /* just to be sure... */
12110
        ndl_n_bonds > n_bonds) {                                /* just to be sure... */
12111
    /* p2c: checkmol.pas, line 9786:
12111
    /* p2c: checkmol.pas, line 9786:
12112
     * Note: Turbo Pascal conditional compilation directive was ignored [218] */
12112
     * Note: Turbo Pascal conditional compilation directive was ignored [218] */
12113
          /*$IFDEF debug */
12113
          /*$IFDEF debug */
12114
    /* p2c: checkmol.pas: Note: Eliminated unused assignment statement [338] */
12114
    /* p2c: checkmol.pas: Note: Eliminated unused assignment statement [338] */
12115
          //debugoutput (" ==> quick_match failed");
12115
          //debugoutput (" ==> quick_match failed");
12116
          /*$ENDIF */
12116
          /*$ENDIF */
12117
    return false;
12117
    return isfalse;
12118
  }
12118
  }
12119
 
12119
 
12120
  if (ndl_n_heavyatoms > 1) {
12120
  if (ndl_n_heavyatoms > 1) {
12121
    for (i = 0; i < ndl_n_atoms; i++) {
12121
    for (i = 0; i < ndl_n_atoms; i++) {
12122
            /*if atom^[i].atype <> ndl_atom^[i].atype then res := false;    (* changed in */
12122
            /*if atom^[i].atype <> ndl_atom^[i].atype then res := isfalse;    (* changed in */
12123
            if (strcmp (atom[i].element, ndl_atom[i].element))  /* v0.2k */
12123
            if (strcmp (atom[i].element, ndl_atom[i].element))  /* v0.2k */
12124
              return false;
12124
              return isfalse;
12125
            //  if (atom[i].formal_charge != ndl_atom[i].formal_charge) /* v0.3o */
12125
            //  if (atom[i].formal_charge != ndl_atom[i].formal_charge) /* v0.3o */
12126
            //res = false;
12126
            //res = isfalse;
12127
 
12127
 
12128
            if (opt_chg) {
12128
            if (opt_chg) {
12129
              if (ndl_atom[i].formal_charge != atom[i].formal_charge)
12129
              if (ndl_atom[i].formal_charge != atom[i].formal_charge)
12130
                      return false;
12130
                      return isfalse;
12131
            }
12131
            }
12132
      /*  else {
12132
      /*  else {
12133
            if (ndl_atom[i].formal_charge != 0 &&
12133
            if (ndl_atom[i].formal_charge != 0 &&
12134
          atom[i].formal_charge != 0 &&
12134
          atom[i].formal_charge != 0 &&
12135
          ndl_atom[i].formal_charge != atom[i].formal_charge)
12135
          ndl_atom[i].formal_charge != atom[i].formal_charge)
12136
        return false;
12136
        return isfalse;
12137
          } */
12137
          } */
12138
 
12138
 
12139
          /* v0.3x: isotopes must be the same */
12139
          /* v0.3x: isotopes must be the same */
12140
            if (opt_iso) {
12140
            if (opt_iso) {
12141
              if (ndl_atom[i].nucleon_number != atom[i].nucleon_number)
12141
              if (ndl_atom[i].nucleon_number != atom[i].nucleon_number)
12142
                      return false;
12142
                      return isfalse;
12143
            }
12143
            }
12144
          /*  else {
12144
          /*  else {
12145
          if (ndl_atom[i].nucleon_number != 0 &&
12145
          if (ndl_atom[i].nucleon_number != 0 &&
12146
          atom[i].nucleon_number != 0 &&
12146
          atom[i].nucleon_number != 0 &&
12147
          ndl_atom[i].nucleon_number !=
12147
          ndl_atom[i].nucleon_number !=
12148
          atom[i].nucleon_number)
12148
          atom[i].nucleon_number)
12149
        return false;
12149
        return isfalse;
12150
        }*/
12150
        }*/
12151
 
12151
 
12152
            /* v0.3x: radicals must be the same */
12152
            /* v0.3x: radicals must be the same */
12153
            if (opt_rad) {
12153
            if (opt_rad) {
12154
              if (ndl_atom[i].radical_type != atom[i].radical_type)
12154
              if (ndl_atom[i].radical_type != atom[i].radical_type)
12155
                      return false;
12155
                      return isfalse;
12156
            }
12156
            }
12157
      /*  else {
12157
      /*  else {
12158
         if (ndl_atom[i].radical_type != 0 &&
12158
         if (ndl_atom[i].radical_type != 0 &&
12159
             atom[i].radical_type != 0 &&
12159
             atom[i].radical_type != 0 &&
12160
             ndl_atom[i].radical_type != atom[i].radical_type)
12160
             ndl_atom[i].radical_type != atom[i].radical_type)
12161
           return false;
12161
           return isfalse;
12162
       }*/
12162
       }*/
12163
 
12163
 
12164
        }
12164
        }
12165
  /* p2c: checkmol.pas, line 9798:
12165
  /* p2c: checkmol.pas, line 9798:
12166
  * Note: Turbo Pascal conditional compilation directive was ignored [218] */
12166
  * Note: Turbo Pascal conditional compilation directive was ignored [218] */
Line 12172... Line 12172...
12172
      /*$ENDIF */
12172
      /*$ENDIF */
12173
    if (ndl_n_bonds > 0) {
12173
    if (ndl_n_bonds > 0) {
12174
            for (i = 0; i < ndl_n_bonds; i++) {
12174
            for (i = 0; i < ndl_n_bonds; i++) {
12175
              if (ndl_bond[i].a1 != bond[i].a1 || ndl_bond[i].a2 != bond[i].a2
12175
              if (ndl_bond[i].a1 != bond[i].a1 || ndl_bond[i].a2 != bond[i].a2
12176
                        || ndl_bond[i].btype != bond[i].btype)
12176
                        || ndl_bond[i].btype != bond[i].btype)
12177
                      return false;
12177
                      return isfalse;
12178
            }
12178
            }
12179
          }
12179
          }
12180
    /* p2c: checkmol.pas, line 9810:
12180
    /* p2c: checkmol.pas, line 9810:
12181
    * Note: Turbo Pascal conditional compilation directive was ignored [218] */
12181
    * Note: Turbo Pascal conditional compilation directive was ignored [218] */
12182
         /*$IFDEF debug */
12182
         /*$IFDEF debug */
Line 12201... Line 12201...
12201
    for (i = 0; i < n_atoms; i++) {                     /* v0.3l, v0.3o */
12201
    for (i = 0; i < n_atoms; i++) {                     /* v0.3l, v0.3o */
12202
            if (                //      !strcmp (atom[i].atype, ndl_atype) &&
12202
            if (                //      !strcmp (atom[i].atype, ndl_atype) &&
12203
                !strcmp (atom[i].element, ndl_el)) {
12203
                !strcmp (atom[i].element, ndl_el)) {
12204
              if (opt_chg || opt_strict) {
12204
              if (opt_chg || opt_strict) {
12205
                      if (ndl_chg != atom[i].formal_charge)
12205
                      if (ndl_chg != atom[i].formal_charge)
12206
                        return false;
12206
                        return isfalse;
12207
                    }
12207
                    }
12208
              if (opt_iso || opt_strict) {
12208
              if (opt_iso || opt_strict) {
12209
                      if (ndl_iso != atom[i].nucleon_number)
12209
                      if (ndl_iso != atom[i].nucleon_number)
12210
                        return false;
12210
                        return isfalse;
12211
                    }
12211
                    }
12212
 
12212
 
12213
              if (opt_rad || opt_strict) {
12213
              if (opt_rad || opt_strict) {
12214
                      if (ndl_rad != atom[i].radical_type)
12214
                      if (ndl_rad != atom[i].radical_type)
12215
                        return false;
12215
                        return isfalse;
12216
                    }
12216
                    }
12217
                    return true;
12217
                    return istrue;
12218
            }
12218
            }
12219
            else {
12219
            else {
12220
              res=false;
12220
              res=isfalse;
12221
            }
12221
            }
12222
          }
12222
          }
12223
  }
12223
  }
12224
  /* p2c: checkmol.pas, line 9828:
12224
  /* p2c: checkmol.pas, line 9828:
12225
  * Note: Turbo Pascal conditional compilation directive was ignored [218] */
12225
  * Note: Turbo Pascal conditional compilation directive was ignored [218] */
Line 12239... Line 12239...
12239
  /*ndl_ref_atom : integer;  (* since v0.3j as a global variable */
12239
  /*ndl_ref_atom : integer;  (* since v0.3j as a global variable */
12240
  int ndl_n_nb, ndl_n_hc, n_nb, n_hc;
12240
  int ndl_n_nb, ndl_n_hc, n_nb, n_hc;
12241
  boolean qm;                   /* v0.3l */
12241
  boolean qm;                   /* v0.3l */
12242
  /* check for NoStruct (0 atoms);  v0.3l */
12242
  /* check for NoStruct (0 atoms);  v0.3l */
12243
  if (n_atoms == 0 || ndl_n_atoms == 0) {
12243
  if (n_atoms == 0 || ndl_n_atoms == 0) {
12244
      matchresult = false;
12244
      matchresult = isfalse;
12245
  /* p2c: checkmol.pas, line 9849:
12245
  /* p2c: checkmol.pas, line 9849:
12246
  * Note: Turbo Pascal conditional compilation directive was ignored [218] */
12246
  * Note: Turbo Pascal conditional compilation directive was ignored [218] */
12247
      /*$IFDEF debug */
12247
      /*$IFDEF debug */
12248
      //debugoutput ("NoStruct encountered - aborted match routine");
12248
      //debugoutput ("NoStruct encountered - aborted match routine");
12249
      /*$ENDIF */
12249
      /*$ENDIF */
Line 12251... Line 12251...
12251
  }
12251
  }
12252
  /* if we perform an exact match, needle and haystack must have */
12252
  /* if we perform an exact match, needle and haystack must have */
12253
  /* the same number of atoms, bonds, and rings */
12253
  /* the same number of atoms, bonds, and rings */
12254
  if (opt_exact && opt_iso)     /* 0.3x */ {
12254
  if (opt_exact && opt_iso)     /* 0.3x */ {
12255
      if (n_heavyatoms != ndl_n_heavyatoms || n_heavybonds != ndl_n_heavybonds) {
12255
      if (n_heavyatoms != ndl_n_heavyatoms || n_heavybonds != ndl_n_heavybonds) {
12256
              matchresult = false;
12256
              matchresult = isfalse;
12257
      /* p2c: checkmol.pas, line 9861:
12257
      /* p2c: checkmol.pas, line 9861:
12258
      * Note: Turbo Pascal conditional compilation directive was ignored [218] */
12258
      * Note: Turbo Pascal conditional compilation directive was ignored [218] */
12259
          /*$IFDEF debug */
12259
          /*$IFDEF debug */
12260
          //debugoutput ("different number of heavy atoms and/or bonds");
12260
          //debugoutput ("different number of heavy atoms and/or bonds");
12261
          /*$ENDIF */
12261
          /*$ENDIF */
Line 12264... Line 12264...
12264
  }
12264
  }
12265
 
12265
 
12266
  /* have a quick look if needle and haystack are identical molfiles */
12266
  /* have a quick look if needle and haystack are identical molfiles */
12267
  qm = quick_match ();          /* v0.3l */
12267
  qm = quick_match ();          /* v0.3l */
12268
  if (qm) {
12268
  if (qm) {
12269
    matchresult = true;
12269
    matchresult = istrue;
12270
    clear_ndl_atom_tags ();     /* v0.3o */
12270
    clear_ndl_atom_tags ();     /* v0.3o */
12271
    return;
12271
    return;
12272
  }
12272
  }
12273
  /* if we have only one heavy atom and quick_match fails, return "false";  v0.3l */
12273
  /* if we have only one heavy atom and quick_match fails, return "isfalse";  v0.3l */
12274
  if (ndl_n_heavyatoms == 1) {
12274
  if (ndl_n_heavyatoms == 1) {
12275
    matchresult = false;
12275
    matchresult = isfalse;
12276
    return;
12276
    return;
12277
  }
12277
  }
12278
  /* p2c: checkmol.pas, line 9881:
12278
  /* p2c: checkmol.pas, line 9881:
12279
  * Note: Turbo Pascal conditional compilation directive was ignored [218] */
12279
  * Note: Turbo Pascal conditional compilation directive was ignored [218] */
12280
  /*$IFDEF debug */
12280
  /*$IFDEF debug */
Line 12285... Line 12285...
12285
  /* p2c: checkmol.pas, line 9886:
12285
  /* p2c: checkmol.pas, line 9886:
12286
  * Note: Turbo Pascal conditional compilation directive was ignored [218] */
12286
  * Note: Turbo Pascal conditional compilation directive was ignored [218] */
12287
  /*$IFDEF debug */
12287
  /*$IFDEF debug */
12288
  /* debugoutput('neighbor atoms: '+inttostr(ndl_n_nb)+'  heteroatom neighbors: '+inttostr(ndl_n_hc)); */
12288
  /* debugoutput('neighbor atoms: '+inttostr(ndl_n_nb)+'  heteroatom neighbors: '+inttostr(ndl_n_hc)); */
12289
  /*$ENDIF */
12289
  /*$ENDIF */
12290
  matchresult = false;
12290
  matchresult = isfalse;
12291
  for (j = 0; j < max_matchpath_length; j++) {
12291
  for (j = 0; j < max_matchpath_length; j++) {
12292
    ndl_matchpath[j] = 0;
12292
    ndl_matchpath[j] = 0;
12293
    hst_matchpath[j] = 0;
12293
    hst_matchpath[j] = 0;
12294
  }
12294
  }
12295
  ndl_matchpath[0] = ndl_ref_atom;
12295
  ndl_matchpath[0] = ndl_ref_atom;
12296
  while (i < n_atoms && matchresult == false) {
12296
  while (i < n_atoms && matchresult == isfalse) {
12297
    i++;
12297
    i++;
12298
    n_nb = atom[i - 1].neighbor_count;
12298
    n_nb = atom[i - 1].neighbor_count;
12299
    n_hc = hetatom_count (i);
12299
    n_hc = hetatom_count (i);
12300
    if (n_nb >= ndl_n_nb && n_hc >= ndl_n_hc) {
12300
    if (n_nb >= ndl_n_nb && n_hc >= ndl_n_hc) {
12301
      /* p2c: checkmol.pas, line 9904:
12301
      /* p2c: checkmol.pas, line 9904:
Line 12311... Line 12311...
12311
       * Note: Turbo Pascal conditional compilation directive was ignored [218] */
12311
       * Note: Turbo Pascal conditional compilation directive was ignored [218] */
12312
          /*$IFDEF debug */
12312
          /*$IFDEF debug */
12313
          /* if matchresult then debugoutput('matching atom in haystack: '+inttostr(i)+' ('+atom^[i].atype+')'); */
12313
          /* if matchresult then debugoutput('matching atom in haystack: '+inttostr(i)+' ('+atom^[i].atype+')'); */
12314
          /*$ENDIF */
12314
          /*$ENDIF */
12315
      if (matchresult)  /* v0.3o; mark this fragment as matched */
12315
      if (matchresult)  /* v0.3o; mark this fragment as matched */
12316
        atom[i - 1].tag = true;
12316
        atom[i - 1].tag = istrue;
12317
          }
12317
          }
12318
  }
12318
  }
12319
}
12319
}
12320
 
12320
 
12321
static void clear_rings ()
12321
static void clear_rings ()
Line 12323... Line 12323...
12323
  int i, FORLIM;
12323
  int i, FORLIM;
12324
  n_rings = 0;
12324
  n_rings = 0;
12325
  memset (ring, 0, sizeof (ringlist));
12325
  memset (ring, 0, sizeof (ringlist));
12326
  for (i = 0; i < max_rings; i++) {                             /* new in v0.3 */
12326
  for (i = 0; i < max_rings; i++) {                             /* new in v0.3 */
12327
    ringprop[i].size = 0;
12327
    ringprop[i].size = 0;
12328
    ringprop[i].arom = false;
12328
    ringprop[i].arom = isfalse;
12329
    ringprop[i].envelope = false;
12329
    ringprop[i].envelope = isfalse;
12330
  }
12330
  }
12331
  if (n_atoms > 0) {
12331
  if (n_atoms > 0) {
12332
    FORLIM = n_atoms;
12332
    FORLIM = n_atoms;
12333
    for (i = 0; i < FORLIM; i++)
12333
    for (i = 0; i < FORLIM; i++)
12334
            atom[i].ring_count = 0;
12334
            atom[i].ring_count = 0;
Line 12412... Line 12412...
12412
  int FORLIM;
12412
  int FORLIM;
12413
  if (n_rings < 2)
12413
  if (n_rings < 2)
12414
    return;
12414
    return;
12415
  FORLIM = n_rings;
12415
  FORLIM = n_rings;
12416
  for (i = 1; i < FORLIM; i++) {
12416
  for (i = 1; i < FORLIM; i++) {
12417
    found_ring = false;
12417
    found_ring = isfalse;
12418
    j = 0;
12418
    j = 0;
12419
    pli = ringprop[i].size;     /* path_length(ring^[i]); */
12419
    pli = ringprop[i].size;     /* path_length(ring^[i]); */
12420
    while (j < i && found_ring == false) {
12420
    while (j < i && found_ring == isfalse) {
12421
            j++;
12421
            j++;
12422
            found_all_atoms = true;
12422
            found_all_atoms = istrue;
12423
            pl = ringprop[j - 1].size;  /* path_length(ring^[j]); */
12423
            pl = ringprop[j - 1].size;  /* path_length(ring^[j]); */
12424
            for (k = 0; k < pl; k++) {
12424
            for (k = 0; k < pl; k++) {
12425
              found_atom = false;
12425
              found_atom = isfalse;
12426
              a = ring[j - 1][k];
12426
              a = ring[j - 1][k];
12427
              for (l = 0; l < pli; l++) {
12427
              for (l = 0; l < pli; l++) {
12428
                      if (ring[i][l] == a)
12428
                      if (ring[i][l] == a)
12429
                        found_atom = true;
12429
                        found_atom = istrue;
12430
                    }
12430
                    }
12431
              if (found_atom == false)
12431
              if (found_atom == isfalse)
12432
                      found_all_atoms = false;
12432
                      found_all_atoms = isfalse;
12433
            }
12433
            }
12434
            if (found_all_atoms)
12434
            if (found_all_atoms)
12435
              found_ring = true;
12435
              found_ring = istrue;
12436
          }
12436
          }
12437
    if (found_ring)
12437
    if (found_ring)
12438
            ringprop[i].envelope = true;
12438
            ringprop[i].envelope = istrue;
12439
  }
12439
  }
12440
}
12440
}
12441
 
12441
 
12442
static void update_ringcount ()
12442
static void update_ringcount ()
12443
{
12443
{
Line 12445... Line 12445...
12445
  if (n_rings <= 0)
12445
  if (n_rings <= 0)
12446
    return;
12446
    return;
12447
  chk_envelopes ();
12447
  chk_envelopes ();
12448
  FORLIM = n_rings;
12448
  FORLIM = n_rings;
12449
  for (i = 0; i < FORLIM; i++) {
12449
  for (i = 0; i < FORLIM; i++) {
12450
      if (ringprop[i].envelope == false) {
12450
      if (ringprop[i].envelope == isfalse) {
12451
            pl = ringprop[i].size;      /* path_length(ring^[i]);  (* v0.3d */
12451
            pl = ringprop[i].size;      /* path_length(ring^[i]);  (* v0.3d */
12452
            a2 = ring[i][pl - 1];
12452
            a2 = ring[i][pl - 1];
12453
            for (j = 0; j < pl; j++) {
12453
            for (j = 0; j < pl; j++) {
12454
              a1 = ring[i][j];
12454
              a1 = ring[i][j];
12455
              atom[a1 - 1].ring_count++;
12455
              atom[a1 - 1].ring_count++;
Line 12465... Line 12465...
12465
{
12465
{
12466
  /* v0.3k */
12466
  /* v0.3k */
12467
  /* changed from a procedure into a function in v0.3m */
12467
  /* changed from a procedure into a function in v0.3m */
12468
  int i, a1, a2, fc1, fc2;
12468
  int i, a1, a2, fc1, fc2;
12469
  char bt;
12469
  char bt;
12470
  boolean res = false;          /* v0.3m */
12470
  boolean res = isfalse;                /* v0.3m */
12471
  int FORLIM;
12471
  int FORLIM;
12472
  /* v0.3m */
12472
  /* v0.3m */
12473
  if (n_bonds == 0)
12473
  if (n_bonds == 0)
12474
    return false;
12474
    return isfalse;
12475
  FORLIM = n_bonds;
12475
  FORLIM = n_bonds;
12476
  for (i = 0; i < FORLIM; i++) {
12476
  for (i = 0; i < FORLIM; i++) {
12477
    a1 = bond[i].a1;
12477
    a1 = bond[i].a1;
12478
    a2 = bond[i].a2;
12478
    a2 = bond[i].a2;
12479
    bt = bond[i].btype;
12479
    bt = bond[i].btype;
Line 12488... Line 12488...
12488
              strcpy (atom[a2 - 1].atype, "N3 ");
12488
              strcpy (atom[a2 - 1].atype, "N3 ");
12489
            if (bt == 'D')
12489
            if (bt == 'D')
12490
              bond[i].btype = 'T';
12490
              bond[i].btype = 'T';
12491
            if (bt == 'S')
12491
            if (bt == 'S')
12492
              bond[i].btype = 'D';
12492
              bond[i].btype = 'D';
12493
            res = true;         /* v0.3m */
12493
            res = istrue;               /* v0.3m */
12494
          }
12494
          }
12495
  }
12495
  }
12496
  return res;                   /* v0.3m (return true if any change was made */
12496
  return res;                   /* v0.3m (return istrue if any change was made */
12497
}
12497
}
12498
 
12498
 
12499
#if 0
12499
#if 0
12500
static void chk_wildcard_rings ()               // new in v0.3p
12500
static void chk_wildcard_rings ()               // new in v0.3p
12501
// checks if there are any wildcard atom types or bond types
12501
// checks if there are any wildcard atom types or bond types
Line 12508... Line 12508...
12508
  int a1, a2, b;
12508
  int a1, a2, b;
12509
  boolean wcr;
12509
  boolean wcr;
12510
  str3 at;
12510
  str3 at;
12511
  char bt;
12511
  char bt;
12512
 
12512
 
12513
  if (ndl_querymol == false)
12513
  if (ndl_querymol == isfalse)
12514
    return;
12514
    return;
12515
  if (ndl_n_rings == 0)
12515
  if (ndl_n_rings == 0)
12516
    return;
12516
    return;
12517
  // now look for any not-yet-aromatic rings which contain a wildcard
12517
  // now look for any not-yet-aromatic rings which contain a wildcard
12518
  for (i = 0; i < ndl_n_rings; i++) {
12518
  for (i = 0; i < ndl_n_rings; i++) {
12519
    wcr = false;
12519
    wcr = isfalse;
12520
    if (ndl_ringprop[i].arom == false) {
12520
    if (ndl_ringprop[i].arom == isfalse) {
12521
            rs = ndl_ringprop[i].size;
12521
            rs = ndl_ringprop[i].size;
12522
            a2 = ndl_ring[i][rs];
12522
            a2 = ndl_ring[i][rs];
12523
            for (j = 0; j < rs; j++) {
12523
            for (j = 0; j < rs; j++) {
12524
              a1 = ndl_ring[i][j];
12524
              a1 = ndl_ring[i][j];
12525
              b = get_ndl_bond (a1, a2);
12525
              b = get_ndl_bond (a1, a2);
12526
              strcpy (at, ndl_atom[a1].atype);
12526
              strcpy (at, ndl_atom[a1].atype);
12527
              bt = ndl_bond[b].btype;
12527
              bt = ndl_bond[b].btype;
12528
              if (!strcmp (at, "A  ") || !strcmp (at, "Q  "))
12528
              if (!strcmp (at, "A  ") || !strcmp (at, "Q  "))
12529
                      wcr = true;
12529
                      wcr = istrue;
12530
              if (bt == 'l' || bt == 's' || bt == 'd' || bt == 'a')
12530
              if (bt == 'l' || bt == 's' || bt == 'd' || bt == 'a')
12531
                      wcr = true;
12531
                      wcr = istrue;
12532
              a2 = a1;
12532
              a2 = a1;
12533
            }
12533
            }
12534
            if (wcr) {                  // if yes, flag all atoms and bonds in this ring as "potentially" aromatic
12534
            if (wcr) {                  // if yes, flag all atoms and bonds in this ring as "potentially" aromatic
12535
              // {$IFDEF debug}
12535
              // {$IFDEF debug}
12536
              // debugoutput('wildcard ring found');
12536
              // debugoutput('wildcard ring found');
Line 12539... Line 12539...
12539
              for (j = 0; j < rs; j++) {
12539
              for (j = 0; j < rs; j++) {
12540
                      a1 = ndl_ring[i][j];
12540
                      a1 = ndl_ring[i][j];
12541
                      b = get_ndl_bond (a1, a2);
12541
                      b = get_ndl_bond (a1, a2);
12542
                      strcpy (at, ndl_atom[a1].atype);
12542
                      strcpy (at, ndl_atom[a1].atype);
12543
                      bt = ndl_bond[b].btype;
12543
                      bt = ndl_bond[b].btype;
12544
                      ndl_atom[a1].q_arom = true;
12544
                      ndl_atom[a1].q_arom = istrue;
12545
                      ndl_bond[b].q_arom = true;
12545
                      ndl_bond[b].q_arom = istrue;
12546
                      a2 = a1;
12546
                      a2 = a1;
12547
                    }
12547
                    }
12548
            }
12548
            }
12549
          }
12549
          }
12550
  }
12550
  }
12551
  // and now undo this flagging for all rings which contain no wildcard
12551
  // and now undo this flagging for all rings which contain no wildcard
12552
  for (i = 0; i < ndl_n_rings; i++) {
12552
  for (i = 0; i < ndl_n_rings; i++) {
12553
    wcr = false;
12553
    wcr = isfalse;
12554
    rs = ndl_ringprop[i].size;
12554
    rs = ndl_ringprop[i].size;
12555
    a2 = ndl_ring[i][rs];
12555
    a2 = ndl_ring[i][rs];
12556
    for (j = 0; j < rs; j++) {
12556
    for (j = 0; j < rs; j++) {
12557
            a1 = ndl_ring[i][j];
12557
            a1 = ndl_ring[i][j];
12558
            b = get_ndl_bond (a1, a2);
12558
            b = get_ndl_bond (a1, a2);
12559
            strcpy (at, ndl_atom[a1].atype);
12559
            strcpy (at, ndl_atom[a1].atype);
12560
            bt = ndl_bond[b].btype;
12560
            bt = ndl_bond[b].btype;
12561
            if (!strcmp (at, "A  ") || !strcmp (at, "Q  "))
12561
            if (!strcmp (at, "A  ") || !strcmp (at, "Q  "))
12562
              wcr = true;
12562
              wcr = istrue;
12563
            if (bt == 'l' || bt == 's' || bt == 'd' || bt == 'a')
12563
            if (bt == 'l' || bt == 's' || bt == 'd' || bt == 'a')
12564
              wcr = true;
12564
              wcr = istrue;
12565
            a2 = a1;
12565
            a2 = a1;
12566
          }
12566
          }
12567
    if (!wcr) {                 // if yes, unflag all atoms and bonds in this ring
12567
    if (!wcr) {                 // if yes, unflag all atoms and bonds in this ring
12568
            a2 = ndl_ring[i][rs];
12568
            a2 = ndl_ring[i][rs];
12569
            for (j = 0; j < rs; j++) {
12569
            for (j = 0; j < rs; j++) {
12570
              a1 = ndl_ring[i][j];
12570
              a1 = ndl_ring[i][j];
12571
              b = get_ndl_bond (a1, a2);
12571
              b = get_ndl_bond (a1, a2);
12572
              strcpy (at, ndl_atom[a1].atype);
12572
              strcpy (at, ndl_atom[a1].atype);
12573
              bt = ndl_bond[b].btype;
12573
              bt = ndl_bond[b].btype;
12574
              ndl_atom[a1].q_arom = false;
12574
              ndl_atom[a1].q_arom = isfalse;
12575
              ndl_bond[b].q_arom = false;
12575
              ndl_bond[b].q_arom = isfalse;
12576
              a2 = a1;
12576
              a2 = a1;
12577
            }
12577
            }
12578
          }
12578
          }
12579
  }
12579
  }
12580
  // some further refinement would be necessary here in order to unflag everything
12580
  // some further refinement would be necessary here in order to unflag everything
Line 12664... Line 12664...
12664
    FORLIM = molbufindex;
12664
    FORLIM = molbufindex;
12665
    for (i = 1; i <= FORLIM; i++)
12665
    for (i = 1; i <= FORLIM; i++)
12666
            puts (molbuf[i - 1]);
12666
            puts (molbuf[i - 1]);
12667
    exit (3);
12667
    exit (3);
12668
  }
12668
  }
12669
  mol_OK = true;                /* added in v0.2i */
12669
  mol_OK = istrue;              /* added in v0.2i */
12670
  if (!strcmp (filetype, "alchemy"))
12670
  if (!strcmp (filetype, "alchemy"))
12671
    read_molfile (ndl_molfilename);
12671
    read_molfile (ndl_molfilename);
12672
  if (!strcmp (filetype, "sybyl"))
12672
  if (!strcmp (filetype, "sybyl"))
12673
    read_mol2file (ndl_molfilename);
12673
    read_mol2file (ndl_molfilename);
12674
  if (!strcmp (filetype, "mdl"))
12674
  if (!strcmp (filetype, "mdl"))
Line 12695... Line 12695...
12695
    if (n_rings >= max_rings) {
12695
    if (n_rings >= max_rings) {
12696
            if (opt_verbose)
12696
            if (opt_verbose)
12697
              printf ("Warning: max. number of rings (%i) reached, reverting to SSR search\n",
12697
              printf ("Warning: max. number of rings (%i) reached, reverting to SSR search\n",
12698
                 max_rings);
12698
                 max_rings);
12699
            ringsearch_mode = rs_ssr;
12699
            ringsearch_mode = rs_ssr;
12700
            auto_ssr = true;    /* v0.3n */
12700
            auto_ssr = istrue;  /* v0.3n */
12701
            clear_rings ();
12701
            clear_rings ();
12702
            max_vringsize = ssr_vringsize;      /* v0.3n (was: 10) */
12702
            max_vringsize = ssr_vringsize;      /* v0.3n (was: 10) */
12703
            chk_ringbonds ();
12703
            chk_ringbonds ();
12704
            remove_redundant_rings ();
12704
            remove_redundant_rings ();
12705
          }
12705
          }
Line 12747... Line 12747...
12747
                printf ("input structure contains query atom or query bond!\n");
12747
                printf ("input structure contains query atom or query bond!\n");
12748
                exit (1);
12748
                exit (1);
12749
            }
12749
            }
12750
            chk_functionalgroups ();
12750
            chk_functionalgroups ();
12751
            if (opt_none)
12751
            if (opt_none)
12752
              opt_text = true;
12752
              opt_text = istrue;
12753
            if (opt_text)
12753
            if (opt_text)
12754
              write_fg_text ();
12754
              write_fg_text ();
12755
            if (opt_text_de)
12755
            if (opt_text_de)
12756
              write_fg_text_de ();
12756
              write_fg_text_de ();
12757
            if (opt_code)
12757
            if (opt_code)
Line 12800... Line 12800...
12800
            /* v0.3n (was: 10) */
12800
            /* v0.3n (was: 10) */
12801
            readinputfile (molfilename);
12801
            readinputfile (molfilename);
12802
            li = 1;
12802
            li = 1;
12803
            get_filetype (filetype, molfilename);
12803
            get_filetype (filetype, molfilename);
12804
            if (strcmp (filetype, "unknown")) {
12804
            if (strcmp (filetype, "unknown")) {
12805
              found_arominfo = false;   /* added in v0.2b */
12805
              found_arominfo = isfalse; /* added in v0.2b */
12806
              mol_OK = true;    /* added in v0.2i */
12806
              mol_OK = istrue;  /* added in v0.2i */
12807
              if (!strcmp (filetype, "alchemy"))
12807
              if (!strcmp (filetype, "alchemy"))
12808
                      read_molfile (molfilename);
12808
                      read_molfile (molfilename);
12809
              if (!strcmp (filetype, "sybyl"))
12809
              if (!strcmp (filetype, "sybyl"))
12810
                      read_mol2file (molfilename);
12810
                      read_mol2file (molfilename);
12811
              if (!strcmp (filetype, "mdl"))
12811
              if (!strcmp (filetype, "mdl"))
Line 12891... Line 12891...
12891
                            }   /* v0.3m */
12891
                            }   /* v0.3m */
12892
                      /* now that we have both molecules, perform the comparison */
12892
                      /* now that we have both molecules, perform the comparison */
12893
                      /* v0.3o: takes care of disconnected fragment... */
12893
                      /* v0.3o: takes care of disconnected fragment... */
12894
                      clear_atom_tags ();
12894
                      clear_atom_tags ();
12895
                      set_ndl_atom_tags ();
12895
                      set_ndl_atom_tags ();
12896
                      matchsummary = true;
12896
                      matchsummary = istrue;
12897
                      perform_match ();
12897
                      perform_match ();
12898
                      matchsummary = matchresult;
12898
                      matchsummary = matchresult;
12899
                      if (count_tagged_ndl_heavyatoms () > 0 && matchsummary == true) {
12899
                      if (count_tagged_ndl_heavyatoms () > 0 && matchsummary == istrue) {
12900
                              do {
12900
                              do {
12901
                                if (rs_strict)
12901
                                if (rs_strict)
12902
                                        ndl_ref_atom = find_ndl_ref_atom_cv ();
12902
                                        ndl_ref_atom = find_ndl_ref_atom_cv ();
12903
                                else
12903
                                else
12904
                                        ndl_ref_atom = find_ndl_ref_atom ();
12904
                                        ndl_ref_atom = find_ndl_ref_atom ();
12905
                                perform_match ();
12905
                                perform_match ();
12906
                                if (matchresult == false)
12906
                                if (matchresult == isfalse)
12907
                                        matchsummary = false;
12907
                                        matchsummary = isfalse;
12908
                              }
12908
                              }
12909
                              while (count_tagged_ndl_heavyatoms () != 0 && matchsummary != false);
12909
                              while (count_tagged_ndl_heavyatoms () != 0 && matchsummary != isfalse);
12910
                            }
12910
                            }
12911
                      /* end of disconnected-fragment matching (v0.3o) */
12911
                      /* end of disconnected-fragment matching (v0.3o) */
12912
                      if (matchsummary == true) {       /* v0.3o */
12912
                      if (matchsummary == istrue) {     /* v0.3o */
12913
                              if (opt_molout) {
12913
                              if (opt_molout) {
12914
                                FORLIM = molbufindex;
12914
                                FORLIM = molbufindex;
12915
                                for (i = 1; i <= FORLIM; i++)
12915
                                for (i = 1; i <= FORLIM; i++)
12916
                                        puts (molbuf[i - 1]);
12916
                                        puts (molbuf[i - 1]);
12917
                              }
12917
                              }
Line 12919... Line 12919...
12919
                                if (!opt_fp)    /* inttostr(mol_count) REPLACE!!!, */
12919
                                if (!opt_fp)    /* inttostr(mol_count) REPLACE!!!, */
12920
                                        printf ("%i:T\n", mol_count);
12920
                                        printf ("%i:T\n", mol_count);
12921
                                else {
12921
                                else {
12922
                                        if (ndl_n_heavyatoms == n_heavyatoms &&
12922
                                        if (ndl_n_heavyatoms == n_heavyatoms &&
12923
                                            ndl_n_heavybonds == n_heavybonds)
12923
                                            ndl_n_heavybonds == n_heavybonds)
12924
                                          fp_exacthit = true;
12924
                                          fp_exacthit = istrue;
12925
                                        else
12925
                                        else
12926
                                          fp_exacthit = false;
12926
                                          fp_exacthit = isfalse;
12927
                                        if (fp_exacthit)
12927
                                        if (fp_exacthit)
12928
                                          fp_exactblock = true;
12928
                                          fp_exactblock = istrue;
12929
                                        if (fpformat == fpf_boolean) {
12929
                                        if (fpformat == fpf_boolean) {
12930
                                          if (fp_exacthit)      /* inttostr(mol_count), REPACE!!! */
12930
                                          if (fp_exacthit)      /* inttostr(mol_count), REPACE!!! */
12931
                                                  printf ("%i:TX\n", mol_count);
12931
                                                  printf ("%i:TX\n", mol_count);
12932
                                          else
12932
                                          else
12933
                                                  printf ("%i:T\n", mol_count);
12933
                                                  printf ("%i:T\n", mol_count);
Line 12952... Line 12952...
12952
                              if (fp_exactblock)
12952
                              if (fp_exactblock)
12953
                                fpdecimal++;
12953
                                fpdecimal++;
12954
                              printf ("%lld\n", fpdecimal);
12954
                              printf ("%lld\n", fpdecimal);
12955
                              fpindex = 0;
12955
                              fpindex = 0;
12956
                              fpdecimal = 0;
12956
                              fpdecimal = 0;
12957
                              fp_exactblock = false;
12957
                              fp_exactblock = isfalse;
12958
                            }
12958
                            }
12959
                      zap_molecule ();
12959
                      zap_molecule ();
12960
                      molbufindex = 0;
12960
                      molbufindex = 0;
12961
                    }
12961
                    }
12962
                  }
12962
                  }
Line 12965... Line 12965...
12965
            /* v0.3l */
12965
            /* v0.3l */
12966
            /* mol_OK */
12966
            /* mol_OK */
12967
            printf ("%i:unknown file format\n", mol_count);
12967
            printf ("%i:unknown file format\n", mol_count);
12968
          }
12968
          }
12969
        }
12969
        }
12970
  while (mol_in_queue != false);
12970
  while (mol_in_queue != isfalse);
12971
    /* if filetype <> 'unknown' */
12971
    /* if filetype <> 'unknown' */
12972
    if (opt_fp && fpformat == fpf_decimal && fpindex > 0) {
12972
    if (opt_fp && fpformat == fpf_decimal && fpindex > 0) {
12973
            if (fp_exactblock)
12973
            if (fp_exactblock)
12974
              fpdecimal++;
12974
              fpdecimal++;
12975
            printf ("%lld\n", fpdecimal);
12975
            printf ("%lld\n", fpdecimal);
Line 12992... Line 12992...
12992
{
12992
{
12993
 
12993
 
12994
//printf("init_globals_dll\n");
12994
//printf("init_globals_dll\n");
12995
 
12995
 
12996
  int i;
12996
  int i;
12997
  opt_verbose = false;
12997
  opt_verbose = isfalse;
12998
  opt_debug = false;
12998
  opt_debug = isfalse;
12999
  opt_stdin = false;
12999
  opt_stdin = isfalse;
13000
  opt_text = false;
13000
  opt_text = isfalse;
13001
  opt_code = false;
13001
  opt_code = isfalse;
13002
  opt_bin = false;
13002
  opt_bin = isfalse;
13003
  opt_bitstring = false;
13003
  opt_bitstring = isfalse;
13004
  opt_molout = false;
13004
  opt_molout = isfalse;
13005
  opt_molstat = false;
13005
  opt_molstat = isfalse;
13006
  opt_molstat_X = false;
13006
  opt_molstat_X = isfalse;
13007
  opt_xmdlout = false;
13007
  opt_xmdlout = isfalse;
13008
  opt_fp = false;               /* new in v0.3m */
13008
  opt_fp = isfalse;             /* new in v0.3m */
13009
  /*cm_mdlmolfile   := false; */
13009
  /*cm_mdlmolfile   := isfalse; */
13010
  found_arominfo = false;
13010
  found_arominfo = isfalse;
13011
  found_querymol = false;
13011
  found_querymol = isfalse;
13012
  ndl_querymol = false;
13012
  ndl_querymol = isfalse;
13013
  opt_rs = rs_sar;              /* v0.3i */
13013
  opt_rs = rs_sar;              /* v0.3i */
13014
  ringsearch_mode = opt_rs;
13014
  ringsearch_mode = opt_rs;
13015
  rfile_is_open = false;        /* new in v0.2g */
13015
  rfile_is_open = isfalse;      /* new in v0.2g */
13016
  ez_flag = false;              /* new in v0.3f */
13016
  ez_flag = isfalse;            /* new in v0.3f */
13017
  chir_flag = false;            /* new in v0.3f */
13017
  chir_flag = isfalse;          /* new in v0.3f */
13018
  n_Ctot = 0;
13018
  n_Ctot = 0;
13019
  n_Otot = 0;
13019
  n_Otot = 0;
13020
  n_Ntot = 0;                   /* new in v0.3g */
13020
  n_Ntot = 0;                   /* new in v0.3g */
13021
  //for (i = 0; i < max_fg; i++)
13021
  //for (i = 0; i < max_fg; i++)
13022
  //  fg[i] = false;
13022
  //  fg[i] = isfalse;
13023
  memset (fg, 0, sizeof (fglist));
13023
  memset (fg, 0, sizeof (fglist));
13024
 
13024
 
13025
  if (!yet_initialized) {
13025
  if (!yet_initialized) {
13026
    molbuf = (void *) safe_malloc (sizeof (molbuftype));
13026
    molbuf = (void *) safe_malloc (sizeof (molbuftype));
13027
    opt_exact = false;
13027
    opt_exact = isfalse;
13028
    opt_strict = false; /* new in v0.2f */
13028
    opt_strict = isfalse;       /* new in v0.2f */
13029
    opt_metalrings = false;     /* new in v0.3 */
13029
    opt_metalrings = isfalse;   /* new in v0.3 */
13030
    opt_geom = false;           /* new in v0.3d */
13030
    opt_geom = isfalse;         /* new in v0.3d */
13031
    opt_chiral = false; /* new in v0.3f */
13031
    opt_chiral = isfalse;       /* new in v0.3f */
13032
    opt_iso = false;            /* new in v0.3x */
13032
    opt_iso = isfalse;          /* new in v0.3x */
13033
    opt_chg = false;            /* new in v0.3x */
13033
    opt_chg = isfalse;          /* new in v0.3x */
13034
    opt_rad = false;            /* new in v0.3x */
13034
    opt_rad = isfalse;          /* new in v0.3x */
13035
    ez_search = false;  /* new in v0.3d */
13035
    ez_search = isfalse;        /* new in v0.3d */
13036
    rs_search = false;  /* new in v0.3f */
13036
    rs_search = isfalse;        /* new in v0.3f */
13037
    rs_strict = false;  /* new in v0.3j */
13037
    rs_strict = isfalse;        /* new in v0.3j */
13038
    ndl_n_Ctot = 0;
13038
    ndl_n_Ctot = 0;
13039
    ndl_n_Otot = 0;
13039
    ndl_n_Otot = 0;
13040
    ndl_n_Ntot = 0;             /* new in v0.3g */
13040
    ndl_n_Ntot = 0;             /* new in v0.3g */
13041
    yet_initialized = true;
13041
    yet_initialized = istrue;
13042
  }
13042
  }
13043
 
13043
 
13044
  ether_generic = false;        /* v0.3j */
13044
  ether_generic = isfalse;      /* v0.3j */
13045
  amine_generic = false;        /* v0.3j */
13045
  amine_generic = isfalse;      /* v0.3j */
13046
  hydroxy_generic = false;      /* v0.3j */
13046
  hydroxy_generic = isfalse;    /* v0.3j */
13047
  fpformat = fpf_decimal;       /* v0.3m */
13047
  fpformat = fpf_decimal;       /* v0.3m */
13048
  fpindex = 0;                  /* v0.3m */
13048
  fpindex = 0;                  /* v0.3m */
13049
  fp_exacthit = false;          /* v0.3m */
13049
  fp_exacthit = isfalse;                /* v0.3m */
13050
  fp_exactblock = false;        /* v0.3m */
13050
  fp_exactblock = isfalse;      /* v0.3m */
13051
  tmfcode = 0;                  /* v0.3m */
13051
  tmfcode = 0;                  /* v0.3m */
13052
  tmfmismatch = false;          /* v0.3m */
13052
  tmfmismatch = isfalse;                /* v0.3m */
13053
  auto_ssr = false;
13053
  auto_ssr = isfalse;
13054
  recursion_depth = 0;
13054
  recursion_depth = 0;
13055
}
13055
}
13056
 
13056
 
13057
static void mm_init_mol ( )
13057
static void mm_init_mol ( )
13058
{
13058
{
Line 13089... Line 13089...
13089
  if (strcmp (filetype, "unknown") == 0) {
13089
  if (strcmp (filetype, "unknown") == 0) {
13090
    //messagebox (0,'Error in mm_ElabMol: Unknown file format','MATCHMOLDLL ERROR',0);
13090
    //messagebox (0,'Error in mm_ElabMol: Unknown file format','MATCHMOLDLL ERROR',0);
13091
    exit (3);
13091
    exit (3);
13092
  }
13092
  }
13093
 
13093
 
13094
  if (checkmol_mode == true)
13094
  if (checkmol_mode == istrue)
13095
    progmode = pmCheckMol;
13095
    progmode = pmCheckMol;
13096
  else
13096
  else
13097
    progmode = pmMatchMol;
13097
    progmode = pmMatchMol;
13098
  if (strcmp (filetype, "alchemy") == 0)
13098
  if (strcmp (filetype, "alchemy") == 0)
13099
    read_molfile (ndl_molfilename);
13099
    read_molfile (ndl_molfilename);
Line 13115... Line 13115...
13115
            remove_redundant_rings ();
13115
            remove_redundant_rings ();
13116
    if (n_rings >= max_rings) {
13116
    if (n_rings >= max_rings) {
13117
            printf ("Warning: max. number of rings (%i) reached, reverting to SSR search\n",
13117
            printf ("Warning: max. number of rings (%i) reached, reverting to SSR search\n",
13118
               max_rings);
13118
               max_rings);
13119
            ringsearch_mode = rs_ssr;
13119
            ringsearch_mode = rs_ssr;
13120
            auto_ssr = true;
13120
            auto_ssr = istrue;
13121
            clear_rings ();
13121
            clear_rings ();
13122
            max_vringsize = ssr_vringsize;
13122
            max_vringsize = ssr_vringsize;
13123
            chk_ringbonds ();
13123
            chk_ringbonds ();
13124
            remove_redundant_rings ();
13124
            remove_redundant_rings ();
13125
          }
13125
          }
Line 13156... Line 13156...
13156
  //mm_ElabMol;
13156
  //mm_ElabMol;
13157
  copy_mol_to_needle ();
13157
  copy_mol_to_needle ();
13158
  //chk_wildcard_rings (); /* 0.3p */
13158
  //chk_wildcard_rings (); /* 0.3p */
13159
  set_ndl_atom_tags ();         /* v0.3o */
13159
  set_ndl_atom_tags ();         /* v0.3o */
13160
  if (opt_geom)                 /* v0.3d */
13160
  if (opt_geom)                 /* v0.3d */
13161
    ez_search = true;
13161
    ez_search = istrue;
13162
  else if (!ez_flag && ez_search)
13162
  else if (!ez_flag && ez_search)
13163
    ez_search = false;          //chir_flag initialized in read_MDLmolfile, otherwise we lose that info
13163
    ez_search = isfalse;                //chir_flag initialized in read_MDLmolfile, otherwise we lose that info
13164
  if (opt_chiral) {                             /* v0.3f */
13164
  if (opt_chiral) {                             /* v0.3f */
13165
      rs_search = true;
13165
      rs_search = istrue;
13166
      //printf("%i\n",rs_search);
13166
      //printf("%i\n",rs_search);
13167
  }
13167
  }
13168
  else
13168
  else
13169
    if (!chir_flag && rs_search) {
13169
    if (!chir_flag && rs_search) {
13170
      rs_search = false;        //chir_flag initialized in read_MDLmolfile, otherwise we lose that info
13170
      rs_search = isfalse;      //chir_flag initialized in read_MDLmolfile, otherwise we lose that info
13171
      //printf("%i\n",rs_search);
13171
      //printf("%i\n",rs_search);
13172
    }
13172
    }
13173
  if (opt_chiral && opt_strict && opt_exact)    /* new in v0.3j */
13173
  if (opt_chiral && opt_strict && opt_exact)    /* new in v0.3j */
13174
    rs_strict = true;
13174
    rs_strict = istrue;
13175
  else
13175
  else
13176
    rs_strict = false;
13176
    rs_strict = isfalse;
13177
    /* if (rs_strict)              // v0.3j
13177
    /* if (rs_strict)              // v0.3j
13178
       ndl_ref_atom = find_ndl_ref_atom_cv ();
13178
       ndl_ref_atom = find_ndl_ref_atom_cv ();
13179
       //ndl_ref_atom = find_ndl_ref_atom ();
13179
       //ndl_ref_atom = find_ndl_ref_atom ();
13180
       else
13180
       else
13181
       ndl_ref_atom = find_ndl_ref_atom (); */
13181
       ndl_ref_atom = find_ndl_ref_atom (); */
Line 13225... Line 13225...
13225
{
13225
{
13226
//printf("mm_read_input_line_in\n");
13226
//printf("mm_read_input_line_in\n");
13227
//var
13227
//var
13228
//yyy:pchar;
13228
//yyy:pchar;
13229
 
13229
 
13230
  mol_in_queue = false;
13230
  mol_in_queue = isfalse;
13231
  if (molbufindex < (max_atoms + max_bonds + slack)) {
13231
  if (molbufindex < (max_atoms + max_bonds + slack)) {
13232
 
13232
 
13233
    //yyy:=Pchar(IntToStr(molbufindex));
13233
    //yyy:=Pchar(IntToStr(molbufindex));
13234
    //messagebox (0,yyy,'',0);
13234
    //messagebox (0,yyy,'',0);
13235
    //printf("%i\n",molbufindex);
13235
    //printf("%i\n",molbufindex);
Line 13294... Line 13294...
13294
//printf("mm_set_mol\n");
13294
//printf("mm_set_mol\n");
13295
}
13295
}
13296
 
13296
 
13297
DLLEXPORT void cm_set_mol (const char *st, int normalize_ionic_bnds)
13297
DLLEXPORT void cm_set_mol (const char *st, int normalize_ionic_bnds)
13298
{
13298
{
13299
  mm_set_mol_dll (st, true, (normalize_ionic_bnds != FEATURE_OFF));
13299
  mm_set_mol_dll (st, istrue, (normalize_ionic_bnds != FEATURE_OFF));
13300
}
13300
}
13301
 
13301
 
13302
DLLEXPORT void mm_set_mol (const char *st)
13302
DLLEXPORT void mm_set_mol (const char *st)
13303
{
13303
{
13304
  mm_set_mol_dll (st, false, true);
13304
  mm_set_mol_dll (st, isfalse, istrue);
13305
}
13305
}
13306
 
13306
 
13307
DLLEXPORT void xm_set_strict_typing (int strict_typing)
13307
DLLEXPORT void xm_set_strict_typing (int strict_typing)
13308
{
13308
{
13309
  if (!yet_initialized)
13309
  if (!yet_initialized)
13310
    init_globals_dll ();
13310
    init_globals_dll ();
13311
  opt_strict = (strict_typing != FEATURE_OFF);
13311
  opt_strict = (strict_typing != FEATURE_OFF);
13312
  //opt_strict=false; //This never worked right and is harmful
13312
  //opt_strict=isfalse; //This never worked right and is harmful
13313
}
13313
}
13314
 
13314
 
13315
DLLEXPORT void mm_set_r_s_check (int r_s_check)
13315
DLLEXPORT void mm_set_r_s_check (int r_s_check)
13316
{
13316
{
13317
  if (!yet_initialized)
13317
  if (!yet_initialized)
Line 13377... Line 13377...
13377
  //ndl_ref_atom = find_ndl_ref_atom ();
13377
  //ndl_ref_atom = find_ndl_ref_atom ();
13378
  else
13378
  else
13379
    ndl_ref_atom = find_ndl_ref_atom ();
13379
    ndl_ref_atom = find_ndl_ref_atom ();
13380
  clear_atom_tags ();
13380
  clear_atom_tags ();
13381
  set_ndl_atom_tags ();
13381
  set_ndl_atom_tags ();
13382
  matchsummary = true;
13382
  matchsummary = istrue;
13383
  perform_match ();
13383
  perform_match ();
13384
  matchsummary = matchresult;
13384
  matchsummary = matchresult;
13385
  if (count_tagged_ndl_heavyatoms () > 0 && matchsummary == true) {
13385
  if (count_tagged_ndl_heavyatoms () > 0 && matchsummary == istrue) {
13386
    do {
13386
    do {
13387
            if (rs_strict)
13387
            if (rs_strict)
13388
              ndl_ref_atom = find_ndl_ref_atom_cv ();
13388
              ndl_ref_atom = find_ndl_ref_atom_cv ();
13389
            else
13389
            else
13390
              ndl_ref_atom = find_ndl_ref_atom ();
13390
              ndl_ref_atom = find_ndl_ref_atom ();
13391
            perform_match ();
13391
            perform_match ();
13392
            if (matchresult == false)
13392
            if (matchresult == isfalse)
13393
             matchsummary = false;
13393
             matchsummary = isfalse;
13394
          }
13394
          }
13395
    while (count_tagged_ndl_heavyatoms () != 0 && matchsummary != false);
13395
    while (count_tagged_ndl_heavyatoms () != 0 && matchsummary != isfalse);
13396
  }
13396
  }
13397
 
13397
 
13398
  //-----------------------------------------------------
13398
  //-----------------------------------------------------
13399
 
13399
 
13400
  //mol_count = 0;
13400
  //mol_count = 0;