Subversion Repositories wimsdev

Rev

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

Rev 11128 Rev 14179
Line 2... Line 2...
2
   Modified to run w/o p2c libraries
2
   Modified to run w/o p2c libraries
3
   2007 Ernst-Georg Schmid
3
   2007 Ernst-Georg Schmid
4
   Modified to run as shared library
4
   Modified to run as shared library
5
   2007 Ernst-Georg Schmid
5
   2007 Ernst-Georg Schmid
6
   pgchem@tuschehund.de
6
   pgchem@tuschehund.de
7
   
7
 
8
   compile with gcc without optimizations (except -march= -mcpu=) or it gets SLOWER!
8
   compile with gcc without optimizations (except -march= -mcpu=) or it gets SLOWER!
9
   
9
 
10
   THIS VERSION HAS extended_molstat SWITCHED ON BY DEFAULT!
10
   THIS VERSION HAS extended_molstat SWITCHED ON BY DEFAULT!
11
   
11
 
12
   This file is part of the xchem::tigress project.
12
   This file is part of the xchem::tigress project.
13
 
13
 
14
   --- DUAL LICENSING ---
14
   --- DUAL LICENSING ---
15
   
15
 
16
   If checkmol.c aka. pgchem::barsoi is compiled as a library, it is released under the terms of the
16
   If checkmol.c aka. pgchem::barsoi is compiled as a library, it is released under the terms of the
17
   lesser GNU General Public License. For the executable, the original GPL
17
   lesser GNU General Public License. For the executable, the original GPL
18
   licensing applies!
18
   licensing applies!
19
   
19
 
20
   This program is free software; you can redistribute it and/or modify
20
   This program is free software; you can redistribute it and/or modify
21
   it under the terms of the lesser GNU General Public License as published by
21
   it under the terms of the lesser GNU General Public License as published by
22
   the Free Software Foundation version 2.1 of the License.
22
   the Free Software Foundation version 2.1 of the License.
23
 
23
 
24
   This program is distributed in the hope that it will be useful,
24
   This program is distributed in the hope that it will be useful,
25
   but WITHOUT ANY WARRANTY; without even the implied warranty of
25
   but WITHOUT ANY WARRANTY; without even the implied warranty of
26
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
26
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
27
   lesser GNU General Public License for more details.
27
   lesser GNU General Public License for more details.
28
   
28
 
29
   --- DUAL LICENSING ---
29
   --- DUAL LICENSING ---
30
 
30
 
31
   ORIGINAL HEADER:
31
   ORIGINAL HEADER:
32
   
32
 
33
checkmol/matchmol
33
checkmol/matchmol
34
Norbert Haider, University of Vienna, 2003-2007
34
Norbert Haider, University of Vienna, 2003-2007
35
norbert.haider@univie.ac.at
35
norbert.haider@univie.ac.at
36
 
36
 
37
This software is published under the terms of the GNU General Public
37
This software is published under the terms of the GNU General Public
Line 49... Line 49...
49
(the "needle") is a substructure of the second one (the "haystack").
49
(the "needle") is a substructure of the second one (the "haystack").
50
"Haystack" can also be a MDL SD-file (containing multiple MOL files);
50
"Haystack" can also be a MDL SD-file (containing multiple MOL files);
51
if invoked with "-" as file argument, both "needle" and "haystack" are
51
if invoked with "-" as file argument, both "needle" and "haystack" are
52
read as an SD-file from standard input, assuming the first entry in
52
read as an SD-file from standard input, assuming the first entry in
53
the SDF to be the "needle"; output: entry number + ":F" (false) or ":T" (true)
53
the SDF to be the "needle"; output: entry number + ":F" (false) or ":T" (true)
54
 
-
 
55
 
54
 
56
Compile with fpc (Free Pascal, see http://www.freepascal.org), using
55
Compile with fpc (Free Pascal, see http://www.freepascal.org), using
57
the -Sd or -S2 option (Delphi mode; IMPORTANT!)
56
the -Sd or -S2 option (Delphi mode; IMPORTANT!)
58
 
57
 
59
example for compilation (with optimization) and installation:
58
example for compilation (with optimization) and installation:
60
 
59
 
61
fpc checkmol.pas -S2 -Xs -OG -Or -O2u -Op1
60
fpc checkmol.pas -S2 -Xs -OG -Or -O2u -Op1
62
 
61
 
63
as "root", do the following:
62
as "root", do the following:
64
 
63
 
65
cp checkmol /usr/local/bin
64
cp checkmol /usr/local/bin
66
cd /usr/local/bin
65
cd /usr/local/bin
67
ln checkmol matchmol
66
ln checkmol matchmol
68
 
-
 
69
 
67
 
70
Version history
68
Version history
71
 
69
 
72
v0.1   extends "chkmol" utility (N. Haider, 2002), adds matching functionality;
70
v0.1   extends "chkmol" utility (N. Haider, 2002), adds matching functionality;
73
 
71
 
Line 267... Line 265...
267
       as aromatic if all bonds are of type 'A'; several minor bug fixes
265
       as aromatic if all bonds are of type 'A'; several minor bug fixes
268
 
266
 
269
v0.3o  minor changes in update_atypes (nitrogen); changed the matching
267
v0.3o  minor changes in update_atypes (nitrogen); changed the matching
270
       algorithm in order to take care of disconnected molecular graphs
268
       algorithm in order to take care of disconnected molecular graphs
271
       (e.g., salts); refined matching of atoms with formal charges
269
       (e.g., salts); refined matching of atoms with formal charges
272
 
-
 
273
 
270
 
274
Credits:
271
Credits:
275
 
272
 
276
Rami Jbara (rami_jbara@hotmail.com) designed the 8-character functional
273
Rami Jbara (rami_jbara@hotmail.com) designed the 8-character functional
277
group codes.
274
group codes.
278
 
275
 
279
I am also very grateful to Ernst-Georg Schmid (Bayer Business Services,
276
I am also very grateful to Ernst-Georg Schmid (Bayer Business Services,
280
Leverkusen/Germany) and to Howard Feldman (The Blueprint Initiative,
277
Leverkusen/Germany) and to Howard Feldman (The Blueprint Initiative,
281
Toronto/Canada) for numerous bug reports and suggestions for improvements.
278
Toronto/Canada) for numerous bug reports and suggestions for improvements.
282
 
-
 
283
 
-
 
284
 
279
 
285
===============================================================================
280
===============================================================================
286
DISCLAIMER
281
DISCLAIMER
287
This program is free software; you can redistribute it and/or
282
This program is free software; you can redistribute it and/or
288
modify it under the terms of the GNU General Public License
283
modify it under the terms of the GNU General Public License
289
as published by the Free Software Foundation; either version 2
284
as published by the Free Software Foundation; either version 2
290
of the License, or (at your option) any later version.
285
of the License, or (at your option) any later version.
291
 
286
 
292
This program is distributed in the hope that it will be useful,
287
This program is distributed in the hope that it will be useful,
293
but WITHOUT ANY WARRANTY; without even the implied warranty of
288
but WITHOUT ANY WARRANTY; without even the implied warranty of
294
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
289
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
295
GNU General Public License for more details.
290
GNU General Public License for more details.
296
 
291
 
Line 301... Line 296...
301
*/
296
*/
302
 
297
 
303
/* $DEFINE debug                    uncomment if desired */
298
/* $DEFINE debug                    uncomment if desired */
304
/* $DEFINE extended_molstat         uncomment if desired */
299
/* $DEFINE extended_molstat         uncomment if desired */
305
/* $DEFINE reduced_SAR              uncomment if desired */
300
/* $DEFINE reduced_SAR              uncomment if desired */
306
 
301
 
307
/* uses
302
/* uses
308
  SYSUTILS, MATH; */
303
  SYSUTILS, MATH; */
309
 
304
 
310
#include <stdlib.h>
305
#include <stdlib.h>
311
#include <stdio.h>
306
#include <stdio.h>
Line 586... Line 581...
586
#define fg_heterocycle  202
581
#define fg_heterocycle  202
587
#define fg_alpha_aminoacid  203
582
#define fg_alpha_aminoacid  203
588
#define fg_alpha_hydroxyacid  204
583
#define fg_alpha_hydroxyacid  204
589
 
584
 
590
typedef enum
585
typedef enum
591
{ false = 0, true } boolean;
586
  { false = 0, true } boolean;
592
 
-
 
593
 
587
 
594
typedef char str2[3];
588
typedef char str2[3];
595
 
589
 
596
typedef char str3[4];
590
typedef char str3[4];
597
 
591
 
598
typedef char str4[5];
592
typedef char str4[5];
599
 
593
 
600
typedef char str5[6];
594
typedef char str5[6];
601
 
595
 
602
typedef char str8[9];
596
typedef char str8[9];
603
 
597
 
604
typedef struct atom_rec
598
typedef struct atom_rec
605
{
599
{
606
  str2 element;
600
  str2 element;
607
  str3 atype;
601
  str3 atype;
608
  float x, y, z;
602
  float x, y, z;
609
  int formal_charge;
603
  int formal_charge;
610
  float real_charge;
604
  float real_charge;
611
  int Hexp;                     /* explicit H count */
605
  int Hexp;      /* explicit H count */
612
  int Htot;                     /* total H count */
606
  int Htot;      /* total H count */
613
  int neighbor_count, ring_count;
607
  int neighbor_count, ring_count;
614
  boolean arom, stereo_care;    /* new in v0.3d */
608
  boolean arom, stereo_care;  /* new in v0.3d */
615
  boolean q_arom;               // v0.3p potentially aromatic in a query structure
609
  boolean q_arom;    // v0.3p potentially aromatic in a query structure
616
  boolean heavy;                /* new in v0.3l */
610
  boolean heavy;    /* new in v0.3l */
617
  boolean metal;                /* new in v0.3l */
611
  boolean metal;    /* new in v0.3l */
618
  int nvalences;                /* new in v0.3m */
612
  int nvalences;    /* new in v0.3m */
619
  boolean tag;                  /* new in v0.3o */
613
  boolean tag;      /* new in v0.3o */
620
  int nucleon_number;           /* 0.3.x */
614
  int nucleon_number;   /* 0.3.x */
621
  int radical_type;             /* 0.3.x */
615
  int radical_type;             /* 0.3.x */
622
} atom_rec;
616
} atom_rec;
623
 
617
 
624
typedef struct bond_rec
618
typedef struct bond_rec
625
{
619
{
626
  int a1, a2;
620
  int a1, a2;
627
  char btype;
621
  char btype;
628
  int ring_count;
622
  int ring_count;
629
  boolean arom;
623
  boolean arom;
630
  boolean q_arom;               // v0.3p potentially aromatic in a query structure
624
  boolean q_arom;    // v0.3p potentially aromatic in a query structure
631
  int topo;                     /* new in v0.3d, see MDL file description */
625
  int topo;      /* new in v0.3d, see MDL file description */
632
  int stereo;                   /* new in v0.3d */
626
  int stereo;    /* new in v0.3d */
633
  int mdl_stereo;               /* new in v0.3n */
627
  int mdl_stereo;/* new in v0.3n */
634
} bond_rec;
628
} bond_rec;
635
 
629
 
636
typedef int ringpath_type[max_ringsize];
630
typedef int ringpath_type[max_ringsize];
637
typedef int matchpath_type[max_matchpath_length];
631
typedef int matchpath_type[max_matchpath_length];
638
 
632
 
639
typedef atom_rec atomlist[max_atoms];
633
typedef atom_rec atomlist[max_atoms];
640
typedef bond_rec bondlist[max_bonds];
634
typedef bond_rec bondlist[max_bonds];
641
typedef ringpath_type ringlist[max_rings];
635
typedef ringpath_type ringlist[max_rings];
642
typedef int neighbor_rec[max_neighbors];        /* new in v0.2h */
636
typedef int neighbor_rec[max_neighbors];  /* new in v0.2h */
643
typedef boolean fglist[max_fg];
637
typedef boolean fglist[max_fg];
644
 
638
 
645
typedef char molbuftype[max_atoms + max_bonds + slack][256];
639
typedef char molbuftype[max_atoms + max_bonds + slack][256];
646
 
640
 
647
typedef boolean matchmatrix[max_neighbors][max_neighbors];
641
typedef boolean matchmatrix[max_neighbors][max_neighbors];
648
    /* new in v0.2i */
642
    /* new in v0.2i */
649
 
643
 
650
typedef struct molstat_rec
644
typedef struct molstat_rec
651
{
645
{
652
  int n_QA, n_QB, n_chg;        /* number of query atoms, query bonds, charges */
646
  int n_QA, n_QB, n_chg;  /* number of query atoms, query bonds, charges */
653
  int n_C1, n_C2, n_C;
647
  int n_C1, n_C2, n_C;
654
  /* number of sp, sp2 hybridized, and total no. of carbons */
648
  /* number of sp, sp2 hybridized, and total no. of carbons */
655
  int n_CHB1p, n_CHB2p, n_CHB3p, n_CHB4;
649
  int n_CHB1p, n_CHB2p, n_CHB3p, n_CHB4;
656
  /* number of C atoms with at least 1, 2, 3 hetero bonds */
650
  /* number of C atoms with at least 1, 2, 3 hetero bonds */
657
  int n_O2, n_O3;               /* number of sp2 and sp3 oxygens */
651
  int n_O2, n_O3;    /* number of sp2 and sp3 oxygens */
658
  int n_N1, n_N2, n_N3;         /* number of sp, sp2, and sp3 nitrogens */
652
  int n_N1, n_N2, n_N3;    /* number of sp, sp2, and sp3 nitrogens */
659
  int n_S, n_SeTe;
653
  int n_S, n_SeTe;
660
  /* number of sulfur atoms and selenium or tellurium atoms */
654
  /* number of sulfur atoms and selenium or tellurium atoms */
661
  int n_F, n_Cl, n_Br, n_I;
655
  int n_F, n_Cl, n_Br, n_I;
662
  /* number of fluorine, chlorine, bromine, iodine atoms */
656
  /* number of fluorine, chlorine, bromine, iodine atoms */
663
  int n_P, n_B;                 /* number of phosphorus and boron atoms */
657
  int n_P, n_B;      /* number of phosphorus and boron atoms */
664
  int n_Met, n_X;
658
  int n_Met, n_X;
665
  /* number of metal and "other" atoms (not listed elsewhere); v0.3l */
659
  /* number of metal and "other" atoms (not listed elsewhere); v0.3l */
666
  int n_b1, n_b2, n_b3, n_bar;
660
  int n_b1, n_b2, n_b3, n_bar;
667
  /* number single, double, triple, and aromatic bonds */
661
  /* number single, double, triple, and aromatic bonds */
668
  int n_C1O, n_C2O, n_CN, n_XY;
662
  int n_C1O, n_C2O, n_CN, n_XY;
Line 676... Line 670...
676
  int n_rO, n_rO1, n_rO2p;
670
  int n_rO, n_rO1, n_rO2p;
677
  /* number of rings containing O (any number), 1 O, and 2 O or more */
671
  /* number of rings containing O (any number), 1 O, and 2 O or more */
678
  int n_rS, n_rX, n_rAr, n_rBz;
672
  int n_rS, n_rX, n_rAr, n_rBz;
679
  /* number of rings containing S (any number), any heteroatom (any number),  */
673
  /* number of rings containing S (any number), any heteroatom (any number),  */
680
  /* number of aromatic rings, number of benzene rings */
674
  /* number of aromatic rings, number of benzene rings */
681
  int n_br2p;                   /* number of bonds belonging to more than one ring (v0.3n) */
675
  int n_br2p;      /* number of bonds belonging to more than one ring (v0.3n) */
682
/* p2c: checkmol.pas, line 590:
676
  /* p2c: checkmol.pas, line 590:
683
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
677
    * Note: Turbo Pascal conditional compilation directive was ignored [218] */
684
  /*$IFDEF extended_molstat */
678
  /*$IFDEF extended_molstat */
685
  int n_psg01, n_psg02, n_psg13, n_psg14;
679
  int n_psg01, n_psg02, n_psg13, n_psg14;
686
  /* number of atoms belonging to elements of group 1, 2, etc.  */
680
  /* number of atoms belonging to elements of group 1, 2, etc.  */
687
  int n_psg15, n_psg16, n_psg17, n_psg18;
681
  int n_psg15, n_psg16, n_psg17, n_psg18;
688
  /* number of atoms belonging to elements of group 15, 16, etc.  */
682
  /* number of atoms belonging to elements of group 15, 16, etc.  */
Line 706... Line 700...
706
{
700
{
707
  /* new in v0.3d */
701
  /* new in v0.3d */
708
  double x, y, z;
702
  double x, y, z;
709
} p_3d;
703
} p_3d;
710
 
704
 
711
typedef int chirpath_type[4];   /* new in v0.3f */
705
typedef int chirpath_type[4];  /* new in v0.3f */
712
 
706
 
713
#ifdef MAKE_SHARED_LIBRARY
707
#ifdef MAKE_SHARED_LIBRARY
714
static boolean yet_initialized = false;
708
static boolean yet_initialized = false;
715
#endif
709
#endif
716
 
710
 
717
typedef struct connval_rec
711
typedef struct connval_rec
718
{
712
{
719
  /* new in v0.3j */
713
  /* new in v0.3j */
720
  int def;                      /* better as longint for large molecules? */
714
  int def;      /* better as longint for large molecules? */
721
  int tmp;
715
  int tmp;
722
} connval_rec;
716
} connval_rec;
723
 
717
 
724
typedef connval_rec connval_type[max_atoms];    /* new in v0.3j  */
718
typedef connval_rec connval_type[max_atoms];  /* new in v0.3j  */
725
 
-
 
726
 
719
 
727
static int progmode;
720
static int progmode;
728
static char progname[256];
721
static char progname[256];
729
 
722
 
730
#ifndef MAKE_SHARED_LIBRARY
723
#ifndef MAKE_SHARED_LIBRARY
731
static int i;                   /* general purpose index */
724
static int i;      /* general purpose index */
732
#endif
725
#endif
733
 
726
 
734
static int li;
727
static int li;
735
static boolean opt_none, opt_verbose, opt_text, opt_text_de, opt_code,
728
static boolean opt_none, opt_verbose, opt_text, opt_text_de, opt_code,
736
  opt_bin, opt_bitstring, opt_stdin, opt_exact, opt_debug,
729
  opt_bin, opt_bitstring, opt_stdin, opt_exact, opt_debug,
737
  opt_molout, opt_molstat, opt_molstat_X, opt_xmdlout, opt_strict;
730
  opt_molout, opt_molstat, opt_molstat_X, opt_xmdlout, opt_strict;
738
    /* new in v0.2f */
731
    /* new in v0.2f */
739
static boolean opt_metalrings;  /* new in v0.3 */
732
static boolean opt_metalrings;  /* new in v0.3 */
740
static boolean opt_geom;        /* new in v0.3d */
733
static boolean opt_geom;  /* new in v0.3d */
741
static boolean opt_chiral;      /* new in v0.3f */
734
static boolean opt_chiral;  /* new in v0.3f */
742
static boolean opt_iso;         /* new in v0.3x */
735
static boolean opt_iso;    /* new in v0.3x */
743
static boolean opt_chg;         /* new in v0.3x */
736
static boolean opt_chg;    /* new in v0.3x */
744
static boolean opt_rad;         /* new in v0.3x */
737
static boolean opt_rad;    /* new in v0.3x */
745
static int opt_rs;              /* new in v0.3i */
738
static int opt_rs;    /* new in v0.3i */
746
 
739
 
747
#ifdef MAKE_SHARED_LIBRARY
740
#ifdef MAKE_SHARED_LIBRARY
748
static int opt_rs_dll = RPA_DEFAULT;
741
static int opt_rs_dll = RPA_DEFAULT;
749
#endif
742
#endif
750
 
743
 
751
static boolean opt_fp;          /* new in v0.3m */
744
static boolean opt_fp;    /* new in v0.3m */
752
static int fpformat;            /* new in v0.3m */
745
static int fpformat;    /* new in v0.3m */
753
static char filetype[256];
746
static char filetype[256];
754
/*molfile : text; */
747
/*molfile : text; */
755
static char molfilename[256];
748
static char molfilename[256];
756
static char ndl_molfilename[256];
749
static char ndl_molfilename[256];
757
static char molname[256];
750
static char molname[256];
758
static char ndl_molname[256];
751
static char ndl_molname[256];
759
static char tmp_molname[256];   /* v0.3m */
752
static char tmp_molname[256];  /* v0.3m */
760
static char molcomment[256];
753
static char molcomment[256];
761
static int n_atoms, n_bonds, n_rings;
754
static int n_atoms, n_bonds, n_rings;
762
    /* the number of rings we determined ourselves */
755
    /* the number of rings we determined ourselves */
763
static int n_countablerings;
756
static int n_countablerings;
764
    /* v0.3n; number of rings which are not envelope rings */
757
    /* v0.3n; number of rings which are not envelope rings */
Line 767... Line 760...
767
//static int n_charges;         /* number of charges */
760
//static int n_charges;         /* number of charges */
768
static int n_heavyatoms, n_heavybonds, ndl_n_atoms, ndl_n_bonds, ndl_n_rings,
761
static int n_heavyatoms, n_heavybonds, ndl_n_atoms, ndl_n_bonds, ndl_n_rings,
769
  ndl_n_heavyatoms, ndl_n_heavybonds;
762
  ndl_n_heavyatoms, ndl_n_heavybonds;
770
/*cm_mdlmolfile  : boolean; */
763
/*cm_mdlmolfile  : boolean; */
771
static boolean found_arominfo, found_querymol, ndl_querymol;
764
static boolean found_arominfo, found_querymol, ndl_querymol;
772
static int tmp_n_atoms;         /* v0.3m */
765
static int tmp_n_atoms;    /* v0.3m */
773
static int tmp_n_bonds;         /* v0.3m */
766
static int tmp_n_bonds;    /* v0.3m */
774
static int tmp_n_rings;         /* v0.3m */
767
static int tmp_n_rings;    /* v0.3m */
775
static int tmp_n_heavyatoms;    /* v0.3m */
768
static int tmp_n_heavyatoms;  /* v0.3m */
776
static int tmp_n_heavybonds;    /* v0.3m */
769
static int tmp_n_heavybonds;  /* v0.3m */
777
 
770
 
778
static atom_rec *atom;
771
static atom_rec *atom;
779
static bond_rec *bond;
772
static bond_rec *bond;
780
static ringpath_type *ring;
773
static ringpath_type *ring;
781
static ringprop_rec *ringprop;  /* new in v0.3 */
774
static ringprop_rec *ringprop;  /* new in v0.3 */
782
 
775
 
783
static atom_rec *ndl_atom;
776
static atom_rec *ndl_atom;
784
static bond_rec *ndl_bond;
777
static bond_rec *ndl_bond;
785
static ringpath_type *ndl_ring;
778
static ringpath_type *ndl_ring;
786
static ringprop_rec *ndl_ringprop;      /* new in v0.3 */
779
static ringprop_rec *ndl_ringprop;  /* new in v0.3 */
787
static int ndl_ref_atom;        /* since v0.3j as a global variable */
780
static int ndl_ref_atom;  /* since v0.3j as a global variable */
788
static atom_rec *tmp_atom;      /* v0.3m */
781
static atom_rec *tmp_atom;  /* v0.3m */
789
static bond_rec *tmp_bond;      /* v0.3m */
782
static bond_rec *tmp_bond;  /* v0.3m */
790
static ringpath_type *tmp_ring; /* v0.3m */
783
static ringpath_type *tmp_ring;  /* v0.3m */
791
static ringprop_rec *tmp_ringprop;      /* v0.3m */
784
static ringprop_rec *tmp_ringprop;  /* v0.3m */
792
 
785
 
793
static boolean matchresult, matchsummary;       /* v0.3o */
786
static boolean matchresult, matchsummary;  /* v0.3o */
794
static matchpath_type ndl_matchpath, hst_matchpath;
787
static matchpath_type ndl_matchpath, hst_matchpath;
795
 
788
 
796
static fglist fg;
789
static fglist fg;
797
static str4 atomtype;
790
static str4 atomtype;
798
static str3 newatomtype;
791
static str3 newatomtype;
799
 
792
 
800
static char (*molbuf)[256];
793
static char (*molbuf)[256];
801
static int molbufindex;
794
static int molbufindex;
802
 
795
 
803
static boolean mol_in_queue;
796
static boolean mol_in_queue;
804
static int mol_count;
797
static int mol_count;
805
 
798
 
806
static molstat_rec molstat, ndl_molstat, tmp_molstat;   /* v0.3m */
799
static molstat_rec molstat, ndl_molstat, tmp_molstat;  /* v0.3m */
807
 
800
 
808
static int ringsearch_mode, max_vringsize;      /* for SSR ring search */
801
static int ringsearch_mode, max_vringsize;  /* for SSR ring search */
809
 
802
 
810
static FILE *rfile;
803
static FILE *rfile;
811
static boolean rfile_is_open, mol_OK;   /* new in v0.2i */
804
static boolean rfile_is_open, mol_OK;  /* new in v0.2i */
812
 
805
 
813
static int n_ar;                /* new in v0.3 */
806
static int n_ar;    /* new in v0.3 */
814
static int prev_n_ar;           /* new in v0.3 */
807
static int prev_n_ar;    /* new in v0.3 */
815
static boolean ez_search;       /* new in v0.3d */
808
static boolean ez_search;  /* new in v0.3d */
816
static boolean rs_search;       /* new in v0.3f */
809
static boolean rs_search;  /* new in v0.3f */
817
static boolean ez_flag;         /* new in v0.3f */
810
static boolean ez_flag;    /* new in v0.3f */
818
static boolean chir_flag;       /* new in v0.3f */
811
static boolean chir_flag;  /* new in v0.3f */
819
static boolean rs_strict;       /* new in v0.3j */
812
static boolean rs_strict;  /* new in v0.3j */
820
 
813
 
821
static int n_Ctot, n_Otot, n_Ntot;      /* new in v0.3g */
814
static int n_Ctot, n_Otot, n_Ntot;  /* new in v0.3g */
822
static int ndl_n_Ctot, ndl_n_Otot, ndl_n_Ntot;  /* new in v0.3g */
815
static int ndl_n_Ctot, ndl_n_Otot, ndl_n_Ntot;  /* new in v0.3g */
823
static int tmp_n_Ctot, tmp_n_Otot, tmp_n_Ntot;  /* new in v0.3m */
816
static int tmp_n_Ctot, tmp_n_Otot, tmp_n_Ntot;  /* new in v0.3m */
824
static boolean ether_generic;   /* v0.3j */
817
static boolean ether_generic;  /* v0.3j */
825
static boolean amine_generic;   /* v0.3j   */
818
static boolean amine_generic;  /* v0.3j   */
826
static boolean hydroxy_generic; /* v0.3j */
819
static boolean hydroxy_generic;  /* v0.3j */
827
static connval_rec *cv;         /* new in v0.3j */
820
static connval_rec *cv;    /* new in v0.3j */
828
static long long fpdecimal;     /* v0.3m */
821
static long long fpdecimal;  /* v0.3m */
829
static long long fpincrement;
822
static long long fpincrement;
830
static int fpindex;
823
static int fpindex;
831
static boolean fp_exacthit, fp_exactblock;
824
static boolean fp_exacthit, fp_exactblock;
832
static int tmfcode;
825
static int tmfcode;
833
    /* v0.3m; version number for tweaked MDL molfiles (tweaklevel) */
826
    /* v0.3m; version number for tweaked MDL molfiles (tweaklevel) */
Line 844... Line 837...
844
  struct stat filestat;
837
  struct stat filestat;
845
 
838
 
846
  return stat (fileName, &filestat) == 0 ? true : false;
839
  return stat (fileName, &filestat) == 0 ? true : false;
847
}
840
}
848
 
841
 
849
static void
-
 
850
lblank (int cols, char *nstr)
842
static void lblank (int cols, char *nstr)
851
{
843
{
852
  /* inserts leading blanks up to a given number of total characters */
844
  /* inserts leading blanks up to a given number of total characters */
853
  char STR1[256];
845
  char STR1[256];
854
 
846
 
855
  if (strlen (nstr) >= cols)
847
  if (strlen (nstr) >= cols)
856
    return;
848
    return;
857
  while (strlen (nstr) < cols)
849
  while (strlen (nstr) < cols)
858
    sprintf (nstr, " %s", strcpy (STR1, nstr));
850
    sprintf (nstr, " %s", strcpy (STR1, nstr));
859
}
851
}
860
 
852
 
861
static inline double
-
 
862
radtodeg (double rads)
853
static inline double radtodeg (double rads)
863
{
854
{
864
  return (180.0 / M_PI) * rads;
855
  return (180.0 / M_PI) * rads;
865
}
856
}
866
 
857
 
867
static void
-
 
868
strdelete (char *s, int pos, int len)
858
static void strdelete (char *s, int pos, int len)
869
{
859
{
870
  int slen;
860
  int slen;
871
 
861
 
872
  if (--pos < 0)
862
  if (--pos < 0)
873
    return;
863
    return;
874
  slen = strlen (s) - pos;
864
  slen = strlen (s) - pos;
875
  if (slen <= 0)
865
  if (slen <= 0)
876
    return;
866
    return;
877
  s += pos;
867
  s += pos;
878
  if (slen <= len)
868
  if (slen <= len) {
879
    {
-
 
880
      *s = 0;
869
    *s = 0;
881
      return;
870
    return;
882
    }
871
  }
883
  while ((*s = s[len]))
872
  while ((*s = s[len]))
884
    s++;
873
    s++;
885
}
874
}
886
 
875
 
887
static int
-
 
888
strpos2 (char *s, char *pat, int pos)
876
static int strpos2 (char *s, char *pat, int pos)
889
{
877
{
890
  char *cp, ch;
878
  char *cp, ch;
891
  int slen;
879
  int slen;
892
 
880
 
893
  if (--pos < 0)
881
  if (--pos < 0)
Line 896... Line 884...
896
  cp = s + pos;
884
  cp = s + pos;
897
  if (!(ch = *pat++))
885
  if (!(ch = *pat++))
898
    return 0;
886
    return 0;
899
  pos = strlen (pat);
887
  pos = strlen (pat);
900
  slen -= pos;
888
  slen -= pos;
901
  while (--slen >= 0)
889
  while (--slen >= 0) {
902
    {
-
 
903
      if (*cp++ == ch && !strncmp (cp, pat, pos))
890
    if (*cp++ == ch && !strncmp (cp, pat, pos))
904
        return cp - s;
891
      return cp - s;
905
    }
892
  }
906
  return 0;
893
  return 0;
907
}
894
}
908
 
895
 
909
static char *
-
 
910
strsub (char *ret, char *s, int pos, int len)
896
static char * strsub (char *ret, char *s, int pos, int len)
911
{
897
{
912
  char *s2;
898
  char *s2;
913
 
899
 
914
  if (--pos < 0 || len <= 0)
900
  if (--pos < 0 || len <= 0){
-
 
901
    *ret = 0;
-
 
902
    return ret;
915
    {
903
  }
-
 
904
  while (pos > 0){
-
 
905
    if (!*s++){
916
      *ret = 0;
906
      *ret = 0;
917
      return ret;
907
      return ret;
918
    }
-
 
919
  while (pos > 0)
-
 
920
    {
-
 
921
      if (!*s++)
-
 
922
        {
-
 
923
          *ret = 0;
-
 
924
          return ret;
-
 
925
        }
-
 
926
      pos--;
-
 
927
    }
908
    }
-
 
909
    pos--;
-
 
910
  }
928
  s2 = ret;
911
  s2 = ret;
929
  while (--len >= 0)
912
  while (--len >= 0){
930
    {
-
 
931
      if (!(*s2++ = *s++))
913
    if (!(*s2++ = *s++))
932
        return ret;
914
      return ret;
933
    }
915
  }
934
  *s2 = 0;
916
  *s2 = 0;
935
  return ret;
917
  return ret;
936
}
918
}
937
 
-
 
938
 
919
 
939
/*============================= auxiliary functions & procedures */
920
/*============================= auxiliary functions & procedures */
940
 
921
 
941
inline static void
-
 
942
all_lowercase (char *astring)
922
inline static void all_lowercase (char *astring)
943
{
923
{
944
  int i;
924
  int i;
945
  int l = strlen (astring);
925
  int l = strlen (astring);
946
 
926
 
947
  for (i = 0; i < l; i++)
927
  for (i = 0; i < l; i++){
948
    {
-
 
949
      astring[i] = tolower (astring[i]);
928
    astring[i] = tolower (astring[i]);
950
    }
929
  }
951
}
930
}
952
 
931
 
953
static void
-
 
954
init_globals ()
932
static void init_globals ()
955
{
933
{
956
  /*int i;*/
934
  /*int i;*/
957
 
935
 
958
  opt_verbose = false;
936
  opt_verbose = false;
959
  opt_debug = false;
937
  opt_debug = false;
Line 965... Line 943...
965
  opt_bitstring = false;
943
  opt_bitstring = false;
966
  opt_molout = false;
944
  opt_molout = false;
967
  opt_molstat = false;
945
  opt_molstat = false;
968
  opt_molstat_X = false;
946
  opt_molstat_X = false;
969
  opt_xmdlout = false;
947
  opt_xmdlout = false;
970
  opt_strict = false;           /* new in v0.2f */
948
  opt_strict = false; /* new in v0.2f */
971
  opt_metalrings = false;       /* new in v0.3 */
949
  opt_metalrings = false;  /* new in v0.3 */
972
  opt_geom = false;             /* new in v0.3d */
950
  opt_geom = false;   /* new in v0.3d */
973
  opt_chiral = false;           /* new in v0.3f */
951
  opt_chiral = false; /* new in v0.3f */
974
  opt_fp = false;               /* new in v0.3m */
952
  opt_fp = false;     /* new in v0.3m */
975
  opt_iso = false;              /* new in v0.3x */
953
  opt_iso = false;    /* new in v0.3x */
976
  opt_chg = false;              /* new in v0.3x */
954
  opt_chg = false;    /* new in v0.3x */
977
  opt_rad = false;              /* new in v0.3x */
955
  opt_rad = false;    /* new in v0.3x */
978
  /*cm_mdlmolfile   := false; */
956
  /*cm_mdlmolfile   := false; */
979
  found_arominfo = false;
957
  found_arominfo = false;
980
  found_querymol = false;
958
  found_querymol = false;
981
  ndl_querymol = false;
959
  ndl_querymol = false;
982
  opt_rs = rs_sar;              /* v0.3i */
960
  opt_rs = rs_sar;    /* v0.3i */
983
  /*ringsearch_mode := rs_sar; */
961
  /*ringsearch_mode := rs_sar; */
984
  rfile_is_open = false;        /* new in v0.2g */
962
  rfile_is_open = false;/* new in v0.2g */
985
  ez_search = false;            /* new in v0.3d */
963
  ez_search = false;    /* new in v0.3d */
986
  rs_search = false;            /* new in v0.3f */
964
  rs_search = false;    /* new in v0.3f */
987
  ez_flag = false;              /* new in v0.3f */
965
  ez_flag = false;      /* new in v0.3f */
988
  chir_flag = false;            /* new in v0.3f */
966
  chir_flag = false;    /* new in v0.3f */
989
  rs_strict = false;            /* new in v0.3j */
967
  rs_strict = false;    /* new in v0.3j */
990
  n_Ctot = 0;
968
  n_Ctot = 0;
991
  n_Otot = 0;
969
  n_Otot = 0;
992
  n_Ntot = 0;                   /* new in v0.3g */
970
  n_Ntot = 0;      /* new in v0.3g */
993
  ndl_n_Ctot = 0;
971
  ndl_n_Ctot = 0;
994
  ndl_n_Otot = 0;
972
  ndl_n_Otot = 0;
995
  ndl_n_Ntot = 0;               /* new in v0.3g */
973
  ndl_n_Ntot = 0;   /* new in v0.3g */
996
  //for (i = 0; i < max_fg; i++)
974
  //for (i = 0; i < max_fg; i++)
997
  //  fg[i] = false;
975
  //  fg[i] = false;
998
  memset (fg, 0, sizeof (fglist));
976
  memset (fg, 0, sizeof (fglist));
999
  /*try */
977
  /*try */
1000
  molbuf = safe_malloc (sizeof (molbuftype));
978
  molbuf = safe_malloc (sizeof (molbuftype));
Line 1003... Line 981...
1003
     begin
981
     begin
1004
     writeln('Not enough memory');
982
     writeln('Not enough memory');
1005
     halt(4);
983
     halt(4);
1006
     end;
984
     end;
1007
     end; */
985
     end; */
1008
  ether_generic = false;        /* v0.3j */
986
  ether_generic = false;  /* v0.3j */
1009
  amine_generic = false;        /* v0.3j */
987
  amine_generic = false;  /* v0.3j */
1010
  hydroxy_generic = false;      /* v0.3j */
988
  hydroxy_generic = false;/* v0.3j */
1011
  fpformat = fpf_decimal;       /* v0.3m */
989
  fpformat = fpf_decimal; /* v0.3m */
1012
  fpindex = 0;                  /* v0.3m */
990
  fpindex = 0;            /* v0.3m */
1013
  fp_exacthit = false;          /* v0.3m */
991
  fp_exacthit = false;    /* v0.3m */
1014
  fp_exactblock = false;        /* v0.3m */
992
  fp_exactblock = false;  /* v0.3m */
1015
  tmfcode = 0;                  /* v0.3m */
993
  tmfcode = 0;            /* v0.3m */
1016
  tmfmismatch = false;          /* v0.3m */
994
  tmfmismatch = false;    /* v0.3m */
1017
  auto_ssr = false;             /* v0.3n */
995
  auto_ssr = false;       /* v0.3n */
1018
  recursion_depth = 0;
996
  recursion_depth = 0;
1019
}
997
}
1020
 
998
 
1021
 
-
 
1022
static inline void
-
 
1023
init_molstat (mstat)
999
static inline void init_molstat (mstat)
1024
     molstat_rec *mstat;
1000
     molstat_rec *mstat;
1025
{
1001
{
1026
  /*
1002
  /*
1027
     with mstat do
1003
     with mstat do
1028
     begin
1004
     begin
Line 1043... Line 1019...
1043
     n_rO := 0; n_rO1 := 0; n_rO2p := 0;
1019
     n_rO := 0; n_rO1 := 0; n_rO2p := 0;
1044
     n_rS := 0; n_rX := 0;
1020
     n_rS := 0; n_rX := 0;
1045
     n_rAr := 0; n_rBz := 0; n_br2p := 0;
1021
     n_rAr := 0; n_rBz := 0; n_br2p := 0;
1046
     end;
1022
     end;
1047
   */
1023
   */
1048
  memset (mstat, 0, sizeof (molstat_rec));      /* v0.3k */
1024
  memset (mstat, 0, sizeof (molstat_rec));  /* v0.3k */
1049
}
1025
}
1050
 
-
 
1051
 
1026
 
1052
#if 0
1027
#if 0
1053
static void
-
 
1054
debugoutput (dstr)
1028
static void debugoutput (dstr)
1055
     char *dstr;
1029
  char *dstr;
1056
{
1030
{
1057
  if (opt_debug)
1031
  if (opt_debug)
1058
    printf ("%s\n", dstr);
1032
    printf ("%s\n", dstr);
1059
}
1033
}
1060
#endif
1034
#endif
1061
 
1035
 
1062
static void
-
 
1063
left_trim (trimstr)
1036
static void left_trim (trimstr)
1064
     char *trimstr;
1037
  char *trimstr;
1065
{
1038
{
1066
  while (*trimstr != '\0' && (trimstr[0] == ' ' || trimstr[0] == TAB))
1039
  while (*trimstr != '\0' && (trimstr[0] == ' ' || trimstr[0] == TAB))
1067
    strdelete (trimstr, 1, 1);
1040
    strdelete (trimstr, 1, 1);
1068
}
1041
}
1069
 
1042
 
1070
 
-
 
1071
static int
-
 
1072
left_int (trimstr)
1043
static int left_int (trimstr)
1073
     char *trimstr;
1044
  char *trimstr;
1074
{
1045
{
1075
  char numstr[256];
1046
  char numstr[256];
1076
  char auxstr[256];
1047
  char auxstr[256];
1077
  int auxint = 0;
1048
  int auxint = 0;
1078
  char STR1[256];
1049
  char STR1[256];
Line 1080... Line 1051...
1080
  strcpy (numstr, "-+0123456789");
1051
  strcpy (numstr, "-+0123456789");
1081
  *auxstr = '\0';
1052
  *auxstr = '\0';
1082
  while (*trimstr != '\0' && (trimstr[0] == ' ' || trimstr[0] == TAB))
1053
  while (*trimstr != '\0' && (trimstr[0] == ' ' || trimstr[0] == TAB))
1083
    strdelete (trimstr, 1, 1);
1054
    strdelete (trimstr, 1, 1);
1084
  while ((*trimstr != '\0') &&
1055
  while ((*trimstr != '\0') &&
1085
         (strpos2 (numstr, (sprintf (STR1, "%c", trimstr[0]), STR1), 1) > 0))
1056
    (strpos2 (numstr, (sprintf (STR1, "%c", trimstr[0]), STR1), 1) > 0)){
1086
    {
-
 
1087
      sprintf (auxstr + strlen (auxstr), "%c", trimstr[0]);
1057
    sprintf (auxstr + strlen (auxstr), "%c", trimstr[0]);
1088
      strdelete (trimstr, 1, 1);
1058
    strdelete (trimstr, 1, 1);
1089
    }
1059
  }
1090
  return auxint;
1060
  return auxint;
1091
}
1061
}
1092
 
1062
 
1093
static int
-
 
1094
path_pos (int id, int *a_path)
1063
static int path_pos (int id, int *a_path)
1095
{
1064
{
1096
  int i = 0;
1065
  int i = 0;
1097
 
1066
 
1098
  for (i = 0; i < max_ringsize; i++)
1067
  for (i = 0; i < max_ringsize; i++){
1099
    {
-
 
1100
      if (*(a_path++) == id)
1068
    if (*(a_path++) == id) {
1101
        {
-
 
1102
          return ++i;
1069
      return ++i;
1103
        }
-
 
1104
    }
1070
    }
-
 
1071
  }
1105
  return 0;
1072
  return 0;
1106
}
1073
}
1107
 
1074
 
1108
static int
-
 
1109
path_length (int *a_path)
1075
static int path_length (int *a_path)
1110
{
1076
{
1111
  if ((a_path[max_ringsize - 1] != 0) && (path_pos (0, a_path) == 0))
1077
  if ((a_path[max_ringsize - 1] != 0) && (path_pos (0, a_path) == 0))
1112
    return max_ringsize;
1078
    return max_ringsize;
1113
  else
1079
  else
1114
    return (path_pos (0, a_path) - 1);
1080
    return (path_pos (0, a_path) - 1);
1115
}
1081
}
1116
 
1082
 
1117
static int
-
 
1118
get_bond (int ba1, int ba2)
1083
static int get_bond (int ba1, int ba2)
1119
{
1084
{
1120
  int i;
1085
  int i;
1121
  int b_id = 0;
1086
  int b_id = 0;
1122
  int FORLIM;
1087
  int FORLIM;
1123
 
1088
 
1124
  if (n_bonds <= 0)
1089
  if (n_bonds <= 0)
1125
    return b_id;
1090
    return b_id;
1126
  FORLIM = n_bonds;
1091
  FORLIM = n_bonds;
1127
  for (i = 1; i <= FORLIM; i++)
1092
  for (i = 1; i <= FORLIM; i++) {
1128
    {
-
 
1129
      if ((bond[i - 1].a1 == ba1 && bond[i - 1].a2 == ba2) ||
1093
    if ((bond[i - 1].a1 == ba1 && bond[i - 1].a2 == ba2) ||
1130
          (bond[i - 1].a1 == ba2 && bond[i - 1].a2 == ba1))
1094
      (bond[i - 1].a1 == ba2 && bond[i - 1].a2 == ba1))
1131
        b_id = i;
1095
      b_id = i;
1132
    }
1096
  }
1133
  return b_id;
1097
  return b_id;
1134
}
1098
}
1135
 
1099
 
1136
static void
-
 
1137
clear_atom_tags ()
1100
static void clear_atom_tags ()
1138
{
1101
{
1139
  int i, FORLIM;
1102
  int i, FORLIM;
1140
 
1103
 
1141
  if (n_atoms > 0)
1104
  if (n_atoms > 0) {
1142
    {
-
 
1143
      FORLIM = n_atoms;
1105
    FORLIM = n_atoms;
1144
      for (i = 0; i < FORLIM; i++)
1106
    for (i = 0; i < FORLIM; i++)
1145
        atom[i].tag = false;
1107
      atom[i].tag = false;
1146
    }
1108
  }
1147
}
1109
}
1148
 
1110
 
1149
#if 0
1111
#if 0
1150
static void
-
 
1151
set_atom_tags ()
1112
static void set_atom_tags ()
1152
{
1113
{
1153
  int i, FORLIM;
1114
  int i, FORLIM;
1154
 
1115
 
1155
  if (n_atoms > 0)
1116
  if (n_atoms > 0){
1156
    {
-
 
1157
      FORLIM = n_atoms;
1117
    FORLIM = n_atoms;
1158
      for (i = 0; i < FORLIM; i++)
1118
    for (i = 0; i < FORLIM; i++)
1159
        atom[i].tag = true;
1119
      atom[i].tag = true;
1160
    }
1120
  }
1161
}
1121
}
1162
#endif
1122
#endif
1163
static void
-
 
1164
order_ringpath (int *r_path)
1123
static void order_ringpath (int *r_path)
1165
{
1124
{
1166
  /* order should be: array starts with atom of lowest number, followed by neighbor atom with lower number */
1125
  /* order should be: array starts with atom of lowest number, followed by neighbor atom with lower number */
1167
  int i, pl, a_ref, a_left, a_right, a_tmp;
1126
  int i, pl, a_ref, a_left, a_right, a_tmp;
1168
 
1127
 
1169
  pl = path_length (r_path);
1128
  pl = path_length (r_path);
1170
  if (pl < 3)
1129
  if (pl < 3)
1171
    return;
1130
    return;
1172
  a_ref = n_atoms;
1131
  a_ref = n_atoms;
1173
  /* start with highest possible value for an atom number */
1132
  /* start with highest possible value for an atom number */
1174
  for (i = 0; i < pl; i++)
1133
  for (i = 0; i < pl; i++){
1175
    {
-
 
1176
      if (r_path[i] < a_ref)    /* find the minimum value ==> reference atom */
1134
    if (r_path[i] < a_ref)  /* find the minimum value ==> reference atom */
1177
        a_ref = r_path[i];
1135
     a_ref = r_path[i];
1178
    }
1136
  }
1179
  if (a_ref < 1)                /* just to be sure */
1137
  if (a_ref < 1)   /* just to be sure */
1180
    return;
1138
    return;
1181
  if (path_pos (a_ref, r_path) < pl)
1139
  if (path_pos (a_ref, r_path) < pl)
1182
    a_right = r_path[path_pos (a_ref, r_path)];
1140
    a_right = r_path[path_pos (a_ref, r_path)];
1183
  else
1141
  else
1184
    a_right = r_path[0];
1142
    a_right = r_path[0];
1185
  if (path_pos (a_ref, r_path) > 1)
1143
  if (path_pos (a_ref, r_path) > 1)
1186
    a_left = r_path[path_pos (a_ref, r_path) - 2];
1144
    a_left = r_path[path_pos (a_ref, r_path) - 2];
1187
  else
1145
  else
1188
    a_left = r_path[pl - 1];
1146
    a_left = r_path[pl - 1];
1189
  if (a_right == a_left)        /* should never happen */
1147
  if (a_right == a_left)  /* should never happen */
1190
    return;
1148
    return;
1191
  if (a_right < a_left)
1149
  if (a_right < a_left) {
1192
    {
-
 
1193
      /* correct ring numbering direction, only shift of the reference atom to the left end required */
1150
      /* correct ring numbering direction, only shift of the reference atom to the left end required */
1194
      while (path_pos (a_ref, r_path) > 1)
1151
    while (path_pos (a_ref, r_path) > 1){
1195
        {
-
 
1196
          a_tmp = r_path[0];
1152
      a_tmp = r_path[0];
1197
          for (i = 1; i < pl; i++)
1153
      for (i = 1; i < pl; i++)
1198
            r_path[i - 1] = r_path[i];
1154
        r_path[i - 1] = r_path[i];
1199
          r_path[pl - 1] = a_tmp;
1155
      r_path[pl - 1] = a_tmp;
1200
        }
1156
    }
1201
      return;
1157
    return;
1202
    }
1158
  }
1203
  while (path_pos (a_ref, r_path) < pl)
1159
  while (path_pos (a_ref, r_path) < pl) {
1204
    {
-
 
1205
      /* step one: create "mirrored" ring path with reference atom at right end */
1160
      /* step one: create "mirrored" ring path with reference atom at right end */
1206
      a_tmp = r_path[pl - 1];
1161
    a_tmp = r_path[pl - 1];
1207
      for (i = pl; i >= 2; i--)
1162
    for (i = pl; i >= 2; i--)
1208
        r_path[i - 1] = r_path[i - 2];
1163
      r_path[i - 1] = r_path[i - 2];
1209
      r_path[0] = a_tmp;
1164
    r_path[0] = a_tmp;
1210
    }
1165
  }
1211
  for (i = 1; i <= pl / 2; i++)
1166
  for (i = 1; i <= pl / 2; i++){        /* one more mirroring */
1212
    {                           /* one more mirroring */
-
 
1213
      a_tmp = r_path[i - 1];
1167
    a_tmp = r_path[i - 1];
1214
      r_path[i - 1] = r_path[pl - i];
1168
    r_path[i - 1] = r_path[pl - i];
1215
      r_path[pl - i] = a_tmp;
1169
    r_path[pl - i] = a_tmp;
1216
      /* wrong ring numbering direction, two steps required */
1170
    /* wrong ring numbering direction, two steps required */
1217
    }
1171
  }
1218
}
1172
}
1219
 
1173
 
1220
static void
-
 
1221
clear_ndl_atom_tags ()
1174
static void clear_ndl_atom_tags ()
1222
{
1175
{
1223
  int i;
1176
  int i;
1224
 
1177
 
1225
  if (ndl_n_atoms > 0)
1178
  if (ndl_n_atoms > 0){
1226
    {
-
 
1227
 
-
 
1228
      for (i = 0; i < ndl_n_atoms; i++)
1179
    for (i = 0; i < ndl_n_atoms; i++)
1229
        ndl_atom[i].tag = false;
1180
      ndl_atom[i].tag = false;
1230
    }
1181
  }
1231
}
1182
}
1232
 
-
 
1233
 
1183
 
1234
static void
-
 
1235
set_ndl_atom_tags ()
1184
static void set_ndl_atom_tags ()
1236
{
1185
{
1237
  int i;
1186
  int i;
1238
 
1187
 
1239
  if (ndl_n_atoms > 0)
1188
  if (ndl_n_atoms > 0){
1240
    {
-
 
1241
 
-
 
1242
      for (i = 0; i < ndl_n_atoms; i++)
1189
    for (i = 0; i < ndl_n_atoms; i++)
1243
        ndl_atom[i].tag = true;
1190
     ndl_atom[i].tag = true;
1244
    }
1191
  }
1245
}
1192
}
1246
 
-
 
1247
 
1193
 
1248
static int
-
 
1249
count_tagged_ndl_heavyatoms ()
1194
static int count_tagged_ndl_heavyatoms ()
1250
{
1195
{
1251
  int i;
1196
  int i;
1252
  int n = 0;
1197
  int n = 0;
1253
 
1198
 
1254
  if (ndl_n_atoms < 1)
1199
  if (ndl_n_atoms < 1)
1255
    return n;
1200
    return n;
1256
 
1201
 
1257
  for (i = 0; i < ndl_n_atoms; i++)
1202
  for (i = 0; i < ndl_n_atoms; i++){
1258
    {
-
 
1259
      if (ndl_atom[i].heavy && ndl_atom[i].tag)
1203
    if (ndl_atom[i].heavy && ndl_atom[i].tag)
1260
        n++;
1204
    n++;
1261
    }
1205
  }
1262
  return n;
1206
  return n;
1263
}
1207
}
1264
 
-
 
1265
 
-
 
1266
 
1208
 
1267
/*============================= geometry functions ========================== */
1209
/*============================= geometry functions ========================== */
1268
 
1210
 
1269
static double
-
 
1270
dist3d (p1, p2)
1211
static double dist3d (p1, p2)
1271
     p_3d p1, p2;
1212
     p_3d p1, p2;
1272
{
1213
{
1273
  double res, TEMP, TEMP1, TEMP2;
1214
  double res, TEMP, TEMP1, TEMP2;
1274
 
1215
 
1275
  TEMP = p1.x - p2.x;
1216
  TEMP = p1.x - p2.x;
1276
  TEMP1 = p1.y - p2.y;
1217
  TEMP1 = p1.y - p2.y;
1277
  TEMP2 = p1.z - p2.z;
1218
  TEMP2 = p1.z - p2.z;
1278
  res = sqrt (TEMP * TEMP + TEMP1 * TEMP1 + TEMP2 * TEMP2);
1219
  res = sqrt (TEMP * TEMP + TEMP1 * TEMP1 + TEMP2 * TEMP2);
1279
  return res;
1220
  return res;
1280
}
1221
}
1281
 
-
 
1282
 
1222
 
1283
/*
1223
/*
1284
function is_cis(p1,p2,p3,p4:p_3d):boolean;  (* new in v0.3d
1224
function is_cis(p1,p2,p3,p4:p_3d):boolean;  (* new in v0.3d
1285
var                         (* just a simple, distance-based estimation
1225
var                         (* just a simple, distance-based estimation
1286
  total_dist  : double;     (* instead of calculating the dihedral angle
1226
  total_dist  : double;     (* instead of calculating the dihedral angle
Line 1293... Line 1233...
1293
  if (direct_dist < 0.78 * total_dist) then res := true;  (* cutoff value of 0.78 was
1233
  if (direct_dist < 0.78 * total_dist) then res := true;  (* cutoff value of 0.78 was
1294
  is_cis := res;                                          (* experimentally determined
1234
  is_cis := res;                                          (* experimentally determined
1295
end;
1235
end;
1296
*/
1236
*/
1297
/* function is_cis was replaced by a new one in v0.3h */
1237
/* function is_cis was replaced by a new one in v0.3h */
1298
 
-
 
1299
 
1238
 
1300
static p_3d
-
 
1301
subtract_3d (p1, p2)
1239
static p_3d subtract_3d (p1, p2)
1302
     p_3d p1, p2;
1240
     p_3d p1, p2;
1303
{
1241
{
1304
  p_3d p;
1242
  p_3d p;
1305
 
1243
 
1306
  p.x = p1.x - p2.x;
1244
  p.x = p1.x - p2.x;
1307
  p.y = p1.y - p2.y;
1245
  p.y = p1.y - p2.y;
1308
  p.z = p1.z - p2.z;
1246
  p.z = p1.z - p2.z;
1309
  return p;
1247
  return p;
1310
}
1248
}
1311
 
1249
 
1312
 
-
 
1313
static p_3d
-
 
1314
add_3d (p1, p2)
1250
static p_3d add_3d (p1, p2)
1315
     p_3d p1, p2;
1251
     p_3d p1, p2;
1316
{
1252
{
1317
  p_3d p;
1253
  p_3d p;
1318
 
1254
 
1319
  p.x = p1.x + p2.x;
1255
  p.x = p1.x + p2.x;
Line 1321... Line 1257...
1321
  p.z = p1.z + p2.z;
1257
  p.z = p1.z + p2.z;
1322
  return p;
1258
  return p;
1323
}
1259
}
1324
 
1260
 
1325
#if 0
1261
#if 0
1326
static void
-
 
1327
vec2origin (p1, p2)
1262
static void vec2origin (p1, p2)
1328
     p_3d *p1, *p2;
1263
     p_3d *p1, *p2;
1329
{
1264
{
1330
  p_3d p;
1265
  p_3d p;
1331
 
1266
 
1332
  p = subtract_3d (*p2, *p1);
1267
  p = subtract_3d (*p2, *p1);
Line 1334... Line 1269...
1334
  p1->x = 0.0;
1269
  p1->x = 0.0;
1335
  p1->y = 0.0;
1270
  p1->y = 0.0;
1336
  p1->z = 0.0;
1271
  p1->z = 0.0;
1337
}
1272
}
1338
#endif
1273
#endif
1339
 
1274
 
1340
static double
-
 
1341
scalar_prod (p1, p2, p3)
1275
static double scalar_prod (p1, p2, p3)
1342
     p_3d p1, p2, p3;
1276
     p_3d p1, p2, p3;
1343
{
1277
{
1344
  p_3d p;
1278
  p_3d p;
1345
  double res;
1279
  double res;
1346
 
1280
 
1347
  p = subtract_3d (p2, p1);
1281
  p = subtract_3d (p2, p1);
1348
  p2 = p;
1282
  p2 = p;
1349
  p = subtract_3d (p3, p1);
1283
  p = subtract_3d (p3, p1);
1350
  p3 = p;
1284
  p3 = p;
1351
  p1.x = 0.0;
1285
  p1.x = 0.0;
1352
  p1.y = 0.0;
1286
  p1.y = 0.0;
1353
  p1.z = 0.0;
1287
  p1.z = 0.0;
1354
  res = p2.x * p3.x + p2.y * p3.y + p2.z * p3.z;
1288
  res = p2.x * p3.x + p2.y * p3.y + p2.z * p3.z;
1355
  return res;
1289
  return res;
1356
}
1290
}
1357
 
-
 
1358
 
1291
 
1359
static p_3d
-
 
1360
cross_prod (p1, p2, p3)
1292
static p_3d cross_prod (p1, p2, p3)
1361
     p_3d p1, p2, p3;
1293
     p_3d p1, p2, p3;
1362
{
1294
{
1363
  p_3d p, orig_p1;
1295
  p_3d p, orig_p1;
1364
 
1296
 
1365
  orig_p1 = p1;
1297
  orig_p1 = p1;
1366
  p = subtract_3d (p2, p1);
1298
  p = subtract_3d (p2, p1);
Line 1371... Line 1303...
1371
  p.y = p2.z * p3.x - p2.x * p3.z;
1303
  p.y = p2.z * p3.x - p2.x * p3.z;
1372
  p.z = p2.x * p3.y - p2.y * p3.x;
1304
  p.z = p2.x * p3.y - p2.y * p3.x;
1373
  return (add_3d (orig_p1, p));
1305
  return (add_3d (orig_p1, p));
1374
}
1306
}
1375
 
1307
 
1376
 
-
 
1377
static double
-
 
1378
angle_3d (p1, p2, p3)
1308
static double angle_3d (p1, p2, p3)
1379
     p_3d p1, p2, p3;
1309
     p_3d p1, p2, p3;
1380
{
1310
{
1381
  p_3d lp1, lp2, lp3, p;
1311
  p_3d lp1, lp2, lp3, p;
1382
  double res = 0.0;
1312
  double res = 0.0;
1383
  double magn_1, magn_2, cos_phi;
1313
  double magn_1, magn_2, cos_phi;
Line 1392... Line 1322...
1392
  lp1.x = 0.0;
1322
  lp1.x = 0.0;
1393
  lp1.y = 0.0;
1323
  lp1.y = 0.0;
1394
  lp1.z = 0.0;
1324
  lp1.z = 0.0;
1395
  magn_1 = dist3d (lp1, lp2);
1325
  magn_1 = dist3d (lp1, lp2);
1396
  magn_2 = dist3d (lp1, lp3);
1326
  magn_2 = dist3d (lp1, lp3);
1397
  if (magn_1 * magn_2 == 0)     /* emergency exit */
1327
  if (magn_1 * magn_2 == 0)  /* emergency exit */
1398
    return M_PI;
1328
    return M_PI;
1399
  cos_phi = scalar_prod (lp1, lp2, lp3) / (magn_1 * magn_2);
1329
  cos_phi = scalar_prod (lp1, lp2, lp3) / (magn_1 * magn_2);
1400
  if (cos_phi < -1)
1330
  if (cos_phi < -1)
1401
    cos_phi = -1.0;
1331
    cos_phi = -1.0;
1402
  if (cos_phi > 1)
1332
  if (cos_phi > 1)
1403
    cos_phi = 1.0;
1333
    cos_phi = 1.0;
1404
  res = acos (cos_phi);
1334
  res = acos (cos_phi);
1405
  return res;
1335
  return res;
1406
}
1336
}
1407
 
1337
 
1408
 
-
 
1409
static double
-
 
1410
torsion (p1, p2, p3, p4)
1338
static double torsion (p1, p2, p3, p4)
1411
     p_3d p1, p2, p3, p4;
1339
     p_3d p1, p2, p3, p4;
1412
{
1340
{
1413
  p_3d lp1, lp2, lp3, lp4, d1, c1, c2;
1341
  p_3d lp1, lp2, lp3, lp4, d1, c1, c2;
1414
  double res;
1342
  double res;
1415
  p_3d c1xc2, c2xc1;
1343
  p_3d c1xc2, c2xc1;
Line 1433... Line 1361...
1433
  c1xc2 = cross_prod (lp3, c1, c2);
1361
  c1xc2 = cross_prod (lp3, c1, c2);
1434
  c2xc1 = cross_prod (lp3, c2, c1);
1362
  c2xc1 = cross_prod (lp3, c2, c1);
1435
  /*next, get the distances from these points to our refernce point lp2 */
1363
  /*next, get the distances from these points to our refernce point lp2 */
1436
  dist1 = dist3d (lp2, c1xc2);
1364
  dist1 = dist3d (lp2, c1xc2);
1437
  dist2 = dist3d (lp2, c2xc1);
1365
  dist2 = dist3d (lp2, c2xc1);
1438
  if (dist1 <= dist2)
1366
  if (dist1 <= dist2)
1439
    sign = 1.0;
1367
    sign = 1.0;
1440
  else
1368
  else
1441
    sign = -1.0;
1369
    sign = -1.0;
1442
  return (sign * res);
1370
  return (sign * res);
1443
}
1371
}
1444
 
-
 
1445
 
1372
 
1446
static double
-
 
1447
ctorsion (p1, p2, p3, p4)
1373
static double ctorsion (p1, p2, p3, p4)
1448
     p_3d p1, p2, p3, p4;
1374
     p_3d p1, p2, p3, p4;
1449
{
1375
{
1450
  /* calculates "pseudo-torsion" defined by atoms 3 and 4, being both */
1376
  /* calculates "pseudo-torsion" defined by atoms 3 and 4, being both */
1451
  /* attached to atom 2, with respect to axis of atoms 1 and 2 */
1377
  /* attached to atom 2, with respect to axis of atoms 1 and 2 */
1452
  p_3d lp1, lp2, lp3, lp4;
1378
  p_3d lp1, lp2, lp3, lp4;
1453
  /*d1 : p_3d; */
1379
  /*d1 : p_3d; */
1454
  p_3d c1, c2;
1380
  p_3d c1, c2;
Line 1477... Line 1403...
1477
  else
1403
  else
1478
    sign = -1.0;
1404
    sign = -1.0;
1479
  return (sign * res);
1405
  return (sign * res);
1480
}
1406
}
1481
 
1407
 
1482
 
-
 
1483
static boolean
-
 
1484
is_cis (p1, p2, p3, p4)
1408
static boolean is_cis (p1, p2, p3, p4)
1485
     p_3d p1, p2, p3, p4;
1409
     p_3d p1, p2, p3, p4;
1486
{
1410
{
1487
  /* new in v0.3h, uses the dihedral angle */
1411
  /* new in v0.3h, uses the dihedral angle */
1488
  double phi;
1412
  double phi;
1489
  boolean res = false;
1413
  boolean res = false;
Line 1491... Line 1415...
1491
  phi = torsion (p1, p2, p3, p4);
1415
  phi = torsion (p1, p2, p3, p4);
1492
  if (fabs (phi) < M_PI / 2)
1416
  if (fabs (phi) < M_PI / 2)
1493
    res = true;
1417
    res = true;
1494
  return res;
1418
  return res;
1495
}
1419
}
1496
 
-
 
1497
 
1420
 
1498
/*====================== end of geometry functions ========================== */
1421
/*====================== end of geometry functions ========================== */
1499
 
1422
 
1500
static void
-
 
1501
show_usage ()
1423
static void show_usage () {
1502
{
-
 
1503
  if (progmode == pmMatchMol)
1424
  if (progmode == pmMatchMol) {
1504
    {
-
 
1505
      printf
-
 
1506
        ("matchmol version %s  N. Haider, University of Vienna, 2003-2007\n",
1425
    printf ("matchmol version %s  N. Haider, University of Vienna, 2003-2007\n", version);
1507
         version);
-
 
1508
      printf ("Usage: matchmol [options] <needle> <haystack>\n");
1426
    printf ("Usage: matchmol [options] <needle> <haystack>\n");
1509
      printf
-
 
1510
        (" where <needle> and <haystack> are the two molecules to compare\n");
1427
    printf (" where <needle> and <haystack> are the two molecules to compare\n");
1511
      printf
-
 
1512
        (" (supported formats: MDL *.mol or *.sdf, Alchemy *.mol, Sybyl *.mol2)\n");
1428
    printf (" (supported formats: MDL *.mol or *.sdf, Alchemy *.mol, Sybyl *.mol2)\n");
1513
      printf (" options can be:\n");
1429
    printf (" options can be:\n");
1514
      printf ("    -v  verbose output\n");
1430
    printf ("    -v  verbose output\n");
1515
      printf ("    -x  exact match\n");
1431
    printf ("    -x  exact match\n");
1516
      printf
-
 
1517
        ("    -s  strict comparison of atom and bond types (including ring check)\n");
1432
    printf ("    -s  strict comparison of atom and bond types (including ring check)\n");
1518
      /* new in v0.2f, v0.3d */
1433
      /* new in v0.2f, v0.3d */
1519
      printf ("    -r  force SSR (set of small rings) ring search mode\n");
1434
    printf ("    -r  force SSR (set of small rings) ring search mode\n");
1520
      printf
-
 
1521
        ("    -m  write matching molecule as MDL molfile to standard output\n");
1435
    printf ("    -m  write matching molecule as MDL molfile to standard output\n");
1522
      printf
-
 
1523
        ("        (default output: record number + \":T\" for hit  or \":F\" for miss\n");
1436
    printf ("        (default output: record number + \":T\" for hit  or \":F\" for miss\n");
1524
      printf ("    -M  accept metal atoms as ring members\n");
1437
    printf ("    -M  accept metal atoms as ring members\n");
1525
      printf ("    -g  check geometry of double bonds (E/Z)\n");
1438
    printf ("    -g  check geometry of double bonds (E/Z)\n");
1526
      printf ("    -G  check geometry of chiral centers (R/S)\n");
1439
    printf ("    -G  check geometry of chiral centers (R/S)\n");
1527
      printf ("    -a  check charges strict\n");        /* 0.3x */
1440
    printf ("    -a  check charges strict\n");   /* 0.3x */
1528
      printf ("    -i  check isotopes strict\n");       /* 0.3x */
1441
    printf ("    -i  check isotopes strict\n");  /* 0.3x */
1529
      printf ("    -d  check radicals strict\n");       /* 0.3x */
1442
    printf ("    -d  check radicals strict\n");  /* 0.3x */
1530
      printf
-
 
1531
        ("    -f  fingerprint mode (1 haystack, multiple needles) with boolean output\n");
1443
    printf ("    -f  fingerprint mode (1 haystack, multiple needles) with boolean output\n");
1532
      printf
-
 
1533
        ("    -F  fingerprint mode (1 haystack, multiple needles) with decimal output\n");
1444
    printf ("    -F  fingerprint mode (1 haystack, multiple needles) with decimal output\n");
1534
      return;
1445
    return;
1535
    }
1446
  }
1536
  printf ("checkmol version %s  N. Haider, University of Vienna, 2003-2007\n",
1447
  printf ("checkmol version %s  N. Haider, University of Vienna, 2003-2007\n", version);
1537
          version);
-
 
1538
  printf ("Usage: checkmol [options] <filename>\n");
1448
  printf ("Usage: checkmol [options] <filename>\n");
1539
  printf (" where options can be:\n");
1449
  printf (" where options can be:\n");
1540
  printf
-
 
1541
    ("    -l  print a list of fingerprint codes + explanation and exit\n");
1450
  printf ("    -l  print a list of fingerprint codes + explanation and exit\n");
1542
  printf ("    -v  verbose output\n");
1451
  printf ("    -v  verbose output\n");
1543
  printf ("    -r  force SSR (set of small rings) ring search mode\n");
1452
  printf ("    -r  force SSR (set of small rings) ring search mode\n");
1544
  printf ("    -M  accept metal atoms as ring members\n");
1453
  printf ("    -M  accept metal atoms as ring members\n");
1545
  printf ("  and one of the following:\n");
1454
  printf ("  and one of the following:\n");
1546
  printf
-
 
1547
    ("    -e  english text (common name of functional group; default)\n");
1455
  printf ("    -e  english text (common name of functional group; default)\n");
1548
  printf ("    -d  german text (common name of functional group)\n");
1456
  printf ("    -d  german text (common name of functional group)\n");
1549
  printf ("    -c  code (acronym-like code for functional group)\n");
1457
  printf ("    -c  code (acronym-like code for functional group)\n");
1550
  printf
-
 
1551
    ("    -b  binary (a bitstring representing absence or presence of each group)\n");
1458
  printf ("    -b  binary (a bitstring representing absence or presence of each group)\n");
1552
  printf
-
 
1553
    ("    -s  the ASCII representation of the above bitstring, i.e. 0s and 1s)\n");
1459
  printf ("    -s  the ASCII representation of the above bitstring, i.e. 0s and 1s)\n");
1554
  printf
-
 
1555
    ("    -x  print molecular statistics (number of various atom types, bond types,\n");
1460
  printf ("    -x  print molecular statistics (number of various atom types, bond types,\n");
1556
  printf ("        ring sizes, etc.\n");
1461
  printf ("        ring sizes, etc.\n");
1557
  printf
-
 
1558
    ("    -X  same as above, listing all records (even if 0) as comma-separated list\n");
1462
  printf ("    -X  same as above, listing all records (even if 0) as comma-separated list\n");
1559
  printf ("    -a  count charges in fingerprint\n");    /* 0.3x */
1463
  printf ("    -a  count charges in fingerprint\n");  /* 0.3x */
1560
  printf
-
 
1561
    ("    -m  write MDL molfile (with special encoding for aromatic atoms/bonds)\n");
1464
  printf ("    -m  write MDL molfile (with special encoding for aromatic atoms/bonds)\n");
1562
  printf (" options can be combined like -vc\n");
1465
  printf (" options can be combined like -vc\n");
1563
  printf (" <filename> specifies any file in the formats supported\n");
1466
  printf (" <filename> specifies any file in the formats supported\n");
1564
  printf
-
 
1565
    (" (MDL *.mol, Alchemy *.mol, Sybyl *.mol2), the filename \"-\" (without quotes)\n");
1467
  printf (" (MDL *.mol, Alchemy *.mol, Sybyl *.mol2), the filename \"-\" (without quotes)\n");
1566
  printf (" specifies standard input\n");
1468
  printf (" specifies standard input\n");
1567
  /* the "debug" option (-D) remains undocumented */
1469
  /* the "debug" option (-D) remains undocumented */
1568
}
1470
}
1569
 
1471
 
1570
 
-
 
1571
static void
-
 
1572
list_molstat_codes ()
1472
static void list_molstat_codes ()
1573
{
1473
{
1574
  printf ("n_atoms:     number of heavy atoms\n");
1474
  printf ("n_atoms:     number of heavy atoms\n");
1575
  printf ("n_bonds:     number of bonds between non-H atoms\n");
1475
  printf ("n_bonds:     number of bonds between non-H atoms\n");
1576
  printf ("n_rings:     number of rings\n");
1476
  printf ("n_rings:     number of rings\n");
1577
  printf ("n_QA:        number of query atoms\n");
1477
  printf ("n_QA:        number of query atoms\n");
Line 1632... Line 1532...
1632
  printf ("n_rO1:       number of rings containing 1 oxygen atom\n");
1532
  printf ("n_rO1:       number of rings containing 1 oxygen atom\n");
1633
  printf ("n_rO2p:      number of rings containing 2 or more oxygen atoms\n");
1533
  printf ("n_rO2p:      number of rings containing 2 or more oxygen atoms\n");
1634
  printf ("n_rS:        number of rings containing sulfur (any number)\n");
1534
  printf ("n_rS:        number of rings containing sulfur (any number)\n");
1635
  printf ("n_rX:        number of heterocycles (any type)\n");
1535
  printf ("n_rX:        number of heterocycles (any type)\n");
1636
  printf ("n_rar:       number of aromatic rings (any type)\n");
1536
  printf ("n_rar:       number of aromatic rings (any type)\n");
1637
/* p2c: checkmol.pas, line 1207:
1537
  /* p2c: checkmol.pas, line 1207:
1638
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
1538
    * Note: Turbo Pascal conditional compilation directive was ignored [218] */
1639
  /*$IFDEF extended_molstat */
1539
  /*$IFDEF extended_molstat */
1640
  printf ("n_rbz:       number of benzene rings\n");
1540
  printf ("n_rbz:       number of benzene rings\n");
1641
  printf ("n_br2p:      number of bonds belonging to two or more rings\n");
1541
  printf ("n_br2p:      number of bonds belonging to two or more rings\n");
1642
  printf
-
 
1643
    ("n_psg01:     number of atoms belonging to group 1 of the periodic system\n");
1542
  printf ("n_psg01:     number of atoms belonging to group 1 of the periodic system\n");
1644
  printf
-
 
1645
    ("n_psg02:     number of atoms belonging to group 2 of the periodic system\n");
1543
  printf ("n_psg02:     number of atoms belonging to group 2 of the periodic system\n");
1646
  printf
-
 
1647
    ("n_psg13:     number of atoms belonging to group 13 of the periodic system\n");
1544
  printf ("n_psg13:     number of atoms belonging to group 13 of the periodic system\n");
1648
  printf
-
 
1649
    ("n_psg14:     number of atoms belonging to group 14 of the periodic system\n");
1545
  printf ("n_psg14:     number of atoms belonging to group 14 of the periodic system\n");
1650
  printf
-
 
1651
    ("n_psg15:     number of atoms belonging to group 15 of the periodic system\n");
1546
  printf ("n_psg15:     number of atoms belonging to group 15 of the periodic system\n");
1652
  printf
-
 
1653
    ("n_psg16:     number of atoms belonging to group 16 of the periodic system\n");
1547
  printf ("n_psg16:     number of atoms belonging to group 16 of the periodic system\n");
1654
  printf
-
 
1655
    ("n_psg17:     number of atoms belonging to group 17 of the periodic system\n");
1548
  printf ("n_psg17:     number of atoms belonging to group 17 of the periodic system\n");
1656
  printf
-
 
1657
    ("n_psg18:     number of atoms belonging to group 18 of the periodic system\n");
1549
  printf ("n_psg18:     number of atoms belonging to group 18 of the periodic system\n");
1658
  printf
-
 
1659
    ("n_pstm:      number of atoms belonging to the transition metals\n");
1550
  printf ("n_pstm:      number of atoms belonging to the transition metals\n");
1660
  printf
-
 
1661
    ("n_psla:      number of atoms belonging to the lanthanides or actinides\n");
1551
  printf ("n_psla:      number of atoms belonging to the lanthanides or actinides\n");
1662
  printf ("n_iso:      number of isotopes\n");
1552
  printf ("n_iso:      number of isotopes\n");
1663
  printf ("n_rad:      number of radicals\n");
1553
  printf ("n_rad:      number of radicals\n");
1664
  /*$ENDIF */
1554
  /*$ENDIF */
1665
}
1555
}
1666
 
-
 
1667
 
1556
 
1668
#if 0
1557
#if 0
1669
static void parse_args()
1558
static void parse_args() {
1670
{
-
 
1671
  int p;
1559
  int p;
1672
  char parstr[256];
1560
  char parstr[256];
1673
  char tmpstr[256];
1561
  char tmpstr[256];
1674
  int l;
1562
  int l;
1675
 
1563
 
1676
  *tmpstr = '\0';
1564
  *tmpstr = '\0';
1677
  opt_none = true;
1565
  opt_none = true;
1678
  if (progmode == pmCheckMol) {
1566
  if (progmode == pmCheckMol) {
1679
    for (p = 1; p < P_argc; p++) {
1567
    for (p = 1; p < P_argc; p++) {
1680
      strcpy(parstr, P_argv[p]);
1568
      strcpy(parstr, P_argv[p]);
1681
      if (!strcmp(parstr, "-l")) {   /* new in v0.3l */
1569
      if (!strcmp(parstr, "-l")) {   /* new in v0.3l */
1682
        list_molstat_codes();
1570
        list_molstat_codes();
1683
        _Escape(0);
1571
        _Escape(0);
1684
      }
1572
      }
1685
      if (p < P_argc - 1) {
1573
      if (p < P_argc - 1) {
1686
        if (strpos2(parstr, "-", 1) == 1 && p < P_argc - 1) {
1574
        if (strpos2(parstr, "-", 1) == 1 && p < P_argc - 1) {
1687
          strcpy(tmpstr, P_argv[p]);
1575
          strcpy(tmpstr, P_argv[p]);
1688
          left_trim(tmpstr);
1576
          left_trim(tmpstr);
1689
          l = 0;
1577
          l = 0;
1690
          if (strpos2(tmpstr, "v", 1) > 0)
1578
          if (strpos2(tmpstr, "v", 1) > 0)
1691
            l++;
1579
            l++;
1692
          if (strpos2(tmpstr, "D", 1) > 0)
1580
          if (strpos2(tmpstr, "D", 1) > 0)
1693
            l++;
1581
            l++;
1694
          if (strpos2(tmpstr, "r", 1) > 0)
1582
          if (strpos2(tmpstr, "r", 1) > 0)
1695
            l++;
1583
            l++;
1696
          if (strpos2(tmpstr, "M", 1) > 0)   /* new in v0.3 */
1584
          if (strpos2(tmpstr, "M", 1) > 0)   /* new in v0.3 */
1697
            l++;
1585
            l++;
1698
          if (strlen(tmpstr) > l + 2) {
1586
          if (strlen(tmpstr) > l + 2) {
1699
            show_usage();
1587
            show_usage();
1700
            _Escape(1);
1588
            _Escape(1);
1701
          }
1589
          }
1702
          opt_none = false;
1590
          opt_none = false;
1703
          if (strpos2(tmpstr, "M", 1) > 0)
1591
          if (strpos2(tmpstr, "M", 1) > 0)
1704
            opt_metalrings = true;
1592
            opt_metalrings = true;
1705
          if (strpos2(tmpstr, "v", 1) > 0)
1593
          if (strpos2(tmpstr, "v", 1) > 0)
1706
            opt_verbose = true;
1594
            opt_verbose = true;
1707
/* p2c: checkmol.pas, line 1261:
1595
            /* p2c: checkmol.pas, line 1261:
1708
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
1596
            * Note: Turbo Pascal conditional compilation directive was ignored [218] */
1709
          /*$IFDEF debug
1597
            /*$IFDEF debug
1710
          if (strpos2(tmpstr, "D", 1) > 0)
1598
            if (strpos2(tmpstr, "D", 1) > 0)
1711
            opt_debug = true;
1599
              opt_debug = true;
1712
          $ENDIF*/
1600
            $ENDIF*/
1713
          if (strpos2(tmpstr, "e", 1) > 0)
1601
          if (strpos2(tmpstr, "e", 1) > 0)
1714
            opt_text = true;
1602
            opt_text = true;
1715
          else {
1603
          else {
1716
            if (strpos2(tmpstr, "d", 1) > 0)
1604
            if (strpos2(tmpstr, "d", 1) > 0)
1717
              opt_text_de = true;
1605
              opt_text_de = true;
1718
            else {
1606
            else {
1719
              if (strpos2(tmpstr, "c", 1) > 0)
1607
              if (strpos2(tmpstr, "c", 1) > 0)
1720
                opt_code = true;
1608
                opt_code = true;
1721
              else {
1609
              else {
1722
                if (strpos2(tmpstr, "b", 1) > 0)
1610
                if (strpos2(tmpstr, "b", 1) > 0)
1723
                  opt_bin = true;
1611
                  opt_bin = true;
1724
                else {
1612
                else {
1725
                  if (strpos2(tmpstr, "s", 1) > 0)
1613
                  if (strpos2(tmpstr, "s", 1) > 0)
1726
                    opt_bitstring = true;
1614
                    opt_bitstring = true;
1727
                }
1615
                }
1728
              }
1616
              }
1729
            }
1617
            }
1730
            if (strpos2(tmpstr, "x", 1) > 0)
1618
            if (strpos2(tmpstr, "x", 1) > 0)
1731
              opt_molstat = true;
1619
              opt_molstat = true;
1732
            if (strpos2(tmpstr, "r", 1) > 0)
1620
            if (strpos2(tmpstr, "r", 1) > 0)
1733
              opt_rs = rs_ssr;
1621
              opt_rs = rs_ssr;
1734
            if (strpos2(tmpstr, "X", 1) > 0) {
1622
            if (strpos2(tmpstr, "X", 1) > 0) {
1735
              opt_molstat = true;
1623
              opt_molstat = true;
1736
              opt_molstat_X = true;
1624
              opt_molstat_X = true;
1737
            }
1625
            }
1738
            if (strpos2(tmpstr, "m", 1) > 0) {
1626
            if (strpos2(tmpstr, "m", 1) > 0) {
1739
              opt_text = false;
1627
              opt_text = false;
1740
              opt_text_de = false;
1628
              opt_text_de = false;
1741
              opt_bin = false;
1629
              opt_bin = false;
1742
              opt_bitstring = false;
1630
              opt_bitstring = false;
1743
              opt_code = false;
1631
              opt_code = false;
1744
              opt_molstat = false;
1632
              opt_molstat = false;
1745
              opt_xmdlout = true;
1633
              opt_xmdlout = true;
1746
            }
1634
                  }
1747
          }
1635
          }
1748
          strcpy(molfilename, tmpstr);
1636
        strcpy(molfilename, tmpstr);
1749
        }
1637
      }
-
 
1638
    } else {
-
 
1639
      if (strpos2(parstr, "-", 1) == 1) {
-
 
1640
        if (strlen(parstr) > 1) {
-
 
1641
          show_usage();
-
 
1642
          _Escape(1);
-
 
1643
        }
-
 
1644
        opt_stdin = true;
1750
      } else {
1645
      } else {
1751
        if (strpos2(parstr, "-", 1) == 1) {
-
 
1752
          if (strlen(parstr) > 1) {
-
 
1753
            show_usage();
-
 
1754
            _Escape(1);
-
 
1755
          }
-
 
1756
          opt_stdin = true;
-
 
1757
        } else {
-
 
1758
          opt_stdin = false;
1646
      opt_stdin = false;
1759
          strcpy(molfilename, parstr);
1647
      strcpy(molfilename, parstr);
1760
        }
-
 
1761
      }
1648
      }
-
 
1649
        }
1762
    }
1650
    }
1763
    if (opt_text == false && opt_text_de == false && opt_code == false &&
1651
    if (opt_text == false && opt_text_de == false && opt_code == false &&
1764
        opt_bin == false && opt_bitstring == false && opt_molstat == false &&
1652
        opt_bin == false && opt_bitstring == false && opt_molstat == false &&
1765
        opt_molstat_X == false && opt_xmdlout == false)
1653
        opt_molstat_X == false && opt_xmdlout == false)
1766
      opt_none = true;
1654
      opt_none = true;
1767
  }
1655
  }
1768
  if (progmode == pmMatchMol) {
1656
  if (progmode == pmMatchMol) {
1769
    *ndl_molfilename = '\0';
1657
    *ndl_molfilename = '\0';
1770
    *molfilename = '\0';
1658
    *molfilename = '\0';
1771
    for (p = 1; p < P_argc; p++) {
1659
    for (p = 1; p < P_argc; p++) {
1772
      strcpy(parstr, P_argv[p]);
1660
        strcpy(parstr, P_argv[p]);
1773
      if (p == 1) {
1661
      if (p == 1) {
1774
        if (strpos2(parstr, "-", 1) == 1) {
1662
        if (strpos2(parstr, "-", 1) == 1) {
1775
          if (strpos2(parstr, "v", 1) > 1)
1663
          if (strpos2(parstr, "v", 1) > 1)
1776
            opt_verbose = true;
1664
            opt_verbose = true;
1777
/* p2c: checkmol.pas, line 1329:
1665
            /* p2c: checkmol.pas, line 1329:
1778
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
1666
             * Note: Turbo Pascal conditional compilation directive was ignored [218] */
1779
          /*$IFDEF debug
1667
            /*$IFDEF debug
1780
             if (strpos2(parstr, "D", 1) > 1)
1668
                if (strpos2(parstr, "D", 1) > 1)
1781
             opt_debug = true;
1669
                  opt_debug = true;
1782
             $ENDIF*/
1670
               $ENDIF*/
1783
             if (strpos2(parstr, "x", 1) > 1)
1671
          if (strpos2(parstr, "x", 1) > 1)
1784
             opt_exact = true;
1672
            opt_exact = true;
1785
             if (strpos2(parstr, "s", 1) > 1)   /* new in v0.2f */
1673
          if (strpos2(parstr, "s", 1) > 1)   /* new in v0.2f */
1786
             opt_strict = true;
1674
            opt_strict = true;
1787
             if (strpos2(parstr, "m", 1) > 1)
1675
          if (strpos2(parstr, "m", 1) > 1)
1788
             opt_molout = true;
1676
           opt_molout = true;
1789
             if (strpos2(parstr, "r", 1) > 1)
1677
          if (strpos2(parstr, "r", 1) > 1)
1790
             opt_rs = rs_ssr;
1678
            opt_rs = rs_ssr;
1791
             if (strpos2(parstr, "M", 1) > 0)   /* new in v0.3 */
1679
          if (strpos2(parstr, "M", 1) > 0)   /* new in v0.3 */
1792
             opt_metalrings = true;
1680
            opt_metalrings = true;
1793
             if (strpos2(parstr, "g", 1) > 0)   /* new in v0.3d */
1681
          if (strpos2(parstr, "g", 1) > 0)   /* new in v0.3d */
1794
             opt_geom = true;
1682
            opt_geom = true;
1795
             if (strpos2(parstr, "G", 1) > 0)   /* new in v0.3f */
1683
          if (strpos2(parstr, "G", 1) > 0)   /* new in v0.3f */
1796
             opt_chiral = true;
1684
            opt_chiral = true;
1797
             if (strpos2(parstr, "f", 1) > 0) {   /* new in v0.3m */
1685
          if (strpos2(parstr, "f", 1) > 0) {   /* new in v0.3m */
1798
             opt_fp = true;
1686
            opt_fp = true;
1799
             fpformat = fpf_boolean;
1687
          fpformat = fpf_boolean;
1800
             }
1688
        }
1801
             if (strpos2(parstr, "F", 1) > 0) {   /* new in v0.3m */
1689
        if (strpos2(parstr, "F", 1) > 0) {   /* new in v0.3m */
1802
             opt_fp = true;
1690
          opt_fp = true;
1803
             fpformat = fpf_decimal;
1691
          fpformat = fpf_decimal;
1804
             }
1692
        }
1805
             if (strpos2(parstr, "h", 1) > 1) {
1693
        if (strpos2(parstr, "h", 1) > 1) {
1806
             show_usage();
1694
          show_usage();
1807
             _Escape(0);
1695
          _Escape(0);
1808
             }
1696
        }
1809
             } else
1697
            } else
1810
             strcpy(ndl_molfilename, parstr);
1698
        strcpy(ndl_molfilename, parstr);
1811
             }
1699
    }
1812
             if (p == P_argc - 2) {
1700
    if (p == P_argc - 2) {
1813
             if (strpos2(parstr, "-", 1) != 1)
1701
      if (strpos2(parstr, "-", 1) != 1)
1814
             strcpy(ndl_molfilename, parstr);
1702
      strcpy(ndl_molfilename, parstr);
1815
             }
1703
    }
1816
             if (p == P_argc - 1) {
1704
    if (p == P_argc - 1) {
1817
             if (strcmp(parstr, "-"))
1705
      if (strcmp(parstr, "-"))
1818
             strcpy(molfilename, parstr);
1706
        strcpy(molfilename, parstr);
1819
             else
1707
      else
1820
             opt_stdin = true;
1708
        opt_stdin = true;
1821
             }
1709
      }
1822
             }
1710
    }
1823
             if (opt_geom)   /* v0.3d */
1711
    if (opt_geom)   /* v0.3d */
1824
             ez_search = true;
1712
      ez_search = true;
1825
             if (opt_chiral)   /* v0.3f */
1713
    if (opt_chiral)   /* v0.3f */
1826
             rs_search = true;
1714
      rs_search = true;
1827
             if (opt_chiral && opt_strict && (opt_exact || opt_fp))
1715
    if (opt_chiral && opt_strict && (opt_exact || opt_fp))
1828
             /* new in v0.3j, v0.3m */
1716
        /* new in v0.3j, v0.3m */
1829
             rs_strict = true;
1717
      rs_strict = true;
1830
             if (opt_fp) {   /* v0.3m */
1718
    if (opt_fp) {   /* v0.3m */
1831
             opt_molout = false;
1719
        opt_molout = false;
1832
             opt_exact = false;
1720
        opt_exact = false;
1833
             }
1721
    }
1834
             }  /* progmode = pmMatchMol */
1722
  }  /* progmode = pmMatchMol */
1835
             ringsearch_mode = opt_rs;   /* v0.3i */
1723
  ringsearch_mode = opt_rs;   /* v0.3i */
1836
             }
1724
}
1837
#endif
1725
#endif
1838
 
1726
 
1839
static void
-
 
1840
parse_args (int argc, char *argv[])
1727
static void parse_args (int argc, char *argv[])
1841
{
1728
{
1842
  short p;
1729
  short p;
1843
  char parstr[256];
1730
  char parstr[256];
1844
  char tmpstr[256];
1731
  char tmpstr[256];
1845
  short l;
1732
  short l;
1846
 
1733
 
1847
  *tmpstr = '\0';
1734
  *tmpstr = '\0';
1848
  opt_none = true;
1735
  opt_none = true;
1849
  *molfilename = '\0';
1736
  *molfilename = '\0';
1850
  *ndl_molfilename = '\0';
1737
  *ndl_molfilename = '\0';
1851
  if (progmode == pmCheckMol)
1738
  if (progmode == pmCheckMol) {
1852
    {
-
 
1853
      for (p = 1; p <= argc - 1; p++)
1739
    for (p = 1; p <= argc - 1; p++) {
1854
        {
-
 
1855
          strcpy (parstr, argv[p]);
1740
            strcpy (parstr, argv[p]);
1856
          if (!strcmp (parstr, "-l"))
1741
            if (!strcmp (parstr, "-l")) {                       /* new in v0.3l */
1857
            {                   /* new in v0.3l */
-
 
1858
              list_molstat_codes ();
1742
              list_molstat_codes ();
1859
              exit (0);
1743
              exit (0);
1860
            }
1744
            }
1861
          if (p < argc - 1)
1745
            if (p < argc - 1) {
1862
            {
-
 
1863
              if (strpos2 (parstr, "-", 1) == 1 && p < argc - 1)
1746
              if (strpos2 (parstr, "-", 1) == 1 && p < argc - 1) {
1864
                {
-
 
1865
                  strcpy (tmpstr, argv[p]);
1747
                      strcpy (tmpstr, argv[p]);
1866
                  left_trim (tmpstr);
1748
                      left_trim (tmpstr);
1867
                  l = 0;
1749
                      l = 0;
1868
                  if (strpos2 (tmpstr, "v", 1) > 0)
-
 
1869
                    l++;
-
 
1870
                  if (strpos2 (tmpstr, "D", 1) > 0)
-
 
1871
                    l++;
-
 
1872
                  if (strpos2 (tmpstr, "r", 1) > 0)
-
 
1873
                    l++;
-
 
1874
                  /*if (strpos2 (tmpstr, "a", 1) > 0)   // 0.3x
-
 
1875
                     l++; */
-
 
1876
                  if (strpos2 (tmpstr, "M", 1) > 0)     /* new in v0.3 */
-
 
1877
                    l++;
-
 
1878
                  if (strlen (tmpstr) > l + 2)
-
 
1879
                    {
-
 
1880
                      show_usage ();
-
 
1881
                      exit (1);
-
 
1882
                    }
-
 
1883
                  opt_none = false;
-
 
1884
                  if (strpos2 (tmpstr, "M", 1) > 0)
-
 
1885
                    opt_metalrings = true;
-
 
1886
                  if (strpos2 (tmpstr, "v", 1) > 0)
-
 
1887
                    opt_verbose = true;
-
 
1888
                  /*{$IFDEF debug
-
 
1889
                     if pos('D',tmpstr)>0 then opt_debug       := true;
-
 
1890
                     {$ENDIF */
-
 
1891
                  if (strpos2 (tmpstr, "e", 1) > 0)
-
 
1892
                    opt_text = true;
-
 
1893
                  else
-
 
1894
                    {
-
 
1895
                      if (strpos2 (tmpstr, "d", 1) > 0)
1750
                      if (strpos2 (tmpstr, "v", 1) > 0)
1896
                        opt_text_de = true;
-
 
1897
                      else
1751
                        l++;
1898
                        {
-
 
1899
                          if (strpos2 (tmpstr, "c", 1) > 0)
-
 
1900
                            opt_code = true;
-
 
1901
                          else
-
 
1902
                            {
-
 
1903
                              if (strpos2 (tmpstr, "b", 1) > 0)
1752
                      if (strpos2 (tmpstr, "D", 1) > 0)
1904
                                opt_bin = true;
-
 
1905
                              else
1753
                        l++;
1906
                                {
-
 
1907
                                  if (strpos2 (tmpstr, "s", 1) > 0)
-
 
1908
                                    opt_bitstring = true;
-
 
1909
                                }
-
 
1910
                            }
-
 
1911
                        }
-
 
1912
                      if (strpos2 (tmpstr, "x", 1) > 0)
-
 
1913
                        opt_molstat = true;
-
 
1914
                      if (strpos2 (tmpstr, "r", 1) > 0)
1754
                      if (strpos2 (tmpstr, "r", 1) > 0)
-
 
1755
                        l++;
-
 
1756
                      /*if (strpos2 (tmpstr, "a", 1) > 0)   // 0.3x
-
 
1757
                         l++; */
-
 
1758
                      if (strpos2 (tmpstr, "M", 1) > 0) /* new in v0.3 */
-
 
1759
                        l++;
-
 
1760
                      if (strlen (tmpstr) > l + 2) {
-
 
1761
                        show_usage ();
-
 
1762
                        exit (1);
-
 
1763
                      }
1915
                        opt_rs = rs_ssr;
1764
                      opt_none = false;
-
 
1765
                      if (strpos2 (tmpstr, "M", 1) > 0)
-
 
1766
                        opt_metalrings = true;
1916
                      /* if (strpos2 (tmpstr, "a", 1) > 0)
1767
                      if (strpos2 (tmpstr, "v", 1) > 0)
1917
                         opt_chg = true; */ /* 0.3x  */
1768
                        opt_verbose = true;
-
 
1769
                      /*{$IFDEF debug
-
 
1770
                         if pos('D',tmpstr)>0 then opt_debug       := true;
-
 
1771
                         {$ENDIF */
1918
                      if (strpos2 (tmpstr, "X", 1) > 0)
1772
                      if (strpos2 (tmpstr, "e", 1) > 0)
-
 
1773
                        opt_text = true;
1919
                        {
1774
                      else {
-
 
1775
                        if (strpos2 (tmpstr, "d", 1) > 0)
1920
                          opt_molstat = true;
1776
                                 opt_text_de = true;
-
 
1777
                        else {
-
 
1778
                                if (strpos2 (tmpstr, "c", 1) > 0)
-
 
1779
                                  opt_code = true;
-
 
1780
                                else {
-
 
1781
                                  if (strpos2 (tmpstr, "b", 1) > 0)
1921
                          opt_molstat_X = true;
1782
                                    opt_bin = true;
-
 
1783
                                  else {
-
 
1784
                                    if (strpos2 (tmpstr, "s", 1) > 0)
-
 
1785
                                      opt_bitstring = true;
-
 
1786
                                  }
-
 
1787
                                }
1922
                        }
1788
                              }
-
 
1789
                        if (strpos2 (tmpstr, "x", 1) > 0)
-
 
1790
                                opt_molstat = true;
1923
                      if (strpos2 (tmpstr, "m", 1) > 0)
1791
                        if (strpos2 (tmpstr, "r", 1) > 0)
-
 
1792
                                opt_rs = rs_ssr;
-
 
1793
                          /* if (strpos2 (tmpstr, "a", 1) > 0)
-
 
1794
                            opt_chg = true; */ /* 0.3x  */
-
 
1795
                        if (strpos2 (tmpstr, "X", 1) > 0) {
-
 
1796
                                opt_molstat = true;
-
 
1797
                                opt_molstat_X = true;
1924
                        {
1798
                              }
-
 
1799
                        if (strpos2 (tmpstr, "m", 1) > 0) {
1925
                          opt_text = false;
1800
                                opt_text = false;
1926
                          opt_text_de = false;
1801
                                opt_text_de = false;
1927
                          opt_bin = false;
1802
                                opt_bin = false;
1928
                          opt_bitstring = false;
1803
                                opt_bitstring = false;
1929
                          opt_code = false;
1804
                                opt_code = false;
1930
                          opt_molstat = false;
1805
                                opt_molstat = false;
1931
                          opt_xmdlout = true;
1806
                                opt_xmdlout = true;
-
 
1807
                              }
-
 
1808
                      }
-
 
1809
                      strcpy (molfilename, tmpstr);
-
 
1810
              }
1932
                        }
1811
            }
-
 
1812
            else {
-
 
1813
              if (strpos2 (parstr, "-", 1) == 1) {
-
 
1814
                if (strlen (parstr) > 1) {
-
 
1815
                  show_usage ();
-
 
1816
                  exit (1);
-
 
1817
                }
-
 
1818
                opt_stdin = true;
-
 
1819
              } else {
-
 
1820
                      opt_stdin = false;
-
 
1821
                      strcpy (molfilename, parstr);
1933
                    }
1822
                    }
1934
                  strcpy (molfilename, tmpstr);
-
 
1935
                }
-
 
1936
            }
1823
            }
1937
          else
-
 
1938
            {
-
 
1939
              if (strpos2 (parstr, "-", 1) == 1)
-
 
1940
                {
-
 
1941
                  if (strlen (parstr) > 1)
-
 
1942
                    {
-
 
1943
                      show_usage ();
-
 
1944
                      exit (1);
-
 
1945
                    }
-
 
1946
                  opt_stdin = true;
-
 
1947
                }
-
 
1948
              else
-
 
1949
                {
-
 
1950
                  opt_stdin = false;
-
 
1951
                  strcpy (molfilename, parstr);
-
 
1952
                }
-
 
1953
            }
1824
          }
1954
        }
-
 
1955
      if (opt_text == false && opt_text_de == false && opt_code == false &&
1825
    if (opt_text == false && opt_text_de == false && opt_code == false &&
1956
          opt_bin == false && opt_bitstring == false && opt_molstat == false
1826
                opt_bin == false && opt_bitstring == false && opt_molstat == false
1957
          && opt_molstat_X == false && opt_xmdlout == false
1827
                && opt_molstat_X == false && opt_xmdlout == false
1958
          && opt_chg == false)
1828
                && opt_chg == false)
1959
        opt_none = true;        /* 0.3x */
1829
              opt_none = true;  /* 0.3x */
1960
    }
1830
  }
1961
  if (progmode == pmMatchMol)
1831
  if (progmode == pmMatchMol) {
1962
    {
-
 
1963
 
-
 
1964
      for (p = 1; p <= argc - 1; p++)
1832
    for (p = 1; p <= argc - 1; p++) {
1965
        {
-
 
1966
          strcpy (parstr, argv[p]);
1833
      strcpy (parstr, argv[p]);
1967
          if (p == 1)
1834
      if (p == 1) {
1968
            {
-
 
1969
              if (strpos2 (parstr, "-", 1) == 1)
1835
        if (strpos2 (parstr, "-", 1) == 1) {
1970
                {
-
 
1971
                  if (strpos2 (parstr, "v", 1) > 1)
1836
          if (strpos2 (parstr, "v", 1) > 1)
1972
                    opt_verbose = true;
1837
            opt_verbose = true;
1973
                  /*{$IFDEF debug
1838
            /*{$IFDEF debug
1974
                     if pos('D',parstr)>1 then opt_debug       := true;
1839
               if pos('D',parstr)>1 then opt_debug       := true;
1975
                     {$ENDIF */
1840
               {$ENDIF */
1976
                  if (strpos2 (parstr, "x", 1) > 1)
1841
          if (strpos2 (parstr, "x", 1) > 1)
1977
                    opt_exact = true;
1842
            opt_exact = true;
1978
                  if (strpos2 (parstr, "s", 1) > 1)     /* new in v0.2f */
1843
          if (strpos2 (parstr, "s", 1) > 1)     /* new in v0.2f */
1979
                    opt_strict = true;
1844
            opt_strict = true;
1980
                  if (strpos2 (parstr, "m", 1) > 1)
1845
          if (strpos2 (parstr, "m", 1) > 1)
1981
                    opt_molout = true;
1846
            opt_molout = true;
1982
                  if (strpos2 (parstr, "r", 1) > 1)
1847
          if (strpos2 (parstr, "r", 1) > 1)
1983
                    opt_rs = rs_ssr;
1848
            opt_rs = rs_ssr;
1984
                  if (strpos2 (parstr, "a", 1) > 0)
1849
          if (strpos2 (parstr, "a", 1) > 0)
1985
                    opt_chg = true;     /* 0.3x */
1850
                    opt_chg = true;     /* 0.3x */
1986
                  if (strpos2 (parstr, "i", 1) > 0)
1851
          if (strpos2 (parstr, "i", 1) > 0)
1987
                    opt_iso = true;     /* 0.3x */
1852
            opt_iso = true;     /* 0.3x */
1988
                  if (strpos2 (parstr, "d", 1) > 0)
1853
          if (strpos2 (parstr, "d", 1) > 0)
1989
                    opt_rad = true;     /* 0.3x */
1854
            opt_rad = true;     /* 0.3x */
1990
                  if (strpos2 (parstr, "M", 1) > 0)     /* new in v0.3 */
1855
          if (strpos2 (parstr, "M", 1) > 0)     /* new in v0.3 */
1991
                    opt_metalrings = true;
1856
            opt_metalrings = true;
1992
                  if (strpos2 (parstr, "g", 1) > 0)     /* new in v0.3d */
1857
          if (strpos2 (parstr, "g", 1) > 0)     /* new in v0.3d */
1993
                    opt_geom = true;
1858
            opt_geom = true;
1994
                  if (strpos2 (parstr, "G", 1) > 0)     /* new in v0.3f */
1859
          if (strpos2 (parstr, "G", 1) > 0)     /* new in v0.3f */
1995
                    opt_chiral = true;
1860
            opt_chiral = true;
1996
                  if (strpos2 (parstr, "f", 1) > 0)
1861
          if (strpos2 (parstr, "f", 1) > 0) {           /* new in v0.3m */
1997
                    {           /* new in v0.3m */
-
 
1998
                      opt_fp = true;
1862
            opt_fp = true;
1999
                      fpformat = fpf_boolean;
1863
            fpformat = fpf_boolean;
2000
                    }
1864
          }
2001
                  if (strpos2 (parstr, "F", 1) > 0)
1865
          if (strpos2 (parstr, "F", 1) > 0) {           /* new in v0.3m */
2002
                    {           /* new in v0.3m */
-
 
2003
                      opt_fp = true;
1866
            opt_fp = true;
2004
                      fpformat = fpf_decimal;
1867
            fpformat = fpf_decimal;
2005
                    }
1868
          }
2006
                  if (strpos2 (parstr, "h", 1) > 1)
1869
          if (strpos2 (parstr, "h", 1) > 1) {
2007
                    {
-
 
2008
                      show_usage ();
1870
            show_usage ();
2009
                      exit (0);
1871
            exit (0);
2010
                    }
1872
          }
2011
                }
-
 
2012
              else
1873
              } else
2013
                strcpy (ndl_molfilename, parstr);
1874
                strcpy (ndl_molfilename, parstr);
2014
            }
1875
            }
2015
          if (p == argc - 2)
1876
            if (p == argc - 2) {
2016
            {
-
 
2017
              if (strpos2 (parstr, "-", 1) != 1)
1877
              if (strpos2 (parstr, "-", 1) != 1)
2018
                strcpy (ndl_molfilename, parstr);
1878
                strcpy (ndl_molfilename, parstr);
2019
            }
1879
              }
2020
          if (p == argc - 1)
1880
            if (p == argc - 1) {
2021
            {
-
 
2022
              if (strcmp (parstr, "-"))
1881
              if (strcmp (parstr, "-"))
2023
                strcpy (molfilename, parstr);
1882
                strcpy (molfilename, parstr);
2024
              else
1883
              else
2025
                opt_stdin = true;
1884
                opt_stdin = true;
2026
            }
1885
            }
2027
        }
1886
          }
2028
      if (opt_geom)             /* v0.3d */
1887
    if (opt_geom)               /* v0.3d */
2029
        ez_search = true;
1888
            ez_search = true;
2030
      if (opt_chiral)           /* v0.3f */
1889
    if (opt_chiral)             /* v0.3f */
2031
        rs_search = true;
1890
            rs_search = true;
2032
      if (opt_chiral && opt_strict && (opt_exact || opt_fp))
1891
    if (opt_chiral && opt_strict && (opt_exact || opt_fp))
2033
        /* new in v0.3j, v0.3m  */
1892
            /* new in v0.3j, v0.3m  */
2034
        rs_strict = true;
1893
            rs_strict = true;
2035
      if (opt_fp)
-
 
2036
        {                       /* v0.3m */
1894
    if (opt_fp) {                       /* v0.3m */
2037
          opt_molout = false;
1895
            opt_molout = false;
2038
          opt_exact = false;
1896
            opt_exact = false;
2039
        }
1897
          }
2040
    }                           /* progmode = pmMatchMol */
1898
  }                             /* progmode = pmMatchMol */
2041
  ringsearch_mode = opt_rs;     /* v0.3i */
1899
  ringsearch_mode = opt_rs;     /* v0.3i */
2042
}
1900
}
2043
 
1901
 
2044
/*============== input-related functions & procedures ===================== */
1902
/*============== input-related functions & procedures ===================== */
2045
 
1903
 
2046
static char *
-
 
2047
get_filetype (Result, f)
1904
static char *get_filetype (Result, f)
2048
     char *Result;
1905
  char *Result;
2049
     char *f;
1906
  char *f;
2050
{
1907
{
2051
  char rline[256];
1908
  char rline[256];
2052
  char auxstr[256];
1909
  char auxstr[256];
2053
  int i;
1910
  int i;
2054
  boolean mdl1 = false;
1911
  boolean mdl1 = false;
Line 2057... Line 1914...
2057
  char STR1[256], STR6[256], STR7[256];
1914
  char STR1[256], STR6[256], STR7[256];
2058
 
1915
 
2059
  strcpy (auxstr, "unknown");
1916
  strcpy (auxstr, "unknown");
2060
  i = li;
1917
  i = li;
2061
  ri = li - 1;
1918
  ri = li - 1;
2062
  while (ri < molbufindex && sepcount < 1)
1919
  while (ri < molbufindex && sepcount < 1) {
2063
    {
-
 
2064
      ri++;
1920
    ri++;
2065
      strcpy (rline, molbuf[ri - 1]);
1921
    strcpy (rline, molbuf[ri - 1]);
2066
      if (strpos2 (rline, "$$$$", 1) > 0)
1922
    if (strpos2 (rline, "$$$$", 1) > 0)
2067
        sepcount++;
1923
            sepcount++;
2068
      if ((i == li) && (strcmp (strsub (STR1, rline, 7, 5), "ATOMS") == 0) &&
1924
    if ((i == li) && (strcmp (strsub (STR1, rline, 7, 5), "ATOMS") == 0) &&
2069
          (strcmp (strsub (STR6, rline, 20, 5), "BONDS") == 0) &&
1925
              (strcmp (strsub (STR6, rline, 20, 5), "BONDS") == 0) &&
2070
          (strcmp (strsub (STR7, rline, 33, 7), "CHARGES") == 0))
1926
              (strcmp (strsub (STR7, rline, 33, 7), "CHARGES") == 0))
2071
        strcpy (auxstr, "alchemy");
1927
            strcpy (auxstr, "alchemy");
2072
      if ((i == li + 3) && (strcmp (strsub (STR1, rline, 35, 5), "V2000") ==
1928
    if ((i == li + 3) && (strcmp (strsub (STR1, rline, 35, 5), "V2000") == 0))
2073
                            0))
-
 
2074
        /* and (copy(rline,31,3)='999') */
1929
            /* and (copy(rline,31,3)='999') */
2075
        mdl1 = true;
1930
            mdl1 = true;
2076
      if ((i == li + 1) && (strcmp (strsub (STR1, rline, 3, 6), "-ISIS-") ==
1931
    if ((i == li + 1) && (strcmp (strsub (STR1, rline, 3, 6), "-ISIS-") == 0))
2077
                            0))
-
 
2078
        mdl1 = true;
1932
            mdl1 = true;
2079
      if ((i == li + 1) && (strcmp (strsub (STR1, rline, 3, 8), "WLViewer") ==
1933
    if ((i == li + 1) && (strcmp (strsub (STR1, rline, 3, 8), "WLViewer") == 0))
2080
                            0))
-
 
2081
        mdl1 = true;
1934
            mdl1 = true;
2082
      if ((i == li + 1) && (strcmp (strsub (STR1, rline, 3, 8), "CheckMol") ==
1935
    if ((i == li + 1) && (strcmp (strsub (STR1, rline, 3, 8), "CheckMol") == 0))
2083
                            0))
-
 
2084
        mdl1 = true;
1936
            mdl1 = true;
2085
      if ((i == li + 1) && (strcmp (strsub (STR1, rline, 3, 8), "CATALYST") ==
1937
    if ((i == li + 1) && (strcmp (strsub (STR1, rline, 3, 8), "CATALYST") == 0)) {
2086
                            0))
-
 
2087
        {
-
 
2088
          mdl1 = true;
1938
            mdl1 = true;
2089
          strcpy (auxstr, "mdl");
1939
            strcpy (auxstr, "mdl");
2090
        }
1940
          }
2091
      if (strpos2 (rline, "M  END", 1) == 1 || mdl1)
1941
    if (strpos2 (rline, "M  END", 1) == 1 || mdl1)
2092
        strcpy (auxstr, "mdl");
1942
            strcpy (auxstr, "mdl");
2093
      if (strpos2 (rline, "@<TRIPOS>MOLECULE", 1) > 0)
1943
    if (strpos2 (rline, "@<TRIPOS>MOLECULE", 1) > 0)
2094
        strcpy (auxstr, "sybyl");
1944
            strcpy (auxstr, "sybyl");
2095
      i++;
1945
    i++;
2096
    }
1946
  }
2097
  /* new in v0.2j: try to identify non-conformant SD-files */
1947
  /* new in v0.2j: try to identify non-conformant SD-files */
2098
  if (!strcmp (auxstr, "unknown") && sepcount > 0)
1948
  if (!strcmp (auxstr, "unknown") && sepcount > 0)
2099
    strcpy (auxstr, "mdl");
1949
    strcpy (auxstr, "mdl");
2100
  return strcpy (Result, auxstr);
1950
  return strcpy (Result, auxstr);
2101
}
1951
}
2102
 
-
 
2103
 
1952
 
2104
static void
-
 
2105
zap_molecule ()
1953
static void zap_molecule ()
2106
{
1954
{
2107
  /* try */
1955
  /* try */
2108
  if (atom != NULL)
1956
  if (atom != NULL) {
2109
    {
-
 
2110
      free (atom);
1957
    free (atom);
2111
      atom = NULL;              /* added in v0.3j */
1958
    atom = NULL;                /* added in v0.3j */
2112
    }
1959
  }
2113
  if (bond != NULL)
1960
  if (bond != NULL) {
2114
    {
-
 
2115
      free (bond);
1961
    free (bond);
2116
      bond = NULL;              /* added in v0.3j */
1962
    bond = NULL;                /* added in v0.3j */
2117
    }
1963
  }
2118
  if (ring != NULL)
1964
  if (ring != NULL) {
2119
    {
-
 
2120
      free (ring);
1965
    free (ring);
2121
      ring = NULL;              /* added in v0.3j */
1966
    ring = NULL;                /* added in v0.3j */
2122
    }
1967
  }
2123
  if (ringprop != NULL)
1968
  if (ringprop != NULL) {
2124
    {
-
 
2125
      free (ringprop);
1969
    free (ringprop);
2126
      ringprop = NULL;          /* added in v0.3j */
1970
    ringprop = NULL;            /* added in v0.3j */
2127
    }
1971
  }
2128
  /* except
1972
  /* except
2129
     on e:Einvalidpointer do begin end;
1973
    on e:Einvalidpointer do begin end;
2130
     end; */
1974
    end; */
2131
  n_atoms = 0;
1975
  n_atoms = 0;
2132
  n_bonds = 0;
1976
  n_bonds = 0;
2133
  n_rings = 0;
1977
  n_rings = 0;
2134
}
1978
}
2135
 
1979
 
2136
 
-
 
2137
static void
-
 
2138
zap_needle ()
1980
static void zap_needle ()
2139
{
1981
{
2140
  /* try */
1982
  /* try */
2141
  if (ndl_atom != NULL)
1983
  if (ndl_atom != NULL) {
2142
    {
-
 
2143
      free (ndl_atom);
1984
    free (ndl_atom);
2144
      ndl_atom = NULL;          /* added in v0.3j */
1985
    ndl_atom = NULL;            /* added in v0.3j */
2145
    }
1986
  }
2146
  if (ndl_bond != NULL)
1987
  if (ndl_bond != NULL) {
2147
    {
-
 
2148
      free (ndl_bond);
1988
    free (ndl_bond);
2149
      ndl_bond = NULL;          /* added in v0.3j */
1989
    ndl_bond = NULL;            /* added in v0.3j */
2150
    }
1990
  }
2151
  if (ndl_ring != NULL)
1991
  if (ndl_ring != NULL) {
2152
    {
-
 
2153
      free (ndl_ring);
1992
    free (ndl_ring);
2154
      ndl_ring = NULL;          /* added in v0.3j */
1993
    ndl_ring = NULL;            /* added in v0.3j */
2155
    }
1994
  }
2156
  if (ndl_ringprop != NULL)
1995
  if (ndl_ringprop != NULL) {
2157
    {
-
 
2158
      free (ndl_ringprop);      /* fixed in v0.3g */
1996
    free (ndl_ringprop);        /* fixed in v0.3g */
2159
      ndl_ringprop = NULL;      /* added in v0.3j */
1997
    ndl_ringprop = NULL;        /* added in v0.3j */
2160
    }
1998
  }
2161
  /* except
1999
  /* except
2162
     on e:Einvalidpointer do begin end;
2000
     on e:Einvalidpointer do begin end;
2163
     end; */
2001
     end; */
2164
  ndl_n_atoms = 0;
2002
  ndl_n_atoms = 0;
2165
  ndl_n_bonds = 0;
2003
  ndl_n_bonds = 0;
2166
  ndl_n_rings = 0;
2004
  ndl_n_rings = 0;
2167
}
2005
}
2168
 
2006
 
2169
#if 0
2007
#if 0
2170
static void
2008
static void zap_tmp ()
2171
zap_tmp ()
-
 
2172
{
2009
{
2173
  /* try */
2010
  /* try */
2174
  if (tmp_atom != NULL)
2011
  if (tmp_atom != NULL) {
2175
    {
-
 
2176
      free (tmp_atom);
2012
      free (tmp_atom);
2177
      tmp_atom = NULL;          /* added in v0.3j */
2013
      tmp_atom = NULL;          /* added in v0.3j */
2178
    }
2014
    }
2179
  if (tmp_bond != NULL)
2015
  if (tmp_bond != NULL) {
2180
    {
-
 
2181
      free (tmp_bond);
2016
      free (tmp_bond);
2182
      tmp_bond = NULL;          /* added in v0.3j */
2017
      tmp_bond = NULL;          /* added in v0.3j */
2183
    }
2018
    }
2184
  if (tmp_ring != NULL)
2019
  if (tmp_ring != NULL) {
2185
    {
-
 
2186
      free (tmp_ring);
2020
      free (tmp_ring);
2187
      tmp_ring = NULL;          /* added in v0.3j */
2021
      tmp_ring = NULL;          /* added in v0.3j */
2188
    }
2022
    }
2189
  if (tmp_ringprop != NULL)
2023
  if (tmp_ringprop != NULL) {
2190
    {
-
 
2191
      free (tmp_ringprop);      /* fixed in v0.3g */
2024
      free (tmp_ringprop);      /* fixed in v0.3g */
2192
      tmp_ringprop = NULL;      /* added in v0.3j */
2025
      tmp_ringprop = NULL;      /* added in v0.3j */
2193
    }
2026
    }
2194
  /* except
2027
  /* except
2195
     on e:Einvalidpointer do begin end;
2028
     on e:Einvalidpointer do begin end;
Line 2198... Line 2031...
2198
  tmp_n_bonds = 0;
2031
  tmp_n_bonds = 0;
2199
  tmp_n_rings = 0;
2032
  tmp_n_rings = 0;
2200
}
2033
}
2201
#endif
2034
#endif
2202
 
2035
 
2203
static boolean
-
 
2204
is_heavyatom (id)
2036
static boolean is_heavyatom (id)
2205
     int id;
2037
     int id;
2206
{
2038
{
2207
  str2 el;
2039
  str2 el;
2208
 
2040
 
2209
  strcpy (el, atom[id - 1].element);
2041
  strcpy (el, atom[id - 1].element);
2210
 
2042
 
2211
  if (!strcmp (el, "DU") || !strcmp (el, "LP"))
2043
  if (!strcmp (el, "DU") || !strcmp (el, "LP"))
2212
    return false;
2044
    return false;
2213
  /*if (progmode == pmCheckMol && !strcmp (el, "H ")
2045
  /*if (progmode == pmCheckMol && !strcmp (el, "H ")
2214
     && atom[id - 1].nucleon_number < 2)
2046
     && atom[id - 1].nucleon_number < 2)
2215
     return false;               0.3x  */
2047
     return false;               0.3x  */
2216
  if (!strcmp (el, "H "))       /* 0.3 p */
2048
  if (!strcmp (el, "H "))       /* 0.3 p */ {
2217
    {
-
 
2218
      if (progmode == pmMatchMol && !opt_iso)
2049
    if (progmode == pmMatchMol && !opt_iso) {
2219
        {
-
 
2220
          return false;
2050
            return false;
2221
        }
2051
          }
2222
      else
2052
    else {
2223
        {
-
 
2224
          if (atom[id - 1].nucleon_number < 2)
2053
          if (atom[id - 1].nucleon_number < 2)
2225
            return false;
2054
            return false;
2226
        }
2055
          }
2227
    }
2056
  }
2228
  return true;
2057
  return true;
2229
}
2058
}
2230
 
2059
 
2231
 
-
 
2232
static boolean
-
 
2233
ndl_alkene_C (ba)
2060
static boolean ndl_alkene_C (ba)
2234
     int ba;
2061
     int ba;
2235
{
2062
{
2236
  /* new in v0.3f */
2063
  /* new in v0.3f */
2237
  boolean res = false;
2064
  boolean res = false;
2238
  int i, ba2, FORLIM;
2065
  int i, ba2, FORLIM;
2239
 
2066
 
2240
  if (ndl_n_atoms <= 0 || ndl_n_bonds <= 0)
2067
  if (ndl_n_atoms <= 0 || ndl_n_bonds <= 0)
2241
    return false;
2068
    return false;
2242
  FORLIM = ndl_n_bonds;
2069
  FORLIM = ndl_n_bonds;
2243
  for (i = 0; i < FORLIM; i++)
2070
  for (i = 0; i < FORLIM; i++) {
2244
    {
-
 
2245
      if (ndl_bond[i].a1 == ba || ndl_bond[i].a2 == ba)
2071
    if (ndl_bond[i].a1 == ba || ndl_bond[i].a2 == ba) {
2246
        {
-
 
2247
          if (ndl_bond[i].a1 == ba)
2072
            if (ndl_bond[i].a1 == ba)
2248
            ba2 = ndl_bond[i].a2;
2073
              ba2 = ndl_bond[i].a2;
2249
          else
2074
            else
2250
            ba2 = ndl_bond[i].a1;
2075
              ba2 = ndl_bond[i].a1;
2251
          if (!strcmp (ndl_atom[ba - 1].atype, "C2 ") &&
2076
          if (!strcmp (ndl_atom[ba - 1].atype, "C2 ") &&
2252
              !strcmp (ndl_atom[ba2 - 1].atype, "C2 ")
2077
              !strcmp (ndl_atom[ba2 - 1].atype, "C2 ")
2253
              && ndl_bond[i].btype == 'D' && ndl_bond[i].arom == false)
2078
              && ndl_bond[i].btype == 'D' && ndl_bond[i].arom == false)
2254
            res = true;
2079
            res = true;
2255
        }
2080
          }
2256
    }
2081
  }
2257
  return res;
2082
  return res;
2258
}
2083
}
2259
 
2084
 
2260
 
-
 
2261
static boolean
2085
static boolean is_metal (id)
2262
is_metal (id)
-
 
2263
     int id;
2086
     int id;
2264
{
2087
{
2265
  boolean r = false;
2088
  boolean r = false;
2266
  str2 el;
2089
  str2 el;
2267
 
2090
 
Line 2275... Line 2098...
2275
      !strcmp (el, "PD") || !strcmp (el, "PT") || !strcmp (el, "SN") ||
2098
      !strcmp (el, "PD") || !strcmp (el, "PT") || !strcmp (el, "SN") ||
2276
      !strcmp (el, "CU") || !strcmp (el, "AG") || !strcmp (el, "AU") ||
2099
      !strcmp (el, "CU") || !strcmp (el, "AG") || !strcmp (el, "AU") ||
2277
      !strcmp (el, "ZN") || !strcmp (el, "CD") || !strcmp (el, "HG") ||
2100
      !strcmp (el, "ZN") || !strcmp (el, "CD") || !strcmp (el, "HG") ||
2278
      !strcmp (el, "AL") || !strcmp (el, "SN") || !strcmp (el, "PB") ||
2101
      !strcmp (el, "AL") || !strcmp (el, "SN") || !strcmp (el, "PB") ||
2279
      !strcmp (el, "SB") || !strcmp (el, "BI"))
2102
      !strcmp (el, "SB") || !strcmp (el, "BI"))
2280
/* p2c: checkmol.pas, line 1577:
2103
  /* p2c: checkmol.pas, line 1577:
2281
 * Note: Line breaker spent 0.0 seconds, 5000 tries on line 1686 [251] */
2104
  * Note: Line breaker spent 0.0 seconds, 5000 tries on line 1686 [251] */
2282
    /* etc. etc. */
2105
    /* etc. etc. */
2283
    r = true;
2106
    r = true;
2284
  return r;
2107
  return r;
2285
}
2108
}
2286
 
-
 
2287
 
2109
 
2288
static int
-
 
2289
get_nvalences (a_el)
2110
static int get_nvalences (a_el)
2290
     char *a_el;
2111
     char *a_el;
2291
{
2112
{
2292
  /* changed name and position in v0.3m */
2113
  /* changed name and position in v0.3m */
2293
  /* preliminary version; should be extended to element/atomtype */
2114
  /* preliminary version; should be extended to element/atomtype */
2294
  int res = 1;
2115
  int res = 1;
2295
 
2116
 
2296
  if (!strcmp (a_el, "H "))
2117
  if (!strcmp (a_el, "H "))
2297
    res = 1;
2118
    res = 1;
2298
  /*if (!strcmp (a_el, "D "))   // v0.3n
2119
  /*if (!strcmp (a_el, "D "))   // v0.3n
2299
     res = 1; */
2120
     res = 1; */
2300
  if (!strcmp (a_el, "C "))
2121
  if (!strcmp (a_el, "C "))
2301
    res = 4;
2122
    res = 4;
2302
  if (!strcmp (a_el, "N "))
2123
  if (!strcmp (a_el, "N "))
2303
    res = 3;
2124
    res = 3;
2304
  if (!strcmp (a_el, "O "))
2125
  if (!strcmp (a_el, "O "))
2305
    res = 2;
2126
    res = 2;
2306
  if (!strcmp (a_el, "S "))
2127
  if (!strcmp (a_el, "S "))
2307
    res = 2;
2128
    res = 2;
2308
  if (!strcmp (a_el, "SE"))
2129
  if (!strcmp (a_el, "SE"))
2309
    res = 2;
2130
    res = 2;
2310
  if (!strcmp (a_el, "TE"))
2131
  if (!strcmp (a_el, "TE"))
2311
    res = 2;
2132
    res = 2;
2312
  if (!strcmp (a_el, "P "))
2133
  if (!strcmp (a_el, "P "))
Line 2352... Line 2173...
2352
  if (!strcmp (a_el, "A "))
2173
  if (!strcmp (a_el, "A "))
2353
    res = 4;
2174
    res = 4;
2354
  if (!strcmp (a_el, "Q "))
2175
  if (!strcmp (a_el, "Q "))
2355
    res = 4;
2176
    res = 4;
2356
  return res;
2177
  return res;
2357
}
2178
}
2358
 
-
 
2359
 
2179
 
2360
static char *
-
 
2361
convert_type (Result, oldtype)
2180
static char * convert_type (Result, oldtype)
2362
     char *Result;
2181
     char *Result;
2363
     char *oldtype;
2182
     char *oldtype;
2364
{
2183
{
2365
  int i;
2184
  int i;
2366
  str3 newtype;
2185
  str3 newtype;
Line 2373... Line 2192...
2373
  if (newtype[0] == '*')
2192
  if (newtype[0] == '*')
2374
    strcpy (newtype, "STR");
2193
    strcpy (newtype, "STR");
2375
  return strcpy (Result, newtype);
2194
  return strcpy (Result, newtype);
2376
}
2195
}
2377
 
2196
 
2378
 
-
 
2379
static char *
-
 
2380
convert_sybtype (Result, oldtype)
2197
static char * convert_sybtype (Result, oldtype)
2381
     char *Result;
2198
     char *Result;
2382
     char *oldtype;
2199
     char *oldtype;
2383
{
2200
{
2384
  str3 newtype;
2201
  str3 newtype;
2385
 
2202
 
Line 2473... Line 2290...
2473
  if (!strcmp (oldtype, "P.4  "))
2290
  if (!strcmp (oldtype, "P.4  "))
2474
    strcpy (newtype, "P4 ");
2291
    strcpy (newtype, "P4 ");
2475
  return strcpy (Result, newtype);
2292
  return strcpy (Result, newtype);
2476
}
2293
}
2477
 
2294
 
2478
 
-
 
2479
static char *
-
 
2480
convert_MDLtype (Result, oldtype)
2295
static char * convert_MDLtype (Result, oldtype)
2481
     char *Result, *oldtype;
2296
     char *Result, *oldtype;
2482
{
2297
{
2483
  str3 newtype;
2298
  str3 newtype;
2484
 
2299
 
2485
  /*  NewType := Copy(OldType,1,3); */
2300
  /*  NewType := Copy(OldType,1,3); */
Line 2517... Line 2332...
2517
    strcpy (newtype, "LI ");
2332
    strcpy (newtype, "LI ");
2518
  if (!strcmp (oldtype, "LP "))
2333
  if (!strcmp (oldtype, "LP "))
2519
    strcpy (newtype, "LP ");
2334
    strcpy (newtype, "LP ");
2520
  if (!strcmp (oldtype, "Na "))
2335
  if (!strcmp (oldtype, "Na "))
2521
    strcpy (newtype, "NA ");
2336
    strcpy (newtype, "NA ");
2522
  if (!strcmp (oldtype, "P  "))
2337
  if (!strcmp (oldtype, "P  "))
2523
    strcpy (newtype, "P3 ");
2338
    strcpy (newtype, "P3 ");
2524
  if (!strcmp (oldtype, "S  "))
2339
  if (!strcmp (oldtype, "S  "))
2525
    strcpy (newtype, "S3 ");
2340
    strcpy (newtype, "S3 ");
2526
  if (!strcmp (oldtype, "Si "))
2341
  if (!strcmp (oldtype, "Si "))
2527
    strcpy (newtype, "SI ");
2342
    strcpy (newtype, "SI ");
Line 2532... Line 2347...
2532
  if (!strcmp (oldtype, "Q  "))
2347
  if (!strcmp (oldtype, "Q  "))
2533
    strcpy (newtype, "Q  ");
2348
    strcpy (newtype, "Q  ");
2534
  return strcpy (Result, newtype);
2349
  return strcpy (Result, newtype);
2535
}
2350
}
2536
 
2351
 
2537
 
-
 
2538
static char *
-
 
2539
get_element (Result, oldtype)
2352
static char * get_element (Result, oldtype)
2540
     char *Result;
2353
     char *Result;
2541
     char *oldtype;
2354
     char *oldtype;
2542
{
2355
{
2543
  char elemstr[256];
2356
  char elemstr[256];
2544
 
2357
 
2545
  if (!strcmp (oldtype, "H   "))
2358
  if (!strcmp (oldtype, "H   "))
2546
    strcpy (elemstr, "H ");
2359
    strcpy (elemstr, "H ");
2547
  /* if (!strcmp (oldtype, "D   "))  // v0.3n
2360
  /* if (!strcmp (oldtype, "D   "))  // v0.3n
2548
     strcpy (elemstr, "D "); */
2361
     strcpy (elemstr, "D "); */
2549
  if (!strcmp (oldtype, "CAR "))
2362
  if (!strcmp (oldtype, "CAR "))
2550
    strcpy (elemstr, "C ");
2363
    strcpy (elemstr, "C ");
2551
  if (!strcmp (oldtype, "C2  "))
2364
  if (!strcmp (oldtype, "C2  "))
2552
    strcpy (elemstr, "C ");
2365
    strcpy (elemstr, "C ");
Line 2625... Line 2438...
2625
  if (!strcmp (oldtype, "Q   "))
2438
  if (!strcmp (oldtype, "Q   "))
2626
    strcpy (elemstr, "Q ");
2439
    strcpy (elemstr, "Q ");
2627
  return strcpy (Result, elemstr);
2440
  return strcpy (Result, elemstr);
2628
}
2441
}
2629
 
2442
 
2630
 
-
 
2631
static char *
-
 
2632
get_sybelement (Result, oldtype)
2443
static char * get_sybelement (Result, oldtype)
2633
     char *Result;
2444
     char *Result;
2634
     char *oldtype;
2445
     char *oldtype;
2635
{
2446
{
2636
  int i;
2447
  int i;
2637
  str2 elemstr;
2448
  str2 elemstr;
2638
 
2449
 
2639
  if (strpos2 (oldtype, ".", 1) < 2)
2450
  if (strpos2 (oldtype, ".", 1) < 2)
2640
    sprintf (elemstr, "%.2s", oldtype);
2451
    sprintf (elemstr, "%.2s", oldtype);
2641
  else
2452
  else {
2642
    {
-
 
2643
      sprintf (elemstr, "%.*s", strpos2 (oldtype, ".", 1) - 1, oldtype);
2453
    sprintf (elemstr, "%.*s", strpos2 (oldtype, ".", 1) - 1, oldtype);
2644
      if (strlen (elemstr) < 2)
2454
    if (strlen (elemstr) < 2)
2645
        strcat (elemstr, " ");
2455
            strcat (elemstr, " ");
2646
    }
2456
  }
2647
  for (i = 0; i <= 1; i++)
2457
  for (i = 0; i <= 1; i++)
2648
    elemstr[i] = toupper (elemstr[i]);
2458
    elemstr[i] = toupper (elemstr[i]);
2649
  return strcpy (Result, elemstr);
2459
  return strcpy (Result, elemstr);
2650
}
2460
}
2651
 
-
 
2652
 
2461
 
2653
static char *
-
 
2654
get_MDLelement (Result, oldtype)
2462
static char * get_MDLelement (Result, oldtype)
2655
     char *Result;
2463
     char *Result;
2656
     char *oldtype;
2464
     char *oldtype;
2657
{
2465
{
2658
  int i;
2466
  int i;
2659
  str2 elemstr;
2467
  str2 elemstr;
Line 2666... Line 2474...
2666
  if (elemstr[0] == '*')
2474
  if (elemstr[0] == '*')
2667
    strcpy (elemstr, "??");
2475
    strcpy (elemstr, "??");
2668
  return strcpy (Result, elemstr);
2476
  return strcpy (Result, elemstr);
2669
}
2477
}
2670
 
2478
 
2671
static void
-
 
2672
read_molfile (mfilename)
2479
static void read_molfile (mfilename)
2673
     char *mfilename;
2480
     char *mfilename;
2674
{
2481
{
2675
  /* reads ALCHEMY mol files */
2482
  /* reads ALCHEMY mol files */
2676
  int n;
2483
  int n;
2677
  char rline[256], tmpstr[256];
2484
  char rline[256], tmpstr[256];
Line 2691... Line 2498...
2691
  sprintf (tmpstr, "%.5s", rline);
2498
  sprintf (tmpstr, "%.5s", rline);
2692
  (void)sscanf (tmpstr, "%d", &n_atoms);
2499
  (void)sscanf (tmpstr, "%d", &n_atoms);
2693
  strsub (tmpstr, rline, 14, 5);
2500
  strsub (tmpstr, rline, 14, 5);
2694
  (void)sscanf (tmpstr, "%d", &n_bonds);
2501
  (void)sscanf (tmpstr, "%d", &n_bonds);
2695
  strsub (molname, rline, 42, (int) (strlen (rline) - 42L));
2502
  strsub (molname, rline, 42, (int) (strlen (rline) - 42L));
2696
  /* try */
2503
  /* try */
2697
  atom = safe_calloc (n_atoms, sizeof (atom_rec));
2504
  atom = safe_calloc (n_atoms, sizeof (atom_rec));
2698
  bond = safe_calloc (n_bonds, sizeof (bond_rec));
2505
  bond = safe_calloc (n_bonds, sizeof (bond_rec));
2699
  ring = safe_calloc (1, sizeof (ringlist));
2506
  ring = safe_calloc (1, sizeof (ringlist));
2700
  ringprop = safe_calloc (1, sizeof (ringprop_type));
2507
  ringprop = safe_calloc (1, sizeof (ringprop_type));
2701
  /* except
2508
  /* except
2702
     on e:Eoutofmemory do
2509
     on e:Eoutofmemory do
2703
     begin
2510
     begin
2704
     writeln('Not enough memory');
2511
     writeln('Not enough memory');
2705
     halt(4);
2512
     halt(4);
2706
     end;
2513
     end;
2707
     end; */
2514
     end; */
2708
  n_heavyatoms = 0;
2515
  n_heavyatoms = 0;
2709
  n_heavybonds = 0;
2516
  n_heavybonds = 0;
2710
  n_Ctot = 0;                   /* v0.3g */
2517
  n_Ctot = 0;                   /* v0.3g */
2711
  n_Otot = 0;                   /* v0.3g */
2518
  n_Otot = 0;                   /* v0.3g */
2712
  n_Ntot = 0;                   /* v0.3g */
2519
  n_Ntot = 0;                   /* v0.3g */
2713
  FORLIM = n_atoms;
2520
  FORLIM = n_atoms;
2714
  for (n = 1; n <= FORLIM; n++)
2521
  for (n = 1; n <= FORLIM; n++) {
2715
    {
-
 
2716
      ri++;
2522
    ri++;
2717
      strcpy (rline, molbuf[ri - 1]);
2523
    strcpy (rline, molbuf[ri - 1]);
2718
      strsub (atomtype, rline, 7, 4);
2524
    strsub (atomtype, rline, 7, 4);
2719
      sprintf (STR1, "%c", toupper (*atomtype));
2525
    sprintf (STR1, "%c", toupper (*atomtype));
2720
      strcpy (atomtype, STR1);  /* fixed in v0.3f */
2526
    strcpy (atomtype, STR1);    /* fixed in v0.3f */
2721
      get_element (elemstr, atomtype);
2527
    get_element (elemstr, atomtype);
2722
      if (!strcmp (elemstr, "C "))
2528
    if (!strcmp (elemstr, "C "))
2723
        n_Ctot++;
2529
            n_Ctot++;
2724
      if (!strcmp (elemstr, "O "))
2530
    if (!strcmp (elemstr, "O "))
2725
        n_Otot++;
2531
            n_Otot++;
2726
      if (!strcmp (elemstr, "N "))
2532
    if (!strcmp (elemstr, "N "))
2727
        n_Ntot++;
2533
            n_Ntot++;
2728
      convert_type (newatomtype, atomtype);
2534
    convert_type (newatomtype, atomtype);
2729
      strsub (xstr, rline, 14, 7);
2535
    strsub (xstr, rline, 14, 7);
2730
      strsub (ystr, rline, 23, 7);
2536
    strsub (ystr, rline, 23, 7);
2731
      strsub (zstr, rline, 32, 7);
2537
    strsub (zstr, rline, 32, 7);
2732
      strsub (chgstr, rline, 43, 7);
2538
    strsub (chgstr, rline, 43, 7);
2733
      (void)sscanf (xstr, "%g", &xval);
2539
    (void)sscanf (xstr, "%g", &xval);
2734
      (void)sscanf (ystr, "%g", &yval);
2540
    (void)sscanf (ystr, "%g", &yval);
2735
      (void)sscanf (zstr, "%g", &zval);
2541
    (void)sscanf (zstr, "%g", &zval);
2736
      (void)sscanf (chgstr, "%g", &chgval);
2542
    (void)sscanf (chgstr, "%g", &chgval);
2737
      WITH = &atom[n - 1];
2543
    WITH = &atom[n - 1];
2738
      strcpy (WITH->element, elemstr);
2544
    strcpy (WITH->element, elemstr);
2739
      strcpy (WITH->atype, newatomtype);
2545
    strcpy (WITH->atype, newatomtype);
2740
      WITH->x = xval;
2546
    WITH->x = xval;
2741
      WITH->y = yval;
2547
    WITH->y = yval;
2742
      WITH->z = zval;
2548
    WITH->z = zval;
2743
      WITH->real_charge = chgval;
2549
    WITH->real_charge = chgval;
2744
      if (is_heavyatom (n))
2550
    if (is_heavyatom (n)) {
2745
        {
-
 
2746
          n_heavyatoms++;
2551
            n_heavyatoms++;
2747
          WITH->heavy = true;
2552
            WITH->heavy = true;
2748
          if (is_metal (n))
2553
            if (is_metal (n))
2749
            WITH->metal = true;
2554
              WITH->metal = true;
2750
        }
2555
          }
2751
      WITH->nvalences = get_nvalences (WITH->element);  /* v0.3m   */
2556
    WITH->nvalences = get_nvalences (WITH->element);    /* v0.3m   */
2752
    }
2557
  }
2753
  /*
2558
  /*
2754
     with atom^[n] do
2559
     with atom^[n] do
2755
     begin
2560
     begin
2756
     x := 0; y := 0; z := 0;  (* v0.3g
2561
     x := 0; y := 0; z := 0;  (* v0.3g
2757
     formal_charge  := 0;
2562
     formal_charge  := 0;
Line 2765... Line 2570...
2765
     heavy          := false;
2570
     heavy          := false;
2766
     metal          := false;
2571
     metal          := false;
2767
     tag            := false;
2572
     tag            := false;
2768
     end;
2573
     end;
2769
   */
2574
   */
2770
  FORLIM = n_bonds;
2575
  FORLIM = n_bonds;
2771
  for (n = 0; n < FORLIM; n++)
2576
  for (n = 0; n < FORLIM; n++) {
2772
    {
-
 
2773
      ri++;
2577
    ri++;
2774
      strcpy (rline, molbuf[ri - 1]);
2578
    strcpy (rline, molbuf[ri - 1]);
2775
      strsub (a1str, rline, 9, 3);
2579
    strsub (a1str, rline, 9, 3);
2776
      strsub (a2str, rline, 15, 3);
2580
    strsub (a2str, rline, 15, 3);
2777
      (void)sscanf(a1str, "%d", &a1val);
2581
    (void)sscanf(a1str, "%d", &a1val);
2778
      (void)sscanf(a2str, "%d", &a2val);
2582
    (void)sscanf(a2str, "%d", &a2val);
2779
      WITH1 = &bond[n];
2583
    WITH1 = &bond[n];
2780
      WITH1->a1 = a1val;
2584
    WITH1->a1 = a1val;
2781
      WITH1->a2 = a2val;
2585
    WITH1->a2 = a2val;
2782
      WITH1->btype = rline[19];
2586
    WITH1->btype = rline[19];
2783
      WITH1->ring_count = 0;
2587
    WITH1->ring_count = 0;
2784
      WITH1->arom = false;
2588
    WITH1->arom = false;
2785
      WITH1->topo = btopo_any;
2589
    WITH1->topo = btopo_any;
2786
      WITH1->stereo = bstereo_any;
2590
    WITH1->stereo = bstereo_any;
2787
      WITH1->mdl_stereo = 0;    /* v0.3n */
2591
    WITH1->mdl_stereo = 0;      /* v0.3n */
2788
      if (atom[a1val - 1].heavy && atom[a2val - 1].heavy)
2592
    if (atom[a1val - 1].heavy && atom[a2val - 1].heavy)
2789
        n_heavybonds++;
2593
            n_heavybonds++;
2790
    }
2594
  }
2791
  memset (ring, 0, sizeof (ringlist));
2595
  memset (ring, 0, sizeof (ringlist));
2792
  for (n = 0; n < max_rings; n++)
2596
  for (n = 0; n < max_rings; n++) {                             /* new in v0.3 */
2793
    {                           /* new in v0.3 */
-
 
2794
      ringprop[n].size = 0;
2597
    ringprop[n].size = 0;
2795
      ringprop[n].arom = false;
2598
    ringprop[n].arom = false;
2796
      ringprop[n].envelope = false;
2599
    ringprop[n].envelope = false;
2797
    }
2600
  }
2798
  li = ri + 1;
2601
  li = ri + 1;
2799
}
2602
}
2800
 
2603
 
2801
 
-
 
2802
static void
-
 
2803
read_mol2file (mfilename)
2604
static void read_mol2file (mfilename) char *mfilename;
2804
     char *mfilename;
-
 
2805
{
2605
{
2806
  /* reads SYBYL mol2 files */
2606
  /* reads SYBYL mol2 files */
2807
  int n, code;
2607
  int n, code;
2808
  char sybatomtype[6];
2608
  char sybatomtype[6];
2809
  char tmpstr[256], rline[256];
2609
  char tmpstr[256], rline[256];
Line 2816... Line 2616...
2816
 
2616
 
2817
  if (n_atoms > 0)
2617
  if (n_atoms > 0)
2818
    zap_molecule ();
2618
    zap_molecule ();
2819
  *rline = '\0';
2619
  *rline = '\0';
2820
  ri = li - 1;
2620
  ri = li - 1;
2821
  while ((ri < molbufindex) && (strpos2 (rline, "@<TRIPOS>MOLECULE", 1) == 0))
2621
  while ((ri < molbufindex) && (strpos2 (rline, "@<TRIPOS>MOLECULE", 1) == 0)) {
2822
    {
-
 
2823
      ri++;
2622
    ri++;
2824
      strcpy (rline, molbuf[ri - 1]);
2623
    strcpy (rline, molbuf[ri - 1]);
2825
    }
2624
  }
2826
  if (ri < molbufindex)
2625
  if (ri < molbufindex) {
2827
    {
-
 
2828
      ri++;
2626
    ri++;
2829
      strcpy (molname, molbuf[ri - 1]);
2627
    strcpy (molname, molbuf[ri - 1]);
2830
    }
2628
  }
2831
  if (ri < molbufindex)
2629
  if (ri < molbufindex) {
2832
    {
-
 
2833
      ri++;
2630
    ri++;
2834
      strcpy (rline, molbuf[ri - 1]);
2631
    strcpy (rline, molbuf[ri - 1]);
2835
    }
2632
  }
2836
  sprintf (tmpstr, "%.5s", rline);
2633
  sprintf (tmpstr, "%.5s", rline);
2837
  (void)sscanf (tmpstr, "%d", &n_atoms);
2634
  (void)sscanf (tmpstr, "%d", &n_atoms);
2838
/* p2c: checkmol.pas: Note: Eliminated unused assignment statement [338] */
2635
  /* p2c: checkmol.pas: Note: Eliminated unused assignment statement [338] */
2839
  strsub (tmpstr, rline, 7, 5);
2636
  strsub (tmpstr, rline, 7, 5);
2840
  (void)sscanf (tmpstr, "%d", &n_bonds);
2637
  (void)sscanf (tmpstr, "%d", &n_bonds);
2841
  /* try */
2638
  /* try */
2842
/* p2c: checkmol.pas: Note: Eliminated unused assignment statement [338] */
2639
  /* p2c: checkmol.pas: Note: Eliminated unused assignment statement [338] */
2843
  atom = safe_calloc (n_atoms, sizeof (atom_rec));
2640
  atom = safe_calloc (n_atoms, sizeof (atom_rec));
2844
  bond = safe_calloc (n_bonds, sizeof (bond_rec));
2641
  bond = safe_calloc (n_bonds, sizeof (bond_rec));
2845
  ring = safe_calloc (1, sizeof (ringlist));
2642
  ring = safe_calloc (1, sizeof (ringlist));
2846
  ringprop = safe_calloc (1, sizeof (ringprop_type));
2643
  ringprop = safe_calloc (1, sizeof (ringprop_type));
2847
  /* except
2644
  /* except
Line 2854... Line 2651...
2854
  n_heavyatoms = 0;
2651
  n_heavyatoms = 0;
2855
  n_heavybonds = 0;
2652
  n_heavybonds = 0;
2856
  n_Ctot = 0;                   /* v0.3g */
2653
  n_Ctot = 0;                   /* v0.3g */
2857
  n_Otot = 0;                   /* v0.3g */
2654
  n_Otot = 0;                   /* v0.3g */
2858
  n_Ntot = 0;                   /* v0.3g */
2655
  n_Ntot = 0;                   /* v0.3g */
2859
  while ((ri < molbufindex) && (strpos2 (rline, "@<TRIPOS>ATOM", 1) == 0))
2656
  while ((ri < molbufindex) && (strpos2 (rline, "@<TRIPOS>ATOM", 1) == 0)) {
2860
    {
-
 
2861
      ri++;
2657
    ri++;
2862
      strcpy (rline, molbuf[ri - 1]);
2658
    strcpy (rline, molbuf[ri - 1]);
2863
    }
2659
  }
2864
  FORLIM = n_atoms;
2660
  FORLIM = n_atoms;
2865
  for (n = 1; n <= FORLIM; n++)
2661
  for (n = 1; n <= FORLIM; n++) {
2866
    {
-
 
2867
      /*
2662
    /*
2868
         with atom^[n] do
2663
      with atom^[n] do
2869
         begin
2664
      begin
2870
         x := 0; y := 0; z := 0;  (* v0.3g
2665
      x := 0; y := 0; z := 0;  (* v0.3g
2871
         formal_charge  := 0;
2666
      formal_charge  := 0;
2872
         real_charge    := 0;
2667
      real_charge    := 0;
2873
         Hexp           := 0;
2668
      Hexp           := 0;
2874
         Htot           := 0;
2669
      Htot           := 0;
2875
         neighbor_count := 0;
2670
      neighbor_count := 0;
2876
         ring_count     := 0;
2671
      ring_count     := 0;
2877
         arom           := false;
2672
      arom           := false;
2878
         stereo_care    := false;
2673
      stereo_care    := false;
2879
         heavy          := false;
2674
      heavy          := false;
2880
         metal          := false;
2675
      metal          := false;
2881
         tag            := false;
2676
      tag            := false;
2882
         end;
2677
      end;
2883
       */
2678
    */
2884
      if (ri < molbufindex)
2679
    if (ri < molbufindex) {
2885
        {
-
 
2886
          ri++;
2680
            ri++;
2887
          strcpy (rline, molbuf[ri - 1]);
2681
            strcpy (rline, molbuf[ri - 1]);
2888
        }
2682
          }
2889
      strsub (sybatomtype, rline, 48, 5);
2683
    strsub (sybatomtype, rline, 48, 5);
2890
      get_sybelement (elemstr, sybatomtype);
2684
    get_sybelement (elemstr, sybatomtype);
2891
      if (!strcmp (elemstr, "C "))
2685
    if (!strcmp (elemstr, "C "))
2892
        n_Ctot++;
2686
            n_Ctot++;
2893
      if (!strcmp (elemstr, "O "))
2687
    if (!strcmp (elemstr, "O "))
2894
        n_Otot++;
2688
            n_Otot++;
2895
      if (!strcmp (elemstr, "N "))
2689
    if (!strcmp (elemstr, "N "))
2896
        n_Ntot++;
2690
            n_Ntot++;
2897
      convert_sybtype (newatomtype, sybatomtype);
2691
    convert_sybtype (newatomtype, sybatomtype);
2898
      strsub (xstr, rline, 18, 9);
2692
    strsub (xstr, rline, 18, 9);
2899
      strsub (ystr, rline, 28, 9);
2693
    strsub (ystr, rline, 28, 9);
2900
      strsub (zstr, rline, 38, 9);
2694
    strsub (zstr, rline, 38, 9);
2901
      strsub (chgstr, rline, 70, 9);
2695
    strsub (chgstr, rline, 70, 9);
2902
      (void)sscanf (xstr, "%g", &xval);
2696
    (void)sscanf (xstr, "%g", &xval);
2903
      (void)sscanf (ystr, "%g", &yval);
2697
    (void)sscanf (ystr, "%g", &yval);
2904
      (void)sscanf (zstr, "%g", &zval);
2698
    (void)sscanf (zstr, "%g", &zval);
2905
      (void)sscanf (chgstr, "%g", &chgval);
2699
    (void)sscanf (chgstr, "%g", &chgval);
2906
      WITH = &atom[n - 1];
2700
    WITH = &atom[n - 1];
2907
      strcpy (WITH->element, elemstr);
2701
    strcpy (WITH->element, elemstr);
2908
      strcpy (WITH->atype, newatomtype);
2702
    strcpy (WITH->atype, newatomtype);
2909
      WITH->x = xval;
2703
    WITH->x = xval;
2910
      WITH->y = yval;
2704
    WITH->y = yval;
2911
      WITH->z = zval;
2705
    WITH->z = zval;
2912
      WITH->real_charge = chgval;
2706
    WITH->real_charge = chgval;
2913
      if (is_heavyatom (n))
2707
    if (is_heavyatom (n)) {
2914
        {
-
 
2915
          n_heavyatoms++;
2708
            n_heavyatoms++;
2916
          WITH->heavy = true;
2709
            WITH->heavy = true;
2917
          if (is_metal (n))
2710
            if (is_metal (n))
2918
            WITH->metal = true;
2711
              WITH->metal = true;
2919
        }
2712
          }
2920
      WITH->nvalences = get_nvalences (WITH->element);  /* v0.3m   */
2713
    WITH->nvalences = get_nvalences (WITH->element);    /* v0.3m   */
2921
    }
2714
  }
2922
  while ((ri < molbufindex) && (strpos2 (rline, "@<TRIPOS>BOND", 1) == 0))
2715
  while ((ri < molbufindex) && (strpos2 (rline, "@<TRIPOS>BOND", 1) == 0)) {
2923
    {
-
 
2924
      ri++;
2716
    ri++;
2925
      strcpy (rline, molbuf[ri - 1]);
2717
    strcpy (rline, molbuf[ri - 1]);
2926
    }
2718
  }
2927
  FORLIM = n_bonds;
2719
  FORLIM = n_bonds;
2928
  for (n = 0; n < FORLIM; n++)
2720
  for (n = 0; n < FORLIM; n++) {
2929
    {
-
 
2930
      if (ri < molbufindex)
2721
    if (ri < molbufindex) {
2931
        {
-
 
2932
          ri++;
2722
            ri++;
2933
          strcpy (rline, molbuf[ri - 1]);
2723
            strcpy (rline, molbuf[ri - 1]);
2934
        }
2724
          }
2935
      strsub (a1str, rline, 9, 3);
2725
    strsub (a1str, rline, 9, 3);
2936
      strsub (a2str, rline, 14, 3);
2726
    strsub (a2str, rline, 14, 3);
2937
      code = (sscanf (a1str, "%d", &a1val) == 0);
2727
    code = (sscanf (a1str, "%d", &a1val) == 0);
2938
      if (code != 0)
2728
    if (code != 0)
2939
        printf ("%s\007\n", rline);
2729
            printf ("%s\007\n", rline);
2940
      code = (sscanf (a2str, "%d", &a2val) == 0);
2730
    code = (sscanf (a2str, "%d", &a2val) == 0);
2941
      if (code != 0)
2731
    if (code != 0)
2942
        printf ("%s\007\n", rline);
2732
            printf ("%s\007\n", rline);
2943
      WITH1 = &bond[n];
2733
    WITH1 = &bond[n];
2944
      WITH1->a1 = a1val;
2734
    WITH1->a1 = a1val;
2945
      WITH1->a2 = a2val;
2735
    WITH1->a2 = a2val;
2946
      if (rline[17] == '1')
2736
    if (rline[17] == '1')
2947
        WITH1->btype = 'S';
2737
            WITH1->btype = 'S';
2948
      if (rline[17] == '2')
2738
    if (rline[17] == '2')
2949
        WITH1->btype = 'D';
2739
            WITH1->btype = 'D';
2950
      if (rline[17] == '3')
2740
    if (rline[17] == '3')
2951
        WITH1->btype = 'T';
2741
            WITH1->btype = 'T';
2952
      if (rline[17] == 'a')
2742
    if (rline[17] == 'a')
2953
        WITH1->btype = 'A';
2743
            WITH1->btype = 'A';
2954
      WITH1->ring_count = 0;
2744
    WITH1->ring_count = 0;
2955
      WITH1->arom = false;
2745
    WITH1->arom = false;
2956
      WITH1->topo = btopo_any;
2746
    WITH1->topo = btopo_any;
2957
      WITH1->stereo = bstereo_any;
2747
    WITH1->stereo = bstereo_any;
2958
      WITH1->mdl_stereo = 0;    /* v0.3n */
2748
    WITH1->mdl_stereo = 0;      /* v0.3n */
2959
      if (atom[a1val - 1].heavy && atom[a2val - 1].heavy)
2749
    if (atom[a1val - 1].heavy && atom[a2val - 1].heavy)
2960
        n_heavybonds++;
2750
            n_heavybonds++;
2961
    }
2751
  }
2962
  memset (ring, 0, sizeof (ringlist));
2752
  memset (ring, 0, sizeof (ringlist));
2963
  for (n = 0; n < max_rings; n++)
2753
  for (n = 0; n < max_rings; n++) {                             /* new in v0.3 */
2964
    {                           /* new in v0.3 */
-
 
2965
      ringprop[n].size = 0;
2754
    ringprop[n].size = 0;
2966
      ringprop[n].arom = false;
2755
    ringprop[n].arom = false;
2967
      ringprop[n].envelope = false;
2756
    ringprop[n].envelope = false;
2968
    }
2757
  }
2969
  li = ri + 1;
2758
  li = ri + 1;
2970
}
2759
}
2971
 
2760
 
2972
 
-
 
2973
static void
-
 
2974
read_charges (chgstring_)
2761
static void read_charges (chgstring_)
2975
     char *chgstring_;
2762
     char *chgstring_;
2976
{
2763
{
2977
  char chgstring[256];
2764
  char chgstring[256];
2978
  int a_id, a_chg;
2765
  int a_id, a_chg;
2979
  /* int n_chrg;*/
2766
  /* int n_chrg;*/
Line 2983... Line 2770...
2983
  strcpy (chgstring, chgstring_);
2770
  strcpy (chgstring, chgstring_);
2984
  if (strpos2 (chgstring, "M  CHG", 1) <= 0)
2771
  if (strpos2 (chgstring, "M  CHG", 1) <= 0)
2985
    return;
2772
    return;
2986
  strdelete (chgstring, 1, 6);
2773
  strdelete (chgstring, 1, 6);
2987
  left_trim (chgstring);
2774
  left_trim (chgstring);
2988
 /* n_chrg = left_int (chgstring);*/
2775
  /* n_chrg = left_int (chgstring);*/
2989
  /* this assignment must be kept also in non-debug mode! */
2776
  /* this assignment must be kept also in non-debug mode! */
2990
/* p2c: checkmol.pas, line 2077:
2777
  /* p2c: checkmol.pas, line 2077:
2991
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
2778
    * Note: Turbo Pascal conditional compilation directive was ignored [218] */
2992
  /*$IFDEF debug */
2779
  /*$IFDEF debug */
2993
  /*if (n_chrg == 0)
2780
  /*if (n_chrg == 0)
2994
     debugoutput ("strange... M  CHG present, but no charges found"); */
2781
     debugoutput ("strange... M  CHG present, but no charges found"); */
2995
  /*$ENDIF */
2782
  /*$ENDIF */
2996
  while (*chgstring != '\0')
2783
  while (*chgstring != '\0') {
2997
    {
-
 
2998
      a_id = left_int (chgstring);
2784
    a_id = left_int (chgstring);
2999
      a_chg = left_int (chgstring);
2785
    a_chg = left_int (chgstring);
3000
      if (a_id != 0 && a_chg != 0)
2786
    if (a_id != 0 && a_chg != 0)
3001
        atom[a_id - 1].formal_charge = a_chg;
2787
          atom[a_id - 1].formal_charge = a_chg;
3002
      //printf ("CHG %i %i\n", a_id, a_chg);
2788
      //printf ("CHG %i %i\n", a_id, a_chg);
3003
    }
2789
  }
3004
}
2790
}
3005
 
2791
 
3006
static void
-
 
3007
read_isotopes (char *isotopestring_)
2792
static void read_isotopes (char *isotopestring_)
3008
{
2793
{
3009
  char isotopestring[256];
2794
  char isotopestring[256];
3010
  int a_id, a_nucleon_number;
2795
  int a_id, a_nucleon_number;
3011
  /* int n_isotopes;*/
2796
  /* int n_isotopes;*/
3012
 
2797
 
Line 3016... Line 2801...
3016
  if (strpos2 (isotopestring, "M  ISO", 1) <= 0)
2801
  if (strpos2 (isotopestring, "M  ISO", 1) <= 0)
3017
    return;
2802
    return;
3018
  strdelete (isotopestring, 1, 6);
2803
  strdelete (isotopestring, 1, 6);
3019
  left_trim (isotopestring);
2804
  left_trim (isotopestring);
3020
  /*n_isotopes = left_int (isotopestring);*/
2805
  /*n_isotopes = left_int (isotopestring);*/
3021
  /* this assignment must be kept also in non-debug mode! */
2806
  /* this assignment must be kept also in non-debug mode! */
3022
/* p2c: checkmol.pas, line 2077:
2807
  /* p2c: checkmol.pas, line 2077:
3023
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
2808
  * Note: Turbo Pascal conditional compilation directive was ignored [218] */
3024
  /*$IFDEF debug */
2809
  /*$IFDEF debug */
3025
  /*if (n_chrg == 0)
2810
  /*if (n_chrg == 0)
3026
     debugoutput ("strange... M  CHG present, but no charges found"); */
2811
     debugoutput ("strange... M  CHG present, but no charges found"); */
3027
  /*$ENDIF */
2812
  /*$ENDIF */
3028
  while (*isotopestring != '\0')
2813
  while (*isotopestring != '\0') {
3029
    {
-
 
3030
      a_id = left_int (isotopestring);
2814
    a_id = left_int (isotopestring);
3031
      a_nucleon_number = left_int (isotopestring);
2815
    a_nucleon_number = left_int (isotopestring);
3032
      if (a_id != 0 && a_nucleon_number != 0)
2816
    if (a_id != 0 && a_nucleon_number != 0) {
3033
        {
-
 
3034
          atom[a_id - 1].nucleon_number = a_nucleon_number;
2817
            atom[a_id - 1].nucleon_number = a_nucleon_number;
3035
          if (!strcmp (atom[a_id - 1].element, "H "))
2818
            if (!strcmp (atom[a_id - 1].element, "H ")) {
3036
            {
-
 
3037
              atom[a_id - 1].heavy = true;
2819
              atom[a_id - 1].heavy = true;
3038
              n_heavyatoms++;
2820
              n_heavyatoms++;
3039
              strcpy (atom[a_id - 1].atype, "DU ");
2821
              strcpy (atom[a_id - 1].atype, "DU ");
3040
            }
2822
            }
3041
        }
2823
          }
3042
      //printf ("ISO %i %i\n", a_id, a_nucleon_number);
2824
      //printf ("ISO %i %i\n", a_id, a_nucleon_number);
3043
    }
2825
  }
3044
}
2826
}
3045
 
2827
 
3046
static void
-
 
3047
read_radicals (radstring_)
2828
static void read_radicals (radstring_)
3048
     char *radstring_;
2829
     char *radstring_;
3049
{
2830
{
3050
  char radstring[256];
2831
  char radstring[256];
3051
  int a_id, a_rad;
2832
  int a_id, a_rad;
3052
 
2833
 
Line 3057... Line 2838...
3057
    return;
2838
    return;
3058
  strdelete (radstring, 1, 6);
2839
  strdelete (radstring, 1, 6);
3059
  left_trim (radstring);
2840
  left_trim (radstring);
3060
  (void)left_int (radstring);
2841
  (void)left_int (radstring);
3061
  /* this assignment must be kept also in non-debug mode! */
2842
  /* this assignment must be kept also in non-debug mode! */
3062
/* p2c: checkmol.pas, line 2077:
2843
  /* p2c: checkmol.pas, line 2077:
3063
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
2844
    * Note: Turbo Pascal conditional compilation directive was ignored [218] */
3064
  /*$IFDEF debug */
2845
  /*$IFDEF debug */
3065
  /*if (n_chrg == 0)
2846
  /*if (n_chrg == 0)
3066
     debugoutput ("strange... M  CHG present, but no charges found"); */
2847
     debugoutput ("strange... M  CHG present, but no charges found"); */
3067
  /*$ENDIF */
2848
  /*$ENDIF */
3068
  while (*radstring != '\0')
2849
  while (*radstring != '\0') {
3069
    {
-
 
3070
      a_id = left_int (radstring);
2850
    a_id = left_int (radstring);
3071
      a_rad = left_int (radstring);
2851
    a_rad = left_int (radstring);
3072
      if (a_id != 0 && a_rad != 0)
2852
    if (a_id != 0 && a_rad != 0)
3073
        atom[a_id - 1].radical_type = a_rad;
2853
            atom[a_id - 1].radical_type = a_rad;
3074
      //printf ("RAD %i %i\n", a_id, a_rad);
2854
    //printf ("RAD %i %i\n", a_id, a_rad);
3075
    }
2855
  }
3076
}
2856
}
3077
 
2857
 
3078
 
-
 
3079
static void
-
 
3080
read_MDLmolfile (char *mfilename)
2858
static void read_MDLmolfile (char *mfilename)
3081
{
2859
{
3082
  /* reads MDL mol files */
2860
  /* reads MDL mol files */
3083
  int n, v, tmp_n_atoms, tmp_n_bonds, code;     /* v0.3l */
2861
  int n, v, tmp_n_atoms, tmp_n_bonds, code;     /* v0.3l */
3084
  char rline[256], tmpstr[256];
2862
  char rline[256], tmpstr[256];
3085
  char xstr[256], ystr[256], zstr[256], chgstr[256];
2863
  char xstr[256], ystr[256], zstr[256], chgstr[256];
Line 3088... Line 2866...
3088
  int a1val, a2val, ri, rc, bt, bs;
2866
  int a1val, a2val, ri, rc, bt, bs;
3089
  int sepcount = 0;
2867
  int sepcount = 0;
3090
  int i;                        /* v0.3j */
2868
  int i;                        /* v0.3j */
3091
  boolean clearcharges = true;  /* v0.3j */
2869
  boolean clearcharges = true;  /* v0.3j */
3092
  char STR1[256];
2870
  char STR1[256];
3093
/*  int FORLIM;*/
2871
  /*  int FORLIM;*/
3094
  atom_rec *WITH;
2872
  atom_rec *WITH;
3095
  bond_rec *WITH1;
2873
  bond_rec *WITH1;
3096
 
2874
 
3097
  /* v0.3j */
2875
  /* v0.3j */
3098
  if (n_atoms > 0)
2876
  if (n_atoms > 0)
Line 3102... Line 2880...
3102
  ri = li;
2880
  ri = li;
3103
  strcpy (molname, molbuf[ri - 1]);     /* line 1 */
2881
  strcpy (molname, molbuf[ri - 1]);     /* line 1 */
3104
  if (ri < molbufindex)         /* line 2 */
2882
  if (ri < molbufindex)         /* line 2 */
3105
    ri++;
2883
    ri++;
3106
  strcpy (rline, molbuf[ri - 1]);
2884
  strcpy (rline, molbuf[ri - 1]);
3107
  if (strpos2 (rline, "CheckMol", 1) == 3)
2885
  if (strpos2 (rline, "CheckMol", 1) == 3) {
3108
    {
-
 
3109
      /*cm_mdlmolfile := true; */
2886
    /*cm_mdlmolfile := true; */
3110
      found_arominfo = true;
2887
    found_arominfo = true;
3111
      tmfcode = 1;              /* v0.3m (begin) */
2888
    tmfcode = 1;                /* v0.3m (begin) */
3112
      code = 0;
2889
    code = 0;
3113
      if ((strlen (rline) >= 39) && (strpos2 (rline, "TMF", 1) == 35))
2890
    if ((strlen (rline) >= 39) && (strpos2 (rline, "TMF", 1) == 35)) {
3114
        {                       /* v0.3m; encoding of tweaklevel */
2891
      /* v0.3m; encoding of tweaklevel */
3115
          strsub (tmpstr, rline, 38, 2);
2892
            strsub (tmpstr, rline, 38, 2);
3116
          code = (sscanf (tmpstr, "%d", &tmfcode) == 0);
2893
            code = (sscanf (tmpstr, "%d", &tmfcode) == 0);
3117
        }
2894
          }
3118
      if (code != 0 || tmfcode != tweaklevel)
2895
    if (code != 0 || tmfcode != tweaklevel)
3119
        tmfmismatch = true;
2896
            tmfmismatch = true;
3120
      else
2897
    else
3121
        tmfmismatch = false;
2898
            tmfmismatch = false;
3122
      if ((strpos2 (rline, ":r0", 1) >= 40 && ringsearch_mode != rs_sar) |
2899
      if ((strpos2 (rline, ":r0", 1) >= 40 && ringsearch_mode != rs_sar) |
3123
          (strpos2 (rline, ":r1", 1) >= 40 && ringsearch_mode != rs_ssr))
2900
                (strpos2 (rline, ":r1", 1) >= 40 && ringsearch_mode != rs_ssr))
3124
        tmfmismatch = true;
2901
              tmfmismatch = true;
3125
      if ((strpos2 (rline, ":m0", 1) >= 40 && opt_metalrings == true) |
2902
      if ((strpos2 (rline, ":m0", 1) >= 40 && opt_metalrings == true) |
3126
          (strpos2 (rline, ":m1", 1) >= 40 && opt_metalrings == false))
2903
                (strpos2 (rline, ":m1", 1) >= 40 && opt_metalrings == false))
3127
        tmfmismatch = true;
2904
              tmfmismatch = true;
3128
/* p2c: checkmol.pas, line 2128:
2905
      /* p2c: checkmol.pas, line 2128:
3129
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
2906
       * Note: Turbo Pascal conditional compilation directive was ignored [218] */
3130
      /*$IFDEF debug */
2907
            /*$IFDEF debug */
3131
      //if (tmfmismatch)
2908
            //if (tmfmismatch)
3132
      //printf ("\"tweaked\" molfile: version mismatch!\n");
2909
            //printf ("\"tweaked\" molfile: version mismatch!\n");
3133
      // else
2910
            // else
3134
      //printf ("\"tweaked\" molfile: version OK");
2911
            //printf ("\"tweaked\" molfile: version OK");
3135
    }
2912
          }
3136
  /*$ENDIF */
2913
      /*$ENDIF */
3137
  /* v0.3m (end) */
2914
      /* v0.3m (end) */
3138
  if (ri < molbufindex)         /* line 3 */
2915
      if (ri < molbufindex)             /* line 3 */
3139
    ri++;
2916
        ri++;
3140
  strcpy (rline, molbuf[ri - 1]);
2917
      strcpy (rline, molbuf[ri - 1]);
3141
  strcpy (molcomment, rline);
2918
      strcpy (molcomment, rline);
3142
  if (ri < molbufindex)         /* line 4 */
2919
      if (ri < molbufindex)             /* line 4 */
3143
    ri++;
2920
        ri++;
3144
  strcpy (rline, molbuf[ri - 1]);
2921
      strcpy (rline, molbuf[ri - 1]);
3145
  sprintf (tmpstr, "%.3s", rline);
2922
      sprintf (tmpstr, "%.3s", rline);
3146
  (void)sscanf (tmpstr, "%d", &n_atoms);
2923
      (void)sscanf (tmpstr, "%d", &n_atoms);
3147
  strsub (tmpstr, rline, 4, 3);
2924
      strsub (tmpstr, rline, 4, 3);
3148
  (void)sscanf (tmpstr, "%d", &n_bonds);
2925
      (void)sscanf (tmpstr, "%d", &n_bonds);
3149
  strsub (tmpstr, rline, 10, 3);
2926
      strsub (tmpstr, rline, 10, 3);
3150
  /* if it is a CheckMol-tweaked molfile, this is the number of rings */
2927
      /* if it is a CheckMol-tweaked molfile, this is the number of rings */
3151
  n_cmrings = 0;
2928
      n_cmrings = 0;
3152
  code = (sscanf (tmpstr, "%d", &n_cmrings) == 0);
2929
      code = (sscanf (tmpstr, "%d", &n_cmrings) == 0);
3153
  if (code != 0)
2930
      if (code != 0)
3154
    n_cmrings = 0;
2931
        n_cmrings = 0;
3155
  /* do some range checking for n_atoms, n_bonds; new in v0.3l */
2932
      /* do some range checking for n_atoms, n_bonds; new in v0.3l */
3156
  tmp_n_atoms = n_atoms;
2933
      tmp_n_atoms = n_atoms;
3157
  if (n_atoms > max_atoms)
2934
      if (n_atoms > max_atoms)
3158
    n_atoms = max_atoms;
2935
        n_atoms = max_atoms;
3159
  if (n_atoms < 0)
2936
      if (n_atoms < 0)
3160
    n_atoms = 0;
2937
        n_atoms = 0;
3161
  tmp_n_bonds = n_bonds;
2938
      tmp_n_bonds = n_bonds;
3162
  if (n_bonds > max_bonds)
2939
      if (n_bonds > max_bonds)
3163
    n_bonds = max_bonds;
2940
        n_bonds = max_bonds;
3164
  if (n_bonds < 0)
2941
      if (n_bonds < 0)
3165
    n_bonds = 0;
2942
        n_bonds = 0;
3166
  if (n_atoms == 0
2943
      if (n_atoms == 0
3167
#ifndef MAKE_SHARED_LIBRARY
2944
#ifndef MAKE_SHARED_LIBRARY
3168
      && opt_verbose
2945
        && opt_verbose
3169
#endif
2946
#endif
3170
    )
-
 
3171
    {                           /* v0.3l */
2947
    ) {                                 /* v0.3l */
3172
      printf ("WARNING: Possible NoStruct read!\n");
2948
        printf ("WARNING: Possible NoStruct read!\n");
3173
      printf ("NoStructs are proprietary, obsolete and dangerous.\n");
2949
        printf ("NoStructs are proprietary, obsolete and dangerous.\n");
3174
    }
2950
      }
3175
  /* try */
2951
      /* try */
3176
  atom = safe_calloc (n_atoms, sizeof (atom_rec));
2952
      atom = safe_calloc (n_atoms, sizeof (atom_rec));
3177
  bond = safe_calloc (n_bonds, sizeof (bond_rec));
2953
      bond = safe_calloc (n_bonds, sizeof (bond_rec));
3178
  /* this would be only one safe_calloc() in C;  v0.3l */
2954
      /* this would be only one safe_calloc() in C;  v0.3l */
3179
  ring = safe_calloc (1, sizeof (ringlist));
2955
      ring = safe_calloc (1, sizeof (ringlist));
3180
  ringprop = safe_calloc (1, sizeof (ringprop_type));
2956
      ringprop = safe_calloc (1, sizeof (ringprop_type));
3181
  /* except
2957
      /* except
3182
     on e:Eoutofmemory do
2958
      on e:Eoutofmemory do
3183
     begin
2959
      begin
3184
     writeln('Not enough memory');
2960
      writeln('Not enough memory');
3185
     (* close(molfile);
2961
      (* close(molfile);
3186
     halt(4);
2962
      halt(4);
3187
     exit;
2963
      exit;
3188
     end;
2964
      end;
3189
     end; */
2965
      end; */
3190
  /* check for the chirality flag */
2966
      /* check for the chirality flag */
3191
  if (strlen (rline) > 14 && rline[14] == '1')  /* new in v0.3f */
2967
      if (strlen (rline) > 14 && rline[14] == '1')      /* new in v0.3f */
3192
    chir_flag = true;
2968
        chir_flag = true;
3193
  n_heavyatoms = 0;
2969
      n_heavyatoms = 0;
3194
  n_heavybonds = 0;
2970
      n_heavybonds = 0;
3195
  n_Ctot = 0;                   /* v0.3g */
2971
      n_Ctot = 0;                       /* v0.3g */
3196
  n_Otot = 0;                   /* v0.3g */
2972
      n_Otot = 0;                       /* v0.3g */
3197
  n_Ntot = 0;                   /* v0.3g */
2973
      n_Ntot = 0;                       /* v0.3g */
3198
  if (n_atoms > 0)
-
 
3199
    {                           /* v0.3l */
2974
      if (n_atoms > 0) {                                /* v0.3l */
3200
      for (n = 1; n <= tmp_n_atoms; n++)
2975
        for (n = 1; n <= tmp_n_atoms; n++) {
3201
        {
-
 
3202
          if (n <= max_atoms)
2976
                if (n <= max_atoms)
3203
            v = n;
2977
                  v = n;
3204
          else
2978
                else
3205
            v = max_atoms;
2979
                  v = max_atoms;
3206
          /* just for safety; v0.3l */
2980
                /* just for safety; v0.3l */
3207
          /*
2981
                /*
3208
             with atom^[v] do
2982
                with atom^[v] do
3209
             begin
2983
                begin
3210
             x := 0; y := 0; z := 0;  (* v0.3g
2984
                x := 0; y := 0; z := 0;  (* v0.3g
3211
             formal_charge  := 0;
2985
                formal_charge  := 0;
3212
             real_charge    := 0;
2986
                real_charge    := 0;
3213
             Hexp           := 0;
2987
                Hexp           := 0;
3214
             Htot           := 0;
2988
                Htot           := 0;
3215
             neighbor_count := 0;
2989
                neighbor_count := 0;
3216
             ring_count     := 0;
2990
                ring_count     := 0;
3217
             arom           := false;
2991
                arom           := false;
3218
             stereo_care    := false;
2992
                stereo_care    := false;
3219
             metal          := false;
2993
                metal          := false;
3220
             heavy          := false;
2994
                heavy          := false;
3221
             tag            := false;
2995
                tag            := false;
3222
             end;
2996
                end;
3223
           */
2997
                */
3224
          /* replaced by fillchar() after getmem() (see above); v0.3l */
2998
                /* replaced by fillchar() after getmem() (see above); v0.3l */
3225
          ri++;
2999
                ri++;
3226
          strcpy (rline, molbuf[ri - 1]);
3000
                strcpy (rline, molbuf[ri - 1]);
3227
          strsub (atomtype, rline, 32, 3);
3001
                strsub (atomtype, rline, 32, 3);
3228
          get_MDLelement (elemstr, atomtype);
3002
                get_MDLelement (elemstr, atomtype);
3229
          if (!strcmp (elemstr, "C "))
3003
                if (!strcmp (elemstr, "C "))
3230
            n_Ctot++;
3004
                  n_Ctot++;
3231
          if (!strcmp (elemstr, "O "))
3005
                if (!strcmp (elemstr, "O "))
3232
            n_Otot++;
3006
                  n_Otot++;
3233
          if (!strcmp (elemstr, "N "))
3007
                if (!strcmp (elemstr, "N "))
3234
            n_Ntot++;
3008
                  n_Ntot++;
3235
 
-
 
3236
          convert_MDLtype (newatomtype, atomtype);
-
 
3237
          strsub (xstr, rline, 1, 10);  /* fixed in v0.3k (was: 2,9 etc.) */
-
 
3238
          strsub (ystr, rline, 11, 10);
-
 
3239
          strsub (zstr, rline, 21, 10);
-
 
3240
          /*chgstr := '0'; */
-
 
3241
          strsub (chgstr, rline, 37, 3);        /* new in v0.3j */
-
 
3242
          (void)sscanf (chgstr, "%f", &chgval);
-
 
3243
          if (chgval != 0)
-
 
3244
            {
-
 
3245
              if (chgval >= 1 && chgval <= 7)
-
 
3246
                chgval = 4.0 - chgval;
-
 
3247
              else
-
 
3248
                {
-
 
3249
                  chgval = 0.0;
-
 
3250
                }
-
 
3251
            }                   /* end (v0.3j) */
-
 
3252
          (void)sscanf (xstr, "%f", &xval);
-
 
3253
          (void)sscanf (ystr, "%f", &yval);
-
 
3254
          (void)sscanf (zstr, "%f", &zval);
-
 
3255
          /* v0.3k: removed superfluous val(chgstr,chgval,code) */
-
 
3256
          WITH = &atom[v - 1];
-
 
3257
          strcpy (WITH->element, elemstr);
-
 
3258
          if (!strcmp (elemstr, "A ") || !strcmp (elemstr, "Q ") ||
-
 
3259
              !strcmp (elemstr, "X "))
-
 
3260
            /* 'X ' added in v0.3n */
-
 
3261
            found_querymol = true;
-
 
3262
 
-
 
3263
          strcpy (WITH->atype, newatomtype);
-
 
3264
 
-
 
3265
 
-
 
3266
          if (!strcmp (elemstr, "D "))
-
 
3267
            {
-
 
3268
              strcpy (WITH->element, "H ");
-
 
3269
              WITH->nucleon_number = 2;
-
 
3270
            }                   /* 0.3x */
-
 
3271
          if (!strcmp (elemstr, "T "))
-
 
3272
            {
-
 
3273
              strcpy (WITH->element, "H ");
-
 
3274
              WITH->nucleon_number = 3;
-
 
3275
            }                   /* 0.3x */
-
 
3276
 
-
 
3277
 
3009
 
-
 
3010
                convert_MDLtype (newatomtype, atomtype);
-
 
3011
                strsub (xstr, rline, 1, 10);    /* fixed in v0.3k (was: 2,9 etc.) */
-
 
3012
                strsub (ystr, rline, 11, 10);
-
 
3013
                strsub (zstr, rline, 21, 10);
-
 
3014
                /*chgstr := '0'; */
-
 
3015
                strsub (chgstr, rline, 37, 3);  /* new in v0.3j */
-
 
3016
                (void)sscanf (chgstr, "%f", &chgval);
-
 
3017
                if (chgval != 0) {
-
 
3018
                  if (chgval >= 1 && chgval <= 7)
-
 
3019
                          chgval = 4.0 - chgval;
-
 
3020
                  else {
-
 
3021
                          chgval = 0.0;
-
 
3022
                        }
-
 
3023
                }                       /* end (v0.3j) */
-
 
3024
                (void)sscanf (xstr, "%f", &xval);
-
 
3025
                (void)sscanf (ystr, "%f", &yval);
-
 
3026
                (void)sscanf (zstr, "%f", &zval);
-
 
3027
                /* v0.3k: removed superfluous val(chgstr,chgval,code) */
-
 
3028
                WITH = &atom[v - 1];
-
 
3029
                strcpy (WITH->element, elemstr);
-
 
3030
                if (!strcmp (elemstr, "A ") || !strcmp (elemstr, "Q ") ||
-
 
3031
                    !strcmp (elemstr, "X "))
-
 
3032
                  /* 'X ' added in v0.3n */
-
 
3033
                  found_querymol = true;
3278
 
3034
 
3279
          WITH->x = xval;
3035
                strcpy (WITH->atype, newatomtype);
3280
          WITH->y = yval;
3036
 
3281
          WITH->z = zval;
3037
                if (!strcmp (elemstr, "D ")) {
3282
          WITH->formal_charge = (long) floor (chgval + 0.5);
3038
                  strcpy (WITH->element, "H ");
3283
          WITH->real_charge = 0.0;      /* v0.3j */
3039
                  WITH->nucleon_number = 2;
3284
          /* read aromaticity flag from CheckMol-tweaked MDL molfile */
3040
                }                       /* 0.3x */
3285
          if (strlen (rline) > 37 && rline[37] == '0')
3041
                if (!strcmp (elemstr, "T ")) {
3286
            {
3042
                  strcpy (WITH->element, "H ");
3287
              WITH->arom = true;
3043
                  WITH->nucleon_number = 3;
3288
              found_arominfo = true;
3044
                }                       /* 0.3x */
3289
            }
3045
 
3290
          /* new in v0.3d: read stereo care flag */
3046
                WITH->x = xval;
3291
          if (strlen (rline) > 47 && rline[47] == '1')
3047
                WITH->y = yval;
3292
            WITH->stereo_care = true;
3048
                WITH->z = zval;
3293
          if (is_heavyatom (n))
3049
                WITH->formal_charge = (long) floor (chgval + 0.5);
3294
            {
3050
                WITH->real_charge = 0.0;        /* v0.3j */
3295
              n_heavyatoms++;
3051
                /* read aromaticity flag from CheckMol-tweaked MDL molfile */
3296
              WITH->heavy = true;
3052
                if (strlen (rline) > 37 && rline[37] == '0') {
3297
              if (is_metal (n))
3053
                  WITH->arom = true;
3298
                WITH->metal = true;
3054
                  found_arominfo = true;
3299
            }
3055
                }
3300
          WITH->nvalences = get_nvalences (WITH->element);
3056
                /* new in v0.3d: read stereo care flag */
3301
          /* v0.3m                 */
3057
                if (strlen (rline) > 47 && rline[47] == '1')
3302
        }
3058
                  WITH->stereo_care = true;
3303
    }                           /* if (n_atoms > 0)... */
3059
                if (is_heavyatom (n)) {
3304
  if (n_bonds > 0)
3060
                  n_heavyatoms++;
3305
    {                           /* v0.3l */
3061
                  WITH->heavy = true;
3306
      for (n = 1; n <= tmp_n_bonds; n++)
3062
                  if (is_metal (n))
3307
        {
3063
                          WITH->metal = true;
3308
          if (n <= max_bonds)
3064
                }
3309
            v = n;
3065
                WITH->nvalences = get_nvalences (WITH->element);
3310
          else
3066
                /* v0.3m                 */
3311
            v = max_bonds;
3067
              }
3312
          /* just for safety; v0.3l */
3068
      }                         /* if (n_atoms > 0)... */
3313
          ri++;
3069
      if (n_bonds > 0) {                                /* v0.3l */
3314
          strcpy (rline, molbuf[ri - 1]);
3070
        for (n = 1; n <= tmp_n_bonds; n++) {
3315
          sprintf (a1str, "%.3s", rline);
3071
                if (n <= max_bonds)
3316
          strsub (a2str, rline, 4, 3);
3072
                  v = n;
3317
          code = (sscanf (a1str, "%d", &a1val) == 0);
3073
                else
3318
          if (code != 0)        /* v0.3l */
3074
                  v = max_bonds;
3319
            a1val = 1;
3075
                /* just for safety; v0.3l */
3320
          code = (sscanf (a2str, "%d", &a2val) == 0);
3076
                ri++;
3321
          if (code != 0)        /* v0.3l */
3077
                strcpy (rline, molbuf[ri - 1]);
3322
            a2val = 1;
3078
                sprintf (a1str, "%.3s", rline);
3323
          WITH1 = &bond[v - 1];
3079
                strsub (a2str, rline, 4, 3);
3324
          WITH1->a1 = a1val;
3080
                code = (sscanf (a1str, "%d", &a1val) == 0);
3325
          WITH1->a2 = a2val;
3081
                if (code != 0)  /* v0.3l */
3326
          if (rline[8] == '1')  /* single */
3082
                  a1val = 1;
3327
            WITH1->btype = 'S';
3083
                code = (sscanf (a2str, "%d", &a2val) == 0);
3328
          if (rline[8] == '2')  /* double */
3084
                if (code != 0)  /* v0.3l */
3329
            WITH1->btype = 'D';
3085
                  a2val = 1;
3330
          if (rline[8] == '3')  /* triple */
3086
                WITH1 = &bond[v - 1];
3331
            WITH1->btype = 'T';
3087
                WITH1->a1 = a1val;
3332
          if (rline[8] == '4')  /* aromatic */
3088
                WITH1->a2 = a2val;
3333
            WITH1->btype = 'A';
3089
                if (rline[8] == '1')    /* single */
3334
          if (rline[8] == '5')  /* single or double */
3090
                  WITH1->btype = 'S';
3335
            WITH1->btype = 'l';
3091
                if (rline[8] == '2')    /* double */
3336
          if (rline[8] == '6')  /* single or aromatic */
3092
                  WITH1->btype = 'D';
3337
            WITH1->btype = 's';
3093
                if (rline[8] == '3')    /* triple */
3338
          if (rline[8] == '7')  /* double or aromatic */
3094
                  WITH1->btype = 'T';
3339
            WITH1->btype = 'd';
3095
                if (rline[8] == '4')    /* aromatic */
3340
          if (rline[8] == '8')  /* any */
3096
                  WITH1->btype = 'A';
3341
            WITH1->btype = 'a';
3097
                if (rline[8] == '5')    /* single or double */
3342
          sprintf (STR1, "%c", WITH1->btype);
3098
                  WITH1->btype = 'l';
3343
          if (strpos2 ("lsda", STR1, 1) > 0)
3099
                if (rline[8] == '6')    /* single or aromatic */
3344
            found_querymol = true;
3100
                  WITH1->btype = 's';
3345
          WITH1->arom = false;
3101
                if (rline[8] == '7')    /* double or aromatic */
3346
          WITH1->q_arom = false;        /* 0.3p */
3102
                  WITH1->btype = 'd';
3347
          /* read aromaticity flag from CheckMol-tweaked MDL molfile */
3103
                if (rline[8] == '8')    /* any */
3348
          if (WITH1->btype == 'A' || rline[7] == '0')
3104
                  WITH1->btype = 'a';
3349
            {
3105
                sprintf (STR1, "%c", WITH1->btype);
3350
              WITH1->arom = true;
3106
                if (strpos2 ("lsda", STR1, 1) > 0)
3351
              if (rline[7] == '0')
3107
                  found_querymol = true;
3352
                found_arominfo = true;
3108
                WITH1->arom = false;
3353
            }
3109
                WITH1->q_arom = false;  /* 0.3p */
3354
          strsub (tmpstr, rline, 13, 3);
3110
                /* read aromaticity flag from CheckMol-tweaked MDL molfile */
3355
          /* new in v0.3d: read ring_count from tweaked molfile */
3111
                if (WITH1->btype == 'A' || rline[7] == '0') {
3356
          code = (sscanf (tmpstr, "%d", &rc) == 0);
3112
                  WITH1->arom = true;
3357
          if (code != 0 || rc < 0 || progmode == pmCheckMol || tmfmismatch)
3113
                  if (rline[7] == '0')
3358
            WITH1->ring_count = 0;
3114
                          found_arominfo = true;
3359
          else
3115
                }
3360
            WITH1->ring_count = rc;
3116
                strsub (tmpstr, rline, 13, 3);
3361
          /* v0.3n: added tmfmismatch check */
3117
                /* new in v0.3d: read ring_count from tweaked molfile */
3362
          strsub (tmpstr, rline, 16, 3);        /* new in v0.3d: read bond topology; */
3118
                code = (sscanf (tmpstr, "%d", &rc) == 0);
3363
          code = (sscanf (tmpstr, "%d", &bt) == 0);
3119
                if (code != 0 || rc < 0 || progmode == pmCheckMol || tmfmismatch)
3364
          /* extended features are encoded by leading zero */
3120
                  WITH1->ring_count = 0;
3365
          if (code != 0 || (unsigned long) bt > 2)
3121
                else
3366
            WITH1->topo = btopo_any;
3122
                 WITH1->ring_count = rc;
3367
          else
3123
                /* v0.3n: added tmfmismatch check */
3368
            {
3124
                strsub (tmpstr, rline, 16, 3);  /* new in v0.3d: read bond topology; */
3369
              if (tmpstr[1] == '0')
3125
                code = (sscanf (tmpstr, "%d", &bt) == 0);
3370
                WITH1->topo = bt + 3;
3126
                /* extended features are encoded by leading zero */
3371
              else
3127
                if (code != 0 || (unsigned long) bt > 2)
3372
                WITH1->topo = bt;
3128
                  WITH1->topo = btopo_any;
3373
            }
3129
                else {
3374
          /* v0.3n changed >5 into >2 */
3130
                  if (tmpstr[1] == '0')
3375
          /* new in v0.3d: add stereo property from MDL "stereo care" flag in atom block */
3131
                          WITH1->topo = bt + 3;
3376
          WITH1->stereo = bstereo_any;
3132
                  else
3377
          if (WITH1->btype == 'D')
3133
                          WITH1->topo = bt;
3378
            {
3134
                }
3379
              if (atom[WITH1->a1 - 1].stereo_care
3135
          /* v0.3n changed >5 into >2 */
3380
                  && atom[WITH1->a2 - 1].stereo_care)
3136
          /* new in v0.3d: add stereo property from MDL "stereo care" flag in atom block */
3381
                {               /* this is the MDL-conformant encoding, */
3137
          WITH1->stereo = bstereo_any;
3382
                  WITH1->stereo = bstereo_xyz;  /* for an alternative see below */
3138
          if (WITH1->btype == 'D') {
3383
                  ez_flag = true;       /* v0.3f */
3139
            if (atom[WITH1->a1 - 1].stereo_care
3384
                }
3140
                && atom[WITH1->a2 - 1].stereo_care) {           /* this is the MDL-conformant encoding, */
3385
              else
3141
              WITH1->stereo = bstereo_xyz;      /* for an alternative see below */
3386
                {               /* this extended feature is encoded by a leading zero */
3142
              ez_flag = true;   /* v0.3f */
3387
                  strsub (tmpstr, rline, 10, 3);
3143
            }
3388
                  /* new in v0.3d: read bond stereo specification; */
3144
                  else {                /* this extended feature is encoded by a leading zero */
3389
                  code = (sscanf (tmpstr, "%d", &bs) == 0);
3145
                          strsub (tmpstr, rline, 10, 3);
3390
                  WITH1->mdl_stereo = bs;       /* v0.3n */
3146
                          /* new in v0.3d: read bond stereo specification; */
3391
                  if (code != 0 || bs <= 0 || bs > 2)
3147
                          code = (sscanf (tmpstr, "%d", &bs) == 0);
3392
                    WITH1->stereo = bstereo_any;
3148
                          WITH1->mdl_stereo = bs;       /* v0.3n */
3393
                  else
3149
                          if (code != 0 || bs <= 0 || bs > 2)
3394
                    WITH1->stereo = bstereo_xyz;
3150
                            WITH1->stereo = bstereo_any;
3395
                  if (tmpstr[1] == '0')
3151
                          else
3396
                    WITH1->stereo = bstereo_xyz;
3152
                            WITH1->stereo = bstereo_xyz;
3397
                }
3153
                          if (tmpstr[1] == '0')
3398
            }
3154
                            WITH1->stereo = bstereo_xyz;
3399
          /*if stereo <> bstereo_any then ez_search := true; */
3155
                        }
3400
          if (WITH1->stereo != bstereo_any)     /* changed in v0.3f */
3156
                }
3401
            ez_flag = true;
3157
                /*if stereo <> bstereo_any then ez_search := true; */
3402
          if (WITH1->btype == 'S' && strlen (rline) > 11 && rline[11] == '1')
3158
                if (WITH1->stereo != bstereo_any)       /* changed in v0.3f */
3403
            WITH1->stereo = bstereo_up;
3159
                  ez_flag = true;
3404
          if (WITH1->btype == 'S' && strlen (rline) > 11 && rline[11] == '6')
3160
                if (WITH1->btype == 'S' && strlen (rline) > 11 && rline[11] == '1')
3405
            WITH1->stereo = bstereo_down;
3161
                  WITH1->stereo = bstereo_up;
3406
          if (WITH1->btype == 'S' && strlen (rline) > 11 && rline[11] == '4')
3162
                if (WITH1->btype == 'S' && strlen (rline) > 11 && rline[11] == '6')
3407
            WITH1->stereo = bstereo_either;     /* 0.3x */
3163
                  WITH1->stereo = bstereo_down;
3408
          if (WITH1->btype == 'D' && strlen (rline) > 11 && rline[11] == '3')
3164
                if (WITH1->btype == 'S' && strlen (rline) > 11 && rline[11] == '4')
3409
            WITH1->stereo = bstereo_double_either;      /* 0.3x */
3165
                  WITH1->stereo = bstereo_either;       /* 0.3x */
3410
          strsub (tmpstr, rline, 10, 3);
3166
                if (WITH1->btype == 'D' && strlen (rline) > 11 && rline[11] == '3')
3411
          /* new in v0.3n: save original bond stereo specification; */
3167
                  WITH1->stereo = bstereo_double_either;        /* 0.3x */
3412
          (void)sscanf (tmpstr, "%d", &bs);
3168
                strsub (tmpstr, rline, 10, 3);
3413
          /* v0.3n */
3169
                /* new in v0.3n: save original bond stereo specification; */
3414
/* p2c: checkmol.pas: Note: Eliminated unused assignment statement [338] */
3170
                (void)sscanf (tmpstr, "%d", &bs);
3415
          WITH1->mdl_stereo = bs;       /* v0.3n */
3171
                /* v0.3n */
3416
          if (atom[a1val - 1].heavy && atom[a2val - 1].heavy)
3172
          /* p2c: checkmol.pas: Note: Eliminated unused assignment statement [338] */
3417
            n_heavybonds++;
3173
                WITH1->mdl_stereo = bs; /* v0.3n */
3418
        }
3174
                if (atom[a1val - 1].heavy && atom[a2val - 1].heavy)
3419
    }                           /* if (n_bonds > 0)... */
3175
                  n_heavybonds++;
3420
  while (ri < molbufindex && sepcount < 1)
3176
              }
3421
    {
3177
      }                         /* if (n_bonds > 0)... */
3422
      ri++;
3178
      while (ri < molbufindex && sepcount < 1) {
3423
      strcpy (rline, molbuf[ri - 1]);
3179
        ri++;
3424
      if (strpos2 (rline, "M  CHG", 1) > 0)
3180
        strcpy (rline, molbuf[ri - 1]);
3425
        {                       /* new in v0.3j */
3181
    if (strpos2 (rline, "M  CHG", 1) > 0) {                     /* new in v0.3j */
3426
          if (clearcharges)
3182
            if (clearcharges) {                 /* "M  CHG" supersedes all "old-style" charge values */
3427
            {                   /* "M  CHG" supersedes all "old-style" charge values */
-
 
3428
 
3183
 
3429
              for (i = 0; i < n_atoms; i++)
3184
              for (i = 0; i < n_atoms; i++)
3430
                atom[i].formal_charge = 0;
3185
                atom[i].formal_charge = 0;
3431
            }
3186
            }
3432
          read_charges (rline);
3187
            read_charges (rline);
3433
          clearcharges = false;
3188
            clearcharges = false;
3434
          /* subsequent "M  CHG" lines must not clear previous values */
3189
            /* subsequent "M  CHG" lines must not clear previous values */
3435
        }
3190
          }
3436
 
3191
 
3437
      if (strpos2 (rline, "M  ISO", 1) > 0)
3192
    if (strpos2 (rline, "M  ISO", 1) > 0)
3438
        read_isotopes (rline);  /* 0.3x */
3193
            read_isotopes (rline);      /* 0.3x */
3439
 
3194
 
3440
      if (strpos2 (rline, "M  RAD", 1) > 0)
3195
    if (strpos2 (rline, "M  RAD", 1) > 0)
3441
        read_radicals (rline);  /* 0.3x */
3196
            read_radicals (rline);      /* 0.3x */
3442
 
3197
 
3443
      if (strpos2 (rline, "$$$$", 1) > 0)
3198
    if (strpos2 (rline, "$$$$", 1) > 0) {
3444
        {
-
 
3445
          sepcount++;
3199
            sepcount++;
3446
          if (molbufindex > ri + 2)     /* we assume this is an SDF file */
3200
            if (molbufindex > ri + 2)   /* we assume this is an SDF file */
3447
            mol_in_queue = true;
3201
              mol_in_queue = true;
3448
        }
3202
          }
3449
    }
3203
  }
3450
  memset (ring, 0, sizeof (ringlist));
3204
  memset (ring, 0, sizeof (ringlist));
3451
  for (n = 0; n < max_rings; n++)
3205
  for (n = 0; n < max_rings; n++) {                             /* new in v0.3 */
3452
    {                           /* new in v0.3 */
-
 
3453
      ringprop[n].size = 0;
3206
    ringprop[n].size = 0;
3454
      ringprop[n].arom = false;
3207
    ringprop[n].arom = false;
3455
      ringprop[n].envelope = false;
3208
    ringprop[n].envelope = false;
3456
    }
3209
  }
3457
  li = ri + 1;
3210
  li = ri + 1;
3458
}
3211
}
3459
 
3212
 
3460
 
-
 
3461
 
-
 
3462
static void
-
 
3463
write_MDLmolfile ()
3213
static void write_MDLmolfile ()
3464
{
3214
{
3465
  int i;
3215
  int i;
3466
  char tmpstr[256];
3216
  char tmpstr[256];
3467
  char wline[256];
3217
  char wline[256];
3468
  int a_chg;
3218
  int a_chg;
Line 3502... Line 3252...
3502
  strcat (wline, tmpstr);
3252
  strcat (wline, tmpstr);
3503
  *tmpstr = '\0';               /* next 3 digits: number of bonds */
3253
  *tmpstr = '\0';               /* next 3 digits: number of bonds */
3504
  strcpy (tmpstr, "  0");
3254
  strcpy (tmpstr, "  0");
3505
  strcat (wline, tmpstr);
3255
  strcat (wline, tmpstr);
3506
  *tmpstr = '\0';               /* next 3 digits: number of atom lists (not used by us) */
3256
  *tmpstr = '\0';               /* next 3 digits: number of atom lists (not used by us) */
3507
/* p2c: checkmol.pas, line 2388:
3257
  /* p2c: checkmol.pas, line 2388:
3508
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
3258
  * Note: Turbo Pascal conditional compilation directive was ignored [218] */
3509
#ifdef REDUCED_SAR
3259
#ifdef REDUCED_SAR
3510
  sprintf (tmpstr, "%d", n_countablerings);
3260
  sprintf (tmpstr, "%d", n_countablerings);
3511
  /* v0.3n; changed n_rings into n_countablerings */
3261
  /* v0.3n; changed n_rings into n_countablerings */
3512
#else
3262
#else
3513
  sprintf (tmpstr, "%d", n_rings);
3263
  sprintf (tmpstr, "%d", n_rings);
Line 3524... Line 3274...
3524
  /* v0.3n */
3274
  /* v0.3n */
3525
  strcat (wline, "               999 V2000");
3275
  strcat (wline, "               999 V2000");
3526
  /* v0.3n (adjust string length) */
3276
  /* v0.3n (adjust string length) */
3527
  puts (wline);
3277
  puts (wline);
3528
  FORLIM = n_atoms;
3278
  FORLIM = n_atoms;
3529
  for (i = 0; i < FORLIM; i++)
3279
  for (i = 0; i < FORLIM; i++) {
3530
    {
-
 
3531
      *wline = '\0';
3280
    *wline = '\0';
3532
      sprintf (tmpstr, "%1.4f", atom[i].x);
3281
    sprintf (tmpstr, "%1.4f", atom[i].x);
3533
      lblank (10L, tmpstr);
3282
    lblank (10L, tmpstr);
3534
      strcat (wline, tmpstr);
3283
    strcat (wline, tmpstr);
3535
      sprintf (tmpstr, "%1.4f", atom[i].y);
3284
    sprintf (tmpstr, "%1.4f", atom[i].y);
3536
      lblank (10L, tmpstr);
3285
    lblank (10L, tmpstr);
3537
      strcat (wline, tmpstr);
3286
    strcat (wline, tmpstr);
3538
      sprintf (tmpstr, "%1.4f", atom[i].z);
3287
    sprintf (tmpstr, "%1.4f", atom[i].z);
3539
      lblank (10L, tmpstr);
3288
    lblank (10L, tmpstr);
3540
      strcat (wline, tmpstr);
3289
    strcat (wline, tmpstr);
3541
      strcpy (tmpstr, atom[i].element);
3290
    strcpy (tmpstr, atom[i].element);
3542
      /* tmpstr := lowercase(tmpstr); REPLACE!!! */
3291
    /* tmpstr := lowercase(tmpstr); REPLACE!!! */
3543
      //tmpstr[0] = toupper (tmpstr[0]);
3292
    //tmpstr[0] = toupper (tmpstr[0]);
3544
      all_lowercase (tmpstr);
3293
    all_lowercase (tmpstr);
3545
      tmpstr[0] = toupper (tmpstr[0]);
3294
    tmpstr[0] = toupper (tmpstr[0]);
3546
      /*wline := wline + ' '+atom^[i].element+' '; */
3295
    /*wline := wline + ' '+atom^[i].element+' '; */
3547
      sprintf (wline + strlen (wline), " %s ", tmpstr);
3296
    sprintf (wline + strlen (wline), " %s ", tmpstr);
3548
      strcat (wline, " 0");     /* mass difference (isotopes) */
3297
    strcat (wline, " 0");       /* mass difference (isotopes) */
3549
      /* now we code aromaticity into the old-style charge column (charges are now in the M  CHG line) */
3298
    /* now we code aromaticity into the old-style charge column (charges are now in the M  CHG line) */
3550
      if (atom[i].arom)
3299
    if (atom[i].arom)
3551
        strcpy (tmpstr, " 00");
3300
            strcpy (tmpstr, " 00");
3552
      else
3301
    else
3553
        strcpy (tmpstr, "  0");
3302
            strcpy (tmpstr, "  0");
3554
      strcat (wline, tmpstr);
3303
      strcat (wline, tmpstr);
3555
      strcat (wline, "  0  0  0  0  0  0  0  0  0  0");
3304
      strcat (wline, "  0  0  0  0  0  0  0  0  0  0");
3556
      puts (wline);
3305
      puts (wline);
3557
    }
3306
  }
3558
  FORLIM = n_bonds;
3307
  FORLIM = n_bonds;
3559
  for (i = 0; i < FORLIM; i++)
3308
  for (i = 0; i < FORLIM; i++) {
3560
    {
-
 
3561
      *wline = '\0';
3309
    *wline = '\0';
3562
      sprintf (tmpstr, "%d", bond[i].a1);
3310
    sprintf (tmpstr, "%d", bond[i].a1);
3563
      lblank (3L, tmpstr);
3311
    lblank (3L, tmpstr);
3564
      strcat (wline, tmpstr);
3312
    strcat (wline, tmpstr);
3565
      sprintf (tmpstr, "%d", bond[i].a2);
3313
    sprintf (tmpstr, "%d", bond[i].a2);
3566
      lblank (3L, tmpstr);
3314
    lblank (3L, tmpstr);
3567
      strcat (wline, tmpstr);
3315
    strcat (wline, tmpstr);
3568
      if (bond[i].btype == 'S')
3316
    if (bond[i].btype == 'S')
3569
        strcpy (tmpstr, "  1");
3317
            strcpy (tmpstr, "  1");
3570
      if (bond[i].btype == 'D')
3318
    if (bond[i].btype == 'D')
3571
        strcpy (tmpstr, "  2");
3319
            strcpy (tmpstr, "  2");
3572
      if (bond[i].btype == 'T')
3320
    if (bond[i].btype == 'T')
3573
        strcpy (tmpstr, "  3");
3321
            strcpy (tmpstr, "  3");
3574
      if (bond[i].btype == 'A')
3322
    if (bond[i].btype == 'A')
3575
        strcpy (tmpstr, "  4");
3323
            strcpy (tmpstr, "  4");
3576
      if (bond[i].btype == 'l')
3324
    if (bond[i].btype == 'l')
3577
        strcpy (tmpstr, "  5");
3325
            strcpy (tmpstr, "  5");
3578
      if (bond[i].btype == 's')
3326
    if (bond[i].btype == 's')
3579
        strcpy (tmpstr, "  6");
3327
            strcpy (tmpstr, "  6");
3580
      if (bond[i].btype == 'd')
3328
    if (bond[i].btype == 'd')
3581
        strcpy (tmpstr, "  7");
3329
            strcpy (tmpstr, "  7");
3582
      if (bond[i].btype == 'a')
3330
    if (bond[i].btype == 'a')
3583
        strcpy (tmpstr, "  8");
3331
            strcpy (tmpstr, "  8");
3584
      /* now encode our own aromaticity information */
3332
      /* now encode our own aromaticity information */
3585
      if (bond[i].arom)
3333
    if (bond[i].arom)
3586
        tmpstr[1] = '0';
3334
            tmpstr[1] = '0';
3587
      strcat (wline, tmpstr);   /* next, encode bond stereo property (v0.3f) */
3335
    strcat (wline, tmpstr);     /* next, encode bond stereo property (v0.3f) */
3588
      /*if (bond^[i].stereo = bstereo_up) then wline := wline + '  1' else */
3336
    /*if (bond^[i].stereo = bstereo_up) then wline := wline + '  1' else */
3589
      /*  if (bond^[i].stereo = bstereo_down) then wline := wline + '  6' else */
3337
    /*  if (bond^[i].stereo = bstereo_down) then wline := wline + '  6' else */
3590
      /*    wline := wline + '  0'; */
3338
    /*    wline := wline + '  0'; */
3591
      /* restore original value from MDL molfile (v0.3n) */
3339
    /* restore original value from MDL molfile (v0.3n) */
3592
      /* wline := wline + '  ' + inttostr(bond^[i].mdl_stereo);    REPLACE!!! */
3340
    /* wline := wline + '  ' + inttostr(bond^[i].mdl_stereo);    REPLACE!!! */
3593
      *tmpstr = '\0';
3341
    *tmpstr = '\0';
3594
      sprintf (tmpstr, "%i", bond[i].mdl_stereo);
3342
    sprintf (tmpstr, "%i", bond[i].mdl_stereo);
3595
      strcat (wline, "  ");
3343
    strcat (wline, "  ");
3596
      strcat (wline, tmpstr);
3344
    strcat (wline, tmpstr);
3597
      *tmpstr = '\0';
3345
    *tmpstr = '\0';
3598
      /* now encode the ring_count of this bond (using a field which officially is "not used") */
3346
    /* now encode the ring_count of this bond (using a field which officially is "not used") */
3599
      /* tmpstr := inttostr(bond^[i].ring_count); REPLACE!!! */
3347
    /* tmpstr := inttostr(bond^[i].ring_count); REPLACE!!! */
3600
      sprintf (tmpstr, "%i", bond[i].ring_count);
3348
    sprintf (tmpstr, "%i", bond[i].ring_count);
3601
      while (strlen (tmpstr) < 3)
3349
    while (strlen (tmpstr) < 3)
3602
        sprintf (tmpstr, " %s", strcpy (STR1, tmpstr));
3350
            sprintf (tmpstr, " %s", strcpy (STR1, tmpstr));
3603
      sprintf (wline + strlen (wline), "%s  0  0", tmpstr);
3351
    sprintf (wline + strlen (wline), "%s  0  0", tmpstr);
3604
      puts (wline);
3352
    puts (wline);
3605
    }
3353
  }
3606
  FORLIM = n_atoms;
3354
  FORLIM = n_atoms;
3607
  for (i = 1; i <= FORLIM; i++)
3355
  for (i = 1; i <= FORLIM; i++) {
3608
    {
-
 
3609
      a_chg = atom[i - 1].formal_charge;
3356
    a_chg = atom[i - 1].formal_charge;
3610
      if (a_chg != 0)
3357
    if (a_chg != 0) {
3611
        {
-
 
3612
          strcpy (wline, "M  CHG  1 ");
3358
            strcpy (wline, "M  CHG  1 ");
3613
          sprintf (tmpstr, "%d", i);
3359
            sprintf (tmpstr, "%d", i);
3614
          lblank (3L, tmpstr);
3360
            lblank (3L, tmpstr);
3615
          sprintf (wline + strlen (wline), "%s ", tmpstr);
3361
            sprintf (wline + strlen (wline), "%s ", tmpstr);
3616
          sprintf (tmpstr, "%d", a_chg);
3362
            sprintf (tmpstr, "%d", a_chg);
3617
          lblank (3L, tmpstr);
3363
            lblank (3L, tmpstr);
3618
          strcat (wline, tmpstr);
3364
            strcat (wline, tmpstr);
3619
          puts (wline);
3365
            puts (wline);
3620
        }
3366
          }
3621
    }
3367
  }
3622
  for (i = 1; i <= FORLIM; i++) /* 0.3x */
3368
  for (i = 1; i <= FORLIM; i++) /* 0.3x */ {
3623
    {
-
 
3624
      a_iso = atom[i - 1].nucleon_number;
3369
    a_iso = atom[i - 1].nucleon_number;
3625
      if (a_iso != 0)
3370
    if (a_iso != 0) {
3626
        {
-
 
3627
          strcpy (wline, "M  ISO  1 ");
3371
            strcpy (wline, "M  ISO  1 ");
3628
          sprintf (tmpstr, "%d", i);
3372
            sprintf (tmpstr, "%d", i);
3629
          lblank (3L, tmpstr);
3373
            lblank (3L, tmpstr);
3630
          sprintf (wline + strlen (wline), "%s ", tmpstr);
3374
            sprintf (wline + strlen (wline), "%s ", tmpstr);
3631
          sprintf (tmpstr, "%d", a_iso);
3375
            sprintf (tmpstr, "%d", a_iso);
3632
          lblank (3L, tmpstr);
3376
            lblank (3L, tmpstr);
3633
          strcat (wline, tmpstr);
3377
            strcat (wline, tmpstr);
3634
          puts (wline);
3378
            puts (wline);
3635
        }
3379
          }
3636
    }
3380
  }
3637
  for (i = 1; i <= FORLIM; i++) /* 0.3x */
3381
  for (i = 1; i <= FORLIM; i++) /* 0.3x */ {
3638
    {
-
 
3639
      a_rad = atom[i - 1].radical_type;
3382
    a_rad = atom[i - 1].radical_type;
3640
      if (a_rad != 0)
3383
    if (a_rad != 0) {
3641
        {
-
 
3642
          strcpy (wline, "M  RAD  1 ");
3384
            strcpy (wline, "M  RAD  1 ");
3643
          sprintf (tmpstr, "%d", i);
3385
            sprintf (tmpstr, "%d", i);
3644
          lblank (3L, tmpstr);
3386
            lblank (3L, tmpstr);
3645
          sprintf (wline + strlen (wline), "%s ", tmpstr);
3387
            sprintf (wline + strlen (wline), "%s ", tmpstr);
3646
          sprintf (tmpstr, "%d", a_rad);
3388
            sprintf (tmpstr, "%d", a_rad);
3647
          lblank (3L, tmpstr);
3389
            lblank (3L, tmpstr);
3648
          strcat (wline, tmpstr);
3390
            strcat (wline, tmpstr);
3649
          puts (wline);
3391
            puts (wline);
3650
        }
3392
          }
3651
    }
3393
  }
3652
  printf ("M  END\n");
3394
  printf ("M  END\n");
3653
}
3395
}
3654
 
-
 
3655
 
3396
 
3656
/*============= chemical processing functions && procedures ============ */
3397
/*============= chemical processing functions && procedures ============ */
3657
 
3398
 
3658
static boolean
-
 
3659
is_electroneg (a_el)
3399
static boolean is_electroneg (a_el)
3660
     char *a_el;
3400
     char *a_el;
3661
{
3401
{
3662
  /* new in v0.3j */
3402
  /* new in v0.3j */
3663
  boolean res = false;
3403
  boolean res = false;
3664
 
3404
 
3665
  if (!strcmp (a_el, "N "))
3405
  if (!strcmp (a_el, "N "))
3666
    res = true;
3406
    res = true;
3667
  if (!strcmp (a_el, "P "))
3407
  if (!strcmp (a_el, "P "))
3668
    res = true;
3408
    res = true;
3669
  if (!strcmp (a_el, "O "))
3409
  if (!strcmp (a_el, "O "))
3670
    res = true;
3410
    res = true;
3671
  if (!strcmp (a_el, "S "))
3411
  if (!strcmp (a_el, "S "))
3672
    res = true;
3412
    res = true;
3673
  if (!strcmp (a_el, "SE"))
3413
  if (!strcmp (a_el, "SE"))
3674
    res = true;
3414
    res = true;
3675
  if (!strcmp (a_el, "TE"))
3415
  if (!strcmp (a_el, "TE"))
3676
    res = true;
3416
    res = true;
3677
  if (!strcmp (a_el, "F "))
3417
  if (!strcmp (a_el, "F "))
3678
    res = true;
3418
    res = true;
3679
  if (!strcmp (a_el, "CL"))
3419
  if (!strcmp (a_el, "CL"))
3680
    res = true;
3420
    res = true;
3681
  if (!strcmp (a_el, "BR"))
3421
  if (!strcmp (a_el, "BR"))
3682
    res = true;
3422
    res = true;
3683
  if (!strcmp (a_el, "I "))
3423
  if (!strcmp (a_el, "I "))
3684
    res = true;
3424
    res = true;
3685
  if (!strcmp (a_el, "AT"))
3425
  if (!strcmp (a_el, "AT"))
3686
    res = true;
3426
    res = true;
3687
  return res;
3427
  return res;
3688
}
3428
}
3689
 
3429
 
3690
 
-
 
3691
static void
-
 
3692
count_neighbors ()
3430
static void count_neighbors ()
3693
{
3431
{
3694
  /* counts heavy-atom neighbors and explicit hydrogens */
3432
  /* counts heavy-atom neighbors and explicit hydrogens */
3695
  int i, FORLIM;
3433
  int i, FORLIM;
3696
 
3434
 
3697
  if (n_atoms < 1 || n_bonds < 1)
3435
  if (n_atoms < 1 || n_bonds < 1)
3698
    return;
3436
    return;
3699
  FORLIM = n_bonds;
3437
  FORLIM = n_bonds;
3700
  for (i = 0; i < FORLIM; i++)
3438
  for (i = 0; i < FORLIM; i++) {
3701
    {
-
 
3702
      if (atom[bond[i].a1 - 1].heavy)
3439
    if (atom[bond[i].a1 - 1].heavy)
3703
        atom[bond[i].a2 - 1].neighbor_count++;
3440
            atom[bond[i].a2 - 1].neighbor_count++;
3704
      if (atom[bond[i].a2 - 1].heavy)
3441
    if (atom[bond[i].a2 - 1].heavy)
3705
        atom[bond[i].a1 - 1].neighbor_count++;
3442
            atom[bond[i].a1 - 1].neighbor_count++;
3706
      if (!strcmp (atom[bond[i].a1 - 1].element, "H "))
3443
    if (!strcmp (atom[bond[i].a1 - 1].element, "H "))
3707
        atom[bond[i].a2 - 1].Hexp++;
3444
            atom[bond[i].a2 - 1].Hexp++;
3708
      if (!strcmp (atom[bond[i].a2 - 1].element, "H "))
3445
    if (!strcmp (atom[bond[i].a2 - 1].element, "H "))
3709
        atom[bond[i].a1 - 1].Hexp++;
3446
            atom[bond[i].a1 - 1].Hexp++;
3710
      /* plausibility check (new in v02.i) */
3447
    /* plausibility check (new in v02.i) */
3711
      if (atom[bond[i].a1 - 1].neighbor_count > max_neighbors ||
3448
    if (atom[bond[i].a1 - 1].neighbor_count > max_neighbors ||
3712
          atom[bond[i].a2 - 1].neighbor_count > max_neighbors)
3449
              atom[bond[i].a2 - 1].neighbor_count > max_neighbors) {
3713
        {
-
 
3714
          mol_OK = false;
3450
            mol_OK = false;
3715
          /*writeln('invalid molecule!'); */
3451
            /*writeln('invalid molecule!'); */
3716
        }
3452
          }
3717
    }
3453
  }
3718
}
3454
}
3719
 
-
 
3720
 
3455
 
3721
static void
-
 
3722
get_neighbors (Result, id)
3456
static void get_neighbors (Result, id)
3723
     int *Result;
3457
  int *Result;
3724
     int id;
3458
  int id;
3725
{
3459
{
3726
  int i;
3460
  int i;
3727
  //neighbor_rec nb_tmp;
3461
  //neighbor_rec nb_tmp;
3728
  int nb_count = 0;
3462
  int nb_count = 0;
3729
  //int FORLIM = n_bonds;
3463
  //int FORLIM = n_bonds;
3730
 
3464
 
3731
  //memset (Result, 0, sizeof (neighbor_rec));
3465
  //memset (Result, 0, sizeof (neighbor_rec));
3732
 
3466
 
3733
  for (i = 0; i < n_bonds; i++)
3467
  for (i = 0; i < n_bonds; i++) {
3734
    {
-
 
3735
      if (bond[i].a1 == id && atom[bond[i].a2 - 1].heavy
3468
    if (bond[i].a1 == id && atom[bond[i].a2 - 1].heavy
3736
          && nb_count < max_neighbors)
3469
              && nb_count < max_neighbors) {
3737
        {
-
 
3738
          Result[nb_count++] = bond[i].a2;
3470
            Result[nb_count++] = bond[i].a2;
3739
        }
3471
          }
3740
      if (bond[i].a2 == id && atom[bond[i].a1 - 1].heavy
3472
    if (bond[i].a2 == id && atom[bond[i].a1 - 1].heavy
3741
          && nb_count < max_neighbors)
3473
              && nb_count < max_neighbors) {
3742
        {
-
 
3743
          Result[nb_count++] = bond[i].a1;
3474
            Result[nb_count++] = bond[i].a1;
3744
        }
3475
          }
3745
    }
3476
  }
3746
  //return memcpy (Result, nb_tmp, sizeof (neighbor_rec));
3477
  //return memcpy (Result, nb_tmp, sizeof (neighbor_rec));
3747
}
3478
}
3748
 
3479
 
3749
 
-
 
3750
static void
-
 
3751
get_ndl_neighbors (int *Result, int id)
3480
static void get_ndl_neighbors (int *Result, int id)
3752
{
3481
{
3753
  int i;
3482
  int i;
3754
  //neighbor_rec nb_tmp;
3483
  //neighbor_rec nb_tmp;
3755
  int nb_count = 0;
3484
  int nb_count = 0;
3756
  /* v0.3i: use max_neighbors instead of a fixed value of 8 */
3485
  /* v0.3i: use max_neighbors instead of a fixed value of 8 */
3757
  //int FORLIM = ndl_n_bonds;
3486
  //int FORLIM = ndl_n_bonds;
3758
 
3487
 
3759
  //memset (nb_tmp, 0, sizeof (neighbor_rec));
3488
  //memset (nb_tmp, 0, sizeof (neighbor_rec));
3760
 
3489
 
3761
  for (i = 0; i < ndl_n_bonds; i++)
3490
  for (i = 0; i < ndl_n_bonds; i++) {
3762
    {
-
 
3763
      if (ndl_bond[i].a1 == id && nb_count < max_neighbors &&
3491
    if (ndl_bond[i].a1 == id && nb_count < max_neighbors &&
3764
          ndl_atom[ndl_bond[i].a2 - 1].heavy)
3492
              ndl_atom[ndl_bond[i].a2 - 1].heavy) {
3765
        {
-
 
3766
          nb_count++;
3493
            nb_count++;
3767
          Result[nb_count - 1] = ndl_bond[i].a2;
3494
            Result[nb_count - 1] = ndl_bond[i].a2;
3768
        }
3495
          }
3769
      if (ndl_bond[i].a2 == id && nb_count < max_neighbors &&
3496
    if (ndl_bond[i].a2 == id && nb_count < max_neighbors &&
3770
          ndl_atom[ndl_bond[i].a1 - 1].heavy)
3497
              ndl_atom[ndl_bond[i].a1 - 1].heavy){
3771
        {
-
 
3772
          nb_count++;
3498
            nb_count++;
3773
          Result[nb_count - 1] = ndl_bond[i].a1;
3499
            Result[nb_count - 1] = ndl_bond[i].a1;
3774
        }
3500
          }
3775
    }
3501
  }
3776
  //return memcpy (Result, nb_tmp, sizeof (neighbor_rec));
3502
  //return memcpy (Result, nb_tmp, sizeof (neighbor_rec));
3777
}
3503
}
3778
 
-
 
3779
 
3504
 
3780
static int *
-
 
3781
get_nextneighbors (int *Result, int id, int prev_id)
3505
static int * get_nextneighbors (int *Result, int id, int prev_id)
3782
{
3506
{
3783
  int i;
3507
  int i;
3784
  neighbor_rec nb_tmp;
3508
  neighbor_rec nb_tmp;
3785
  int nb_count = 0;
3509
  int nb_count = 0;
3786
  int FORLIM;
3510
  int FORLIM;
3787
 
3511
 
3788
  /* gets all neighbors except prev_id (usually the atom where we came from */
3512
  /* gets all neighbors except prev_id (usually the atom where we came from */
3789
  memset (nb_tmp, 0, sizeof (neighbor_rec));
3513
  memset (nb_tmp, 0, sizeof (neighbor_rec));
3790
  FORLIM = n_bonds;
3514
  FORLIM = n_bonds;
3791
  for (i = 0; i < FORLIM; i++)
3515
  for (i = 0; i < FORLIM; i++) {
3792
    {
-
 
3793
      if (bond[i].a1 == id && bond[i].a2 != prev_id &&
3516
    if (bond[i].a1 == id && bond[i].a2 != prev_id &&
3794
          nb_count < max_neighbors && atom[bond[i].a2 - 1].heavy)
3517
              nb_count < max_neighbors && atom[bond[i].a2 - 1].heavy) {
3795
        {
-
 
3796
          nb_count++;
3518
            nb_count++;
3797
          nb_tmp[nb_count - 1] = bond[i].a2;
3519
            nb_tmp[nb_count - 1] = bond[i].a2;
3798
        }
3520
          }
3799
      if (bond[i].a2 == id && bond[i].a1 != prev_id &&
3521
    if (bond[i].a2 == id && bond[i].a1 != prev_id &&
3800
          nb_count < max_neighbors && atom[bond[i].a1 - 1].heavy)
3522
              nb_count < max_neighbors && atom[bond[i].a1 - 1].heavy) {
3801
        {
-
 
3802
          nb_count++;
3523
            nb_count++;
3803
          nb_tmp[nb_count - 1] = bond[i].a1;
3524
            nb_tmp[nb_count - 1] = bond[i].a1;
3804
        }
3525
          }
3805
    }
3526
  }
3806
  return memcpy (Result, nb_tmp, sizeof (neighbor_rec));
3527
  return memcpy (Result, nb_tmp, sizeof (neighbor_rec));
3807
}
3528
}
3808
 
-
 
3809
 
3529
 
3810
static int *
-
 
3811
get_ndl_nextneighbors (int *Result, int id, int prev_id)
3530
static int * get_ndl_nextneighbors (int *Result, int id, int prev_id)
3812
{
3531
{
3813
  int i;
3532
  int i;
3814
  neighbor_rec nb_tmp;
3533
  neighbor_rec nb_tmp;
3815
  int nb_count = 0;
3534
  int nb_count = 0;
3816
  int FORLIM;
3535
  int FORLIM;
3817
 
3536
 
3818
  /* gets all neighbors except prev_id (usually the atom where we came from */
3537
  /* gets all neighbors except prev_id (usually the atom where we came from */
3819
  memset (nb_tmp, 0, sizeof (neighbor_rec));
3538
  memset (nb_tmp, 0, sizeof (neighbor_rec));
3820
  FORLIM = ndl_n_bonds;
3539
  FORLIM = ndl_n_bonds;
3821
  for (i = 0; i < FORLIM; i++)
3540
  for (i = 0; i < FORLIM; i++) {
3822
    {
-
 
3823
      if (ndl_bond[i].a1 == id && ndl_bond[i].a2 != prev_id &&
3541
    if (ndl_bond[i].a1 == id && ndl_bond[i].a2 != prev_id &&
3824
          nb_count < max_neighbors && ndl_atom[ndl_bond[i].a2 - 1].heavy)
3542
              nb_count < max_neighbors && ndl_atom[ndl_bond[i].a2 - 1].heavy) {
3825
        {
-
 
3826
          nb_count++;
3543
            nb_count++;
3827
          nb_tmp[nb_count - 1] = ndl_bond[i].a2;
3544
            nb_tmp[nb_count - 1] = ndl_bond[i].a2;
3828
        }
3545
          }
3829
      if (ndl_bond[i].a2 == id && ndl_bond[i].a1 != prev_id &&
3546
    if (ndl_bond[i].a2 == id && ndl_bond[i].a1 != prev_id &&
3830
          nb_count < max_neighbors && ndl_atom[ndl_bond[i].a1 - 1].heavy)
3547
              nb_count < max_neighbors && ndl_atom[ndl_bond[i].a1 - 1].heavy) {
3831
        {
-
 
3832
          nb_count++;
3548
            nb_count++;
3833
          nb_tmp[nb_count - 1] = ndl_bond[i].a1;
3549
            nb_tmp[nb_count - 1] = ndl_bond[i].a1;
3834
        }
3550
          }
3835
    }
3551
  }
3836
  return memcpy (Result, nb_tmp, sizeof (neighbor_rec));
3552
  return memcpy (Result, nb_tmp, sizeof (neighbor_rec));
3837
}
3553
}
3838
 
3554
 
3839
#if 0
3555
#if 0
3840
static int path_pos (id, a_path) int id;
3556
static int path_pos (id, a_path) int id;
3841
     int *a_path;
3557
  int *a_path;
3842
     {
3558
  {
3843
     /* new version in v0.3l */
3559
  /* new version in v0.3l */
3844
     int i;
3560
  int i;
3845
     int pp = 0;
3561
  int pp = 0;
3846
 
3562
 
3847
     for (i = 1; i <= max_ringsize; i++)
3563
  for (i = 1; i <= max_ringsize; i++)
3848
     {
3564
  {
3849
     if (a_path[i - 1] == id)
3565
  if (a_path[i - 1] == id)
3850
     {
3566
  {
3851
     pp = i;
3567
  pp = i;
3852
     /* p2c: checkmol.pas, line 2620:
3568
  /* p2c: checkmol.pas, line 2620:
3853
     * Warning: Expected a '(', found a semicolon [227]  */
3569
  * Warning: Expected a '(', found a semicolon [227]  */
3854
     /* p2c: checkmol.pas, line 2620:
3570
  /* p2c: checkmol.pas, line 2620:
3855
     * Warning: Expected an expression, found a semicolon [227] */
3571
  * Warning: Expected an expression, found a semicolon [227] */
3856
     fflush (0);
3572
  fflush (0);
3857
     P_ioresult = 0;
3573
  P_ioresult = 0;
3858
     }
3574
  }
3859
     }
3575
  }
3860
     return pp;
3576
  return pp;
3861
     }
3577
  }
3862
#endif
3578
#endif
3863
 
3579
 
3864
static int
-
 
3865
matchpath_pos (int id, int *a_path)
3580
static int matchpath_pos (int id, int *a_path)
3866
{
3581
{
3867
  int i;
3582
  int i;
3868
  int pp = 0;
3583
  int pp = 0;
3869
 
3584
 
3870
  for (i = max_matchpath_length; i >= 1; i--)
3585
  for (i = max_matchpath_length; i >= 1; i--) {
3871
    {
-
 
3872
      if (a_path[i - 1] == id)
3586
    if (a_path[i - 1] == id)
3873
        pp = i;
3587
            pp = i;
3874
    }
3588
  }
3875
  return pp;
3589
  return pp;
3876
}
3590
}
3877
 
3591
 
3878
 
-
 
3879
static int
-
 
3880
matchpath_length (int *a_path)
3592
static int matchpath_length (int *a_path)
3881
{
3593
{
3882
  if (a_path[max_matchpath_length - 1] != 0)
3594
  if (a_path[max_matchpath_length - 1] != 0)
3883
    return max_matchpath_length;
3595
    return max_matchpath_length;
3884
  else
3596
  else
3885
    return (matchpath_pos (0L, a_path) - 1);
3597
    return (matchpath_pos (0L, a_path) - 1);
3886
}
3598
}
3887
 
3599
 
3888
static int
-
 
3889
get_ndl_bond (int ba1, int ba2)
3600
static int get_ndl_bond (int ba1, int ba2)
3890
{
3601
{
3891
  int i;
3602
  int i;
3892
  int b_id = 0;
3603
  int b_id = 0;
3893
  int FORLIM;
3604
  int FORLIM;
3894
 
3605
 
3895
  if (ndl_n_bonds <= 0)
3606
  if (ndl_n_bonds <= 0)
3896
    return b_id;
3607
    return b_id;
3897
  FORLIM = ndl_n_bonds;
3608
  FORLIM = ndl_n_bonds;
3898
  for (i = 1; i <= FORLIM; i++)
3609
  for (i = 1; i <= FORLIM; i++) {
3899
    {
-
 
3900
      if ((ndl_bond[i - 1].a1 == ba1 && ndl_bond[i - 1].a2 == ba2) ||
3610
    if ((ndl_bond[i - 1].a1 == ba1 && ndl_bond[i - 1].a2 == ba2) ||
3901
          (ndl_bond[i - 1].a1 == ba2 && ndl_bond[i - 1].a2 == ba1))
3611
              (ndl_bond[i - 1].a1 == ba2 && ndl_bond[i - 1].a2 == ba1))
3902
        b_id = i;
3612
          b_id = i;
3903
    }
3613
  }
3904
  return b_id;
3614
  return b_id;
3905
}
3615
}
3906
 
3616
 
3907
static int
-
 
3908
ringcompare (int *rp1, int *rp2)
3617
static int ringcompare (int *rp1, int *rp2)
3909
{
3618
{
3910
  int i, j;
3619
  int i, j;
3911
  int rc = 0;
3620
  int rc = 0;
3912
  int rs1, rs2;
3621
  int rs1, rs2;
3913
  int n_common = 0;
3622
  int n_common = 0;
Line 3917... Line 3626...
3917
  rs2 = path_length (rp2);
3626
  rs2 = path_length (rp2);
3918
  if (rs1 < rs2)
3627
  if (rs1 < rs2)
3919
    max_cra = rs1;
3628
    max_cra = rs1;
3920
  else
3629
  else
3921
    max_cra = rs2;
3630
    max_cra = rs2;
3922
  for (i = 0; i < rs1; i++)
3631
  for (i = 0; i < rs1; i++) {
3923
    {
-
 
3924
      for (j = 0; j < rs2; j++)
3632
    for (j = 0; j < rs2; j++) {
3925
        {
-
 
3926
          if (rp1[i] == rp2[j])
3633
            if (rp1[i] == rp2[j])
3927
            n_common++;
3634
              n_common++;
3928
        }
3635
          }
3929
    }
3636
  }
3930
  if (rs1 == rs2 && n_common == max_cra)
3637
  if (rs1 == rs2 && n_common == max_cra) {
3931
    {
-
 
3932
      rc = 0;
3638
    rc = 0;
3933
      return rc;
3639
    return rc;
3934
    }
3640
  }
3935
  if (n_common == 0)
3641
  if (n_common == 0)
3936
    rc += 8;
3642
    rc += 8;
3937
  if (n_common < max_cra)
3643
  if (n_common < max_cra) {
3938
    {
-
 
3939
      rc += 4;
3644
    rc += 4;
3940
      return rc;
3645
    return rc;
3941
    }
3646
  }
3942
  if (rs1 < rs2)
3647
  if (rs1 < rs2)
3943
    rc++;
3648
    rc++;
3944
  else
3649
  else
3945
    rc += 2;
3650
    rc += 2;
3946
  return rc;
3651
  return rc;
3947
}
3652
}
3948
 
-
 
3949
 
3653
 
3950
static boolean
-
 
3951
rc_identical (int rc_int)
3654
static boolean rc_identical (int rc_int)
3952
{
3655
{
3953
  if (rc_int == 0)
3656
  if (rc_int == 0)
3954
    return true;
3657
    return true;
3955
  else
3658
  else
3956
    return false;
3659
    return false;
3957
}
3660
}
3958
 
3661
 
-
 
3662
static boolean rc_1in2 (int rc_int)
-
 
3663
{
-
 
3664
  if (rc_int & 1)
-
 
3665
    return true;
-
 
3666
  else
-
 
3667
    return false;
-
 
3668
}
3959
 
3669
 
3960
static boolean
-
 
3961
rc_1in2 (int rc_int)
-
 
3962
{
-
 
3963
  if (rc_int & 1)
-
 
3964
    return true;
-
 
3965
  else
-
 
3966
    return false;
-
 
3967
}
-
 
3968
 
-
 
3969
 
-
 
3970
static boolean
-
 
3971
rc_2in1 (int rc_int)
3670
static boolean rc_2in1 (int rc_int)
3972
{
3671
{
3973
  rc_int /= 2;
3672
  rc_int /= 2;
3974
  if (rc_int & 1)
3673
  if (rc_int & 1)
3975
    return true;
3674
    return true;
3976
  else
3675
  else
3977
    return false;
3676
    return false;
3978
}
3677
}
3979
 
-
 
3980
 
3678
 
3981
#if 0
3679
#if 0
3982
static boolean
-
 
3983
rc_different (int rc_int)
3680
static boolean rc_different (int rc_int)
3984
{
3681
{
3985
  rc_int /= 4;
3682
  rc_int /= 4;
3986
  if (rc_int & 1)
3683
  if (rc_int & 1)
3987
    return true;
3684
    return true;
3988
  else
3685
  else
3989
    return false;
3686
    return false;
3990
}
3687
}
3991
#endif
3688
#endif
3992
#if 0
3689
#if 0
3993
static boolean
-
 
3994
rc_independent (int rc_int)
3690
static boolean rc_independent (int rc_int)
3995
{
3691
{
3996
  rc_int /= 8;
3692
  rc_int /= 8;
3997
  if (rc_int & 1)
3693
  if (rc_int & 1)
3998
    return true;
3694
    return true;
3999
  else
3695
  else
4000
    return false;
3696
    return false;
4001
}
3697
}
4002
#endif
3698
#endif
4003
 
3699
 
4004
static boolean
-
 
4005
is_newring (int *n_path)
3700
static boolean is_newring (int *n_path)
4006
{
3701
{
4007
  int i, j;
3702
  int i, j;
4008
  boolean nr = true;
3703
  boolean nr = true;
4009
  boolean same_ring;
3704
  boolean same_ring;
4010
  ringpath_type tmp_path;
3705
  ringpath_type tmp_path;
Line 4014... Line 3709...
4014
  int FORLIM;
3709
  int FORLIM;
4015
 
3710
 
4016
  pl = path_length (n_path);    /* new in v0.3 */
3711
  pl = path_length (n_path);    /* new in v0.3 */
4017
  if (n_rings <= 0)
3712
  if (n_rings <= 0)
4018
    return true;
3713
    return true;
4019
  switch (ringsearch_mode)
3714
  switch (ringsearch_mode) {
4020
    {
-
 
4021
 
-
 
4022
    case rs_sar:
3715
    case rs_sar:
4023
      found_ring = false;
3716
      found_ring = false;
4024
      i = 0;
3717
      i = 0;
4025
      while (i < n_rings && !found_ring)
3718
      while (i < n_rings && !found_ring) {
4026
        {
-
 
4027
          i++;
3719
              i++;
4028
          if (pl != ringprop[i - 1].size)       /* compare only rings of same size */
3720
              if (pl != ringprop[i - 1].size)   /* compare only rings of same size */
4029
            continue;
3721
                continue;
4030
          same_ring = true;
3722
              same_ring = true;
4031
          for (j = 0; j < max_ringsize; j++)
3723
              for (j = 0; j < max_ringsize; j++) {
4032
            {
-
 
4033
              if (ring[i - 1][j] != n_path[j])
3724
                if (ring[i - 1][j] != n_path[j])
4034
                same_ring = false;
3725
                        same_ring = false;
4035
            }
3726
              }
4036
          if (same_ring)
3727
              if (same_ring) {
4037
            {
-
 
4038
              nr = false;
3728
                nr = false;
4039
              found_ring = true;
3729
                found_ring = true;
4040
            }
3730
              }
4041
        }
3731
            }
4042
      break;
3732
      break;
4043
 
3733
 
4044
    case rs_ssr:
3734
    case rs_ssr:
4045
      FORLIM = n_rings;
3735
      FORLIM = n_rings;
4046
      for (i = 0; i < FORLIM; i++)
3736
      for (i = 0; i < FORLIM; i++) {
4047
        {
-
 
4048
          for (j = 0; j < max_ringsize; j++)
3737
              for (j = 0; j < max_ringsize; j++)
4049
            tmp_path[j] = ring[i][j];
3738
                tmp_path[j] = ring[i][j];
4050
          rc_result = ringcompare (n_path, tmp_path);
3739
              rc_result = ringcompare (n_path, tmp_path);
4051
          if (rc_identical (rc_result))
3740
              if (rc_identical (rc_result))
4052
            nr = false;
3741
                nr = false;
4053
          if (rc_1in2 (rc_result))
3742
              if (rc_1in2 (rc_result)) {
4054
            {
-
 
4055
              /* exchange existing ring by smaller one */
3743
              /* exchange existing ring by smaller one */
4056
              for (j = 0; j < max_ringsize; j++)
3744
                for (j = 0; j < max_ringsize; j++)
4057
                ring[i][j] = n_path[j];
3745
                        ring[i][j] = n_path[j];
4058
              /* update ring property record (new in v0.3) */
3746
                /* update ring property record (new in v0.3) */
4059
              ringprop[i].size = pl;
3747
                ringprop[i].size = pl;
4060
              nr = false;
3748
                nr = false;
4061
/* p2c: checkmol.pas, line 2841:
3749
        /* p2c: checkmol.pas, line 2841:
4062
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
3750
        * Note: Turbo Pascal conditional compilation directive was ignored [218] */
4063
              /*$IFDEF debug */
3751
              /*$IFDEF debug */
4064
              /* debugoutput('replacing ring '+inttostr(i)+' by smaller one (ringsize: '+inttostr(path_length(n_path))+')'); */
3752
              /* debugoutput('replacing ring '+inttostr(i)+' by smaller one (ringsize: '+inttostr(path_length(n_path))+')'); */
4065
              /*$ENDIF */
3753
              /*$ENDIF */
4066
            }
3754
        }
4067
          if (rc_2in1 (rc_result))
3755
        if (rc_2in1 (rc_result)) {
4068
            {
-
 
4069
              /* new ring contains existing one, but is larger ==> discard */
3756
                  /* new ring contains existing one, but is larger ==> discard */
4070
              nr = false;
3757
                nr = false;
-
 
3758
              }
4071
            }
3759
            }
4072
        }
-
 
4073
      break;
3760
    break;
4074
    }
3761
  }
4075
  return nr;
3762
  return nr;
4076
}
3763
}
4077
 
3764
 
4078
 
-
 
4079
static void
-
 
4080
add_ring (int *n_path)
3765
static void add_ring (int *n_path)
4081
{
3766
{
4082
  /* new in v0.3: store rings in an ordered way (with ascending ring size) */
3767
  /* new in v0.3: store rings in an ordered way (with ascending ring size) */
4083
  int i;
3768
  int i;
4084
  int j = 0;
3769
  int j = 0;
4085
  int k, s, pl;
3770
  int k, s, pl;
4086
/* p2c: checkmol.pas, line 2862:
3771
  /* p2c: checkmol.pas, line 2862:
4087
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
3772
  * Note: Turbo Pascal conditional compilation directive was ignored [218] */
4088
  /*$IFDEF debug */
3773
  /*$IFDEF debug */
4089
  /*char dstr[256];*/
3774
  /*char dstr[256];*/
4090
  int FORLIM;
3775
  int FORLIM;
4091
 
3776
 
4092
  /*$ENDIF */
3777
  /*$ENDIF */
4093
  pl = path_length (n_path);
3778
  pl = path_length (n_path);
4094
 
3779
 
4095
  if (pl < 1)
3780
  if (pl < 1)
4096
    return;
3781
    return;
4097
 
3782
 
4098
  if (n_rings >= max_rings)
3783
  if (n_rings >= max_rings) {
4099
    {
-
 
4100
 
-
 
4101
/* p2c: checkmol.pas, line 2906:
3784
    /* p2c: checkmol.pas, line 2906:
4102
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
3785
     * Note: Turbo Pascal conditional compilation directive was ignored [218] */
4103
      /*$IFDEF debug
3786
          /*$IFDEF debug
4104
         debugoutput ("max_rings exceeded!");
3787
             debugoutput ("max_rings exceeded!");
4105
         $ENDIF */
3788
             $ENDIF */
4106
      return;
3789
    return;
4107
    }
3790
  }
4108
  n_rings++;
3791
  n_rings++;
4109
 
3792
 
4110
/* p2c: checkmol.pas, line 2871:
3793
  /* p2c: checkmol.pas, line 2871:
4111
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
3794
   * Note: Turbo Pascal conditional compilation directive was ignored [218] */
4112
  /*$IFDEF debug */
3795
    /*$IFDEF debug */
4113
  /* dstr := '';
3796
    /* dstr := '';
4114
     for j := 1 to pl do dstr := dstr + inttostr((n_path[j])) + ' ';
3797
       for j := 1 to pl do dstr := dstr + inttostr((n_path[j])) + ' ';
4115
     debugoutput('adding ring '+inttostr(n_rings)+':  '+dstr); */
3798
       debugoutput('adding ring '+inttostr(n_rings)+':  '+dstr); */
4116
  /*$ENDIF */
3799
    /*$ENDIF */
4117
  if (n_rings > 1)
3800
  if (n_rings > 1) {
4118
    {
-
 
4119
      FORLIM = n_rings;
3801
    FORLIM = n_rings;
4120
      for (i = 1; i < FORLIM; i++)
3802
    for (i = 1; i < FORLIM; i++) {
4121
        {
-
 
4122
          s = ringprop[i - 1].size;
3803
            s = ringprop[i - 1].size;
4123
          if (pl >= s)
3804
            if (pl >= s)
4124
            j = i;
3805
              j = i;
4125
        }
3806
          }
4126
    }
3807
  }
4127
  j++;                          /* the next position is ours */
3808
  j++;                          /* the next position is ours */
4128
  if (j < n_rings)
-
 
4129
    {                           /* push up the remaining rings by one position */
3809
  if (j < n_rings) {                            /* push up the remaining rings by one position */
4130
      for (k = n_rings; k > j; k--)
3810
    for (k = n_rings; k > j; k--) {
4131
        {
-
 
4132
          ringprop[k - 1].size = ringprop[k - 2].size;
3811
            ringprop[k - 1].size = ringprop[k - 2].size;
4133
          /*ringprop^[k].arom := ringprop^[(k-1)].arom; */
3812
            /*ringprop^[k].arom := ringprop^[(k-1)].arom; */
4134
          for (i = 0; i < max_ringsize; i++)
3813
            for (i = 0; i < max_ringsize; i++)
4135
            ring[k - 1][i] = ring[k - 2][i];
3814
              ring[k - 1][i] = ring[k - 2][i];
4136
        }
3815
          }
4137
    }
3816
  }
4138
  ringprop[j - 1].size = pl;
3817
  ringprop[j - 1].size = pl;
4139
  for (i = 0; i < max_ringsize; i++)
3818
  for (i = 0; i < max_ringsize; i++) {
4140
    {
-
 
4141
      ring[j - 1][i] = n_path[i];
3819
    ring[j - 1][i] = n_path[i];
4142
      /*inc(atom^[(n_path[i])].ring_count); */
3820
    /*inc(atom^[(n_path[i])].ring_count); */
4143
    }
3821
  }
4144
}
3822
}
4145
 
-
 
4146
 
3823
 
4147
#if 0
3824
#if 0
4148
 static boolean is_ringpath (s_path) int *s_path;
3825
static boolean is_ringpath (s_path) int *s_path;
4149
     {
3826
   {
4150
     boolean Result;
3827
   boolean Result;
4151
     int i, j;
3828
   int i, j;
4152
     neighbor_rec nb;
3829
   neighbor_rec nb;
4153
     boolean rp = false;
3830
   boolean rp = false;
4154
     boolean new_atom;
3831
   boolean new_atom;
4155
     int a_last, pl;
3832
   int a_last, pl;
4156
     ringpath_type l_path;
3833
   ringpath_type l_path;
4157
     int FORLIM;
3834
   int FORLIM;
4158
 
3835
 
4159
     /* p2c: checkmol.pas: Note: Eliminated unused assignment statement [338] */
3836
   /* p2c: checkmol.pas: Note: Eliminated unused assignment statement [338] */
4160
     memset (nb, 0, sizeof (neighbor_rec));
3837
   memset (nb, 0, sizeof (neighbor_rec));
4161
     memset (l_path, 0, sizeof (ringpath_type));
3838
   memset (l_path, 0, sizeof (ringpath_type));
4162
     pl = path_length (s_path);
3839
   pl = path_length (s_path);
4163
     if (pl < 1)
3840
   if (pl < 1) {
4164
     {
-
 
4165
     /* p2c: checkmol.pas, line 2928:
3841
   /* p2c: checkmol.pas, line 2928:
4166
     * Note: Turbo Pascal conditional compilation directive was ignored [218] */
3842
     * Note: Turbo Pascal conditional compilation directive was ignored [218] */
4167
     /*$IFDEF debug
3843
     /*$IFDEF debug
4168
     debugoutput ("Oops! Got zero-length s_path!");
3844
     debugoutput ("Oops! Got zero-length s_path!");
4169
     $ENDIF */
3845
     $ENDIF */
4170
     return Result;
3846
     return Result;
4171
     }
3847
    }
4172
     for (i = 0; i < pl; i++)
3848
    for (i = 0; i < pl; i++)
4173
     l_path[i] = s_path[i];
3849
      l_path[i] = s_path[i];
4174
     /* check if the last atom is a metal and stop if opt_metalrings is not set (v0.3) */
3850
    /* check if the last atom is a metal and stop if opt_metalrings is not set (v0.3) */
4175
     if (opt_metalrings == false)
3851
    if (opt_metalrings == false) {
4176
     {
-
 
4177
     if (atom[l_path[pl - 1] - 1].metal)
3852
      if (atom[l_path[pl - 1] - 1].metal){
4178
     {
-
 
4179
     /* p2c: checkmol.pas, line 2942:
3853
        /* p2c: checkmol.pas, line 2942:
4180
     * Note: Turbo Pascal conditional compilation directive was ignored [218] */
3854
        * Note: Turbo Pascal conditional compilation directive was ignored [218] */
4181
     /*$IFDEF debug
3855
        /*$IFDEF debug
4182
     debugoutput ("skipping metal in ring search");
3856
        debugoutput ("skipping metal in ring search");
4183
     $ENDIF */
3857
         $ENDIF */
4184
     return false;
3858
        return false;
4185
     }
3859
      }
4186
     }
3860
    }
4187
     /* check if ring is already closed */
3861
    /* check if ring is already closed */
4188
     if (pl > 2 && l_path[pl - 1] == l_path[0])
3862
    if (pl > 2 && l_path[pl - 1] == l_path[0]) {
4189
     {
-
 
4190
     l_path[pl - 1] = 0;        /* remove last entry (redundant!) */
3863
    l_path[pl - 1] = 0;        /* remove last entry (redundant!) */
4191
     order_ringpath (l_path);
3864
    order_ringpath (l_path);
4192
     if (is_newring (l_path))
3865
    if (is_newring (l_path)) {
4193
     {
-
 
4194
     if (n_rings >= max_rings)
3866
      if (n_rings >= max_rings) {
4195
     {
-
 
4196
     /* p2c: checkmol.pas, line 2958:
3867
        /* p2c: checkmol.pas, line 2958:
4197
     * Note: Turbo Pascal conditional compilation directive was ignored [218] */
3868
        * Note: Turbo Pascal conditional compilation directive was ignored [218] */
4198
     /*$IFDEF debug
3869
        /*$IFDEF debug
4199
     debugoutput ("maximum number of rings exceeded!");
3870
        debugoutput ("maximum number of rings exceeded!");
4200
     $ENDIF */
3871
        $ENDIF */
4201
     return false;
3872
        return false;
4202
     }
3873
      }
4203
     add_ring (l_path);
3874
      add_ring (l_path);
4204
     }
3875
    }
4205
     /* p2c: checkmol.pas: Note: Eliminated unused assignment statement [338] */
3876
    /* p2c: checkmol.pas: Note: Eliminated unused assignment statement [338] */
4206
     return true;
3877
    return true;
4207
     }
3878
  }
4208
     /* any other case: ring is not (yet) closed */
3879
  /* any other case: ring is not (yet) closed */
4209
     a_last = l_path[pl - 1];
3880
  a_last = l_path[pl - 1];
4210
     get_neighbors (nb, a_last);
3881
  get_neighbors (nb, a_last);
4211
     if (atom[a_last - 1].neighbor_count <= 1)
3882
  if (atom[a_last - 1].neighbor_count <= 1)
4212
     return false;
3883
    return false;
4213
     if (n_rings >= max_rings)
3884
  if (n_rings >= max_rings)
4214
     /* added in v0.2: check if max_rings is reached **/
3885
    /* added in v0.2: check if max_rings is reached **/
4215
     {                          /* if ring is not closed, continue searching */
3886
  {                          /* if ring is not closed, continue searching */
4216
     return false;
3887
    return false;
4217
     }
3888
  }
4218
     FORLIM = atom[a_last - 1].neighbor_count;
3889
  FORLIM = atom[a_last - 1].neighbor_count;
4219
     for (i = 0; i < FORLIM; i++)
3890
  for (i = 0; i < FORLIM; i++) {
4220
     {
-
 
4221
     new_atom = true;
3891
    new_atom = true;
4222
     for (j = 1; j < pl; j++)
3892
     for (j = 1; j < pl; j++) {
4223
     {
-
 
4224
     if (nb[i] == l_path[j])
-
 
4225
     {                    /* v0.3k */
3893
      if (nb[i] == l_path[j]) {                    /* v0.3k */
4226
     new_atom = false;
3894
       new_atom = false;
4227
     /* p2c: checkmol.pas, line 2982:
3895
       /* p2c: checkmol.pas, line 2982:
4228
     * Warning: Expected a '(', found a semicolon [227] */
3896
       * Warning: Expected a '(', found a semicolon [227] */
4229
     /* p2c: checkmol.pas, line 2982:
3897
       /* p2c: checkmol.pas, line 2982:
4230
     * Warning: Expected an expression, found a semicolon [227] */
3898
       * Warning: Expected an expression, found a semicolon [227] */
4231
     fflush (0);
3899
       fflush (0);
4232
     P_ioresult = 0;      /* v0.3k */
3900
       P_ioresult = 0;      /* v0.3k */
4233
     }
3901
      }
4234
     }
3902
    }
4235
     /* added in v0.1a: check if max_rings not yet reached */
3903
    /* added in v0.1a: check if max_rings not yet reached */
4236
     /* added in v0.2:  limit ring size to max_vringsize instead of max_ringsize */
3904
    /* added in v0.2:  limit ring size to max_vringsize instead of max_ringsize */
4237
     if (new_atom && pl < max_vringsize && n_rings < max_rings)
3905
    if (new_atom && pl < max_vringsize && n_rings < max_rings) {
4238
     {
-
 
4239
     l_path[pl] = nb[i];
3906
      l_path[pl] = nb[i];
4240
     if (pl < max_ringsize - 1)   /* just to be sure */
3907
      if (pl < max_ringsize - 1)   /* just to be sure */
4241
     l_path[pl + 1] = 0;
3908
      l_path[pl + 1] = 0;
4242
     if (is_ringpath (l_path))
3909
      if (is_ringpath (l_path))
4243
     rp = true;
3910
       rp = true;
4244
     }
3911
    }
4245
     }
3912
  }
4246
     return rp;
3913
  return rp;
4247
     }
3914
}
4248
#endif
3915
#endif
4249
 
3916
 
4250
static boolean
-
 
4251
is_ringpath (int *s_path)
3917
static boolean is_ringpath (int *s_path)
4252
{
3918
{
4253
  int i, j;
3919
  int i, j;
4254
  neighbor_rec nb;
3920
  neighbor_rec nb;
4255
  boolean rp = false;
3921
  boolean rp = false;
4256
  boolean new_atom;
3922
  boolean new_atom;
Line 4260... Line 3926...
4260
 
3926
 
4261
/* p2c: checkmol.pas: Note: Eliminated unused assignment statement [338] */
3927
/* p2c: checkmol.pas: Note: Eliminated unused assignment statement [338] */
4262
  memset ((void *) nb, 0, sizeof (neighbor_rec));
3928
  memset ((void *) nb, 0, sizeof (neighbor_rec));
4263
  memset ((void *) l_path, 0, sizeof (ringpath_type));
3929
  memset ((void *) l_path, 0, sizeof (ringpath_type));
4264
  pl = path_length (s_path);
3930
  pl = path_length (s_path);
4265
  if (pl < 1)
3931
  if (pl < 1) {
4266
    {
-
 
4267
/* p2c: checkmol.pas, line 2524:
3932
    /* p2c: checkmol.pas, line 2524:
4268
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
3933
    * Note: Turbo Pascal conditional compilation directive was ignored [218] */
4269
 
3934
 
4270
      return false;
3935
      return false;
4271
    }
3936
    }
4272
 
3937
 
4273
  pl_prev = pl - 1;
3938
  pl_prev = pl - 1;
4274
  //memcpy (l_path, s_path, sizeof (ringpath_type));
3939
  //memcpy (l_path, s_path, sizeof (ringpath_type));
4275
  memcpy (l_path, s_path, pl * sizeof (int));
3940
  memcpy (l_path, s_path, pl * sizeof (int));
4276
 
3941
 
4277
  /* check if the last atom is a metal and stop if opt_metalrings is not set (v0.3) */
3942
  /* check if the last atom is a metal and stop if opt_metalrings is not set (v0.3) */
4278
  if (opt_metalrings == false)
3943
  if (opt_metalrings == false) {
4279
    {
-
 
4280
      if (atom[l_path[pl_prev] - 1].metal)
3944
    if (atom[l_path[pl_prev] - 1].metal) {
4281
        {
-
 
4282
/* p2c: checkmol.pas, line 2538:
3945
    /* p2c: checkmol.pas, line 2538:
4283
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
3946
     * Note: Turbo Pascal conditional compilation directive was ignored [218] */
4284
          return false;
3947
          return false;
4285
        }
3948
          }
4286
    }
3949
  }
4287
  /* check if ring is already closed */
3950
  /* check if ring is already closed */
4288
  if (pl > 2 && l_path[pl_prev] == l_path[0])
3951
  if (pl > 2 && l_path[pl_prev] == l_path[0]) {
4289
    {
-
 
4290
      l_path[pl_prev] = 0;      /* remove last entry (redundant!) */
3952
    l_path[pl_prev] = 0;        /* remove last entry (redundant!) */
4291
      order_ringpath (l_path);
3953
    order_ringpath (l_path);
4292
      if (is_newring (l_path))
3954
    if (is_newring (l_path)) {
4293
        {
-
 
4294
          if (n_rings >= max_rings)
3955
            if (n_rings >= max_rings) {
4295
            {
-
 
4296
/* p2c: checkmol.pas, line 2554:
3956
        /* p2c: checkmol.pas, line 2554:
4297
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
3957
        * Note: Turbo Pascal conditional compilation directive was ignored [218] */
4298
 
-
 
4299
              return false;
3958
              return false;
4300
            }
3959
            }
4301
          add_ring (l_path);
3960
            add_ring (l_path);
4302
        }
3961
          }
4303
/* p2c: checkmol.pas: Note: Eliminated unused assignment statement [338] */
3962
    /* p2c: checkmol.pas: Note: Eliminated unused assignment statement [338] */
4304
      return true;
3963
      return true;
4305
    }
3964
  }
4306
  /* any other case: ring is not (yet) closed */
3965
  /* any other case: ring is not (yet) closed */
4307
  a_last = l_path[pl_prev];
3966
  a_last = l_path[pl_prev];
4308
  get_neighbors (nb, a_last);
3967
  get_neighbors (nb, a_last);
4309
  if (atom[a_last - 1].neighbor_count <= 1)
3968
  if (atom[a_last - 1].neighbor_count <= 1)
4310
    return false;
3969
    return false;
4311
  if (n_rings >= max_rings)
3970
  if (n_rings >= max_rings)
4312
    /* added in v0.2: check if max_rings is reached */
-
 
4313
    {                           /* if ring is not closed, continue searching */
3971
    /* added in v0.2: check if max_rings is reached */ {                                /* if ring is not closed, continue searching */
4314
      return false;
3972
    return false;
4315
    }
3973
  }
4316
  FORLIM = atom[a_last - 1].neighbor_count;
3974
  FORLIM = atom[a_last - 1].neighbor_count;
4317
  pl_next = pl + 1;
3975
  pl_next = pl + 1;
4318
  max_ringsize_dec = max_ringsize - 1;
3976
  max_ringsize_dec = max_ringsize - 1;
4319
  for (i = 0; i < FORLIM; i++)
3977
  for (i = 0; i < FORLIM; i++) {
4320
    {
-
 
4321
      new_atom = true;
3978
    new_atom = true;
4322
      for (j = 1; j < pl; j++)
3979
    for (j = 1; j < pl; j++) {
4323
        {
-
 
4324
          if (nb[i] == l_path[j])
3980
            if (nb[i] == l_path[j]) {
4325
            {
-
 
4326
              new_atom = false;
3981
              new_atom = false;
4327
              break;
3982
              break;
4328
            }
3983
            }
4329
        }
3984
          }
4330
      /* added in v0.1a: check if max_rings not yet reached */
3985
    /* added in v0.1a: check if max_rings not yet reached */
4331
      /* added in v0.2:  limit ring size to max_vringsize instead of max_ringsize */
3986
    /* added in v0.2:  limit ring size to max_vringsize instead of max_ringsize */
4332
      if (new_atom && pl < max_vringsize && n_rings < max_rings)
3987
    if (new_atom && pl < max_vringsize && n_rings < max_rings) {
4333
        {
-
 
4334
          l_path[pl] = nb[i];
3988
            l_path[pl] = nb[i];
4335
          if (pl < max_ringsize_dec)    /* just to be sure */
3989
            if (pl < max_ringsize_dec)  /* just to be sure */
4336
            l_path[pl_next] = 0;
3990
              l_path[pl_next] = 0;
4337
 
3991
 
4338
          if (max_ringpath_recursion_depth != 0
3992
            if (max_ringpath_recursion_depth != 0
4339
              && ++recursion_depth > max_ringpath_recursion_depth)
3993
                && ++recursion_depth > max_ringpath_recursion_depth) {
4340
            {
-
 
4341
#ifndef MAKE_SHARED_LIBRARY
3994
#ifndef MAKE_SHARED_LIBRARY
4342
              if (opt_verbose)
3995
              if (opt_verbose)
4343
#endif
3996
#endif
4344
                printf
-
 
4345
                  ("Warning: max. number of ringpath recursions (%i) reached\n",
3997
                    printf ("Warning: max. number of ringpath recursions (%i) reached\n",
4346
                   max_ringpath_recursion_depth);
3998
                    max_ringpath_recursion_depth);
4347
              n_rings = max_rings;
3999
              n_rings = max_rings;
4348
              return false;
4000
              return false;
4349
            }
4001
            }
4350
 
4002
 
4351
          /*printf("%i\n",recursion_depth);
4003
            /*printf("%i\n",recursion_depth);
4352
          fflush(stdout);*/
4004
            fflush(stdout);*/
4353
 
4005
 
4354
          if (is_ringpath (l_path))
4006
            if (is_ringpath (l_path))
4355
            rp = true;
4007
              rp = true;
4356
          /*return true;*/
4008
            /*return true;*/
4357
        }
4009
          }
4358
    }
4010
  }
4359
  return rp;
4011
  return rp;
4360
}
4012
}
4361
 
4013
 
4362
static boolean
-
 
4363
is_ringbond (int b_id)
4014
static boolean is_ringbond (int b_id)
4364
{
4015
{
4365
  int i, ra1, ra2;
4016
  int i, ra1, ra2;
4366
  neighbor_rec nb;
4017
  neighbor_rec nb;
4367
  ringpath_type search_path;
4018
  ringpath_type search_path;
4368
  boolean rb = false;
4019
  boolean rb = false;
Line 4378... Line 4029...
4378
  if (atom[ra2 - 1].neighbor_count <= 1 || atom[ra1 - 1].neighbor_count <= 1)
4029
  if (atom[ra2 - 1].neighbor_count <= 1 || atom[ra1 - 1].neighbor_count <= 1)
4379
    return false;
4030
    return false;
4380
  search_path[0] = ra1;
4031
  search_path[0] = ra1;
4381
  search_path[1] = ra2;
4032
  search_path[1] = ra2;
4382
  FORLIM = atom[ra2 - 1].neighbor_count;
4033
  FORLIM = atom[ra2 - 1].neighbor_count;
4383
  for (i = 0; i < FORLIM; i++)
4034
  for (i = 0; i < FORLIM; i++) {
4384
    {
-
 
4385
      if (nb[i] != ra1 && atom[nb[i] - 1].heavy)
4035
    if (nb[i] != ra1 && atom[nb[i] - 1].heavy) {
4386
        {
-
 
4387
          search_path[2] = nb[i];
4036
            search_path[2] = nb[i];
4388
          if (is_ringpath (search_path))
4037
            if (is_ringpath (search_path))
4389
            rb = true;
4038
              rb = true;
4390
          //return true;
4039
            //return true;
4391
        }
4040
          }
4392
    }
4041
  }
4393
  return rb;
4042
  return rb;
4394
}
4043
}
4395
 
-
 
4396
 
4044
 
4397
static void
-
 
4398
chk_ringbonds ()
4045
static void chk_ringbonds ()
4399
{
4046
{
4400
  int i, a1rc, a2rc;
4047
  int i, a1rc, a2rc;
4401
 
4048
 
4402
  if (n_bonds < 1)
4049
  if (n_bonds < 1)
4403
    return;
4050
    return;
4404
 
4051
 
4405
  for (i = 0; i < n_bonds; i++)
4052
  for (i = 0; i < n_bonds; i++) {
4406
    {
-
 
4407
      a1rc = atom[bond[i].a1 - 1].ring_count;
4053
    a1rc = atom[bond[i].a1 - 1].ring_count;
4408
      a2rc = atom[bond[i].a2 - 1].ring_count;
4054
    a2rc = atom[bond[i].a2 - 1].ring_count;
4409
      if (n_rings == 0 || (a1rc < n_rings && a2rc < n_rings))
4055
    if (n_rings == 0 || (a1rc < n_rings && a2rc < n_rings)) {
4410
        {
-
 
4411
          is_ringbond (i + 1);
4056
            is_ringbond (i + 1);
4412
          /*inc(bond^[i].ring_count); */
4057
          /*inc(bond^[i].ring_count); */
4413
        }
4058
          }
4414
    }
4059
  }
4415
}
4060
}
4416
 
-
 
4417
 
4061
 
4418
/* v0.3d: moved procedure update_ringcount a bit down */
4062
/* v0.3d: moved procedure update_ringcount a bit down */
4419
 
4063
 
4420
 
-
 
4421
static int
-
 
4422
raw_hetbond_count (int a)
4064
static int raw_hetbond_count (int a)
4423
{
4065
{
4424
  /* new in v0.2j, ignores bond order */
4066
  /* new in v0.2j, ignores bond order */
4425
  int i;
4067
  int i;
4426
  neighbor_rec nb;
4068
  neighbor_rec nb;
4427
  str2 nb_el;
4069
  str2 nb_el;
Line 4433... Line 4075...
4433
  memset (nb, 0, sizeof (neighbor_rec));
4075
  memset (nb, 0, sizeof (neighbor_rec));
4434
  get_neighbors (nb, a);
4076
  get_neighbors (nb, a);
4435
  if (atom[a - 1].neighbor_count <= 0)
4077
  if (atom[a - 1].neighbor_count <= 0)
4436
    return hbc;
4078
    return hbc;
4437
  FORLIM = atom[a - 1].neighbor_count;
4079
  FORLIM = atom[a - 1].neighbor_count;
4438
  for (i = 0; i < FORLIM; i++)
4080
  for (i = 0; i < FORLIM; i++) {
4439
    {
-
 
4440
      strcpy (nb_el, atom[nb[i] - 1].element);
4081
    strcpy (nb_el, atom[nb[i] - 1].element);
4441
      if (strcmp (nb_el, "C ") && strcmp (nb_el, "A ") && strcmp (nb_el, "H ")  /* &&  strcmp (nb_el, "D ") */
4082
    if (strcmp (nb_el, "C ") && strcmp (nb_el, "A ") && strcmp (nb_el, "H ")    /* &&  strcmp (nb_el, "D ") */
4442
          && strcmp (nb_el, "LP") && strcmp (nb_el, "DU"))
4083
              && strcmp (nb_el, "LP") && strcmp (nb_el, "DU"))
4443
        /* added 'D ' in v0.3n */
4084
            /* added 'D ' in v0.3n */
4444
        hbc++;
4085
          hbc++;
4445
    }
4086
  }
4446
  return hbc;
4087
  return hbc;
4447
}
4088
}
4448
 
-
 
4449
 
4089
 
4450
static int
-
 
4451
hetbond_count (int a)
4090
static int hetbond_count (int a)
4452
{
4091
{
4453
  int i;
4092
  int i;
4454
  neighbor_rec nb;
4093
  neighbor_rec nb;
4455
  str2 nb_el;
4094
  str2 nb_el;
4456
  float hbc = 0.0;
4095
  float hbc = 0.0;
4457
  int FORLIM;
4096
  int FORLIM;
4458
 
4097
 
4459
  if (a <= 0 || a > n_atoms)
4098
  if (a <= 0 || a > n_atoms)
-
 
4099
    return ((int) floor (hbc + 0.5));
-
 
4100
  memset (nb, 0, sizeof (neighbor_rec));
-
 
4101
  get_neighbors (nb, a);
-
 
4102
  if (atom[a - 1].neighbor_count <= 0)
4460
    return ((int) floor (hbc + 0.5));
4103
    return ((int) floor (hbc + 0.5));
4461
  memset (nb, 0, sizeof (neighbor_rec));
-
 
4462
  get_neighbors (nb, a);
-
 
4463
  if (atom[a - 1].neighbor_count <= 0)
-
 
4464
    return ((int) floor (hbc + 0.5));
-
 
4465
  FORLIM = atom[a - 1].neighbor_count;
4104
  FORLIM = atom[a - 1].neighbor_count;
4466
  for (i = 0; i < FORLIM; i++)
4105
  for (i = 0; i < FORLIM; i++) {
4467
    {
-
 
4468
      strcpy (nb_el, atom[nb[i] - 1].element);
4106
    strcpy (nb_el, atom[nb[i] - 1].element);
4469
      if (strcmp (nb_el, "C ") && strcmp (nb_el, "A ") && strcmp (nb_el, "H ")  /*&& strcmp (nb_el, "D ") */
4107
    if (strcmp (nb_el, "C ") && strcmp (nb_el, "A ") && strcmp (nb_el, "H ")    /*&& strcmp (nb_el, "D ") */
4470
          && strcmp (nb_el, "LP") && strcmp (nb_el, "DU"))
4108
              && strcmp (nb_el, "LP") && strcmp (nb_el, "DU")) {                        /* added 'D ' in v0.3n */
4471
        {                       /* added 'D ' in v0.3n */
-
 
4472
          if (bond[get_bond (a, nb[i]) - 1].btype == 'S')
4109
            if (bond[get_bond (a, nb[i]) - 1].btype == 'S')
4473
            hbc += 1.0;
4110
              hbc += 1.0;
4474
          if (bond[get_bond (a, nb[i]) - 1].btype == 'A')
4111
            if (bond[get_bond (a, nb[i]) - 1].btype == 'A')
4475
            hbc += 1.5;
4112
              hbc += 1.5;
4476
          if (bond[get_bond (a, nb[i]) - 1].btype == 'D')
4113
            if (bond[get_bond (a, nb[i]) - 1].btype == 'D')
4477
            hbc += 2.0;
4114
              hbc += 2.0;
4478
          if (bond[get_bond (a, nb[i]) - 1].btype == 'T')
4115
            if (bond[get_bond (a, nb[i]) - 1].btype == 'T')
4479
            hbc += 3.0;
4116
              hbc += 3.0;
4480
        }
4117
          }
4481
    }
4118
  }
4482
  return ((int) floor (hbc + 0.5));
4119
  return ((int) floor (hbc + 0.5));
4483
}
4120
}
4484
 
-
 
4485
 
4121
 
4486
static int
-
 
4487
hetatom_count (int a)
4122
static int hetatom_count (int a)
4488
{
4123
{
4489
  int i;
4124
  int i;
4490
  neighbor_rec nb;
4125
  neighbor_rec nb;
4491
  str2 nb_el;
4126
  str2 nb_el;
4492
  int hac = 0;
4127
  int hac = 0;
4493
  int FORLIM;
4128
  int FORLIM;
4494
 
4129
 
4495
  if (a <= 0 || a > n_atoms)
4130
  if (a <= 0 || a > n_atoms)
4496
    return hac;
4131
    return hac;
4497
  memset (nb, 0, sizeof (neighbor_rec));
4132
  memset (nb, 0, sizeof (neighbor_rec));
4498
  get_neighbors (nb, a);
4133
  get_neighbors (nb, a);
4499
  if (atom[a - 1].neighbor_count <= 0)
4134
  if (atom[a - 1].neighbor_count <= 0)
4500
    return hac;
4135
    return hac;
4501
  FORLIM = atom[a - 1].neighbor_count;
4136
  FORLIM = atom[a - 1].neighbor_count;
4502
  for (i = 0; i < FORLIM; i++)
4137
  for (i = 0; i < FORLIM; i++) {
4503
    {
-
 
4504
      strcpy (nb_el, atom[nb[i] - 1].element);
4138
    strcpy (nb_el, atom[nb[i] - 1].element);
4505
      if (strcmp (nb_el, "C ") && strcmp (nb_el, "H ")
4139
    if (strcmp (nb_el, "C ") && strcmp (nb_el, "H ")
4506
          /*&&  strcmp (nb_el, "D ") */  && strcmp (nb_el, "LP")
4140
              /*&&  strcmp (nb_el, "D ") */  && strcmp (nb_el, "LP")
4507
          && strcmp (nb_el, "DU"))
4141
              && strcmp (nb_el, "DU"))
4508
        /* added 'D ' in v0.3n */
4142
            /* added 'D ' in v0.3n */
4509
        hac++;
4143
            hac++;
4510
    }
4144
  }
4511
  return hac;
4145
  return hac;
4512
}
4146
}
4513
 
4147
 
4514
#if 0
4148
#if 0
4515
static int
-
 
4516
ndl_hetbond_count (int a)
4149
static int ndl_hetbond_count (int a)
4517
{
4150
{
4518
  int i;
4151
  int i;
4519
  neighbor_rec nb;
4152
  neighbor_rec nb;
4520
  str2 nb_el;
4153
  str2 nb_el;
4521
  float hbc = 0.0;
4154
  float hbc = 0.0;
4522
  int FORLIM;
4155
  int FORLIM;
4523
 
4156
 
4524
  if (a <= 0 || a > n_atoms)
4157
  if (a <= 0 || a > n_atoms)
4525
    return ((int) floor (hbc + 0.5));
4158
    return ((int) floor (hbc + 0.5));
4526
  memset (nb, 0, sizeof (neighbor_rec));
4159
  memset (nb, 0, sizeof (neighbor_rec));
4527
  get_ndl_neighbors (nb, a);
4160
  get_ndl_neighbors (nb, a);
4528
  if (ndl_atom[a - 1].neighbor_count <= 0)
4161
  if (ndl_atom[a - 1].neighbor_count <= 0)
4529
    return ((int) floor (hbc + 0.5));
4162
    return ((int) floor (hbc + 0.5));
4530
  FORLIM = ndl_atom[a - 1].neighbor_count;
4163
  FORLIM = ndl_atom[a - 1].neighbor_count;
4531
  for (i = 0; i < FORLIM; i++)
4164
  for (i = 0; i < FORLIM; i++) {
4532
    {
-
 
4533
      strcpy (nb_el, ndl_atom[nb[i] - 1].element);
4165
    strcpy (nb_el, ndl_atom[nb[i] - 1].element);
4534
      if (strcmp (nb_el, "C ") && strcmp (nb_el, "H ")
4166
    if (strcmp (nb_el, "C ") && strcmp (nb_el, "H ")
4535
          /*&&  strcmp (nb_el, "D ") */  && strcmp (nb_el, "LP")
4167
              /*&&  strcmp (nb_el, "D ") */  && strcmp (nb_el, "LP")
4536
          && strcmp (nb_el, "DU"))
-
 
4537
        {                       /* added 'D ' in v0.3n */
4168
              && strcmp (nb_el, "DU")) {                        /* added 'D ' in v0.3n */
4538
          if (ndl_bond[get_ndl_bond (a, nb[i]) - 1].btype == 'S')
4169
            if (ndl_bond[get_ndl_bond (a, nb[i]) - 1].btype == 'S')
4539
            hbc += 1.0;
4170
              hbc += 1.0;
4540
          if (ndl_bond[get_ndl_bond (a, nb[i]) - 1].btype == 'A')
4171
            if (ndl_bond[get_ndl_bond (a, nb[i]) - 1].btype == 'A')
4541
            hbc += 1.5;
4172
              hbc += 1.5;
4542
          if (ndl_bond[get_ndl_bond (a, nb[i]) - 1].btype == 'D')
4173
            if (ndl_bond[get_ndl_bond (a, nb[i]) - 1].btype == 'D')
4543
            hbc += 2.0;
4174
              hbc += 2.0;
4544
          if (ndl_bond[get_ndl_bond (a, nb[i]) - 1].btype == 'T')
4175
            if (ndl_bond[get_ndl_bond (a, nb[i]) - 1].btype == 'T')
4545
            hbc += 3.0;
4176
              hbc += 3.0;
4546
        }
4177
          }
4547
    }
4178
  }
4548
  return ((int) floor (hbc + 0.5));
4179
  return ((int) floor (hbc + 0.5));
4549
}
4180
}
4550
#endif
4181
#endif
4551
 
4182
 
4552
static int
-
 
4553
ndl_hetatom_count (int a)
4183
static int ndl_hetatom_count (int a)
4554
{
4184
{
4555
  int i;
4185
  int i;
4556
  neighbor_rec nb;
4186
  neighbor_rec nb;
4557
  str2 nb_el;
4187
  str2 nb_el;
4558
  int hac = 0;
4188
  int hac = 0;
4559
  int FORLIM;
4189
  int FORLIM;
Line 4563... Line 4193...
4563
  memset (nb, 0, sizeof (neighbor_rec));
4193
  memset (nb, 0, sizeof (neighbor_rec));
4564
  get_ndl_neighbors (nb, a);
4194
  get_ndl_neighbors (nb, a);
4565
  if (ndl_atom[a - 1].neighbor_count <= 0)
4195
  if (ndl_atom[a - 1].neighbor_count <= 0)
4566
    return hac;
4196
    return hac;
4567
  FORLIM = ndl_atom[a - 1].neighbor_count;
4197
  FORLIM = ndl_atom[a - 1].neighbor_count;
4568
  for (i = 0; i < FORLIM; i++)
-
 
4569
    {                           /* note: query atoms like 'A' should be present only in the needle */
4198
  for (i = 0; i < FORLIM; i++) {                                /* note: query atoms like 'A' should be present only in the needle */
4570
      strcpy (nb_el, ndl_atom[nb[i] - 1].element);
4199
    strcpy (nb_el, ndl_atom[nb[i] - 1].element);
4571
      if (strcmp (nb_el, "C ") && strcmp (nb_el, "A ") && strcmp (nb_el, "H ")  /*&&  strcmp (nb_el, "D ") */
4200
    if (strcmp (nb_el, "C ") && strcmp (nb_el, "A ") && strcmp (nb_el, "H ")    /*&&  strcmp (nb_el, "D ") */
4572
          && strcmp (nb_el, "LP") && strcmp (nb_el, "DU"))
4201
              && strcmp (nb_el, "LP") && strcmp (nb_el, "DU"))
4573
        /* added 'D ' in v0.3n */
4202
            /* added 'D ' in v0.3n */
4574
        hac++;
4203
          hac++;
4575
    }
4204
  }
4576
  return hac;
4205
  return hac;
4577
}
4206
}
4578
 
-
 
4579
 
4207
 
4580
static boolean
-
 
4581
is_oxo_C (int id)
4208
static boolean is_oxo_C (int id)
4582
{
4209
{
4583
  int i;
4210
  int i;
4584
  boolean r = false;
4211
  boolean r = false;
4585
  neighbor_rec nb;
4212
  neighbor_rec nb;
4586
  int FORLIM;
4213
  int FORLIM;
Line 4590... Line 4217...
4590
    return false;
4217
    return false;
4591
  get_neighbors (nb, id);
4218
  get_neighbors (nb, id);
4592
  if (strcmp (atom[id - 1].element, "C ") || atom[id - 1].neighbor_count <= 0)
4219
  if (strcmp (atom[id - 1].element, "C ") || atom[id - 1].neighbor_count <= 0)
4593
    return false;
4220
    return false;
4594
  FORLIM = atom[id - 1].neighbor_count;
4221
  FORLIM = atom[id - 1].neighbor_count;
4595
  for (i = 0; i < FORLIM; i++)
4222
  for (i = 0; i < FORLIM; i++) {
4596
    {
-
 
4597
      if (bond[get_bond (id, nb[i]) - 1].btype == 'D' &&
4223
    if (bond[get_bond (id, nb[i]) - 1].btype == 'D' &&
4598
          !strcmp (atom[nb[i] - 1].element, "O "))
4224
              !strcmp (atom[nb[i] - 1].element, "O "))
4599
        /* no N, amidines are different... */
4225
            /* no N, amidines are different... */
4600
        r = true;
4226
            r = true;
4601
      /* or
4227
      /* or
4602
         (atom^[(nb[i])].element = 'S ')  or
4228
         (atom^[(nb[i])].element = 'S ')  or
4603
         (atom^[(nb[i])].element = 'SE') */
4229
         (atom^[(nb[i])].element = 'SE') */
4604
    }
4230
  }
4605
  return r;
-
 
4606
}
-
 
4607
 
-
 
4608
 
-
 
4609
static boolean
-
 
4610
is_thioxo_C (int id)
-
 
4611
{
-
 
4612
  int i;
-
 
4613
  boolean r = false;
-
 
4614
  neighbor_rec nb;
-
 
4615
  int FORLIM;
-
 
4616
 
-
 
4617
  memset (nb, 0, sizeof (neighbor_rec));
-
 
4618
  if (id < 1 || id > n_atoms)
-
 
4619
    return false;
-
 
4620
  get_neighbors (nb, id);
-
 
4621
  if (strcmp (atom[id - 1].element, "C ") || atom[id - 1].neighbor_count <= 0)
-
 
4622
    return false;
-
 
4623
  FORLIM = atom[id - 1].neighbor_count;
-
 
4624
  for (i = 0; i < FORLIM; i++)
-
 
4625
    {
-
 
4626
      if (bond[get_bond (id, nb[i]) - 1].btype == 'D' &&
-
 
4627
          (!strcmp (atom[nb[i] - 1].element, "S ") ||
-
 
4628
           !strcmp (atom[nb[i] - 1].element, "SE")))
-
 
4629
        /* no N, amidines are different... */
-
 
4630
        r = true;
-
 
4631
    }
-
 
4632
  return r;
4231
  return r;
4633
}
4232
}
4634
 
4233
 
4635
 
-
 
4636
static boolean
-
 
4637
is_imino_C (int id)
4234
static boolean is_thioxo_C (int id)
4638
{
4235
{
4639
  int i;
4236
  int i;
4640
  boolean r = false;
4237
  boolean r = false;
4641
  neighbor_rec nb;
4238
  neighbor_rec nb;
4642
  int FORLIM;
4239
  int FORLIM;
Line 4646... Line 4243...
4646
    return false;
4243
    return false;
4647
  get_neighbors (nb, id);
4244
  get_neighbors (nb, id);
4648
  if (strcmp (atom[id - 1].element, "C ") || atom[id - 1].neighbor_count <= 0)
4245
  if (strcmp (atom[id - 1].element, "C ") || atom[id - 1].neighbor_count <= 0)
4649
    return false;
4246
    return false;
4650
  FORLIM = atom[id - 1].neighbor_count;
4247
  FORLIM = atom[id - 1].neighbor_count;
4651
  for (i = 0; i < FORLIM; i++)
4248
  for (i = 0; i < FORLIM; i++) {
4652
    {
-
 
4653
      if (bond[get_bond (id, nb[i]) - 1].btype == 'D' &&
4249
    if (bond[get_bond (id, nb[i]) - 1].btype == 'D' &&
-
 
4250
              (!strcmp (atom[nb[i] - 1].element, "S ") ||
4654
          !strcmp (atom[nb[i] - 1].element, "N "))
4251
              !strcmp (atom[nb[i] - 1].element, "SE")))
-
 
4252
            /* no N, amidines are different... */
4655
        r = true;
4253
          r = true;
4656
    }
4254
  }
4657
  return r;
4255
  return r;
4658
}
4256
}
4659
 
4257
 
-
 
4258
static boolean is_imino_C (int id)
-
 
4259
{
-
 
4260
  int i;
-
 
4261
  boolean r = false;
-
 
4262
  neighbor_rec nb;
-
 
4263
  int FORLIM;
4660
 
4264
 
-
 
4265
  memset (nb, 0, sizeof (neighbor_rec));
-
 
4266
  if (id < 1 || id > n_atoms)
-
 
4267
    return false;
-
 
4268
  get_neighbors (nb, id);
-
 
4269
  if (strcmp (atom[id - 1].element, "C ") || atom[id - 1].neighbor_count <= 0)
-
 
4270
    return false;
-
 
4271
  FORLIM = atom[id - 1].neighbor_count;
-
 
4272
  for (i = 0; i < FORLIM; i++) {
-
 
4273
    if (bond[get_bond (id, nb[i]) - 1].btype == 'D' &&
-
 
4274
              !strcmp (atom[nb[i] - 1].element, "N "))
4661
static boolean
4275
            r = true;
-
 
4276
  }
-
 
4277
  return r;
-
 
4278
}
-
 
4279
 
4662
is_true_imino_C (int id)
4280
static boolean is_true_imino_C (int id)
4663
{
4281
{
4664
  int i;
4282
  int i;
4665
  boolean r = true;
4283
  boolean r = true;
4666
  neighbor_rec nb;
4284
  neighbor_rec nb;
4667
  str2 nb_el;
4285
  str2 nb_el;
4668
  int a_n = 0;
4286
  int a_n = 0;
4669
  int b;                        /* v0.3j */
4287
  int b;                        /* v0.3j */
4670
  int FORLIM;
4288
  int FORLIM;
4671
 
4289
 
4672
/* p2c: checkmol.pas: Note: Eliminated unused assignment statement [338] */
4290
/* p2c: checkmol.pas: Note: Eliminated unused assignment statement [338] */
4673
  memset (nb, 0, sizeof (neighbor_rec));
4291
  memset (nb, 0, sizeof (neighbor_rec));
4674
  if (id < 1 || id > n_atoms)
4292
  if (id < 1 || id > n_atoms)
4675
    return false;
4293
    return false;
4676
  get_neighbors (nb, id);
4294
  get_neighbors (nb, id);
4677
  if (strcmp (atom[id - 1].element, "C ") || atom[id - 1].neighbor_count <= 0)
4295
  if (strcmp (atom[id - 1].element, "C ") || atom[id - 1].neighbor_count <= 0)
4678
    return false;
4296
    return false;
4679
  FORLIM = atom[id - 1].neighbor_count;
4297
  FORLIM = atom[id - 1].neighbor_count;
4680
  for (i = 0; i < FORLIM; i++)
4298
  for (i = 0; i < FORLIM; i++) {
4681
    {
-
 
4682
      b = get_bond (id, nb[i]); /* v0.3j */
4299
    b = get_bond (id, nb[i]);   /* v0.3j */
4683
      if (bond[b - 1].btype == 'D' && bond[b - 1].arom == false &&
4300
    if (bond[b - 1].btype == 'D' && bond[b - 1].arom == false &&
4684
          !strcmp (atom[nb[i] - 1].element, "N "))
4301
              !strcmp (atom[nb[i] - 1].element, "N "))
4685
        /* v0.3j */
4302
        /* v0.3j */
4686
        a_n = nb[i];
4303
            a_n = nb[i];
4687
    }
4304
  }
4688
  if (a_n <= 0)
4305
  if (a_n <= 0)
4689
    return false;
4306
    return false;
4690
  memset (nb, 0, sizeof (neighbor_rec));
4307
  memset (nb, 0, sizeof (neighbor_rec));
4691
  get_neighbors (nb, a_n);
4308
  get_neighbors (nb, a_n);
4692
  FORLIM = atom[a_n - 1].neighbor_count;
4309
  FORLIM = atom[a_n - 1].neighbor_count;
4693
  for (i = 0; i < FORLIM; i++)
4310
  for (i = 0; i < FORLIM; i++) {
4694
    {
-
 
4695
      strcpy (nb_el, atom[nb[i] - 1].element);
4311
    strcpy (nb_el, atom[nb[i] - 1].element);
4696
      if (strcmp (nb_el, "C ") && strcmp (nb_el, "H ")
4312
    if (strcmp (nb_el, "C ") && strcmp (nb_el, "H ")
4697
          /*&&  strcmp (nb_el, "D ") */ )
4313
            /*&&  strcmp (nb_el, "D ") */ )
4698
        /* v0.3n: D */
4314
            /* v0.3n: D */
4699
        r = false;
4315
            r = false;
4700
    }
4316
  }
4701
  return r;
4317
  return r;
4702
}
4318
}
4703
 
4319
 
4704
 
-
 
4705
static boolean
-
 
4706
is_true_exocyclic_imino_C (int id, int r_id)
4320
static boolean is_true_exocyclic_imino_C (int id, int r_id)
4707
{
4321
{
4708
  /* v0.3j */
4322
  /* v0.3j */
4709
  int i, j;
4323
  int i, j;
4710
  boolean r = false;
4324
  boolean r = false;
4711
  neighbor_rec nb;
4325
  neighbor_rec nb;
4712
  ringpath_type testring;
4326
  ringpath_type testring;
4713
  int ring_size, b, FORLIM;
4327
  int ring_size, b, FORLIM;
4714
 
4328
 
4715
  memset (nb, 0, sizeof (neighbor_rec));
4329
  memset (nb, 0, sizeof (neighbor_rec));
4716
  if (id < 1 || id > n_atoms)
4330
  if (id < 1 || id > n_atoms)
4717
    return false;
4331
    return false;
4718
  get_neighbors (nb, id);
4332
  get_neighbors (nb, id);
4719
  memset (testring, 0, sizeof (ringpath_type));
4333
  memset (testring, 0, sizeof (ringpath_type));
4720
  ring_size = ringprop[r_id - 1].size;  /* v0.3j */
4334
  ring_size = ringprop[r_id - 1].size;  /* v0.3j */
4721
  for (j = 0; j < ring_size; j++)       /* v0.3j */
4335
  for (j = 0; j < ring_size; j++)       /* v0.3j */
4722
    testring[j] = ring[r_id - 1][j];
4336
    testring[j] = ring[r_id - 1][j];
4723
  if (strcmp (atom[id - 1].element, "C ") || atom[id - 1].neighbor_count <= 0)
4337
  if (strcmp (atom[id - 1].element, "C ") || atom[id - 1].neighbor_count <= 0)
4724
    return false;
4338
    return false;
4725
  FORLIM = atom[id - 1].neighbor_count;
4339
  FORLIM = atom[id - 1].neighbor_count;
4726
  for (i = 0; i < FORLIM; i++)
4340
  for (i = 0; i < FORLIM; i++) {
4727
    {
-
 
4728
      b = get_bond (id, nb[i]);
4341
    b = get_bond (id, nb[i]);
4729
      if (bond[b - 1].btype == 'D' && bond[b - 1].arom == false &&
4342
    if (bond[b - 1].btype == 'D' && bond[b - 1].arom == false &&
4730
          !strcmp (atom[nb[i] - 1].element, "N "))
4343
              !strcmp (atom[nb[i] - 1].element, "N ")) {
4731
        {
-
 
4732
          r = true;
4344
            r = true;
4733
          for (j = 0; j < ring_size; j++)
4345
            for (j = 0; j < ring_size; j++) {
4734
            {
-
 
4735
              if (nb[i] == ring[r_id - 1][j])
4346
              if (nb[i] == ring[r_id - 1][j])
4736
                r = false;
4347
                      r = false;
4737
            }
4348
            }
4738
        }
4349
          }
4739
    }
4350
  }
4740
  return r;
4351
  return r;
4741
}
4352
}
4742
 
-
 
4743
 
4353
 
4744
static boolean
-
 
4745
is_exocyclic_imino_C (int id, int r_id)
4354
static boolean is_exocyclic_imino_C (int id, int r_id)
4746
{
4355
{
4747
  int i, j;
4356
  int i, j;
4748
  boolean r = false;
4357
  boolean r = false;
4749
  neighbor_rec nb;
4358
  neighbor_rec nb;
4750
  ringpath_type testring;
4359
  ringpath_type testring;
4751
  int ring_size, FORLIM;
4360
  int ring_size, FORLIM;
4752
 
4361
 
4753
  memset (nb, 0, sizeof (neighbor_rec));
4362
  memset (nb, 0, sizeof (neighbor_rec));
4754
  if (id < 1 || id > n_atoms)
4363
  if (id < 1 || id > n_atoms)
4755
    return false;
4364
    return false;
4756
  get_neighbors (nb, id);
4365
  get_neighbors (nb, id);
4757
  memset (testring, 0, sizeof (ringpath_type));
4366
  memset (testring, 0, sizeof (ringpath_type));
4758
  ring_size = ringprop[r_id - 1].size;  /* v0.3j */
4367
  ring_size = ringprop[r_id - 1].size;  /* v0.3j */
4759
  for (j = 0; j < ring_size; j++)       /* v0.3j */
4368
  for (j = 0; j < ring_size; j++)       /* v0.3j */
4760
    testring[j] = ring[r_id - 1][j];
4369
    testring[j] = ring[r_id - 1][j];
4761
  if (strcmp (atom[id - 1].element, "C ") || atom[id - 1].neighbor_count <= 0)
4370
  if (strcmp (atom[id - 1].element, "C ") || atom[id - 1].neighbor_count <= 0)
4762
    return false;
4371
    return false;
4763
  FORLIM = atom[id - 1].neighbor_count;
4372
  FORLIM = atom[id - 1].neighbor_count;
4764
  for (i = 0; i < FORLIM; i++)
4373
  for (i = 0; i < FORLIM; i++) {
4765
    {
-
 
4766
      if (bond[get_bond (id, nb[i]) - 1].btype == 'D' &&
4374
    if (bond[get_bond (id, nb[i]) - 1].btype == 'D' &&
4767
          !strcmp (atom[nb[i] - 1].element, "N "))
4375
              !strcmp (atom[nb[i] - 1].element, "N ")) {
4768
        {
-
 
4769
          r = true;
4376
            r = true;
4770
          for (j = 0; j < ring_size; j++)
4377
            for (j = 0; j < ring_size; j++) {
4771
            {
-
 
4772
              if (nb[i] == ring[r_id - 1][j])
4378
              if (nb[i] == ring[r_id - 1][j])
4773
                r = false;
4379
                      r = false;
4774
            }
4380
            }
4775
        }
4381
          }
4776
    }
4382
  }
4777
  return r;
4383
  return r;
4778
}
4384
}
4779
 
4385
 
4780
 
-
 
4781
static int
-
 
4782
find_exocyclic_methylene_C (int id, int r_id)
4386
static int find_exocyclic_methylene_C (int id, int r_id)
4783
{
4387
{
4784
  /* renamed and rewritten in v0.3j */
4388
  /* renamed and rewritten in v0.3j */
4785
  int i, j;
4389
  int i, j;
4786
  int r = 0;
4390
  int r = 0;
4787
  neighbor_rec nb;
4391
  neighbor_rec nb;
4788
  ringpath_type testring;
4392
  ringpath_type testring;
4789
  int ring_size, FORLIM;
4393
  int ring_size, FORLIM;
4790
 
4394
 
4791
  memset (nb, 0, sizeof (neighbor_rec));
4395
  memset (nb, 0, sizeof (neighbor_rec));
Line 4797... Line 4401...
4797
  for (j = 0; j < ring_size; j++)       /* v0.3j */
4401
  for (j = 0; j < ring_size; j++)       /* v0.3j */
4798
    testring[j] = ring[r_id - 1][j];
4402
    testring[j] = ring[r_id - 1][j];
4799
  if (strcmp (atom[id - 1].element, "C ") || atom[id - 1].neighbor_count <= 0)
4403
  if (strcmp (atom[id - 1].element, "C ") || atom[id - 1].neighbor_count <= 0)
4800
    return r;
4404
    return r;
4801
  FORLIM = atom[id - 1].neighbor_count;
4405
  FORLIM = atom[id - 1].neighbor_count;
4802
  for (i = 0; i < FORLIM; i++)
4406
  for (i = 0; i < FORLIM; i++) {
4803
    {
-
 
4804
      if (bond[get_bond (id, nb[i]) - 1].btype == 'D' &&
4407
    if (bond[get_bond (id, nb[i]) - 1].btype == 'D' &&
4805
          !strcmp (atom[nb[i] - 1].element, "C "))
4408
              !strcmp (atom[nb[i] - 1].element, "C ")) {
4806
        {
-
 
4807
          r = nb[i];
4409
            r = nb[i];
4808
          for (j = 0; j < ring_size; j++)
4410
            for (j = 0; j < ring_size; j++) {
4809
            {
-
 
4810
              if (nb[i] == ring[r_id - 1][j])
4411
              if (nb[i] == ring[r_id - 1][j])
4811
                r = 0;
4412
                    r = 0;
4812
            }
4413
            }
4813
        }
4414
          }
4814
    }
4415
  }
4815
  return r;
4416
  return r;
4816
}
4417
}
4817
 
-
 
4818
 
4418
 
4819
static boolean
-
 
4820
is_hydroxy (int a_view, int a_ref)
4419
static boolean is_hydroxy (int a_view, int a_ref)
4821
{
4420
{
4822
  boolean r = false;
4421
  boolean r = false;
4823
 
4422
 
4824
  if (atom[a_view - 1].
-
 
4825
      heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S'))
4423
  if (atom[a_view - 1]. heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')) {
4826
    {
-
 
4827
      if (!strcmp (atom[a_ref - 1].atype, "O3 ") &&
4424
    if (!strcmp (atom[a_ref - 1].atype, "O3 ") &&
4828
          atom[a_ref - 1].neighbor_count == 1)
-
 
4829
        r = true;
-
 
4830
    }
-
 
4831
  return r;
-
 
4832
}
-
 
4833
 
-
 
4834
 
-
 
4835
static boolean
-
 
4836
is_sulfanyl (int a_view, int a_ref)
-
 
4837
{
-
 
4838
  boolean r = false;
-
 
4839
 
-
 
4840
  if (atom[a_view - 1].
-
 
4841
      heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S'))
-
 
4842
    {
-
 
4843
      if (!strcmp (atom[a_ref - 1].atype, "S3 ") &&
-
 
4844
          atom[a_ref - 1].neighbor_count == 1)
4425
              atom[a_ref - 1].neighbor_count == 1)
4845
        r = true;
4426
            r = true;
4846
    }
4427
  }
4847
  return r;
4428
  return r;
4848
}
4429
}
4849
 
4430
 
4850
 
-
 
4851
static boolean
-
 
4852
is_amino (int a_view, int a_ref)
4431
static boolean is_sulfanyl (int a_view, int a_ref)
4853
{
4432
{
4854
  boolean r = false;
4433
  boolean r = false;
4855
 
4434
 
4856
  if (atom[a_view - 1].
4435
  if (atom[a_view - 1].
4857
      heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S'))
4436
      heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')) {
4858
    {
-
 
4859
      if ((!strcmp (atom[a_ref - 1].atype, "N3 ") ||
4437
    if (!strcmp (atom[a_ref - 1].atype, "S3 ") &&
4860
           !strcmp (atom[a_ref - 1].atype, "N3+")) &&
-
 
4861
          atom[a_ref - 1].neighbor_count == 1)
4438
              atom[a_ref - 1].neighbor_count == 1)
4862
        r = true;
4439
            r = true;
4863
    }
4440
  }
4864
  return r;
4441
  return r;
4865
}
4442
}
4866
 
4443
 
-
 
4444
static boolean is_amino (int a_view, int a_ref)
-
 
4445
{
-
 
4446
  boolean r = false;
-
 
4447
 
-
 
4448
  if (atom[a_view - 1].
-
 
4449
      heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')) {
-
 
4450
    if ((!strcmp (atom[a_ref - 1].atype, "N3 ") ||
-
 
4451
              !strcmp (atom[a_ref - 1].atype, "N3+")) &&
-
 
4452
              atom[a_ref - 1].neighbor_count == 1)
-
 
4453
            r = true;
-
 
4454
    }
-
 
4455
  return r;
-
 
4456
}
4867
 
4457
 
4868
static boolean
-
 
4869
is_alkyl (int a_view, int a_ref)
4458
static boolean is_alkyl (int a_view, int a_ref)
4870
{
4459
{
4871
  int i;
4460
  int i;
4872
  boolean r = false;
4461
  boolean r = false;
4873
  neighbor_rec nb;
4462
  neighbor_rec nb;
4874
  str2 nb_el;
4463
  str2 nb_el;
4875
  int het_count = 0;
4464
  int het_count = 0;
4876
  int FORLIM;
4465
  int FORLIM;
4877
 
4466
 
4878
  memset (nb, 0, sizeof (neighbor_rec));
4467
  memset (nb, 0, sizeof (neighbor_rec));
4879
  if (!
-
 
4880
      (atom[a_view - 1].
4468
  if (! (atom[a_view - 1].
4881
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S'))
4469
      heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S'))
4882
      || strcmp (atom[a_ref - 1].atype, "C3 ")
4470
      || strcmp (atom[a_ref - 1].atype, "C3 ")
4883
      || atom[a_ref - 1].arom != false)
4471
      || atom[a_ref - 1].arom != false)
4884
    return false;
4472
    return false;
4885
  get_nextneighbors (nb, a_ref, a_view);
4473
  get_nextneighbors (nb, a_ref, a_view);
4886
  FORLIM = atom[a_ref - 1].neighbor_count - 2;
4474
  FORLIM = atom[a_ref - 1].neighbor_count - 2;
4887
  for (i = 0; i <= FORLIM; i++)
4475
  for (i = 0; i <= FORLIM; i++) {
4888
    {
-
 
4889
      strcpy (nb_el, atom[nb[i] - 1].element);
4476
    strcpy (nb_el, atom[nb[i] - 1].element);
4890
      if (strcmp (nb_el, "C ") && strcmp (nb_el, "H ")
4477
    if (strcmp (nb_el, "C ") && strcmp (nb_el, "H ")
4891
          /*&&  strcmp (nb_el, "D ") */  && strcmp (nb_el, "DU")
4478
              /*&&  strcmp (nb_el, "D ") */  && strcmp (nb_el, "DU")
4892
          && strcmp (nb_el, "LP"))
4479
              && strcmp (nb_el, "LP"))
4893
        /* added 'D ' in v0.3n */
4480
            /* added 'D ' in v0.3n */
4894
        het_count++;
4481
            het_count++;
4895
    }
4482
  }
4896
  if (het_count <= 1)           /* we consider (e.g.) alkoxyalkyl groups as alkyl */
4483
  if (het_count <= 1)           /* we consider (e.g.) alkoxyalkyl groups as alkyl */
4897
    r = true;
4484
    r = true;
4898
  return r;
4485
  return r;
4899
}
4486
}
4900
 
-
 
4901
 
4487
 
4902
static boolean
-
 
4903
is_true_alkyl (int a_view, int a_ref)
4488
static boolean is_true_alkyl (int a_view, int a_ref)
4904
{
4489
{
4905
  int i;
4490
  int i;
4906
  boolean r = false;
4491
  boolean r = false;
4907
  neighbor_rec nb;
4492
  neighbor_rec nb;
4908
  str2 nb_el;
4493
  str2 nb_el;
4909
  int het_count = 0;
4494
  int het_count = 0;
4910
  int FORLIM;
4495
  int FORLIM;
4911
 
4496
 
4912
  memset (nb, 0, sizeof (neighbor_rec));
4497
  memset (nb, 0, sizeof (neighbor_rec));
4913
  if (!
-
 
4914
      (atom[a_view - 1].
4498
  if (!(atom[a_view - 1].
4915
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S'))
4499
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S'))
4916
      || strcmp (atom[a_ref - 1].atype, "C3 ")
4500
      || strcmp (atom[a_ref - 1].atype, "C3 ")
4917
      || atom[a_ref - 1].arom != false)
4501
      || atom[a_ref - 1].arom != false)
4918
    return false;
4502
    return false;
4919
  get_nextneighbors (nb, a_ref, a_view);
4503
  get_nextneighbors (nb, a_ref, a_view);
4920
  FORLIM = atom[a_ref - 1].neighbor_count - 2;
4504
  FORLIM = atom[a_ref - 1].neighbor_count - 2;
4921
  for (i = 0; i <= FORLIM; i++)
4505
  for (i = 0; i <= FORLIM; i++) {
4922
    {
-
 
4923
      strcpy (nb_el, atom[nb[i] - 1].element);
4506
    strcpy (nb_el, atom[nb[i] - 1].element);
4924
      if (strcmp (nb_el, "C ") && strcmp (nb_el, "H ")
4507
    if (strcmp (nb_el, "C ") && strcmp (nb_el, "H ")
4925
          /*&&  strcmp (nb_el, "D ") */  && strcmp (nb_el, "DU"))
4508
             /*&&  strcmp (nb_el, "D ") */  && strcmp (nb_el, "DU"))
4926
        /* added 'D ' in v0.3n */
4509
             /* added 'D ' in v0.3n */
4927
        het_count++;
4510
             het_count++;
4928
    }
4511
  }
4929
  if (het_count == 0)           /* */
4512
  if (het_count == 0)           /* */
4930
    r = true;
4513
    r = true;
4931
  return r;
4514
  return r;
4932
}
4515
}
4933
 
-
 
4934
 
4516
 
4935
static boolean
-
 
4936
is_alkenyl (int a_view, int a_ref)
4517
static boolean is_alkenyl (int a_view, int a_ref)
4937
{
4518
{
4938
  /* new in v0.3j */
4519
  /* new in v0.3j */
4939
  int i;
4520
  int i;
4940
  boolean r = false;
4521
  boolean r = false;
4941
  neighbor_rec nb;
4522
  neighbor_rec nb;
4942
  str2 nb_el;
4523
  str2 nb_el;
4943
  str3 nb_at;
4524
  str3 nb_at;
4944
  int c2_count = 0, het_count = 0;
4525
  int c2_count = 0, het_count = 0;
4945
  int FORLIM;
4526
  int FORLIM;
4946
 
4527
 
4947
  memset (nb, 0, sizeof (neighbor_rec));
4528
  memset (nb, 0, sizeof (neighbor_rec));
4948
  if (!
-
 
4949
      (atom[a_view - 1].
4529
  if (! (atom[a_view - 1].
4950
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S'))
4530
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S'))
4951
      || strcmp (atom[a_ref - 1].atype, "C2 ")
4531
      || strcmp (atom[a_ref - 1].atype, "C2 ")
4952
      || atom[a_ref - 1].arom != false)
4532
      || atom[a_ref - 1].arom != false) {
4953
    {
-
 
4954
      return false;
4533
    return false;
4955
    }                           /* v0.3k: changed c2_count = 1 into c2_count >= 1 */
4534
  }                             /* v0.3k: changed c2_count = 1 into c2_count >= 1 */
4956
  get_nextneighbors (nb, a_ref, a_view);
4535
  get_nextneighbors (nb, a_ref, a_view);
4957
  FORLIM = atom[a_ref - 1].neighbor_count - 2;
4536
  FORLIM = atom[a_ref - 1].neighbor_count - 2;
4958
  for (i = 0; i <= FORLIM; i++)
4537
  for (i = 0; i <= FORLIM; i++) {
4959
    {
-
 
4960
      strcpy (nb_el, atom[nb[i] - 1].element);
4538
    strcpy (nb_el, atom[nb[i] - 1].element);
4961
      strcpy (nb_at, atom[nb[i] - 1].atype);
4539
    strcpy (nb_at, atom[nb[i] - 1].atype);
4962
      if (strcmp (nb_el, "C ") && strcmp (nb_el, "H ")
4540
    if (strcmp (nb_el, "C ") && strcmp (nb_el, "H ")
4963
          /*&&  strcmp (nb_el, "D ") */  && strcmp (nb_el, "DU")
4541
            /*&&  strcmp (nb_el, "D ") */  && strcmp (nb_el, "DU")
4964
          && strcmp (nb_el, "LP"))
4542
             && strcmp (nb_el, "LP"))
4965
        /* added 'D ' in v0.3n */
4543
            /* added 'D ' in v0.3n */
4966
        het_count++;
4544
            het_count++;
4967
      if (!strcmp (nb_at, "C2 "))
4545
    if (!strcmp (nb_at, "C2 "))
4968
        c2_count++;
4546
            c2_count++;
4969
    }
4547
  }
4970
  if (c2_count >= 1 && het_count <= 1)
4548
  if (c2_count >= 1 && het_count <= 1)
4971
    /* we consider (e.g.) alkoxyalkenyl groups as alkenyl */
4549
    /* we consider (e.g.) alkoxyalkenyl groups as alkenyl */
4972
    r = true;
4550
    r = true;
4973
  return r;
4551
  return r;
4974
}
4552
}
4975
 
4553
 
4976
 
-
 
4977
static boolean
-
 
4978
is_alkynyl (int a_view, int a_ref)
4554
static boolean is_alkynyl (int a_view, int a_ref)
4979
{
4555
{
4980
  /* new in v0.3j */
4556
  /* new in v0.3j */
4981
  int i;
4557
  int i;
4982
  boolean r = false;
4558
  boolean r = false;
4983
  neighbor_rec nb;
4559
  neighbor_rec nb;
4984
  str3 nb_at;
4560
  str3 nb_at;
4985
  int c1_count = 0;
4561
  int c1_count = 0;
4986
  int FORLIM;
4562
  int FORLIM;
4987
 
4563
 
4988
  memset (nb, 0, sizeof (neighbor_rec));
4564
  memset (nb, 0, sizeof (neighbor_rec));
4989
  if (!
-
 
4990
      (atom[a_view - 1].
4565
  if (!(atom[a_view - 1].
4991
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S'))
4566
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S'))
4992
      || strcmp (atom[a_ref - 1].atype, "C1 ")
4567
      || strcmp (atom[a_ref - 1].atype, "C1 ")
4993
      || atom[a_ref - 1].arom != false)
4568
      || atom[a_ref - 1].arom != false)
4994
    return false;
4569
    return false;
4995
  get_nextneighbors (nb, a_ref, a_view);
4570
  get_nextneighbors (nb, a_ref, a_view);
4996
  FORLIM = atom[a_ref - 1].neighbor_count - 2;
4571
  FORLIM = atom[a_ref - 1].neighbor_count - 2;
4997
  for (i = 0; i <= FORLIM; i++)
4572
  for (i = 0; i <= FORLIM; i++) {
4998
    {
-
 
4999
      strcpy (nb_at, atom[nb[i] - 1].atype);
4573
    strcpy (nb_at, atom[nb[i] - 1].atype);
5000
      if (!strcmp (nb_at, "C1 "))
4574
    if (!strcmp (nb_at, "C1 "))
5001
        c1_count++;
4575
            c1_count++;
5002
    }
4576
  }
5003
  if (c1_count == 1)
4577
  if (c1_count == 1)
5004
    r = true;
4578
    r = true;
5005
  return r;
4579
  return r;
5006
}
4580
}
5007
 
-
 
5008
 
4581
 
5009
static boolean
-
 
5010
is_aryl (int a_view, int a_ref)
4582
static boolean is_aryl (int a_view, int a_ref)
5011
{
4583
{
5012
  boolean r = false;
4584
  boolean r = false;
5013
 
4585
 
5014
  if ((atom[a_view - 1].
4586
  if ((atom[a_view - 1].
5015
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S'))
4587
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S'))
5016
      && !strcmp (atom[a_ref - 1].element, "C ")
4588
      && !strcmp (atom[a_ref - 1].element, "C ")
5017
      && atom[a_ref - 1].arom == true)
4589
      && atom[a_ref - 1].arom == true)
5018
    r = true;
4590
    r = true;
-
 
4591
  return r;
-
 
4592
}
-
 
4593
 
-
 
4594
static boolean is_alkoxy (int a_view, int a_ref)
-
 
4595
{
-
 
4596
  boolean r = false;
-
 
4597
  neighbor_rec nb;
-
 
4598
 
-
 
4599
  memset (nb, 0, sizeof (neighbor_rec));
-
 
4600
  if (!(atom[a_view - 1].
-
 
4601
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
-
 
4602
    return false;
-
 
4603
  if (strcmp (atom[a_ref - 1].atype, "O3 ")
-
 
4604
      || atom[a_ref - 1].neighbor_count != 2)
-
 
4605
    return false;
-
 
4606
  get_nextneighbors (nb, a_ref, a_view);
-
 
4607
  if (is_alkyl (a_ref, nb[0]))
-
 
4608
    r = true;
5019
  return r;
4609
  return r;
5020
}
4610
}
-
 
4611
 
-
 
4612
static boolean is_siloxy (int a_view, int a_ref)
-
 
4613
{
-
 
4614
  boolean r = false;
-
 
4615
  neighbor_rec nb;
5021
 
4616
 
-
 
4617
  memset (nb, 0, sizeof (neighbor_rec));
-
 
4618
  if (!(atom[a_view - 1].
-
 
4619
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
-
 
4620
    return false;
-
 
4621
  if (strcmp (atom[a_ref - 1].atype, "O3 ")
-
 
4622
      || atom[a_ref - 1].neighbor_count != 2)
-
 
4623
    return false;
-
 
4624
  get_nextneighbors (nb, a_ref, a_view);
-
 
4625
  if (!strcmp (atom[nb[0] - 1].element, "SI"))
-
 
4626
    r = true;
-
 
4627
  return r;
-
 
4628
}
5022
 
4629
 
-
 
4630
static boolean is_true_alkoxy (int a_view, int a_ref)
-
 
4631
{
-
 
4632
  boolean r = false;
5023
static boolean
4633
  neighbor_rec nb;
-
 
4634
 
-
 
4635
  memset (nb, 0, sizeof (neighbor_rec));
-
 
4636
  if (!(atom[a_view - 1].
-
 
4637
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
-
 
4638
    return false;
-
 
4639
  if (strcmp (atom[a_ref - 1].atype, "O3 ")
-
 
4640
      || atom[a_ref - 1].neighbor_count != 2)
-
 
4641
    return false;
-
 
4642
  get_nextneighbors (nb, a_ref, a_view);
-
 
4643
  if (is_true_alkyl (a_ref, nb[0]))
-
 
4644
    r = true;
-
 
4645
  return r;
-
 
4646
}
-
 
4647
 
5024
is_alkoxy (int a_view, int a_ref)
4648
static boolean is_aryloxy (int a_view, int a_ref)
5025
{
4649
{
5026
  boolean r = false;
4650
  boolean r = false;
5027
  neighbor_rec nb;
4651
  neighbor_rec nb;
5028
 
4652
 
5029
  memset (nb, 0, sizeof (neighbor_rec));
4653
  memset (nb, 0, sizeof (neighbor_rec));
5030
  if (!
-
 
5031
      (atom[a_view - 1].
4654
  if (!(atom[a_view - 1].
5032
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
4655
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5033
    return false;
4656
    return false;
5034
  if (strcmp (atom[a_ref - 1].atype, "O3 ")
4657
  if (strcmp (atom[a_ref - 1].atype, "O3 ")
5035
      || atom[a_ref - 1].neighbor_count != 2)
4658
      || atom[a_ref - 1].neighbor_count != 2)
5036
    return false;
4659
    return false;
5037
  get_nextneighbors (nb, a_ref, a_view);
4660
  get_nextneighbors (nb, a_ref, a_view);
5038
  if (is_alkyl (a_ref, nb[0]))
4661
  if (is_aryl (a_ref, nb[0]))
5039
    r = true;
4662
    r = true;
5040
  return r;
4663
  return r;
5041
}
4664
}
5042
 
4665
 
5043
 
-
 
5044
static boolean
-
 
5045
is_siloxy (int a_view, int a_ref)
4666
static boolean is_alkenyloxy (int a_view, int a_ref) {
5046
{
4667
  /* v0.3j */
5047
  boolean r = false;
4668
  boolean r = false;
5048
  neighbor_rec nb;
4669
  neighbor_rec nb;
5049
 
4670
 
5050
  memset (nb, 0, sizeof (neighbor_rec));
4671
  memset (nb, 0, sizeof (neighbor_rec));
5051
  if (!
-
 
5052
      (atom[a_view - 1].
4672
  if (!(atom[a_view - 1].
5053
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
4673
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5054
    return false;
4674
    return false;
5055
  if (strcmp (atom[a_ref - 1].atype, "O3 ")
4675
  if (strcmp (atom[a_ref - 1].atype, "O3 ")
5056
      || atom[a_ref - 1].neighbor_count != 2)
4676
      || atom[a_ref - 1].neighbor_count != 2)
5057
    return false;
4677
    return false;
5058
  get_nextneighbors (nb, a_ref, a_view);
4678
  get_nextneighbors (nb, a_ref, a_view);
5059
  if (!strcmp (atom[nb[0] - 1].element, "SI"))
4679
  if (is_alkenyl (a_ref, nb[0]))
5060
    r = true;
4680
    r = true;
5061
  return r;
4681
  return r;
5062
}
4682
}
5063
 
-
 
5064
 
4683
 
5065
static boolean
-
 
5066
is_true_alkoxy (int a_view, int a_ref)
4684
static boolean is_alkynyloxy (int a_view, int a_ref)
5067
{
4685
{
5068
  boolean r = false;
-
 
5069
  neighbor_rec nb;
-
 
5070
 
-
 
5071
  memset (nb, 0, sizeof (neighbor_rec));
-
 
5072
  if (!
-
 
5073
      (atom[a_view - 1].
-
 
5074
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
-
 
5075
    return false;
-
 
5076
  if (strcmp (atom[a_ref - 1].atype, "O3 ")
-
 
5077
      || atom[a_ref - 1].neighbor_count != 2)
-
 
5078
    return false;
-
 
5079
  get_nextneighbors (nb, a_ref, a_view);
-
 
5080
  if (is_true_alkyl (a_ref, nb[0]))
-
 
5081
    r = true;
-
 
5082
  return r;
4686
  /* v0.3j */
5083
}
-
 
5084
 
-
 
5085
 
-
 
5086
static boolean
-
 
5087
is_aryloxy (int a_view, int a_ref)
-
 
5088
{
-
 
5089
  boolean r = false;
4687
  boolean r = false;
5090
  neighbor_rec nb;
4688
  neighbor_rec nb;
5091
 
4689
 
5092
  memset (nb, 0, sizeof (neighbor_rec));
4690
  memset (nb, 0, sizeof (neighbor_rec));
5093
  if (!
-
 
5094
      (atom[a_view - 1].
4691
  if (!(atom[a_view - 1].
5095
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
4692
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5096
    return false;
4693
    return false;
5097
  if (strcmp (atom[a_ref - 1].atype, "O3 ")
4694
  if (strcmp (atom[a_ref - 1].atype, "O3 ")
5098
      || atom[a_ref - 1].neighbor_count != 2)
4695
      || atom[a_ref - 1].neighbor_count != 2)
5099
    return false;
4696
    return false;
5100
  get_nextneighbors (nb, a_ref, a_view);
4697
  get_nextneighbors (nb, a_ref, a_view);
5101
  if (is_aryl (a_ref, nb[0]))
4698
  if (is_alkynyl (a_ref, nb[0]))
5102
    r = true;
4699
    r = true;
5103
  return r;
4700
  return r;
5104
}
4701
}
5105
 
4702
 
5106
 
-
 
5107
static boolean
-
 
5108
is_alkenyloxy (int a_view, int a_ref)
4703
static boolean is_alkylsulfanyl (int a_view, int a_ref)
5109
{
4704
{
5110
  /* v0.3j */
-
 
5111
  boolean r = false;
4705
  boolean r = false;
5112
  neighbor_rec nb;
4706
  neighbor_rec nb;
5113
 
4707
 
5114
  memset (nb, 0, sizeof (neighbor_rec));
4708
  memset (nb, 0, sizeof (neighbor_rec));
5115
  if (!
-
 
5116
      (atom[a_view - 1].
4709
  if (!(atom[a_view - 1].
5117
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
4710
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5118
    return false;
4711
    return false;
5119
  if (strcmp (atom[a_ref - 1].atype, "O3 ")
-
 
5120
      || atom[a_ref - 1].neighbor_count != 2)
-
 
5121
    return false;
-
 
5122
  get_nextneighbors (nb, a_ref, a_view);
-
 
5123
  if (is_alkenyl (a_ref, nb[0]))
-
 
5124
    r = true;
-
 
5125
  return r;
-
 
5126
}
-
 
5127
 
-
 
5128
 
-
 
5129
static boolean
-
 
5130
is_alkynyloxy (int a_view, int a_ref)
-
 
5131
{
-
 
5132
  /* v0.3j */
-
 
5133
  boolean r = false;
-
 
5134
  neighbor_rec nb;
-
 
5135
 
-
 
5136
  memset (nb, 0, sizeof (neighbor_rec));
-
 
5137
  if (!
-
 
5138
      (atom[a_view - 1].
-
 
5139
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
-
 
5140
    return false;
-
 
5141
  if (strcmp (atom[a_ref - 1].atype, "O3 ")
-
 
5142
      || atom[a_ref - 1].neighbor_count != 2)
-
 
5143
    return false;
-
 
5144
  get_nextneighbors (nb, a_ref, a_view);
-
 
5145
  if (is_alkynyl (a_ref, nb[0]))
-
 
5146
    r = true;
-
 
5147
  return r;
-
 
5148
}
-
 
5149
 
-
 
5150
 
-
 
5151
static boolean
-
 
5152
is_alkylsulfanyl (int a_view, int a_ref)
-
 
5153
{
-
 
5154
  boolean r = false;
-
 
5155
  neighbor_rec nb;
-
 
5156
 
-
 
5157
  memset (nb, 0, sizeof (neighbor_rec));
-
 
5158
  if (!
-
 
5159
      (atom[a_view - 1].
-
 
5160
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
-
 
5161
    return false;
-
 
5162
  if (strcmp (atom[a_ref - 1].atype, "S3 ")
4712
  if (strcmp (atom[a_ref - 1].atype, "S3 ")
5163
      || atom[a_ref - 1].neighbor_count != 2)
4713
      || atom[a_ref - 1].neighbor_count != 2)
5164
    return false;
4714
    return false;
5165
  get_nextneighbors (nb, a_ref, a_view);
4715
  get_nextneighbors (nb, a_ref, a_view);
5166
  if (is_alkyl (a_ref, nb[0]))
4716
  if (is_alkyl (a_ref, nb[0]))
5167
    r = true;
4717
    r = true;
5168
  return r;
4718
  return r;
5169
}
4719
}
5170
 
-
 
5171
 
4720
 
5172
static boolean
-
 
5173
is_true_alkylsulfanyl (int a_view, int a_ref)
4721
static boolean is_true_alkylsulfanyl (int a_view, int a_ref)
5174
{
4722
{
5175
  boolean r = false;
4723
  boolean r = false;
5176
  neighbor_rec nb;
4724
  neighbor_rec nb;
5177
 
4725
 
5178
  memset (nb, 0, sizeof (neighbor_rec));
4726
  memset (nb, 0, sizeof (neighbor_rec));
5179
  if (!
-
 
5180
      (atom[a_view - 1].
4727
  if (!(atom[a_view - 1].
5181
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
4728
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5182
    return false;
4729
    return false;
5183
  if (strcmp (atom[a_ref - 1].atype, "S3 ")
4730
  if (strcmp (atom[a_ref - 1].atype, "S3 ")
5184
      || atom[a_ref - 1].neighbor_count != 2)
4731
      || atom[a_ref - 1].neighbor_count != 2)
5185
    return false;
4732
    return false;
5186
  get_nextneighbors (nb, a_ref, a_view);
4733
  get_nextneighbors (nb, a_ref, a_view);
5187
  if (is_true_alkyl (a_ref, nb[0]))
4734
  if (is_true_alkyl (a_ref, nb[0]))
5188
    r = true;
4735
    r = true;
5189
  return r;
4736
  return r;
5190
}
4737
}
5191
 
4738
 
5192
 
-
 
5193
static boolean
-
 
5194
is_arylsulfanyl (int a_view, int a_ref)
4739
static boolean is_arylsulfanyl (int a_view, int a_ref)
5195
{
4740
{
5196
  boolean r = false;
4741
  boolean r = false;
5197
  neighbor_rec nb;
4742
  neighbor_rec nb;
5198
 
4743
 
5199
  memset (nb, 0, sizeof (neighbor_rec));
4744
  memset (nb, 0, sizeof (neighbor_rec));
5200
  if (!
-
 
5201
      (atom[a_view - 1].
4745
  if (!(atom[a_view - 1].
5202
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
4746
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5203
    return false;
4747
    return false;
5204
  if (strcmp (atom[a_ref - 1].atype, "S3 ")
4748
  if (strcmp (atom[a_ref - 1].atype, "S3 ")
5205
      || atom[a_ref - 1].neighbor_count != 2)
4749
      || atom[a_ref - 1].neighbor_count != 2)
5206
    return false;
4750
    return false;
Line 5208... Line 4752...
5208
  if (is_aryl (a_ref, nb[0]))
4752
  if (is_aryl (a_ref, nb[0]))
5209
    r = true;
4753
    r = true;
5210
  return r;
4754
  return r;
5211
}
4755
}
5212
 
4756
 
5213
 
-
 
5214
static boolean
-
 
5215
is_alkenylsulfanyl (a_view, a_ref)
4757
static boolean is_alkenylsulfanyl (a_view, a_ref)
5216
     int a_view, a_ref;
4758
     int a_view, a_ref;
5217
{
4759
{
5218
  /* v0.3j */
4760
  /* v0.3j */
5219
  boolean r = false;
4761
  boolean r = false;
5220
  neighbor_rec nb;
4762
  neighbor_rec nb;
5221
 
4763
 
5222
  memset (nb, 0, sizeof (neighbor_rec));
4764
  memset (nb, 0, sizeof (neighbor_rec));
5223
  if (!
-
 
5224
      (atom[a_view - 1].
4765
  if (!(atom[a_view - 1].
5225
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
4766
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5226
    return false;
4767
    return false;
5227
  if (strcmp (atom[a_ref - 1].atype, "S3 ")
4768
  if (strcmp (atom[a_ref - 1].atype, "S3 ")
5228
      || atom[a_ref - 1].neighbor_count != 2)
4769
      || atom[a_ref - 1].neighbor_count != 2)
5229
    return false;
4770
    return false;
5230
  get_nextneighbors (nb, a_ref, a_view);
4771
  get_nextneighbors (nb, a_ref, a_view);
5231
  if (is_alkenyl (a_ref, nb[0]))
4772
  if (is_alkenyl (a_ref, nb[0]))
5232
    r = true;
4773
    r = true;
5233
  return r;
4774
  return r;
5234
}
4775
}
5235
 
4776
 
5236
 
-
 
5237
static boolean
-
 
5238
is_alkynylsulfanyl (a_view, a_ref)
4777
static boolean is_alkynylsulfanyl (a_view, a_ref)
5239
     int a_view, a_ref;
4778
     int a_view, a_ref;
5240
{
4779
{
5241
  /* v0.3j */
4780
  /* v0.3j */
5242
  boolean r = false;
4781
  boolean r = false;
5243
  neighbor_rec nb;
4782
  neighbor_rec nb;
5244
 
4783
 
5245
  memset (nb, 0, sizeof (neighbor_rec));
4784
  memset (nb, 0, sizeof (neighbor_rec));
5246
  if (!
-
 
5247
      (atom[a_view - 1].
4785
  if (!(atom[a_view - 1].
5248
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
4786
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5249
    return false;
4787
    return false;
5250
  if (strcmp (atom[a_ref - 1].atype, "S3 ")
4788
  if (strcmp (atom[a_ref - 1].atype, "S3 ")
5251
      || atom[a_ref - 1].neighbor_count != 2)
4789
      || atom[a_ref - 1].neighbor_count != 2)
5252
    return false;
4790
    return false;
Line 5254... Line 4792...
5254
  if (is_alkynyl (a_ref, nb[0]))
4792
  if (is_alkynyl (a_ref, nb[0]))
5255
    r = true;
4793
    r = true;
5256
  return r;
4794
  return r;
5257
}
4795
}
5258
 
4796
 
5259
 
-
 
5260
static boolean
-
 
5261
is_alkylamino (a_view, a_ref)
4797
static boolean is_alkylamino (a_view, a_ref)
5262
     int a_view, a_ref;
4798
     int a_view, a_ref;
5263
{
4799
{
5264
  boolean r = false;
4800
  boolean r = false;
5265
  neighbor_rec nb;
4801
  neighbor_rec nb;
5266
  int alkyl_count = 0;
4802
  int alkyl_count = 0;
5267
 
4803
 
5268
  memset (nb, 0, sizeof (neighbor_rec));
4804
  memset (nb, 0, sizeof (neighbor_rec));
5269
  if (!
-
 
5270
      (atom[a_view - 1].
4805
  if (!(atom[a_view - 1].
5271
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
4806
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5272
    return false;
4807
    return false;
5273
  if (strcmp (atom[a_ref - 1].element, "N ")
4808
  if (strcmp (atom[a_ref - 1].element, "N ")
5274
      || atom[a_ref - 1].neighbor_count != 2)
4809
      || atom[a_ref - 1].neighbor_count != 2)
5275
    return false;
4810
    return false;
5276
  get_nextneighbors (nb, a_ref, a_view);
4811
  get_nextneighbors (nb, a_ref, a_view);
5277
  if (is_alkyl (a_ref, nb[0]))
4812
  if (is_alkyl (a_ref, nb[0]))
5278
    alkyl_count++;
4813
    alkyl_count++;
5279
  if (alkyl_count == 1)
4814
  if (alkyl_count == 1)
-
 
4815
    r = true;
-
 
4816
  return r;
-
 
4817
}
-
 
4818
 
-
 
4819
static boolean is_dialkylamino (a_view, a_ref)
-
 
4820
     int a_view, a_ref;
-
 
4821
{
-
 
4822
  int i;
-
 
4823
  boolean r = false;
-
 
4824
  neighbor_rec nb;
-
 
4825
  int alkyl_count = 0;
-
 
4826
 
-
 
4827
  memset (nb, 0, sizeof (neighbor_rec));
-
 
4828
  if (!(atom[a_view - 1].
-
 
4829
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
-
 
4830
    return false;
-
 
4831
  if (strcmp (atom[a_ref - 1].element, "N ")
-
 
4832
      || atom[a_ref - 1].neighbor_count != 3)
-
 
4833
    return false;
-
 
4834
  get_nextneighbors (nb, a_ref, a_view);
-
 
4835
  for (i = 0; i <= 1; i++) {
-
 
4836
    if (is_alkyl (a_ref, nb[i]))
-
 
4837
            alkyl_count++;
-
 
4838
  }
-
 
4839
  if (alkyl_count == 2)
5280
    r = true;
4840
    r = true;
5281
  return r;
4841
  return r;
5282
}
4842
}
5283
 
4843
 
5284
 
-
 
5285
static boolean
-
 
5286
is_dialkylamino (a_view, a_ref)
4844
static boolean is_arylamino (a_view, a_ref)
5287
     int a_view, a_ref;
4845
     int a_view, a_ref;
5288
{
4846
{
5289
  int i;
-
 
5290
  boolean r = false;
4847
  boolean r = false;
5291
  neighbor_rec nb;
4848
  neighbor_rec nb;
5292
  int alkyl_count = 0;
4849
  int aryl_count = 0;
5293
 
4850
 
5294
  memset (nb, 0, sizeof (neighbor_rec));
4851
  memset (nb, 0, sizeof (neighbor_rec));
5295
  if (!
-
 
5296
      (atom[a_view - 1].
4852
  if (!(atom[a_view - 1].
5297
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
4853
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5298
    return false;
4854
    return false;
5299
  if (strcmp (atom[a_ref - 1].element, "N ")
4855
  if (strcmp (atom[a_ref - 1].element, "N ")
5300
      || atom[a_ref - 1].neighbor_count != 3)
-
 
5301
    return false;
-
 
5302
  get_nextneighbors (nb, a_ref, a_view);
-
 
5303
  for (i = 0; i <= 1; i++)
-
 
5304
    {
-
 
5305
      if (is_alkyl (a_ref, nb[i]))
-
 
5306
        alkyl_count++;
-
 
5307
    }
-
 
5308
  if (alkyl_count == 2)
-
 
5309
    r = true;
-
 
5310
  return r;
-
 
5311
}
-
 
5312
 
-
 
5313
 
-
 
5314
static boolean
-
 
5315
is_arylamino (a_view, a_ref)
-
 
5316
     int a_view, a_ref;
-
 
5317
{
-
 
5318
  boolean r = false;
-
 
5319
  neighbor_rec nb;
-
 
5320
  int aryl_count = 0;
-
 
5321
 
-
 
5322
  memset (nb, 0, sizeof (neighbor_rec));
-
 
5323
  if (!
-
 
5324
      (atom[a_view - 1].
-
 
5325
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
-
 
5326
    return false;
-
 
5327
  if (strcmp (atom[a_ref - 1].element, "N ")
-
 
5328
      || atom[a_ref - 1].neighbor_count != 2)
4856
      || atom[a_ref - 1].neighbor_count != 2)
5329
    return false;
4857
    return false;
5330
  get_nextneighbors (nb, a_ref, a_view);
4858
  get_nextneighbors (nb, a_ref, a_view);
5331
  if (is_aryl (a_ref, nb[0]))
4859
  if (is_aryl (a_ref, nb[0]))
5332
    aryl_count++;
4860
    aryl_count++;
5333
  if (aryl_count == 1)
4861
  if (aryl_count == 1)
5334
    r = true;
4862
    r = true;
5335
  return r;
4863
  return r;
5336
}
4864
}
5337
 
4865
 
5338
 
-
 
5339
static boolean
-
 
5340
is_diarylamino (a_view, a_ref)
4866
static boolean is_diarylamino (a_view, a_ref)
5341
     int a_view, a_ref;
4867
     int a_view, a_ref;
5342
{
4868
{
5343
  int i;
4869
  int i;
5344
  boolean r = false;
4870
  boolean r = false;
5345
  neighbor_rec nb;
4871
  neighbor_rec nb;
5346
  int aryl_count = 0;
4872
  int aryl_count = 0;
5347
 
4873
 
5348
  memset (nb, 0, sizeof (neighbor_rec));
4874
  memset (nb, 0, sizeof (neighbor_rec));
5349
  if (!
-
 
5350
      (atom[a_view - 1].
4875
  if (!(atom[a_view - 1].
5351
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
4876
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5352
    return false;
4877
    return false;
5353
  if (strcmp (atom[a_ref - 1].element, "N ")
4878
  if (strcmp (atom[a_ref - 1].element, "N ")
5354
      || atom[a_ref - 1].neighbor_count != 3)
4879
      || atom[a_ref - 1].neighbor_count != 3)
5355
    return false;
4880
    return false;
5356
  get_nextneighbors (nb, a_ref, a_view);
4881
  get_nextneighbors (nb, a_ref, a_view);
5357
  for (i = 0; i <= 1; i++)
4882
  for (i = 0; i <= 1; i++) {
5358
    {
-
 
5359
      if (is_aryl (a_ref, nb[i]))
4883
    if (is_aryl (a_ref, nb[i]))
5360
        aryl_count++;
4884
            aryl_count++;
5361
    }
4885
  }
5362
  if (aryl_count == 2)
4886
  if (aryl_count == 2)
5363
    r = true;
4887
    r = true;
5364
  return r;
4888
  return r;
5365
}
4889
}
5366
 
4890
 
5367
 
-
 
5368
static boolean
-
 
5369
is_alkylarylamino (a_view, a_ref)
4891
static boolean is_alkylarylamino (a_view, a_ref)
5370
     int a_view, a_ref;
4892
     int a_view, a_ref;
5371
{
4893
{
5372
  int i;
4894
  int i;
5373
  boolean r = false;
4895
  boolean r = false;
5374
  neighbor_rec nb;
4896
  neighbor_rec nb;
5375
  int alkyl_count = 0, aryl_count = 0;
4897
  int alkyl_count = 0, aryl_count = 0;
5376
 
4898
 
5377
  memset (nb, 0, sizeof (neighbor_rec));
4899
  memset (nb, 0, sizeof (neighbor_rec));
5378
  if (!
-
 
5379
      (atom[a_view - 1].
4900
  if (!(atom[a_view - 1].
5380
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
4901
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5381
    return false;
4902
    return false;
5382
  if (strcmp (atom[a_ref - 1].element, "N ")
4903
  if (strcmp (atom[a_ref - 1].element, "N ")
5383
      || atom[a_ref - 1].neighbor_count != 3)
4904
      || atom[a_ref - 1].neighbor_count != 3)
5384
    return false;
4905
    return false;
5385
  get_nextneighbors (nb, a_ref, a_view);
4906
  get_nextneighbors (nb, a_ref, a_view);
5386
  for (i = 0; i <= 1; i++)
4907
  for (i = 0; i <= 1; i++) {
5387
    {
-
 
5388
      if (is_alkyl (a_ref, nb[i]))
4908
    if (is_alkyl (a_ref, nb[i]))
5389
        alkyl_count++;
4909
            alkyl_count++;
5390
      if (is_aryl (a_ref, nb[i]))
4910
    if (is_aryl (a_ref, nb[i]))
5391
        aryl_count++;
4911
            aryl_count++;
5392
    }
4912
  }
5393
  if (alkyl_count == 1 && aryl_count == 1)
4913
  if (alkyl_count == 1 && aryl_count == 1)
5394
    r = true;
4914
    r = true;
5395
  return r;
4915
  return r;
5396
}
4916
}
5397
 
-
 
5398
 
4917
 
5399
static boolean
-
 
5400
is_C_monosubst_amino (a_view, a_ref)
4918
static boolean is_C_monosubst_amino (a_view, a_ref)
5401
     int a_view, a_ref;
4919
     int a_view, a_ref;
5402
{
4920
{
5403
  /* new in v0.3j */
4921
  /* new in v0.3j */
5404
  boolean r = false;
4922
  boolean r = false;
5405
  neighbor_rec nb;
4923
  neighbor_rec nb;
5406
  int c_count = 0;
4924
  int c_count = 0;
5407
 
4925
 
5408
  memset (nb, 0, sizeof (neighbor_rec));
4926
  memset (nb, 0, sizeof (neighbor_rec));
5409
  if (!
-
 
5410
      (atom[a_view - 1].
4927
  if (! (atom[a_view - 1].
5411
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
4928
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5412
    return false;
4929
    return false;
5413
  if ((strcmp (atom[a_ref - 1].atype, "N3 ")
4930
  if ((strcmp (atom[a_ref - 1].atype, "N3 ")
5414
      && strcmp (atom[a_ref - 1].atype, "NAM"))
4931
      && strcmp (atom[a_ref - 1].atype, "NAM"))
5415
      || atom[a_ref - 1].neighbor_count != 2)
4932
      || atom[a_ref - 1].neighbor_count != 2)
5416
    return false;
4933
    return false;
5417
  get_nextneighbors (nb, a_ref, a_view);
4934
  get_nextneighbors (nb, a_ref, a_view);
Line 5420... Line 4937...
5420
  if (c_count == 1)
4937
  if (c_count == 1)
5421
    r = true;
4938
    r = true;
5422
  return r;
4939
  return r;
5423
}
4940
}
5424
 
4941
 
5425
 
-
 
5426
static boolean
-
 
5427
is_C_disubst_amino (a_view, a_ref)
4942
static boolean is_C_disubst_amino (a_view, a_ref)
5428
     int a_view, a_ref;
4943
     int a_view, a_ref;
5429
{
4944
{
5430
  /* new in v0.3j */
4945
  /* new in v0.3j */
5431
  int i;
4946
  int i;
5432
  boolean r = false;
4947
  boolean r = false;
Line 5435... Line 4950...
5435
  int c_count = 0;
4950
  int c_count = 0;
5436
 
4951
 
5437
  b = get_bond (a_view, a_ref);
4952
  b = get_bond (a_view, a_ref);
5438
  memset (nb, 0, sizeof (neighbor_rec));
4953
  memset (nb, 0, sizeof (neighbor_rec));
5439
  if (!(atom[a_view - 1].heavy && bond[b - 1].btype == 'S' &&
4954
  if (!(atom[a_view - 1].heavy && bond[b - 1].btype == 'S' &&
5440
        bond[b - 1].arom == false))
4955
            bond[b - 1].arom == false))
5441
    return false;
4956
    return false;
5442
  if ((strcmp (atom[a_ref - 1].atype, "N3 ")
4957
  if ((strcmp (atom[a_ref - 1].atype, "N3 ")
5443
      && strcmp (atom[a_ref - 1].atype, "NAM"))
4958
      && strcmp (atom[a_ref - 1].atype, "NAM"))
5444
      || atom[a_ref - 1].neighbor_count != 3)
4959
      || atom[a_ref - 1].neighbor_count != 3)
5445
    return false;
4960
    return false;
5446
  get_nextneighbors (nb, a_ref, a_view);
4961
  get_nextneighbors (nb, a_ref, a_view);
5447
  for (i = 0; i <= 1; i++)
4962
  for (i = 0; i <= 1; i++) {
5448
    {
-
 
5449
      if (!strcmp (atom[nb[i] - 1].element, "C "))
4963
    if (!strcmp (atom[nb[i] - 1].element, "C "))
5450
        c_count++;
4964
            c_count++;
5451
    }
4965
  }
5452
  if (c_count == 2)
4966
  if (c_count == 2)
5453
    r = true;
4967
    r = true;
5454
  return r;
4968
  return r;
5455
}
4969
}
5456
 
4970
 
5457
 
-
 
5458
static boolean
-
 
5459
is_subst_amino (a_view, a_ref)
4971
static boolean is_subst_amino (a_view, a_ref)
5460
     int a_view, a_ref;
4972
     int a_view, a_ref;
5461
{
4973
{
5462
  boolean r = false;
4974
  boolean r = false;
5463
 
4975
 
5464
  if (is_amino (a_view, a_ref) || is_alkylamino (a_view, a_ref) |
4976
  if (is_amino (a_view, a_ref) || is_alkylamino (a_view, a_ref) |
Line 5466... Line 4978...
5466
      is_alkylarylamino (a_view, a_ref) || is_diarylamino (a_view, a_ref))
4978
      is_alkylarylamino (a_view, a_ref) || is_diarylamino (a_view, a_ref))
5467
    r = true;
4979
    r = true;
5468
  return r;
4980
  return r;
5469
}
4981
}
5470
 
4982
 
5471
 
-
 
5472
static boolean
-
 
5473
is_true_alkylamino (a_view, a_ref)
4983
static boolean is_true_alkylamino (a_view, a_ref)
5474
     int a_view, a_ref;
4984
     int a_view, a_ref;
5475
{
4985
{
5476
  boolean r = false;
4986
  boolean r = false;
5477
  neighbor_rec nb;
4987
  neighbor_rec nb;
5478
  int alkyl_count = 0;
4988
  int alkyl_count = 0;
5479
 
4989
 
5480
  memset (nb, 0, sizeof (neighbor_rec));
4990
  memset (nb, 0, sizeof (neighbor_rec));
5481
  if (!
-
 
5482
      (atom[a_view - 1].
4991
  if (!(atom[a_view - 1].
5483
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
4992
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5484
    return false;
4993
    return false;
5485
  if ((strcmp (atom[a_ref - 1].atype, "N3 ")
4994
  if ((strcmp (atom[a_ref - 1].atype, "N3 ")
5486
      && strcmp (atom[a_ref - 1].atype, "N3+"))
4995
      && strcmp (atom[a_ref - 1].atype, "N3+"))
5487
      || atom[a_ref - 1].neighbor_count != 2)
4996
      || atom[a_ref - 1].neighbor_count != 2)
5488
    return false;
4997
    return false;
5489
  get_nextneighbors (nb, a_ref, a_view);
4998
  get_nextneighbors (nb, a_ref, a_view);
5490
  if (is_true_alkyl (a_ref, nb[0]))
4999
  if (is_true_alkyl (a_ref, nb[0]))
5491
    alkyl_count++;
5000
    alkyl_count++;
5492
  if (alkyl_count == 1)
5001
  if (alkyl_count == 1)
5493
    r = true;
5002
    r = true;
5494
  return r;
5003
  return r;
5495
}
5004
}
5496
 
-
 
5497
 
5005
 
5498
static boolean
-
 
5499
is_true_dialkylamino (a_view, a_ref)
5006
static boolean is_true_dialkylamino (a_view, a_ref)
5500
     int a_view, a_ref;
5007
     int a_view, a_ref;
5501
{
5008
{
5502
  int i;
5009
  int i;
5503
  boolean r = false;
5010
  boolean r = false;
5504
  neighbor_rec nb;
5011
  neighbor_rec nb;
5505
  int alkyl_count = 0;
5012
  int alkyl_count = 0;
5506
 
5013
 
5507
  memset (nb, 0, sizeof (neighbor_rec));
5014
  memset (nb, 0, sizeof (neighbor_rec));
5508
  if (!
-
 
5509
      (atom[a_view - 1].
5015
  if (!(atom[a_view - 1].
5510
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5016
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5511
    return false;
5017
    return false;
5512
  if ((strcmp (atom[a_ref - 1].atype, "N3 ")
5018
  if ((strcmp (atom[a_ref - 1].atype, "N3 ")
5513
      && strcmp (atom[a_ref - 1].atype, "N3+"))
5019
      && strcmp (atom[a_ref - 1].atype, "N3+"))
5514
      || atom[a_ref - 1].neighbor_count != 3)
5020
      || atom[a_ref - 1].neighbor_count != 3)
5515
    return false;
5021
    return false;
5516
  get_nextneighbors (nb, a_ref, a_view);
5022
  get_nextneighbors (nb, a_ref, a_view);
5517
  for (i = 0; i <= 1; i++)
5023
  for (i = 0; i <= 1; i++) {
5518
    {
-
 
5519
      if (is_true_alkyl (a_ref, nb[i]))
5024
    if (is_true_alkyl (a_ref, nb[i]))
5520
        alkyl_count++;
5025
            alkyl_count++;
5521
    }
5026
  }
5522
  if (alkyl_count == 2)
5027
  if (alkyl_count == 2)
5523
    r = true;
5028
    r = true;
5524
  return r;
5029
  return r;
5525
}
5030
}
5526
 
5031
 
5527
#if 0
5032
#if 0
5528
static boolean
-
 
5529
is_true_alkylarylamino (a_view, a_ref)
5033
static boolean is_true_alkylarylamino (a_view, a_ref)
5530
     int a_view, a_ref;
5034
     int a_view, a_ref;
5531
{
5035
{
5532
  int i;
5036
  int i;
5533
  boolean r = false;
5037
  boolean r = false;
5534
  neighbor_rec nb;
5038
  neighbor_rec nb;
5535
  int alkyl_count = 0, aryl_count = 0;
5039
  int alkyl_count = 0, aryl_count = 0;
5536
 
5040
 
5537
  memset (nb, 0, sizeof (neighbor_rec));
5041
  memset (nb, 0, sizeof (neighbor_rec));
5538
  if (!
-
 
5539
      (atom[a_view - 1].
5042
  if (!(atom[a_view - 1].
5540
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5043
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5541
    return false;
5044
    return false;
5542
  if ((strcmp (atom[a_ref - 1].atype, "N3 ")
5045
  if ((strcmp (atom[a_ref - 1].atype, "N3 ")
5543
      && strcmp (atom[a_ref - 1].atype, "N3+"))
5046
      && strcmp (atom[a_ref - 1].atype, "N3+"))
5544
      || atom[a_ref - 1].neighbor_count != 3)
5047
      || atom[a_ref - 1].neighbor_count != 3)
5545
    return false;
5048
    return false;
5546
  get_nextneighbors (nb, a_ref, a_view);
5049
  get_nextneighbors (nb, a_ref, a_view);
5547
  for (i = 0; i <= 1; i++)
5050
  for (i = 0; i <= 1; i++) {
5548
    {
-
 
5549
      if (is_true_alkyl (a_ref, nb[i]))
5051
    if (is_true_alkyl (a_ref, nb[i]))
5550
        alkyl_count++;
5052
            alkyl_count++;
5551
      if (is_aryl (a_ref, nb[i]))
5053
    if (is_aryl (a_ref, nb[i]))
5552
        aryl_count++;
5054
            aryl_count++;
5553
    }
5055
  }
5554
  if (alkyl_count == 1 && aryl_count == 1)
5056
  if (alkyl_count == 1 && aryl_count == 1)
5555
    r = true;
5057
    r = true;
5556
  return r;
5058
  return r;
5557
}
5059
}
5558
#endif
5060
#endif
5559
 
5061
 
5560
static boolean
-
 
5561
is_hydroxylamino (a_view, a_ref)
5062
static boolean is_hydroxylamino (a_view, a_ref)
5562
     int a_view, a_ref;
5063
     int a_view, a_ref;
5563
{
5064
{
5564
  int i;
5065
  int i;
5565
  boolean r = false;
5066
  boolean r = false;
5566
  neighbor_rec nb;
5067
  neighbor_rec nb;
5567
  int oh_count = 0, het_count = 0;      /* v0.3k */
5068
  int oh_count = 0, het_count = 0;      /* v0.3k */
5568
  str2 nb_el;                   /* v0.3k */
5069
  str2 nb_el;                   /* v0.3k */
5569
  int FORLIM;
5070
  int FORLIM;
5570
 
5071
 
5571
  memset (nb, 0, sizeof (neighbor_rec));
5072
  memset (nb, 0, sizeof (neighbor_rec));
5572
  if (!
-
 
5573
      (atom[a_view - 1].
5073
  if (!(atom[a_view - 1].
5574
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5074
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5575
    return false;
5075
    return false;
5576
  if (strcmp (atom[a_ref - 1].element, "N ")
5076
  if (strcmp (atom[a_ref - 1].element, "N ")
5577
      || atom[a_ref - 1].neighbor_count < 2)
5077
      || atom[a_ref - 1].neighbor_count < 2)
5578
    /* v0.3c */
5078
    /* v0.3c */
5579
    return false;
5079
    return false;
5580
  get_nextneighbors (nb, a_ref, a_view);
5080
  get_nextneighbors (nb, a_ref, a_view);
5581
  FORLIM = atom[a_ref - 1].neighbor_count - 2;
5081
  FORLIM = atom[a_ref - 1].neighbor_count - 2;
5582
  for (i = 0; i <= FORLIM; i++)
5082
  for (i = 0; i <= FORLIM; i++) {                               /* v0.3c */
5583
    {                           /* v0.3c */
-
 
5584
      if (is_hydroxy (a_ref, nb[i]))
5083
    if (is_hydroxy (a_ref, nb[i]))
5585
        oh_count++;
5084
            oh_count++;
5586
      strcpy (nb_el, atom[nb[i] - 1].element);  /* v0.3k */
5085
    strcpy (nb_el, atom[nb[i] - 1].element);    /* v0.3k */
5587
      if (strcmp (nb_el, "C ") && strcmp (nb_el, "H ")
5086
    if (strcmp (nb_el, "C ") && strcmp (nb_el, "H ")
5588
          /*&&  strcmp (nb_el, "D ") */  && strcmp (nb_el, "DU")
5087
              /*&&  strcmp (nb_el, "D ") */  && strcmp (nb_el, "DU")
5589
          && strcmp (nb_el, "LP"))
5088
              && strcmp (nb_el, "LP"))
5590
        /* v0.3k */
5089
              /* v0.3k */
5591
        het_count++;
5090
            het_count++;
5592
      /* v0.3n: D */
5091
      /* v0.3n: D */
5593
    }
5092
  }
5594
  if (oh_count == 1 && het_count == 1)
5093
  if (oh_count == 1 && het_count == 1)
5595
    r = true;
5094
    r = true;
5596
  return r;
5095
  return r;
5597
}
5096
}
5598
 
-
 
5599
 
5097
 
5600
static boolean
-
 
5601
is_nitro (a_view, a_ref)
5098
static boolean is_nitro (a_view, a_ref)
5602
     int a_view, a_ref;
5099
     int a_view, a_ref;
5603
{
5100
{
5604
  int i;
5101
  int i;
5605
  boolean r = false;
5102
  boolean r = false;
5606
  neighbor_rec nb;
5103
  neighbor_rec nb;
5607
  int o_count = 0, bond_count = 0;
5104
  int o_count = 0, bond_count = 0;
5608
 
5105
 
5609
  memset (nb, 0, sizeof (neighbor_rec));
5106
  memset (nb, 0, sizeof (neighbor_rec));
5610
  if (!
-
 
5611
      (atom[a_view - 1].
5107
  if (!(atom[a_view - 1].
5612
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5108
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5613
    return false;
5109
    return false;
5614
  if (strcmp (atom[a_ref - 1].element, "N ")
5110
  if (strcmp (atom[a_ref - 1].element, "N ")
5615
      || atom[a_ref - 1].neighbor_count != 3)
5111
      || atom[a_ref - 1].neighbor_count != 3)
5616
    return false;
5112
    return false;
5617
  get_nextneighbors (nb, a_ref, a_view);
5113
  get_nextneighbors (nb, a_ref, a_view);
5618
  for (i = 0; i <= 1; i++)
5114
  for (i = 0; i <= 1; i++) {
5619
    {
-
 
5620
      if (!strcmp (atom[nb[i] - 1].element, "O "))
5115
    if (!strcmp (atom[nb[i] - 1].element, "O "))
5621
        o_count++;
5116
            o_count++;
5622
      if (bond[get_bond (a_ref, nb[i]) - 1].btype == 'S')
5117
    if (bond[get_bond (a_ref, nb[i]) - 1].btype == 'S')
5623
        bond_count++;
5118
            bond_count++;
5624
      if (bond[get_bond (a_ref, nb[i]) - 1].btype == 'D')
5119
    if (bond[get_bond (a_ref, nb[i]) - 1].btype == 'D')
5625
        bond_count += 2;
5120
            bond_count += 2;
5626
    }
5121
  }
5627
  if (o_count == 2 && bond_count >= 3)
5122
  if (o_count == 2 && bond_count >= 3)
5628
    r = true;
5123
    r = true;
5629
  return r;
5124
  return r;
5630
}
5125
}
5631
 
5126
 
5632
 
-
 
5633
static boolean
-
 
5634
is_azido (a_view, a_ref)
5127
static boolean is_azido (a_view, a_ref)
5635
     int a_view, a_ref;
5128
     int a_view, a_ref;
5636
{
5129
{
5637
  boolean r = false;
5130
  boolean r = false;
5638
  neighbor_rec nb;
5131
  neighbor_rec nb;
5639
  int bond_count = 0, n1 = 0, n2 = 0, n3 = 0;
5132
  int bond_count = 0, n1 = 0, n2 = 0, n3 = 0;
5640
 
5133
 
5641
  if (!
-
 
5642
      (atom[a_view - 1].
5134
  if (!(atom[a_view - 1].
5643
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5135
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5644
    return false;
5136
    return false;
5645
  if (strcmp (atom[a_ref - 1].element, "N ")
5137
  if (strcmp (atom[a_ref - 1].element, "N ")
5646
      || atom[a_ref - 1].neighbor_count != 2)
5138
      || atom[a_ref - 1].neighbor_count != 2)
5647
    return false;
5139
    return false;
5648
  n1 = a_ref;
5140
  n1 = a_ref;
5649
  memset (nb, 0, sizeof (neighbor_rec));
5141
  memset (nb, 0, sizeof (neighbor_rec));
5650
  get_nextneighbors (nb, n1, a_view);
5142
  get_nextneighbors (nb, n1, a_view);
5651
  if (!strcmp (atom[nb[0] - 1].element, "N "))
5143
  if (!strcmp (atom[nb[0] - 1].element, "N ")) {
5652
    {
-
 
5653
      n2 = nb[0];
5144
    n2 = nb[0];
5654
      if (bond[get_bond (n1, n2) - 1].btype == 'S')
5145
    if (bond[get_bond (n1, n2) - 1].btype == 'S')
5655
        bond_count++;
-
 
5656
      if (bond[get_bond (n1, n2) - 1].btype == 'D')
-
 
5657
        bond_count += 2;
-
 
5658
      if (bond[get_bond (n1, n2) - 1].btype == 'T')
-
 
5659
        bond_count += 3;
-
 
5660
    }
-
 
5661
  if (n2 > 0 && atom[n2 - 1].neighbor_count == 2)
-
 
5662
    {
-
 
5663
      memset (nb, 0, sizeof (neighbor_rec));
-
 
5664
      get_nextneighbors (nb, n2, n1);
-
 
5665
      if (!strcmp (atom[nb[0] - 1].element, "N "))
-
 
5666
        {
-
 
5667
          n3 = nb[0];
-
 
5668
          if (bond[get_bond (n2, n3) - 1].btype == 'S')
-
 
5669
            bond_count++;
5146
            bond_count++;
5670
          if (bond[get_bond (n2, n3) - 1].btype == 'D')
5147
    if (bond[get_bond (n1, n2) - 1].btype == 'D')
5671
            bond_count += 2;
5148
            bond_count += 2;
5672
          if (bond[get_bond (n2, n3) - 1].btype == 'T')
5149
    if (bond[get_bond (n1, n2) - 1].btype == 'T')
5673
            bond_count += 3;
5150
            bond_count += 3;
-
 
5151
  }
-
 
5152
  if (n2 > 0 && atom[n2 - 1].neighbor_count == 2) {
-
 
5153
    memset (nb, 0, sizeof (neighbor_rec));
-
 
5154
    get_nextneighbors (nb, n2, n1);
-
 
5155
    if (!strcmp (atom[nb[0] - 1].element, "N ")){
-
 
5156
            n3 = nb[0];
-
 
5157
            if (bond[get_bond (n2, n3) - 1].btype == 'S')
-
 
5158
              bond_count++;
-
 
5159
            if (bond[get_bond (n2, n3) - 1].btype == 'D')
-
 
5160
              bond_count += 2;
-
 
5161
            if (bond[get_bond (n2, n3) - 1].btype == 'T')
-
 
5162
              bond_count += 3;
5674
        }
5163
          }
5675
    }
5164
  }
5676
  if (n1 > 0 && n2 > 0 && n3 > 0 && atom[n3 - 1].neighbor_count == 1 &&
5165
  if (n1 > 0 && n2 > 0 && n3 > 0 && atom[n3 - 1].neighbor_count == 1 &&
5677
      bond_count > 3)
5166
      bond_count > 3)
5678
    r = true;
5167
    r = true;
5679
  return r;
5168
  return r;
5680
}
5169
}
5681
 
5170
 
5682
 
-
 
5683
static boolean
-
 
5684
is_diazonium (a_view, a_ref)
5171
static boolean is_diazonium (a_view, a_ref)
5685
     int a_view, a_ref;
5172
     int a_view, a_ref;
5686
{
5173
{
5687
  boolean r = false;
5174
  boolean r = false;
5688
  neighbor_rec nb;
5175
  neighbor_rec nb;
5689
  int bond_count = 0, chg_count = 0, n1 = 0, n2 = 0;
5176
  int bond_count = 0, chg_count = 0, n1 = 0, n2 = 0;
5690
 
5177
 
5691
  if (!
-
 
5692
      (atom[a_view - 1].
5178
  if (!(atom[a_view - 1].
5693
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5179
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5694
    return false;
5180
    return false;
5695
  if (strcmp (atom[a_ref - 1].element, "N ")
5181
  if (strcmp (atom[a_ref - 1].element, "N ")
5696
      || atom[a_ref - 1].neighbor_count != 2)
5182
      || atom[a_ref - 1].neighbor_count != 2)
5697
    return false;
5183
    return false;
5698
  n1 = a_ref;
5184
  n1 = a_ref;
5699
  chg_count = atom[n1 - 1].formal_charge;
5185
  chg_count = atom[n1 - 1].formal_charge;
5700
  memset (nb, 0, sizeof (neighbor_rec));
5186
  memset (nb, 0, sizeof (neighbor_rec));
5701
  get_nextneighbors (nb, n1, a_view);
5187
  get_nextneighbors (nb, n1, a_view);
5702
  if (!strcmp (atom[nb[0] - 1].element, "N "))
5188
  if (!strcmp (atom[nb[0] - 1].element, "N ")) {
5703
    {
-
 
5704
      n2 = nb[0];
5189
    n2 = nb[0];
5705
      chg_count += atom[n2 - 1].formal_charge;
5190
    chg_count += atom[n2 - 1].formal_charge;
5706
      if (bond[get_bond (n1, n2) - 1].btype == 'S')
5191
    if (bond[get_bond (n1, n2) - 1].btype == 'S')
5707
        bond_count++;
5192
            bond_count++;
5708
      if (bond[get_bond (n1, n2) - 1].btype == 'D')
5193
    if (bond[get_bond (n1, n2) - 1].btype == 'D')
5709
        bond_count += 2;
5194
            bond_count += 2;
5710
      if (bond[get_bond (n1, n2) - 1].btype == 'T')
5195
    if (bond[get_bond (n1, n2) - 1].btype == 'T')
5711
        bond_count += 3;
5196
            bond_count += 3;
5712
    }
5197
  }
5713
  if (n1 > 0 && n2 > 0 && atom[n2 - 1].neighbor_count == 1
5198
  if (n1 > 0 && n2 > 0 && atom[n2 - 1].neighbor_count == 1
5714
      && bond_count >= 2 && chg_count > 0)
5199
      && bond_count >= 2 && chg_count > 0)
5715
    r = true;
5200
    r = true;
-
 
5201
  return r;
-
 
5202
}
-
 
5203
 
-
 
5204
static boolean is_hydroximino_C (id)
-
 
5205
     int id;
-
 
5206
{
-
 
5207
  int i;
-
 
5208
  boolean r = false;
-
 
5209
  neighbor_rec nb;
-
 
5210
  int a_het = 0;
-
 
5211
  int FORLIM;
-
 
5212
 
-
 
5213
  memset (nb, 0, sizeof (neighbor_rec));
-
 
5214
  if (id < 1 || id > n_atoms)
-
 
5215
    return false;
-
 
5216
  get_neighbors (nb, id);
-
 
5217
  if (strcmp (atom[id - 1].element, "C ") || atom[id - 1].neighbor_count <= 0)
-
 
5218
    return false;
-
 
5219
  FORLIM = atom[id - 1].neighbor_count;
-
 
5220
  for (i = 0; i < FORLIM; i++) {
-
 
5221
    if ((bond[get_bond (id, nb[i]) - 1].btype == 'D' &&
-
 
5222
              !strcmp (atom[nb[i] - 1].element, "N ")) && (hetbond_count (nb[i]) == 3))
-
 
5223
            a_het = nb[i];
-
 
5224
  }
-
 
5225
  if (a_het <= 0)
-
 
5226
    return false;
-
 
5227
  memset (nb, 0, sizeof (neighbor_rec));
-
 
5228
  get_neighbors (nb, a_het);
-
 
5229
  if (strcmp (atom[a_het - 1].element, "N ")
-
 
5230
      || atom[a_het - 1].neighbor_count <= 0)
-
 
5231
    return false;
-
 
5232
  FORLIM = atom[a_het - 1].neighbor_count;
-
 
5233
  for (i = 0; i < FORLIM; i++) {
-
 
5234
    if (is_hydroxy (a_het, nb[i]))
-
 
5235
          r = true;
-
 
5236
  }
5716
  return r;
5237
  return r;
5717
}
5238
}
5718
 
5239
 
5719
 
-
 
5720
static boolean
-
 
5721
is_hydroximino_C (id)
5240
static boolean is_hydrazono_C (id)
5722
     int id;
5241
     int id;
5723
{
5242
{
5724
  int i;
5243
  int i;
5725
  boolean r = false;
5244
  boolean r = false;
5726
  neighbor_rec nb;
5245
  neighbor_rec nb;
5727
  int a_het = 0;
5246
  int a_het = 0;
5728
  int FORLIM;
5247
  int FORLIM;
5729
 
5248
 
5730
  memset (nb, 0, sizeof (neighbor_rec));
5249
  memset (nb, 0, sizeof (neighbor_rec));
5731
  if (id < 1 || id > n_atoms)
5250
  if (id < 1 || id > n_atoms)
5732
    return false;
5251
    return false;
5733
  get_neighbors (nb, id);
5252
  get_neighbors (nb, id);
5734
  if (strcmp (atom[id - 1].element, "C ") || atom[id - 1].neighbor_count <= 0)
5253
  if (strcmp (atom[id - 1].element, "C ") || atom[id - 1].neighbor_count <= 0)
5735
    return false;
5254
    return false;
5736
  FORLIM = atom[id - 1].neighbor_count;
5255
  FORLIM = atom[id - 1].neighbor_count;
5737
  for (i = 0; i < FORLIM; i++)
5256
  for (i = 0; i < FORLIM; i++) {
5738
    {
-
 
5739
      if ((bond[get_bond (id, nb[i]) - 1].btype == 'D' &&
5257
    if (bond[get_bond (id, nb[i]) - 1].btype == 'D' &&
5740
           !strcmp (atom[nb[i] - 1].element,
5258
              !strcmp (atom[nb[i] - 1].element, "N ")) {
-
 
5259
          /* and
5741
                    "N ")) && (hetbond_count (nb[i]) == 3))
5260
             (hetbond_count(nb[i]) = 3)  */
5742
        a_het = nb[i];
5261
          a_het = nb[i];
5743
    }
5262
          }
-
 
5263
  }
5744
  if (a_het <= 0)
5264
  if (a_het <= 0)
5745
    return false;
5265
    return false;
5746
  memset (nb, 0, sizeof (neighbor_rec));
5266
  memset (nb, 0, sizeof (neighbor_rec));
5747
  get_neighbors (nb, a_het);
5267
  get_neighbors (nb, a_het);
5748
  if (strcmp (atom[a_het - 1].element, "N ")
5268
  if (strcmp (atom[a_het - 1].element, "N ")
5749
      || atom[a_het - 1].neighbor_count <= 0)
5269
      || atom[a_het - 1].neighbor_count <= 0)
5750
    return false;
5270
    return false;
5751
  FORLIM = atom[a_het - 1].neighbor_count;
5271
  FORLIM = atom[a_het - 1].neighbor_count;
5752
  for (i = 0; i < FORLIM; i++)
5272
  for (i = 0; i < FORLIM; i++) {
-
 
5273
    if (is_amino (a_het, nb[i]) || is_alkylamino (a_het, nb[i]) |
-
 
5274
              is_alkylarylamino (a_het, nb[i]) || is_arylamino (a_het, nb[i]) |
-
 
5275
              is_dialkylamino (a_het, nb[i]) || is_diarylamino (a_het, nb[i]))
-
 
5276
            r = true;
-
 
5277
  }
-
 
5278
  return r;
-
 
5279
}
-
 
5280
 
-
 
5281
static boolean is_alkoxycarbonyl (a_view, a_ref)
-
 
5282
     int a_view, a_ref;
-
 
5283
{
-
 
5284
  int i;
-
 
5285
  boolean r = false;
-
 
5286
  neighbor_rec nb;
-
 
5287
 
-
 
5288
  memset (nb, 0, sizeof (neighbor_rec));
-
 
5289
  if (!(atom[a_view - 1].heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
-
 
5290
    return false;
-
 
5291
  if (!(is_oxo_C (a_ref) && atom[a_ref - 1].neighbor_count == 3))
-
 
5292
    return false;
-
 
5293
  get_nextneighbors (nb, a_ref, a_view);
-
 
5294
  for (i = 0; i <= 1; i++) {
-
 
5295
    if (is_alkoxy (a_ref, nb[i]))
-
 
5296
            r = true;
-
 
5297
  }
-
 
5298
  return r;
-
 
5299
}
-
 
5300
 
-
 
5301
static boolean is_aryloxycarbonyl (a_view, a_ref)
-
 
5302
     int a_view, a_ref;
-
 
5303
{
-
 
5304
  int i;
-
 
5305
  boolean r = false;
-
 
5306
  neighbor_rec nb;
-
 
5307
 
-
 
5308
  memset (nb, 0, sizeof (neighbor_rec));
-
 
5309
  if (!(atom[a_view - 1].
-
 
5310
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
-
 
5311
    return false;
-
 
5312
  if (!(is_oxo_C (a_ref) && atom[a_ref - 1].neighbor_count == 3))
-
 
5313
    return false;
-
 
5314
  get_nextneighbors (nb, a_ref, a_view);
-
 
5315
  for (i = 0; i <= 1; i++) {
-
 
5316
    if (is_aryloxy (a_ref, nb[i]))
-
 
5317
            r = true;
-
 
5318
  }
-
 
5319
  return r;
-
 
5320
}
-
 
5321
 
-
 
5322
static boolean is_carbamoyl (a_view, a_ref)
-
 
5323
     int a_view, a_ref;
-
 
5324
{
-
 
5325
  int i;
-
 
5326
  boolean r = false;
-
 
5327
  neighbor_rec nb;
-
 
5328
 
-
 
5329
  memset (nb, 0, sizeof (neighbor_rec));
-
 
5330
  if (!(atom[a_view - 1].
-
 
5331
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
-
 
5332
    return false;
-
 
5333
  if (!(is_oxo_C (a_ref) && atom[a_ref - 1].neighbor_count == 3))
-
 
5334
    return false;
-
 
5335
  get_nextneighbors (nb, a_ref, a_view);
-
 
5336
  for (i = 0; i <= 1; i++) {
-
 
5337
    if (!strcmp (atom[nb[i] - 1].atype, "N3 ") || !strcmp (atom[nb[i] - 1].atype, "NAM"))
-
 
5338
            r = true;
-
 
5339
  }
-
 
5340
  return r;
-
 
5341
}
-
 
5342
 
-
 
5343
static boolean is_alkoxythiocarbonyl (a_view, a_ref)
-
 
5344
     int a_view, a_ref;
-
 
5345
{
-
 
5346
  int i;
-
 
5347
  boolean r = false;
-
 
5348
  neighbor_rec nb;
-
 
5349
 
-
 
5350
  memset (nb, 0, sizeof (neighbor_rec));
-
 
5351
  if (!(atom[a_view - 1].heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
-
 
5352
    return false;
-
 
5353
  if (!(is_thioxo_C (a_ref) && atom[a_ref - 1].neighbor_count == 3))
-
 
5354
    return false;
-
 
5355
  get_nextneighbors (nb, a_ref, a_view);
-
 
5356
  for (i = 0; i <= 1; i++) {
-
 
5357
    if (is_alkoxy (a_ref, nb[i]))
-
 
5358
            r = true;
5753
    {
5359
  }
-
 
5360
  return r;
-
 
5361
}
-
 
5362
 
-
 
5363
static boolean is_aryloxythiocarbonyl (a_view, a_ref)
-
 
5364
     int a_view, a_ref;
-
 
5365
{
-
 
5366
  int i;
-
 
5367
  boolean r = false;
-
 
5368
  neighbor_rec nb;
-
 
5369
 
-
 
5370
  memset (nb, 0, sizeof (neighbor_rec));
-
 
5371
  if (!(atom[a_view - 1].heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
-
 
5372
    return false;
-
 
5373
  if (!(is_thioxo_C (a_ref) && atom[a_ref - 1].neighbor_count == 3))
-
 
5374
    return false;
-
 
5375
  get_nextneighbors (nb, a_ref, a_view);
-
 
5376
  for (i = 0; i <= 1; i++) {
5754
      if (is_hydroxy (a_het, nb[i]))
5377
    if (is_aryloxy (a_ref, nb[i]))
5755
        r = true;
5378
            r = true;
5756
    }
5379
  }
5757
  return r;
5380
  return r;
5758
}
5381
}
5759
 
5382
 
5760
 
-
 
5761
static boolean
5383
static boolean is_thiocarbamoyl (a_view, a_ref)
5762
is_hydrazono_C (id)
-
 
5763
     int id;
5384
     int a_view, a_ref;
5764
{
5385
{
5765
  int i;
5386
  int i;
5766
  boolean r = false;
5387
  boolean r = false;
5767
  neighbor_rec nb;
5388
  neighbor_rec nb;
5768
  int a_het = 0;
5389
 
5769
  int FORLIM;
5390
  memset (nb, 0, sizeof (neighbor_rec));
5770
 
5391
  if (!(atom[a_view - 1].
5771
  memset (nb, 0, sizeof (neighbor_rec));
5392
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5772
  if (id < 1 || id > n_atoms)
5393
    return false;
5773
    return false;
5394
  if (!(is_thioxo_C (a_ref) && atom[a_ref - 1].neighbor_count == 3))
5774
  get_neighbors (nb, id);
5395
    return false;
5775
  if (strcmp (atom[id - 1].element, "C ") || atom[id - 1].neighbor_count <= 0)
5396
  get_nextneighbors (nb, a_ref, a_view);
5776
    return false;
5397
  for (i = 0; i <= 1; i++) {
5777
  FORLIM = atom[id - 1].neighbor_count;
5398
    if (!strcmp (atom[nb[i] - 1].atype, "N3 ") ||
5778
  for (i = 0; i < FORLIM; i++)
5399
              !strcmp (atom[nb[i] - 1].atype, "NAM"))
5779
    {
5400
            r = true;
5780
      if (bond[get_bond (id, nb[i]) - 1].btype == 'D' &&
5401
  }
5781
          !strcmp (atom[nb[i] - 1].element, "N "))
5402
  return r;
5782
        {
5403
}
5783
          /* and
5404
 
5784
             (hetbond_count(nb[i]) = 3)  */
5405
static boolean is_alkanoyl (a_view, a_ref)
5785
          a_het = nb[i];
5406
     int a_view, a_ref;
5786
        }
5407
{
5787
    }
5408
  int i;
5788
  if (a_het <= 0)
5409
  boolean r = false;
5789
    return false;
5410
  neighbor_rec nb;
5790
  memset (nb, 0, sizeof (neighbor_rec));
5411
 
5791
  get_neighbors (nb, a_het);
5412
  memset (nb, 0, sizeof (neighbor_rec));
5792
  if (strcmp (atom[a_het - 1].element, "N ")
5413
  if (!(atom[a_view - 1].
5793
      || atom[a_het - 1].neighbor_count <= 0)
5414
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5794
    return false;
5415
    return false;
5795
  FORLIM = atom[a_het - 1].neighbor_count;
5416
  if (!(is_oxo_C (a_ref) && atom[a_ref - 1].neighbor_count == 3))
5796
  for (i = 0; i < FORLIM; i++)
5417
    return false;
5797
    {
5418
  get_nextneighbors (nb, a_ref, a_view);
5798
      if (is_amino (a_het, nb[i]) || is_alkylamino (a_het, nb[i]) |
5419
  for (i = 0; i <= 1; i++) {
5799
          is_alkylarylamino (a_het, nb[i]) || is_arylamino (a_het, nb[i]) |
5420
    if (is_alkyl (a_ref, nb[i]))
5800
          is_dialkylamino (a_het, nb[i]) || is_diarylamino (a_het, nb[i]))
5421
            r = true;
5801
        r = true;
5422
  }
5802
    }
5423
  return r;
5803
  return r;
5424
}
5804
}
5425
 
5805
 
5426
static boolean is_aroyl (a_view, a_ref)
5806
 
5427
     int a_view, a_ref;
5807
static boolean
5428
{
5808
is_alkoxycarbonyl (a_view, a_ref)
5429
  int i;
5809
     int a_view, a_ref;
5430
  boolean r = false;
5810
{
5431
  neighbor_rec nb;
5811
  int i;
5432
 
5812
  boolean r = false;
5433
  memset (nb, 0, sizeof (neighbor_rec));
5813
  neighbor_rec nb;
5434
  if (!(atom[a_view - 1].
5814
 
5435
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5815
  memset (nb, 0, sizeof (neighbor_rec));
5436
    return false;
5816
  if (!
5437
  if (!(is_oxo_C (a_ref) && atom[a_ref - 1].neighbor_count == 3))
5817
      (atom[a_view - 1].
5438
    return false;
5818
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5439
  get_nextneighbors (nb, a_ref, a_view);
5819
    return false;
5440
  for (i = 0; i <= 1; i++) {
5820
  if (!(is_oxo_C (a_ref) && atom[a_ref - 1].neighbor_count == 3))
5441
    if (is_aryl (a_ref, nb[i]))
5821
    return false;
5442
            r = true;
5822
  get_nextneighbors (nb, a_ref, a_view);
5443
  }
5823
  for (i = 0; i <= 1; i++)
5444
  return r;
5824
    {
5445
}
5825
      if (is_alkoxy (a_ref, nb[i]))
5446
 
5826
        r = true;
5447
static boolean is_acyl (a_view, a_ref)
5827
    }
5448
     int a_view, a_ref;
5828
  return r;
5449
{
5829
}
5450
  boolean r = false;
5830
 
5451
 
5831
 
-
 
5832
static boolean
-
 
5833
is_aryloxycarbonyl (a_view, a_ref)
-
 
5834
     int a_view, a_ref;
-
 
5835
{
-
 
5836
  int i;
-
 
5837
  boolean r = false;
-
 
5838
  neighbor_rec nb;
-
 
5839
 
-
 
5840
  memset (nb, 0, sizeof (neighbor_rec));
-
 
5841
  if (!
-
 
5842
      (atom[a_view - 1].
-
 
5843
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
-
 
5844
    return false;
-
 
5845
  if (!(is_oxo_C (a_ref) && atom[a_ref - 1].neighbor_count == 3))
-
 
5846
    return false;
-
 
5847
  get_nextneighbors (nb, a_ref, a_view);
-
 
5848
  for (i = 0; i <= 1; i++)
-
 
5849
    {
-
 
5850
      if (is_aryloxy (a_ref, nb[i]))
-
 
5851
        r = true;
-
 
5852
    }
-
 
5853
  return r;
-
 
5854
}
-
 
5855
 
-
 
5856
 
-
 
5857
static boolean
-
 
5858
is_carbamoyl (a_view, a_ref)
-
 
5859
     int a_view, a_ref;
-
 
5860
{
-
 
5861
  int i;
-
 
5862
  boolean r = false;
-
 
5863
  neighbor_rec nb;
-
 
5864
 
-
 
5865
  memset (nb, 0, sizeof (neighbor_rec));
-
 
5866
  if (!
-
 
5867
      (atom[a_view - 1].
-
 
5868
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
-
 
5869
    return false;
-
 
5870
  if (!(is_oxo_C (a_ref) && atom[a_ref - 1].neighbor_count == 3))
-
 
5871
    return false;
-
 
5872
  get_nextneighbors (nb, a_ref, a_view);
-
 
5873
  for (i = 0; i <= 1; i++)
-
 
5874
    {
-
 
5875
      if (!strcmp (atom[nb[i] - 1].atype, "N3 ") ||
-
 
5876
          !strcmp (atom[nb[i] - 1].atype, "NAM"))
-
 
5877
        r = true;
-
 
5878
    }
-
 
5879
  return r;
-
 
5880
}
-
 
5881
 
-
 
5882
 
-
 
5883
static boolean
-
 
5884
is_alkoxythiocarbonyl (a_view, a_ref)
-
 
5885
     int a_view, a_ref;
-
 
5886
{
-
 
5887
  int i;
-
 
5888
  boolean r = false;
-
 
5889
  neighbor_rec nb;
-
 
5890
 
-
 
5891
  memset (nb, 0, sizeof (neighbor_rec));
-
 
5892
  if (!
-
 
5893
      (atom[a_view - 1].
-
 
5894
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
-
 
5895
    return false;
-
 
5896
  if (!(is_thioxo_C (a_ref) && atom[a_ref - 1].neighbor_count == 3))
-
 
5897
    return false;
-
 
5898
  get_nextneighbors (nb, a_ref, a_view);
-
 
5899
  for (i = 0; i <= 1; i++)
-
 
5900
    {
-
 
5901
      if (is_alkoxy (a_ref, nb[i]))
-
 
5902
        r = true;
-
 
5903
    }
-
 
5904
  return r;
-
 
5905
}
-
 
5906
 
-
 
5907
 
-
 
5908
static boolean
-
 
5909
is_aryloxythiocarbonyl (a_view, a_ref)
-
 
5910
     int a_view, a_ref;
-
 
5911
{
-
 
5912
  int i;
-
 
5913
  boolean r = false;
-
 
5914
  neighbor_rec nb;
-
 
5915
 
-
 
5916
  memset (nb, 0, sizeof (neighbor_rec));
-
 
5917
  if (!
-
 
5918
      (atom[a_view - 1].
-
 
5919
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
-
 
5920
    return false;
-
 
5921
  if (!(is_thioxo_C (a_ref) && atom[a_ref - 1].neighbor_count == 3))
-
 
5922
    return false;
-
 
5923
  get_nextneighbors (nb, a_ref, a_view);
-
 
5924
  for (i = 0; i <= 1; i++)
-
 
5925
    {
-
 
5926
      if (is_aryloxy (a_ref, nb[i]))
-
 
5927
        r = true;
-
 
5928
    }
-
 
5929
  return r;
-
 
5930
}
-
 
5931
 
-
 
5932
 
-
 
5933
static boolean
-
 
5934
is_thiocarbamoyl (a_view, a_ref)
-
 
5935
     int a_view, a_ref;
-
 
5936
{
-
 
5937
  int i;
-
 
5938
  boolean r = false;
-
 
5939
  neighbor_rec nb;
-
 
5940
 
-
 
5941
  memset (nb, 0, sizeof (neighbor_rec));
-
 
5942
  if (!
-
 
5943
      (atom[a_view - 1].
-
 
5944
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
-
 
5945
    return false;
-
 
5946
  if (!(is_thioxo_C (a_ref) && atom[a_ref - 1].neighbor_count == 3))
-
 
5947
    return false;
-
 
5948
  get_nextneighbors (nb, a_ref, a_view);
-
 
5949
  for (i = 0; i <= 1; i++)
-
 
5950
    {
-
 
5951
      if (!strcmp (atom[nb[i] - 1].atype, "N3 ") ||
-
 
5952
          !strcmp (atom[nb[i] - 1].atype, "NAM"))
-
 
5953
        r = true;
-
 
5954
    }
-
 
5955
  return r;
-
 
5956
}
-
 
5957
 
-
 
5958
 
-
 
5959
static boolean
-
 
5960
is_alkanoyl (a_view, a_ref)
-
 
5961
     int a_view, a_ref;
-
 
5962
{
-
 
5963
  int i;
-
 
5964
  boolean r = false;
-
 
5965
  neighbor_rec nb;
-
 
5966
 
-
 
5967
  memset (nb, 0, sizeof (neighbor_rec));
-
 
5968
  if (!
-
 
5969
      (atom[a_view - 1].
-
 
5970
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
-
 
5971
    return false;
-
 
5972
  if (!(is_oxo_C (a_ref) && atom[a_ref - 1].neighbor_count == 3))
-
 
5973
    return false;
-
 
5974
  get_nextneighbors (nb, a_ref, a_view);
-
 
5975
  for (i = 0; i <= 1; i++)
-
 
5976
    {
-
 
5977
      if (is_alkyl (a_ref, nb[i]))
-
 
5978
        r = true;
-
 
5979
    }
-
 
5980
  return r;
-
 
5981
}
-
 
5982
 
-
 
5983
 
-
 
5984
static boolean
-
 
5985
is_aroyl (a_view, a_ref)
-
 
5986
     int a_view, a_ref;
-
 
5987
{
-
 
5988
  int i;
-
 
5989
  boolean r = false;
-
 
5990
  neighbor_rec nb;
-
 
5991
 
-
 
5992
  memset (nb, 0, sizeof (neighbor_rec));
-
 
5993
  if (!
-
 
5994
      (atom[a_view - 1].
-
 
5995
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
-
 
5996
    return false;
-
 
5997
  if (!(is_oxo_C (a_ref) && atom[a_ref - 1].neighbor_count == 3))
-
 
5998
    return false;
-
 
5999
  get_nextneighbors (nb, a_ref, a_view);
-
 
6000
  for (i = 0; i <= 1; i++)
-
 
6001
    {
-
 
6002
      if (is_aryl (a_ref, nb[i]))
-
 
6003
        r = true;
-
 
6004
    }
-
 
6005
  return r;
-
 
6006
}
-
 
6007
 
-
 
6008
 
-
 
6009
static boolean
-
 
6010
is_acyl (a_view, a_ref)
-
 
6011
     int a_view, a_ref;
-
 
6012
{
-
 
6013
  boolean r = false;
-
 
6014
 
-
 
6015
  if (is_alkanoyl (a_view, a_ref) || is_aroyl (a_view, a_ref))
5452
  if (is_alkanoyl (a_view, a_ref) || is_aroyl (a_view, a_ref))
6016
    r = true;
5453
    r = true;
6017
  return r;
5454
  return r;
6018
}
5455
}
6019
 
5456
 
6020
 
-
 
6021
static boolean
-
 
6022
is_acyl_gen (a_view, a_ref)
5457
static boolean is_acyl_gen (a_view, a_ref)
6023
     int a_view, a_ref;
5458
     int a_view, a_ref;
6024
{
5459
{
6025
  /* new in v0.3j */
5460
  /* new in v0.3j */
6026
  boolean r = false;
5461
  boolean r = false;
6027
 
5462
 
6028
  if (is_oxo_C (a_ref))
5463
  if (is_oxo_C (a_ref))
6029
    r = true;
5464
    r = true;
6030
  return r;
5465
  return r;
6031
}
5466
}
6032
 
-
 
6033
 
5467
 
6034
static boolean
-
 
6035
is_acylamino (a_view, a_ref)
5468
static boolean is_acylamino (a_view, a_ref)
6036
     int a_view, a_ref;
5469
     int a_view, a_ref;
6037
{
5470
{
6038
  boolean r = false;
5471
  boolean r = false;
6039
  neighbor_rec nb;
5472
  neighbor_rec nb;
6040
  int acyl_count = 0;
5473
  int acyl_count = 0;
6041
 
5474
 
6042
  memset (nb, 0, sizeof (neighbor_rec));
5475
  memset (nb, 0, sizeof (neighbor_rec));
6043
  if (!
-
 
6044
      (atom[a_view - 1].
5476
  if (!(atom[a_view - 1].
6045
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5477
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
6046
    return false;
5478
    return false;
6047
  if (strcmp (atom[a_ref - 1].element, "N ")
5479
  if (strcmp (atom[a_ref - 1].element, "N ")
6048
      || atom[a_ref - 1].neighbor_count != 2)
5480
      || atom[a_ref - 1].neighbor_count != 2)
6049
    return false;
5481
    return false;
6050
  get_nextneighbors (nb, a_ref, a_view);
5482
  get_nextneighbors (nb, a_ref, a_view);
6051
  if (is_acyl (a_ref, nb[0]))
5483
  if (is_acyl (a_ref, nb[0]))
6052
    acyl_count++;
5484
    acyl_count++;
6053
  if (acyl_count == 1)
5485
  if (acyl_count == 1)
6054
    r = true;
5486
    r = true;
6055
  return r;
5487
  return r;
6056
}
5488
}
6057
 
5489
 
6058
 
-
 
6059
static boolean
-
 
6060
is_subst_acylamino (a_view, a_ref)
5490
static boolean is_subst_acylamino (a_view, a_ref)
6061
     int a_view, a_ref;
5491
     int a_view, a_ref;
6062
{
5492
{
6063
  /* may be substituted _or_ unsubstituted acylamino group! */
5493
  /* may be substituted _or_ unsubstituted acylamino group! */
6064
  int i;
5494
  int i;
6065
  boolean r = false;
5495
  boolean r = false;
6066
  neighbor_rec nb;
5496
  neighbor_rec nb;
6067
  int acyl_count = 0;
5497
  int acyl_count = 0;
6068
  int FORLIM;
5498
  int FORLIM;
6069
 
5499
 
6070
  memset (nb, 0, sizeof (neighbor_rec));
5500
  memset (nb, 0, sizeof (neighbor_rec));
6071
  if (!
-
 
6072
      (atom[a_view - 1].
5501
  if (!(atom[a_view - 1].
6073
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5502
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
6074
    return false;
5503
    return false;
6075
  if (strcmp (atom[a_ref - 1].element, "N ")
5504
  if (strcmp (atom[a_ref - 1].element, "N ")
6076
      || atom[a_ref - 1].neighbor_count < 2)
5505
      || atom[a_ref - 1].neighbor_count < 2)
6077
    return false;
5506
    return false;
6078
  get_nextneighbors (nb, a_ref, a_view);
5507
  get_nextneighbors (nb, a_ref, a_view);
6079
  FORLIM = atom[a_ref - 1].neighbor_count - 2;
5508
  FORLIM = atom[a_ref - 1].neighbor_count - 2;
6080
  for (i = 0; i <= FORLIM; i++)
5509
  for (i = 0; i <= FORLIM; i++) {
6081
    {
-
 
6082
      if (is_acyl_gen (a_ref, nb[i]))   /* v0.3j */
5510
    if (is_acyl_gen (a_ref, nb[i]))     /* v0.3j */
6083
        acyl_count++;
5511
            acyl_count++;
6084
    }
5512
  }
6085
  if (acyl_count > 0)
5513
  if (acyl_count > 0)
6086
    r = true;
5514
    r = true;
6087
  return r;
5515
  return r;
6088
}
5516
}
6089
 
5517
 
6090
 
-
 
6091
static boolean
-
 
6092
is_hydrazino (a_view, a_ref)
5518
static boolean is_hydrazino (a_view, a_ref)
6093
     int a_view, a_ref;
5519
     int a_view, a_ref;
6094
{
5520
{
6095
  int i;
5521
  int i;
6096
  boolean r = false;
5522
  boolean r = false;
6097
  neighbor_rec nb;
5523
  neighbor_rec nb;
6098
  int nr_count = 0;
5524
  int nr_count = 0;
6099
  int FORLIM;
5525
  int FORLIM;
6100
 
5526
 
6101
  memset (nb, 0, sizeof (neighbor_rec));
5527
  memset (nb, 0, sizeof (neighbor_rec));
6102
  if (!
-
 
6103
      (atom[a_view - 1].
5528
  if (!(atom[a_view - 1].
6104
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5529
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
6105
    return false;
5530
    return false;
6106
  if (strcmp (atom[a_ref - 1].element, "N ")
5531
  if (strcmp (atom[a_ref - 1].element, "N ")
6107
      || atom[a_ref - 1].neighbor_count < 2)
5532
      || atom[a_ref - 1].neighbor_count < 2)
6108
    return false;
5533
    return false;
6109
  get_nextneighbors (nb, a_ref, a_view);
5534
  get_nextneighbors (nb, a_ref, a_view);
6110
  FORLIM = atom[a_ref - 1].neighbor_count - 2;
5535
  FORLIM = atom[a_ref - 1].neighbor_count - 2;
6111
  for (i = 0; i <= FORLIM; i++)
5536
  for (i = 0; i <= FORLIM; i++) {                               /* fixed in v0.3c */
6112
    {                           /* fixed in v0.3c */
-
 
6113
      if (is_amino (a_ref, nb[i]) || is_subst_amino (a_ref, nb[i]))
5537
    if (is_amino (a_ref, nb[i]) || is_subst_amino (a_ref, nb[i]))
6114
        nr_count++;
5538
            nr_count++;
6115
    }
5539
  }
6116
  if (nr_count == 1)
5540
  if (nr_count == 1)
6117
    r = true;
5541
    r = true;
6118
  return r;
5542
  return r;
6119
}
5543
}
6120
 
5544
 
6121
 
-
 
6122
static boolean
-
 
6123
is_nitroso (a_view, a_ref)
5545
static boolean is_nitroso (a_view, a_ref)
6124
     int a_view, a_ref;
5546
     int a_view, a_ref;
6125
{
5547
{
6126
  /* new in v0.3j */
5548
  /* new in v0.3j */
6127
  boolean r = false;
5549
  boolean r = false;
6128
  neighbor_rec nb;
5550
  neighbor_rec nb;
6129
  int o_count = 0;
5551
  int o_count = 0;
6130
  int a2;
5552
  int a2;
6131
 
5553
 
6132
  memset (nb, 0, sizeof (neighbor_rec));
5554
  memset (nb, 0, sizeof (neighbor_rec));
6133
  if (!
-
 
6134
      (atom[a_view - 1].
5555
  if (!(atom[a_view - 1].
6135
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5556
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
6136
    return false;
5557
    return false;
6137
  if (strcmp (atom[a_ref - 1].element, "N ")
5558
  if (strcmp (atom[a_ref - 1].element, "N ")
6138
      || atom[a_ref - 1].neighbor_count != 2)
5559
      || atom[a_ref - 1].neighbor_count != 2)
6139
    return false;
5560
    return false;
Line 6145... Line 5566...
6145
  if (o_count == 1)
5566
  if (o_count == 1)
6146
    r = true;
5567
    r = true;
6147
  return r;
5568
  return r;
6148
}
5569
}
6149
 
5570
 
6150
 
-
 
6151
static boolean
-
 
6152
is_subst_hydrazino (a_view, a_ref)
5571
static boolean is_subst_hydrazino (a_view, a_ref)
6153
     int a_view, a_ref;
5572
     int a_view, a_ref;
6154
{
5573
{
6155
  int i;
5574
  int i;
6156
  boolean r = false;
5575
  boolean r = false;
6157
  neighbor_rec nb;
5576
  neighbor_rec nb;
6158
  int nr_count = 0;
5577
  int nr_count = 0;
6159
  int a2, FORLIM;
5578
  int a2, FORLIM;
6160
 
5579
 
6161
  memset (nb, 0, sizeof (neighbor_rec));
5580
  memset (nb, 0, sizeof (neighbor_rec));
6162
  if (!
-
 
6163
      (atom[a_view - 1].
5581
  if (!(atom[a_view - 1].
6164
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5582
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
6165
    return false;
5583
    return false;
6166
  if (strcmp (atom[a_ref - 1].element, "N ")
5584
  if (strcmp (atom[a_ref - 1].element, "N ")
6167
      || atom[a_ref - 1].neighbor_count < 2)
5585
      || atom[a_ref - 1].neighbor_count < 2)
6168
    return false;
5586
    return false;
6169
  get_nextneighbors (nb, a_ref, a_view);
5587
  get_nextneighbors (nb, a_ref, a_view);
6170
  FORLIM = atom[a_ref - 1].neighbor_count - 2;
5588
  FORLIM = atom[a_ref - 1].neighbor_count - 2;
6171
  for (i = 0; i <= FORLIM; i++)
5589
  for (i = 0; i <= FORLIM; i++) {
6172
    {
-
 
6173
      a2 = nb[i];
5590
    a2 = nb[i];
6174
      if ((strcmp (atom[a2 - 1].element, "N ") ==
5591
    if ((strcmp (atom[a2 - 1].element, "N ") == 0) && (!is_nitroso (a_ref, a2)))
6175
           0) && (!is_nitroso (a_ref, a2)))
-
 
6176
        /* v0.3j */
5592
            /* v0.3j */
6177
        nr_count++;
5593
            nr_count++;
6178
    }
5594
  }
6179
  if (nr_count == 1)
5595
  if (nr_count == 1)
6180
    r = true;
5596
    r = true;
6181
  return r;
5597
  return r;
6182
}
5598
}
6183
 
5599
 
6184
 
-
 
6185
static boolean
-
 
6186
is_cyano (a_view, a_ref)
5600
static boolean is_cyano (a_view, a_ref)
6187
     int a_view, a_ref;
5601
     int a_view, a_ref;
6188
{
5602
{
6189
  boolean r = false;
5603
  boolean r = false;
6190
 
5604
 
6191
  if (((strcmp (atom[a_view - 1].atype, "C1 ") == 0) &
5605
  if (((strcmp (atom[a_view - 1].atype, "C1 ") == 0) &
6192
       (bond[get_bond (a_view, a_ref) - 1].btype == 'T')) &&
5606
      (bond[get_bond (a_view, a_ref) - 1].btype == 'T')) &&
6193
      !strcmp (atom[a_ref - 1].atype, "N1 ") &&
5607
      !strcmp (atom[a_ref - 1].atype, "N1 ") &&
6194
      atom[a_ref - 1].neighbor_count == 1)
5608
      atom[a_ref - 1].neighbor_count == 1)
6195
    r = true;
5609
    r = true;
6196
  return r;
5610
  return r;
6197
}
5611
}
6198
 
5612
 
6199
 
-
 
6200
static boolean
-
 
6201
is_cyano_c (a_ref)
5613
static boolean is_cyano_c (a_ref)
6202
     int a_ref;
5614
     int a_ref;
6203
{
5615
{
6204
  int i;
5616
  int i;
6205
  boolean r = false;
5617
  boolean r = false;
6206
  neighbor_rec nb;
5618
  neighbor_rec nb;
Line 6210... Line 5622...
6210
  if (strcmp (atom[a_ref - 1].atype, "C1 ")
5622
  if (strcmp (atom[a_ref - 1].atype, "C1 ")
6211
      || atom[a_ref - 1].neighbor_count <= 0)
5623
      || atom[a_ref - 1].neighbor_count <= 0)
6212
    return false;
5624
    return false;
6213
  get_neighbors (nb, a_ref);
5625
  get_neighbors (nb, a_ref);
6214
  FORLIM = atom[a_ref - 1].neighbor_count;
5626
  FORLIM = atom[a_ref - 1].neighbor_count;
6215
  for (i = 0; i < FORLIM; i++)
5627
  for (i = 0; i < FORLIM; i++) {
6216
    {
-
 
6217
      if (is_cyano (a_ref, nb[i]))
5628
    if (is_cyano (a_ref, nb[i]))
6218
        r = true;
5629
            r = true;
6219
    }
5630
  }
6220
  return r;
5631
  return r;
6221
}
5632
}
6222
 
-
 
6223
 
5633
 
6224
static boolean
-
 
6225
is_nitrile (a_view, a_ref)
5634
static boolean is_nitrile (a_view, a_ref)
6226
     int a_view, a_ref;
5635
     int a_view, a_ref;
6227
{
5636
{
6228
  boolean r = false;
5637
  boolean r = false;
6229
  neighbor_rec nb;
5638
  neighbor_rec nb;
6230
  str2 nb_el;
5639
  str2 nb_el;
6231
 
5640
 
6232
  if (!is_cyano (a_view, a_ref))
5641
  if (!is_cyano (a_view, a_ref))
Line 6240... Line 5649...
6240
  if (!strcmp (nb_el, "C ")
5649
  if (!strcmp (nb_el, "C ")
6241
      || !strcmp (nb_el, "H ") /*|| !strcmp (nb_el, "D ") */ )
5650
      || !strcmp (nb_el, "H ") /*|| !strcmp (nb_el, "D ") */ )
6242
    /* v0.3n: D */
5651
    /* v0.3n: D */
6243
    r = true;
5652
    r = true;
6244
  /* HCN is also a nitrile! */
5653
  /* HCN is also a nitrile! */
6245
  return r;
5654
  return r;
6246
}
5655
}
6247
 
-
 
6248
 
5656
 
6249
static boolean
-
 
6250
is_isonitrile (a_view, a_ref)
5657
static boolean is_isonitrile (a_view, a_ref)
6251
     int a_view, a_ref;
5658
     int a_view, a_ref;
6252
{
5659
{
6253
  /* only recognized with CN triple bond! */
5660
  /* only recognized with CN triple bond! */
6254
  boolean r = false;
5661
  boolean r = false;
6255
 
5662
 
6256
  if (((strcmp (atom[a_view - 1].atype, "C1 ") == 0) &
5663
  if (((strcmp (atom[a_view - 1].atype, "C1 ") == 0) &
6257
       (bond[get_bond (a_view, a_ref) - 1].btype == 'T')) &&
5664
       (bond[get_bond (a_view, a_ref) - 1].btype == 'T')) &&
6258
      !strcmp (atom[a_ref - 1].atype, "N1 ") &&
5665
      !strcmp (atom[a_ref - 1].atype, "N1 ") &&
6259
      atom[a_ref - 1].neighbor_count == 2
5666
      atom[a_ref - 1].neighbor_count == 2
6260
      && atom[a_view - 1].neighbor_count == 1)
5667
      && atom[a_view - 1].neighbor_count == 1)
6261
    r = true;
5668
    r = true;
6262
  return r;
5669
  return r;
6263
}
5670
}
6264
 
-
 
6265
 
5671
 
6266
static boolean
-
 
6267
is_cyanate (a_view, a_ref)
5672
static boolean is_cyanate (a_view, a_ref)
6268
     int a_view, a_ref;
5673
     int a_view, a_ref;
6269
{
5674
{
6270
  boolean r = false;
5675
  boolean r = false;
6271
  neighbor_rec nb;
5676
  neighbor_rec nb;
6272
 
5677
 
6273
  if (!is_cyano (a_view, a_ref))
5678
  if (!is_cyano (a_view, a_ref))
6274
    return false;
5679
    return false;
6275
  if (atom[a_view - 1].neighbor_count != 2)
5680
  if (atom[a_view - 1].neighbor_count != 2)
6276
    return false;
5681
    return false;
6277
  get_nextneighbors (nb, a_view, a_ref);
5682
  get_nextneighbors (nb, a_view, a_ref);
6278
  if (is_alkoxy (a_view, nb[0]) || is_aryloxy (a_view, nb[0]))
5683
  if (is_alkoxy (a_view, nb[0]) || is_aryloxy (a_view, nb[0]))
6279
    r = true;
5684
    r = true;
6280
  return r;
5685
  return r;
6281
}
5686
}
6282
 
5687
 
6283
 
-
 
6284
static boolean
-
 
6285
is_thiocyanate (a_view, a_ref)
5688
static boolean is_thiocyanate (a_view, a_ref)
6286
     int a_view, a_ref;
5689
     int a_view, a_ref;
6287
{
5690
{
6288
  boolean r = false;
5691
  boolean r = false;
6289
  neighbor_rec nb;
5692
  neighbor_rec nb;
6290
 
5693
 
6291
  if (!is_cyano (a_view, a_ref))
5694
  if (!is_cyano (a_view, a_ref))
6292
    return false;
5695
    return false;
6293
  if (atom[a_view - 1].neighbor_count != 2)
5696
  if (atom[a_view - 1].neighbor_count != 2)
6294
    return false;
5697
    return false;
6295
  get_nextneighbors (nb, a_view, a_ref);
5698
  get_nextneighbors (nb, a_view, a_ref);
6296
  if (is_alkylsulfanyl (a_view, nb[0]) || is_arylsulfanyl (a_view, nb[0]))
5699
  if (is_alkylsulfanyl (a_view, nb[0]) || is_arylsulfanyl (a_view, nb[0]))
6297
    r = true;
5700
    r = true;
6298
  return r;
5701
  return r;
6299
}
5702
}
6300
 
5703
 
6301
 
-
 
6302
static void
-
 
6303
update_Htotal ()
5704
static void update_Htotal ()
6304
{
5705
{
6305
  int i, j, b_id;
5706
  int i, j, b_id;
6306
  neighbor_rec nb;
5707
  neighbor_rec nb;
6307
  int single_count, double_count, triple_count, arom_count, total_bonds,
5708
  int single_count, double_count, triple_count, arom_count, total_bonds,
6308
    Htotal, nval;
5709
    Htotal, nval;
Line 6314... Line 5715...
6314
 
5715
 
6315
  if (n_atoms < 1)
5716
  if (n_atoms < 1)
6316
    return;
5717
    return;
6317
  memset (nb, 0, sizeof (neighbor_rec));
5718
  memset (nb, 0, sizeof (neighbor_rec));
6318
  FORLIM = n_atoms;
5719
  FORLIM = n_atoms;
6319
  for (i = 1; i <= FORLIM; i++)
5720
  for (i = 1; i <= FORLIM; i++) {
6320
    {
-
 
6321
      single_count = 0;
5721
    single_count = 0;
6322
      double_count = 0;
5722
    double_count = 0;
6323
      triple_count = 0;
5723
    triple_count = 0;
6324
      arom_count = 0;
5724
    arom_count = 0;
6325
      total_bonds = 0;
5725
    total_bonds = 0;
6326
      Htotal = 0;
5726
    Htotal = 0;
6327
      get_neighbors (nb, i);
5727
    get_neighbors (nb, i);
6328
      if (atom[i - 1].neighbor_count > 0)
5728
    if (atom[i - 1].neighbor_count > 0) {
6329
        {
-
 
6330
          /* count single, double, triple, and aromatic bonds to all neighbor atoms */
5729
            /* count single, double, triple, and aromatic bonds to all neighbor atoms */
6331
          FORLIM1 = atom[i - 1].neighbor_count;
5730
            FORLIM1 = atom[i - 1].neighbor_count;
6332
          for (j = 0; j < FORLIM1; j++)
5731
            for (j = 0; j < FORLIM1; j++) {
6333
            {
-
 
6334
              b_id = get_bond (i, nb[j]);
5732
                b_id = get_bond (i, nb[j]);
6335
              if (b_id > 0)
5733
              if (b_id > 0) {
6336
                {
-
 
6337
                  if (bond[b_id - 1].btype == 'S')
5734
                      if (bond[b_id - 1].btype == 'S')
6338
                    single_count++;
5735
                        single_count++;
6339
                  if (bond[b_id - 1].btype == 'D')
5736
                      if (bond[b_id - 1].btype == 'D')
6340
                    double_count++;
5737
                        double_count++;
6341
                  if (bond[b_id - 1].btype == 'T')
5738
                      if (bond[b_id - 1].btype == 'T')
6342
                    triple_count++;
5739
                        triple_count++;
6343
                  if (bond[b_id - 1].btype == 'A')
5740
                      if (bond[b_id - 1].btype == 'A')
6344
                    arom_count++;
5741
                        arom_count++;
6345
                }
-
 
6346
            }
5742
                    }
6347
          /*check for diazonium salts */
-
 
6348
          a1 = i;
-
 
6349
          a2 = nb[0];
-
 
6350
          if (!strcmp (atom[a1 - 1].element, "N ") &&
-
 
6351
              !strcmp (atom[a2 - 1].element, "N "))
-
 
6352
            {
-
 
6353
              if (atom[a2 - 1].neighbor_count == 2)
-
 
6354
                {
-
 
6355
                  get_nextneighbors (nb2, a2, a1);
-
 
6356
                  a3 = nb2[0];
-
 
6357
                  if ((strcmp (atom[a3 - 1].element, "C ") ==
-
 
6358
                       0) && is_diazonium (a3, a2))
-
 
6359
                    diazon = true;
-
 
6360
                }
-
 
6361
            }
5743
            }
-
 
5744
            /*check for diazonium salts */
-
 
5745
            a1 = i;
-
 
5746
            a2 = nb[0];
-
 
5747
            if (!strcmp (atom[a1 - 1].element, "N ") && !strcmp (atom[a2 - 1].element, "N ")) {
-
 
5748
              if (atom[a2 - 1].neighbor_count == 2) {
-
 
5749
                      get_nextneighbors (nb2, a2, a1);
-
 
5750
                      a3 = nb2[0];
-
 
5751
                      if ((strcmp (atom[a3 - 1].element, "C ") == 0) && is_diazonium (a3, a2))
-
 
5752
                        diazon = true;
-
 
5753
                  }
-
 
5754
            }
6362
        }
5755
          }
6363
      total_bonds = single_count + double_count * 2 + triple_count * 3 +
5756
    total_bonds = single_count + double_count * 2 + triple_count * 3 + (int) (1.5 * arom_count);
6364
        (int) (1.5 * arom_count);
-
 
6365
      /* calculate number of total hydrogens per atom */
5757
      /* calculate number of total hydrogens per atom */
6366
      /*nval := nvalences(atom^[i].element);    (* new in v0.3 */
5758
      /*nval := nvalences(atom^[i].element);    (* new in v0.3 */
6367
      nval = atom[i - 1].nvalences;     /* new in v0.3m */
5759
    nval = atom[i - 1].nvalences;       /* new in v0.3m */
6368
      if (!strcmp (atom[i - 1].element, "P "))
5760
    if (!strcmp (atom[i - 1].element, "P ")) {
6369
        {
-
 
6370
          if (total_bonds - atom[i - 1].formal_charge > 3)      /* refined in v0.3n */
5761
            if (total_bonds - atom[i - 1].formal_charge > 3)    /* refined in v0.3n */
6371
            nval = 5;
5762
              nval = 5;
6372
        }                       /*  */
5763
          }                     /*  */
6373
      if (!strcmp (atom[i - 1].element, "S "))
5764
    if (!strcmp (atom[i - 1].element, "S ")) {                  /* v0.3h */
6374
        {                       /* v0.3h */
-
 
6375
          if (total_bonds > 2 && atom[i - 1].formal_charge < 1)
5765
            if (total_bonds > 2 && atom[i - 1].formal_charge < 1)
6376
            /* updated in v0.3j */
5766
              /* updated in v0.3j */
6377
            nval = 4;
5767
              nval = 4;
6378
          if (total_bonds > 4)  /* this will need some refinement... */
5768
            if (total_bonds > 4)        /* this will need some refinement... */
6379
            nval = 6;
5769
              nval = 6;
6380
        }                       /*  */
5770
          }                     /*  */
6381
      Htotal = nval - total_bonds + atom[i - 1].formal_charge;
5771
    Htotal = nval - total_bonds + atom[i - 1].formal_charge;
6382
      if (diazon)               /* v0.3j */
5772
    if (diazon)         /* v0.3j */
6383
        Htotal = 0;
5773
            Htotal = 0;
6384
      if (Htotal < 0)           /* e.g., N in nitro group */
5774
    if (Htotal < 0)             /* e.g., N in nitro group */
6385
        Htotal = 0;
5775
            Htotal = 0;
6386
      atom[i - 1].Htot = Htotal;
5776
      atom[i - 1].Htot = Htotal;
6387
      if (atom[i - 1].Hexp > atom[i - 1].Htot)  /* v0.3n; just to be sure... */
5777
    if (atom[i - 1].Hexp > atom[i - 1].Htot)    /* v0.3n; just to be sure... */
6388
        atom[i - 1].Htot = atom[i - 1].Hexp;
5778
            atom[i - 1].Htot = atom[i - 1].Hexp;
6389
    }
5779
  }
6390
}
5780
}
6391
 
5781
 
6392
 
-
 
6393
static void
-
 
6394
update_atypes ()
5782
static void update_atypes ()
6395
{
5783
{
6396
  int i, j, b_id;
5784
  int i, j, b_id;
6397
  neighbor_rec nb;
5785
  neighbor_rec nb;
6398
  int single_count, double_count, triple_count, arom_count, acyl_count,
5786
  int single_count, double_count, triple_count, arom_count, acyl_count,
6399
    C_count, O_count, total_bonds, NdO_count, NdC_count, Htotal, FORLIM,
5787
    C_count, O_count, total_bonds, NdO_count, NdC_count, Htotal, FORLIM,
Line 6401... Line 5789...
6401
 
5789
 
6402
  if (n_atoms < 1)
5790
  if (n_atoms < 1)
6403
    return;
5791
    return;
6404
  memset (nb, 0, sizeof (neighbor_rec));
5792
  memset (nb, 0, sizeof (neighbor_rec));
6405
  FORLIM = n_atoms;
5793
  FORLIM = n_atoms;
6406
  for (i = 0; i < FORLIM; i++)
5794
  for (i = 0; i < FORLIM; i++) {
6407
    {
-
 
6408
      single_count = 0;
5795
    single_count = 0;
6409
      double_count = 0;
5796
    double_count = 0;
6410
      triple_count = 0;
5797
    triple_count = 0;
6411
      arom_count = 0;
5798
    arom_count = 0;
6412
      total_bonds = 0;
5799
    total_bonds = 0;
6413
      acyl_count = 0;
5800
    acyl_count = 0;
6414
      C_count = 0;
5801
    C_count = 0;
6415
      O_count = 0;
5802
    O_count = 0;
6416
      NdO_count = 0;
5803
    NdO_count = 0;
6417
      NdC_count = 0;
5804
    NdC_count = 0;
6418
      Htotal = 0;
5805
    Htotal = 0;
6419
      get_neighbors (nb, i + 1);
5806
    get_neighbors (nb, i + 1);
6420
      if (atom[i].neighbor_count > 0)
5807
    if (atom[i].neighbor_count > 0) {
6421
        {
-
 
6422
          /* count single, double, triple, and aromatic bonds to all neighbor atoms */
5808
            /* count single, double, triple, and aromatic bonds to all neighbor atoms */
6423
          FORLIM1 = atom[i].neighbor_count;
5809
            FORLIM1 = atom[i].neighbor_count;
6424
          for (j = 0; j < FORLIM1; j++)
5810
            for (j = 0; j < FORLIM1; j++) {
6425
            {
-
 
6426
              if (is_oxo_C (nb[j]) || is_thioxo_C (nb[j]))
5811
              if (is_oxo_C (nb[j]) || is_thioxo_C (nb[j]))
6427
                acyl_count++;
5812
          acyl_count++;
6428
              if (!strcmp (atom[nb[j] - 1].element, "C "))
5813
              if (!strcmp (atom[nb[j] - 1].element, "C "))
6429
                C_count++;
5814
                      C_count++;
6430
              if (!strcmp (atom[nb[j] - 1].element, "O "))
5815
              if (!strcmp (atom[nb[j] - 1].element, "O "))
6431
                O_count++;
5816
                      O_count++;
6432
              b_id = get_bond (i + 1, nb[j]);
5817
              b_id = get_bond (i + 1, nb[j]);
6433
              if (b_id > 0)
5818
              if (b_id > 0) {
6434
                {
-
 
6435
                  if (bond[b_id - 1].btype == 'S')
5819
                      if (bond[b_id - 1].btype == 'S')
6436
                    single_count++;
5820
                        single_count++;
6437
                  if (bond[b_id - 1].btype == 'D')
5821
                      if (bond[b_id - 1].btype == 'D')
6438
                    double_count++;
5822
                        double_count++;
6439
                  if (bond[b_id - 1].btype == 'T')
5823
                      if (bond[b_id - 1].btype == 'T')
6440
                    triple_count++;
5824
                        triple_count++;
6441
                  if (bond[b_id - 1].btype == 'A')
5825
                      if (bond[b_id - 1].btype == 'A'){
6442
                    /* v0.3n: special treatment for acyclic bonds */
5826
                        /* v0.3n: special treatment for acyclic bonds */
6443
                    {           /* flagged as "aromatic" (in query structures) */
5827
                           /* flagged as "aromatic" (in query structures) */
6444
                      if (bond[b_id - 1].ring_count > 0)
5828
                        if (bond[b_id - 1].ring_count > 0)
6445
                        arom_count++;
5829
                                arom_count++;
6446
                      else
5830
                        else
6447
                        double_count++;
5831
                                double_count++;
6448
                    }
5832
                      }
6449
                  if ((!strcmp (atom[i].element, "N ") &&
5833
                      if ((!strcmp (atom[i].element, "N ") &&
6450
                       !strcmp (atom[nb[j] - 1].element, "O ")) ||
5834
                          !strcmp (atom[nb[j] - 1].element, "O ")) ||
6451
                      (!strcmp (atom[i].element, "O ") &&
5835
                          (!strcmp (atom[i].element, "O ") &&
6452
                       !strcmp (atom[nb[j] - 1].element, "N ")))
5836
                        !strcmp (atom[nb[j] - 1].element, "N "))) {
-
 
5837
                        /* check if it is an N-oxide drawn with a double bond ==> should be N3 */
-
 
5838
                        if (bond[b_id - 1].btype == 'D')
-
 
5839
                                NdO_count++;
6453
                    {
5840
                     }
-
 
5841
                    if ((!strcmp (atom[i].element, "N ") &&
-
 
5842
                         !strcmp (atom[nb[j] - 1].element, "C ")) ||
-
 
5843
                        (!strcmp (atom[i].element, "C ") &&
6454
                      /* check if it is an N-oxide drawn with a double bond ==> should be N3 */
5844
                         !strcmp (atom[nb[j] - 1].element, "N "))) {
6455
                      if (bond[b_id - 1].btype == 'D')
5845
                      if (bond[b_id - 1].btype == 'D')
6456
                        NdO_count++;
5846
                              NdC_count++;
6457
                    }
5847
                    }
6458
                  if ((!strcmp (atom[i].element, "N ") &&
-
 
6459
                       !strcmp (atom[nb[j] - 1].element, "C ")) ||
-
 
6460
                      (!strcmp (atom[i].element, "C ") &&
-
 
6461
                       !strcmp (atom[nb[j] - 1].element, "N ")))
-
 
6462
                    {
-
 
6463
                      if (bond[b_id - 1].btype == 'D')
-
 
6464
                        NdC_count++;
-
 
6465
                    }
5848
                  }
6466
                }
-
 
6467
            }
5849
          }
6468
          total_bonds = single_count + double_count * 2 + triple_count * 3 +
5850
          total_bonds = single_count + double_count * 2 + triple_count * 3 +
6469
            (int) (1.5 * arom_count);
5851
            (int) (1.5 * arom_count);
6470
          /* calculate number of total hydrogens per atom */
5852
          /* calculate number of total hydrogens per atom */
6471
          /*Htotal := nvalences(atom^[i].element) - total_bonds + atom^[i].formal_charge; */
5853
          /*Htotal := nvalences(atom^[i].element) - total_bonds + atom^[i].formal_charge; */
6472
          Htotal = atom[i].nvalences - total_bonds + atom[i].formal_charge;
5854
          Htotal = atom[i].nvalences - total_bonds + atom[i].formal_charge;
6473
          if (Htotal < 0)       /* e.g., N in nitro group */
5855
          if (Htotal < 0)       /* e.g., N in nitro group */
6474
            Htotal = 0;
5856
            Htotal = 0;
6475
          atom[i].Htot = Htotal;
5857
          atom[i].Htot = Htotal;
6476
          /* refine atom types, based on bond types */
5858
          /* refine atom types, based on bond types */
6477
          if (!strcmp (atom[i].element, "C "))
5859
          if (!strcmp (atom[i].element, "C ")) {
6478
            {
-
 
6479
              if (arom_count > 1)
5860
            if (arom_count > 1)
6480
                strcpy (atom[i].atype, "CAR");
5861
                    strcpy (atom[i].atype, "CAR");
6481
              if (triple_count == 1 || double_count == 2)
5862
      if (triple_count == 1 || double_count == 2)
6482
                strcpy (atom[i].atype, "C1 ");
5863
                    strcpy (atom[i].atype, "C1 ");
6483
              if (double_count == 1)
5864
            if (double_count == 1)
6484
                strcpy (atom[i].atype, "C2 ");
5865
                    strcpy (atom[i].atype, "C2 ");
6485
              if (triple_count == 0 && double_count == 0 && arom_count < 2)
5866
            if (triple_count == 0 && double_count == 0 && arom_count < 2)
6486
                strcpy (atom[i].atype, "C3 ");
5867
                    strcpy (atom[i].atype, "C3 ");
6487
            }
5868
          }
6488
          if (!strcmp (atom[i].element, "O "))
5869
          if (!strcmp (atom[i].element, "O ")) {
6489
            {
-
 
6490
              if (double_count == 1)
5870
            if (double_count == 1)
6491
                strcpy (atom[i].atype, "O2 ");
5871
                    strcpy (atom[i].atype, "O2 ");
6492
              if (double_count == 0)
5872
            if (double_count == 0)
6493
                strcpy (atom[i].atype, "O3 ");
5873
                    strcpy (atom[i].atype, "O3 ");
6494
            }
5874
          }
6495
          if (!strcmp (atom[i].element, "N "))
5875
          if (!strcmp (atom[i].element, "N ")) {
6496
            {
-
 
6497
              if (total_bonds > 3)
5876
            if (total_bonds > 3) {
6498
                {
-
 
6499
                  if (O_count == 0)
5877
                    if (O_count == 0) {
6500
                    {
-
 
6501
                      if (single_count > 3 ||
5878
                      if (single_count > 3 ||
6502
                          (single_count == 2 && double_count == 1
5879
                                (single_count == 2 && double_count == 1 && C_count >= 2))
6503
                          && C_count >= 2))
-
 
6504
                        atom[i].formal_charge = 1;
5880
                              atom[i].formal_charge = 1;
6505
                    }
5881
                    }
6506
                  else
5882
                    else {
6507
                    {
-
 
6508
                      if (O_count == 1 && atom[i].formal_charge == 0)   /* v0.3m */
5883
                      if (O_count == 1 && atom[i].formal_charge == 0)   /* v0.3m */
6509
                        strcpy (atom[i].atype, "N3 ");
5884
                              strcpy (atom[i].atype, "N3 ");
6510
                      if (O_count == 2 && atom[i].formal_charge == 0)
5885
                      if (O_count == 2 && atom[i].formal_charge == 0) {
6511
                        {
-
 
6512
                          if (atom[i].neighbor_count > 2)       /* nitro v0.3o */
5886
                              if (atom[i].neighbor_count > 2)   /* nitro v0.3o */
6513
                            strcpy (atom[i].atype, "N2 ");
5887
                                strcpy (atom[i].atype, "N2 ");
6514
                          if (atom[i].neighbor_count == 2)      /* NO2   v0.3o */
5888
                              if (atom[i].neighbor_count == 2)  /* NO2   v0.3o */
6515
                            strcpy (atom[i].atype, "N1 ");
5889
                                strcpy (atom[i].atype, "N1 ");
6516
                        }
5890
                            }
6517
                      /* the rest is left empty, so far.... */
5891
                      /* the rest is left empty, so far.... */
6518
                    }
5892
                    }
6519
                }
5893
                  }
6520
              /* could be an N-oxide -> should be found elsewhere  */
5894
            /* could be an N-oxide -> should be found elsewhere  */
6521
              if (triple_count == 1 ||
-
 
6522
                  (double_count == 2 && atom[i].neighbor_count == 2))
5895
            if (triple_count == 1 || (double_count == 2 && atom[i].neighbor_count == 2))
6523
                /* v0.3n */
5896
                    /* v0.3n */
6524
                strcpy (atom[i].atype, "N1 ");
5897
                    strcpy (atom[i].atype, "N1 ");
6525
              if (double_count == 1)
5898
              if (double_count == 1) {
6526
                {
-
 
6527
                  /*if NdC_count > 0 then atom^[i].atype := 'N2 '; */
5899
                      /*if NdC_count > 0 then atom^[i].atype := 'N2 '; */
6528
                  if (NdC_count == 0 && NdO_count > 0 && C_count >= 2)
5900
                      if (NdC_count == 0 && NdO_count > 0 && C_count >= 2)
6529
                    strcpy (atom[i].atype, "N3 ");
5901
                        strcpy (atom[i].atype, "N3 ");
6530
                  /* N-oxide is N3 except in hetarene etc. */
5902
                      /* N-oxide is N3 except in hetarene etc. */
6531
                  else
5903
                      else
6532
                    strcpy (atom[i].atype, "N2 ");
5904
                        strcpy (atom[i].atype, "N2 ");
6533
                }
5905
                    }
6534
              /* fallback, added in v0.3g  */
5906
              /* fallback, added in v0.3g  */
6535
              if (arom_count > 1 || atom[i].arom == true)       /* v0.3n */
5907
              if (arom_count > 1 || atom[i].arom == true)       /* v0.3n */
6536
                strcpy (atom[i].atype, "NAR");
5908
                      strcpy (atom[i].atype, "NAR");
6537
              if (triple_count == 0 && double_count == 0)
5909
              if (triple_count == 0 && double_count == 0) {
6538
                {
-
 
6539
                  if (atom[i].formal_charge == 0)
5910
                      if (atom[i].formal_charge == 0) {
6540
                    {
-
 
6541
                      if (acyl_count == 0)
5911
                        if (acyl_count == 0)
6542
                        strcpy (atom[i].atype, "N3 ");
5912
                                strcpy (atom[i].atype, "N3 ");
6543
                      if (acyl_count > 0)
5913
                        if (acyl_count > 0)
6544
                        strcpy (atom[i].atype, "NAM");
5914
                                strcpy (atom[i].atype, "NAM");
6545
                    }
5915
                      }
6546
                  if (atom[i].formal_charge == 1)
5916
                      if (atom[i].formal_charge == 1)
6547
                    strcpy (atom[i].atype, "N3+");
5917
                        strcpy (atom[i].atype, "N3+");
6548
                }
5918
                      }
6549
            }
5919
              }
6550
          if (!strcmp (atom[i].element, "P "))
5920
              if (!strcmp (atom[i].element, "P ")) {
6551
            {
-
 
6552
              if (single_count > 4)
5921
                if (single_count > 4)
6553
                strcpy (atom[i].atype, "P4 ");
5922
                        strcpy (atom[i].atype, "P4 ");
6554
              if (single_count <= 4 && double_count == 0)
5923
                if (single_count <= 4 && double_count == 0)
6555
                strcpy (atom[i].atype, "P3 ");
5924
                        strcpy (atom[i].atype, "P3 ");
6556
              if (double_count == 2)
5925
                if (double_count == 2)
6557
                strcpy (atom[i].atype, "P3D");
5926
                        strcpy (atom[i].atype, "P3D");
6558
            }
5927
             }
6559
          if (!strcmp (atom[i].element, "S "))
5928
            if (!strcmp (atom[i].element, "S ")) {
6560
            {
-
 
6561
              if (double_count == 1 && single_count == 0)
5929
              if (double_count == 1 && single_count == 0)
6562
                strcpy (atom[i].atype, "S2 ");
5930
                      strcpy (atom[i].atype, "S2 ");
6563
              if (double_count == 0)
5931
              if (double_count == 0)
6564
                strcpy (atom[i].atype, "S3 ");
5932
                      strcpy (atom[i].atype, "S3 ");
6565
              if (double_count == 1 && single_count > 0)
5933
              if (double_count == 1 && single_count > 0)
6566
                strcpy (atom[i].atype, "SO ");
5934
                      strcpy (atom[i].atype, "SO ");
6567
              if (double_count == 2 && single_count > 0)
5935
              if (double_count == 2 && single_count > 0)
6568
                strcpy (atom[i].atype, "SO2");
5936
                      strcpy (atom[i].atype, "SO2");
6569
            }
5937
            }
6570
          /* further atom types should go here */
5938
          /* further atom types should go here */
6571
        }
5939
          }
6572
    }
5940
  }
6573
}
5941
}
6574
 
5942
 
6575
 
-
 
6576
static void
-
 
6577
chk_arom ()
5943
static void chk_arom ()
6578
{
5944
{
6579
  int i, j, pi_count, ring_size, b, a1, a2;     /* v0.3n */
5945
  int i, j, pi_count, ring_size, b, a1, a2;     /* v0.3n */
6580
  ringpath_type testring;
5946
  ringpath_type testring;
6581
  int a_ref, a_prev, a_next, b_bk, b_fw, b_exo;
5947
  int a_ref, a_prev, a_next, b_bk, b_fw, b_exo;
6582
  char bt_bk, bt_fw;
5948
  char bt_bk, bt_fw;
Line 6590... Line 5956...
6590
 
5956
 
6591
  if (n_rings < 1)
5957
  if (n_rings < 1)
6592
    return;
5958
    return;
6593
  FORLIM = n_rings;
5959
  FORLIM = n_rings;
6594
  /* first, do a very quick check for benzene, pyridine, etc. */
5960
  /* first, do a very quick check for benzene, pyridine, etc. */
6595
  for (i = 0; i < FORLIM; i++)
5961
  for (i = 0; i < FORLIM; i++) {
6596
    {
-
 
6597
      ring_size = ringprop[i].size;
5962
    ring_size = ringprop[i].size;
6598
      if (ring_size == 6)
5963
    if (ring_size == 6) {
6599
        {
-
 
6600
          memset (testring, 0, sizeof (ringpath_type));
5964
            memset (testring, 0, sizeof (ringpath_type));
6601
          for (j = 0; j < ring_size; j++)
5965
            for (j = 0; j < ring_size; j++)
6602
            testring[j] = ring[i][j];
5966
              testring[j] = ring[i][j];
6603
          cumul = false;
5967
            cumul = false;
6604
          n_sb = 0;
5968
            n_sb = 0;
6605
          n_db = 0;
5969
            n_db = 0;
6606
          n_ar = 0;
5970
            n_ar = 0;
6607
          a_prev = testring[ring_size - 1];
5971
            a_prev = testring[ring_size - 1];
6608
          for (j = 1; j <= ring_size; j++)
5972
            for (j = 1; j <= ring_size; j++) {
6609
            {
-
 
6610
              a_ref = testring[j - 1];
5973
              a_ref = testring[j - 1];
6611
              if (j < ring_size)
5974
              if (j < ring_size)
6612
                a_next = testring[j];
5975
               a_next = testring[j];
6613
              else
5976
              else
6614
                a_next = testring[0];
5977
               a_next = testring[0];
6615
              b_bk = get_bond (a_prev, a_ref);
5978
              b_bk = get_bond (a_prev, a_ref);
6616
              b_fw = get_bond (a_ref, a_next);
5979
              b_fw = get_bond (a_ref, a_next);
6617
              bt_bk = bond[b_bk - 1].btype;
5980
              bt_bk = bond[b_bk - 1].btype;
6618
              bt_fw = bond[b_fw - 1].btype;
5981
              bt_fw = bond[b_fw - 1].btype;
6619
              if (bt_fw == 'S')
5982
              if (bt_fw == 'S')
6620
                n_sb++;
5983
                n_sb++;
6621
              if (bt_fw == 'D')
5984
              if (bt_fw == 'D')
6622
                n_db++;
5985
                n_db++;
6623
              if (bt_fw == 'A')
5986
              if (bt_fw == 'A')
6624
                n_ar++;
5987
                      n_ar++;
6625
              if (bt_fw != 'A' && bt_bk == bt_fw)
5988
              if (bt_fw != 'A' && bt_bk == bt_fw)
6626
                cumul = true;
5989
                      cumul = true;
6627
              a_prev = a_ref;
5990
              a_prev = a_ref;
6628
            }
5991
            }
6629
          if (n_ar == 6 || (n_sb == 3 && n_db == 3 && cumul == false))
5992
            if (n_ar == 6 || (n_sb == 3 && n_db == 3 && cumul == false)) {
6630
            {                   /* this ring is aromatic */
5993
              /* this ring is aromatic */
6631
              a_prev = testring[ring_size - 1];
5994
              a_prev = testring[ring_size - 1];
6632
              for (j = 0; j < ring_size; j++)
5995
              for (j = 0; j < ring_size; j++) {
6633
                {
-
 
6634
                  a_ref = testring[j];
5996
                      a_ref = testring[j];
6635
                  b_bk = get_bond (a_prev, a_ref);
5997
                      b_bk = get_bond (a_prev, a_ref);
6636
                  bond[b_bk - 1].arom = true;
5998
                      bond[b_bk - 1].arom = true;
6637
                  a_prev = a_ref;
5999
                      a_prev = a_ref;
6638
                }
6000
                    }
6639
              ringprop[i].arom = true;
6001
              ringprop[i].arom = true;
6640
            }
6002
            }
6641
        }
6003
          }
6642
    }
6004
  }
6643
  FORLIM = n_rings;
6005
  FORLIM = n_rings;
6644
  for (i = 1; i <= FORLIM; i++)
6006
  for (i = 1; i <= FORLIM; i++) {
6645
    {
-
 
6646
      if (ringprop[i - 1].arom == false)
6007
    if (ringprop[i - 1].arom == false) {
6647
        {
-
 
6648
          /* do the hard work only for those rings which are not yet flagged aromatic */
6008
            /* do the hard work only for those rings which are not yet flagged aromatic */
6649
          memset (testring, 0, sizeof (ringpath_type));
6009
            memset (testring, 0, sizeof (ringpath_type));
6650
          ring_size = ringprop[i - 1].size;     /* v0.3j */
6010
            ring_size = ringprop[i - 1].size;   /* v0.3j */
6651
          for (j = 0; j < ring_size; j++)       /* v0.3j */
6011
            for (j = 0; j < ring_size; j++)     /* v0.3j */
6652
            testring[j] = ring[i - 1][j];
6012
              testring[j] = ring[i - 1][j];
6653
          pi_count = 0;
6013
            pi_count = 0;
6654
          arom_pi_diff = 0;     /* v0.3j */
6014
            arom_pi_diff = 0;   /* v0.3j */
6655
/* p2c: checkmol.pas: Note: Eliminated unused assignment statement [338] */
6015
      /* p2c: checkmol.pas: Note: Eliminated unused assignment statement [338] */
6656
          ko = false;
6016
            ko = false;
6657
          a_prev = testring[ring_size - 1];
6017
            a_prev = testring[ring_size - 1];
6658
          for (j = 1; j <= ring_size; j++)
6018
            for (j = 1; j <= ring_size; j++) {
6659
            {
-
 
6660
              a_ref = testring[j - 1];
6019
              a_ref = testring[j - 1];
6661
              if (j < ring_size)
6020
              if (j < ring_size)
6662
                a_next = testring[j];
6021
                a_next = testring[j];
6663
              else
6022
              else
6664
                a_next = testring[0];
6023
                a_next = testring[0];
6665
              b_bk = get_bond (a_prev, a_ref);
6024
              b_bk = get_bond (a_prev, a_ref);
6666
              b_fw = get_bond (a_ref, a_next);
6025
              b_fw = get_bond (a_ref, a_next);
6667
              bt_bk = bond[b_bk - 1].btype;
6026
              bt_bk = bond[b_bk - 1].btype;
6668
              bt_fw = bond[b_fw - 1].btype;
6027
              bt_fw = bond[b_fw - 1].btype;
6669
              ar_bk = bond[b_bk - 1].arom;
6028
              ar_bk = bond[b_bk - 1].arom;
6670
              ar_fw = bond[b_fw - 1].arom;
6029
              ar_fw = bond[b_fw - 1].arom;
6671
              if (bt_bk == 'S' && bt_fw == 'S' && ar_bk == false
6030
              if (bt_bk == 'S' && bt_fw == 'S' && ar_bk == false && ar_fw == false) {
6672
                  && ar_fw == false)
-
 
6673
                {
-
 
6674
                  /* first, assume the worst case (interrupted conjugation) */
6031
                /* first, assume the worst case (interrupted conjugation) */
6675
                  conj_intr = true;
6032
                conj_intr = true;
6676
                  /* conjugation can be restored by hetero atoms */
6033
                /* conjugation can be restored by hetero atoms */
6677
                  if (!strcmp (atom[a_ref - 1].atype, "O3 ") ||
6034
                if (!strcmp (atom[a_ref - 1].atype, "O3 ") ||
6678
                      !strcmp (atom[a_ref - 1].atype, "S3 ") ||
6035
                    !strcmp (atom[a_ref - 1].atype, "S3 ") ||
6679
                      !strcmp (atom[a_ref - 1].element, "N ") ||
6036
                          !strcmp (atom[a_ref - 1].element, "N ") ||
6680
                      !strcmp (atom[a_ref - 1].element, "SE"))
6037
                          !strcmp (atom[a_ref - 1].element, "SE")) {
6681
                    {
-
 
6682
                      conj_intr = false;
6038
                        conj_intr = false;
6683
                      pi_count += 2;    /* lone pair adds for 2 pi electrons */
6039
                        pi_count += 2;  /* lone pair adds for 2 pi electrons */
6684
                    }
6040
                      }
6685
                  /* conjugation can be restored by a formal charge at a methylene group */
6041
                      /* conjugation can be restored by a formal charge at a methylene group */
6686
                  if (!strcmp (atom[a_ref - 1].element, "C ") &&
-
 
6687
                      atom[a_ref - 1].formal_charge != 0)
-
 
6688
                    {
-
 
6689
                      conj_intr = false;
-
 
6690
                      pi_count -= atom[a_ref - 1].formal_charge;
-
 
6691
                      /* neg. charge increases pi_count! */
-
 
6692
                    }
-
 
6693
                  /* conjugation can be restored by carbonyl groups etc. */
-
 
6694
                  if (is_oxo_C (a_ref) || is_thioxo_C (a_ref) |
-
 
6695
                      is_exocyclic_imino_C (a_ref, i))
-
 
6696
                    conj_intr = false;
-
 
6697
                  /* conjugation can be restored by exocyclic C=C double bond, */
-
 
6698
                  /* adds 2 pi electrons to 5-membered rings, not to 7-membered rings (CAUTION!) */
-
 
6699
                  /* apply only to non-aromatic exocyclic C=C bonds */
-
 
6700
                  exo_mC = find_exocyclic_methylene_C (a_ref, i);       /* v0.3j */
-
 
6701
                  if (exo_mC > 0 && (ring_size & 1))
-
 
6702
                    {           /* v0.3j */
-
 
6703
                      b_exo = get_bond (a_ref, exo_mC); /* v0.3j  */
-
 
6704
                      ar_exo = bond[b_exo - 1].arom;
-
 
6705
                      if (((ring_size - 1) & 3) == 0)
-
 
6706
                        {       /* 5-membered rings and related */
-
 
6707
                          conj_intr = false;
-
 
6708
                          pi_count += 2;
-
 
6709
                        }
-
 
6710
                      else
-
 
6711
                        {
-
 
6712
                          if (!ar_exo)
-
 
6713
                            conj_intr = false;
-
 
6714
                        }
-
 
6715
                    }
-
 
6716
                  /* 7-membered rings and related */
-
 
6717
                  /* if conjugation is still interrupted ==> knock-out */
-
 
6718
                  if (conj_intr)
-
 
6719
                    ko = true;
-
 
6720
                }
-
 
6721
              else
-
 
6722
                {
-
 
6723
                  if (bt_bk == 'S' && bt_fw == 'S' && ar_bk == true
-
 
6724
                      && ar_fw == true)
-
 
6725
                    {
-
 
6726
                      if (!strcmp (atom[a_ref - 1].atype, "O3 ") ||
-
 
6727
                          !strcmp (atom[a_ref - 1].atype, "S3 ") ||
-
 
6728
                          !strcmp (atom[a_ref - 1].element, "N ") ||
-
 
6729
                          !strcmp (atom[a_ref - 1].element, "SE"))
-
 
6730
                        pi_count += 2;  /* lone pair adds for 2 pi electrons */
-
 
6731
                      if (!strcmp (atom[a_ref - 1].element, "C ") &&
6042
                      if (!strcmp (atom[a_ref - 1].element, "C ") &&
6732
                          atom[a_ref - 1].formal_charge != 0)
6043
                          atom[a_ref - 1].formal_charge != 0) {
-
 
6044
                          conj_intr = false;
6733
                        pi_count -= atom[a_ref - 1].formal_charge;
6045
                          pi_count -= atom[a_ref - 1].formal_charge;
6734
                      /* neg. charge increases pi_count! */
6046
                          /* neg. charge increases pi_count! */
-
 
6047
                      }
-
 
6048
                      /* conjugation can be restored by carbonyl groups etc. */
-
 
6049
                      if (is_oxo_C (a_ref) || is_thioxo_C (a_ref) |
-
 
6050
                          is_exocyclic_imino_C (a_ref, i))
-
 
6051
                        conj_intr = false;
-
 
6052
                      /* conjugation can be restored by exocyclic C=C double bond, */
-
 
6053
                      /* adds 2 pi electrons to 5-membered rings, not to 7-membered rings (CAUTION!) */
-
 
6054
                      /* apply only to non-aromatic exocyclic C=C bonds */
6735
                      exo_mC = find_exocyclic_methylene_C (a_ref, i);   /* v0.3j */
6055
                      exo_mC = find_exocyclic_methylene_C (a_ref, i);   /* v0.3j */
6736
                      if (exo_mC > 0 && (ring_size & 1))
6056
                      if (exo_mC > 0 && (ring_size & 1)) {              /* v0.3j */
-
 
6057
                          b_exo = get_bond (a_ref, exo_mC);     /* v0.3j  */
-
 
6058
                          ar_exo = bond[b_exo - 1].arom;
-
 
6059
                        if (((ring_size - 1) & 3) == 0) {       /* 5-membered rings and related */
-
 
6060
                                conj_intr = false;
-
 
6061
                                pi_count += 2;
-
 
6062
                              }
6737
                        {       /* v0.3j */
6063
                        else {
-
 
6064
                                if (!ar_exo)
-
 
6065
                                  conj_intr = false;
-
 
6066
                              }
-
 
6067
                      }
-
 
6068
                      /* 7-membered rings and related */
-
 
6069
                      /* if conjugation is still interrupted ==> knock-out */
-
 
6070
                      if (conj_intr)
-
 
6071
                        ko = true;
-
 
6072
                    }
-
 
6073
              else {
-
 
6074
                      if (bt_bk == 'S' && bt_fw == 'S' && ar_bk == true && ar_fw == true) {
-
 
6075
                        if (!strcmp (atom[a_ref - 1].atype, "O3 ") ||
-
 
6076
                                  !strcmp (atom[a_ref - 1].atype, "S3 ") ||
-
 
6077
                                  !strcmp (atom[a_ref - 1].element, "N ") ||
-
 
6078
                                  !strcmp (atom[a_ref - 1].element, "SE"))
-
 
6079
                                pi_count += 2;  /* lone pair adds for 2 pi electrons */
-
 
6080
                        if (!strcmp (atom[a_ref - 1].element, "C ") &&
-
 
6081
                                  atom[a_ref - 1].formal_charge != 0)
-
 
6082
                                pi_count -= atom[a_ref - 1].formal_charge;
-
 
6083
                          /* neg. charge increases pi_count! */
-
 
6084
                        exo_mC = find_exocyclic_methylene_C (a_ref, i); /* v0.3j */
-
 
6085
                        if (exo_mC > 0 && (ring_size & 1))  {   /* v0.3j */
6738
                          b_exo = get_bond (a_ref, exo_mC);     /* v0.3j */
6086
                                b_exo = get_bond (a_ref, exo_mC);       /* v0.3j */
6739
/* p2c: checkmol.pas: Note: Eliminated unused assignment statement [338] */
6087
            /* p2c: checkmol.pas: Note: Eliminated unused assignment statement [338] */
6740
                          if (((ring_size - 1) & 3) == 0)
6088
                                if (((ring_size - 1) & 3) == 0)
6741
                            /* 5-membered rings and related */
6089
                                  /* 5-membered rings and related */
6742
                            pi_count += 2;
6090
                                  pi_count += 2;
6743
                        }
-
 
6744
                    }
6091
                              }
6745
                  else
6092
                      }
6746
                    {
6093
                      else {
6747
                      pi_count++;       /* v0.3j; adjustment for bridgehead N: see below */
6094
                  pi_count++;   /* v0.3j; adjustment for bridgehead N: see below */
6748
                      if (bt_bk == 'S' && bt_fw == 'S' &&
6095
                  if (bt_bk == 'S' && bt_fw == 'S' && ((ar_bk == true && ar_fw == false) ||
6749
                          ((ar_bk == true && ar_fw == false) ||
-
 
6750
                           (ar_bk == false && ar_fw == true)))
6096
                                  (ar_bk == false && ar_fw == true))) {
6751
                        {
-
 
6752
                          /* v0.3j; if a bridgehead N were not aromatic, it could  */
6097
                                /* v0.3j; if a bridgehead N were not aromatic, it could  */
6753
                          /* contribute 2 pi electrons --> try also this variant */
6098
                                /* contribute 2 pi electrons --> try also this variant */
6754
                          /* (example: CAS 32278-54-9) */
6099
                                /* (example: CAS 32278-54-9) */
6755
                          if (!strcmp (atom[a_ref - 1].element, "N "))
6100
                                if (!strcmp (atom[a_ref - 1].element, "N ")) {
6756
                            {
-
 
6757
                              arom_pi_diff++;
6101
                                  arom_pi_diff++;
6758
                              /* any other case: increase pi count by one electron */
6102
                                  /* any other case: increase pi count by one electron */
-
 
6103
                                }
6759
                            }
6104
                              }
6760
                        }
6105
                      }
6761
                    }
6106
                    }
6762
                }
-
 
6763
              /* last command: */
6107
        /* last command: */
6764
              a_prev = a_ref;
6108
        a_prev = a_ref;
6765
            }                   /* for j := 1 to ring_size */
6109
            }                   /* for j := 1 to ring_size */
6766
          /* now we can draw our conclusion */
6110
            /* now we can draw our conclusion */
6767
          /*if not ((ko) or (odd(pi_count))) then */
6111
            /*if not ((ko) or (odd(pi_count))) then */
6768
          if (!ko)
6112
            if (!ko) {
6769
            /* v0.3j; odd pi_count might be compensated by arom_pi_diff */
6113
              /* v0.3j; odd pi_count might be compensated by arom_pi_diff */
6770
            {                   /* apply Hueckel's rule */
6114
                          /* apply Hueckel's rule */
6771
              if (labs (ring_size - pi_count) < 2 &&
6115
              if (labs (ring_size - pi_count) < 2 &&
6772
                  (((pi_count - 2) & 3) == 0 ||
-
 
6773
                   ((pi_count + arom_pi_diff - 2) & 3) == 0))
6116
                        (((pi_count - 2) & 3) == 0 || ((pi_count + arom_pi_diff - 2) & 3) == 0)) {
6774
                {
-
 
6775
                  /* this ring is aromatic */
6117
                      /* this ring is aromatic */
6776
                  ringprop[i - 1].arom = true;
6118
                      ringprop[i - 1].arom = true;
6777
                  /* now mark _all_ bonds in the ring as aromatic */
6119
                      /* now mark _all_ bonds in the ring as aromatic */
6778
                  a_prev = testring[ring_size - 1];
6120
                      a_prev = testring[ring_size - 1];
6779
                  for (j = 0; j < ring_size; j++)
6121
                      for (j = 0; j < ring_size; j++) {
6780
                    {
-
 
6781
                      a_ref = testring[j];
6122
                        a_ref = testring[j];
6782
                      bond[get_bond (a_prev, a_ref) - 1].arom = true;
6123
                        bond[get_bond (a_prev, a_ref) - 1].arom = true;
6783
                      a_prev = a_ref;
6124
                        a_prev = a_ref;
-
 
6125
                      }
6784
                    }
6126
                    }
6785
                }
-
 
6786
            }
6127
            }
6787
        }
6128
          }
6788
    }                           /* (for i := 1 to n_rings) */
6129
  }                             /* (for i := 1 to n_rings) */
6789
  FORLIM = n_bonds;
6130
  FORLIM = n_bonds;
6790
  /* finally, mark all involved atoms as aromatic */
6131
  /* finally, mark all involved atoms as aromatic */
6791
  for (i = 0; i < FORLIM; i++)
6132
  for (i = 0; i < FORLIM; i++) {
6792
    {
-
 
6793
      if (bond[i].arom)
6133
    if (bond[i].arom) {
6794
        {
-
 
6795
          a1 = bond[i].a1;      /* v0.3n */
6134
            a1 = bond[i].a1;    /* v0.3n */
6796
          a2 = bond[i].a2;      /* v0.3n */
6135
            a2 = bond[i].a2;    /* v0.3n */
6797
          atom[a1 - 1].arom = true;
6136
            atom[a1 - 1].arom = true;
6798
          atom[a2 - 1].arom = true;
6137
            atom[a2 - 1].arom = true;
6799
          /* v0.3n: update atom types if applicable (C and N) */
6138
            /* v0.3n: update atom types if applicable (C and N) */
6800
          if (!strcmp (atom[a1 - 1].element, "C "))
6139
            if (!strcmp (atom[a1 - 1].element, "C "))
6801
            strcpy (atom[a1 - 1].atype, "CAR");
6140
              strcpy (atom[a1 - 1].atype, "CAR");
6802
          if (!strcmp (atom[a2 - 1].element, "C "))
6141
            if (!strcmp (atom[a2 - 1].element, "C "))
6803
            strcpy (atom[a2 - 1].atype, "CAR");
6142
              strcpy (atom[a2 - 1].atype, "CAR");
6804
          if (!strcmp (atom[a1 - 1].element, "N "))
6143
            if (!strcmp (atom[a1 - 1].element, "N "))
6805
            strcpy (atom[a1 - 1].atype, "NAR");
6144
              strcpy (atom[a1 - 1].atype, "NAR");
6806
          if (!strcmp (atom[a2 - 1].element, "N "))
6145
            if (!strcmp (atom[a2 - 1].element, "N "))
6807
            strcpy (atom[a2 - 1].atype, "NAR");
6146
              strcpy (atom[a2 - 1].atype, "NAR");
6808
        }
6147
          }
6809
    }
6148
  }
6810
  FORLIM = n_rings;
6149
  FORLIM = n_rings;
6811
  /* update aromaticity information in ringprop */
6150
  /* update aromaticity information in ringprop */
6812
  /* new in v0.3n: accept rings as aromatic if all bonds are of type 'A' */
6151
  /* new in v0.3n: accept rings as aromatic if all bonds are of type 'A' */
6813
  for (i = 0; i < FORLIM; i++)
6152
  for (i = 0; i < FORLIM; i++) {
6814
    {
-
 
6815
      memcpy (testring, ring[i], sizeof (ringpath_type));
6153
    memcpy (testring, ring[i], sizeof (ringpath_type));
6816
      /*ring_size := path_length(testring); */
6154
    /*ring_size := path_length(testring); */
6817
      ring_size = ringprop[i].size;     /* v0.3j */
6155
    ring_size = ringprop[i].size;       /* v0.3j */
6818
      aromatic = true;
6156
    aromatic = true;
6819
      aromatic_bt = true;       /* v0.3n */
6157
    aromatic_bt = true; /* v0.3n */
6820
      a_prev = testring[ring_size - 1];
6158
    a_prev = testring[ring_size - 1];
6821
      for (j = 0; j < ring_size; j++)
6159
    for (j = 0; j < ring_size; j++) {
6822
        {
-
 
6823
          a_ref = testring[j];
6160
            a_ref = testring[j];
6824
          b = get_bond (a_prev, a_ref); /* v0.3n */
6161
            b = get_bond (a_prev, a_ref);       /* v0.3n */
6825
          if (!bond[b - 1].arom)
6162
            if (!bond[b - 1].arom)
6826
            aromatic = false;
6163
              aromatic = false;
6827
          if (bond[b - 1].btype != 'A') /* v0.3n */
6164
            if (bond[b - 1].btype != 'A')       /* v0.3n */
6828
            aromatic_bt = false;
6165
              aromatic_bt = false;
6829
          a_prev = a_ref;
6166
            a_prev = a_ref;
6830
        }
6167
          }
6831
      if (aromatic_bt && !aromatic)
-
 
6832
        {                       /* v0.3n: update aromaticity flag */
6168
    if (aromatic_bt && !aromatic) {                     /* v0.3n: update aromaticity flag */
6833
          a_prev = testring[ring_size - 1];
6169
            a_prev = testring[ring_size - 1];
6834
          for (j = 0; j < ring_size; j++)
6170
            for (j = 0; j < ring_size; j++) {
6835
            {
-
 
6836
              a_ref = testring[j];
6171
              a_ref = testring[j];
6837
              b = get_bond (a_prev, a_ref);
6172
              b = get_bond (a_prev, a_ref);
6838
              bond[b - 1].arom = true;
6173
              bond[b - 1].arom = true;
6839
              if (!strcmp (atom[a_ref - 1].element, "C "))
6174
              if (!strcmp (atom[a_ref - 1].element, "C "))
6840
                strcpy (atom[a_ref - 1].atype, "CAR");
6175
                      strcpy (atom[a_ref - 1].atype, "CAR");
6841
              if (!strcmp (atom[a_ref - 1].element, "N "))
6176
              if (!strcmp (atom[a_ref - 1].element, "N "))
6842
                strcpy (atom[a_ref - 1].atype, "NAR");
6177
                      strcpy (atom[a_ref - 1].atype, "NAR");
6843
              a_prev = a_ref;
6178
              a_prev = a_ref;
6844
            }
6179
            }
6845
          aromatic = true;
6180
            aromatic = true;
6846
        }                       /* end v0.3n block   */
6181
          }                     /* end v0.3n block   */
6847
      if (aromatic)
6182
    if (aromatic)
6848
        ringprop[i].arom = true;
6183
            ringprop[i].arom = true;
6849
      else
6184
    else
6850
        ringprop[i].arom = false;
6185
            ringprop[i].arom = false;
6851
    }
6186
  }
6852
}
6187
}
6853
 
6188
 
6854
 
-
 
6855
static void
-
 
6856
write_mol ()
6189
static void write_mol ()
6857
{
6190
{
6858
  int i, j;
6191
  int i, j;
6859
  ringpath_type testring;
6192
  ringpath_type testring;
6860
  int ring_size, FORLIM;
6193
  int ring_size, FORLIM;
6861
 
6194
 
Line 6869... Line 6202...
6869
  if (n_atoms < 1)
6202
  if (n_atoms < 1)
6870
    return;
6203
    return;
6871
  if (n_bonds < 1)
6204
  if (n_bonds < 1)
6872
    return;
6205
    return;
6873
  FORLIM = n_atoms;
6206
  FORLIM = n_atoms;
6874
  for (i = 1; i <= FORLIM; i++)
6207
  for (i = 1; i <= FORLIM; i++) {
6875
    {
-
 
6876
      if (i < 10)
-
 
6877
        putchar (' ');
6208
    if (i < 10) putchar (' ');
6878
      if (i < 100)
6209
    if (i < 100) putchar (' ');
6879
        putchar (' ');
-
 
6880
      if (i < 1000)
6210
    if (i < 1000) putchar (' ');
6881
        putchar (' ');
-
 
6882
      printf ("%d %s %s %f %f ",
6211
    printf ("%d %s %s %f %f ",
6883
              i, atom[i - 1].element, atom[i - 1].atype, atom[i - 1].x,
6212
              i, atom[i - 1].element, atom[i - 1].atype, atom[i - 1].x,
6884
              atom[i - 1].y);
6213
              atom[i - 1].y);
6885
      printf ("%f", atom[i - 1].z);
6214
    printf ("%f", atom[i - 1].z);
6886
      printf ("  (%d heavy-atom neighbors, Hexp: %d Htot: %d)",
6215
    printf ("  (%d heavy-atom neighbors, Hexp: %d Htot: %d)",
6887
              atom[i - 1].neighbor_count, atom[i - 1].Hexp, atom[i - 1].Htot);
6216
            atom[i - 1].neighbor_count, atom[i - 1].Hexp, atom[i - 1].Htot);
6888
      if (atom[i - 1].formal_charge != 0)
6217
    if (atom[i - 1].formal_charge != 0)
6889
        printf ("  charge: %d", atom[i - 1].formal_charge);
6218
            printf ("  charge: %d", atom[i - 1].formal_charge);
6890
      putchar ('\n');
6219
    putchar ('\n');
6891
    }
6220
  }
6892
  FORLIM = n_bonds;
6221
  FORLIM = n_bonds;
6893
  for (i = 1; i <= FORLIM; i++)
6222
  for (i = 1; i <= FORLIM; i++) {
6894
    {
-
 
6895
      if (i < 10)
-
 
6896
        putchar (' ');
6223
    if (i < 10) putchar (' ');
6897
      if (i < 100)
6224
    if (i < 100) putchar (' ');
6898
        putchar (' ');
-
 
6899
      if (i < 1000)
6225
    if (i < 1000) putchar (' ');
6900
        putchar (' ');
-
 
6901
      printf ("%d %d %d %c",
-
 
6902
              i, bond[i - 1].a1, bond[i - 1].a2, bond[i - 1].btype);
6226
    printf ("%d %d %d %c", i, bond[i - 1].a1, bond[i - 1].a2, bond[i - 1].btype);
6903
      if (bond[i - 1].ring_count > 0)
6227
    if (bond[i - 1].ring_count > 0)
6904
        printf (", contained in %d ring(s)", bond[i - 1].ring_count);
6228
            printf (", contained in %d ring(s)", bond[i - 1].ring_count);
6905
      if (bond[i - 1].arom)
-
 
6906
        printf (" (aromatic) ");
6229
    if (bond[i - 1].arom) printf (" (aromatic) ");
6907
      putchar ('\n');
6230
    putchar ('\n');
6908
    }
6231
  }
6909
  if (n_rings <= 0)
6232
  if (n_rings <= 0)
6910
    return;
6233
    return;
6911
  FORLIM = n_rings;
6234
  FORLIM = n_rings;
6912
  for (i = 0; i < FORLIM; i++)
6235
  for (i = 0; i < FORLIM; i++) {
6913
    {
-
 
6914
      printf ("ring %d: ", i + 1);
6236
    printf ("ring %d: ", i + 1);
6915
      /*aromatic := true; */
6237
    /*aromatic := true; */
6916
      memset (testring, 0, sizeof (ringpath_type));
6238
    memset (testring, 0, sizeof (ringpath_type));
6917
      ring_size = ringprop[i].size;     /* v0.3j */
6239
    ring_size = ringprop[i].size;       /* v0.3j */
6918
      /*for j := 1 to max_ringsize do if ring^[i,j] > 0 then testring[j] := ring^[i,j]; */
6240
    /*for j := 1 to max_ringsize do if ring^[i,j] > 0 then testring[j] := ring^[i,j]; */
6919
      for (j = 0; j < ring_size; j++)   /* v0.3j */
6241
    for (j = 0; j < ring_size; j++)     /* v0.3j */
6920
        testring[j] = ring[i][j];
6242
            testring[j] = ring[i][j];
6921
      /*ring_size := path_length(testring); */
6243
    /*ring_size := path_length(testring); */
6922
      /*a_prev := testring[ring_size]; */
6244
    /*a_prev := testring[ring_size]; */
6923
      for (j = 0; j < ring_size; j++)
6245
    for (j = 0; j < ring_size; j++) {
6924
        {
-
 
6925
          printf ("%d ", testring[j]);
6246
            printf ("%d ", testring[j]);
6926
          /*a_ref := testring[j]; */
6247
            /*a_ref := testring[j]; */
6927
          /*if (not bond^[get_bond(a_prev,a_ref)].arom) then aromatic := false; */
6248
            /*if (not bond^[get_bond(a_prev,a_ref)].arom) then aromatic := false; */
6928
          /*a_prev := a_ref; */
6249
            /*a_prev := a_ref; */
6929
        }
6250
          }
6930
      /*if aromatic then write(' (aromatic)'); */
6251
    /*if aromatic then write(' (aromatic)'); */
6931
      if (ringprop[i].arom)
6252
    if (ringprop[i].arom) printf (" (aromatic)");
6932
        printf (" (aromatic)");
-
 
6933
      if (ringprop[i].envelope)
6253
    if (ringprop[i].envelope) printf (" (env)");
6934
        printf (" (env)");
-
 
6935
      putchar ('\n');
6254
    putchar ('\n');
6936
    }
6255
  }
6937
}
6256
}
6938
 
6257
 
6939
 
-
 
6940
static void
-
 
6941
write_needle_mol ()
6258
static void write_needle_mol ()
6942
{
6259
{
6943
  int i, j;
6260
  int i, j;
6944
  ringpath_type testring;
6261
  ringpath_type testring;
6945
  int ring_size;
6262
  int ring_size;
6946
  boolean aromatic;
6263
  boolean aromatic;
Line 6952... Line 6269...
6952
  if (ndl_n_atoms < 1)
6269
  if (ndl_n_atoms < 1)
6953
    return;
6270
    return;
6954
  if (ndl_n_bonds < 1)
6271
  if (ndl_n_bonds < 1)
6955
    return;
6272
    return;
6956
  FORLIM = ndl_n_atoms;
6273
  FORLIM = ndl_n_atoms;
6957
  for (i = 1; i <= FORLIM; i++)
6274
  for (i = 1; i <= FORLIM; i++) {
6958
    {
-
 
6959
      if (i < 10)
-
 
6960
        putchar (' ');
6275
    if (i < 10) putchar (' ');
6961
      if (i < 100)
6276
    if (i < 100) putchar (' ');
6962
        putchar (' ');
-
 
6963
      if (i < 1000)
6277
    if (i < 1000) putchar (' ');
6964
        putchar (' ');
-
 
6965
      printf ("%d %s %s %f %f ",
6278
    printf ("%d %s %s %f %f ",
6966
              i, ndl_atom[i - 1].element, ndl_atom[i - 1].atype,
6279
              i, ndl_atom[i - 1].element, ndl_atom[i - 1].atype,
6967
              ndl_atom[i - 1].x, atom[i - 1].y);
6280
              ndl_atom[i - 1].x, atom[i - 1].y);
6968
      printf ("%f", ndl_atom[i - 1].z);
6281
    printf ("%f", ndl_atom[i - 1].z);
6969
      printf ("  (%d heavy-atom neighbors, Hexp: %d Htot: %d)",
6282
    printf ("  (%d heavy-atom neighbors, Hexp: %d Htot: %d)",
6970
              ndl_atom[i - 1].neighbor_count, ndl_atom[i - 1].Hexp,
6283
            ndl_atom[i - 1].neighbor_count, ndl_atom[i - 1].Hexp,
6971
              ndl_atom[i - 1].Htot);
6284
            ndl_atom[i - 1].Htot);
6972
      if (ndl_atom[i - 1].formal_charge != 0)
6285
    if (ndl_atom[i - 1].formal_charge != 0)
6973
        printf ("  charge: %d", ndl_atom[i - 1].formal_charge);
6286
            printf ("  charge: %d", ndl_atom[i - 1].formal_charge);
6974
      putchar ('\n');
6287
    putchar ('\n');
6975
    }
6288
  }
6976
  FORLIM = ndl_n_bonds;
6289
  FORLIM = ndl_n_bonds;
6977
  for (i = 1; i <= FORLIM; i++)
6290
  for (i = 1; i <= FORLIM; i++) {
6978
    {
-
 
6979
      if (i < 10)
-
 
6980
        putchar (' ');
6291
    if (i < 10) putchar (' ');
6981
      if (i < 100)
6292
    if (i < 100) putchar (' ');
6982
        putchar (' ');
-
 
6983
      if (i < 1000)
6293
    if (i < 1000) putchar (' ');
6984
        putchar (' ');
-
 
6985
      printf ("%d %d %d %c",
-
 
6986
              i, ndl_bond[i - 1].a1, ndl_bond[i - 1].a2,
6294
    printf ("%d %d %d %c", i, ndl_bond[i - 1].a1, ndl_bond[i - 1].a2,
6987
              ndl_bond[i - 1].btype);
6295
              ndl_bond[i - 1].btype);
6988
      if (ndl_bond[i - 1].ring_count > 0)
6296
    if (ndl_bond[i - 1].ring_count > 0)
6989
        printf (", contained in %d ring(s)", ndl_bond[i - 1].ring_count);
6297
            printf (", contained in %d ring(s)", ndl_bond[i - 1].ring_count);
6990
      if (ndl_bond[i - 1].arom)
6298
    if (ndl_bond[i - 1].arom)
6991
        printf (" (aromatic) ");
6299
            printf (" (aromatic) ");
6992
      putchar ('\n');
6300
    putchar ('\n');
6993
    }
6301
  }
6994
  if (ndl_n_rings <= 0)
6302
  if (ndl_n_rings <= 0)
6995
    return;
6303
    return;
6996
  FORLIM = ndl_n_rings;
6304
  FORLIM = ndl_n_rings;
6997
  for (i = 0; i < FORLIM; i++)
6305
  for (i = 0; i < FORLIM; i++) {
6998
    {
-
 
6999
      aromatic = true;
6306
    aromatic = true;
7000
      memset (testring, 0, sizeof (ringpath_type));
6307
    memset (testring, 0, sizeof (ringpath_type));
7001
      for (j = 0; j < max_ringsize; j++)
6308
    for (j = 0; j < max_ringsize; j++) {
7002
        {
-
 
7003
          if (ndl_ring[i][j] > 0)
6309
            if (ndl_ring[i][j] > 0)
7004
            testring[j] = ndl_ring[i][j];
6310
              testring[j] = ndl_ring[i][j];
7005
        }
6311
          }
7006
      ring_size = path_length (testring);
6312
    ring_size = path_length (testring);
7007
      printf ("ring %d: ", i + 1);
6313
    printf ("ring %d: ", i + 1);
7008
      a_prev = testring[ring_size - 1];
6314
    a_prev = testring[ring_size - 1];
7009
      for (j = 0; j < ring_size; j++)
6315
    for (j = 0; j < ring_size; j++) {
7010
        {
-
 
7011
          printf ("%d ", testring[j]);
6316
            printf ("%d ", testring[j]);
7012
          a_ref = testring[j];
6317
            a_ref = testring[j];
7013
          if (!ndl_bond[get_ndl_bond (a_prev, a_ref) - 1].arom) /* v0.3k */
6318
            if (!ndl_bond[get_ndl_bond (a_prev, a_ref) - 1].arom)       /* v0.3k */
7014
            aromatic = false;
6319
              aromatic = false;
7015
          a_prev = a_ref;
6320
            a_prev = a_ref;
7016
        }
6321
          }
7017
      if (aromatic)
-
 
7018
        printf (" (aromatic)");
6322
    if (aromatic) printf (" (aromatic)");
7019
      putchar ('\n');
6323
    putchar ('\n');
7020
    }
6324
  }
7021
}
6325
}
7022
 
6326
 
7023
 
-
 
7024
static void
-
 
7025
chk_so2_deriv (a_ref)
6327
static void chk_so2_deriv (a_ref)
7026
     int a_ref;
6328
     int a_ref;
7027
{
6329
{
7028
  int i;
6330
  int i;
7029
  neighbor_rec nb;
6331
  neighbor_rec nb;
7030
  str2 nb_el;
6332
  str2 nb_el;
Line 7035... Line 6337...
7035
  memset (nb, 0, sizeof (neighbor_rec));
6337
  memset (nb, 0, sizeof (neighbor_rec));
7036
  if (strcmp (atom[a_ref - 1].atype, "SO2"))
6338
  if (strcmp (atom[a_ref - 1].atype, "SO2"))
7037
    return;
6339
    return;
7038
  get_neighbors (nb, a_ref);
6340
  get_neighbors (nb, a_ref);
7039
  FORLIM = atom[a_ref - 1].neighbor_count;
6341
  FORLIM = atom[a_ref - 1].neighbor_count;
7040
  for (i = 0; i < FORLIM; i++)
6342
  for (i = 0; i < FORLIM; i++) {
7041
    {
-
 
7042
      if (bond[get_bond (a_ref, nb[i]) - 1].btype == 'S')
6343
    if (bond[get_bond (a_ref, nb[i]) - 1].btype == 'S') {
7043
        {
-
 
7044
          strcpy (nb_el, atom[nb[i] - 1].element);
6344
            strcpy (nb_el, atom[nb[i] - 1].element);
7045
          if (strcmp (nb_el, "C ") && strcmp (nb_el, "H ")
6345
            if (strcmp (nb_el, "C ") && strcmp (nb_el, "H ")
7046
              /*&&  strcmp (nb_el, "D ") */  && strcmp (nb_el, "DU")
6346
                /*&&  strcmp (nb_el, "D ") */  && strcmp (nb_el, "DU")
7047
              && strcmp (nb_el, "LP"))
6347
                && strcmp (nb_el, "LP"))
7048
            /* added 'D ' in v0.3n */
6348
              /* added 'D ' in v0.3n */
7049
            het_count++;
6349
              het_count++;
7050
          if (!strcmp (nb_el, "O "))
6350
            if (!strcmp (nb_el, "O ")) {
7051
            {
-
 
7052
              o_count++;
6351
              o_count++;
7053
              if (is_alkoxy (a_ref, nb[i]) || is_aryloxy (a_ref, nb[i]))
6352
              if (is_alkoxy (a_ref, nb[i]) || is_aryloxy (a_ref, nb[i]))
7054
                or_count++;
6353
                      or_count++;
7055
            }
6354
            }
7056
          if (!strcmp (nb_el, "N "))
6355
            if (!strcmp (nb_el, "N "))
7057
            n_count++;
6356
              n_count++;
7058
          if (!strcmp (nb_el, "C "))
6357
            if (!strcmp (nb_el, "C "))
7059
            c_count++;
6358
              c_count++;
7060
          if (!strcmp (nb_el, "F ") || !strcmp (nb_el, "CL") ||
6359
            if (!strcmp (nb_el, "F ") || !strcmp (nb_el, "CL") ||
7061
              !strcmp (nb_el, "BR") || !strcmp (nb_el, "I ")
6360
                !strcmp (nb_el, "BR") || !strcmp (nb_el, "I ")
7062
              || !strcmp (nb_el, "AT"))
6361
                || !strcmp (nb_el, "AT"))
7063
            hal_count++;
6362
              hal_count++;
7064
        }
6363
          }
7065
    }
6364
  }
7066
  if (het_count == 2)
-
 
7067
    {                           /* sulfuric acid derivative */
6365
  if (het_count == 2) {                                 /* sulfuric acid derivative */
7068
      fg[fg_sulfuric_acid_deriv - 1] = true;
6366
    fg[fg_sulfuric_acid_deriv - 1] = true;
7069
      if (o_count == 2)
6367
    if (o_count == 2) {
7070
        {
-
 
7071
          if (or_count == 0)
6368
            if (or_count == 0)
7072
            fg[fg_sulfuric_acid - 1] = true;
6369
              fg[fg_sulfuric_acid - 1] = true;
7073
          if (or_count == 1)
6370
            if (or_count == 1)
7074
            fg[fg_sulfuric_acid_monoester - 1] = true;
6371
              fg[fg_sulfuric_acid_monoester - 1] = true;
7075
          if (or_count == 2)
6372
            if (or_count == 2)
7076
            fg[fg_sulfuric_acid_diester - 1] = true;
6373
              fg[fg_sulfuric_acid_diester - 1] = true;
7077
        }
6374
          }
7078
      if (o_count == 1)
6375
    if (o_count == 1) {
7079
        {
-
 
7080
          if (or_count == 1 && n_count == 1)
6376
            if (or_count == 1 && n_count == 1)
7081
            fg[fg_sulfuric_acid_amide_ester - 1] = true;
6377
              fg[fg_sulfuric_acid_amide_ester - 1] = true;
7082
          if (or_count == 0 && n_count == 1)
6378
            if (or_count == 0 && n_count == 1)
7083
            fg[fg_sulfuric_acid_amide - 1] = true;
6379
              fg[fg_sulfuric_acid_amide - 1] = true;
7084
        }
6380
          }
7085
      if (n_count == 2)
6381
    if (n_count == 2)
7086
        fg[fg_sulfuric_acid_diamide - 1] = true;
6382
            fg[fg_sulfuric_acid_diamide - 1] = true;
7087
      if (hal_count > 0)
6383
    if (hal_count > 0)
7088
        fg[fg_sulfuryl_halide - 1] = true;
6384
            fg[fg_sulfuryl_halide - 1] = true;
7089
    }
6385
  }
7090
  if (het_count == 1 && c_count == 1)
-
 
7091
    {                           /* sulfonic acid derivative */
6386
  if (het_count == 1 && c_count == 1) {                                 /* sulfonic acid derivative */
7092
      fg[fg_sulfonic_acid_deriv - 1] = true;
6387
    fg[fg_sulfonic_acid_deriv - 1] = true;
7093
      if (o_count == 1 && or_count == 0)
6388
    if (o_count == 1 && or_count == 0)
7094
        fg[fg_sulfonic_acid - 1] = true;
6389
            fg[fg_sulfonic_acid - 1] = true;
7095
      if (o_count == 1 && or_count == 1)
6390
    if (o_count == 1 && or_count == 1)
7096
        fg[fg_sulfonic_acid_ester - 1] = true;
6391
            fg[fg_sulfonic_acid_ester - 1] = true;
7097
      if (n_count == 1)
6392
    if (n_count == 1)
7098
        fg[fg_sulfonamide - 1] = true;
6393
            fg[fg_sulfonamide - 1] = true;
7099
      if (hal_count == 1)
6394
    if (hal_count == 1)
7100
        fg[fg_sulfonyl_halide - 1] = true;
6395
            fg[fg_sulfonyl_halide - 1] = true;
7101
    }
6396
  }
7102
  if (het_count == 0 && c_count == 2)   /* sulfone */
6397
  if (het_count == 0 && c_count == 2)   /* sulfone */
7103
    fg[fg_sulfone - 1] = true;
6398
    fg[fg_sulfone - 1] = true;
7104
}
6399
}
7105
 
6400
 
7106
 
-
 
7107
static void
-
 
7108
chk_p_deriv (a_ref)
6401
static void chk_p_deriv (a_ref)
7109
     int a_ref;
6402
     int a_ref;
7110
{
6403
{
7111
  int i;
6404
  int i;
7112
  neighbor_rec nb;
6405
  neighbor_rec nb;
7113
  str2 nb_el, dbl_het;
6406
  str2 nb_el, dbl_het;
Line 7118... Line 6411...
7118
  if (strcmp (atom[a_ref - 1].element, "P "))
6411
  if (strcmp (atom[a_ref - 1].element, "P "))
7119
    return;
6412
    return;
7120
  memset (nb, 0, sizeof (neighbor_rec));
6413
  memset (nb, 0, sizeof (neighbor_rec));
7121
  get_neighbors (nb, a_ref);
6414
  get_neighbors (nb, a_ref);
7122
  *dbl_het = '\0';
6415
  *dbl_het = '\0';
7123
/* p2c: checkmol.pas: Note: Eliminated unused assignment statement [338] */
6416
  /* p2c: checkmol.pas: Note: Eliminated unused assignment statement [338] */
7124
  FORLIM = atom[a_ref - 1].neighbor_count;
6417
  FORLIM = atom[a_ref - 1].neighbor_count;
7125
  for (i = 0; i < FORLIM; i++)
6418
  for (i = 0; i < FORLIM; i++) {
7126
    {
-
 
7127
      if (bond[get_bond (a_ref, nb[i]) - 1].btype == 'D')
6419
    if (bond[get_bond (a_ref, nb[i]) - 1].btype == 'D')
7128
        strcpy (dbl_het, atom[nb[i] - 1].element);
6420
            strcpy (dbl_het, atom[nb[i] - 1].element);
7129
      if (bond[get_bond (a_ref, nb[i]) - 1].btype == 'S')
6421
    if (bond[get_bond (a_ref, nb[i]) - 1].btype == 'S') {
7130
        {
-
 
7131
          strcpy (nb_el, atom[nb[i] - 1].element);
6422
            strcpy (nb_el, atom[nb[i] - 1].element);
7132
          if (!strcmp (nb_el, "C "))
6423
            if (!strcmp (nb_el, "C "))
7133
            c_count++;
6424
              c_count++;
7134
          if (is_hydroxy (a_ref, nb[i]))
6425
            if (is_hydroxy (a_ref, nb[i]))
7135
            oh_count++;
6426
              oh_count++;
7136
          if (is_alkoxy (a_ref, nb[i]) || is_aryloxy (a_ref, nb[i]))
6427
            if (is_alkoxy (a_ref, nb[i]) || is_aryloxy (a_ref, nb[i]))
7137
            or_count++;
6428
              or_count++;
7138
          if (!strcmp (nb_el, "N "))
6429
            if (!strcmp (nb_el, "N "))
7139
            n_count++;
6430
              n_count++;
7140
          if (!strcmp (nb_el, "F ") || !strcmp (nb_el, "CL") ||
6431
            if (!strcmp (nb_el, "F ") || !strcmp (nb_el, "CL") ||
7141
              !strcmp (nb_el, "BR") || !strcmp (nb_el, "I ")
6432
                !strcmp (nb_el, "BR") || !strcmp (nb_el, "I ")
7142
              || !strcmp (nb_el, "AT"))
6433
                || !strcmp (nb_el, "AT"))
7143
            hal_count++;
6434
              hal_count++;
7144
        }
6435
          }
7145
    }
6436
  }
7146
  het_count = oh_count + or_count + hal_count + n_count;
6437
  het_count = oh_count + or_count + hal_count + n_count;
7147
  if (!strcmp (atom[a_ref - 1].atype, "P3D") ||
6438
  if (!strcmp (atom[a_ref - 1].atype, "P3D") ||
7148
      !strcmp (atom[a_ref - 1].atype, "P4 "))
6439
      !strcmp (atom[a_ref - 1].atype, "P4 ")) {
7149
    {
-
 
7150
      if (!strcmp (dbl_het, "O "))
6440
    if (!strcmp (dbl_het, "O ")) {
7151
        {
-
 
7152
          if (c_count == 0)
6441
            if (c_count == 0) {
7153
            {
-
 
7154
              fg[fg_phosphoric_acid_deriv - 1] = true;
6442
              fg[fg_phosphoric_acid_deriv - 1] = true;
7155
              if (oh_count == 3)
6443
              if (oh_count == 3)
7156
                fg[fg_phosphoric_acid - 1] = true;
6444
                fg[fg_phosphoric_acid - 1] = true;
7157
              if (or_count > 0)
6445
              if (or_count > 0)
7158
                fg[fg_phosphoric_acid_ester - 1] = true;
6446
                fg[fg_phosphoric_acid_ester - 1] = true;
7159
              if (hal_count > 0)
6447
              if (hal_count > 0)
7160
                fg[fg_phosphoric_acid_halide - 1] = true;
6448
                fg[fg_phosphoric_acid_halide - 1] = true;
7161
              if (n_count > 0)
6449
              if (n_count > 0)
7162
                fg[fg_phosphoric_acid_amide - 1] = true;
6450
                fg[fg_phosphoric_acid_amide - 1] = true;
7163
            }
6451
            }
7164
          if (c_count == 1)
6452
            if (c_count == 1) {
7165
            {
-
 
7166
              fg[fg_phosphonic_acid_deriv - 1] = true;
6453
              fg[fg_phosphonic_acid_deriv - 1] = true;
7167
              if (oh_count == 2)
6454
              if (oh_count == 2)
7168
                fg[fg_phosphonic_acid - 1] = true;
6455
                fg[fg_phosphonic_acid - 1] = true;
7169
              if (or_count > 0)
6456
              if (or_count > 0)
7170
                fg[fg_phosphonic_acid_ester - 1] = true;
6457
                fg[fg_phosphonic_acid_ester - 1] = true;
7171
              /*if (hal_count > 0)  then fg[fg_phosphonic_acid_halide] := true;             */
6458
              /*if (hal_count > 0)  then fg[fg_phosphonic_acid_halide] := true;             */
7172
              /*if (n_count > 0)    then fg[fg_phosphonic_acid_amide]  := true; */
6459
              /*if (n_count > 0)    then fg[fg_phosphonic_acid_amide]  := true; */
7173
            }
6460
            }
7174
          if (c_count == 3)
6461
            if (c_count == 3)
7175
            fg[fg_phosphinoxide - 1] = true;
6462
              fg[fg_phosphinoxide - 1] = true;
7176
        }
6463
          }
7177
      if (!strcmp (dbl_het, "S "))
6464
    if (!strcmp (dbl_het, "S ")) {
7178
        {
-
 
7179
          if (c_count == 0)
6465
      if (c_count == 0) {
7180
            {
-
 
7181
              fg[fg_thiophosphoric_acid_deriv - 1] = true;
6466
        fg[fg_thiophosphoric_acid_deriv - 1] = true;
7182
              if (oh_count == 3)
6467
        if (oh_count == 3)
7183
                fg[fg_thiophosphoric_acid - 1] = true;
6468
            fg[fg_thiophosphoric_acid - 1] = true;
7184
              if (or_count > 0)
6469
        if (or_count > 0)
7185
                fg[fg_thiophosphoric_acid_ester - 1] = true;
6470
            fg[fg_thiophosphoric_acid_ester - 1] = true;
7186
              if (hal_count > 0)
6471
        if (hal_count > 0)
7187
                fg[fg_thiophosphoric_acid_halide - 1] = true;
6472
            fg[fg_thiophosphoric_acid_halide - 1] = true;
7188
              if (n_count > 0)
6473
        if (n_count > 0)
7189
                fg[fg_thiophosphoric_acid_amide - 1] = true;
6474
            fg[fg_thiophosphoric_acid_amide - 1] = true;
7190
            }
6475
      }
7191
        }
-
 
7192
    }
6476
    }
-
 
6477
  }
7193
  /*  if (atom^[a_ref].atype = 'P4 ') then fg[fg_phosphoric_acid_deriv] := true; */
6478
  /*  if (atom^[a_ref].atype = 'P4 ') then fg[fg_phosphoric_acid_deriv] := true; */
7194
  if (strcmp (atom[a_ref - 1].atype, "P3 "))    /* changed P3D into P3 in v0.3b */
6479
  if (strcmp (atom[a_ref - 1].atype, "P3 "))    /* changed P3D into P3 in v0.3b */
7195
    return;
6480
    return;
7196
  if (c_count == 3 && het_count == 0)
6481
  if (c_count == 3 && het_count == 0)
7197
    fg[fg_phosphine - 1] = true;
6482
    fg[fg_phosphine - 1] = true;
7198
  if (c_count == 3 && oh_count == 1)
6483
  if (c_count == 3 && oh_count == 1)
7199
    fg[fg_phosphinoxide - 1] = true;
6484
    fg[fg_phosphinoxide - 1] = true;
7200
}
6485
}
7201
 
6486
 
7202
 
-
 
7203
static void
-
 
7204
chk_b_deriv (a_ref)
6487
static void chk_b_deriv (a_ref)
7205
     int a_ref;
6488
     int a_ref;
7206
{
6489
{
7207
  int i;
6490
  int i;
7208
  neighbor_rec nb;
6491
  neighbor_rec nb;
7209
  str2 nb_el;
6492
  str2 nb_el;
Line 7214... Line 6497...
7214
  if (strcmp (atom[a_ref - 1].element, "B "))
6497
  if (strcmp (atom[a_ref - 1].element, "B "))
7215
    return;
6498
    return;
7216
  memset (nb, 0, sizeof (neighbor_rec));
6499
  memset (nb, 0, sizeof (neighbor_rec));
7217
  get_neighbors (nb, a_ref);
6500
  get_neighbors (nb, a_ref);
7218
  FORLIM = atom[a_ref - 1].neighbor_count;
6501
  FORLIM = atom[a_ref - 1].neighbor_count;
7219
  for (i = 0; i < FORLIM; i++)
6502
  for (i = 0; i < FORLIM; i++) {
7220
    {
-
 
7221
      if (bond[get_bond (a_ref, nb[i]) - 1].btype == 'S')
6503
    if (bond[get_bond (a_ref, nb[i]) - 1].btype == 'S') {
7222
        {
-
 
7223
          strcpy (nb_el, atom[nb[i] - 1].element);
6504
            strcpy (nb_el, atom[nb[i] - 1].element);
7224
          if (!strcmp (nb_el, "C "))
6505
            if (!strcmp (nb_el, "C "))
7225
            c_count++;
6506
              c_count++;
-
 
6507
            else
7226
          else if (strcmp (nb_el, "H ") /*&& strcmp (nb_el, "D ") */  &&
6508
              if (strcmp (nb_el, "H ") /*&& strcmp (nb_el, "D ") */  &&
7227
                   strcmp (nb_el, "LP"))
6509
                      strcmp (nb_el, "LP"))
7228
            /* v0.3n: D */
6510
                /* v0.3n: D */
7229
            het_count++;
6511
              het_count++;
7230
          if (is_hydroxy (a_ref, nb[i]))
6512
              if (is_hydroxy (a_ref, nb[i]))
7231
            oh_count++;
6513
                oh_count++;
7232
          if (is_alkoxy (a_ref, nb[i]) || is_aryloxy (a_ref, nb[i]))
6514
              if (is_alkoxy (a_ref, nb[i]) || is_aryloxy (a_ref, nb[i]))
7233
            /* fixed in v0.3b */
6515
                /* fixed in v0.3b */
7234
            or_count++;
6516
                or_count++;
7235
          if (!strcmp (nb_el, "N "))
6517
              if (!strcmp (nb_el, "N "))
7236
            n_count++;
6518
                n_count++;
7237
          if (!strcmp (nb_el, "F ") || !strcmp (nb_el, "CL") ||
6519
              if (!strcmp (nb_el, "F ") || !strcmp (nb_el, "CL") ||
7238
              !strcmp (nb_el, "BR") || !strcmp (nb_el, "I ")
6520
                  !strcmp (nb_el, "BR") || !strcmp (nb_el, "I ")
7239
              || !strcmp (nb_el, "AT"))
6521
                  || !strcmp (nb_el, "AT"))
7240
            hal_count++;
6522
                hal_count++;
7241
        }
6523
          }
7242
    }
6524
  }
7243
  het_count = oh_count + or_count + hal_count + n_count;
6525
  het_count = oh_count + or_count + hal_count + n_count;
7244
  /* fixed in v0.3b */
6526
  /* fixed in v0.3b */
7245
  if (c_count != 1 || het_count != 2)
6527
  if (c_count != 1 || het_count != 2)
7246
    return;
6528
    return;
7247
  fg[fg_boronic_acid_deriv - 1] = true;
6529
  fg[fg_boronic_acid_deriv - 1] = true;
Line 7249... Line 6531...
7249
    fg[fg_boronic_acid - 1] = true;
6531
    fg[fg_boronic_acid - 1] = true;
7250
  if (or_count > 0)
6532
  if (or_count > 0)
7251
    fg[fg_boronic_acid_ester - 1] = true;
6533
    fg[fg_boronic_acid_ester - 1] = true;
7252
}
6534
}
7253
 
6535
 
7254
 
-
 
7255
static void
-
 
7256
chk_ammon (a_ref)
6536
static void chk_ammon (a_ref)
7257
     int a_ref;
6537
     int a_ref;
7258
{
6538
{
7259
  int i;
6539
  int i;
7260
  neighbor_rec nb;
6540
  neighbor_rec nb;
7261
  str2 nb_el;
6541
  str2 nb_el;
Line 7271... Line 6551...
7271
    return;
6551
    return;
7272
  if (strcmp (atom[a_ref - 1].element, "N "))   /* just to be sure;  v0.3i */
6552
  if (strcmp (atom[a_ref - 1].element, "N "))   /* just to be sure;  v0.3i */
7273
    return;
6553
    return;
7274
  get_neighbors (nb, a_ref);
6554
  get_neighbors (nb, a_ref);
7275
  FORLIM = atom[a_ref - 1].neighbor_count;
6555
  FORLIM = atom[a_ref - 1].neighbor_count;
7276
  for (i = 0; i < FORLIM; i++)
6556
  for (i = 0; i < FORLIM; i++) {
7277
    {
-
 
7278
      bt = bond[get_bond (a_ref, nb[i]) - 1].btype;     /* v0.3k */
6557
    bt = bond[get_bond (a_ref, nb[i]) - 1].btype;       /* v0.3k */
7279
      strcpy (nb_el, atom[nb[i] - 1].element);  /* v0.3k */
6558
    strcpy (nb_el, atom[nb[i] - 1].element);    /* v0.3k */
7280
      ha = atom[nb[i] - 1].heavy;       /* v0.3k */
6559
    ha = atom[nb[i] - 1].heavy; /* v0.3k */
7281
      if (bt == 'S')
6560
    if (bt == 'S') {
7282
        {
-
 
7283
          if (ha)
6561
            if (ha)
7284
            bo_sum += 1.0;
6562
              bo_sum += 1.0;
7285
          if (strcmp (nb_el, "C ") && strcmp (nb_el, "H ")
6563
            if (strcmp (nb_el, "C ") && strcmp (nb_el, "H ")
7286
              /*&&  strcmp (nb_el, "D ") */  && strcmp (nb_el, "DU"))
6564
                /*&&  strcmp (nb_el, "D ") */  && strcmp (nb_el, "DU")) {
7287
            {                   /* added 'D ' in v0.3n */
6565
                /* added 'D ' in v0.3n */
7288
              het_count++;
6566
              het_count++;
7289
              if (!strcmp (nb_el, "O "))
6567
              if (!strcmp (nb_el, "O ")) {
7290
                {
-
 
7291
                  o_count++;
6568
                      o_count++;
7292
                  if (atom[nb[i] - 1].neighbor_count > 1)
6569
                      if (atom[nb[i] - 1].neighbor_count > 1)
7293
                    or_count++;
6570
                        or_count++;
7294
                }
6571
                    }
7295
            }
6572
            }
7296
          if (is_alkyl (a_ref, nb[i]) || is_aryl (a_ref, nb[i]) |
6573
            if (is_alkyl (a_ref, nb[i]) || is_aryl (a_ref, nb[i]) |
7297
              is_alkenyl (a_ref, nb[i]) || is_alkynyl (a_ref, nb[i]))
6574
                is_alkenyl (a_ref, nb[i]) || is_alkynyl (a_ref, nb[i]))
7298
            /* v0.3k */
6575
              /* v0.3k */
7299
            r_count++;
6576
              r_count++;
7300
        }
6577
          }
7301
      if (bt == 'D')
6578
    if (bt == 'D') {
7302
        {
-
 
7303
          if (ha)
6579
            if (ha)
7304
            bo_sum += 2.0;
6580
              bo_sum += 2.0;
7305
          if (strcmp (nb_el, "C "))
6581
            if (strcmp (nb_el, "C ")) {
7306
            {
-
 
7307
              het_count += 2;
6582
              het_count += 2;
7308
              if (!strcmp (nb_el, "O "))
6583
              if (!strcmp (nb_el, "O "))
7309
                o_count += 2;
6584
                      o_count += 2;
7310
            }
6585
            }
7311
          if (!strcmp (nb_el, "C "))
6586
            if (!strcmp (nb_el, "C "))
7312
            r_count++;
6587
              r_count++;
7313
        }
6588
          }
7314
      if (bt == 'A' && ha)
6589
    if (bt == 'A' && ha)
7315
        bo_sum += 1.5;
6590
            bo_sum += 1.5;
7316
    }                           /* v0.3k: corrected end of "for ..." loop */
6591
  }                             /* v0.3k: corrected end of "for ..." loop */
7317
  if (het_count == 0 && r_count == 4)
6592
  if (het_count == 0 && r_count == 4)
7318
    fg[fg_quart_ammonium - 1] = true;
6593
    fg[fg_quart_ammonium - 1] = true;
7319
  if (het_count != 1 || atom[a_ref - 1].neighbor_count < 3)
6594
  if (het_count != 1 || atom[a_ref - 1].neighbor_count < 3)
7320
    return;
6595
    return;
7321
  if (o_count == 1 && or_count == 0 && bo_sum > 3)
6596
  if (o_count == 1 && or_count == 0 && bo_sum > 3)
Line 7323... Line 6598...
7323
  if (((o_count == 1 && or_count == 1) || o_count == 0) &&
6598
  if (((o_count == 1 && or_count == 1) || o_count == 0) &&
7324
      atom[a_ref - 1].arom == true)
6599
      atom[a_ref - 1].arom == true)
7325
    fg[fg_quart_ammonium - 1] = true;
6600
    fg[fg_quart_ammonium - 1] = true;
7326
}
6601
}
7327
 
6602
 
7328
 
-
 
7329
static void
-
 
7330
swap_atoms (a1, a2)
6603
static void swap_atoms (a1, a2)
7331
     int *a1, *a2;
6604
     int *a1, *a2;
7332
{
6605
{
7333
  int a_tmp;
6606
  int a_tmp;
7334
 
6607
 
7335
  a_tmp = *a1;
6608
  a_tmp = *a1;
7336
  *a1 = *a2;
6609
  *a1 = *a2;
7337
  *a2 = a_tmp;
6610
  *a2 = a_tmp;
7338
}
6611
}
7339
 
6612
 
7340
 
-
 
7341
static void
-
 
7342
orient_bond (a1, a2)
6613
static void orient_bond (a1, a2)
7343
     int *a1, *a2;
6614
     int *a1, *a2;
7344
{
6615
{
7345
  str2 a1_el, a2_el;
6616
  str2 a1_el, a2_el;
7346
 
6617
 
7347
  strcpy (a1_el, atom[*a1 - 1].element);
6618
  strcpy (a1_el, atom[*a1 - 1].element);
Line 7350... Line 6621...
7350
      || !strcmp (a1_el, "D ") || !strcmp (a2_el, "D "))
6621
      || !strcmp (a1_el, "D ") || !strcmp (a2_el, "D "))
7351
    /* v0.3n: D */
6622
    /* v0.3n: D */
7352
    return;
6623
    return;
7353
  if (!strcmp (a2_el, "C ") && strcmp (a1_el, "C "))
6624
  if (!strcmp (a2_el, "C ") && strcmp (a1_el, "C "))
7354
    swap_atoms (a1, a2);
6625
    swap_atoms (a1, a2);
7355
  if (!strcmp (a2_el, a1_el))
6626
  if (!strcmp (a2_el, a1_el)) {
7356
    {
-
 
7357
      if (hetbond_count (*a1) > hetbond_count (*a2))
6627
    if (hetbond_count (*a1) > hetbond_count (*a2))
7358
        swap_atoms (a1, a2);
-
 
7359
    }
-
 
7360
  if (strcmp (a2_el, "C ") && strcmp (a1_el, "C ") && strcmp (a1_el, a2_el))
-
 
7361
    {
-
 
7362
      if (!strcmp (a1_el, "O ") || !strcmp (a2_el, "O "))
-
 
7363
        {
-
 
7364
          if (!strcmp (a1_el, "O "))
-
 
7365
            swap_atoms (a1, a2);
6628
            swap_atoms (a1, a2);
-
 
6629
  }
-
 
6630
  if (strcmp (a2_el, "C ") && strcmp (a1_el, "C ") && strcmp (a1_el, a2_el)) {
-
 
6631
    if (!strcmp (a1_el, "O ") || !strcmp (a2_el, "O ")) {
-
 
6632
            if (!strcmp (a1_el, "O "))
-
 
6633
              swap_atoms (a1, a2);
7366
        }
6634
          }
7367
    }
6635
  }
7368
  if (strcmp (a2_el, "C ") && strcmp (a1_el, "C ") && !strcmp (a1_el, a2_el))
6636
  if (strcmp (a2_el, "C ") && strcmp (a1_el, "C ") && !strcmp (a1_el, a2_el)) {
7369
    {
-
 
7370
      if (atom[*a2 - 1].neighbor_count - hetbond_count (*a2) >
6637
      if (atom[*a2 - 1].neighbor_count - hetbond_count (*a2) >
7371
          atom[*a1 - 1].neighbor_count - hetbond_count (*a1))
6638
              atom[*a1 - 1].neighbor_count - hetbond_count (*a1))
7372
        swap_atoms (a1, a2);
6639
          swap_atoms (a1, a2);
7373
    }
6640
  }
7374
}
6641
}
7375
 
-
 
7376
 
6642
 
7377
static void
-
 
7378
chk_imine (a_ref, a_view)
6643
static void chk_imine (a_ref, a_view)
7379
     int a_ref, a_view;
6644
     int a_ref, a_view;
7380
{
6645
{
7381
  /* a_ref = C, a_view = N */
6646
  /* a_ref = C, a_view = N */
7382
  int i;
6647
  int i;
7383
  neighbor_rec nb;
6648
  neighbor_rec nb;
Line 7385... Line 6650...
7385
  int a_het = 0, a_c;
6650
  int a_het = 0, a_c;
7386
  int het_count = 0, c_count = 0, o_count = 0;  /* v0.3k */
6651
  int het_count = 0, c_count = 0, o_count = 0;  /* v0.3k */
7387
  int FORLIM;
6652
  int FORLIM;
7388
 
6653
 
7389
  /* v0.3k */
6654
  /* v0.3k */
7390
  if (atom[a_view - 1].neighbor_count == 1)
6655
  if (atom[a_view - 1].neighbor_count == 1) {
7391
    {
-
 
7392
      if (atom[a_ref - 1].arom == false)
6656
      if (atom[a_ref - 1].arom == false)
7393
        fg[fg_imine - 1] = true;
6657
        fg[fg_imine - 1] = true;
7394
      return;
6658
      return;
7395
    }
6659
    }
7396
  memset (nb, 0, sizeof (neighbor_rec));
6660
  memset (nb, 0, sizeof (neighbor_rec));
7397
  get_neighbors (nb, a_view);
6661
  get_neighbors (nb, a_view);
7398
  if (atom[a_view - 1].neighbor_count <= 1)
6662
  if (atom[a_view - 1].neighbor_count <= 1)
7399
    return;
6663
    return;
7400
  FORLIM = atom[a_view - 1].neighbor_count;
6664
  FORLIM = atom[a_view - 1].neighbor_count;
7401
  for (i = 0; i < FORLIM; i++)
6665
  for (i = 0; i < FORLIM; i++) {
7402
    {
-
 
7403
      if ((nb[i] != a_ref) && (bond[get_bond (a_view, nb[i]) - 1].btype ==
6666
    if ((nb[i] != a_ref) && (bond[get_bond (a_view, nb[i]) - 1].btype == 'S')){
7404
                               'S'))
-
 
7405
        {
-
 
7406
          strcpy (nb_el, atom[nb[i] - 1].element);
6667
            strcpy (nb_el, atom[nb[i] - 1].element);
7407
          if (!strcmp (nb_el, "C "))
6668
            if (!strcmp (nb_el, "C ")) {
7408
            {
-
 
7409
              a_c = nb[i];
6669
              a_c = nb[i];
7410
              c_count++;
6670
              c_count++;
7411
            }
6671
            }
7412
          if (!strcmp (nb_el, "O ") || !strcmp (nb_el, "N "))
6672
            if (!strcmp (nb_el, "O ") || !strcmp (nb_el, "N ")) {
7413
            {
-
 
7414
              a_het = nb[i];
6673
              a_het = nb[i];
7415
              het_count++;
6674
              het_count++;
7416
            }
6675
            }
7417
          if ((!strcmp (nb_el, "O ")
6676
            if ((!strcmp (nb_el, "O ")
7418
               && atom[nb[i] - 1].neighbor_count ==
-
 
7419
               1) && (bond[get_bond (a_view, nb[i]) - 1].arom == false))
-
 
7420
            /* v0.3k */
-
 
7421
            o_count++;
-
 
7422
        }
-
 
7423
      if ((nb[i] != a_ref) && (bond[get_bond (a_view, nb[i]) - 1].btype ==
-
 
7424
                               'D'))
-
 
7425
        {                       /* v0.3k; make sure we do not count nitro groups in "azi" form etc. */
-
 
7426
          strcpy (nb_el, atom[nb[i] - 1].element);
-
 
7427
          if (!strcmp (nb_el, "O ") || !strcmp (nb_el, "N ")
-
 
7428
              || !strcmp (nb_el, "S "))
-
 
7429
            {
-
 
7430
              a_het = nb[i];    /* v0.3m */
-
 
7431
              het_count++;
-
 
7432
            }
-
 
7433
          if ((!strcmp (nb_el, "O ")
-
 
7434
               && atom[nb[i] - 1].neighbor_count ==
6677
               && atom[nb[i] - 1].neighbor_count ==
7435
               1) && (bond[get_bond (a_view, nb[i]) - 1].arom == false))
6678
               1) && (bond[get_bond (a_view, nb[i]) - 1].arom == false))
-
 
6679
              /* v0.3k */
-
 
6680
              o_count++;
-
 
6681
          }
-
 
6682
    if ((nb[i] != a_ref) && (bond[get_bond (a_view, nb[i]) - 1].btype == 'D')){
-
 
6683
      /* v0.3k; make sure we do not count nitro groups in "azi" form etc. */
-
 
6684
            strcpy (nb_el, atom[nb[i] - 1].element);
-
 
6685
            if (!strcmp (nb_el, "O ") || !strcmp (nb_el, "N ") || !strcmp (nb_el, "S ")) {
-
 
6686
              a_het = nb[i];    /* v0.3m */
-
 
6687
              het_count++;
-
 
6688
            }
-
 
6689
            if ((!strcmp (nb_el, "O ")
-
 
6690
                && atom[nb[i] - 1].neighbor_count == 1) &&
-
 
6691
                  (bond[get_bond (a_view, nb[i]) - 1].arom == false))
-
 
6692
              /* v0.3k */
-
 
6693
              o_count++;
-
 
6694
          }
-
 
6695
  }
-
 
6696
  if (c_count == 1) {
-
 
6697
    if ((is_alkyl (a_view, a_c) || is_aryl (a_view, a_c) |
-
 
6698
              is_alkenyl (a_view, a_c) || is_alkynyl (a_view, a_c))
-
 
6699
              && atom[a_ref - 1].arom == false && het_count == 0)
7436
            /* v0.3k */
6700
            /* v0.3k */
7437
            o_count++;
-
 
7438
        }
-
 
7439
    }
-
 
7440
  if (c_count == 1)
-
 
7441
    {
-
 
7442
      if ((is_alkyl (a_view, a_c) || is_aryl (a_view, a_c) |
-
 
7443
           is_alkenyl (a_view, a_c) || is_alkynyl (a_view, a_c))
-
 
7444
          && atom[a_ref - 1].arom == false && het_count == 0)
-
 
7445
        /* v0.3k */
-
 
7446
        fg[fg_imine - 1] = true;
6701
            fg[fg_imine - 1] = true;
7447
    }
6702
  }
7448
  if (het_count == 1)
6703
  if (het_count == 1) {
7449
    {
-
 
7450
      strcpy (nb_el, atom[a_het - 1].element);
6704
    strcpy (nb_el, atom[a_het - 1].element);
7451
      if (!strcmp (nb_el, "O "))
6705
    if (!strcmp (nb_el, "O ")) {
7452
        {
-
 
7453
          if (is_hydroxy (a_view, a_het))
6706
            if (is_hydroxy (a_view, a_het))
7454
            fg[fg_oxime - 1] = true;
6707
              fg[fg_oxime - 1] = true;
7455
          if (is_alkoxy (a_view, a_het) || is_aryloxy (a_view, a_het) |
6708
          if (is_alkoxy (a_view, a_het) || is_aryloxy (a_view, a_het) |
7456
              is_alkenyloxy (a_view, a_het) || is_alkynyloxy (a_view, a_het))
6709
              is_alkenyloxy (a_view, a_het) || is_alkynyloxy (a_view, a_het))
7457
            fg[fg_oxime_ether - 1] = true;
6710
            fg[fg_oxime_ether - 1] = true;
7458
        }
6711
          }
7459
      if (!strcmp (nb_el, "N "))
6712
    if (!strcmp (nb_el, "N ")) {
7460
        {
-
 
7461
          if (is_amino (a_view, a_het) || is_alkylamino (a_view, a_het) |
6713
            if (is_amino (a_view, a_het) || is_alkylamino (a_view, a_het) |
7462
              is_dialkylamino (a_view, a_het) || is_alkylarylamino (a_view,
6714
                is_dialkylamino (a_view, a_het) || is_alkylarylamino (a_view,a_het) |
7463
                                                                    a_het) |
-
 
7464
              is_arylamino (a_view, a_het) || is_diarylamino (a_view, a_het))
6715
                is_arylamino (a_view, a_het) || is_diarylamino (a_view, a_het))
7465
            fg[fg_hydrazone - 1] = true;
6716
              fg[fg_hydrazone - 1] = true;
7466
          else
6717
            else {
7467
            {
-
 
7468
              memset (nb, 0, sizeof (neighbor_rec));
6718
              memset (nb, 0, sizeof (neighbor_rec));
7469
              get_neighbors (nb, a_het);
6719
              get_neighbors (nb, a_het);
7470
              if (atom[a_het - 1].neighbor_count > 1)
6720
              if (atom[a_het - 1].neighbor_count > 1) {
7471
                {
-
 
7472
                  FORLIM = atom[a_het - 1].neighbor_count;
6721
                      FORLIM = atom[a_het - 1].neighbor_count;
7473
                  for (i = 0; i < FORLIM; i++)
6722
                      for (i = 0; i < FORLIM; i++) {
7474
                    {
-
 
7475
                      if (nb[i] != a_view)
6723
                        if (nb[i] != a_view) {
7476
                        {
-
 
7477
                          if (is_carbamoyl (a_het, nb[i]))
6724
                                if (is_carbamoyl (a_het, nb[i]))
7478
                            fg[fg_semicarbazone - 1] = true;
6725
                                  fg[fg_semicarbazone - 1] = true;
7479
                          if (is_thiocarbamoyl (a_het, nb[i]))
6726
                                if (is_thiocarbamoyl (a_het, nb[i]))
7480
                            fg[fg_thiosemicarbazone - 1] = true;
6727
                                  fg[fg_thiosemicarbazone - 1] = true;
7481
                        }
6728
                              }
-
 
6729
                      }
7482
                    }
6730
                    }
7483
                }
-
 
7484
            }
6731
            }
7485
        }
6732
          }
7486
    }                           /* v0.3k: nitro groups in "azi" form */
6733
  }                             /* v0.3k: nitro groups in "azi" form */
7487
  /* check for semicarbazone or thiosemicarbazone */
6734
  /* check for semicarbazone or thiosemicarbazone */
7488
  if (het_count == 2 && o_count == 2)
6735
  if (het_count == 2 && o_count == 2)
7489
    fg[fg_nitro_compound - 1] = true;
6736
    fg[fg_nitro_compound - 1] = true;
7490
}
6737
}
7491
 
6738
 
7492
 
-
 
7493
static void
-
 
7494
chk_carbonyl_deriv (a_view, a_ref)
6739
static void chk_carbonyl_deriv (a_view, a_ref)
7495
     int a_view, a_ref;
6740
     int a_view, a_ref;
7496
{
6741
{
7497
  /* a_view = C */
6742
  /* a_view = C */
7498
  int i;
6743
  int i;
7499
  neighbor_rec nb;
6744
  neighbor_rec nb;
7500
  str2 nb_el;
6745
  str2 nb_el;
7501
  int c_count = 0, cn_count = 0;
6746
  int c_count = 0, cn_count = 0;
7502
  char bt;                      /* new in v0.3b */
6747
  char bt;                      /* new in v0.3b */
7503
  int n_db = 0;                 /* new in v0.3b */
6748
  int n_db = 0;                 /* new in v0.3b */
7504
  int FORLIM;
6749
  int FORLIM;
7505
 
6750
 
7506
  memset (nb, 0, sizeof (neighbor_rec));
6751
  memset (nb, 0, sizeof (neighbor_rec));
7507
  get_neighbors (nb, a_view);
6752
  get_neighbors (nb, a_view);
7508
  FORLIM = atom[a_view - 1].neighbor_count;
6753
  FORLIM = atom[a_view - 1].neighbor_count;
7509
  /* new in v0.3b */
6754
  /* new in v0.3b */
7510
  for (i = 0; i < FORLIM; i++)
6755
  for (i = 0; i < FORLIM; i++) {
7511
    {
-
 
7512
      bt = bond[get_bond (a_view, nb[i]) - 1].btype;
6756
    bt = bond[get_bond (a_view, nb[i]) - 1].btype;
7513
      if (bt == 'S')
6757
    if (bt == 'S') {
7514
        {
-
 
7515
          strcpy (nb_el, atom[nb[i] - 1].element);
6758
            strcpy (nb_el, atom[nb[i] - 1].element);
7516
          if (!strcmp (nb_el, "C "))
6759
            if (!strcmp (nb_el, "C ")) {
7517
            {
-
 
7518
              if (is_cyano_c (nb[i]))
6760
              if (is_cyano_c (nb[i]))
7519
                cn_count++;
6761
                      cn_count++;
7520
              else
6762
              else
7521
                c_count++;
6763
                      c_count++;
7522
            }
6764
            }
7523
        }
6765
          }
7524
      else
6766
    else {
7525
        {
-
 
7526
          if (bt == 'D')
6767
            if (bt == 'D')
7527
            n_db++;
6768
              n_db++;
7528
        }
6769
          }
7529
    }
6770
  }
7530
  /* new in v0.3b */
6771
  /* new in v0.3b */
7531
  if (is_oxo_C (a_view))
6772
  if (is_oxo_C (a_view)) {
7532
    {
-
 
7533
      fg[fg_carbonyl - 1] = true;
6773
    fg[fg_carbonyl - 1] = true;
7534
      if (c_count + cn_count < 2)
-
 
7535
        {                       /* new in v0.3b (detection of ketenes) */
6774
    if (c_count + cn_count < 2) {                       /* new in v0.3b (detection of ketenes) */
7536
          if (n_db <= 1)
6775
            if (n_db <= 1)
7537
            fg[fg_aldehyde - 1] = true;
6776
              fg[fg_aldehyde - 1] = true;
7538
          else
6777
            else
7539
            fg[fg_ketene - 1] = true;
6778
              fg[fg_ketene - 1] = true;
7540
        }
6779
          }
7541
      if (c_count == 2)
6780
    if (c_count == 2) {
7542
        {
-
 
7543
          if (atom[a_view - 1].arom)
6781
            if (atom[a_view - 1].arom)
7544
            fg[fg_oxohetarene - 1] = true;
6782
              fg[fg_oxohetarene - 1] = true;
7545
          else
6783
            else
7546
            fg[fg_ketone - 1] = true;
6784
              fg[fg_ketone - 1] = true;
7547
        }
6785
          }
7548
      if (cn_count > 0)
6786
    if (cn_count > 0)
7549
        fg[fg_acyl_cyanide - 1] = true;
6787
            fg[fg_acyl_cyanide - 1] = true;
7550
    }
6788
  }
7551
  if (is_thioxo_C (a_view))
6789
  if (is_thioxo_C (a_view)) {
7552
    {
-
 
7553
      fg[fg_thiocarbonyl - 1] = true;
6790
    fg[fg_thiocarbonyl - 1] = true;
7554
      if (c_count < 2)
6791
    if (c_count < 2)
7555
        fg[fg_thioaldehyde - 1] = true;
6792
            fg[fg_thioaldehyde - 1] = true;
7556
      if (c_count == 2)
6793
    if (c_count == 2) {
7557
        {
-
 
7558
          if (atom[a_view - 1].arom)
6794
            if (atom[a_view - 1].arom)
7559
            fg[fg_thioxohetarene - 1] = true;
6795
              fg[fg_thioxohetarene - 1] = true;
7560
          else
6796
            else
7561
            fg[fg_thioketone - 1] = true;
6797
              fg[fg_thioketone - 1] = true;
7562
        }
6798
          }
7563
    }
6799
  }
7564
  if (is_imino_C (a_view))
6800
  if (is_imino_C (a_view))
7565
    chk_imine (a_view, a_ref);
6801
    chk_imine (a_view, a_ref);
7566
}
6802
}
7567
 
-
 
7568
 
6803
 
7569
static void
-
 
7570
chk_carboxyl_deriv (a_view, a_ref)
6804
static void chk_carboxyl_deriv (a_view, a_ref)
7571
     int a_view, a_ref;
6805
     int a_view, a_ref;
7572
{
6806
{
7573
  int i;
6807
  int i;
7574
  neighbor_rec nb;
6808
  neighbor_rec nb;
7575
  str2 nb_el;
6809
  str2 nb_el;
Line 7577... Line 6811...
7577
  int a_o = 0, a_n = 0, a_s = 0, FORLIM;
6811
  int a_o = 0, a_n = 0, a_s = 0, FORLIM;
7578
 
6812
 
7579
  memset (nb, 0, sizeof (neighbor_rec));
6813
  memset (nb, 0, sizeof (neighbor_rec));
7580
  get_neighbors (nb, a_view);
6814
  get_neighbors (nb, a_view);
7581
  FORLIM = atom[a_view - 1].neighbor_count;
6815
  FORLIM = atom[a_view - 1].neighbor_count;
7582
  for (i = 0; i < FORLIM; i++)
6816
  for (i = 0; i < FORLIM; i++) {
7583
    {
-
 
7584
      if (bond[get_bond (a_view, nb[i]) - 1].btype == 'S')
6817
    if (bond[get_bond (a_view, nb[i]) - 1].btype == 'S') {
7585
        {
-
 
7586
          strcpy (nb_el, atom[nb[i] - 1].element);
6818
            strcpy (nb_el, atom[nb[i] - 1].element);
7587
          if (strcmp (nb_el, "C "))
6819
            if (strcmp (nb_el, "C ")) {
7588
            {
-
 
7589
              if (!strcmp (nb_el, "O "))
6820
              if (!strcmp (nb_el, "O ")) {
7590
                {
-
 
7591
                  o_count++;
6821
                      o_count++;
7592
                  a_o = nb[i];
6822
                      a_o = nb[i];
7593
                }
6823
                    }
7594
              if (!strcmp (nb_el, "N "))
6824
              if (!strcmp (nb_el, "N ")) {
7595
                {
-
 
7596
                  n_count++;
6825
                      n_count++;
7597
                  a_n = nb[i];
6826
                      a_n = nb[i];
7598
                }
6827
                    }
7599
              if (!strcmp (nb_el, "S "))
6828
              if (!strcmp (nb_el, "S ")) {
7600
                {
-
 
7601
                  s_count++;
6829
                      s_count++;
7602
                  a_s = nb[i];
6830
                      a_s = nb[i];
7603
                }
6831
                    }
7604
            }
6832
            }
7605
        }
6833
          }
7606
    }
6834
  }
7607
  if (is_oxo_C (a_view))
6835
  if (is_oxo_C (a_view)) {
7608
    {
-
 
7609
      if (o_count == 1)
-
 
7610
        {                       /* anhydride is checked somewhere else */
6836
    if (o_count == 1) {                 /* anhydride is checked somewhere else */
7611
          if (bond[get_bond (a_view, a_o) - 1].arom == false)
6837
            if (bond[get_bond (a_view, a_o) - 1].arom == false)
7612
            fg[fg_carboxylic_acid_deriv - 1] = true;
6838
              fg[fg_carboxylic_acid_deriv - 1] = true;
7613
          if (is_hydroxy (a_view, a_o))
6839
            if (is_hydroxy (a_view, a_o)) {
7614
            {
-
 
7615
              if (atom[a_o - 1].formal_charge == 0)
6840
              if (atom[a_o - 1].formal_charge == 0)
7616
                fg[fg_carboxylic_acid - 1] = true;
6841
                      fg[fg_carboxylic_acid - 1] = true;
7617
              if (atom[a_o - 1].formal_charge == -1)
6842
              if (atom[a_o - 1].formal_charge == -1)
7618
                fg[fg_carboxylic_acid_salt - 1] = true;
6843
                      fg[fg_carboxylic_acid_salt - 1] = true;
7619
            }
6844
            }
7620
          if (is_alkoxy (a_view, a_o) || is_aryloxy (a_view, a_o) |
6845
            if (is_alkoxy (a_view, a_o) || is_aryloxy (a_view, a_o) |
7621
              is_alkenyloxy (a_view, a_o) || is_alkynyloxy (a_view, a_o))
6846
                is_alkenyloxy (a_view, a_o) || is_alkynyloxy (a_view, a_o)) {
7622
            {
-
 
7623
              if (bond[get_bond (a_view, a_o) - 1].arom == false)
6847
              if (bond[get_bond (a_view, a_o) - 1].arom == false)
7624
                fg[fg_carboxylic_acid_ester - 1] = true;
6848
                      fg[fg_carboxylic_acid_ester - 1] = true;
7625
              if (bond[get_bond (a_view, a_o) - 1].ring_count > 0)
6849
              if (bond[get_bond (a_view, a_o) - 1].ring_count > 0) {
7626
                {
-
 
7627
                  if (bond[get_bond (a_view, a_o) - 1].arom == true)
6850
                      if (bond[get_bond (a_view, a_o) - 1].arom == true) {
7628
                    {
-
 
7629
                      /*fg[fg_lactone_heteroarom] := true else fg[fg_lactone] := true; */
6851
                        /*fg[fg_lactone_heteroarom] := true else fg[fg_lactone] := true; */
7630
                      fg[fg_oxohetarene - 1] = true;
6852
                        fg[fg_oxohetarene - 1] = true;
-
 
6853
                      }
-
 
6854
                    else
-
 
6855
                      fg[fg_lactone - 1] = true;
7631
                    }
6856
                    }
7632
                  else
-
 
7633
                    fg[fg_lactone - 1] = true;
-
 
7634
                }
-
 
7635
            }
6857
            }
7636
        }
6858
          }
7637
      if (n_count == 1)
6859
    if (n_count == 1) {
7638
        {
-
 
7639
          if (bond[get_bond (a_view, a_n) - 1].arom == false)
6860
            if (bond[get_bond (a_view, a_n) - 1].arom == false)
7640
            fg[fg_carboxylic_acid_deriv - 1] = true;
6861
              fg[fg_carboxylic_acid_deriv - 1] = true;
7641
          else
6862
            else {
7642
            {
-
 
7643
              /*fg[fg_lactam_heteroarom] := true;  (* catches also pyridazines, 1,2,3-triazines, etc. */
6863
              /*fg[fg_lactam_heteroarom] := true;  (* catches also pyridazines, 1,2,3-triazines, etc. */
7644
              fg[fg_oxohetarene - 1] = true;
6864
              fg[fg_oxohetarene - 1] = true;
7645
            }
6865
            }
7646
          if (is_amino (a_view, a_n)
-
 
7647
              || (!strcmp (atom[a_n - 1].atype, "NAM")
6866
            if (is_amino (a_view, a_n) || (!strcmp (atom[a_n - 1].atype, "NAM")
7648
                  && atom[a_n - 1].neighbor_count == 1))
6867
                      && atom[a_n - 1].neighbor_count == 1)) {
7649
            {
-
 
7650
              fg[fg_carboxylic_acid_amide - 1] = true;
6868
              fg[fg_carboxylic_acid_amide - 1] = true;
7651
              fg[fg_carboxylic_acid_prim_amide - 1] = true;
6869
              fg[fg_carboxylic_acid_prim_amide - 1] = true;
7652
            }
6870
            }
7653
          /*if (is_alkylamino(a_view,a_n)) or (is_arylamino(a_view,a_n)) then  */
6871
            /*if (is_alkylamino(a_view,a_n)) or (is_arylamino(a_view,a_n)) then  */
7654
          if (is_C_monosubst_amino (a_view, a_n) &
6872
            if (is_C_monosubst_amino (a_view, a_n) &
7655
              (!is_subst_acylamino (a_view, a_n)))
6873
                (!is_subst_acylamino (a_view, a_n))) {                  /* v0.3j */
7656
            {                   /* v0.3j */
-
 
7657
              if (bond[get_bond (a_view, a_n) - 1].arom == false)
6874
              if (bond[get_bond (a_view, a_n) - 1].arom == false)
7658
                fg[fg_carboxylic_acid_amide - 1] = true;
6875
                      fg[fg_carboxylic_acid_amide - 1] = true;
7659
              if (bond[get_bond (a_view, a_n) - 1].arom == false)
6876
              if (bond[get_bond (a_view, a_n) - 1].arom == false)
7660
                fg[fg_carboxylic_acid_sec_amide - 1] = true;
6877
                      fg[fg_carboxylic_acid_sec_amide - 1] = true;
7661
              if (bond[get_bond (a_view, a_n) - 1].ring_count > 0)
6878
              if (bond[get_bond (a_view, a_n) - 1].ring_count > 0) {
7662
                {
-
 
7663
                  if (bond[get_bond (a_view, a_n) - 1].arom == true)
6879
                      if (bond[get_bond (a_view, a_n) - 1].arom == true) {
7664
                    {
-
 
7665
                      /*fg[fg_lactam_heteroarom]    := true else  */
6880
                        /*fg[fg_lactam_heteroarom]    := true else  */
7666
                      fg[fg_oxohetarene - 1] = true;
6881
                        fg[fg_oxohetarene - 1] = true;
7667
                    }
6882
                      }
7668
                  else
6883
                      else
7669
                    fg[fg_lactam - 1] = true;
6884
                        fg[fg_lactam - 1] = true;
7670
                }
6885
                    }
7671
            }
6886
            }
7672
          /*if (is_dialkylamino(a_view,a_n)) or (is_alkylarylamino(a_view,a_n)) or */
6887
            /*if (is_dialkylamino(a_view,a_n)) or (is_alkylarylamino(a_view,a_n)) or */
7673
          /*   (is_diarylamino(a_view,a_n)) then  */
6888
            /*   (is_diarylamino(a_view,a_n)) then  */
7674
          if (is_C_disubst_amino (a_view, a_n) &
-
 
7675
              (!is_subst_acylamino (a_view, a_n)))
6889
            if (is_C_disubst_amino (a_view, a_n) & (!is_subst_acylamino (a_view, a_n))) {
7676
            {                   /* v0.3j */
6890
              /* v0.3j */
7677
              if (bond[get_bond (a_view, a_n) - 1].arom == false)
6891
              if (bond[get_bond (a_view, a_n) - 1].arom == false)
7678
                fg[fg_carboxylic_acid_amide - 1] = true;
6892
                fg[fg_carboxylic_acid_amide - 1] = true;
7679
              if (bond[get_bond (a_view, a_n) - 1].arom == false)
6893
              if (bond[get_bond (a_view, a_n) - 1].arom == false)
7680
                fg[fg_carboxylic_acid_tert_amide - 1] = true;
6894
                fg[fg_carboxylic_acid_tert_amide - 1] = true;
7681
              if (bond[get_bond (a_view, a_n) - 1].ring_count > 0)
6895
              if (bond[get_bond (a_view, a_n) - 1].ring_count > 0) {
7682
                {
-
 
7683
                  if (bond[get_bond (a_view, a_n) - 1].arom == true)
6896
                if (bond[get_bond (a_view, a_n) - 1].arom == true) {
7684
                    {
-
 
7685
                      /*fg[fg_lactam_heteroarom]    := true else  */
6897
                        /*fg[fg_lactam_heteroarom]    := true else  */
7686
                      fg[fg_oxohetarene - 1] = true;
6898
                        fg[fg_oxohetarene - 1] = true;
7687
                    }
6899
                      }
7688
                  else
6900
                      else
7689
                    fg[fg_lactam - 1] = true;
6901
                        fg[fg_lactam - 1] = true;
7690
                }
6902
                    }
7691
            }
6903
            }
7692
          if (is_hydroxylamino (a_view, a_n))
6904
            if (is_hydroxylamino (a_view, a_n))
7693
            fg[fg_hydroxamic_acid - 1] = true;
6905
              fg[fg_hydroxamic_acid - 1] = true;
7694
          if (is_hydrazino (a_view, a_n))
6906
            if (is_hydrazino (a_view, a_n))
7695
            fg[fg_carboxylic_acid_hydrazide - 1] = true;
6907
              fg[fg_carboxylic_acid_hydrazide - 1] = true;
7696
          if (is_azido (a_view, a_n))
6908
            if (is_azido (a_view, a_n))
7697
            fg[fg_carboxylic_acid_azide - 1] = true;
6909
              fg[fg_carboxylic_acid_azide - 1] = true;
7698
        }
6910
          }
7699
      if (s_count == 1)
-
 
7700
        {                       /* anhydride is checked somewhere else */
6911
    if (s_count == 1) {                 /* anhydride is checked somewhere else */
7701
          if (bond[get_bond (a_view, a_s) - 1].arom == false)
6912
            if (bond[get_bond (a_view, a_s) - 1].arom == false)
7702
            fg[fg_thiocarboxylic_acid_deriv - 1] = true;
6913
              fg[fg_thiocarboxylic_acid_deriv - 1] = true;
7703
          if (is_sulfanyl (a_view, a_s))
6914
            if (is_sulfanyl (a_view, a_s))
7704
            fg[fg_thiocarboxylic_acid - 1] = true;
6915
              fg[fg_thiocarboxylic_acid - 1] = true;
7705
          if (is_alkylsulfanyl (a_view, a_s) || is_arylsulfanyl (a_view, a_s))
6916
            if (is_alkylsulfanyl (a_view, a_s) || is_arylsulfanyl (a_view, a_s)) {
7706
            {
-
 
7707
              if (bond[get_bond (a_view, a_s) - 1].arom == false)
6917
              if (bond[get_bond (a_view, a_s) - 1].arom == false)
7708
                fg[fg_thiocarboxylic_acid_ester - 1] = true;
6918
                      fg[fg_thiocarboxylic_acid_ester - 1] = true;
7709
              if (bond[get_bond (a_view, a_s) - 1].ring_count > 0)
6919
              if (bond[get_bond (a_view, a_s) - 1].ring_count > 0) {
7710
                {
-
 
7711
                  if (bond[get_bond (a_view, a_s) - 1].arom == true)
6920
                      if (bond[get_bond (a_view, a_s) - 1].arom == true) {
7712
                    {
-
 
7713
                      /*fg[fg_thiolactone_heteroarom] := true else fg[fg_thiolactone] := true; */
6921
                        /*fg[fg_thiolactone_heteroarom] := true else fg[fg_thiolactone] := true; */
7714
                      fg[fg_oxohetarene - 1] = true;
6922
                        fg[fg_oxohetarene - 1] = true;
7715
                    }
6923
                      }
7716
                  else
6924
                      else
7717
                    fg[fg_thiolactone - 1] = true;
6925
                        fg[fg_thiolactone - 1] = true;
7718
                }
6926
                    }
7719
            }
6927
            }
7720
        }
6928
          }
7721
    }                           /* end Oxo-C */
6929
  }                             /* end Oxo-C */
7722
  if (is_thioxo_C (a_view))
6930
  if (is_thioxo_C (a_view)) {
7723
    {
-
 
7724
      /* fg[fg_thiocarboxylic_acid_deriv]  := true; */
6931
    /* fg[fg_thiocarboxylic_acid_deriv]  := true; */
7725
      if (o_count == 1)
-
 
7726
        {                       /* anhydride is checked somewhere else */
6932
    if (o_count == 1) {                 /* anhydride is checked somewhere else */
7727
          if (bond[get_bond (a_view, a_o) - 1].arom == false)
6933
            if (bond[get_bond (a_view, a_o) - 1].arom == false)
7728
            fg[fg_thiocarboxylic_acid_deriv - 1] = true;
6934
              fg[fg_thiocarboxylic_acid_deriv - 1] = true;
7729
          if (is_hydroxy (a_view, a_o))
6935
            if (is_hydroxy (a_view, a_o))
7730
            fg[fg_thiocarboxylic_acid - 1] = true;      /* fixed in v0.3c */
6936
              fg[fg_thiocarboxylic_acid - 1] = true;    /* fixed in v0.3c */
7731
          if (is_alkoxy (a_view, a_o) || is_aryloxy (a_view, a_o))
6937
            if (is_alkoxy (a_view, a_o) || is_aryloxy (a_view, a_o)) {
7732
            {
-
 
7733
              if (bond[get_bond (a_view, a_s) - 1].arom == false)
6938
              if (bond[get_bond (a_view, a_s) - 1].arom == false)
7734
                fg[fg_thiocarboxylic_acid_ester - 1] = true;
6939
                      fg[fg_thiocarboxylic_acid_ester - 1] = true;
7735
              if (bond[get_bond (a_view, a_o) - 1].ring_count > 0)
6940
              if (bond[get_bond (a_view, a_o) - 1].ring_count > 0) {
7736
                {
-
 
7737
                  if (bond[get_bond (a_view, a_o) - 1].arom == true)
6941
                      if (bond[get_bond (a_view, a_o) - 1].arom == true) {
7738
                    {
-
 
7739
                      /*fg[fg_thiolactone_heteroarom] := true else fg[fg_thiolactone] := true; */
6942
                        /*fg[fg_thiolactone_heteroarom] := true else fg[fg_thiolactone] := true; */
7740
                      fg[fg_thioxohetarene - 1] = true;
6943
                        fg[fg_thioxohetarene - 1] = true;
7741
                    }
6944
                      }
7742
                  else
6945
                      else
7743
                    fg[fg_thiolactone - 1] = true;
6946
                        fg[fg_thiolactone - 1] = true;
7744
                }
6947
                    }
7745
            }
6948
            }
7746
        }
6949
          }
7747
      if (n_count == 1)
6950
    if (n_count == 1) {
7748
        {
-
 
7749
          if (bond[get_bond (a_view, a_n) - 1].arom == false)
6951
            if (bond[get_bond (a_view, a_n) - 1].arom == false)
7750
            fg[fg_thiocarboxylic_acid_deriv - 1] = true;
6952
              fg[fg_thiocarboxylic_acid_deriv - 1] = true;
7751
          else
6953
            else {
7752
            {
-
 
7753
              /*fg[fg_thiolactam_heteroarom] := true;  (* catches also pyridazines, 1,2,3-triazines, etc. */
6954
              /*fg[fg_thiolactam_heteroarom] := true;  (* catches also pyridazines, 1,2,3-triazines, etc. */
7754
              fg[fg_thioxohetarene - 1] = true;
6955
              fg[fg_thioxohetarene - 1] = true;
7755
            }
6956
            }
7756
          /* catches also pyridazines, 1,2,3-triazines, etc. */
6957
            /* catches also pyridazines, 1,2,3-triazines, etc. */
7757
          if (is_amino (a_view, a_n))
6958
            if (is_amino (a_view, a_n)){
7758
            {
-
 
7759
              fg[fg_thiocarboxylic_acid_amide - 1] = true;
6959
              fg[fg_thiocarboxylic_acid_amide - 1] = true;
7760
              /* fg[fg_thiocarboxylic_acid_prim_amide] := true; */
6960
              /* fg[fg_thiocarboxylic_acid_prim_amide] := true; */
7761
            }
6961
            }
7762
          /*if (is_alkylamino(a_view,a_n)) or (is_arylamino(a_view,a_n)) then  */
6962
            /*if (is_alkylamino(a_view,a_n)) or (is_arylamino(a_view,a_n)) then  */
7763
          if (is_C_monosubst_amino (a_view, a_n) &
-
 
7764
              (!is_subst_acylamino (a_view, a_n)))
6963
            if (is_C_monosubst_amino (a_view, a_n) & (!is_subst_acylamino (a_view, a_n))) {
7765
            {                   /* v0.3j */
6964
              /* v0.3j */
7766
              if (bond[get_bond (a_view, a_n) - 1].arom == false)
6965
              if (bond[get_bond (a_view, a_n) - 1].arom == false)
7767
                fg[fg_thiocarboxylic_acid_amide - 1] = true;
6966
                      fg[fg_thiocarboxylic_acid_amide - 1] = true;
7768
              /*fg[fg_thiocarboxylic_acid_sec_amide]  := true; */
6967
              /*fg[fg_thiocarboxylic_acid_sec_amide]  := true; */
7769
              if (bond[get_bond (a_view, a_n) - 1].ring_count > 0)
6968
              if (bond[get_bond (a_view, a_n) - 1].ring_count > 0) {
7770
                {
-
 
7771
                  if (bond[get_bond (a_view, a_n) - 1].arom == true)
6969
                      if (bond[get_bond (a_view, a_n) - 1].arom == true) {
7772
                    {
-
 
7773
                      /*fg[fg_thiolactam_heteroarom] := true else fg[fg_thiolactam] := true; */
6970
                        /*fg[fg_thiolactam_heteroarom] := true else fg[fg_thiolactam] := true; */
7774
                      fg[fg_thioxohetarene - 1] = true;
6971
                        fg[fg_thioxohetarene - 1] = true;
7775
                    }
6972
                    }
7776
                  else
6973
                    else
7777
                    fg[fg_thiolactam - 1] = true;
6974
                      fg[fg_thiolactam - 1] = true;
7778
                }
6975
                  }
7779
            }
6976
          }
7780
          /*if (is_dialkylamino(a_view,a_n)) or (is_alkylarylamino(a_view,a_n)) or */
6977
          /*if (is_dialkylamino(a_view,a_n)) or (is_alkylarylamino(a_view,a_n)) or */
7781
          /*   (is_diarylamino(a_view,a_n)) then  */
6978
          /*   (is_diarylamino(a_view,a_n)) then  */
7782
          if (is_C_disubst_amino (a_view, a_n) &
-
 
7783
              (!is_subst_acylamino (a_view, a_n)))
6979
          if (is_C_disubst_amino (a_view, a_n) & (!is_subst_acylamino (a_view, a_n))) {
7784
            {                   /* v0.3j */
6980
            /* v0.3j */
7785
              if (bond[get_bond (a_view, a_n) - 1].arom == false)
6981
            if (bond[get_bond (a_view, a_n) - 1].arom == false)
7786
                fg[fg_thiocarboxylic_acid_amide - 1] = true;
6982
                    fg[fg_thiocarboxylic_acid_amide - 1] = true;
7787
              /*fg[fg_thiocarboxylic_acid_tert_amide] := true; */
6983
              /*fg[fg_thiocarboxylic_acid_tert_amide] := true; */
7788
              if (bond[get_bond (a_view, a_n) - 1].ring_count > 0)
6984
            if (bond[get_bond (a_view, a_n) - 1].ring_count > 0) {
7789
                {
-
 
7790
                  if (bond[get_bond (a_view, a_n) - 1].arom == true)
6985
                    if (bond[get_bond (a_view, a_n) - 1].arom == true) {
7791
                    {
-
 
7792
                      /*fg[fg_thiolactam_heteroarom] := true else fg[fg_thiolactam] := true; */
6986
                      /*fg[fg_thiolactam_heteroarom] := true else fg[fg_thiolactam] := true; */
7793
                      fg[fg_thioxohetarene - 1] = true;
6987
                      fg[fg_thioxohetarene - 1] = true;
7794
                    }
6988
                    }
7795
                  else
6989
                    else
7796
                    fg[fg_thiolactam - 1] = true;
6990
                      fg[fg_thiolactam - 1] = true;
7797
                }
6991
                  }
7798
            }
6992
          }
7799
        }
6993
        }
7800
      if (s_count == 1)
-
 
7801
        {                       /* anhydride is checked somewhere else */
6994
  if (s_count == 1) {                   /* anhydride is checked somewhere else */
7802
          if (bond[get_bond (a_view, a_s) - 1].arom == false)
6995
          if (bond[get_bond (a_view, a_s) - 1].arom == false)
7803
            fg[fg_thiocarboxylic_acid_deriv - 1] = true;
6996
            fg[fg_thiocarboxylic_acid_deriv - 1] = true;
7804
          if (is_sulfanyl (a_view, a_s))
6997
          if (is_sulfanyl (a_view, a_s))
7805
            fg[fg_thiocarboxylic_acid - 1] = true;
6998
            fg[fg_thiocarboxylic_acid - 1] = true;
7806
          if (is_alkylsulfanyl (a_view, a_s) || is_arylsulfanyl (a_view, a_s))
6999
          if (is_alkylsulfanyl (a_view, a_s) || is_arylsulfanyl (a_view, a_s)) {
7807
            {
-
 
7808
              if (bond[get_bond (a_view, a_s) - 1].arom == false)
7000
      if (bond[get_bond (a_view, a_s) - 1].arom == false)
7809
                fg[fg_thiocarboxylic_acid_ester - 1] = true;
7001
                    fg[fg_thiocarboxylic_acid_ester - 1] = true;
7810
              if (bond[get_bond (a_view, a_s) - 1].ring_count > 0)
7002
              if (bond[get_bond (a_view, a_s) - 1].ring_count > 0) {
7811
                {
-
 
7812
                  if (bond[get_bond (a_view, a_s) - 1].arom == true)
7003
                      if (bond[get_bond (a_view, a_s) - 1].arom == true) {
7813
                    {
-
 
7814
                      /*fg[fg_thiolactone_heteroarom] := true else fg[fg_thiolactone] := true; */
7004
                        /*fg[fg_thiolactone_heteroarom] := true else fg[fg_thiolactone] := true; */
7815
                      fg[fg_thioxohetarene - 1] = true;
7005
                        fg[fg_thioxohetarene - 1] = true;
-
 
7006
                      }
-
 
7007
                      else
-
 
7008
                        fg[fg_thiolactone - 1] = true;
7816
                    }
7009
                    }
7817
                  else
-
 
7818
                    fg[fg_thiolactone - 1] = true;
-
 
7819
                }
-
 
7820
            }
7010
            }
7821
        }
7011
          }
7822
    }                           /* end Thioxo-C */
7012
  }                             /* end Thioxo-C */
7823
  if (is_true_imino_C (a_view))
7013
  if (is_true_imino_C (a_view)) {
7824
    {
-
 
7825
      if (o_count == 1)
7014
    if (o_count == 1) {
7826
        {
-
 
7827
          if (bond[get_bond (a_view, a_o) - 1].arom == false)
7015
            if (bond[get_bond (a_view, a_o) - 1].arom == false)
7828
            fg[fg_carboxylic_acid_deriv - 1] = true;
7016
              fg[fg_carboxylic_acid_deriv - 1] = true;
7829
          if (is_alkoxy (a_view, a_o) || is_aryloxy (a_view, a_o))
7017
            if (is_alkoxy (a_view, a_o) || is_aryloxy (a_view, a_o)) {
7830
            {
-
 
7831
              if (bond[get_bond (a_view, a_o) - 1].arom == false)
7018
              if (bond[get_bond (a_view, a_o) - 1].arom == false)
7832
                fg[fg_imido_ester - 1] = true;
7019
                      fg[fg_imido_ester - 1] = true;
7833
            }
7020
            }
7834
        }
7021
          }
7835
      if ((n_count == 1) && (bond[get_bond (a_view, a_n) - 1].arom == false))
7022
    if ((n_count == 1) && (bond[get_bond (a_view, a_n) - 1].arom == false)) {
7836
        {
-
 
7837
          if (bond[get_bond (a_view, a_n) - 1].arom == false)
7023
            if (bond[get_bond (a_view, a_n) - 1].arom == false)
7838
            fg[fg_carboxylic_acid_deriv - 1] = true;
7024
              fg[fg_carboxylic_acid_deriv - 1] = true;
7839
          if (is_amino (a_view, a_n) || is_subst_amino (a_view, a_n))
7025
            if (is_amino (a_view, a_n) || is_subst_amino (a_view, a_n)) {
7840
            {
-
 
7841
              if (bond[get_bond (a_view, a_n) - 1].arom == false)
7026
              if (bond[get_bond (a_view, a_n) - 1].arom == false)
7842
                fg[fg_carboxylic_acid_deriv - 1] = true;
7027
                      fg[fg_carboxylic_acid_deriv - 1] = true;
7843
              fg[fg_carboxylic_acid_amidine - 1] = true;
7028
              fg[fg_carboxylic_acid_amidine - 1] = true;
7844
            }
7029
            }
7845
          if (is_hydrazino (a_view, a_n))
7030
            if (is_hydrazino (a_view, a_n)) {
7846
            {
-
 
7847
              if (bond[get_bond (a_view, a_n) - 1].arom == false)
7031
              if (bond[get_bond (a_view, a_n) - 1].arom == false)
7848
                fg[fg_carboxylic_acid_amidrazone - 1] = true;
7032
                      fg[fg_carboxylic_acid_amidrazone - 1] = true;
7849
            }
7033
            }
7850
        }
7034
          }
7851
      if ((n_count == 1) && (bond[get_bond (a_view, a_n) - 1].arom == true))
7035
    if ((n_count == 1) && (bond[get_bond (a_view, a_n) - 1].arom == true))
7852
        /* catches also pyridazines, 1,2,3-triazines, etc. */
7036
            /* catches also pyridazines, 1,2,3-triazines, etc. */
7853
        fg[fg_iminohetarene - 1] = true;
7037
          fg[fg_iminohetarene - 1] = true;
7854
      if (s_count == 1)
7038
    if (s_count == 1) {
7855
        {
-
 
7856
          if (bond[get_bond (a_view, a_s) - 1].arom == false)
7039
            if (bond[get_bond (a_view, a_s) - 1].arom == false)
7857
            fg[fg_carboxylic_acid_deriv - 1] = true;
7040
              fg[fg_carboxylic_acid_deriv - 1] = true;
7858
          if (is_alkylsulfanyl (a_view, a_s) || is_arylsulfanyl (a_view, a_s))
7041
            if (is_alkylsulfanyl (a_view, a_s) || is_arylsulfanyl (a_view, a_s)) {
7859
            {
-
 
7860
              if (bond[get_bond (a_view, a_s) - 1].arom == false)
7042
              if (bond[get_bond (a_view, a_s) - 1].arom == false)
7861
                fg[fg_imido_thioester - 1] = true;
7043
                 fg[fg_imido_thioester - 1] = true;
-
 
7044
            }
-
 
7045
          }
-
 
7046
  }
-
 
7047
  if (is_hydroximino_C (a_view)) {
-
 
7048
    if (bond[get_bond (a_view, a_n) - 1].arom == false)
-
 
7049
            fg[fg_carboxylic_acid_deriv - 1] = true;
-
 
7050
      if (o_count == 1) {
-
 
7051
              if (is_hydroxy (a_view, a_o))
-
 
7052
                fg[fg_hydroxamic_acid - 1] = true;
7862
            }
7053
            }
7863
        }
-
 
7864
    }
-
 
7865
  if (is_hydroximino_C (a_view))
-
 
7866
    {
-
 
7867
      if (bond[get_bond (a_view, a_n) - 1].arom == false)
-
 
7868
        fg[fg_carboxylic_acid_deriv - 1] = true;
-
 
7869
      if (o_count == 1)
-
 
7870
        {
-
 
7871
          if (is_hydroxy (a_view, a_o))
-
 
7872
            fg[fg_hydroxamic_acid - 1] = true;
-
 
7873
        }
-
 
7874
    }
-
 
7875
  if (!is_hydrazono_C (a_view))
-
 
7876
    return;
-
 
7877
  if (bond[get_bond (a_view, a_n) - 1].arom == false)
-
 
7878
    fg[fg_carboxylic_acid_deriv - 1] = true;
-
 
7879
  if (n_count == 1)
-
 
7880
    {
-
 
7881
      if (is_amino (a_view, a_n) || is_subst_amino (a_view, a_n))
-
 
7882
        fg[fg_carboxylic_acid_amidrazone - 1] = true;
-
 
7883
    }
7054
    }
-
 
7055
    if (!is_hydrazono_C (a_view))
-
 
7056
      return;
-
 
7057
    if (bond[get_bond (a_view, a_n) - 1].arom == false)
-
 
7058
      fg[fg_carboxylic_acid_deriv - 1] = true;
-
 
7059
    if (n_count == 1) {
-
 
7060
        if (is_amino (a_view, a_n) || is_subst_amino (a_view, a_n))
-
 
7061
          fg[fg_carboxylic_acid_amidrazone - 1] = true;
-
 
7062
  }
7884
}
7063
}
7885
 
7064
 
7886
 
-
 
7887
static void
-
 
7888
chk_co2_sp2 (a_view, a_ref)
7065
static void chk_co2_sp2 (a_view, a_ref)
7889
     int a_view, a_ref;
7066
     int a_view, a_ref;
7890
{
7067
{
7891
  int i;
7068
  int i;
7892
  neighbor_rec nb;
7069
  neighbor_rec nb;
7893
  str2 nb_el;
7070
  str2 nb_el;
7894
  int o_count = 0, or_count = 0, n_count = 0, nn_count = 0, nnx_count = 0,
7071
  int o_count = 0, or_count = 0, n_count = 0, nn_count = 0, nnx_count = 0,
7895
    s_count = 0, sr_count = 0;
7072
    s_count = 0, sr_count = 0;
7896
  int FORLIM;
7073
  int FORLIM;
7897
 
7074
 
7898
  memset (nb, 0, sizeof (neighbor_rec));
7075
  memset (nb, 0, sizeof (neighbor_rec));
7899
  get_neighbors (nb, a_view);
7076
  get_neighbors (nb, a_view);
7900
  FORLIM = atom[a_view - 1].neighbor_count;
7077
  FORLIM = atom[a_view - 1].neighbor_count;
7901
  for (i = 0; i < FORLIM; i++)
7078
  for (i = 0; i < FORLIM; i++) {
7902
    {
-
 
7903
      if (bond[get_bond (a_view, nb[i]) - 1].btype == 'S')
7079
    if (bond[get_bond (a_view, nb[i]) - 1].btype == 'S') {
7904
        {
-
 
7905
          strcpy (nb_el, atom[nb[i] - 1].element);
7080
           strcpy (nb_el, atom[nb[i] - 1].element);
7906
          if (strcmp (nb_el, "C "))
7081
            if (strcmp (nb_el, "C ")) {
7907
            {
-
 
7908
              if (!strcmp (nb_el, "O "))
7082
              if (!strcmp (nb_el, "O ")) {
7909
                {
-
 
7910
                  o_count++;
7083
                      o_count++;
7911
                  if (is_alkoxy (a_view, nb[i]) |
7084
                      if (is_alkoxy (a_view, nb[i]) |
7912
                      is_alkenyloxy (a_view, nb[i]) || is_aryloxy (a_view,
7085
                          is_alkenyloxy (a_view, nb[i]) || is_aryloxy (a_view,nb[i]))
7913
                                                                   nb[i]))
-
 
7914
                    /* v0.3j */
7086
                        /* v0.3j */
7915
                    or_count++;
7087
                        or_count++;
7916
                }
7088
                    }
7917
              if (!strcmp (nb_el, "N "))
7089
              if (!strcmp (nb_el, "N ")) {
7918
                {
-
 
7919
                  n_count++;
7090
                      n_count++;
7920
                  if (is_hydrazino (a_view, nb[i]))
7091
                      if (is_hydrazino (a_view, nb[i]))
7921
                    nn_count++;
7092
                        nn_count++;
7922
                  if (is_subst_hydrazino (a_view, nb[i]))       /* more general... */
7093
                      if (is_subst_hydrazino (a_view, nb[i]))   /* more general... */
7923
                    nnx_count++;
7094
                        nnx_count++;
7924
                }
7095
                    }
7925
              if (!strcmp (nb_el, "S "))
7096
              if (!strcmp (nb_el, "S ")) {
-
 
7097
                      s_count++;
-
 
7098
                      if (is_alkylsulfanyl (a_view, nb[i]) | is_arylsulfanyl (a_view, nb[i]))
-
 
7099
                        sr_count++;
-
 
7100
                    }
-
 
7101
            }
7926
                {
7102
          }
-
 
7103
  }
-
 
7104
  if (is_oxo_C (a_view)) {
-
 
7105
      if (o_count == 2) {
-
 
7106
              fg[fg_carbonic_acid_deriv - 1] = true;
-
 
7107
              if (or_count == 1)
-
 
7108
                fg[fg_carbonic_acid_monoester - 1] = true;
7927
                  s_count++;
7109
              if (or_count == 2)
-
 
7110
                fg[fg_carbonic_acid_diester - 1] = true;
-
 
7111
            }
7928
                  if (is_alkylsulfanyl (a_view, nb[i]) |
7112
      if (o_count == 1 && s_count == 1) {
-
 
7113
              fg[fg_thiocarbonic_acid_deriv - 1] = true;
-
 
7114
              if (or_count + sr_count == 1)
-
 
7115
                fg[fg_thiocarbonic_acid_monoester - 1] = true;
7929
                      is_arylsulfanyl (a_view, nb[i]))
7116
              if (or_count + sr_count == 2)
-
 
7117
                fg[fg_thiocarbonic_acid_diester - 1] = true;
-
 
7118
            }
-
 
7119
      if (s_count == 2) {
-
 
7120
              fg[fg_thiocarbonic_acid_deriv - 1] = true;
-
 
7121
              if (sr_count == 1)
-
 
7122
                fg[fg_thiocarbonic_acid_monoester - 1] = true;
-
 
7123
              if (sr_count == 2)
-
 
7124
                fg[fg_thiocarbonic_acid_diester - 1] = true;
-
 
7125
            }
-
 
7126
      if (o_count == 1 && n_count == 1) {
-
 
7127
              fg[fg_carbamic_acid_deriv - 1] = true;
-
 
7128
              if (or_count == 0)
-
 
7129
                fg[fg_carbamic_acid - 1] = true;
-
 
7130
              if (or_count == 1)
-
 
7131
                fg[fg_carbamic_acid_ester - 1] = true;
-
 
7132
            }
-
 
7133
      if (s_count == 1 && n_count == 1) {
-
 
7134
              fg[fg_thiocarbamic_acid_deriv - 1] = true;
-
 
7135
              if (sr_count == 0)
-
 
7136
                fg[fg_thiocarbamic_acid - 1] = true;
7930
                    sr_count++;
7137
              if (sr_count == 1)
-
 
7138
                fg[fg_thiocarbamic_acid_ester - 1] = true;
-
 
7139
            }
-
 
7140
      if (n_count == 2) {
-
 
7141
            if (nn_count == 1)
-
 
7142
              fg[fg_semicarbazide - 1] = true;
-
 
7143
            else {
-
 
7144
              if (nnx_count == 0)       /* excludes semicarbazones */
-
 
7145
                      fg[fg_urea - 1] = true;
-
 
7146
            }
7931
                }
7147
          }
-
 
7148
  }                             /* end Oxo-C */
-
 
7149
  if (is_thioxo_C (a_view)) {
-
 
7150
      if (o_count == 2) {
-
 
7151
              fg[fg_thiocarbonic_acid_deriv - 1] = true;
-
 
7152
              if (or_count == 1)
-
 
7153
                fg[fg_thiocarbonic_acid_monoester - 1] = true;
-
 
7154
              if (or_count == 2)
-
 
7155
                fg[fg_thiocarbonic_acid_diester - 1] = true;
-
 
7156
            }
-
 
7157
      if (o_count == 1 && s_count == 1) {
-
 
7158
              fg[fg_thiocarbonic_acid_deriv - 1] = true;
-
 
7159
              if (or_count + sr_count == 1)
-
 
7160
                fg[fg_thiocarbonic_acid_monoester - 1] = true;
-
 
7161
              if (or_count + sr_count == 2)
-
 
7162
                fg[fg_thiocarbonic_acid_diester - 1] = true;
-
 
7163
            }
-
 
7164
      if (s_count == 2) {
-
 
7165
              fg[fg_thiocarbonic_acid_deriv - 1] = true;
-
 
7166
              if (sr_count == 1)
-
 
7167
                fg[fg_thiocarbonic_acid_monoester - 1] = true;
-
 
7168
              if (sr_count == 2)
-
 
7169
                fg[fg_thiocarbonic_acid_diester - 1] = true;
-
 
7170
            }
-
 
7171
      if (o_count == 1 && n_count == 1) {
-
 
7172
              fg[fg_thiocarbamic_acid_deriv - 1] = true;
-
 
7173
              if (or_count == 0)
-
 
7174
                fg[fg_thiocarbamic_acid - 1] = true;
-
 
7175
              if (or_count == 1)
-
 
7176
                fg[fg_thiocarbamic_acid_ester - 1] = true;
-
 
7177
            }
-
 
7178
      if (s_count == 1 && n_count == 1) {
-
 
7179
              fg[fg_thiocarbamic_acid_deriv - 1] = true;
-
 
7180
              if (sr_count == 0)
-
 
7181
                fg[fg_thiocarbamic_acid - 1] = true;
-
 
7182
              if (sr_count == 1)
-
 
7183
                fg[fg_thiocarbamic_acid_ester - 1] = true;
7932
            }
7184
            }
7933
        }
-
 
7934
    }
-
 
7935
  if (is_oxo_C (a_view))
-
 
7936
    {
-
 
7937
      if (o_count == 2)
-
 
7938
        {
-
 
7939
          fg[fg_carbonic_acid_deriv - 1] = true;
-
 
7940
          if (or_count == 1)
-
 
7941
            fg[fg_carbonic_acid_monoester - 1] = true;
-
 
7942
          if (or_count == 2)
-
 
7943
            fg[fg_carbonic_acid_diester - 1] = true;
-
 
7944
        }
-
 
7945
      if (o_count == 1 && s_count == 1)
-
 
7946
        {
-
 
7947
          fg[fg_thiocarbonic_acid_deriv - 1] = true;
-
 
7948
          if (or_count + sr_count == 1)
-
 
7949
            fg[fg_thiocarbonic_acid_monoester - 1] = true;
-
 
7950
          if (or_count + sr_count == 2)
-
 
7951
            fg[fg_thiocarbonic_acid_diester - 1] = true;
-
 
7952
        }
-
 
7953
      if (s_count == 2)
-
 
7954
        {
-
 
7955
          fg[fg_thiocarbonic_acid_deriv - 1] = true;
-
 
7956
          if (sr_count == 1)
-
 
7957
            fg[fg_thiocarbonic_acid_monoester - 1] = true;
-
 
7958
          if (sr_count == 2)
-
 
7959
            fg[fg_thiocarbonic_acid_diester - 1] = true;
-
 
7960
        }
-
 
7961
      if (o_count == 1 && n_count == 1)
-
 
7962
        {
-
 
7963
          fg[fg_carbamic_acid_deriv - 1] = true;
-
 
7964
          if (or_count == 0)
-
 
7965
            fg[fg_carbamic_acid - 1] = true;
-
 
7966
          if (or_count == 1)
-
 
7967
            fg[fg_carbamic_acid_ester - 1] = true;
-
 
7968
        }
-
 
7969
      if (s_count == 1 && n_count == 1)
-
 
7970
        {
-
 
7971
          fg[fg_thiocarbamic_acid_deriv - 1] = true;
-
 
7972
          if (sr_count == 0)
-
 
7973
            fg[fg_thiocarbamic_acid - 1] = true;
-
 
7974
          if (sr_count == 1)
-
 
7975
            fg[fg_thiocarbamic_acid_ester - 1] = true;
-
 
7976
        }
-
 
7977
      if (n_count == 2)
-
 
7978
        {
-
 
7979
          if (nn_count == 1)
-
 
7980
            fg[fg_semicarbazide - 1] = true;
-
 
7981
          else
-
 
7982
            {
-
 
7983
              if (nnx_count == 0)       /* excludes semicarbazones */
-
 
7984
                fg[fg_urea - 1] = true;
-
 
7985
            }
-
 
7986
        }
-
 
7987
    }                           /* end Oxo-C */
-
 
7988
  if (is_thioxo_C (a_view))
-
 
7989
    {
-
 
7990
      if (o_count == 2)
-
 
7991
        {
-
 
7992
          fg[fg_thiocarbonic_acid_deriv - 1] = true;
-
 
7993
          if (or_count == 1)
-
 
7994
            fg[fg_thiocarbonic_acid_monoester - 1] = true;
-
 
7995
          if (or_count == 2)
-
 
7996
            fg[fg_thiocarbonic_acid_diester - 1] = true;
-
 
7997
        }
-
 
7998
      if (o_count == 1 && s_count == 1)
-
 
7999
        {
-
 
8000
          fg[fg_thiocarbonic_acid_deriv - 1] = true;
-
 
8001
          if (or_count + sr_count == 1)
-
 
8002
            fg[fg_thiocarbonic_acid_monoester - 1] = true;
-
 
8003
          if (or_count + sr_count == 2)
-
 
8004
            fg[fg_thiocarbonic_acid_diester - 1] = true;
-
 
8005
        }
-
 
8006
      if (s_count == 2)
-
 
8007
        {
-
 
8008
          fg[fg_thiocarbonic_acid_deriv - 1] = true;
-
 
8009
          if (sr_count == 1)
-
 
8010
            fg[fg_thiocarbonic_acid_monoester - 1] = true;
-
 
8011
          if (sr_count == 2)
-
 
8012
            fg[fg_thiocarbonic_acid_diester - 1] = true;
-
 
8013
        }
-
 
8014
      if (o_count == 1 && n_count == 1)
-
 
8015
        {
-
 
8016
          fg[fg_thiocarbamic_acid_deriv - 1] = true;
-
 
8017
          if (or_count == 0)
-
 
8018
            fg[fg_thiocarbamic_acid - 1] = true;
-
 
8019
          if (or_count == 1)
-
 
8020
            fg[fg_thiocarbamic_acid_ester - 1] = true;
-
 
8021
        }
-
 
8022
      if (s_count == 1 && n_count == 1)
-
 
8023
        {
-
 
8024
          fg[fg_thiocarbamic_acid_deriv - 1] = true;
-
 
8025
          if (sr_count == 0)
-
 
8026
            fg[fg_thiocarbamic_acid - 1] = true;
-
 
8027
          if (sr_count == 1)
-
 
8028
            fg[fg_thiocarbamic_acid_ester - 1] = true;
-
 
8029
        }
-
 
8030
      if (n_count == 2)
7185
      if (n_count == 2) {
8031
        {
-
 
8032
          if (nn_count == 1)
7186
            if (nn_count == 1)
8033
            fg[fg_thiosemicarbazide - 1] = true;
7187
              fg[fg_thiosemicarbazide - 1] = true;
8034
          else
7188
            else {
8035
            {
-
 
8036
              if (nnx_count == 0)       /* excludes thiosemicarbazones */
7189
              if (nnx_count == 0)       /* excludes thiosemicarbazones */
8037
                fg[fg_thiourea - 1] = true;
7190
                      fg[fg_thiourea - 1] = true;
8038
            }
7191
            }
8039
        }
7192
          }
8040
    }                           /* end Thioxo-C */
7193
  }                             /* end Thioxo-C */
8041
  if (!
-
 
8042
      (is_true_imino_C (a_view) &
7194
  if (!(is_true_imino_C (a_view) &
8043
       (bond[get_bond (a_view, a_ref) - 1].arom == false)))
7195
       (bond[get_bond (a_view, a_ref) - 1].arom == false))) {
8044
    {
-
 
8045
      return;
7196
      return;
8046
    }                           /* end Imino-C */
7197
  }                             /* end Imino-C */
8047
  if (o_count == 1 && n_count == 1)
7198
  if (o_count == 1 && n_count == 1)
8048
    fg[fg_isourea - 1] = true;
7199
    fg[fg_isourea - 1] = true;
8049
  if (s_count == 1 && n_count == 1)
7200
  if (s_count == 1 && n_count == 1)
8050
    fg[fg_isothiourea - 1] = true;
7201
    fg[fg_isothiourea - 1] = true;
8051
  if (n_count == 2)
7202
  if (n_count == 2)
8052
    fg[fg_guanidine - 1] = true;
7203
    fg[fg_guanidine - 1] = true;
8053
}
7204
}
8054
 
-
 
8055
 
7205
 
8056
static void
-
 
8057
chk_co2_sp (a_view, a_ref)
7206
static void chk_co2_sp (a_view, a_ref)
8058
     int a_view, a_ref;
7207
     int a_view, a_ref;
8059
{
7208
{
8060
  int i;
7209
  int i;
8061
  neighbor_rec nb;
7210
  neighbor_rec nb;
8062
  str2 nb_el;
7211
  str2 nb_el;
Line 8064... Line 7213...
8064
  int FORLIM;
7213
  int FORLIM;
8065
 
7214
 
8066
  memset (nb, 0, sizeof (neighbor_rec));
7215
  memset (nb, 0, sizeof (neighbor_rec));
8067
  get_neighbors (nb, a_view);
7216
  get_neighbors (nb, a_view);
8068
  FORLIM = atom[a_view - 1].neighbor_count;
7217
  FORLIM = atom[a_view - 1].neighbor_count;
8069
  for (i = 0; i < FORLIM; i++)
7218
  for (i = 0; i < FORLIM; i++) {
8070
    {
-
 
8071
      if (bond[get_bond (a_view, nb[i]) - 1].btype == 'D')
7219
    if (bond[get_bond (a_view, nb[i]) - 1].btype == 'D') {
8072
        {
-
 
8073
          strcpy (nb_el, atom[nb[i] - 1].element);
7220
            strcpy (nb_el, atom[nb[i] - 1].element);
8074
          if (strcmp (nb_el, "C "))
7221
            if (strcmp (nb_el, "C ")) {
8075
            {
-
 
8076
              if (!strcmp (nb_el, "O "))
7222
              if (!strcmp (nb_el, "O "))
8077
                o_count++;
7223
                      o_count++;
8078
              if (!strcmp (nb_el, "N "))
7224
              if (!strcmp (nb_el, "N "))
8079
                n_count++;
7225
                      n_count++;
8080
              if (!strcmp (nb_el, "S "))
7226
              if (!strcmp (nb_el, "S "))
8081
                s_count++;
7227
                      s_count++;
8082
            }
7228
            }
8083
        }
7229
          }
8084
    }
7230
  }
8085
  if (o_count + s_count == 2)   /* new in v0.3b */
7231
  if (o_count + s_count == 2)   /* new in v0.3b */
8086
    fg[fg_co2_deriv - 1] = true;
7232
    fg[fg_co2_deriv - 1] = true;
8087
  if (o_count == 1 && n_count == 1)
7233
  if (o_count == 1 && n_count == 1)
8088
    fg[fg_isocyanate - 1] = true;
7234
    fg[fg_isocyanate - 1] = true;
8089
  if (s_count == 1 && n_count == 1)
7235
  if (s_count == 1 && n_count == 1)
8090
    fg[fg_isothiocyanate - 1] = true;
7236
    fg[fg_isothiocyanate - 1] = true;
8091
  if (n_count == 2)
7237
  if (n_count == 2)
8092
    fg[fg_carbodiimide - 1] = true;
7238
    fg[fg_carbodiimide - 1] = true;
8093
}
7239
}
8094
 
7240
 
8095
 
-
 
8096
static void
-
 
8097
chk_triple (a1, a2)
7241
static void chk_triple (a1, a2)
8098
     int a1, a2;
7242
     int a1, a2;
8099
{
7243
{
8100
  str2 a1_el, a2_el;
7244
  str2 a1_el, a2_el;
8101
 
7245
 
8102
  strcpy (a1_el, atom[a1 - 1].element);
7246
  strcpy (a1_el, atom[a1 - 1].element);
Line 8112... Line 7256...
8112
    fg[fg_cyanate - 1] = true;
7256
    fg[fg_cyanate - 1] = true;
8113
  if (is_thiocyanate (a1, a2))
7257
  if (is_thiocyanate (a1, a2))
8114
    fg[fg_thiocyanate - 1] = true;
7258
    fg[fg_thiocyanate - 1] = true;
8115
}
7259
}
8116
 
7260
 
8117
 
-
 
8118
static void
-
 
8119
chk_ccx (a_view, a_ref)
7261
static void chk_ccx (a_view, a_ref)
8120
     int a_view, a_ref;
-
 
8121
{
-
 
8122
  int i;
-
 
8123
  neighbor_rec nb;
-
 
8124
  int oh_count = 0, or_count = 0, n_count = 0;
-
 
8125
  int FORLIM;
-
 
8126
 
-
 
8127
  memset (nb, 0, sizeof (neighbor_rec));
-
 
8128
  get_neighbors (nb, a_ref);
-
 
8129
  FORLIM = atom[a_ref - 1].neighbor_count;
-
 
8130
  for (i = 0; i < FORLIM; i++)
-
 
8131
    {
-
 
8132
      if (bond[get_bond (a_ref, nb[i]) - 1].btype == 'S')
-
 
8133
        {
-
 
8134
          if (is_hydroxy (a_ref, nb[i]))
-
 
8135
            oh_count++;
-
 
8136
          if (is_alkoxy (a_ref, nb[i]) || is_aryloxy (a_ref, nb[i]) |
-
 
8137
              is_siloxy (a_ref, nb[i]))
-
 
8138
            or_count++;
-
 
8139
          if (!strcmp (atom[nb[i] - 1].atype, "N3 ") ||
-
 
8140
              !strcmp (atom[nb[i] - 1].atype, "NAM"))
-
 
8141
            n_count++;
-
 
8142
        }
-
 
8143
    }
-
 
8144
  if (oh_count == 1)
-
 
8145
    fg[fg_enol - 1] = true;
-
 
8146
  if (or_count == 1)
-
 
8147
    fg[fg_enolether - 1] = true;
-
 
8148
  if (n_count == 1)
-
 
8149
    fg[fg_enamine - 1] = true;
-
 
8150
  /* new in v0.2f   (regard anything else as an alkene) */
-
 
8151
  if (oh_count + or_count + n_count == 0)
-
 
8152
    fg[fg_alkene - 1] = true;
-
 
8153
}
-
 
8154
 
-
 
8155
 
-
 
8156
static void
-
 
8157
chk_xccx (a_view, a_ref)
-
 
8158
     int a_view, a_ref;
7262
     int a_view, a_ref;
8159
{
7263
{
8160
  int i;
7264
  int i;
8161
  neighbor_rec nb;
7265
  neighbor_rec nb;
8162
  int oh_count = 0, or_count = 0, n_count = 0;
7266
  int oh_count = 0, or_count = 0, n_count = 0;
8163
  int FORLIM;
7267
  int FORLIM;
8164
 
7268
 
8165
  memset (nb, 0, sizeof (neighbor_rec));
-
 
8166
  get_neighbors (nb, a_view);
-
 
8167
  FORLIM = atom[a_view - 1].neighbor_count;
-
 
8168
  for (i = 0; i < FORLIM; i++)
-
 
8169
    {
-
 
8170
      if (bond[get_bond (a_view, nb[i]) - 1].btype == 'S')
-
 
8171
        {
-
 
8172
          if (is_hydroxy (a_view, nb[i]))
-
 
8173
            oh_count++;
-
 
8174
          if (is_alkoxy (a_view, nb[i]) || is_aryloxy (a_view, nb[i]) |
-
 
8175
              is_siloxy (a_view, nb[i]))
-
 
8176
            or_count++;
-
 
8177
          if (!strcmp (atom[nb[i] - 1].atype, "N3 ") ||
-
 
8178
              !strcmp (atom[nb[i] - 1].atype, "NAM"))
-
 
8179
            n_count++;
-
 
8180
        }
-
 
8181
    }
-
 
8182
  memset (nb, 0, sizeof (neighbor_rec));
7269
  memset (nb, 0, sizeof (neighbor_rec));
8183
  get_neighbors (nb, a_ref);
7270
  get_neighbors (nb, a_ref);
8184
  FORLIM = atom[a_ref - 1].neighbor_count;
7271
  FORLIM = atom[a_ref - 1].neighbor_count;
8185
  for (i = 0; i < FORLIM; i++)
7272
  for (i = 0; i < FORLIM; i++) {
8186
    {
-
 
8187
      if (bond[get_bond (a_ref, nb[i]) - 1].btype == 'S')
7273
    if (bond[get_bond (a_ref, nb[i]) - 1].btype == 'S') {
8188
        {
-
 
8189
          if (is_hydroxy (a_ref, nb[i]))
7274
          if (is_hydroxy (a_ref, nb[i]))
8190
            oh_count++;
7275
            oh_count++;
8191
          if (is_alkoxy (a_ref, nb[i]) || is_aryloxy (a_ref, nb[i]) |
7276
          if (is_alkoxy (a_ref, nb[i]) || is_aryloxy (a_ref, nb[i]) |
8192
              is_siloxy (a_ref, nb[i]))
7277
              is_siloxy (a_ref, nb[i]))
8193
            or_count++;
7278
            or_count++;
8194
          if (!strcmp (atom[nb[i] - 1].atype, "N3 ") ||
7279
          if (!strcmp (atom[nb[i] - 1].atype, "N3 ") ||
8195
              !strcmp (atom[nb[i] - 1].atype, "NAM"))
7280
              !strcmp (atom[nb[i] - 1].atype, "NAM"))
8196
            n_count++;
7281
            n_count++;
-
 
7282
          }
-
 
7283
  }
-
 
7284
  if (oh_count == 1)
-
 
7285
    fg[fg_enol - 1] = true;
-
 
7286
  if (or_count == 1)
-
 
7287
    fg[fg_enolether - 1] = true;
-
 
7288
  if (n_count == 1)
-
 
7289
    fg[fg_enamine - 1] = true;
-
 
7290
  /* new in v0.2f   (regard anything else as an alkene) */
-
 
7291
  if (oh_count + or_count + n_count == 0)
-
 
7292
    fg[fg_alkene - 1] = true;
8197
        }
7293
}
-
 
7294
 
-
 
7295
static void chk_xccx (a_view, a_ref)
-
 
7296
     int a_view, a_ref;
-
 
7297
{
-
 
7298
  int i;
-
 
7299
  neighbor_rec nb;
-
 
7300
  int oh_count = 0, or_count = 0, n_count = 0;
-
 
7301
  int FORLIM;
-
 
7302
 
-
 
7303
  memset (nb, 0, sizeof (neighbor_rec));
-
 
7304
  get_neighbors (nb, a_view);
-
 
7305
  FORLIM = atom[a_view - 1].neighbor_count;
-
 
7306
  for (i = 0; i < FORLIM; i++) {
-
 
7307
    if (bond[get_bond (a_view, nb[i]) - 1].btype == 'S') {
-
 
7308
            if (is_hydroxy (a_view, nb[i]))
-
 
7309
              oh_count++;
-
 
7310
            if (is_alkoxy (a_view, nb[i]) || is_aryloxy (a_view, nb[i]) |
-
 
7311
                is_siloxy (a_view, nb[i]))
-
 
7312
              or_count++;
-
 
7313
            if (!strcmp (atom[nb[i] - 1].atype, "N3 ") ||
-
 
7314
                !strcmp (atom[nb[i] - 1].atype, "NAM"))
-
 
7315
              n_count++;
-
 
7316
          }
-
 
7317
  }
-
 
7318
  memset (nb, 0, sizeof (neighbor_rec));
-
 
7319
  get_neighbors (nb, a_ref);
-
 
7320
  FORLIM = atom[a_ref - 1].neighbor_count;
-
 
7321
  for (i = 0; i < FORLIM; i++) {
-
 
7322
    if (bond[get_bond (a_ref, nb[i]) - 1].btype == 'S') {
-
 
7323
            if (is_hydroxy (a_ref, nb[i]))
-
 
7324
              oh_count++;
-
 
7325
            if (is_alkoxy (a_ref, nb[i]) || is_aryloxy (a_ref, nb[i]) |
-
 
7326
                is_siloxy (a_ref, nb[i]))
-
 
7327
              or_count++;
-
 
7328
            if (!strcmp (atom[nb[i] - 1].atype, "N3 ") ||
-
 
7329
                !strcmp (atom[nb[i] - 1].atype, "NAM"))
-
 
7330
              n_count++;
8198
    }
7331
          }
-
 
7332
  }
8199
  if (oh_count == 2)
7333
  if (oh_count == 2)
8200
    fg[fg_enediol - 1] = true;
7334
    fg[fg_enediol - 1] = true;
8201
  /* new in v0.2f   (regard anything else as an alkene) */
7335
  /* new in v0.2f   (regard anything else as an alkene) */
8202
  if (oh_count + or_count + n_count == 0)
7336
  if (oh_count + or_count + n_count == 0)
8203
    fg[fg_alkene - 1] = true;
7337
    fg[fg_alkene - 1] = true;
8204
}
7338
}
8205
 
7339
 
8206
 
-
 
8207
static void
-
 
8208
chk_n_o_dbl (a1, a2)
7340
static void chk_n_o_dbl (a1, a2)
8209
     int a1, a2;
7341
     int a1, a2;
8210
{
7342
{
8211
  int i;
7343
  int i;
8212
  neighbor_rec nb;
7344
  neighbor_rec nb;
8213
  str2 nb_el;
7345
  str2 nb_el;
8214
  int or_count = 0, n_count = 0, c_count = 0;
7346
  int or_count = 0, n_count = 0, c_count = 0;
8215
  int b;                        /* v0.3j */
7347
  int b;                        /* v0.3j */
8216
  int het_count = 0;            /* v0.3k */
7348
  int het_count = 0;            /* v0.3k */
8217
  char bt;                      /* v0.3k */
7349
  char bt;                      /* v0.3k */
8218
  float bo_sum = 0.0;           /* v0.3k */
7350
  float bo_sum = 0.0;           /* v0.3k */
8219
  int FORLIM;
7351
  int FORLIM;
8220
 
7352
 
8221
  memset (nb, 0, sizeof (neighbor_rec));
7353
  memset (nb, 0, sizeof (neighbor_rec));
8222
  get_neighbors (nb, a1);
7354
  get_neighbors (nb, a1);
8223
  FORLIM = atom[a1 - 1].neighbor_count;
7355
  FORLIM = atom[a1 - 1].neighbor_count;
8224
  /* v0.3k */
7356
  /* v0.3k */
8225
  /* v0.3k */
7357
  /* v0.3k */
8226
  for (i = 0; i < FORLIM; i++)
7358
  for (i = 0; i < FORLIM; i++) {
8227
    {
-
 
8228
      if (nb[i] != a2)
7359
    if (nb[i] != a2) {
8229
        {
-
 
8230
          b = get_bond (a1, nb[i]);     /* v0.3j */
7360
            b = get_bond (a1, nb[i]);   /* v0.3j */
8231
          strcpy (nb_el, atom[nb[i] - 1].element);
7361
            strcpy (nb_el, atom[nb[i] - 1].element);
8232
          bt = bond[b - 1].btype;       /* v0.3k */
7362
            bt = bond[b - 1].btype;     /* v0.3k */
8233
          if (strcmp (nb_el, "C ") && strcmp (nb_el, "H ")
7363
            if (strcmp (nb_el, "C ") && strcmp (nb_el, "H ")
8234
              /*&&  strcmp (nb_el, "D ") */  && strcmp (nb_el, "DU")
7364
                /*&&  strcmp (nb_el, "D ") */  && strcmp (nb_el, "DU")
8235
              && strcmp (nb_el, "LP") && bond[b - 1].arom == false)
7365
                && strcmp (nb_el, "LP") && bond[b - 1].arom == false)
8236
            /* added 'D ' in v0.3n */
7366
                /* added 'D ' in v0.3n */
8237
            het_count++;
7367
              het_count++;
8238
          /* v0.3k: ignore hetero atoms */
7368
            /* v0.3k: ignore hetero atoms */
8239
          /* in aromatic rings like isoxazole  */
7369
            /* in aromatic rings like isoxazole  */
8240
          if (bt == 'S')
7370
            if (bt == 'S')
8241
            bo_sum += 1.0;
7371
              bo_sum += 1.0;
8242
          if (bt == 'D')
7372
            if (bt == 'D')
8243
            bo_sum += 2.0;
7373
              bo_sum += 2.0;
8244
          if (bt == 'A')
7374
            if (bt == 'A')
8245
            bo_sum += 1.5;
7375
              bo_sum += 1.5;
8246
          if (!strcmp (nb_el, "O "))
7376
            if (!strcmp (nb_el, "O "))
8247
            or_count++;
7377
              or_count++;
8248
          if (!strcmp (nb_el, "N "))
7378
            if (!strcmp (nb_el, "N "))
8249
            n_count++;
7379
              n_count++;
8250
          if (!strcmp (nb_el, "C ") && bond[b - 1].btype == 'S')        /* v0.3k */
7380
            if (!strcmp (nb_el, "C ") && bond[b - 1].btype == 'S')      /* v0.3k */
8251
            c_count++;
7381
              c_count++;
8252
          /* if (is_alkyl(a1,nb[i])) or (is_aryl(a1,nb[i])) then inc(c_count); */
7382
            /* if (is_alkyl(a1,nb[i])) or (is_aryl(a1,nb[i])) then inc(c_count); */
8253
        }
7383
          }
8254
    }
7384
  }
8255
  if (or_count + n_count + c_count == 1 && atom[a1 - 1].neighbor_count == 2)
7385
  if (or_count + n_count + c_count == 1 && atom[a1 - 1].neighbor_count == 2) {
8256
    {                           /* excludes nitro etc. */
7386
    /* excludes nitro etc. */
8257
      if (or_count == 1)
7387
    if (or_count == 1)
8258
        fg[fg_nitrite - 1] = true;
7388
            fg[fg_nitrite - 1] = true;
8259
      if (c_count == 1)
7389
    if (c_count == 1)
8260
        fg[fg_nitroso_compound - 1] = true;
7390
            fg[fg_nitroso_compound - 1] = true;
8261
      if (n_count == 1)         /* instead of nitrosamine  v0.3j */
7391
    if (n_count == 1)           /* instead of nitrosamine  v0.3j */
8262
        fg[fg_nitroso_compound - 1] = true;
7392
            fg[fg_nitroso_compound - 1] = true;
8263
      /*if (n_count = 1) then fg[fg_nitrosamine]   := true;  (* still missing */
7393
    /*if (n_count = 1) then fg[fg_nitrosamine]   := true;  (* still missing */
8264
    }
7394
  }
8265
  /*if ((c_count > 1) and (or_count = 0) and (n_count = 0)) then */
7395
  /*if ((c_count > 1) and (or_count = 0) and (n_count = 0)) then */
8266
  /*  begin */
7396
  /*  begin */
8267
  /*    fg[fg_n_oxide] := true; */
7397
  /*    fg[fg_n_oxide] := true; */
8268
  /*  end; */
7398
  /*  end; */
8269
  /* new approach in v0.3k */
7399
  /* new approach in v0.3k */
8270
  if (het_count == 0 && bo_sum > 2)     /* =O does not count! */
7400
  if (het_count == 0 && bo_sum > 2)     /* =O does not count! */
8271
    fg[fg_n_oxide - 1] = true;
7401
    fg[fg_n_oxide - 1] = true;
8272
}
7402
}
8273
 
7403
 
8274
 
-
 
8275
static void
-
 
8276
chk_sulfoxide (a1, a2)
7404
static void chk_sulfoxide (a1, a2)
8277
     int a1, a2;
7405
     int a1, a2;
8278
{
7406
{
8279
  int i;
7407
  int i;
8280
  neighbor_rec nb;
7408
  neighbor_rec nb;
8281
  str2 nb_el;
7409
  str2 nb_el;
8282
  int o_count = 0, c_count = 0;
7410
  int o_count = 0, c_count = 0;
8283
  int FORLIM;
7411
  int FORLIM;
8284
 
7412
 
8285
  memset (nb, 0, sizeof (neighbor_rec));
7413
  memset (nb, 0, sizeof (neighbor_rec));
8286
  get_neighbors (nb, a1);
7414
  get_neighbors (nb, a1);
8287
  FORLIM = atom[a1 - 1].neighbor_count;
7415
  FORLIM = atom[a1 - 1].neighbor_count;
8288
  for (i = 0; i < FORLIM; i++)
7416
  for (i = 0; i < FORLIM; i++) {
8289
    {
-
 
8290
      strcpy (nb_el, atom[nb[i] - 1].element);
7417
    strcpy (nb_el, atom[nb[i] - 1].element);
8291
      if (!strcmp (nb_el, "O "))
7418
    if (!strcmp (nb_el, "O "))
8292
        o_count++;
7419
            o_count++;
8293
      if (is_alkyl (a1, nb[i]) || is_aryl (a1, nb[i]))
7420
    if (is_alkyl (a1, nb[i]) || is_aryl (a1, nb[i]))
8294
        c_count++;
7421
            c_count++;
8295
    }
7422
  }
8296
  if (o_count == 1 && c_count == 2)
7423
  if (o_count == 1 && c_count == 2)
8297
    fg[fg_sulfoxide - 1] = true;
7424
    fg[fg_sulfoxide - 1] = true;
8298
}
7425
}
8299
 
7426
 
8300
 
-
 
8301
static void
-
 
8302
chk_double (a1, a2)
7427
static void chk_double (a1, a2)
8303
     int a1, a2;
7428
     int a1, a2;
8304
{
7429
{
8305
  str2 a1_el, a2_el;
7430
  str2 a1_el, a2_el;
8306
 
7431
 
8307
  strcpy (a1_el, atom[a1 - 1].element);
7432
  strcpy (a1_el, atom[a1 - 1].element);
8308
  strcpy (a2_el, atom[a2 - 1].element);
7433
  strcpy (a2_el, atom[a2 - 1].element);
8309
  if ((!strcmp (a1_el, "C ") && strcmp (a2_el, "C ")) &
7434
  if ((!strcmp (a1_el, "C ") && strcmp (a2_el, "C ")) &
8310
      (bond[get_bond (a1, a2) - 1].arom == false))
7435
      (bond[get_bond (a1, a2) - 1].arom == false)) {
8311
    {
-
 
8312
      if (hetbond_count (a1) == 2)
7436
    if (hetbond_count (a1) == 2)
8313
        chk_carbonyl_deriv (a1, a2);
7437
            chk_carbonyl_deriv (a1, a2);
8314
      if (hetbond_count (a1) == 3)
7438
    if (hetbond_count (a1) == 3)
8315
        chk_carboxyl_deriv (a1, a2);
7439
            chk_carboxyl_deriv (a1, a2);
8316
      if (hetbond_count (a1) == 4)
7440
    if (hetbond_count (a1) == 4) {
8317
        {
-
 
8318
          if (!strcmp (atom[a1 - 1].atype, "C2 "))
7441
            if (!strcmp (atom[a1 - 1].atype, "C2 "))
8319
            chk_co2_sp2 (a1, a2);
7442
              chk_co2_sp2 (a1, a2);
8320
          if (!strcmp (atom[a1 - 1].atype, "C1 "))
7443
            if (!strcmp (atom[a1 - 1].atype, "C1 "))
8321
            chk_co2_sp (a1, a2);
7444
              chk_co2_sp (a1, a2);
8322
        }
7445
          }
8323
    }                           /* end C=X */
7446
  }                             /* end C=X */
8324
  if ((!strcmp (atom[a1 - 1].atype, "C2 ")
7447
  if ((!strcmp (atom[a1 - 1].atype, "C2 ")
8325
       && !strcmp (atom[a2 - 1].atype,
7448
       && !strcmp (atom[a2 - 1].atype,
8326
                   "C2 ")) && (bond[get_bond (a1, a2) - 1].arom == false))
7449
                   "C2 ")) && (bond[get_bond (a1, a2) - 1].arom == false)) {
8327
    {
-
 
8328
      if ((hetbond_count (a1) == 0) && (hetbond_count (a2) == 2))
7450
    if ((hetbond_count (a1) == 0) && (hetbond_count (a2) == 2))
8329
        fg[fg_ketene_acetal_deriv - 1] = true;
7451
            fg[fg_ketene_acetal_deriv - 1] = true;
8330
      if ((hetbond_count (a1) == 0) && (hetbond_count (a2) == 1))
7452
    if ((hetbond_count (a1) == 0) && (hetbond_count (a2) == 1))
8331
        chk_ccx (a1, a2);
7453
            chk_ccx (a1, a2);
8332
      if ((hetbond_count (a1) == 1) && (hetbond_count (a2) == 1))
7454
    if ((hetbond_count (a1) == 1) && (hetbond_count (a2) == 1))
8333
        chk_xccx (a1, a2);
7455
            chk_xccx (a1, a2);
8334
      if (((hetbond_count (a1) == 0) && (hetbond_count (a2) == 0)) &&
7456
    if (((hetbond_count (a1) == 0) && (hetbond_count (a2) == 0)) &&
8335
          atom[a1 - 1].arom == false && atom[a2 - 1].arom == false)
7457
              atom[a1 - 1].arom == false && atom[a2 - 1].arom == false)
8336
        fg[fg_alkene - 1] = true;
7458
            fg[fg_alkene - 1] = true;
8337
    }
7459
  }
8338
  if (((!strcmp (a1_el, "N ")
7460
  if (((!strcmp (a1_el, "N ") && !strcmp (a2_el, "N "))
8339
        && !strcmp (a2_el,
-
 
8340
                    "N ")) && (hetbond_count (a1) ==
-
 
8341
                               2) && (hetbond_count (a2) ==
7461
      && (hetbond_count (a1) == 2) && (hetbond_count (a2) == 2)
8342
                                      2) && (bond[get_bond (a1, a2) -
7462
      && (bond[get_bond (a1, a2) - 1].arom == false))
8343
                                                  1].arom == false))
-
 
8344
      && atom[a1 - 1].neighbor_count == 2 && atom[a2 - 1].neighbor_count == 2)
7463
      && atom[a1 - 1].neighbor_count == 2 && atom[a2 - 1].neighbor_count == 2)
8345
    fg[fg_azo_compound - 1] = true;
7464
    fg[fg_azo_compound - 1] = true;
8346
  if (!strcmp (a1_el, "N ") && !strcmp (a2_el, "O "))
7465
  if (!strcmp (a1_el, "N ") && !strcmp (a2_el, "O "))
8347
    chk_n_o_dbl (a1, a2);
7466
    chk_n_o_dbl (a1, a2);
8348
  if (!strcmp (a1_el, "S ") && !strcmp (a2_el, "O "))
7467
  if (!strcmp (a1_el, "S ") && !strcmp (a2_el, "O "))
8349
    chk_sulfoxide (a1, a2);
7468
    chk_sulfoxide (a1, a2);
8350
}
7469
}
8351
 
7470
 
8352
 
-
 
8353
static void
-
 
8354
chk_c_hal (a1, a2)
7471
static void chk_c_hal (a1, a2)
8355
     int a1, a2;
7472
     int a1, a2;
8356
{
7473
{
8357
  str2 a2_el;
7474
  str2 a2_el;
8358
 
7475
 
8359
  strcpy (a2_el, atom[a2 - 1].element);
7476
  strcpy (a2_el, atom[a2 - 1].element);
8360
  fg[fg_halogen_deriv - 1] = true;
7477
  fg[fg_halogen_deriv - 1] = true;
8361
  if (atom[a1 - 1].arom)
7478
  if (atom[a1 - 1].arom) {
8362
    {
-
 
8363
      fg[fg_aryl_halide - 1] = true;
7479
    fg[fg_aryl_halide - 1] = true;
8364
      if (!strcmp (a2_el, "F "))
7480
    if (!strcmp (a2_el, "F "))
8365
        fg[fg_aryl_fluoride - 1] = true;
7481
            fg[fg_aryl_fluoride - 1] = true;
8366
      if (!strcmp (a2_el, "CL"))
7482
    if (!strcmp (a2_el, "CL"))
8367
        fg[fg_aryl_chloride - 1] = true;
7483
            fg[fg_aryl_chloride - 1] = true;
8368
      if (!strcmp (a2_el, "BR"))
7484
    if (!strcmp (a2_el, "BR"))
8369
        fg[fg_aryl_bromide - 1] = true;
7485
            fg[fg_aryl_bromide - 1] = true;
8370
      if (!strcmp (a2_el, "I "))
7486
    if (!strcmp (a2_el, "I "))
8371
        fg[fg_aryl_iodide - 1] = true;
7487
            fg[fg_aryl_iodide - 1] = true;
8372
      return;
7488
    return;
8373
    }
7489
  }
8374
  if ((strcmp (atom[a1 - 1].atype, "C3 ") == 0) && (hetbond_count (a1) <= 2))
7490
  if ((strcmp (atom[a1 - 1].atype, "C3 ") == 0) && (hetbond_count (a1) <= 2)) {
8375
    {                           /* alkyl halides */
7491
    /* alkyl halides */
8376
      fg[fg_alkyl_halide - 1] = true;
7492
    fg[fg_alkyl_halide - 1] = true;
8377
      if (!strcmp (a2_el, "F "))
7493
    if (!strcmp (a2_el, "F "))
8378
        fg[fg_alkyl_fluoride - 1] = true;
7494
            fg[fg_alkyl_fluoride - 1] = true;
8379
      if (!strcmp (a2_el, "CL"))
7495
    if (!strcmp (a2_el, "CL"))
8380
        fg[fg_alkyl_chloride - 1] = true;
7496
            fg[fg_alkyl_chloride - 1] = true;
8381
      if (!strcmp (a2_el, "BR"))
7497
    if (!strcmp (a2_el, "BR"))
8382
        fg[fg_alkyl_bromide - 1] = true;
7498
            fg[fg_alkyl_bromide - 1] = true;
8383
      if (!strcmp (a2_el, "I "))
7499
    if (!strcmp (a2_el, "I "))
8384
        fg[fg_alkyl_iodide - 1] = true;
7500
            fg[fg_alkyl_iodide - 1] = true;
8385
    }
7501
  }
8386
  if ((strcmp (atom[a1 - 1].atype, "C2 ") == 0) && (hetbond_count (a1) == 3))
7502
  if ((strcmp (atom[a1 - 1].atype, "C2 ") == 0) && (hetbond_count (a1) == 3)) {
8387
    {                           /* acyl halides and related compounds */
7503
    /* acyl halides and related compounds */
8388
      if (is_oxo_C (a1))
7504
    if (is_oxo_C (a1)) {
8389
        {
-
 
8390
          fg[fg_acyl_halide - 1] = true;
7505
            fg[fg_acyl_halide - 1] = true;
8391
          if (!strcmp (a2_el, "F "))
7506
            if (!strcmp (a2_el, "F "))
8392
            fg[fg_acyl_fluoride - 1] = true;
7507
              fg[fg_acyl_fluoride - 1] = true;
8393
          if (!strcmp (a2_el, "CL"))
7508
            if (!strcmp (a2_el, "CL"))
8394
            fg[fg_acyl_chloride - 1] = true;
7509
              fg[fg_acyl_chloride - 1] = true;
8395
          if (!strcmp (a2_el, "BR"))
7510
            if (!strcmp (a2_el, "BR"))
8396
            fg[fg_acyl_bromide - 1] = true;
7511
              fg[fg_acyl_bromide - 1] = true;
8397
          if (!strcmp (a2_el, "I "))
7512
            if (!strcmp (a2_el, "I "))
8398
            fg[fg_acyl_iodide - 1] = true;
7513
              fg[fg_acyl_iodide - 1] = true;
8399
        }
7514
          }
8400
      if (is_thioxo_C (a1))
7515
    if (is_thioxo_C (a1))
8401
        fg[fg_thiocarboxylic_acid_deriv - 1] = true;
7516
            fg[fg_thiocarboxylic_acid_deriv - 1] = true;
8402
      if (is_imino_C (a1))
7517
    if (is_imino_C (a1))
8403
        fg[fg_imidoyl_halide - 1] = true;
7518
            fg[fg_imidoyl_halide - 1] = true;
8404
    }
7519
  }
8405
  if (!
-
 
8406
      ((strcmp (atom[a1 - 1].atype, "C2 ") == 0)
7520
  if (!((strcmp (atom[a1 - 1].atype, "C2 ") == 0)
8407
       && (hetbond_count (a1) == 4)))
7521
       && (hetbond_count (a1) == 4)))
8408
    /* chloroformates etc. */
7522
    /* chloroformates etc. */
8409
    return;
7523
    return;
8410
  /* still missing: polyhalogen compounds (-CX2H, -CX3) */
7524
  /* still missing: polyhalogen compounds (-CX2H, -CX3) */
8411
  fg[fg_co2_deriv - 1] = true;
7525
  fg[fg_co2_deriv - 1] = true;
8412
  if (is_oxo_C (a1))
7526
  if (is_oxo_C (a1)) {
8413
    {
-
 
8414
      fg[fg_carbonic_acid_deriv - 1] = true;
7527
      fg[fg_carbonic_acid_deriv - 1] = true;
8415
      if (is_alkoxycarbonyl (a2, a1) || is_aryloxycarbonyl (a2, a1))
7528
    if (is_alkoxycarbonyl (a2, a1) || is_aryloxycarbonyl (a2, a1))
8416
        fg[fg_carbonic_acid_ester_halide - 1] = true;
7529
            fg[fg_carbonic_acid_ester_halide - 1] = true;
8417
      if (is_carbamoyl (a2, a1))
7530
    if (is_carbamoyl (a2, a1)) {
8418
        {
-
 
8419
          fg[fg_carbamic_acid_deriv - 1] = true;
7531
            fg[fg_carbamic_acid_deriv - 1] = true;
8420
          fg[fg_carbamic_acid_halide - 1] = true;
7532
            fg[fg_carbamic_acid_halide - 1] = true;
8421
        }
7533
          }
8422
    }
7534
  }
8423
  if (!is_thioxo_C (a1))
7535
  if (!is_thioxo_C (a1))
8424
    return;
7536
    return;
8425
  fg[fg_thiocarbonic_acid_deriv - 1] = true;
7537
  fg[fg_thiocarbonic_acid_deriv - 1] = true;
8426
  if (is_alkoxythiocarbonyl (a2, a1) || is_aryloxythiocarbonyl (a2, a1))
7538
  if (is_alkoxythiocarbonyl (a2, a1) || is_aryloxythiocarbonyl (a2, a1))
8427
    fg[fg_thiocarbonic_acid_ester_halide - 1] = true;
7539
    fg[fg_thiocarbonic_acid_ester_halide - 1] = true;
8428
  if (is_thiocarbamoyl (a2, a1))
7540
  if (is_thiocarbamoyl (a2, a1)) {
8429
    {
-
 
8430
      fg[fg_thiocarbamic_acid_deriv - 1] = true;
7541
    fg[fg_thiocarbamic_acid_deriv - 1] = true;
8431
      fg[fg_thiocarbamic_acid_halide - 1] = true;
7542
    fg[fg_thiocarbamic_acid_halide - 1] = true;
8432
      /* end of non-aromatic halogen compounds */
7543
      /* end of non-aromatic halogen compounds */
8433
    }
7544
  }
8434
}
7545
}
8435
 
-
 
8436
 
7546
 
8437
static void
-
 
8438
chk_c_o (a1, a2)
7547
static void chk_c_o (a1, a2)
8439
     int a1, a2;
7548
     int a1, a2;
8440
{
7549
{
8441
  /* ignore heteroaromatic rings (like furan, thiophene, etc.) */
7550
  /* ignore heteroaromatic rings (like furan, thiophene, etc.) */
8442
  if (bond[get_bond (a1, a2) - 1].arom == true)
7551
  if (bond[get_bond (a1, a2) - 1].arom == true)
8443
    return;
7552
    return;
8444
  if (is_true_alkyl (a2, a1) && is_hydroxy (a1, a2))
7553
  if (is_true_alkyl (a2, a1) && is_hydroxy (a1, a2)) {
8445
    {
-
 
8446
      fg[fg_hydroxy - 1] = true;
7554
    fg[fg_hydroxy - 1] = true;
8447
      fg[fg_alcohol - 1] = true;
7555
    fg[fg_alcohol - 1] = true;
8448
      if (atom[a1 - 1].neighbor_count <= 2)
7556
    if (atom[a1 - 1].neighbor_count <= 2)
8449
        fg[fg_prim_alcohol - 1] = true;
7557
            fg[fg_prim_alcohol - 1] = true;
8450
      if (atom[a1 - 1].neighbor_count == 3)
7558
    if (atom[a1 - 1].neighbor_count == 3)
8451
        fg[fg_sec_alcohol - 1] = true;
7559
            fg[fg_sec_alcohol - 1] = true;
8452
      if (atom[a1 - 1].neighbor_count == 4)
7560
    if (atom[a1 - 1].neighbor_count == 4)
8453
        fg[fg_tert_alcohol - 1] = true;
7561
            fg[fg_tert_alcohol - 1] = true;
8454
    }
7562
  }
8455
  if (is_aryl (a2, a1) && is_hydroxy (a1, a2))
7563
  if (is_aryl (a2, a1) && is_hydroxy (a1, a2)) {
8456
    {
-
 
8457
      fg[fg_hydroxy - 1] = true;
7564
    fg[fg_hydroxy - 1] = true;
8458
      fg[fg_phenol - 1] = true;
7565
    fg[fg_phenol - 1] = true;
8459
    }
7566
  }
8460
  if (is_true_alkyl (a2, a1) && is_true_alkoxy (a1, a2))
7567
  if (is_true_alkyl (a2, a1) && is_true_alkoxy (a1, a2)) {
8461
    {
-
 
8462
      fg[fg_ether - 1] = true;
7568
    fg[fg_ether - 1] = true;
8463
      fg[fg_dialkylether - 1] = true;
7569
    fg[fg_dialkylether - 1] = true;
8464
    }
7570
  }
8465
  if ((is_true_alkyl (a2, a1) && is_aryloxy (a1, a2)) |
7571
  if ((is_true_alkyl (a2, a1) && is_aryloxy (a1, a2)) |
8466
      (is_aryl (a2, a1) && is_true_alkoxy (a1, a2)))
7572
      (is_aryl (a2, a1) && is_true_alkoxy (a1, a2))) {
8467
    {
-
 
8468
      fg[fg_ether - 1] = true;
7573
    fg[fg_ether - 1] = true;
8469
      fg[fg_alkylarylether - 1] = true;
7574
    fg[fg_alkylarylether - 1] = true;
8470
    }
7575
  }
8471
  if (is_aryl (a2, a1) && is_aryloxy (a1, a2))
7576
  if (is_aryl (a2, a1) && is_aryloxy (a1, a2)) {
8472
    {
-
 
8473
      fg[fg_ether - 1] = true;
7577
    fg[fg_ether - 1] = true;
8474
      fg[fg_diarylether - 1] = true;
7578
    fg[fg_diarylether - 1] = true;
8475
    }
7579
  }
8476
  if ((is_true_alkyl (a2, a1) || is_aryl (a2, a1)) && is_alkynyloxy (a1, a2))
7580
  if ((is_true_alkyl (a2, a1) || is_aryl (a2, a1)) && is_alkynyloxy (a1, a2)) {
8477
    {
-
 
8478
      fg[fg_ether - 1] = true;
7581
    fg[fg_ether - 1] = true;
8479
      ether_generic = true;
7582
    ether_generic = true;
8480
    }
7583
  }
8481
  if (is_alkynyl (a2, a1) && is_hydroxy (a1, a2))
7584
  if (is_alkynyl (a2, a1) && is_hydroxy (a1, a2)) {
8482
    {
-
 
8483
      fg[fg_hydroxy - 1] = true;
7585
    fg[fg_hydroxy - 1] = true;
8484
      hydroxy_generic = true;
7586
    hydroxy_generic = true;
8485
    }
7587
  }
8486
 
-
 
8487
}
7588
}
8488
 
-
 
8489
 
7589
 
8490
static void
-
 
8491
chk_c_s (a1, a2)
7590
static void chk_c_s (a1, a2)
8492
     int a1, a2;
7591
     int a1, a2;
8493
{
7592
{
8494
  int i;
7593
  int i;
8495
  neighbor_rec nb;
7594
  neighbor_rec nb;
8496
  str2 nb_el;
7595
  str2 nb_el;
Line 8499... Line 7598...
8499
  int FORLIM;
7598
  int FORLIM;
8500
 
7599
 
8501
  /* ignore heteroaromatic rings (like furan, thiophene, etc.) */
7600
  /* ignore heteroaromatic rings (like furan, thiophene, etc.) */
8502
  if (bond[get_bond (a1, a2) - 1].arom == true)
7601
  if (bond[get_bond (a1, a2) - 1].arom == true)
8503
    return;
7602
    return;
8504
  if (is_alkyl (a2, a1) && is_sulfanyl (a1, a2))
7603
  if (is_alkyl (a2, a1) && is_sulfanyl (a1, a2)) {
8505
    {
-
 
8506
      fg[fg_thiol - 1] = true;
7604
    fg[fg_thiol - 1] = true;
8507
      fg[fg_alkylthiol - 1] = true;
7605
    fg[fg_alkylthiol - 1] = true;
8508
    }
7606
  }
8509
  if (is_aryl (a2, a1) && is_sulfanyl (a1, a2))
7607
  if (is_aryl (a2, a1) && is_sulfanyl (a1, a2)) {
8510
    {
-
 
8511
      fg[fg_thiol - 1] = true;
7608
    fg[fg_thiol - 1] = true;
8512
      fg[fg_arylthiol - 1] = true;
7609
    fg[fg_arylthiol - 1] = true;
8513
    }
7610
  }
8514
  if (is_true_alkyl (a2, a1) && is_true_alkylsulfanyl (a1, a2))
7611
  if (is_true_alkyl (a2, a1) && is_true_alkylsulfanyl (a1, a2))
8515
    fg[fg_thioether - 1] = true;
7612
    fg[fg_thioether - 1] = true;
8516
  if ((is_true_alkyl (a2, a1) && is_arylsulfanyl (a1, a2)) |
7613
  if ((is_true_alkyl (a2, a1) && is_arylsulfanyl (a1, a2)) |
8517
      (is_aryl (a2, a1) && is_true_alkylsulfanyl (a1, a2)))
7614
        (is_aryl (a2, a1) && is_true_alkylsulfanyl (a1, a2)))
8518
    fg[fg_thioether - 1] = true;
7615
    fg[fg_thioether - 1] = true;
8519
  if (is_aryl (a2, a1) && is_arylsulfanyl (a1, a2))
7616
  if (is_aryl (a2, a1) && is_arylsulfanyl (a1, a2))
8520
    fg[fg_thioether - 1] = true;
7617
    fg[fg_thioether - 1] = true;
8521
  /* check for sulfinic/sulfenic acid derivatives */
7618
  /* check for sulfinic/sulfenic acid derivatives */
8522
  memset (nb, 0, sizeof (neighbor_rec));
7619
  memset (nb, 0, sizeof (neighbor_rec));
8523
  get_neighbors (nb, a2);
7620
  get_neighbors (nb, a2);
8524
  FORLIM = atom[a2 - 1].neighbor_count;
7621
  FORLIM = atom[a2 - 1].neighbor_count;
8525
  for (i = 0; i < FORLIM; i++)
7622
  for (i = 0; i < FORLIM; i++) {
8526
    {
-
 
8527
      strcpy (nb_el, atom[nb[i] - 1].element);
7623
    strcpy (nb_el, atom[nb[i] - 1].element);
8528
      if (is_alkyl (a2, nb[i]) || is_aryl (a2, nb[i]))
7624
    if (is_alkyl (a2, nb[i]) || is_aryl (a2, nb[i]))
8529
        c_count++;
7625
            c_count++;
8530
      if (is_hydroxy (a2, nb[i]))
7626
    if (is_hydroxy (a2, nb[i]))
8531
        oh_count++;
7627
            oh_count++;
8532
      if (is_alkoxy (a2, nb[i]) || is_aryloxy (a2, nb[i]))
7628
    if (is_alkoxy (a2, nb[i]) || is_aryloxy (a2, nb[i]))
8533
        or_count++;
7629
            or_count++;
8534
      if (is_amino (a2, nb[i]) || is_subst_amino (a2, nb[i]))
7630
    if (is_amino (a2, nb[i]) || is_subst_amino (a2, nb[i]))
8535
        n_count++;
7631
            n_count++;
8536
      if (!strcmp (nb_el, "F ") || !strcmp (nb_el, "CL") ||
7632
    if (!strcmp (nb_el, "F ") || !strcmp (nb_el, "CL") ||
8537
          !strcmp (nb_el, "BR") || !strcmp (nb_el, "I "))
7633
              !strcmp (nb_el, "BR") || !strcmp (nb_el, "I "))
8538
        hal_count++;
7634
            hal_count++;
8539
      if (!strcmp (nb_el, "O "))
7635
    if (!strcmp (nb_el, "O "))
8540
        o_count++;
7636
            o_count++;
8541
    }
7637
  }
8542
  if (c_count != 1)
7638
  if (c_count != 1)
8543
    return;
7639
    return;
8544
  if (atom[a2 - 1].neighbor_count == 3 && o_count - oh_count - or_count == 1)
7640
  if (atom[a2 - 1].neighbor_count == 3 && o_count - oh_count - or_count == 1) {
8545
    {                           /* sulfinic acid && derivs */
7641
    /* sulfinic acid && derivs */
8546
      fg[fg_sulfinic_acid_deriv - 1] = true;
7642
    fg[fg_sulfinic_acid_deriv - 1] = true;
8547
      if (oh_count == 1)
7643
    if (oh_count == 1)
8548
        fg[fg_sulfinic_acid - 1] = true;
7644
            fg[fg_sulfinic_acid - 1] = true;
8549
      if (or_count == 1)
7645
    if (or_count == 1)
8550
        fg[fg_sulfinic_acid_ester - 1] = true;
7646
            fg[fg_sulfinic_acid_ester - 1] = true;
8551
      if (hal_count == 1)
7647
    if (hal_count == 1)
8552
        fg[fg_sulfinic_acid_halide - 1] = true;
7648
            fg[fg_sulfinic_acid_halide - 1] = true;
8553
      if (n_count == 1)
7649
    if (n_count == 1)
8554
        fg[fg_sulfinic_acid_amide - 1] = true;
7650
            fg[fg_sulfinic_acid_amide - 1] = true;
8555
    }
7651
  }
8556
  if (atom[a2 - 1].neighbor_count != 2 || o_count - oh_count - or_count != 0)
7652
  if (atom[a2 - 1].neighbor_count != 2 || o_count - oh_count - or_count != 0)
8557
    /* sulfenic acid && derivs */
7653
    /* sulfenic acid && derivs */
8558
    return;
7654
    return;
8559
 
7655
 
8560
  fg[fg_sulfenic_acid_deriv - 1] = true;
7656
  fg[fg_sulfenic_acid_deriv - 1] = true;
Line 8566... Line 7662...
8566
    fg[fg_sulfenic_acid_halide - 1] = true;
7662
    fg[fg_sulfenic_acid_halide - 1] = true;
8567
  if (n_count == 1)
7663
  if (n_count == 1)
8568
    fg[fg_sulfenic_acid_amide - 1] = true;
7664
    fg[fg_sulfenic_acid_amide - 1] = true;
8569
}
7665
}
8570
 
7666
 
8571
 
-
 
8572
static void
-
 
8573
chk_c_n (a1, a2)
7667
static void chk_c_n (a1, a2)
8574
     int a1, a2;
7668
     int a1, a2;
8575
{
7669
{
8576
  /* ignore heteroaromatic rings (like furan, thiophene, pyrrol, etc.) */
7670
  /* ignore heteroaromatic rings (like furan, thiophene, pyrrol, etc.) */
8577
  if (atom[a2 - 1].arom == true)
7671
  if (atom[a2 - 1].arom == true)
8578
    return;
7672
    return;
8579
  if (is_true_alkyl (a2, a1) && is_amino (a1, a2))
7673
  if (is_true_alkyl (a2, a1) && is_amino (a1, a2)) {
8580
    {
-
 
8581
      fg[fg_amine - 1] = true;
7674
    fg[fg_amine - 1] = true;
8582
      fg[fg_prim_amine - 1] = true;
7675
    fg[fg_prim_amine - 1] = true;
8583
      fg[fg_prim_aliph_amine - 1] = true;
7676
    fg[fg_prim_aliph_amine - 1] = true;
8584
    }
7677
    }
8585
  if (is_aryl (a2, a1) && is_amino (a1, a2))
7678
  if (is_aryl (a2, a1) && is_amino (a1, a2)) {
8586
    {
-
 
8587
      fg[fg_amine - 1] = true;
7679
    fg[fg_amine - 1] = true;
8588
      fg[fg_prim_amine - 1] = true;
7680
    fg[fg_prim_amine - 1] = true;
8589
      fg[fg_prim_arom_amine - 1] = true;
7681
    fg[fg_prim_arom_amine - 1] = true;
8590
    }
7682
  }
8591
  if (is_true_alkyl (a2, a1) && is_true_alkylamino (a1, a2))
7683
  if (is_true_alkyl (a2, a1) && is_true_alkylamino (a1, a2)) {
8592
    {
-
 
8593
      fg[fg_amine - 1] = true;
7684
    fg[fg_amine - 1] = true;
8594
      fg[fg_sec_amine - 1] = true;
7685
    fg[fg_sec_amine - 1] = true;
8595
      fg[fg_sec_aliph_amine - 1] = true;
7686
    fg[fg_sec_aliph_amine - 1] = true;
8596
    }
7687
  }
8597
  if (is_aryl (a2, a1) && is_true_alkylamino (a1, a2))
7688
  if (is_aryl (a2, a1) && is_true_alkylamino (a1, a2)) {
8598
    {
-
 
8599
      fg[fg_amine - 1] = true;
7689
    fg[fg_amine - 1] = true;
8600
      fg[fg_sec_amine - 1] = true;
7690
    fg[fg_sec_amine - 1] = true;
8601
      fg[fg_sec_mixed_amine - 1] = true;
7691
    fg[fg_sec_mixed_amine - 1] = true;
8602
    }
7692
  }
8603
  if (is_aryl (a2, a1) && is_arylamino (a1, a2))
7693
  if (is_aryl (a2, a1) && is_arylamino (a1, a2)) {
8604
    {
-
 
8605
      fg[fg_amine - 1] = true;
7694
    fg[fg_amine - 1] = true;
8606
      fg[fg_sec_amine - 1] = true;
7695
    fg[fg_sec_amine - 1] = true;
8607
      fg[fg_sec_arom_amine - 1] = true;
7696
    fg[fg_sec_arom_amine - 1] = true;
8608
    }
7697
  }
8609
  if (is_true_alkyl (a2, a1) && is_true_dialkylamino (a1, a2))
7698
  if (is_true_alkyl (a2, a1) && is_true_dialkylamino (a1, a2)) {
8610
    {
-
 
8611
      fg[fg_amine - 1] = true;
7699
    fg[fg_amine - 1] = true;
8612
      fg[fg_tert_amine - 1] = true;
7700
    fg[fg_tert_amine - 1] = true;
8613
      fg[fg_tert_aliph_amine - 1] = true;
7701
    fg[fg_tert_aliph_amine - 1] = true;
8614
    }
7702
  }
8615
  if ((is_true_alkyl (a2, a1) && is_diarylamino (a1, a2)) |
7703
  if ((is_true_alkyl (a2, a1) && is_diarylamino (a1, a2)) |
8616
      (is_aryl (a2, a1) && is_true_dialkylamino (a1, a2)))
7704
      (is_aryl (a2, a1) && is_true_dialkylamino (a1, a2))) {
8617
    {
-
 
8618
      fg[fg_amine - 1] = true;
7705
    fg[fg_amine - 1] = true;
8619
      fg[fg_tert_amine - 1] = true;
7706
    fg[fg_tert_amine - 1] = true;
8620
      fg[fg_tert_mixed_amine - 1] = true;
7707
    fg[fg_tert_mixed_amine - 1] = true;
8621
    }
7708
  }
8622
  if (is_aryl (a2, a1) && is_diarylamino (a1, a2))
7709
  if (is_aryl (a2, a1) && is_diarylamino (a1, a2)) {
8623
    {
-
 
8624
      fg[fg_amine - 1] = true;
7710
    fg[fg_amine - 1] = true;
8625
      fg[fg_tert_amine - 1] = true;
7711
    fg[fg_tert_amine - 1] = true;
8626
      fg[fg_tert_arom_amine - 1] = true;
7712
    fg[fg_tert_arom_amine - 1] = true;
8627
    }
7713
  }
8628
  if ((is_alkyl (a2, a1) || is_aryl (a2, a1) || is_alkenyl (a2, a1) |
7714
  if ((is_alkyl (a2, a1) || is_aryl (a2, a1) || is_alkenyl (a2, a1) |
8629
       is_alkynyl (a2, a1)) && is_hydroxylamino (a1, a2) && (is_acyl_gen (a2,
7715
       is_alkynyl (a2, a1)) && is_hydroxylamino (a1, a2) && (is_acyl_gen (a2, a1) == false))
8630
                                                                          a1)
-
 
8631
                                                             == false))
-
 
8632
    /* v0.3k */
7716
    /* v0.3k */
8633
    fg[fg_hydroxylamine - 1] = true;
7717
    fg[fg_hydroxylamine - 1] = true;
8634
  /* v0.3k */
7718
  /* v0.3k */
8635
  /* v0.3k  */
7719
  /* v0.3k  */
8636
  if ((is_alkyl (a2, a1) || is_aryl (a2, a1) || is_acyl (a2, a1) |
7720
  if ((is_alkyl (a2, a1) || is_aryl (a2, a1) || is_acyl (a2, a1) |
8637
       is_alkenyl (a2, a1) || is_alkynyl (a2, a1)) && is_hydrazino (a1, a2))
7721
       is_alkenyl (a2, a1) || is_alkynyl (a2, a1)) && is_hydrazino (a1, a2))
8638
    fg[fg_hydrazine - 1] = true;
7722
    fg[fg_hydrazine - 1] = true;
8639
  if ((is_alkyl (a2, a1) || is_aryl (a2, a1) || is_alkenyl (a2, a1) |
7723
  if ((is_alkyl (a2, a1) || is_aryl (a2, a1) || is_alkenyl (a2, a1) |
8640
       is_alkynyl (a2, a1)) && is_azido (a1, a2))
7724
       is_alkynyl (a2, a1)) && is_azido (a1, a2))
8641
    /* v0.3k */
7725
    /* v0.3k */
8642
    fg[fg_azide - 1] = true;
7726
    fg[fg_azide - 1] = true;
8643
  if ((is_alkyl (a2, a1) || is_aryl (a2, a1) || is_alkenyl (a2, a1) |
7727
  if ((is_alkyl (a2, a1) || is_aryl (a2, a1) || is_alkenyl (a2, a1) |
8644
       is_alkynyl (a2, a1)) && is_diazonium (a1, a2))
7728
       is_alkynyl (a2, a1)) && is_diazonium (a1, a2))
Line 8647... Line 7731...
8647
  if ((is_alkyl (a2, a1) || is_aryl (a2, a1) || is_alkenyl (a2, a1) |
7731
  if ((is_alkyl (a2, a1) || is_aryl (a2, a1) || is_alkenyl (a2, a1) |
8648
       is_alkynyl (a2, a1)) && is_nitro (a1, a2))
7732
       is_alkynyl (a2, a1)) && is_nitro (a1, a2))
8649
    /* v0.3k */
7733
    /* v0.3k */
8650
    fg[fg_nitro_compound - 1] = true;
7734
    fg[fg_nitro_compound - 1] = true;
8651
  if (is_alkynyl (a2, a1) &
7735
  if (is_alkynyl (a2, a1) &
8652
      (is_amino (a1, a2) || is_C_monosubst_amino (a1, a2) |
7736
        (is_amino (a1, a2) || is_C_monosubst_amino (a1, a2) |
8653
       (is_C_disubst_amino (a1, a2) && (!is_acylamino (a1, a2)))))
7737
       (is_C_disubst_amino (a1, a2) && (!is_acylamino (a1, a2))))) {
8654
    {
-
 
8655
      fg[fg_amine - 1] = true;
7738
      fg[fg_amine - 1] = true;
8656
      amine_generic = true;
7739
      amine_generic = true;
8657
    }
7740
  }
8658
}
7741
}
8659
 
-
 
8660
 
7742
 
8661
static void
-
 
8662
chk_c_c (a1, a2)
7743
static void chk_c_c (a1, a2)
8663
     int a1, a2;
7744
     int a1, a2;
8664
{
7745
{
8665
  int i;
7746
  int i;
8666
  neighbor_rec nb;
7747
  neighbor_rec nb;
8667
  int oh_count, nhr_count, FORLIM;
7748
  int oh_count, nhr_count, FORLIM;
8668
 
7749
 
8669
  /* ignore aromatic rings */
7750
  /* ignore aromatic rings */
8670
  if (atom[a2 - 1].arom == true)
7751
  if (atom[a2 - 1].arom == true)
8671
    return;
7752
    return;
8672
  /*check for 1,2-diols and 1,2-aminoalcoholes */
7753
  /*check for 1,2-diols and 1,2-aminoalcoholes */
8673
  if (!strcmp (atom[a1 - 1].atype, "C3 ")
7754
  if (!strcmp (atom[a1 - 1].atype, "C3 ")
8674
      && !strcmp (atom[a2 - 1].atype, "C3 "))
7755
        && !strcmp (atom[a2 - 1].atype, "C3 ")) {
8675
    {
-
 
8676
      if ((hetbond_count (a1) == 1) && (hetbond_count (a2) == 1))
7756
      if ((hetbond_count (a1) == 1) && (hetbond_count (a2) == 1)) {
8677
        {
-
 
8678
          oh_count = 0;
7757
            oh_count = 0;
8679
          nhr_count = 0;
7758
            nhr_count = 0;
8680
          memset (nb, 0, sizeof (neighbor_rec));
7759
            memset (nb, 0, sizeof (neighbor_rec));
8681
          get_neighbors (nb, a1);
7760
            get_neighbors (nb, a1);
8682
          FORLIM = atom[a1 - 1].neighbor_count;
7761
            FORLIM = atom[a1 - 1].neighbor_count;
8683
          for (i = 0; i < FORLIM; i++)
7762
            for (i = 0; i < FORLIM; i++) {
-
 
7763
              if (nb[i] != a2) {
-
 
7764
                      if (is_hydroxy (a1, nb[i]))
-
 
7765
                        oh_count++;
-
 
7766
                      if (is_amino (a1, nb[i]) || is_alkylamino (a1, nb[i]) |
-
 
7767
                        is_arylamino (a1, nb[i]))
-
 
7768
                      nhr_count++;
-
 
7769
                    }
8684
            {
7770
            }
-
 
7771
            memset (nb, 0, sizeof (neighbor_rec));
-
 
7772
            get_neighbors (nb, a2);
-
 
7773
            FORLIM = atom[a2 - 1].neighbor_count;
-
 
7774
            for (i = 0; i < FORLIM; i++) {
8685
              if (nb[i] != a2)
7775
              if (nb[i] != a1) {
8686
                {
-
 
8687
                  if (is_hydroxy (a1, nb[i]))
7776
                      if (is_hydroxy (a2, nb[i]))
8688
                    oh_count++;
7777
                        oh_count++;
8689
                  if (is_amino (a1, nb[i]) || is_alkylamino (a1, nb[i]) |
7778
                      if (is_amino (a2, nb[i]) || is_alkylamino (a2, nb[i]) |
8690
                      is_arylamino (a1, nb[i]))
7779
                          is_arylamino (a2, nb[i]))
8691
                    nhr_count++;
7780
                        nhr_count++;
8692
                }
7781
                    }
8693
            }
7782
            }
8694
          memset (nb, 0, sizeof (neighbor_rec));
-
 
8695
          get_neighbors (nb, a2);
-
 
8696
          FORLIM = atom[a2 - 1].neighbor_count;
-
 
8697
          for (i = 0; i < FORLIM; i++)
-
 
8698
            {
-
 
8699
              if (nb[i] != a1)
-
 
8700
                {
-
 
8701
                  if (is_hydroxy (a2, nb[i]))
-
 
8702
                    oh_count++;
-
 
8703
                  if (is_amino (a2, nb[i]) || is_alkylamino (a2, nb[i]) |
-
 
8704
                      is_arylamino (a2, nb[i]))
-
 
8705
                    nhr_count++;
-
 
8706
                }
-
 
8707
            }
-
 
8708
          if (oh_count == 2)
7783
            if (oh_count == 2)
8709
            fg[fg_1_2_diol - 1] = true;
7784
              fg[fg_1_2_diol - 1] = true;
8710
          if (oh_count == 1 && nhr_count == 1)
7785
            if (oh_count == 1 && nhr_count == 1)
8711
            fg[fg_1_2_aminoalcohol - 1] = true;
7786
              fg[fg_1_2_aminoalcohol - 1] = true;
8712
        }
7787
          }
8713
    }
7788
  }
8714
  /* check for alpha-aminoacids and alpha-hydroxyacids */
7789
  /* check for alpha-aminoacids and alpha-hydroxyacids */
8715
  if (strcmp (atom[a1 - 1].atype, "C3 ")
7790
  if (strcmp (atom[a1 - 1].atype, "C3 ")
8716
      || strcmp (atom[a2 - 1].atype, "C2 "))
7791
      || strcmp (atom[a2 - 1].atype, "C2 "))
8717
    return;
7792
    return;
8718
  if (!((hetbond_count (a1) == 1) && (hetbond_count (a2) == 3)))
7793
  if (!((hetbond_count (a1) == 1) && (hetbond_count (a2) == 3)))
Line 8720... Line 7795...
8720
  oh_count = 0;
7795
  oh_count = 0;
8721
  nhr_count = 0;
7796
  nhr_count = 0;
8722
  memset (nb, 0, sizeof (neighbor_rec));
7797
  memset (nb, 0, sizeof (neighbor_rec));
8723
  get_neighbors (nb, a1);
7798
  get_neighbors (nb, a1);
8724
  FORLIM = atom[a1 - 1].neighbor_count;
7799
  FORLIM = atom[a1 - 1].neighbor_count;
8725
  for (i = 0; i < FORLIM; i++)
7800
  for (i = 0; i < FORLIM; i++) {
8726
    {
-
 
8727
      if (nb[i] != a2)
7801
    if (nb[i] != a2) {
8728
        {
-
 
8729
          if (is_hydroxy (a1, nb[i]))
7802
            if (is_hydroxy (a1, nb[i]))
8730
            oh_count++;
7803
              oh_count++;
8731
          if (is_amino (a1, nb[i]) || is_alkylamino (a1, nb[i]) |
7804
            if (is_amino (a1, nb[i]) || is_alkylamino (a1, nb[i]) |
8732
              is_arylamino (a1, nb[i]))
7805
                is_arylamino (a1, nb[i]))
8733
            nhr_count++;
7806
              nhr_count++;
8734
        }
7807
          }
8735
    }
7808
  }
8736
  memset (nb, 0, sizeof (neighbor_rec));
7809
  memset (nb, 0, sizeof (neighbor_rec));
8737
  get_neighbors (nb, a2);
7810
  get_neighbors (nb, a2);
8738
  FORLIM = atom[a2 - 1].neighbor_count;
7811
  FORLIM = atom[a2 - 1].neighbor_count;
8739
  for (i = 0; i < FORLIM; i++)
7812
  for (i = 0; i < FORLIM; i++) {
8740
    {
-
 
8741
      if (nb[i] != a1)
7813
    if (nb[i] != a1) {
8742
        {
-
 
8743
          if (is_hydroxy (a2, nb[i]))
7814
            if (is_hydroxy (a2, nb[i]))
8744
            oh_count++;
7815
              oh_count++;
8745
        }
7816
          }
8746
    }
7817
  }
8747
  if ((oh_count == 2) && is_oxo_C (a2))
7818
  if ((oh_count == 2) && is_oxo_C (a2))
8748
    fg[fg_alpha_hydroxyacid - 1] = true;
7819
    fg[fg_alpha_hydroxyacid - 1] = true;
8749
  if ((oh_count == 1 && nhr_count == 1) && is_oxo_C (a2))
7820
  if ((oh_count == 1 && nhr_count == 1) && is_oxo_C (a2))
8750
    fg[fg_alpha_aminoacid - 1] = true;
7821
    fg[fg_alpha_aminoacid - 1] = true;
8751
}
7822
}
8752
 
7823
 
8753
 
-
 
8754
static void
-
 
8755
chk_x_y_single (a_view, a_ref)
7824
static void chk_x_y_single (a_view, a_ref)
8756
     int a_view, a_ref;
7825
     int a_view, a_ref;
8757
{
7826
{
8758
  if (!strcmp (atom[a_view - 1].atype, "O3 ") &&
7827
  if (!strcmp (atom[a_view - 1].atype, "O3 ") &&
8759
      !strcmp (atom[a_ref - 1].atype, "O3 "))
7828
        !strcmp (atom[a_ref - 1].atype, "O3 ")) {
8760
    {
-
 
8761
      if (is_hydroxy (a_ref, a_view) || is_hydroxy (a_view, a_ref))
7829
    if (is_hydroxy (a_ref, a_view) || is_hydroxy (a_view, a_ref))
8762
        fg[fg_hydroperoxide - 1] = true;
7830
            fg[fg_hydroperoxide - 1] = true;
8763
      if ((is_alkoxy (a_ref, a_view) || is_aryloxy (a_ref, a_view) |
7831
    if ((is_alkoxy (a_ref, a_view) || is_aryloxy (a_ref, a_view) |
8764
           is_siloxy (a_ref, a_view)) && (is_alkoxy (a_view,
7832
              is_siloxy (a_ref, a_view)) && (is_alkoxy (a_view,a_ref) |
8765
                                                     a_ref) |
-
 
8766
                                          is_aryloxy (a_view,
7833
                        is_aryloxy (a_view, a_ref) |
8767
                                                      a_ref) |
-
 
8768
                                          is_siloxy (a_view, a_ref)))
7834
                        is_siloxy (a_view, a_ref)))
8769
        fg[fg_peroxide - 1] = true;
7835
            fg[fg_peroxide - 1] = true;
8770
    }                           /* still missing: peracid */
7836
  }                             /* still missing: peracid */
8771
  if (!strcmp (atom[a_view - 1].atype, "S3 ") &&
7837
  if (!strcmp (atom[a_view - 1].atype, "S3 ") &&
8772
      !strcmp (atom[a_ref - 1].atype, "S3 "))
7838
      !strcmp (atom[a_ref - 1].atype, "S3 ")) {
8773
    {
-
 
8774
      if (atom[a_view - 1].neighbor_count == 2 &&
7839
      if (atom[a_view - 1].neighbor_count == 2 &&
8775
          atom[a_ref - 1].neighbor_count == 2)
7840
          atom[a_ref - 1].neighbor_count == 2)
8776
        fg[fg_disulfide - 1] = true;
7841
          fg[fg_disulfide - 1] = true;
8777
    }
7842
  }
8778
  if ((!strcmp (atom[a_view - 1].element, "N ") &&
7843
  if ((!strcmp (atom[a_view - 1].element, "N ") &&
8779
       !strcmp (atom[a_ref - 1].element,
7844
       !strcmp (atom[a_ref - 1].element, "N ")) && (hetbond_count (a_view) == 1)
8780
                "N ")) && (hetbond_count (a_view) ==
-
 
8781
                           1) && (hetbond_count (a_ref) == 1))
7845
      && (hetbond_count (a_ref) == 1)) {
8782
    {
-
 
8783
      /*if ((is_amino(a_ref,a_view)) or  */
7846
      /*if ((is_amino(a_ref,a_view)) or  */
8784
      /*    (is_subst_amino(a_ref,a_view)) or */
7847
      /*    (is_subst_amino(a_ref,a_view)) or */
8785
      /*    (is_acylamino(a_ref,a_view))) and */
7848
      /*    (is_acylamino(a_ref,a_view))) and */
8786
      /*   ((is_amino(a_view,a_ref)) or  */
7849
      /*   ((is_amino(a_view,a_ref)) or  */
8787
      /*    (is_subst_amino(a_view,a_ref)) or */
7850
      /*    (is_subst_amino(a_view,a_ref)) or */
8788
      /*    (is_acylamino(a_ref,a_view))) then  */
7851
      /*    (is_acylamino(a_ref,a_view))) then  */
8789
      if (bond[get_bond (a_view, a_ref) - 1].arom == false)
7852
      if (bond[get_bond (a_view, a_ref) - 1].arom == false)
8790
        fg[fg_hydrazine - 1] = true;
7853
              fg[fg_hydrazine - 1] = true;
8791
    }
7854
  }
8792
  if (!strcmp (atom[a_view - 1].element, "N ") &&
7855
  if (!strcmp (atom[a_view - 1].element, "N ") &&
8793
      !strcmp (atom[a_ref - 1].atype, "O3 "))
7856
      !strcmp (atom[a_ref - 1].atype, "O3 ")) {
8794
    {                           /* bond is in "opposite" direction */
7857
    /* bond is in "opposite" direction */
8795
      if ((is_alkoxy (a_view, a_ref) || is_aryloxy (a_view, a_ref)) &
7858
    if ((is_alkoxy (a_view, a_ref) || is_aryloxy (a_view, a_ref)) &
8796
          is_nitro (a_ref, a_view))
7859
              is_nitro (a_ref, a_view))
8797
        fg[fg_nitrate - 1] = true;
7860
            fg[fg_nitrate - 1] = true;
8798
      if ((is_nitro (a_ref, a_view) == false
7861
    if ((is_nitro (a_ref, a_view) == false
8799
           && atom[a_view - 1].arom == false) && (is_amino (a_ref,
7862
              && atom[a_view - 1].arom == false) && (is_amino (a_ref, a_view) |
8800
                                                            a_view) |
-
 
8801
                                                  is_subst_amino (a_ref,
7863
                    is_subst_amino (a_ref, a_view)) &
8802
                                                                  a_view)) &
-
 
8803
          (is_acylamino (a_ref, a_view) == false))
7864
              (is_acylamino (a_ref, a_view) == false))
8804
        fg[fg_hydroxylamine - 1] = true;        /* new in v0.3c */
7865
            fg[fg_hydroxylamine - 1] = true;    /* new in v0.3c */
8805
    }
7866
  }
8806
  if (!strcmp (atom[a_view - 1].element, "S ") &&
7867
  if (!strcmp (atom[a_view - 1].element, "S ") &&
8807
      !strcmp (atom[a_ref - 1].element, "O "))
7868
      !strcmp (atom[a_ref - 1].element, "O "))
8808
    chk_sulfoxide (a_view, a_ref);
7869
    chk_sulfoxide (a_view, a_ref);
8809
}
7870
}
8810
 
7871
 
8811
 
-
 
8812
static void
-
 
8813
chk_single (a1, a2)
7872
static void chk_single (a1, a2)
8814
     int a1, a2;
7873
     int a1, a2;
8815
{
7874
{
8816
  str2 a1_el, a2_el;
7875
  str2 a1_el, a2_el;
8817
 
7876
 
8818
  strcpy (a1_el, atom[a1 - 1].element);
7877
  strcpy (a1_el, atom[a1 - 1].element);
Line 8825... Line 7884...
8825
    chk_c_o (a1, a2);
7884
    chk_c_o (a1, a2);
8826
  if (!strcmp (a1_el, "C ") && !strcmp (a2_el, "S "))
7885
  if (!strcmp (a1_el, "C ") && !strcmp (a2_el, "S "))
8827
    chk_c_s (a1, a2);
7886
    chk_c_s (a1, a2);
8828
  if (!strcmp (a1_el, "C ") && !strcmp (a2_el, "N "))
7887
  if (!strcmp (a1_el, "C ") && !strcmp (a2_el, "N "))
8829
    chk_c_n (a1, a2);
7888
    chk_c_n (a1, a2);
8830
  if ((strcmp (a1_el, "C ") == 0) && atom[a2 - 1].metal && (is_cyano_c (a1) ==
7889
  if ((strcmp (a1_el, "C ") == 0) && atom[a2 - 1].metal && (is_cyano_c (a1) == false)) {
8831
                                                            false))
-
 
8832
    {
-
 
8833
      fg[fg_organometallic - 1] = true;
7890
      fg[fg_organometallic - 1] = true;
8834
      if (!strcmp (a2_el, "LI"))
7891
      if (!strcmp (a2_el, "LI"))
8835
        fg[fg_organolithium - 1] = true;
7892
              fg[fg_organolithium - 1] = true;
8836
      if (!strcmp (a2_el, "MG"))
7893
      if (!strcmp (a2_el, "MG"))
8837
        fg[fg_organomagnesium - 1] = true;
7894
              fg[fg_organomagnesium - 1] = true;
8838
    }
7895
  }
8839
  if (!strcmp (a1_el, "C ") && !strcmp (a2_el, "C "))
7896
  if (!strcmp (a1_el, "C ") && !strcmp (a2_el, "C "))
8840
    chk_c_c (a1, a2);
7897
    chk_c_c (a1, a2);
8841
  if (strcmp (a1_el, "C ") && strcmp (a2_el, "C "))
7898
  if (strcmp (a1_el, "C ") && strcmp (a2_el, "C "))
8842
    chk_x_y_single (a1, a2);
7899
    chk_x_y_single (a1, a2);
8843
}
7900
}
8844
 
7901
 
8845
 
-
 
8846
static void
-
 
8847
chk_carbonyl_deriv_sp3 (a_ref)
7902
static void chk_carbonyl_deriv_sp3 (a_ref)
8848
     int a_ref;
7903
     int a_ref;
8849
{
7904
{
8850
  int i;
7905
  int i;
8851
  neighbor_rec nb;
7906
  neighbor_rec nb;
8852
  int oh_count = 0, or_count = 0, n_count = 0, sh_count = 0, sr_count = 0;
7907
  int oh_count = 0, or_count = 0, n_count = 0, sh_count = 0, sr_count = 0;
8853
  int FORLIM;
7908
  int FORLIM;
8854
 
7909
 
8855
  memset (nb, 0, sizeof (neighbor_rec));
7910
  memset (nb, 0, sizeof (neighbor_rec));
8856
  get_neighbors (nb, a_ref);
7911
  get_neighbors (nb, a_ref);
8857
  FORLIM = atom[a_ref - 1].neighbor_count;
7912
  FORLIM = atom[a_ref - 1].neighbor_count;
8858
  for (i = 0; i < FORLIM; i++)
7913
  for (i = 0; i < FORLIM; i++) {
8859
    {
-
 
8860
      if (is_hydroxy (a_ref, nb[i]))
7914
    if (is_hydroxy (a_ref, nb[i]))
8861
        oh_count++;
7915
            oh_count++;
8862
      if (is_alkoxy (a_ref, nb[i]) || is_aryloxy (a_ref, nb[i]) |
7916
    if (is_alkoxy (a_ref, nb[i]) || is_aryloxy (a_ref, nb[i]) |
8863
          is_alkenyloxy (a_ref, nb[i]) || is_alkynyloxy (a_ref, nb[i]))
7917
              is_alkenyloxy (a_ref, nb[i]) || is_alkynyloxy (a_ref, nb[i]))
8864
        or_count++;
7918
            or_count++;
8865
      if (is_sulfanyl (a_ref, nb[i]))
7919
    if (is_sulfanyl (a_ref, nb[i]))
8866
        sh_count++;
7920
            sh_count++;
8867
      if (is_alkylsulfanyl (a_ref, nb[i]) || is_arylsulfanyl (a_ref, nb[i]) |
7921
    if (is_alkylsulfanyl (a_ref, nb[i]) || is_arylsulfanyl (a_ref, nb[i]) |
8868
          is_alkenylsulfanyl (a_ref, nb[i]) || is_alkynylsulfanyl (a_ref,
7922
              is_alkenylsulfanyl (a_ref, nb[i]) || is_alkynylsulfanyl (a_ref, nb[i]))
8869
                                                                   nb[i]))
-
 
8870
        sr_count++;
7923
            sr_count++;
8871
      if (!strcmp (atom[nb[i] - 1].atype, "N3 ") ||
7924
    if (!strcmp (atom[nb[i] - 1].atype, "N3 ") || !strcmp (atom[nb[i] - 1].atype, "NAM"))
8872
          !strcmp (atom[nb[i] - 1].atype, "NAM"))
-
 
8873
        n_count++;
7925
            n_count++;
8874
    }
7926
  }
8875
  if (oh_count == 2)
7927
  if (oh_count == 2)
8876
    fg[fg_carbonyl_hydrate - 1] = true;
7928
    fg[fg_carbonyl_hydrate - 1] = true;
8877
  if (oh_count == 1 && or_count == 1)
7929
  if (oh_count == 1 && or_count == 1)
8878
    fg[fg_hemiacetal - 1] = true;
7930
    fg[fg_hemiacetal - 1] = true;
8879
  if (or_count == 2)
7931
  if (or_count == 2)
Line 8886... Line 7938...
8886
    fg[fg_thiohemiaminal - 1] = true;
7938
    fg[fg_thiohemiaminal - 1] = true;
8887
  if (sr_count == 2 || (or_count == 1 && sr_count == 1))
7939
  if (sr_count == 2 || (or_count == 1 && sr_count == 1))
8888
    fg[fg_thioacetal - 1] = true;
7940
    fg[fg_thioacetal - 1] = true;
8889
}
7941
}
8890
 
7942
 
8891
 
-
 
8892
static void
-
 
8893
chk_carboxyl_deriv_sp3 (a_ref)
7943
static void chk_carboxyl_deriv_sp3 (a_ref)
8894
     int a_ref;
7944
     int a_ref;
8895
{
7945
{
8896
  int i;
7946
  int i;
8897
  neighbor_rec nb;
7947
  neighbor_rec nb;
8898
  int or_count = 0, oh_count = 0, n_count = 0;  /* oh_count new in v0.3c */
7948
  int or_count = 0, oh_count = 0, n_count = 0;  /* oh_count new in v0.3c */
8899
  int electroneg_count = 0;     /* new in v0.3j */
7949
  int electroneg_count = 0;     /* new in v0.3j */
8900
  int hal_count = 0;
7950
  int hal_count = 0;
8901
  str2 nb_el;
7951
  str2 nb_el;
8902
  int FORLIM;
7952
  int FORLIM;
8903
 
7953
 
8904
  memset (nb, 0, sizeof (neighbor_rec));
7954
  memset (nb, 0, sizeof (neighbor_rec));
8905
  get_neighbors (nb, a_ref);
7955
  get_neighbors (nb, a_ref);
8906
  FORLIM = atom[a_ref - 1].neighbor_count;
7956
  FORLIM = atom[a_ref - 1].neighbor_count;
8907
  for (i = 0; i < FORLIM; i++)
7957
  for (i = 0; i < FORLIM; i++) {
8908
    {
-
 
8909
      strcpy (nb_el, atom[nb[i] - 1].element);  /* v0.3j */
7958
    strcpy (nb_el, atom[nb[i] - 1].element);    /* v0.3j */
8910
      if (is_electroneg (nb_el))
7959
    if (is_electroneg (nb_el))
8911
        electroneg_count++;
7960
            electroneg_count++;
8912
      if (!strcmp (nb_el, "F ") || !strcmp (nb_el, "CL") ||
7961
    if (!strcmp (nb_el, "F ") || !strcmp (nb_el, "CL") ||
8913
          !strcmp (nb_el, "BR") || !strcmp (nb_el, "I ")
7962
              !strcmp (nb_el, "BR") || !strcmp (nb_el, "I ")
8914
          || !strcmp (nb_el, "AT"))
7963
              || !strcmp (nb_el, "AT"))
8915
        hal_count++;
7964
            hal_count++;
8916
      if (is_alkoxy (a_ref, nb[i]) || is_aryloxy (a_ref, nb[i]) |
7965
    if (is_alkoxy (a_ref, nb[i]) || is_aryloxy (a_ref, nb[i]) |
8917
          is_siloxy (a_ref, nb[i]))
7966
              is_siloxy (a_ref, nb[i]))
8918
        or_count++;
7967
            or_count++;
8919
      if (is_hydroxy (a_ref, nb[i]))    /* new in v0.3c    */
7968
    if (is_hydroxy (a_ref, nb[i]))      /* new in v0.3c    */
8920
        oh_count++;
7969
            oh_count++;
8921
      if (!strcmp (atom[nb[i] - 1].atype, "N3 ") ||
7970
    if (!strcmp (atom[nb[i] - 1].atype, "N3 ") ||
8922
          !strcmp (atom[nb[i] - 1].atype, "NAM"))
7971
              !strcmp (atom[nb[i] - 1].atype, "NAM"))
8923
        n_count++;
7972
            n_count++;
8924
    }
7973
  }
8925
  /*if (or_count + n_count > 1) then fg[fg_orthocarboxylic_acid_deriv] := true;  (* until v0.3i */
7974
  /*if (or_count + n_count > 1) then fg[fg_orthocarboxylic_acid_deriv] := true;  (* until v0.3i */
8926
  if (electroneg_count == 3 && hal_count < 3)   /* v0.3j */
7975
  if (electroneg_count == 3 && hal_count < 3)   /* v0.3j */
8927
    fg[fg_orthocarboxylic_acid_deriv - 1] = true;
7976
    fg[fg_orthocarboxylic_acid_deriv - 1] = true;
8928
  if (or_count == 3)
7977
  if (or_count == 3)
8929
    fg[fg_carboxylic_acid_orthoester - 1] = true;
7978
    fg[fg_carboxylic_acid_orthoester - 1] = true;
8930
  if (or_count == 2 && n_count == 1)
7979
  if (or_count == 2 && n_count == 1)
8931
    fg[fg_carboxylic_acid_amide_acetal - 1] = true;
7980
    fg[fg_carboxylic_acid_amide_acetal - 1] = true;
8932
  if (oh_count > 0 && oh_count + or_count + n_count == 3)       /* new in v0.3c */
7981
  if (oh_count > 0 && oh_count + or_count + n_count == 3)       /* new in v0.3c */
8933
    fg[fg_orthocarboxylic_acid_deriv - 1] = true;
7982
    fg[fg_orthocarboxylic_acid_deriv - 1] = true;
8934
}
7983
}
8935
 
7984
 
-
 
7985
static void chk_anhydride (a_ref)
-
 
7986
     int a_ref;
-
 
7987
{
-
 
7988
  int i;
-
 
7989
  neighbor_rec nb;
-
 
7990
  int acyl_count = 0;
-
 
7991
  int FORLIM;
8936
 
7992
 
-
 
7993
  memset (nb, 0, sizeof (neighbor_rec));
-
 
7994
  get_neighbors (nb, a_ref);
-
 
7995
  FORLIM = atom[a_ref - 1].neighbor_count;
-
 
7996
  for (i = 0; i < FORLIM; i++) {
-
 
7997
    if (is_acyl (a_ref, nb[i]) || is_carbamoyl (a_ref, nb[i]))
8937
static void
7998
            acyl_count++;
-
 
7999
  }
-
 
8000
  if (acyl_count == 2 && !strcmp (atom[a_ref - 1].atype, "O3 ")) {
-
 
8001
    fg[fg_carboxylic_acid_deriv - 1] = true;
-
 
8002
    fg[fg_carboxylic_acid_anhydride - 1] = true;
-
 
8003
  }
-
 
8004
}
-
 
8005
 
8938
chk_anhydride (a_ref)
8006
static void chk_imide (a_ref)
8939
     int a_ref;
8007
     int a_ref;
8940
{
8008
{
8941
  int i;
8009
  int i;
8942
  neighbor_rec nb;
8010
  neighbor_rec nb;
8943
  int acyl_count = 0;
8011
  int acyl_count = 0;
8944
  int FORLIM;
8012
  int FORLIM;
8945
 
8013
 
8946
  memset (nb, 0, sizeof (neighbor_rec));
8014
  memset (nb, 0, sizeof (neighbor_rec));
8947
  get_neighbors (nb, a_ref);
8015
  get_neighbors (nb, a_ref);
8948
  FORLIM = atom[a_ref - 1].neighbor_count;
8016
  FORLIM = atom[a_ref - 1].neighbor_count;
8949
  for (i = 0; i < FORLIM; i++)
8017
  for (i = 0; i < FORLIM; i++) {
8950
    {
-
 
8951
      if (is_acyl (a_ref, nb[i]) || is_carbamoyl (a_ref, nb[i]))
-
 
8952
        acyl_count++;
-
 
8953
    }
-
 
8954
  if (acyl_count == 2 && !strcmp (atom[a_ref - 1].atype, "O3 "))
-
 
8955
    {
-
 
8956
      fg[fg_carboxylic_acid_deriv - 1] = true;
-
 
8957
      fg[fg_carboxylic_acid_anhydride - 1] = true;
-
 
8958
    }
-
 
8959
}
-
 
8960
 
-
 
8961
 
-
 
8962
static void
-
 
8963
chk_imide (a_ref)
-
 
8964
     int a_ref;
-
 
8965
{
-
 
8966
  int i;
-
 
8967
  neighbor_rec nb;
-
 
8968
  int acyl_count = 0;
-
 
8969
  int FORLIM;
-
 
8970
 
-
 
8971
  memset (nb, 0, sizeof (neighbor_rec));
-
 
8972
  get_neighbors (nb, a_ref);
-
 
8973
  FORLIM = atom[a_ref - 1].neighbor_count;
-
 
8974
  for (i = 0; i < FORLIM; i++)
-
 
8975
    {
-
 
8976
      if (is_acyl_gen (a_ref, nb[i]) || is_carbamoyl (a_ref, nb[i]))    /* v0.3j */
8018
    if (is_acyl_gen (a_ref, nb[i]) || is_carbamoyl (a_ref, nb[i]))      /* v0.3j */
8977
        acyl_count++;
8019
            acyl_count++;
8978
    }
8020
  }
8979
  if (acyl_count < 2 || strcmp (atom[a_ref - 1].element, "N "))
8021
  if (acyl_count < 2 || strcmp (atom[a_ref - 1].element, "N "))
8980
    /* v0.3j: accept also N-acyl-imides */
8022
    /* v0.3j: accept also N-acyl-imides */
8981
    return;
8023
    return;
8982
  fg[fg_carboxylic_acid_deriv - 1] = true;
8024
  fg[fg_carboxylic_acid_deriv - 1] = true;
8983
  fg[fg_carboxylic_acid_imide - 1] = true;
8025
  fg[fg_carboxylic_acid_imide - 1] = true;
Line 8985... Line 8027...
8985
    fg[fg_carboxylic_acid_unsubst_imide - 1] = true;
8027
    fg[fg_carboxylic_acid_unsubst_imide - 1] = true;
8986
  if (atom[a_ref - 1].neighbor_count == 3)
8028
  if (atom[a_ref - 1].neighbor_count == 3)
8987
    fg[fg_carboxylic_acid_subst_imide - 1] = true;
8029
    fg[fg_carboxylic_acid_subst_imide - 1] = true;
8988
}
8030
}
8989
 
8031
 
8990
 
-
 
8991
static void
-
 
8992
chk_12diphenol (a_view, a_ref)
8032
static void chk_12diphenol (a_view, a_ref)
8993
     int a_view, a_ref;
8033
     int a_view, a_ref;
8994
{
8034
{
8995
  int i;
8035
  int i;
8996
  neighbor_rec nb;
8036
  neighbor_rec nb;
8997
  int oh_count = 0;
8037
  int oh_count = 0;
8998
  int FORLIM;
8038
  int FORLIM;
8999
 
8039
 
9000
  memset (nb, 0, sizeof (neighbor_rec));
8040
  memset (nb, 0, sizeof (neighbor_rec));
9001
  get_neighbors (nb, a_view);
8041
  get_neighbors (nb, a_view);
9002
  FORLIM = atom[a_view - 1].neighbor_count;
8042
  FORLIM = atom[a_view - 1].neighbor_count;
9003
  for (i = 0; i < FORLIM; i++)
8043
  for (i = 0; i < FORLIM; i++) {
9004
    {
-
 
9005
      if (bond[get_bond (a_view, nb[i]) - 1].btype == 'S')
8044
    if (bond[get_bond (a_view, nb[i]) - 1].btype == 'S') {
9006
        {
-
 
9007
          if (is_hydroxy (a_view, nb[i]))
8045
            if (is_hydroxy (a_view, nb[i]))
9008
            oh_count++;
8046
              oh_count++;
9009
        }
8047
          }
9010
    }
8048
  }
9011
  memset (nb, 0, sizeof (neighbor_rec));
8049
  memset (nb, 0, sizeof (neighbor_rec));
9012
  get_neighbors (nb, a_ref);
8050
  get_neighbors (nb, a_ref);
9013
  FORLIM = atom[a_ref - 1].neighbor_count;
8051
  FORLIM = atom[a_ref - 1].neighbor_count;
9014
  for (i = 0; i < FORLIM; i++)
8052
  for (i = 0; i < FORLIM; i++) {
9015
    {
-
 
9016
      if (bond[get_bond (a_ref, nb[i]) - 1].btype == 'S')
8053
    if (bond[get_bond (a_ref, nb[i]) - 1].btype == 'S') {
9017
        {
-
 
9018
          if (is_hydroxy (a_ref, nb[i]))
8054
            if (is_hydroxy (a_ref, nb[i]))
9019
            oh_count++;
8055
              oh_count++;
9020
        }
8056
          }
9021
    }
8057
  }
9022
  if (oh_count == 2)
8058
  if (oh_count == 2)
9023
    fg[fg_1_2_diphenol - 1] = true;
8059
    fg[fg_1_2_diphenol - 1] = true;
9024
}
8060
}
9025
 
8061
 
9026
 
-
 
9027
static void
-
 
9028
chk_arom_fg (a1, a2)
8062
static void chk_arom_fg (a1, a2)
9029
     int a1, a2;
8063
     int a1, a2;
9030
{
8064
{
9031
  if ((hetbond_count (a1) == 1) && (hetbond_count (a2) == 1))
8065
  if ((hetbond_count (a1) == 1) && (hetbond_count (a2) == 1))
9032
    chk_12diphenol (a1, a2);
8066
    chk_12diphenol (a1, a2);
9033
}
8067
}
9034
 
-
 
9035
 
8068
 
9036
static boolean
-
 
9037
is_arene (r_id)
8069
static boolean is_arene (r_id)
9038
     int r_id;
8070
     int r_id;
9039
{
8071
{
9040
  int i, j;
8072
  int i, j;
9041
  boolean r = true;
8073
  boolean r = true;
9042
  ringpath_type testring;
8074
  ringpath_type testring;
Line 9052... Line 8084...
9052
    testring[j] = ring[r_id - 1][j];
8084
    testring[j] = ring[r_id - 1][j];
9053
  /*ring_size := path_length(testring); */
8085
  /*ring_size := path_length(testring); */
9054
  if (ring_size <= 2)
8086
  if (ring_size <= 2)
9055
    return false;
8087
    return false;
9056
  a_prev = testring[ring_size - 1];
8088
  a_prev = testring[ring_size - 1];
9057
  for (i = 0; i < ring_size; i++)
8089
  for (i = 0; i < ring_size; i++) {
9058
    {
-
 
9059
      a_ref = testring[i];
8090
    a_ref = testring[i];
9060
      if (bond[get_bond (a_prev, a_ref) - 1].arom == false)
8091
    if (bond[get_bond (a_prev, a_ref) - 1].arom == false)
9061
        r = false;
8092
            r = false;
9062
      a_prev = a_ref;
8093
    a_prev = a_ref;
9063
    }
8094
  }
9064
  return r;
8095
  return r;
9065
}
8096
}
9066
 
8097
 
9067
 
-
 
9068
static boolean
-
 
9069
is_heterocycle (r_id)
8098
static boolean is_heterocycle (r_id)
9070
     int r_id;
8099
     int r_id;
9071
{
8100
{
9072
  int i, j;
8101
  int i, j;
9073
  boolean r = false;
8102
  boolean r = false;
9074
  ringpath_type testring;
8103
  ringpath_type testring;
9075
  int ring_size, a_ref;
8104
  int ring_size, a_ref;
9076
 
8105
 
9077
  if (r_id < 1 || r_id > n_rings)
8106
  if (r_id < 1 || r_id > n_rings)
9078
    return false;
8107
    return false;
9079
  memset (testring, 0, sizeof (ringpath_type));
8108
  memset (testring, 0, sizeof (ringpath_type));
9080
  ring_size = ringprop[r_id - 1].size;  /* v0.3j */
8109
  ring_size = ringprop[r_id - 1].size;  /* v0.3j */
9081
  /*for j := 1 to max_ringsize do if ring^[r_id,j] > 0 then testring[j] := ring^[r_id,j]; */
8110
  /*for j := 1 to max_ringsize do if ring^[r_id,j] > 0 then testring[j] := ring^[r_id,j]; */
9082
  for (j = 0; j < ring_size; j++)       /* v0.3j */
8111
  for (j = 0; j < ring_size; j++)       /* v0.3j */
9083
    testring[j] = ring[r_id - 1][j];
8112
    testring[j] = ring[r_id - 1][j];
9084
  /*ring_size := path_length(testring); */
8113
  /*ring_size := path_length(testring); */
9085
  if (ring_size <= 2)
8114
  if (ring_size <= 2)
9086
    return false;
8115
    return false;
9087
  for (i = 0; i < ring_size; i++)
8116
  for (i = 0; i < ring_size; i++) {
9088
    {
-
 
9089
      a_ref = testring[i];
8117
    a_ref = testring[i];
9090
      if (strcmp (atom[a_ref - 1].element, "C "))
8118
    if (strcmp (atom[a_ref - 1].element, "C "))
9091
        r = true;
8119
            r = true;
9092
    }
8120
  }
9093
  return r;
8121
  return r;
9094
}
8122
}
9095
 
-
 
9096
 
8123
 
9097
static void
-
 
9098
chk_oxo_thioxo_imino_hetarene (r_id)
8124
static void chk_oxo_thioxo_imino_hetarene (r_id)
9099
     int r_id;
8125
     int r_id;
9100
{
8126
{
9101
  int i, j;
8127
  int i, j;
9102
  ringpath_type testring;
8128
  ringpath_type testring;
9103
  int ring_size, a_ref;
8129
  int ring_size, a_ref;
Line 9110... Line 8136...
9110
  for (j = 0; j < ring_size; j++)       /* v0.3j */
8136
  for (j = 0; j < ring_size; j++)       /* v0.3j */
9111
    testring[j] = ring[r_id - 1][j];
8137
    testring[j] = ring[r_id - 1][j];
9112
  /*ring_size := path_length(testring); */
8138
  /*ring_size := path_length(testring); */
9113
  /*if (is_arene(r_id)) and (odd(ring_size) = false) then */
8139
  /*if (is_arene(r_id)) and (odd(ring_size) = false) then */
9114
  if (!is_arene (r_id))         /* v0.3j */
8140
  if (!is_arene (r_id))         /* v0.3j */
9115
    return;
8141
    return;
9116
  for (i = 0; i < ring_size; i++)
8142
  for (i = 0; i < ring_size; i++) {
9117
    {
-
 
9118
      a_ref = testring[i];
8143
    a_ref = testring[i];
9119
      if (is_oxo_C (a_ref))
8144
    if (is_oxo_C (a_ref))
9120
        fg[fg_oxohetarene - 1] = true;
8145
            fg[fg_oxohetarene - 1] = true;
9121
      if (is_thioxo_C (a_ref))
8146
    if (is_thioxo_C (a_ref))
9122
        fg[fg_thioxohetarene - 1] = true;
8147
            fg[fg_thioxohetarene - 1] = true;
9123
      if (is_true_exocyclic_imino_C (a_ref, r_id))      /* v0.3j */
8148
    if (is_true_exocyclic_imino_C (a_ref, r_id))        /* v0.3j */
9124
        fg[fg_iminohetarene - 1] = true;
8149
            fg[fg_iminohetarene - 1] = true;
9125
    }
8150
  }
9126
}
8151
}
9127
 
8152
 
9128
 
-
 
9129
static void
-
 
9130
chk_ion (a_ref)
8153
static void chk_ion (a_ref)
9131
     int a_ref;
8154
     int a_ref;
9132
{
8155
{
9133
  int i;
8156
  int i;
9134
  neighbor_rec nb;
8157
  neighbor_rec nb;
9135
  int charge, FORLIM;
8158
  int charge, FORLIM;
9136
 
8159
 
9137
  memset (nb, 0, sizeof (neighbor_rec));
8160
  memset (nb, 0, sizeof (neighbor_rec));
9138
  get_neighbors (nb, a_ref);
8161
  get_neighbors (nb, a_ref);
9139
  charge = atom[a_ref - 1].formal_charge;
8162
  charge = atom[a_ref - 1].formal_charge;
9140
  if (charge == 0)
8163
  if (charge == 0)
9141
    /* check if charge is neutralized by an adjacent opposite charge */
8164
    /* check if charge is neutralized by an adjacent opposite charge */
Line 9147... Line 8170...
9147
    fg[fg_cation - 1] = true;
8170
    fg[fg_cation - 1] = true;
9148
  if (charge < 0)
8171
  if (charge < 0)
9149
    fg[fg_anion - 1] = true;
8172
    fg[fg_anion - 1] = true;
9150
}
8173
}
9151
 
8174
 
9152
 
-
 
9153
static void
-
 
9154
chk_functionalgroups ()
8175
static void chk_functionalgroups ()
9155
{
8176
{
9156
  int i, a1, a2;
8177
  int i, a1, a2;
9157
  char bt;
8178
  char bt;
9158
  int pos_chg = 0, neg_chg = 0;
8179
  int pos_chg = 0, neg_chg = 0;
9159
  int FORLIM;
8180
  int FORLIM;
9160
 
8181
 
9161
  if (n_atoms < 1 || n_bonds < 1)
8182
  if (n_atoms < 1 || n_bonds < 1)
9162
    return;
8183
    return;
9163
  FORLIM = n_atoms;
8184
  FORLIM = n_atoms;
9164
  for (i = 1; i <= FORLIM; i++)
-
 
9165
    {                           /* a few groups are best discovered in the atom list */
8185
  for (i = 1; i <= FORLIM; i++) {                               /* a few groups are best discovered in the atom list */
9166
      if (!strcmp (atom[i - 1].atype, "SO2"))
8186
    if (!strcmp (atom[i - 1].atype, "SO2"))
9167
        chk_so2_deriv (i);
8187
            chk_so2_deriv (i);
9168
      /*if (atom^[i].atype = 'SO ') then fg[fg_sulfoxide] := true;  (* do another check in the bond list!! */
8188
    /*if (atom^[i].atype = 'SO ') then fg[fg_sulfoxide] := true;  (* do another check in the bond list!! */
9169
      if (!strcmp (atom[i - 1].element, "P "))
8189
    if (!strcmp (atom[i - 1].element, "P "))
9170
        chk_p_deriv (i);
8190
            chk_p_deriv (i);
9171
      if (!strcmp (atom[i - 1].element, "B "))
8191
    if (!strcmp (atom[i - 1].element, "B "))
9172
        chk_b_deriv (i);
8192
            chk_b_deriv (i);
9173
      if (!strcmp (atom[i - 1].atype, "N3+") || atom[i - 1].formal_charge > 0)
8193
    if (!strcmp (atom[i - 1].atype, "N3+") || atom[i - 1].formal_charge > 0)
9174
        chk_ammon (i);
8194
            chk_ammon (i);
9175
      if ((strcmp (atom[i - 1].atype, "C3 ") == 0)
8195
    if ((strcmp (atom[i - 1].atype, "C3 ") == 0) && (hetbond_count (i) == 2))
9176
          && (hetbond_count (i) == 2))
-
 
9177
        chk_carbonyl_deriv_sp3 (i);
8196
            chk_carbonyl_deriv_sp3 (i);
9178
      if ((strcmp (atom[i - 1].atype, "C3 ") == 0)
8197
    if ((strcmp (atom[i - 1].atype, "C3 ") == 0) && (hetbond_count (i) == 3))
9179
          && (hetbond_count (i) == 3))
-
 
9180
        chk_carboxyl_deriv_sp3 (i);
8198
            chk_carboxyl_deriv_sp3 (i);
9181
      if (!strcmp (atom[i - 1].atype, "O3 ")
8199
    if (!strcmp (atom[i - 1].atype, "O3 ") && atom[i - 1].neighbor_count == 2)
9182
          && atom[i - 1].neighbor_count == 2)
-
 
9183
        chk_anhydride (i);
8200
            chk_anhydride (i);
9184
      if ((!strcmp (atom[i - 1].atype, "N3 ")
8201
    if ((!strcmp (atom[i - 1].atype, "N3 ") || !strcmp (atom[i - 1].atype, "NAM"))
9185
           || !strcmp (atom[i - 1].atype, "NAM"))
-
 
9186
          && atom[i - 1].neighbor_count >= 2)
8202
              && atom[i - 1].neighbor_count >= 2)
9187
        chk_imide (i);
8203
            chk_imide (i);
9188
      if (atom[i - 1].formal_charge > 0)
8204
    if (atom[i - 1].formal_charge > 0)
9189
        pos_chg += atom[i - 1].formal_charge;
8205
            pos_chg += atom[i - 1].formal_charge;
9190
      if (atom[i - 1].formal_charge < 0)
8206
    if (atom[i - 1].formal_charge < 0)
9191
        neg_chg += atom[i - 1].formal_charge;
8207
            neg_chg += atom[i - 1].formal_charge;
9192
      chk_ion (i);
8208
    chk_ion (i);
9193
    }
8209
  }
9194
  FORLIM = n_bonds;
8210
  FORLIM = n_bonds;
9195
  for (i = 0; i < FORLIM; i++)
-
 
9196
    {                           /* most groups are best discovered in the bond list */
8211
  for (i = 0; i < FORLIM; i++) {                                /* most groups are best discovered in the bond list */
9197
      a1 = bond[i].a1;
8212
    a1 = bond[i].a1;
9198
      a2 = bond[i].a2;
8213
    a2 = bond[i].a2;
9199
      bt = bond[i].btype;
8214
    bt = bond[i].btype;
9200
      if (atom[a1 - 1].heavy && atom[a2 - 1].heavy)
8215
    if (atom[a1 - 1].heavy && atom[a2 - 1].heavy) {
9201
        {
-
 
9202
          orient_bond (&a1, &a2);
8216
            orient_bond (&a1, &a2);
9203
          if (bt == 'T')
8217
            if (bt == 'T')
9204
            chk_triple (a1, a2);
8218
              chk_triple (a1, a2);
9205
          if (bt == 'D')
8219
            if (bt == 'D')
9206
            chk_double (a1, a2);
8220
              chk_double (a1, a2);
9207
          if (bt == 'S')
8221
            if (bt == 'S')
9208
            chk_single (a1, a2);
8222
              chk_single (a1, a2);
9209
          if (bond[i].arom)
8223
            if (bond[i].arom)
9210
            chk_arom_fg (a1, a2);
8224
              chk_arom_fg (a1, a2);
9211
        }
8225
          }
9212
    }
8226
  }
9213
  if (n_rings > 0)
8227
  if (n_rings > 0) {
9214
    {
-
 
9215
      FORLIM = n_rings;
8228
    FORLIM = n_rings;
9216
      for (i = 1; i <= FORLIM; i++)
8229
    for (i = 1; i <= FORLIM; i++) {
9217
        {
-
 
9218
          chk_oxo_thioxo_imino_hetarene (i);
8230
            chk_oxo_thioxo_imino_hetarene (i);
9219
          if (is_arene (i))
8231
            if (is_arene (i))
9220
            fg[fg_aromatic - 1] = true;
8232
              fg[fg_aromatic - 1] = true;
9221
          if (is_heterocycle (i))
8233
            if (is_heterocycle (i))
9222
            fg[fg_heterocycle - 1] = true;
8234
              fg[fg_heterocycle - 1] = true;
9223
        }
8235
          }
9224
    }
8236
  }
9225
  if (pos_chg + neg_chg > 0)
8237
  if (pos_chg + neg_chg > 0)
9226
    fg[fg_cation - 1] = true;
8238
    fg[fg_cation - 1] = true;
9227
  if (pos_chg + neg_chg < 0)
8239
  if (pos_chg + neg_chg < 0)
9228
    fg[fg_anion - 1] = true;
8240
    fg[fg_anion - 1] = true;
9229
}
8241
}
9230
 
8242
 
9231
 
-
 
9232
static void
-
 
9233
write_fg_text ()
8243
static void write_fg_text ()
9234
{
8244
{
9235
  if (fg[fg_cation - 1])
8245
  if (fg[fg_cation - 1])
9236
    printf ("cation\n");
8246
    printf ("cation\n");
9237
  if (fg[fg_anion - 1])
8247
  if (fg[fg_anion - 1])
9238
    printf ("anion\n");
8248
    printf ("anion\n");
Line 9348... Line 8358...
9348
  if (fg[fg_quart_ammonium - 1])
8358
  if (fg[fg_quart_ammonium - 1])
9349
    printf ("quaternary ammonium salt\n");
8359
    printf ("quaternary ammonium salt\n");
9350
  if (fg[fg_n_oxide - 1])
8360
  if (fg[fg_n_oxide - 1])
9351
    printf ("N-oxide\n");
8361
    printf ("N-oxide\n");
9352
  /* new in v0.2f */
8362
  /* new in v0.2f */
9353
  if (fg[fg_halogen_deriv - 1])
8363
  if (fg[fg_halogen_deriv - 1]) {
9354
    {
-
 
9355
      if (!fg[fg_alkyl_halide - 1] && !fg[fg_aryl_halide - 1] &&
8364
      if (!fg[fg_alkyl_halide - 1] && !fg[fg_aryl_halide - 1] &&
9356
          !fg[fg_acyl_halide - 1])
8365
              !fg[fg_acyl_halide - 1])
9357
        printf ("halogen derivative\n");
8366
            printf ("halogen derivative\n");
9358
    }
8367
  }
9359
  /*  if fg[fg_alkyl_halide]                   then writeln('alkyl halide'); */
8368
  /*  if fg[fg_alkyl_halide]                   then writeln('alkyl halide'); */
9360
  if (fg[fg_alkyl_fluoride - 1])
8369
  if (fg[fg_alkyl_fluoride - 1])
9361
    printf ("alkyl fluoride\n");
8370
    printf ("alkyl fluoride\n");
9362
  if (fg[fg_alkyl_chloride - 1])
8371
  if (fg[fg_alkyl_chloride - 1])
9363
    printf ("alkyl chloride\n");
8372
    printf ("alkyl chloride\n");
Line 9639... Line 8648...
9639
    printf ("alpha-aminoacid\n");
8648
    printf ("alpha-aminoacid\n");
9640
  if (fg[fg_alpha_hydroxyacid - 1])
8649
  if (fg[fg_alpha_hydroxyacid - 1])
9641
    printf ("alpha-hydroxyacid\n");
8650
    printf ("alpha-hydroxyacid\n");
9642
}
8651
}
9643
 
8652
 
9644
 
-
 
9645
static void
-
 
9646
write_fg_text_de ()
8653
static void write_fg_text_de ()
9647
{
8654
{
9648
  if (fg[fg_cation - 1])
8655
  if (fg[fg_cation - 1])
9649
    printf ("Kation\n");
8656
    printf ("Kation\n");
9650
  if (fg[fg_anion - 1])
8657
  if (fg[fg_anion - 1])
9651
    printf ("Anion\n");
8658
    printf ("Anion\n");
Line 9698... Line 8705...
9698
  if (fg[fg_hydroxy - 1] && hydroxy_generic)
8705
  if (fg[fg_hydroxy - 1] && hydroxy_generic)
9699
    printf ("Hydroxy-Verbindung\n");
8706
    printf ("Hydroxy-Verbindung\n");
9700
  /*  if fg[fg_alcohol]                        then writeln('Alkohol'); */
8707
  /*  if fg[fg_alcohol]                        then writeln('Alkohol'); */
9701
  if (fg[fg_prim_alcohol - 1])
8708
  if (fg[fg_prim_alcohol - 1])
9702
    printf ("prim\344rer Alkohol\n");
8709
    printf ("prim\344rer Alkohol\n");
9703
/* p2c: checkmol.pas, line 7283: Note: character >= 128 encountered [281] */
8710
  /* p2c: checkmol.pas, line 7283: Note: character >= 128 encountered [281] */
9704
  if (fg[fg_sec_alcohol - 1])
8711
  if (fg[fg_sec_alcohol - 1])
9705
    printf ("sekund\344rer Alkohol\n");
8712
    printf ("sekund\344rer Alkohol\n");
9706
/* p2c: checkmol.pas, line 7284: Note: character >= 128 encountered [281] */
8713
  /* p2c: checkmol.pas, line 7284: Note: character >= 128 encountered [281] */
9707
  if (fg[fg_tert_alcohol - 1])
8714
  if (fg[fg_tert_alcohol - 1])
9708
    printf ("terti\344rer Alkohol\n");
8715
    printf ("terti\344rer Alkohol\n");
9709
/* p2c: checkmol.pas, line 7285: Note: character >= 128 encountered [281] */
8716
  /* p2c: checkmol.pas, line 7285: Note: character >= 128 encountered [281] */
9710
  if (fg[fg_1_2_diol - 1])
8717
  if (fg[fg_1_2_diol - 1])
9711
    printf ("1,2-Diol\n");
8718
    printf ("1,2-Diol\n");
9712
  if (fg[fg_1_2_aminoalcohol - 1])
8719
  if (fg[fg_1_2_aminoalcohol - 1])
9713
    printf ("1,2-Aminoalkohol\n");
8720
    printf ("1,2-Aminoalkohol\n");
9714
  if (fg[fg_phenol - 1])
8721
  if (fg[fg_phenol - 1])
Line 9739... Line 8746...
9739
    printf ("Hydroxylamin\n");
8746
    printf ("Hydroxylamin\n");
9740
  if (fg[fg_amine - 1] && amine_generic)
8747
  if (fg[fg_amine - 1] && amine_generic)
9741
    printf ("Amin\n");
8748
    printf ("Amin\n");
9742
  if (fg[fg_prim_amine - 1])
8749
  if (fg[fg_prim_amine - 1])
9743
    printf ("prim\344res Amin\n");
8750
    printf ("prim\344res Amin\n");
9744
/* p2c: checkmol.pas, line 7302: Note: character >= 128 encountered [281] */
8751
  /* p2c: checkmol.pas, line 7302: Note: character >= 128 encountered [281] */
9745
  if (fg[fg_prim_aliph_amine - 1])
8752
  if (fg[fg_prim_aliph_amine - 1])
9746
    printf ("prim\344res aliphatisches Amin (Alkylamin)\n");
8753
    printf ("prim\344res aliphatisches Amin (Alkylamin)\n");
9747
/* p2c: checkmol.pas, line 7303: Note: character >= 128 encountered [281] */
8754
  /* p2c: checkmol.pas, line 7303: Note: character >= 128 encountered [281] */
9748
  if (fg[fg_prim_arom_amine - 1])
8755
  if (fg[fg_prim_arom_amine - 1])
9749
    printf ("prim\344res aromatisches Amin\n");
8756
    printf ("prim\344res aromatisches Amin\n");
9750
/* p2c: checkmol.pas, line 7304: Note: character >= 128 encountered [281] */
8757
  /* p2c: checkmol.pas, line 7304: Note: character >= 128 encountered [281] */
9751
  if (fg[fg_sec_amine - 1])
8758
  if (fg[fg_sec_amine - 1])
9752
    printf ("sekund\344res Amin\n");
8759
    printf ("sekund\344res Amin\n");
9753
/* p2c: checkmol.pas, line 7305: Note: character >= 128 encountered [281] */
8760
  /* p2c: checkmol.pas, line 7305: Note: character >= 128 encountered [281] */
9754
  if (fg[fg_sec_aliph_amine - 1])
8761
  if (fg[fg_sec_aliph_amine - 1])
9755
    printf ("sekund\344res aliphatisches Amin (Dialkylamin)\n");
8762
    printf ("sekund\344res aliphatisches Amin (Dialkylamin)\n");
9756
/* p2c: checkmol.pas, line 7306: Note: character >= 128 encountered [281] */
8763
  /* p2c: checkmol.pas, line 7306: Note: character >= 128 encountered [281] */
9757
  if (fg[fg_sec_mixed_amine - 1])
8764
  if (fg[fg_sec_mixed_amine - 1])
9758
    printf
8765
    printf
9759
      ("sekund\344res aliphatisches/aromatisches Amin (Alkylarylamin)\n");
8766
      ("sekund\344res aliphatisches/aromatisches Amin (Alkylarylamin)\n");
9760
/* p2c: checkmol.pas, line 7307: Note: character >= 128 encountered [281] */
8767
  /* p2c: checkmol.pas, line 7307: Note: character >= 128 encountered [281] */
9761
  if (fg[fg_sec_arom_amine - 1])
8768
  if (fg[fg_sec_arom_amine - 1])
9762
    printf ("sekund\344res aromatisches Amin (Diarylamin)\n");
8769
    printf ("sekund\344res aromatisches Amin (Diarylamin)\n");
9763
/* p2c: checkmol.pas, line 7308: Note: character >= 128 encountered [281] */
8770
  /* p2c: checkmol.pas, line 7308: Note: character >= 128 encountered [281] */
9764
  if (fg[fg_tert_amine - 1])
8771
  if (fg[fg_tert_amine - 1])
9765
    printf ("terti\344res Amin\n");
8772
    printf ("terti\344res Amin\n");
9766
/* p2c: checkmol.pas, line 7309: Note: character >= 128 encountered [281] */
8773
  /* p2c: checkmol.pas, line 7309: Note: character >= 128 encountered [281] */
9767
  if (fg[fg_tert_aliph_amine - 1])
8774
  if (fg[fg_tert_aliph_amine - 1])
9768
    printf ("terti\344res aliphatisches Amin (Trialkylamin)\n");
8775
    printf ("terti\344res aliphatisches Amin (Trialkylamin)\n");
9769
/* p2c: checkmol.pas, line 7310: Note: character >= 128 encountered [281] */
8776
  /* p2c: checkmol.pas, line 7310: Note: character >= 128 encountered [281] */
9770
  if (fg[fg_tert_mixed_amine - 1])
8777
  if (fg[fg_tert_mixed_amine - 1])
9771
    printf ("terti\344res aliphatisches/aromatisches Amin (Alkylarylamin)\n");
8778
    printf ("terti\344res aliphatisches/aromatisches Amin (Alkylarylamin)\n");
9772
/* p2c: checkmol.pas, line 7311: Note: character >= 128 encountered [281] */
8779
  /* p2c: checkmol.pas, line 7311: Note: character >= 128 encountered [281] */
9773
  if (fg[fg_tert_arom_amine - 1])
8780
  if (fg[fg_tert_arom_amine - 1])
9774
    printf ("terti\344res aromatisches Amin (Triarylamin)\n");
8781
    printf ("terti\344res aromatisches Amin (Triarylamin)\n");
9775
/* p2c: checkmol.pas, line 7312: Note: character >= 128 encountered [281] */
8782
  /* p2c: checkmol.pas, line 7312: Note: character >= 128 encountered [281] */
9776
  if (fg[fg_quart_ammonium - 1])
8783
  if (fg[fg_quart_ammonium - 1])
9777
    printf ("quart\344res Ammoniumsalz\n");
8784
    printf ("quart\344res Ammoniumsalz\n");
9778
/* p2c: checkmol.pas, line 7313: Note: character >= 128 encountered [281] */
8785
  /* p2c: checkmol.pas, line 7313: Note: character >= 128 encountered [281] */
9779
  if (fg[fg_n_oxide - 1])
8786
  if (fg[fg_n_oxide - 1])
9780
    printf ("N-Oxid\n");
8787
    printf ("N-Oxid\n");
9781
  /* new in v0.2f */
8788
  /* new in v0.2f */
9782
  if (fg[fg_halogen_deriv - 1])
8789
  if (fg[fg_halogen_deriv - 1]) {
9783
    {
-
 
9784
      if (!fg[fg_alkyl_halide - 1] && !fg[fg_aryl_halide - 1] &&
8790
    if (!fg[fg_alkyl_halide - 1] && !fg[fg_aryl_halide - 1] &&
9785
          !fg[fg_acyl_halide - 1])
8791
              !fg[fg_acyl_halide - 1])
9786
        printf ("Halogenverbindung\n");
8792
            printf ("Halogenverbindung\n");
9787
    }
8793
  }
9788
  /*  if fg[fg_alkyl_halide]                   then writeln('Alkylhalogenid'); */
8794
  /*  if fg[fg_alkyl_halide]                   then writeln('Alkylhalogenid'); */
9789
  if (fg[fg_alkyl_fluoride - 1])
8795
  if (fg[fg_alkyl_fluoride - 1])
9790
    printf ("Alkylfluorid\n");
8796
    printf ("Alkylfluorid\n");
9791
  if (fg[fg_alkyl_chloride - 1])
8797
  if (fg[fg_alkyl_chloride - 1])
9792
    printf ("Alkylchlorid\n");
8798
    printf ("Alkylchlorid\n");
Line 9810... Line 8816...
9810
  if (fg[fg_organomagnesium - 1])
8816
  if (fg[fg_organomagnesium - 1])
9811
    printf ("Organomagnesium-Verbindung\n");
8817
    printf ("Organomagnesium-Verbindung\n");
9812
  /*  if fg[fg_carboxylic_acid_deriv]          then writeln('Carbonsäure-Derivat'); */
8818
  /*  if fg[fg_carboxylic_acid_deriv]          then writeln('Carbonsäure-Derivat'); */
9813
  if (fg[fg_carboxylic_acid - 1])
8819
  if (fg[fg_carboxylic_acid - 1])
9814
    printf ("Carbons\344ure\n");
8820
    printf ("Carbons\344ure\n");
9815
/* p2c: checkmol.pas, line 7335: Note: character >= 128 encountered [281] */
8821
  /* p2c: checkmol.pas, line 7335: Note: character >= 128 encountered [281] */
9816
  if (fg[fg_carboxylic_acid_salt - 1])
8822
  if (fg[fg_carboxylic_acid_salt - 1])
9817
    printf ("Carbons\344uresalz\n");
8823
    printf ("Carbons\344uresalz\n");
9818
/* p2c: checkmol.pas, line 7336: Note: character >= 128 encountered [281] */
8824
  /* p2c: checkmol.pas, line 7336: Note: character >= 128 encountered [281] */
9819
  if (fg[fg_carboxylic_acid_ester - 1])
8825
  if (fg[fg_carboxylic_acid_ester - 1])
9820
    printf ("Carbons\344ureester\n");
8826
    printf ("Carbons\344ureester\n");
9821
/* p2c: checkmol.pas, line 7337: Note: character >= 128 encountered [281] */
8827
  /* p2c: checkmol.pas, line 7337: Note: character >= 128 encountered [281] */
9822
  if (fg[fg_lactone - 1])
8828
  if (fg[fg_lactone - 1])
9823
    printf ("Lacton\n");
8829
    printf ("Lacton\n");
9824
  /*  if fg[fg_carboxylic_acid_amide]          then writeln('Carbonsäureamid'); */
8830
  /*  if fg[fg_carboxylic_acid_amide]          then writeln('Carbonsäureamid'); */
9825
  if (fg[fg_carboxylic_acid_prim_amide - 1])
8831
  if (fg[fg_carboxylic_acid_prim_amide - 1])
9826
    printf ("prim\344res Carbons\344ureamid\n");
8832
    printf ("prim\344res Carbons\344ureamid\n");
9827
/* p2c: checkmol.pas, line 7340:
8833
  /* p2c: checkmol.pas, line 7340:
9828
 * Note: characters >= 128 encountered [281] */
8834
  * Note: characters >= 128 encountered [281] */
9829
  if (fg[fg_carboxylic_acid_sec_amide - 1])
8835
  if (fg[fg_carboxylic_acid_sec_amide - 1])
9830
    printf ("sekund\344res Carbons\344ureamid\n");
8836
    printf ("sekund\344res Carbons\344ureamid\n");
9831
/* p2c: checkmol.pas, line 7341:
8837
  /* p2c: checkmol.pas, line 7341:
9832
 * Note: characters >= 128 encountered [281] */
8838
  * Note: characters >= 128 encountered [281] */
9833
  if (fg[fg_carboxylic_acid_tert_amide - 1])
8839
  if (fg[fg_carboxylic_acid_tert_amide - 1])
9834
    printf ("terti\344res Carbons\344ureamid\n");
8840
    printf ("terti\344res Carbons\344ureamid\n");
9835
/* p2c: checkmol.pas, line 7342:
8841
  /* p2c: checkmol.pas, line 7342:
9836
 * Note: characters >= 128 encountered [281] */
8842
  * Note: characters >= 128 encountered [281] */
9837
  if (fg[fg_lactam - 1])
8843
  if (fg[fg_lactam - 1])
9838
    printf ("Lactam\n");
8844
    printf ("Lactam\n");
9839
  if (fg[fg_carboxylic_acid_hydrazide - 1])
8845
  if (fg[fg_carboxylic_acid_hydrazide - 1])
9840
    printf ("Carbons\344urehydrazid\n");
8846
    printf ("Carbons\344urehydrazid\n");
9841
/* p2c: checkmol.pas, line 7344: Note: character >= 128 encountered [281] */
8847
  /* p2c: checkmol.pas, line 7344: Note: character >= 128 encountered [281] */
9842
  if (fg[fg_carboxylic_acid_azide - 1])
8848
  if (fg[fg_carboxylic_acid_azide - 1])
9843
    printf ("Carbons\344ureazid\n");
8849
    printf ("Carbons\344ureazid\n");
9844
/* p2c: checkmol.pas, line 7345: Note: character >= 128 encountered [281] */
8850
  /* p2c: checkmol.pas, line 7345: Note: character >= 128 encountered [281] */
9845
  if (fg[fg_hydroxamic_acid - 1])
8851
  if (fg[fg_hydroxamic_acid - 1])
9846
    printf ("Hydroxams\344ure\n");
8852
    printf ("Hydroxams\344ure\n");
9847
/* p2c: checkmol.pas, line 7346: Note: character >= 128 encountered [281] */
8853
  /* p2c: checkmol.pas, line 7346: Note: character >= 128 encountered [281] */
9848
  if (fg[fg_carboxylic_acid_amidine - 1])
8854
  if (fg[fg_carboxylic_acid_amidine - 1])
9849
    printf ("Carbons\344ureamidin\n");
8855
    printf ("Carbons\344ureamidin\n");
9850
/* p2c: checkmol.pas, line 7347: Note: character >= 128 encountered [281] */
8856
  /* p2c: checkmol.pas, line 7347: Note: character >= 128 encountered [281] */
9851
  if (fg[fg_carboxylic_acid_amidrazone - 1])
8857
  if (fg[fg_carboxylic_acid_amidrazone - 1])
9852
    printf ("Carbons\344ureamidrazon\n");
8858
    printf ("Carbons\344ureamidrazon\n");
9853
/* p2c: checkmol.pas, line 7348: Note: character >= 128 encountered [281] */
8859
  /* p2c: checkmol.pas, line 7348: Note: character >= 128 encountered [281] */
9854
  if (fg[fg_nitrile - 1])
8860
  if (fg[fg_nitrile - 1])
9855
    printf ("Carbonitril\n");
8861
    printf ("Carbonitril\n");
9856
  /*  if fg[fg_acyl_halide]                    then writeln('Acylhalogenid'); */
8862
  /*  if fg[fg_acyl_halide]                    then writeln('Acylhalogenid'); */
9857
  if (fg[fg_acyl_fluoride - 1])
8863
  if (fg[fg_acyl_fluoride - 1])
9858
    printf ("Acylfluorid\n");
8864
    printf ("Acylfluorid\n");
Line 9869... Line 8875...
9869
  if (fg[fg_imidoyl_halide - 1])
8875
  if (fg[fg_imidoyl_halide - 1])
9870
    printf ("Imidoylhalogenid\n");
8876
    printf ("Imidoylhalogenid\n");
9871
  /*  if fg[fg_thiocarboxylic_acid_deriv]      then writeln('Thiocarbonsäure-Derivat'); */
8877
  /*  if fg[fg_thiocarboxylic_acid_deriv]      then writeln('Thiocarbonsäure-Derivat'); */
9872
  if (fg[fg_thiocarboxylic_acid - 1])
8878
  if (fg[fg_thiocarboxylic_acid - 1])
9873
    printf ("Thiocarbons\344ure\n");
8879
    printf ("Thiocarbons\344ure\n");
9874
/* p2c: checkmol.pas, line 7359: Note: character >= 128 encountered [281] */
8880
  /* p2c: checkmol.pas, line 7359: Note: character >= 128 encountered [281] */
9875
  if (fg[fg_thiocarboxylic_acid_ester - 1])
8881
  if (fg[fg_thiocarboxylic_acid_ester - 1])
9876
    printf ("Thiocarbons\344ureester\n");
8882
    printf ("Thiocarbons\344ureester\n");
9877
/* p2c: checkmol.pas, line 7360: Note: character >= 128 encountered [281] */
8883
  /* p2c: checkmol.pas, line 7360: Note: character >= 128 encountered [281] */
9878
  if (fg[fg_thiolactone - 1])
8884
  if (fg[fg_thiolactone - 1])
9879
    printf ("Thiolacton\n");
8885
    printf ("Thiolacton\n");
9880
  if (fg[fg_thiocarboxylic_acid_amide - 1])
8886
  if (fg[fg_thiocarboxylic_acid_amide - 1])
9881
    printf ("Thiocarbons\344ureamid\n");
8887
    printf ("Thiocarbons\344ureamid\n");
9882
/* p2c: checkmol.pas, line 7362: Note: character >= 128 encountered [281] */
8888
  /* p2c: checkmol.pas, line 7362: Note: character >= 128 encountered [281] */
9883
  if (fg[fg_thiolactam - 1])
8889
  if (fg[fg_thiolactam - 1])
9884
    printf ("Thiolactam\n");
8890
    printf ("Thiolactam\n");
9885
  if (fg[fg_imido_thioester - 1])
8891
  if (fg[fg_imido_thioester - 1])
9886
    printf ("Imidothioester\n");
8892
    printf ("Imidothioester\n");
9887
  if (fg[fg_oxohetarene - 1])
8893
  if (fg[fg_oxohetarene - 1])
Line 9890... Line 8896...
9890
    printf ("Thioxo(het)aren\n");
8896
    printf ("Thioxo(het)aren\n");
9891
  if (fg[fg_iminohetarene - 1])
8897
  if (fg[fg_iminohetarene - 1])
9892
    printf ("Imino(het)aren\n");
8898
    printf ("Imino(het)aren\n");
9893
  if (fg[fg_orthocarboxylic_acid_deriv - 1])
8899
  if (fg[fg_orthocarboxylic_acid_deriv - 1])
9894
    printf ("Orthocarbons\344ure-Derivat\n");
8900
    printf ("Orthocarbons\344ure-Derivat\n");
9895
/* p2c: checkmol.pas, line 7368: Note: character >= 128 encountered [281] */
8901
  /* p2c: checkmol.pas, line 7368: Note: character >= 128 encountered [281] */
9896
  if (fg[fg_carboxylic_acid_orthoester - 1])
8902
  if (fg[fg_carboxylic_acid_orthoester - 1])
9897
    printf ("Orthoester\n");
8903
    printf ("Orthoester\n");
9898
  if (fg[fg_carboxylic_acid_amide_acetal - 1])
8904
  if (fg[fg_carboxylic_acid_amide_acetal - 1])
9899
    printf ("Amidacetal\n");
8905
    printf ("Amidacetal\n");
9900
  if (fg[fg_carboxylic_acid_anhydride - 1])
8906
  if (fg[fg_carboxylic_acid_anhydride - 1])
9901
    printf ("Carbons\344ureanhydrid\n");
8907
    printf ("Carbons\344ureanhydrid\n");
9902
/* p2c: checkmol.pas, line 7371: Note: character >= 128 encountered [281] */
8908
  /* p2c: checkmol.pas, line 7371: Note: character >= 128 encountered [281] */
9903
  /*  if fg[fg_carboxylic_acid_imide]          then writeln('Carbonsäureimid'); */
8909
  /*  if fg[fg_carboxylic_acid_imide]          then writeln('Carbonsäureimid'); */
9904
  if (fg[fg_carboxylic_acid_unsubst_imide - 1])
8910
  if (fg[fg_carboxylic_acid_unsubst_imide - 1])
9905
    printf ("Carbons\344ureimid, N-unsubstituiert\n");
8911
    printf ("Carbons\344ureimid, N-unsubstituiert\n");
9906
/* p2c: checkmol.pas, line 7373: Note: character >= 128 encountered [281] */
8912
  /* p2c: checkmol.pas, line 7373: Note: character >= 128 encountered [281] */
9907
  if (fg[fg_carboxylic_acid_subst_imide - 1])
8913
  if (fg[fg_carboxylic_acid_subst_imide - 1])
9908
    printf ("Carbons\344ureimid, N-substituiert\n");
8914
    printf ("Carbons\344ureimid, N-substituiert\n");
9909
/* p2c: checkmol.pas, line 7374: Note: character >= 128 encountered [281] */
8915
  /* p2c: checkmol.pas, line 7374: Note: character >= 128 encountered [281] */
9910
  if (fg[fg_co2_deriv - 1])
8916
  if (fg[fg_co2_deriv - 1])
9911
    printf ("CO2-Derivat (allgemein)\n");
8917
    printf ("CO2-Derivat (allgemein)\n");
9912
  if (fg[fg_carbonic_acid_deriv - 1] &&
-
 
9913
      !(fg[fg_carbonic_acid_monoester - 1]
8918
  if (fg[fg_carbonic_acid_deriv - 1] && !(fg[fg_carbonic_acid_monoester - 1]
9914
        || fg[fg_carbonic_acid_diester - 1]
-
 
9915
        || fg[fg_carbonic_acid_ester_halide - 1]))
8919
            || fg[fg_carbonic_acid_diester - 1] || fg[fg_carbonic_acid_ester_halide - 1]))
9916
    /* changed in v0.3c */
8920
    /* changed in v0.3c */
9917
    printf ("Kohlens\344ure-Derivat\n");
8921
    printf ("Kohlens\344ure-Derivat\n");
9918
/* p2c: checkmol.pas, line 7379: Note: character >= 128 encountered [281] */
8922
  /* p2c: checkmol.pas, line 7379: Note: character >= 128 encountered [281] */
9919
  if (fg[fg_carbonic_acid_monoester - 1])
8923
  if (fg[fg_carbonic_acid_monoester - 1])
9920
    printf ("Kohlens\344uremonoester\n");
8924
    printf ("Kohlens\344uremonoester\n");
9921
/* p2c: checkmol.pas, line 7380: Note: character >= 128 encountered [281] */
8925
  /* p2c: checkmol.pas, line 7380: Note: character >= 128 encountered [281] */
9922
  if (fg[fg_carbonic_acid_diester - 1])
8926
  if (fg[fg_carbonic_acid_diester - 1])
9923
    printf ("Kohlens\344urediester\n");
8927
    printf ("Kohlens\344urediester\n");
9924
/* p2c: checkmol.pas, line 7381: Note: character >= 128 encountered [281] */
8928
  /* p2c: checkmol.pas, line 7381: Note: character >= 128 encountered [281] */
9925
  if (fg[fg_carbonic_acid_ester_halide - 1])
8929
  if (fg[fg_carbonic_acid_ester_halide - 1])
9926
    printf ("Kohlens\344ureesterhalogenid (Alkyl/Aryl-Halogenformiat)\n");
8930
    printf ("Kohlens\344ureesterhalogenid (Alkyl/Aryl-Halogenformiat)\n");
9927
/* p2c: checkmol.pas, line 7382: Note: character >= 128 encountered [281] */
8931
  /* p2c: checkmol.pas, line 7382: Note: character >= 128 encountered [281] */
9928
  if (fg[fg_thiocarbonic_acid_deriv - 1])
8932
  if (fg[fg_thiocarbonic_acid_deriv - 1])
9929
    printf ("Thiokohlens\344ure-Derivat\n");
8933
    printf ("Thiokohlens\344ure-Derivat\n");
9930
/* p2c: checkmol.pas, line 7383: Note: character >= 128 encountered [281] */
8934
  /* p2c: checkmol.pas, line 7383: Note: character >= 128 encountered [281] */
9931
  if (fg[fg_thiocarbonic_acid_monoester - 1])
8935
  if (fg[fg_thiocarbonic_acid_monoester - 1])
9932
    printf ("Thiokohlens\344uremonoester\n");
8936
    printf ("Thiokohlens\344uremonoester\n");
9933
/* p2c: checkmol.pas, line 7384: Note: character >= 128 encountered [281] */
8937
  /* p2c: checkmol.pas, line 7384: Note: character >= 128 encountered [281] */
9934
  if (fg[fg_thiocarbonic_acid_diester - 1])
8938
  if (fg[fg_thiocarbonic_acid_diester - 1])
9935
    printf ("Thiokohlens\344urediester\n");
8939
    printf ("Thiokohlens\344urediester\n");
9936
/* p2c: checkmol.pas, line 7385: Note: character >= 128 encountered [281] */
8940
  /* p2c: checkmol.pas, line 7385: Note: character >= 128 encountered [281] */
9937
  if (fg[fg_thiocarbonic_acid_ester_halide - 1])
8941
  if (fg[fg_thiocarbonic_acid_ester_halide - 1])
9938
    printf
-
 
9939
      ("Thiokohlens\344ureesterhalogenid (Alkyl/Aryl-Halogenthioformiat)\n");
8942
    printf ("Thiokohlens\344ureesterhalogenid (Alkyl/Aryl-Halogenthioformiat)\n");
9940
/* p2c: checkmol.pas, line 7386: Note: character >= 128 encountered [281] */
8943
  /* p2c: checkmol.pas, line 7386: Note: character >= 128 encountered [281] */
9941
  if (fg[fg_carbamic_acid_deriv - 1] &&
8944
  if (fg[fg_carbamic_acid_deriv - 1] &&
9942
      !(fg[fg_carbamic_acid - 1] || fg[fg_carbamic_acid_ester - 1] ||
8945
      !(fg[fg_carbamic_acid - 1] || fg[fg_carbamic_acid_ester - 1] ||
9943
        fg[fg_carbamic_acid_halide - 1]))
8946
            fg[fg_carbamic_acid_halide - 1]))
9944
    /* changed in v0.3c */
8947
    /* changed in v0.3c */
9945
    printf ("Carbamins\344ure-Derivat\n");
8948
    printf ("Carbamins\344ure-Derivat\n");
9946
/* p2c: checkmol.pas, line 7390: Note: character >= 128 encountered [281] */
8949
  /* p2c: checkmol.pas, line 7390: Note: character >= 128 encountered [281] */
9947
  if (fg[fg_carbamic_acid - 1])
8950
  if (fg[fg_carbamic_acid - 1])
9948
    printf ("Carbamins\344ure\n");
8951
    printf ("Carbamins\344ure\n");
9949
/* p2c: checkmol.pas, line 7391: Note: character >= 128 encountered [281] */
8952
  /* p2c: checkmol.pas, line 7391: Note: character >= 128 encountered [281] */
9950
  if (fg[fg_carbamic_acid_ester - 1])
8953
  if (fg[fg_carbamic_acid_ester - 1])
9951
    printf ("Carbamins\344ureester (Urethan)\n");
8954
    printf ("Carbamins\344ureester (Urethan)\n");
9952
/* p2c: checkmol.pas, line 7392: Note: character >= 128 encountered [281] */
8955
  /* p2c: checkmol.pas, line 7392: Note: character >= 128 encountered [281] */
9953
  if (fg[fg_carbamic_acid_halide - 1])
8956
  if (fg[fg_carbamic_acid_halide - 1])
9954
    printf ("Carbamins\344urehalogenid (Halogenformamid)\n");
8957
    printf ("Carbamins\344urehalogenid (Halogenformamid)\n");
9955
/* p2c: checkmol.pas, line 7393: Note: character >= 128 encountered [281] */
8958
  /* p2c: checkmol.pas, line 7393: Note: character >= 128 encountered [281] */
9956
  if (fg[fg_thiocarbamic_acid_deriv - 1] &&
8959
  if (fg[fg_thiocarbamic_acid_deriv - 1] &&
9957
      !(fg[fg_thiocarbamic_acid - 1] || fg[fg_thiocarbamic_acid_ester - 1]
8960
      !(fg[fg_thiocarbamic_acid - 1] || fg[fg_thiocarbamic_acid_ester - 1]
9958
        || fg[fg_thiocarbamic_acid_halide - 1]))
8961
            || fg[fg_thiocarbamic_acid_halide - 1]))
9959
    /* changed in v0.3c */
8962
    /* changed in v0.3c */
9960
    printf ("Thiocarbamins\344ure-Derivat\n");
8963
    printf ("Thiocarbamins\344ure-Derivat\n");
9961
/* p2c: checkmol.pas, line 7397: Note: character >= 128 encountered [281] */
8964
  /* p2c: checkmol.pas, line 7397: Note: character >= 128 encountered [281] */
9962
  if (fg[fg_thiocarbamic_acid - 1])
8965
  if (fg[fg_thiocarbamic_acid - 1])
9963
    printf ("Thiocarbamins\344ure\n");
8966
    printf ("Thiocarbamins\344ure\n");
9964
/* p2c: checkmol.pas, line 7398: Note: character >= 128 encountered [281] */
8967
  /* p2c: checkmol.pas, line 7398: Note: character >= 128 encountered [281] */
9965
  if (fg[fg_thiocarbamic_acid_ester - 1])
8968
  if (fg[fg_thiocarbamic_acid_ester - 1])
9966
    printf ("Thiocarbamins\344ureester\n");
8969
    printf ("Thiocarbamins\344ureester\n");
9967
/* p2c: checkmol.pas, line 7399: Note: character >= 128 encountered [281] */
8970
  /* p2c: checkmol.pas, line 7399: Note: character >= 128 encountered [281] */
9968
  if (fg[fg_thiocarbamic_acid_halide - 1])
8971
  if (fg[fg_thiocarbamic_acid_halide - 1])
9969
    printf ("Thiocarbamins\344urehalogenid (Halogenthioformamid)\n");
8972
    printf ("Thiocarbamins\344urehalogenid (Halogenthioformamid)\n");
9970
/* p2c: checkmol.pas, line 7400: Note: character >= 128 encountered [281] */
8973
  /* p2c: checkmol.pas, line 7400: Note: character >= 128 encountered [281] */
9971
  if (fg[fg_urea - 1])
8974
  if (fg[fg_urea - 1])
9972
    printf ("Harnstoff\n");
8975
    printf ("Harnstoff\n");
9973
  if (fg[fg_isourea - 1])
8976
  if (fg[fg_isourea - 1])
9974
    printf ("Isoharnstoff\n");
8977
    printf ("Isoharnstoff\n");
9975
  if (fg[fg_thiourea - 1])
8978
  if (fg[fg_thiourea - 1])
Line 10009... Line 9012...
10009
  if (fg[fg_nitrate - 1])
9012
  if (fg[fg_nitrate - 1])
10010
    printf ("Nitrat\n");
9013
    printf ("Nitrat\n");
10011
  /*  if fg[fg_sulfuric_acid_deriv]            then writeln('Schwefelsäure-Derivat'); */
9014
  /*  if fg[fg_sulfuric_acid_deriv]            then writeln('Schwefelsäure-Derivat'); */
10012
  if (fg[fg_sulfuric_acid - 1])
9015
  if (fg[fg_sulfuric_acid - 1])
10013
    printf ("Schwefels\344ure\n");
9016
    printf ("Schwefels\344ure\n");
10014
/* p2c: checkmol.pas, line 7422: Note: character >= 128 encountered [281] */
9017
  /* p2c: checkmol.pas, line 7422: Note: character >= 128 encountered [281] */
10015
  if (fg[fg_sulfuric_acid_monoester - 1])
9018
  if (fg[fg_sulfuric_acid_monoester - 1])
10016
    printf ("Schwefels\344uremonoester\n");
9019
    printf ("Schwefels\344uremonoester\n");
10017
/* p2c: checkmol.pas, line 7423: Note: character >= 128 encountered [281] */
9020
  /* p2c: checkmol.pas, line 7423: Note: character >= 128 encountered [281] */
10018
  if (fg[fg_sulfuric_acid_diester - 1])
9021
  if (fg[fg_sulfuric_acid_diester - 1])
10019
    printf ("Schwefels\344urediester\n");
9022
    printf ("Schwefels\344urediester\n");
10020
/* p2c: checkmol.pas, line 7424: Note: character >= 128 encountered [281] */
9023
  /* p2c: checkmol.pas, line 7424: Note: character >= 128 encountered [281] */
10021
  if (fg[fg_sulfuric_acid_amide_ester - 1])
9024
  if (fg[fg_sulfuric_acid_amide_ester - 1])
10022
    printf ("Schwefels\344ureamidester\n");
9025
    printf ("Schwefels\344ureamidester\n");
10023
/* p2c: checkmol.pas, line 7425: Note: character >= 128 encountered [281] */
9026
  /* p2c: checkmol.pas, line 7425: Note: character >= 128 encountered [281] */
10024
  if (fg[fg_sulfuric_acid_amide - 1])
9027
  if (fg[fg_sulfuric_acid_amide - 1])
10025
    printf ("Schwefels\344ureamid\n");
9028
    printf ("Schwefels\344ureamid\n");
10026
/* p2c: checkmol.pas, line 7426: Note: character >= 128 encountered [281] */
9029
  /* p2c: checkmol.pas, line 7426: Note: character >= 128 encountered [281] */
10027
  if (fg[fg_sulfuric_acid_diamide - 1])
9030
  if (fg[fg_sulfuric_acid_diamide - 1])
10028
    printf ("Schwefels\344urediamid\n");
9031
    printf ("Schwefels\344urediamid\n");
10029
/* p2c: checkmol.pas, line 7427: Note: character >= 128 encountered [281] */
9032
  /* p2c: checkmol.pas, line 7427: Note: character >= 128 encountered [281] */
10030
  if (fg[fg_sulfuryl_halide - 1])
9033
  if (fg[fg_sulfuryl_halide - 1])
10031
    printf ("Sulfurylhalogenid\n");
9034
    printf ("Sulfurylhalogenid\n");
10032
  /*  if fg[fg_sulfonic_acid_deriv]            then writeln('Sulfonsäure-Derivat '); */
9035
  /*  if fg[fg_sulfonic_acid_deriv]            then writeln('Sulfonsäure-Derivat '); */
10033
  if (fg[fg_sulfonic_acid - 1])
9036
  if (fg[fg_sulfonic_acid - 1])
10034
    printf ("Sulfons\344ure\n");
9037
    printf ("Sulfons\344ure\n");
10035
/* p2c: checkmol.pas, line 7430: Note: character >= 128 encountered [281] */
9038
  /* p2c: checkmol.pas, line 7430: Note: character >= 128 encountered [281] */
10036
  if (fg[fg_sulfonic_acid_ester - 1])
9039
  if (fg[fg_sulfonic_acid_ester - 1])
10037
    printf ("Sulfons\344ureester\n");
9040
    printf ("Sulfons\344ureester\n");
10038
/* p2c: checkmol.pas, line 7431: Note: character >= 128 encountered [281] */
9041
  /* p2c: checkmol.pas, line 7431: Note: character >= 128 encountered [281] */
10039
  if (fg[fg_sulfonamide - 1])
9042
  if (fg[fg_sulfonamide - 1])
10040
    printf ("Sulfonamid\n");
9043
    printf ("Sulfonamid\n");
10041
  if (fg[fg_sulfonyl_halide - 1])
9044
  if (fg[fg_sulfonyl_halide - 1])
10042
    printf ("Sulfonylhalogenid\n");
9045
    printf ("Sulfonylhalogenid\n");
10043
  if (fg[fg_sulfone - 1])
9046
  if (fg[fg_sulfone - 1])
Line 10045... Line 9048...
10045
  if (fg[fg_sulfoxide - 1])
9048
  if (fg[fg_sulfoxide - 1])
10046
    printf ("Sulfoxid\n");
9049
    printf ("Sulfoxid\n");
10047
  /*  if fg[fg_sulfinic_acid_deriv]            then writeln('Sulfinsäure-Derivat'); */
9050
  /*  if fg[fg_sulfinic_acid_deriv]            then writeln('Sulfinsäure-Derivat'); */
10048
  if (fg[fg_sulfinic_acid - 1])
9051
  if (fg[fg_sulfinic_acid - 1])
10049
    printf ("Sulfins\344ure\n");
9052
    printf ("Sulfins\344ure\n");
10050
/* p2c: checkmol.pas, line 7437: Note: character >= 128 encountered [281] */
9053
  /* p2c: checkmol.pas, line 7437: Note: character >= 128 encountered [281] */
10051
  if (fg[fg_sulfinic_acid_ester - 1])
9054
  if (fg[fg_sulfinic_acid_ester - 1])
10052
    printf ("Sulfins\344ureester\n");
9055
    printf ("Sulfins\344ureester\n");
10053
/* p2c: checkmol.pas, line 7438: Note: character >= 128 encountered [281] */
9056
  /* p2c: checkmol.pas, line 7438: Note: character >= 128 encountered [281] */
10054
  if (fg[fg_sulfinic_acid_halide - 1])
9057
  if (fg[fg_sulfinic_acid_halide - 1])
10055
    printf ("Sulfins\344urehalogenid\n");
9058
    printf ("Sulfins\344urehalogenid\n");
10056
/* p2c: checkmol.pas, line 7439: Note: character >= 128 encountered [281] */
9059
  /* p2c: checkmol.pas, line 7439: Note: character >= 128 encountered [281] */
10057
  if (fg[fg_sulfinic_acid_amide - 1])
9060
  if (fg[fg_sulfinic_acid_amide - 1])
10058
    printf ("Sulfins\344ureamid\n");
9061
    printf ("Sulfins\344ureamid\n");
10059
/* p2c: checkmol.pas, line 7440: Note: character >= 128 encountered [281] */
9062
  /* p2c: checkmol.pas, line 7440: Note: character >= 128 encountered [281] */
10060
  /*  if fg[fg_sulfenic_acid_deriv]            then writeln('Sulfensäure-Derivat'); */
9063
  /*  if fg[fg_sulfenic_acid_deriv]            then writeln('Sulfensäure-Derivat'); */
10061
  if (fg[fg_sulfenic_acid - 1])
9064
  if (fg[fg_sulfenic_acid - 1])
10062
    printf ("Sulfens\344ure\n");
9065
    printf ("Sulfens\344ure\n");
10063
/* p2c: checkmol.pas, line 7442: Note: character >= 128 encountered [281] */
9066
  /* p2c: checkmol.pas, line 7442: Note: character >= 128 encountered [281] */
10064
  if (fg[fg_sulfenic_acid_ester - 1])
9067
  if (fg[fg_sulfenic_acid_ester - 1])
10065
    printf ("Sulfens\344ureester\n");
9068
    printf ("Sulfens\344ureester\n");
10066
/* p2c: checkmol.pas, line 7443: Note: character >= 128 encountered [281] */
9069
  /* p2c: checkmol.pas, line 7443: Note: character >= 128 encountered [281] */
10067
  if (fg[fg_sulfenic_acid_halide - 1])
9070
  if (fg[fg_sulfenic_acid_halide - 1])
10068
    printf ("Sulfens\344urehalogenid\n");
9071
    printf ("Sulfens\344urehalogenid\n");
10069
/* p2c: checkmol.pas, line 7444: Note: character >= 128 encountered [281] */
9072
  /* p2c: checkmol.pas, line 7444: Note: character >= 128 encountered [281] */
10070
  if (fg[fg_sulfenic_acid_amide - 1])
9073
  if (fg[fg_sulfenic_acid_amide - 1])
10071
    printf ("Sulfens\344ureamid\n");
9074
    printf ("Sulfens\344ureamid\n");
10072
/* p2c: checkmol.pas, line 7445: Note: character >= 128 encountered [281] */
9075
  /* p2c: checkmol.pas, line 7445: Note: character >= 128 encountered [281] */
10073
  if (fg[fg_thiol - 1])
9076
  if (fg[fg_thiol - 1])
10074
    printf ("Thiol (Sulfanyl-Verbindung, Mercaptan)\n");
9077
    printf ("Thiol (Sulfanyl-Verbindung, Mercaptan)\n");
10075
  if (fg[fg_alkylthiol - 1])
9078
  if (fg[fg_alkylthiol - 1])
10076
    printf ("Alkylthiol\n");
9079
    printf ("Alkylthiol\n");
10077
  if (fg[fg_arylthiol - 1])
9080
  if (fg[fg_arylthiol - 1])
10078
    printf ("Arylthiol\n");
9081
    printf ("Arylthiol\n");
10079
  /*  if fg[fg_phosphoric_acid_deriv]          then writeln('Phosphorsäure-Derivat'); */
9082
  /*  if fg[fg_phosphoric_acid_deriv]          then writeln('Phosphorsäure-Derivat'); */
10080
  if (fg[fg_phosphoric_acid - 1])
9083
  if (fg[fg_phosphoric_acid - 1])
10081
    printf ("Phosphors\344ure\n");
9084
    printf ("Phosphors\344ure\n");
10082
/* p2c: checkmol.pas, line 7450: Note: character >= 128 encountered [281] */
9085
  /* p2c: checkmol.pas, line 7450: Note: character >= 128 encountered [281] */
10083
  if (fg[fg_phosphoric_acid_ester - 1])
9086
  if (fg[fg_phosphoric_acid_ester - 1])
10084
    printf ("Phosphors\344ureester\n");
9087
    printf ("Phosphors\344ureester\n");
10085
/* p2c: checkmol.pas, line 7451: Note: character >= 128 encountered [281] */
9088
  /* p2c: checkmol.pas, line 7451: Note: character >= 128 encountered [281] */
10086
  if (fg[fg_phosphoric_acid_halide - 1])
9089
  if (fg[fg_phosphoric_acid_halide - 1])
10087
    printf ("Phosphors\344urehalogenid\n");
9090
    printf ("Phosphors\344urehalogenid\n");
10088
/* p2c: checkmol.pas, line 7452: Note: character >= 128 encountered [281] */
9091
  /* p2c: checkmol.pas, line 7452: Note: character >= 128 encountered [281] */
10089
  if (fg[fg_phosphoric_acid_amide - 1])
9092
  if (fg[fg_phosphoric_acid_amide - 1])
10090
    printf ("Phosphors\344ureamid\n");
9093
    printf ("Phosphors\344ureamid\n");
10091
/* p2c: checkmol.pas, line 7453: Note: character >= 128 encountered [281] */
9094
  /* p2c: checkmol.pas, line 7453: Note: character >= 128 encountered [281] */
10092
  /*  if fg[fg_thiophosphoric_acid_deriv]      then writeln('Thiophosphorsäure-Derivat'); */
9095
  /*  if fg[fg_thiophosphoric_acid_deriv]      then writeln('Thiophosphorsäure-Derivat'); */
10093
  if (fg[fg_thiophosphoric_acid - 1])
9096
  if (fg[fg_thiophosphoric_acid - 1])
10094
    printf ("Thiophosphors\344ure\n");
9097
    printf ("Thiophosphors\344ure\n");
10095
/* p2c: checkmol.pas, line 7455: Note: character >= 128 encountered [281] */
9098
  /* p2c: checkmol.pas, line 7455: Note: character >= 128 encountered [281] */
10096
  if (fg[fg_thiophosphoric_acid_ester - 1])
9099
  if (fg[fg_thiophosphoric_acid_ester - 1])
10097
    printf ("Thiophosphors\344ureester\n");
9100
    printf ("Thiophosphors\344ureester\n");
10098
/* p2c: checkmol.pas, line 7456: Note: character >= 128 encountered [281] */
9101
  /* p2c: checkmol.pas, line 7456: Note: character >= 128 encountered [281] */
10099
  if (fg[fg_thiophosphoric_acid_halide - 1])
9102
  if (fg[fg_thiophosphoric_acid_halide - 1])
10100
    printf ("Thiophosphors\344urehalogenid\n");
9103
    printf ("Thiophosphors\344urehalogenid\n");
10101
/* p2c: checkmol.pas, line 7457: Note: character >= 128 encountered [281] */
9104
  /* p2c: checkmol.pas, line 7457: Note: character >= 128 encountered [281] */
10102
  if (fg[fg_thiophosphoric_acid_amide - 1])
9105
  if (fg[fg_thiophosphoric_acid_amide - 1])
10103
    printf ("Thiophosphors\344ureamid\n");
9106
    printf ("Thiophosphors\344ureamid\n");
10104
/* p2c: checkmol.pas, line 7458: Note: character >= 128 encountered [281] */
9107
  /* p2c: checkmol.pas, line 7458: Note: character >= 128 encountered [281] */
10105
  if (fg[fg_phosphonic_acid_deriv - 1])
9108
  if (fg[fg_phosphonic_acid_deriv - 1])
10106
    printf ("Phosphons\344ure-Derivat \n");
9109
    printf ("Phosphons\344ure-Derivat \n");
10107
/* p2c: checkmol.pas, line 7459: Note: character >= 128 encountered [281] */
9110
  /* p2c: checkmol.pas, line 7459: Note: character >= 128 encountered [281] */
10108
  if (fg[fg_phosphonic_acid - 1])
9111
  if (fg[fg_phosphonic_acid - 1])
10109
    printf ("Phosphons\344ure\n");
9112
    printf ("Phosphons\344ure\n");
10110
/* p2c: checkmol.pas, line 7460: Note: character >= 128 encountered [281] */
9113
  /* p2c: checkmol.pas, line 7460: Note: character >= 128 encountered [281] */
10111
  if (fg[fg_phosphonic_acid_ester - 1])
9114
  if (fg[fg_phosphonic_acid_ester - 1])
10112
    printf ("Phosphons\344ureester\n");
9115
    printf ("Phosphons\344ureester\n");
10113
/* p2c: checkmol.pas, line 7461: Note: character >= 128 encountered [281] */
9116
  /* p2c: checkmol.pas, line 7461: Note: character >= 128 encountered [281] */
10114
  if (fg[fg_phosphine - 1])
9117
  if (fg[fg_phosphine - 1])
10115
    printf ("Phosphin\n");
9118
    printf ("Phosphin\n");
10116
  if (fg[fg_phosphinoxide - 1])
9119
  if (fg[fg_phosphinoxide - 1])
10117
    printf ("Phosphinoxid\n");
9120
    printf ("Phosphinoxid\n");
10118
  if (fg[fg_boronic_acid_deriv - 1])
9121
  if (fg[fg_boronic_acid_deriv - 1])
10119
    printf ("Borons\344ure-Derivat\n");
9122
    printf ("Borons\344ure-Derivat\n");
10120
/* p2c: checkmol.pas, line 7464: Note: character >= 128 encountered [281] */
9123
  /* p2c: checkmol.pas, line 7464: Note: character >= 128 encountered [281] */
10121
  if (fg[fg_boronic_acid - 1])
9124
  if (fg[fg_boronic_acid - 1])
10122
    printf ("Borons\344ure\n");
9125
    printf ("Borons\344ure\n");
10123
/* p2c: checkmol.pas, line 7465: Note: character >= 128 encountered [281] */
9126
  /* p2c: checkmol.pas, line 7465: Note: character >= 128 encountered [281] */
10124
  if (fg[fg_boronic_acid_ester - 1])
9127
  if (fg[fg_boronic_acid_ester - 1])
10125
    printf ("Borons\344ureester\n");
9128
    printf ("Borons\344ureester\n");
10126
/* p2c: checkmol.pas, line 7466: Note: character >= 128 encountered [281] */
9129
  /* p2c: checkmol.pas, line 7466: Note: character >= 128 encountered [281] */
10127
  if (fg[fg_alkene - 1])
9130
  if (fg[fg_alkene - 1])
10128
    printf ("Alken\n");
9131
    printf ("Alken\n");
10129
  if (fg[fg_alkyne - 1])
9132
  if (fg[fg_alkyne - 1])
10130
    printf ("Alkin\n");
9133
    printf ("Alkin\n");
10131
  if (fg[fg_aromatic - 1])
9134
  if (fg[fg_aromatic - 1])
10132
    printf ("aromatische Verbindung\n");
9135
    printf ("aromatische Verbindung\n");
10133
  if (fg[fg_heterocycle - 1])
9136
  if (fg[fg_heterocycle - 1])
10134
    printf ("heterocyclische Verbindung\n");
9137
    printf ("heterocyclische Verbindung\n");
10135
  if (fg[fg_alpha_aminoacid - 1])
9138
  if (fg[fg_alpha_aminoacid - 1])
10136
    printf ("alpha-Aminos\344ure\n");
9139
    printf ("alpha-Aminos\344ure\n");
10137
/* p2c: checkmol.pas, line 7471: Note: character >= 128 encountered [281] */
9140
  /* p2c: checkmol.pas, line 7471: Note: character >= 128 encountered [281] */
10138
  if (fg[fg_alpha_hydroxyacid - 1])
9141
  if (fg[fg_alpha_hydroxyacid - 1])
10139
    printf ("alpha-Hydroxys\344ure\n");
9142
    printf ("alpha-Hydroxys\344ure\n");
10140
/* p2c: checkmol.pas, line 7472: Note: character >= 128 encountered [281] */
9143
  /* p2c: checkmol.pas, line 7472: Note: character >= 128 encountered [281] */
10141
}
9144
}
10142
 
-
 
10143
 
9145
 
10144
#define sc              ';'
9146
#define sc              ';'
10145
 
9147
 
10146
 
-
 
10147
static void
-
 
10148
write_fg_code ()
9148
static void write_fg_code ()
10149
{
9149
{
10150
  if (fg[fg_cation - 1])
9150
  if (fg[fg_cation - 1])
10151
    printf ("000000T2%c", sc);
9151
    printf ("000000T2%c", sc);
10152
  if (fg[fg_anion - 1])
9152
  if (fg[fg_anion - 1])
10153
    printf ("000000T1%c", sc);
9153
    printf ("000000T1%c", sc);
Line 10261... Line 9261...
10261
    printf ("N1C400T2%c", sc);
9261
    printf ("N1C400T2%c", sc);
10262
  if (fg[fg_n_oxide - 1])
9262
  if (fg[fg_n_oxide - 1])
10263
    printf ("N0O10000%c", sc);
9263
    printf ("N0O10000%c", sc);
10264
  /*  if fg[fg_halogen_deriv]                  then write('XX000000',sc); */
9264
  /*  if fg[fg_halogen_deriv]                  then write('XX000000',sc); */
10265
  /* new in v0.2f */
9265
  /* new in v0.2f */
10266
  if (fg[fg_halogen_deriv - 1])
9266
  if (fg[fg_halogen_deriv - 1]) {
10267
    {
-
 
10268
      if (!fg[fg_alkyl_halide - 1] && !fg[fg_aryl_halide - 1] &&
9267
      if (!fg[fg_alkyl_halide - 1] && !fg[fg_aryl_halide - 1] && !fg[fg_acyl_halide - 1])
10269
          !fg[fg_acyl_halide - 1])
-
 
10270
        printf ("XX000000%c", sc);
9268
              printf ("XX000000%c", sc);
10271
    }
9269
  }
10272
  /*  if fg[fg_alkyl_halide]                   then write('XX00C000',sc); */
9270
  /*  if fg[fg_alkyl_halide]                   then write('XX00C000',sc); */
10273
  if (fg[fg_alkyl_fluoride - 1])
9271
  if (fg[fg_alkyl_fluoride - 1])
10274
    printf ("XF00C000%c", sc);
9272
    printf ("XF00C000%c", sc);
10275
  if (fg[fg_alkyl_chloride - 1])
9273
  if (fg[fg_alkyl_chloride - 1])
10276
    printf ("XC00C000%c", sc);
9274
    printf ("XC00C000%c", sc);
Line 10549... Line 9547...
10549
    printf ("C3O2HO1H%c", sc);
9547
    printf ("C3O2HO1H%c", sc);
10550
}
9548
}
10551
 
9549
 
10552
#undef sc
9550
#undef sc
10553
 
9551
 
10554
 
-
 
10555
static void
-
 
10556
write_fg_binary ()
9552
static void write_fg_binary ()
10557
{
9553
{
10558
  int i, n;
9554
  int i, n;
10559
  char o;
9555
  char o;
10560
 
9556
 
10561
  for (i = 1; i <= max_fg / 8; i++)
9557
  for (i = 1; i <= max_fg / 8; i++) {
10562
    {
-
 
10563
      n = 0;
9558
    n = 0;
10564
      if (fg[i * 8 - 1])
9559
    if (fg[i * 8 - 1])
10565
        n++;
9560
            n++;
10566
      if (fg[i * 8 - 2])
9561
    if (fg[i * 8 - 2])
10567
        n += 2;
9562
            n += 2;
10568
      if (fg[i * 8 - 3])
9563
    if (fg[i * 8 - 3])
10569
        n += 4;
9564
            n += 4;
10570
      if (fg[i * 8 - 4])
9565
    if (fg[i * 8 - 4])
10571
        n += 8;
9566
            n += 8;
10572
      if (fg[i * 8 - 5])
9567
    if (fg[i * 8 - 5])
10573
        n += 16;
9568
            n += 16;
10574
      if (fg[i * 8 - 6])
9569
    if (fg[i * 8 - 6])
10575
        n += 32;
9570
            n += 32;
10576
      if (fg[i * 8 - 7])
9571
    if (fg[i * 8 - 7])
10577
        n += 64;
9572
            n += 64;
10578
      if (fg[i * 8 - 8])
9573
    if (fg[i * 8 - 8])
10579
        n += 128;
9574
            n += 128;
10580
      o = (char) n;
9575
    o = (char) n;
10581
      putchar (o);
9576
    putchar (o);
10582
    }
9577
  }
10583
}
9578
}
10584
 
-
 
10585
 
9579
 
10586
static void
-
 
10587
write_fg_bitstring ()
9580
static void write_fg_bitstring ()
10588
{
9581
{
10589
  int i;
9582
  int i;
10590
 
9583
 
10591
  for (i = 0; i < max_fg; i++)
9584
  for (i = 0; i < max_fg; i++) {
10592
    {
-
 
10593
      if (fg[i])
9585
    if (fg[i])
10594
        putchar ('1');
9586
            putchar ('1');
10595
      else
9587
    else
10596
        putchar ('0');
9588
            putchar ('0');
10597
    }
9589
  }
10598
}
9590
}
10599
 
-
 
10600
 
9591
 
10601
#if 0
9592
#if 0
10602
static void readinputfile (molfilename) char *molfilename;
9593
static void readinputfile (molfilename) char *molfilename;
10603
     {
9594
  {
10604
     /* new version in v0.2g */
9595
  /* new version in v0.2g */
10605
     char rline[256];
9596
  char rline[256];
10606
     char *TEMP;
9597
  char *TEMP;
10607
 
9598
 
10608
     molbufindex = 0;
9599
  molbufindex = 0;
10609
     if (!opt_stdin)
9600
  if (!opt_stdin)
10610
     {
9601
  {
10611
     if (!rfile_is_open)
9602
  if (!rfile_is_open)
10612
     {
9603
  {
10613
     assign (rfile, molfilename);
9604
  assign (rfile, molfilename);
10614
     rewind (rfile);
9605
  rewind (rfile);
10615
     rfile_is_open = true;
9606
  rfile_is_open = true;
10616
     }
9607
  }
10617
     /* p2c: checkmol.pas, line 7733: Warning:
9608
  /* p2c: checkmol.pas, line 7733: Warning:
10618
     * Don't know how to ASSIGN to a non-explicit file variable [207] */
9609
  * Don't know how to ASSIGN to a non-explicit file variable [207] */
10619
     *rline = '\0';
9610
  *rline = '\0';
10620
     mol_in_queue = false;
9611
  mol_in_queue = false;
10621
     while ((!P_eof (rfile)) && (strpos2 (rline, "$$$$", 1) == 0))
9612
  while ((!P_eof (rfile)) && (strpos2 (rline, "$$$$", 1) == 0))
10622
     {
9613
  {
10623
     fgets (rline, 256, rfile);
9614
  fgets (rline, 256, rfile);
10624
     TEMP = strchr (rline, '\n');
9615
  TEMP = strchr (rline, '\n');
10625
     if (TEMP != NULL)
9616
  if (TEMP != NULL)
10626
     *TEMP = 0;
9617
  *TEMP = 0;
10627
     /*mol_in_queue := false; */
9618
  /*mol_in_queue := false; */
10628
     if (molbufindex >= max_atoms + max_bonds + 64)
9619
  if (molbufindex >= max_atoms + max_bonds + 64)
10629
     {
9620
  {
10630
     printf ("Not enough memory for molfile! %12ld\n",
9621
  printf ("Not enough memory for molfile! %12ld\n",
10631
     molbufindex);
9622
  molbufindex);
10632
     if (rfile != NULL)
9623
  if (rfile != NULL)
10633
     fclose (rfile);
9624
  fclose (rfile);
10634
     rfile = NULL;
9625
  rfile = NULL;
10635
     _Escape (1);
9626
  _Escape (1);
10636
     }
9627
  }
10637
     molbufindex++;
9628
  molbufindex++;
10638
     strcpy (molbuf[molbufindex - 1], rline);
9629
  strcpy (molbuf[molbufindex - 1], rline);
10639
     if (strpos2 (rline, "$$$$", 1) > 0)
9630
  if (strpos2 (rline, "$$$$", 1) > 0)
10640
     mol_in_queue = true;
9631
  mol_in_queue = true;
10641
     }
9632
  }
10642
     if (!P_eof (rfile))
9633
  if (!P_eof (rfile))
10643
     return;
9634
  return;
10644
     if (rfile != NULL)
9635
  if (rfile != NULL)
10645
     fclose (rfile);
9636
  fclose (rfile);
10646
     rfile = NULL;
9637
  rfile = NULL;
10647
     rfile_is_open = false;
9638
  rfile_is_open = false;
10648
     mol_in_queue = false;
9639
  mol_in_queue = false;
10649
     return;
9640
  return;
10650
     }
9641
  }
10651
     *rline = '\0';
9642
  *rline = '\0';
10652
     mol_in_queue = false;
9643
  mol_in_queue = false;
10653
     while ((!P_eof (stdin)) && (strpos2 (rline, "$$$$", 1) == 0))
9644
  while ((!P_eof (stdin)) && (strpos2 (rline, "$$$$", 1) == 0))
10654
     {
9645
  {
10655
     gets (rline);
9646
  gets (rline);
10656
     if (molbufindex >= max_atoms + max_bonds + 64)
9647
  if (molbufindex >= max_atoms + max_bonds + 64)
10657
     {
9648
  {
10658
     printf ("Not enough memory!\n");
9649
  printf ("Not enough memory!\n");
10659
     _Escape (1);
9650
  _Escape (1);
10660
     }
9651
  }
10661
     molbufindex++;
9652
  molbufindex++;
10662
     strcpy (molbuf[molbufindex - 1], rline);
9653
  strcpy (molbuf[molbufindex - 1], rline);
10663
     if (strpos2 (rline, "$$$$", 1) > 0)
9654
  if (strpos2 (rline, "$$$$", 1) > 0)
10664
     {
9655
  {
10665
     mol_in_queue = true;
9656
  mol_in_queue = true;
10666
     /* read from standard input
9657
  /* read from standard input
10667
     }
9658
  }
10668
     }
9659
  }
10669
     } */
9660
  } */
10670
#endif
9661
#endif
10671
 
9662
 
10672
static void
-
 
10673
readinputfile (char *molfilename)
9663
static void readinputfile (char *molfilename)
10674
{
9664
{
10675
  /* new version in v0.2g */
9665
  /* new version in v0.2g */
10676
  char rline[256];
9666
  char rline[256];
10677
  char *TEMP;
9667
  char *TEMP;
10678
 
9668
 
10679
  molbufindex = 0;
9669
  molbufindex = 0;
10680
  if (!opt_stdin)
9670
  if (!opt_stdin) {
10681
    {
-
 
10682
      if (!rfile_is_open)
9671
    if (!rfile_is_open) {
10683
        {
-
 
10684
          rfile = fopen (molfilename, "r");
9672
            rfile = fopen (molfilename, "r");
10685
          rewind (rfile);
9673
            rewind (rfile);
10686
          rfile_is_open = true;
9674
            rfile_is_open = true;
10687
        }
9675
          }
10688
/* p2c: checkmol.pas, line 7226: Warning:
9676
    /* p2c: checkmol.pas, line 7226: Warning:
10689
 * Don't know how to ASSIGN to a non-explicit file variable [207] */
9677
     * Don't know how to ASSIGN to a non-explicit file variable [207] */
10690
      *rline = '\0';
9678
    *rline = '\0';
10691
      mol_in_queue = false;
9679
    mol_in_queue = false;
10692
      while ((fgets (rline, 256, rfile) != NULL)
9680
    while ((fgets (rline, 256, rfile) != NULL) && (strstr (rline, "$$$$") == NULL)) {
10693
             && (strstr (rline, "$$$$") == NULL))
-
 
10694
        {
-
 
10695
          TEMP = strchr (rline, '\n');
9681
            TEMP = strchr (rline, '\n');
10696
          if (TEMP != NULL)
9682
            if (TEMP != NULL)
10697
            *TEMP = 0;
9683
              *TEMP = 0;
10698
          /*mol_in_queue := false; */
9684
            /*mol_in_queue := false; */
10699
          if (molbufindex >= max_atoms + max_bonds + 64)
9685
            if (molbufindex >= max_atoms + max_bonds + 64) {
10700
            {
-
 
10701
              printf ("Not enough memory for molfile! %d\n", molbufindex);
9686
              printf ("Not enough memory for molfile! %d\n", molbufindex);
10702
              if (rfile != NULL)
9687
              if (rfile != NULL)
10703
                fclose (rfile);
9688
                      fclose (rfile);
10704
              rfile = NULL;
9689
              rfile = NULL;
10705
              exit (1);
9690
              exit (1);
10706
            }
9691
            }
10707
          //molbufindex++;
9692
            //molbufindex++;
10708
          strcpy (molbuf[molbufindex++], rline);
9693
            strcpy (molbuf[molbufindex++], rline);
10709
          if (strstr (rline, "$$$$") != NULL)
9694
            if (strstr (rline, "$$$$") != NULL)
10710
            mol_in_queue = true;
9695
              mol_in_queue = true;
10711
        }
9696
          }
10712
      if (!feof (rfile))
9697
    if (!feof (rfile))
10713
        return;
9698
            return;
10714
      if (rfile != NULL)
9699
    if (rfile != NULL)
10715
        fclose (rfile);
9700
            fclose (rfile);
10716
      rfile = NULL;
9701
    rfile = NULL;
10717
      rfile_is_open = false;
9702
    rfile_is_open = false;
10718
      mol_in_queue = false;
9703
    mol_in_queue = false;
10719
      return;
9704
    return;
10720
    }
9705
  }
10721
  *rline = '\0';
9706
  *rline = '\0';
10722
  mol_in_queue = false;
9707
  mol_in_queue = false;
10723
  do
-
 
10724
    {
9708
  do {
10725
      if(fgets (rline, 256, stdin)==NULL || feof (stdin))
9709
    if(fgets (rline, 256, stdin)==NULL || feof (stdin))
10726
        return;
9710
            return;
10727
      TEMP = strchr (rline, '\n');
9711
    TEMP = strchr (rline, '\n');
10728
      if (TEMP != NULL)
9712
    if (TEMP != NULL)
10729
        *TEMP = '\0';
9713
            *TEMP = '\0';
10730
      if (molbufindex >= max_atoms + max_bonds + 64)
9714
    if (molbufindex >= max_atoms + max_bonds + 64) {
10731
        {
-
 
10732
          printf ("Not enough memory!\n");
9715
            printf ("Not enough memory!\n");
10733
          exit (1);
9716
            exit (1);
10734
        }
9717
          }
10735
      //molbufindex++;
9718
    //molbufindex++;
10736
      strcpy (molbuf[molbufindex++], rline);
9719
    strcpy (molbuf[molbufindex++], rline);
10737
      if (strstr (rline, "$$$$") != NULL)
9720
    if (strstr (rline, "$$$$") != NULL) {
10738
        {
-
 
10739
          mol_in_queue = true;
9721
            mol_in_queue = true;
10740
          /* read from standard input */
9722
            /* read from standard input */
10741
        }
9723
          }
10742
    }
9724
  }
10743
  while (strstr (rline, "$$$$") == NULL);
9725
  while (strstr (rline, "$$$$") == NULL);
10744
}
9726
}
10745
 
9727
 
10746
#if 0
9728
#if 0
10747
static void copy_mol_to_needle()
9729
static void copy_mol_to_needle()
Line 10759... Line 9741...
10759
    on e:Eoutofmemory do
9741
    on e:Eoutofmemory do
10760
      begin
9742
      begin
10761
        writeln('Not enough memory');
9743
        writeln('Not enough memory');
10762
        halt(4);
9744
        halt(4);
10763
      end;
9745
      end;
10764
  end;
9746
  end;
10765
  ndl_n_atoms = n_atoms;
9747
  ndl_n_atoms = n_atoms;
10766
  ndl_n_bonds = n_bonds;
9748
  ndl_n_bonds = n_bonds;
10767
  ndl_n_rings = n_rings;
9749
  ndl_n_rings = n_rings;
10768
  ndl_n_heavyatoms = n_heavyatoms;
9750
  ndl_n_heavyatoms = n_heavyatoms;
10769
  ndl_n_heavybonds = n_heavybonds;
9751
  ndl_n_heavybonds = n_heavybonds;
Line 10787... Line 9769...
10787
    ndl_atom[i].arom = atom[i].arom;
9769
    ndl_atom[i].arom = atom[i].arom;
10788
    ndl_atom[i].stereo_care = atom[i].stereo_care;
9770
    ndl_atom[i].stereo_care = atom[i].stereo_care;
10789
    ndl_atom[i].heavy = atom[i].heavy;   /* v0.3l */
9771
    ndl_atom[i].heavy = atom[i].heavy;   /* v0.3l */
10790
    ndl_atom[i].metal = atom[i].metal;   /* v0.3l */
9772
    ndl_atom[i].metal = atom[i].metal;   /* v0.3l */
10791
    ndl_atom[i].tag = atom[i].tag;      /* v0.3o */
9773
    ndl_atom[i].tag = atom[i].tag;      /* v0.3o */
10792
                                           }
9774
        }
10793
                                           if (n_bonds > 0) {
9775
        if (n_bonds > 0) {
10794
                                           FORLIM = n_bonds;
9776
          FORLIM = n_bonds;
10795
                                           for (i = 0; i < FORLIM; i++) {
9777
          for (i = 0; i < FORLIM; i++) {
10796
                                           ndl_bond[i].a1 = bond[i].a1;
9778
            ndl_bond[i].a1 = bond[i].a1;
10797
                                           ndl_bond[i].a2 = bond[i].a2;
9779
            ndl_bond[i].a2 = bond[i].a2;
10798
                                           ndl_bond[i].btype = bond[i].btype;
9780
            ndl_bond[i].btype = bond[i].btype;
10799
                                           ndl_bond[i].arom = bond[i].arom;
9781
            ndl_bond[i].arom = bond[i].arom;
10800
                                           ndl_bond[i].ring_count = bond[i].ring_count;   /* new in v0.3d */
9782
            ndl_bond[i].ring_count = bond[i].ring_count;   /* new in v0.3d */
10801
                                           ndl_bond[i].topo = bond[i].topo;   /* new in v0.3d */
9783
            ndl_bond[i].topo = bond[i].topo;   /* new in v0.3d */
10802
                                           ndl_bond[i].stereo = bond[i].stereo;   /* new in v0.3d */
9784
            ndl_bond[i].stereo = bond[i].stereo;   /* new in v0.3d */
10803
                                           }
9785
          }
10804
                                           }
9786
        }
10805
                                           if (n_rings > 0) {
9787
        if (n_rings > 0) {
10806
                                           FORLIM = n_rings;
9788
          FORLIM = n_rings;
10807
                                           for (i = 0; i < FORLIM; i++) {
9789
          for (i = 0; i < FORLIM; i++) {
10808
                                           for (j = 0; j < max_ringsize; j++)
9790
            for (j = 0; j < max_ringsize; j++)
10809
                                           ndl_ring[i][j] = ring[i][j];
9791
              ndl_ring[i][j] = ring[i][j];
10810
                                           }
9792
          }
10811
                                           for (i = 0; i < max_rings; i++) {   /* new in v0.3 */
9793
          for (i = 0; i < max_rings; i++) {   /* new in v0.3 */
10812
                                           ndl_ringprop[i].size = ringprop[i].size;
9794
            ndl_ringprop[i].size = ringprop[i].size;
10813
                                           ndl_ringprop[i].arom = ringprop[i].arom;
9795
            ndl_ringprop[i].arom = ringprop[i].arom;
10814
                                           ndl_ringprop[i].envelope = ringprop[i].envelope;
9796
            ndl_ringprop[i].envelope = ringprop[i].envelope;
10815
                                           }
9797
          }
10816
                                           }
9798
        }
10817
                                           ndl_molstat.n_QA = molstat.n_QA;
9799
        ndl_molstat.n_QA = molstat.n_QA;
10818
                                           ndl_molstat.n_QB = molstat.n_QB;
9800
  ndl_molstat.n_QB = molstat.n_QB;
10819
                                           ndl_molstat.n_chg = molstat.n_chg;
9801
  ndl_molstat.n_chg = molstat.n_chg;
10820
                                           ndl_molstat.n_C1 = molstat.n_C1;
9802
  ndl_molstat.n_C1 = molstat.n_C1;
10821
                                           ndl_molstat.n_C2 = molstat.n_C2;
9803
  ndl_molstat.n_C2 = molstat.n_C2;
10822
                                           ndl_molstat.n_C = molstat.n_C;
9804
  ndl_molstat.n_C = molstat.n_C;
10823
                                           ndl_molstat.n_CHB1p = molstat.n_CHB1p;
9805
  ndl_molstat.n_CHB1p = molstat.n_CHB1p;
10824
                                           ndl_molstat.n_CHB2p = molstat.n_CHB2p;
9806
  ndl_molstat.n_CHB2p = molstat.n_CHB2p;
10825
                                           ndl_molstat.n_CHB3p = molstat.n_CHB3p;
9807
  ndl_molstat.n_CHB3p = molstat.n_CHB3p;
10826
                                           ndl_molstat.n_CHB4 = molstat.n_CHB4;
9808
  ndl_molstat.n_CHB4 = molstat.n_CHB4;
10827
                                           ndl_molstat.n_O2 = molstat.n_O2;
9809
  ndl_molstat.n_O2 = molstat.n_O2;
10828
                                           ndl_molstat.n_O3 = molstat.n_O3;
9810
  ndl_molstat.n_O3 = molstat.n_O3;
10829
                                           ndl_molstat.n_N1 = molstat.n_N1;
9811
  ndl_molstat.n_N1 = molstat.n_N1;
10830
                                           ndl_molstat.n_N2 = molstat.n_N2;
9812
  ndl_molstat.n_N2 = molstat.n_N2;
10831
                                           ndl_molstat.n_N3 = molstat.n_N3;
9813
  ndl_molstat.n_N3 = molstat.n_N3;
10832
                                           ndl_molstat.n_S = molstat.n_S;
9814
  ndl_molstat.n_S = molstat.n_S;
10833
                                           ndl_molstat.n_SeTe = molstat.n_SeTe;
9815
  ndl_molstat.n_SeTe = molstat.n_SeTe;
10834
                                           ndl_molstat.n_F = molstat.n_F;
9816
  ndl_molstat.n_F = molstat.n_F;
10835
                                           ndl_molstat.n_Cl = molstat.n_Cl;
9817
  ndl_molstat.n_Cl = molstat.n_Cl;
10836
                                           ndl_molstat.n_Br = molstat.n_Br;
9818
  ndl_molstat.n_Br = molstat.n_Br;
10837
                                           ndl_molstat.n_I = molstat.n_I;
9819
  ndl_molstat.n_I = molstat.n_I;
10838
                                           ndl_molstat.n_P = molstat.n_P;
9820
  ndl_molstat.n_P = molstat.n_P;
10839
                                           ndl_molstat.n_B = molstat.n_B;
9821
  ndl_molstat.n_B = molstat.n_B;
10840
                                           ndl_molstat.n_Met = molstat.n_Met;
9822
  ndl_molstat.n_Met = molstat.n_Met;
10841
                                           ndl_molstat.n_X = molstat.n_X;
9823
  ndl_molstat.n_X = molstat.n_X;
10842
                                           ndl_molstat.n_b1 = molstat.n_b1;
9824
  ndl_molstat.n_b1 = molstat.n_b1;
10843
                                           ndl_molstat.n_b2 = molstat.n_b2;
9825
  ndl_molstat.n_b2 = molstat.n_b2;
10844
                                           ndl_molstat.n_b3 = molstat.n_b3;
9826
  ndl_molstat.n_b3 = molstat.n_b3;
10845
                                           ndl_molstat.n_bar = molstat.n_bar;
9827
  ndl_molstat.n_bar = molstat.n_bar;
10846
                                           ndl_molstat.n_C1O = molstat.n_C1O;
9828
  ndl_molstat.n_C1O = molstat.n_C1O;
10847
                                           ndl_molstat.n_C2O = molstat.n_C2O;
9829
  ndl_molstat.n_C2O = molstat.n_C2O;
10848
                                           ndl_molstat.n_CN = molstat.n_CN;
9830
  ndl_molstat.n_CN = molstat.n_CN;
10849
                                           ndl_molstat.n_XY = molstat.n_XY;
9831
  ndl_molstat.n_XY = molstat.n_XY;
10850
                                           ndl_molstat.n_r3 = molstat.n_r3;
9832
  ndl_molstat.n_r3 = molstat.n_r3;
10851
                                           ndl_molstat.n_r4 = molstat.n_r4;
9833
  ndl_molstat.n_r4 = molstat.n_r4;
10852
                                           ndl_molstat.n_r5 = molstat.n_r5;
9834
  ndl_molstat.n_r5 = molstat.n_r5;
10853
                                           ndl_molstat.n_r6 = molstat.n_r6;
9835
  ndl_molstat.n_r6 = molstat.n_r6;
10854
                                           ndl_molstat.n_r7 = molstat.n_r7;
9836
  ndl_molstat.n_r7 = molstat.n_r7;
10855
                                           ndl_molstat.n_r8 = molstat.n_r8;
9837
        ndl_molstat.n_r8 = molstat.n_r8;
10856
                                           ndl_molstat.n_r9 = molstat.n_r9;
9838
        ndl_molstat.n_r9 = molstat.n_r9;
10857
                                           ndl_molstat.n_r10 = molstat.n_r10;
9839
        ndl_molstat.n_r10 = molstat.n_r10;
10858
                                           ndl_molstat.n_r11 = molstat.n_r11;
9840
        ndl_molstat.n_r11 = molstat.n_r11;
10859
                                           ndl_molstat.n_r12 = molstat.n_r12;
9841
        ndl_molstat.n_r12 = molstat.n_r12;
10860
                                           ndl_molstat.n_r13p = molstat.n_r13p;
9842
        ndl_molstat.n_r13p = molstat.n_r13p;
10861
                                           ndl_molstat.n_rN = molstat.n_rN;
9843
        ndl_molstat.n_rN = molstat.n_rN;
10862
                                           ndl_molstat.n_rN1 = molstat.n_rN1;
9844
        ndl_molstat.n_rN1 = molstat.n_rN1;
10863
                                           ndl_molstat.n_rN2 = molstat.n_rN2;
9845
        ndl_molstat.n_rN2 = molstat.n_rN2;
10864
                                           ndl_molstat.n_rN3p = molstat.n_rN3p;
9846
        ndl_molstat.n_rN3p = molstat.n_rN3p;
10865
                                           ndl_molstat.n_rO = molstat.n_rO;
9847
        ndl_molstat.n_rO = molstat.n_rO;
10866
                                           ndl_molstat.n_rO1 = molstat.n_rO1;
9848
        ndl_molstat.n_rO1 = molstat.n_rO1;
10867
                                           ndl_molstat.n_rO2p = molstat.n_rO2p;
9849
        ndl_molstat.n_rO2p = molstat.n_rO2p;
10868
                                           ndl_molstat.n_rS = molstat.n_rS;
9850
        ndl_molstat.n_rS = molstat.n_rS;
10869
                                           ndl_molstat.n_rX = molstat.n_rX;
9851
        ndl_molstat.n_rX = molstat.n_rX;
10870
                                           ndl_molstat.n_rAr = molstat.n_rAr;
9852
        ndl_molstat.n_rAr = molstat.n_rAr;
10871
                                           ndl_molstat.n_rBz = molstat.n_rBz;   /* v0.3l */
9853
        ndl_molstat.n_rBz = molstat.n_rBz;   /* v0.3l */
10872
                                           ndl_molstat.n_br2p = molstat.n_br2p;   /* v0.3n */
9854
        ndl_molstat.n_br2p = molstat.n_br2p;   /* v0.3n */
10873
                                           /* p2c: checkmol.pas, line 7875:
9855
        /* p2c: checkmol.pas, line 7875:
10874
                                           * Note: Turbo Pascal conditional compilation directive was ignored [218] */
9856
        * Note: Turbo Pascal conditional compilation directive was ignored [218] */
10875
                                           /*$IFDEF extended_molstat
9857
        /*$IFDEF extended_molstat
10876
                                            v0.3m */
9858
         v0.3m */
10877
                                           ndl_molstat.n_psg01 = molstat.n_psg01;
9859
        ndl_molstat.n_psg01 = molstat.n_psg01;
10878
                                           ndl_molstat.n_psg02 = molstat.n_psg02;
9860
        ndl_molstat.n_psg02 = molstat.n_psg02;
10879
                                           ndl_molstat.n_psg13 = molstat.n_psg13;
9861
        ndl_molstat.n_psg13 = molstat.n_psg13;
10880
                                           ndl_molstat.n_psg14 = molstat.n_psg14;
9862
        ndl_molstat.n_psg14 = molstat.n_psg14;
10881
                                           ndl_molstat.n_psg15 = molstat.n_psg15;
9863
        ndl_molstat.n_psg15 = molstat.n_psg15;
10882
                                           ndl_molstat.n_psg16 = molstat.n_psg16;
9864
        ndl_molstat.n_psg16 = molstat.n_psg16;
10883
                                           ndl_molstat.n_psg17 = molstat.n_psg17;
9865
        ndl_molstat.n_psg17 = molstat.n_psg17;
10884
                                           ndl_molstat.n_psg18 = molstat.n_psg18;
9866
        ndl_molstat.n_psg18 = molstat.n_psg18;
10885
                                           ndl_molstat.n_pstm = molstat.n_pstm;
9867
        ndl_molstat.n_pstm = molstat.n_pstm;
10886
                                           ndl_molstat.n_psla = molstat.n_psla;
9868
        ndl_molstat.n_psla = molstat.n_psla;
10887
                                           $ENDIF*/
9869
        $ENDIF*/
10888
                                           /* make sure some modes can be switched on only by the query file *M*/
9870
  /* make sure some modes can be switched on only by the query file *M*/
10889
                                           /* and not by subsequent haystack file(s) */
9871
  /* and not by subsequent haystack file(s) */
10890
                                           if (ez_flag)   /* new in v0.3f */
9872
  if (ez_flag)   /* new in v0.3f */
10891
                                           ez_search = true;
9873
   ez_search = true;
10892
                                           if (chir_flag)   /* new in v0.3f */
9874
  if (chir_flag)   /* new in v0.3f */
10893
                                           rs_search = true;
9875
    rs_search = true;
10894
                                           }
9876
}
10895
#endif
9877
#endif
10896
 
9878
 
10897
 
-
 
10898
static void
-
 
10899
copy_mol_to_needle ()
9879
static void copy_mol_to_needle ()
10900
{
9880
{
10901
  //int i, j, FORLIM;
9881
  //int i, j, FORLIM;
10902
 
9882
 
10903
  /*if (n_atoms == 0)
9883
  /*if (n_atoms == 0)
10904
     return; *///If a NoStruct is read, this leads to madness and illegal memory access
9884
     return; *///If a NoStruct is read, this leads to madness and illegal memory access
10905
 
-
 
10906
 
9885
 
10907
  ndl_atom = (atom_rec *) safe_calloc (n_atoms, sizeof (atom_rec));
9886
  ndl_atom = (atom_rec *) safe_calloc (n_atoms, sizeof (atom_rec));
10908
  ndl_bond = (bond_rec *) safe_calloc (n_bonds, sizeof (bond_rec));
9887
  ndl_bond = (bond_rec *) safe_calloc (n_bonds, sizeof (bond_rec));
10909
  ndl_ring = (ringpath_type *) safe_calloc (1, sizeof (ringlist));
9888
  ndl_ring = (ringpath_type *) safe_calloc (1, sizeof (ringlist));
10910
  ndl_ringprop = (ringprop_rec *) safe_calloc (1, sizeof (ringprop_type));
9889
  ndl_ringprop = (ringprop_rec *) safe_calloc (1, sizeof (ringprop_type));
10911
 
-
 
10912
 
9890
 
10913
  ndl_n_atoms = n_atoms;
9891
  ndl_n_atoms = n_atoms;
10914
  ndl_n_bonds = n_bonds;
9892
  ndl_n_bonds = n_bonds;
10915
  ndl_n_rings = n_rings;
9893
  ndl_n_rings = n_rings;
10916
  ndl_n_heavyatoms = n_heavyatoms;
9894
  ndl_n_heavyatoms = n_heavyatoms;
Line 10922... Line 9900...
10922
  memcpy (ndl_atom, atom, n_atoms * sizeof (atom_rec));
9900
  memcpy (ndl_atom, atom, n_atoms * sizeof (atom_rec));
10923
 
9901
 
10924
  if (n_bonds > 0)
9902
  if (n_bonds > 0)
10925
    memcpy (ndl_bond, bond, n_bonds * sizeof (bond_rec));
9903
    memcpy (ndl_bond, bond, n_bonds * sizeof (bond_rec));
10926
 
9904
 
10927
  if (n_rings > 0)
9905
  if (n_rings > 0) {
10928
    {
-
 
10929
      memcpy (ndl_ring, ring, sizeof (ringlist));
9906
    memcpy (ndl_ring, ring, sizeof (ringlist));
10930
      memcpy (ndl_ringprop, ringprop, sizeof (ringprop_type));
9907
    memcpy (ndl_ringprop, ringprop, sizeof (ringprop_type));
10931
    }
9908
  }
10932
 
9909
 
10933
  memcpy (&ndl_molstat, &molstat, sizeof (molstat));
9910
  memcpy (&ndl_molstat, &molstat, sizeof (molstat));
10934
 
9911
 
10935
 
-
 
10936
  // make sure some modes can be switched on only by the query file 
9912
  // make sure some modes can be switched on only by the query file
10937
  // and not by subsequent haystack file(s) 
9913
  // and not by subsequent haystack file(s)
10938
  if (ez_flag)                  // new in v0.3f 
9914
  if (ez_flag)                  // new in v0.3f
10939
    ez_search = true;
9915
    ez_search = true;
10940
 
9916
 
10941
  if (chir_flag)                // new in v0.3f 
9917
  if (chir_flag)                // new in v0.3f
10942
    rs_search = true;
9918
    rs_search = true;
10943
 
9919
 
10944
  ndl_querymol = found_querymol;        /* 0.3p */
9920
  ndl_querymol = found_querymol;        /* 0.3p */
10945
 
9921
 
10946
}
9922
}
10947
 
9923
 
10948
static void
-
 
10949
copy_mol_to_tmp ()
9924
static void copy_mol_to_tmp ()
10950
{
9925
{
10951
  //int i, j, FORLIM;
9926
  //int i, j, FORLIM;
10952
 
9927
 
10953
  /*if (n_atoms == 0)
9928
  /*if (n_atoms == 0)
10954
     return; *///If a NoStruct is read, this leads to madness and illegal memory access
9929
     return; *///If a NoStruct is read, this leads to madness and illegal memory access
10955
 
-
 
10956
 
9930
 
10957
  tmp_atom = (atom_rec *) safe_calloc (n_atoms, sizeof (atom_rec));
9931
  tmp_atom = (atom_rec *) safe_calloc (n_atoms, sizeof (atom_rec));
10958
  tmp_bond = (bond_rec *) safe_calloc (n_bonds, sizeof (bond_rec));
9932
  tmp_bond = (bond_rec *) safe_calloc (n_bonds, sizeof (bond_rec));
10959
  tmp_ring = (ringpath_type *) safe_calloc (1, sizeof (ringlist));
9933
  tmp_ring = (ringpath_type *) safe_calloc (1, sizeof (ringlist));
10960
  tmp_ringprop = (ringprop_rec *) safe_calloc (1, sizeof (ringprop_type));
9934
  tmp_ringprop = (ringprop_rec *) safe_calloc (1, sizeof (ringprop_type));
10961
 
-
 
10962
 
9935
 
10963
  tmp_n_atoms = n_atoms;
9936
  tmp_n_atoms = n_atoms;
10964
  tmp_n_bonds = n_bonds;
9937
  tmp_n_bonds = n_bonds;
10965
  tmp_n_rings = n_rings;
9938
  tmp_n_rings = n_rings;
10966
  tmp_n_heavyatoms = n_heavyatoms;
9939
  tmp_n_heavyatoms = n_heavyatoms;
Line 10968... Line 9941...
10968
  strcpy (tmp_molname, molname);
9941
  strcpy (tmp_molname, molname);
10969
  tmp_n_Ctot = n_Ctot;
9942
  tmp_n_Ctot = n_Ctot;
10970
  tmp_n_Otot = n_Otot;
9943
  tmp_n_Otot = n_Otot;
10971
  tmp_n_Ntot = n_Ntot;
9944
  tmp_n_Ntot = n_Ntot;
10972
  memcpy (tmp_atom, atom, n_atoms * sizeof (atom_rec));
9945
  memcpy (tmp_atom, atom, n_atoms * sizeof (atom_rec));
10973
 
9946
 
10974
  if (n_bonds > 0)
9947
  if (n_bonds > 0)
10975
    memcpy (tmp_bond, bond, n_bonds * sizeof (bond_rec));
9948
    memcpy (tmp_bond, bond, n_bonds * sizeof (bond_rec));
10976
 
9949
 
10977
  if (n_rings > 0)
9950
  if (n_rings > 0) {
10978
    {
-
 
10979
      memcpy (tmp_ring, ring, sizeof (ringlist));
9951
      memcpy (tmp_ring, ring, sizeof (ringlist));
10980
      memcpy (tmp_ringprop, ringprop, sizeof (ringprop_type));
9952
      memcpy (tmp_ringprop, ringprop, sizeof (ringprop_type));
10981
    }
9953
  }
10982
 
9954
 
10983
  memcpy (&tmp_molstat, &molstat, sizeof (molstat));
9955
  memcpy (&tmp_molstat, &molstat, sizeof (molstat));
10984
 
9956
 
10985
 
-
 
10986
  // make sure some modes can be switched on only by the query file 
9957
  // make sure some modes can be switched on only by the query file
10987
  // and not by subsequent haystack file(s) 
9958
  // and not by subsequent haystack file(s)
10988
  if (ez_flag)                  // new in v0.3f 
9959
  if (ez_flag)                  // new in v0.3f
10989
    ez_search = true;
9960
    ez_search = true;
10990
 
9961
 
10991
  if (chir_flag)                // new in v0.3f 
9962
  if (chir_flag)                // new in v0.3f
10992
    rs_search = true;
9963
    rs_search = true;
10993
 
9964
 
10994
  ndl_querymol = found_querymol;        /* 0.3p */
9965
  ndl_querymol = found_querymol;        /* 0.3p */
10995
 
9966
 
10996
}
9967
}
Line 11123... Line 10094...
11123
  tmp_molstat.n_rBz = molstat.n_rBz;   /* v0.3l */
10094
  tmp_molstat.n_rBz = molstat.n_rBz;   /* v0.3l */
11124
  tmp_molstat.n_br2p = molstat.n_br2p;   /* v0.3n */
10095
  tmp_molstat.n_br2p = molstat.n_br2p;   /* v0.3n */
11125
/* p2c: checkmol.pas, line 8022:
10096
/* p2c: checkmol.pas, line 8022:
11126
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
10097
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11127
  /*$IFDEF extended_molstat
10098
  /*$IFDEF extended_molstat
11128
   v0.3m
10099
   v0.3m
11129
  tmp_molstat.n_psg01 = molstat.n_psg01;
10100
  tmp_molstat.n_psg01 = molstat.n_psg01;
11130
  tmp_molstat.n_psg02 = molstat.n_psg02;
10101
  tmp_molstat.n_psg02 = molstat.n_psg02;
11131
  tmp_molstat.n_psg13 = molstat.n_psg13;
10102
  tmp_molstat.n_psg13 = molstat.n_psg13;
11132
  tmp_molstat.n_psg14 = molstat.n_psg14;
10103
  tmp_molstat.n_psg14 = molstat.n_psg14;
11133
  tmp_molstat.n_psg15 = molstat.n_psg15;
10104
  tmp_molstat.n_psg15 = molstat.n_psg15;
Line 11144... Line 10115...
11144
  if (chir_flag)   /* new in v0.3f */
10115
  if (chir_flag)   /* new in v0.3f */
11145
    rs_search = true;
10116
    rs_search = true;
11146
}
10117
}
11147
#endif
10118
#endif
11148
 
10119
 
11149
static void
-
 
11150
copy_tmp_to_mol ()
10120
static void copy_tmp_to_mol ()
11151
{
10121
{
11152
  //int i, j, FORLIM;
10122
  //int i, j, FORLIM;
11153
 
10123
 
11154
  /*if (n_atoms == 0)
10124
  /*if (n_atoms == 0)
11155
     return; *///If a NoStruct is read, this leads to madness and illegal memory access
10125
     return; *///If a NoStruct is read, this leads to madness and illegal memory access
11156
 
-
 
11157
 
10126
 
11158
  atom = (atom_rec *) safe_calloc (n_atoms, sizeof (atom_rec));
10127
  atom = (atom_rec *) safe_calloc (n_atoms, sizeof (atom_rec));
11159
  bond = (bond_rec *) safe_calloc (n_bonds, sizeof (bond_rec));
10128
  bond = (bond_rec *) safe_calloc (n_bonds, sizeof (bond_rec));
11160
  ring = (ringpath_type *) safe_calloc (1, sizeof (ringlist));
10129
  ring = (ringpath_type *) safe_calloc (1, sizeof (ringlist));
11161
  ringprop = (ringprop_rec *) safe_calloc (1, sizeof (ringprop_type));
10130
  ringprop = (ringprop_rec *) safe_calloc (1, sizeof (ringprop_type));
11162
 
-
 
11163
 
10131
 
11164
  n_atoms = tmp_n_atoms;
10132
  n_atoms = tmp_n_atoms;
11165
  n_bonds = tmp_n_bonds;
10133
  n_bonds = tmp_n_bonds;
11166
  n_rings = tmp_n_rings;
10134
  n_rings = tmp_n_rings;
11167
  n_heavyatoms = tmp_n_heavyatoms;
10135
  n_heavyatoms = tmp_n_heavyatoms;
Line 11173... Line 10141...
11173
  memcpy (atom, tmp_atom, tmp_n_atoms * sizeof (atom_rec));
10141
  memcpy (atom, tmp_atom, tmp_n_atoms * sizeof (atom_rec));
11174
 
10142
 
11175
  if (tmp_n_bonds > 0)
10143
  if (tmp_n_bonds > 0)
11176
    memcpy (bond, tmp_bond, tmp_n_bonds * sizeof (bond_rec));
10144
    memcpy (bond, tmp_bond, tmp_n_bonds * sizeof (bond_rec));
11177
 
10145
 
11178
  if (tmp_n_rings > 0)
10146
  if (tmp_n_rings > 0) {
11179
    {
-
 
11180
      memcpy (ring, tmp_ring, sizeof (ringlist));
10147
      memcpy (ring, tmp_ring, sizeof (ringlist));
11181
      memcpy (ringprop, tmp_ringprop, sizeof (ringprop_type));
10148
      memcpy (ringprop, tmp_ringprop, sizeof (ringprop_type));
11182
    }
10149
  }
11183
 
10150
 
11184
  memcpy (&molstat, &tmp_molstat, sizeof (tmp_molstat));
10151
  memcpy (&molstat, &tmp_molstat, sizeof (tmp_molstat));
11185
 
10152
 
11186
 
-
 
11187
  // make sure some modes can be switched on only by the query file 
10153
  // make sure some modes can be switched on only by the query file
11188
  // and not by subsequent haystack file(s) 
10154
  // and not by subsequent haystack file(s)
11189
  if (ez_flag)                  // new in v0.3f 
10155
  if (ez_flag)                  // new in v0.3f
11190
    ez_search = true;
10156
    ez_search = true;
11191
 
10157
 
11192
  if (chir_flag)                // new in v0.3f 
10158
  if (chir_flag)                // new in v0.3f
11193
    rs_search = true;
10159
    rs_search = true;
11194
 
10160
 
11195
}
10161
}
11196
 
10162
 
11197
#if 0
10163
#if 0
11198
static void copy_tmp_to_mol()
10164
static void copy_tmp_to_mol()
11199
{
10165
{
Line 11220... Line 10186...
11220
    on e:Eoutofmemory do
10186
    on e:Eoutofmemory do
11221
      begin
10187
      begin
11222
        writeln('Not enough memory');
10188
        writeln('Not enough memory');
11223
        halt(4);
10189
        halt(4);
11224
      end;
10190
      end;
11225
  end;
10191
  end;
11226
  for (i = 0; i < FORLIM; i++) {
10192
  for (i = 0; i < FORLIM; i++) {
11227
    strcpy(atom[i].element, tmp_atom[i].element);
10193
    strcpy(atom[i].element, tmp_atom[i].element);
11228
    strcpy(atom[i].atype, tmp_atom[i].atype);
10194
    strcpy(atom[i].atype, tmp_atom[i].atype);
11229
    atom[i].x = tmp_atom[i].x;
10195
    atom[i].x = tmp_atom[i].x;
11230
    atom[i].y = tmp_atom[i].y;
10196
    atom[i].y = tmp_atom[i].y;
Line 11342... Line 10308...
11342
     if (chir_flag)
10308
     if (chir_flag)
11343
     rs_search = true;
10309
     rs_search = true;
11344
     }
10310
     }
11345
#endif
10311
#endif
11346
 
10312
 
11347
 
-
 
11348
 
-
 
11349
 
-
 
11350
 
-
 
11351
static void
-
 
11352
get_ringstat (r_id)
10313
static void get_ringstat (r_id)
11353
     int r_id;
10314
     int r_id;
11354
{
10315
{
11355
  int i, j;
10316
  int i, j;
11356
  ringpath_type testring;
10317
  ringpath_type testring;
11357
  int ring_size, a_ref;
10318
  int ring_size, a_ref;
Line 11362... Line 10323...
11362
    return;
10323
    return;
11363
  memset (testring, 0, sizeof (ringpath_type));
10324
  memset (testring, 0, sizeof (ringpath_type));
11364
  ring_size = ringprop[r_id - 1].size;  /* v0.3j */
10325
  ring_size = ringprop[r_id - 1].size;  /* v0.3j */
11365
  for (j = 0; j < ring_size; j++)       /* v0.3j */
10326
  for (j = 0; j < ring_size; j++)       /* v0.3j */
11366
    testring[j] = ring[r_id - 1][j];
10327
    testring[j] = ring[r_id - 1][j];
11367
/* p2c: checkmol.pas, line 8238:
10328
    /* p2c: checkmol.pas, line 8238:
11368
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
10329
    * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11369
#ifdef reduced_SAR
10330
#ifdef reduced_SAR
11370
  if (ring_size <= 2 || ringprop[r_id - 1].envelope != false)
10331
  if (ring_size <= 2 || ringprop[r_id - 1].envelope != false)
11371
    /* v0.3n: ignore envelope rings */
10332
    /* v0.3n: ignore envelope rings */
11372
    return;
10333
    return;
11373
#else
10334
#else
11374
  if (ring_size <= 2)
10335
  if (ring_size <= 2)
11375
    return;
10336
    return;
11376
#endif
10337
#endif
11377
  for (i = 0; i < ring_size; i++)
10338
  for (i = 0; i < ring_size; i++) {
11378
    {
-
 
11379
      a_ref = testring[i];
10339
    a_ref = testring[i];
11380
      strcpy (elem, atom[a_ref - 1].element);
10340
    strcpy (elem, atom[a_ref - 1].element);
11381
      if (strcmp (elem, "C ") && strcmp (elem, "A "))
10341
    if (strcmp (elem, "C ") && strcmp (elem, "A ")) {
11382
        {
-
 
11383
          nX++;                 /* general heteroatom count */
10342
            nX++;                       /* general heteroatom count */
11384
          if (!strcmp (elem, "N "))
10343
            if (!strcmp (elem, "N "))
11385
            nN++;
10344
              nN++;
11386
          if (!strcmp (elem, "O "))
10345
            if (!strcmp (elem, "O "))
11387
            nO++;
10346
              nO++;
11388
          if (!strcmp (elem, "S "))
10347
            if (!strcmp (elem, "S "))
11389
            nS++;
10348
              nS++;
11390
        }
10349
          }
11391
    }
10350
  }
11392
  if (nN > 0)
10351
  if (nN > 0) {
11393
    {
-
 
11394
      molstat.n_rN++;
10352
    molstat.n_rN++;
11395
      if (nN == 1)
10353
    if (nN == 1)
11396
        molstat.n_rN1++;
10354
            molstat.n_rN1++;
11397
      if (nN == 2)
10355
    if (nN == 2)
11398
        molstat.n_rN2++;
10356
            molstat.n_rN2++;
11399
      if (nN > 2)
10357
    if (nN > 2)
11400
        molstat.n_rN3p++;
10358
            molstat.n_rN3p++;
11401
    }
10359
  }
11402
  if (nO > 0)
10360
  if (nO > 0) {
11403
    {
-
 
11404
      molstat.n_rO++;
10361
    molstat.n_rO++;
11405
      if (nO == 1)
10362
    if (nO == 1)
11406
        molstat.n_rO1++;
10363
            molstat.n_rO1++;
11407
      if (nO == 2)
10364
    if (nO == 2)
11408
        molstat.n_rO2p++;
10365
            molstat.n_rO2p++;
11409
    }
10366
  }
11410
  if (nS > 0)
10367
  if (nS > 0)
11411
    molstat.n_rS++;
10368
    molstat.n_rS++;
11412
  if (nX > 0)
10369
  if (nX > 0)
11413
    molstat.n_rX++;
10370
    molstat.n_rX++;
11414
  /* general ringsize descriptors; v0.3m */
10371
  /* general ringsize descriptors; v0.3m */
11415
  switch (ring_size)
10372
  switch (ring_size) {
11416
    {
-
 
11417
 
-
 
11418
    case 3:
10373
    case 3:
11419
      molstat.n_r3++;
10374
      molstat.n_r3++;
11420
      break;
10375
      break;
11421
 
10376
 
11422
    case 4:
10377
    case 4:
11423
      molstat.n_r4++;
10378
      molstat.n_r4++;
11424
      break;
10379
      break;
11425
 
10380
 
11426
    case 5:
10381
    case 5:
11427
      molstat.n_r5++;
10382
      molstat.n_r5++;
11428
      break;
10383
      break;
11429
 
10384
 
11430
    case 6:
10385
    case 6:
11431
      molstat.n_r6++;
10386
      molstat.n_r6++;
11432
      break;
10387
      break;
11433
 
10388
 
11434
    case 7:
10389
    case 7:
11435
      molstat.n_r7++;
10390
      molstat.n_r7++;
11436
      break;
10391
      break;
11437
 
10392
 
Line 11456... Line 10411...
11456
      break;
10411
      break;
11457
 
10412
 
11458
    default:
10413
    default:
11459
      molstat.n_r13p++;
10414
      molstat.n_r13p++;
11460
      break;
10415
      break;
11461
    }                           /* end v0.3m        */
10416
  }                             /* end v0.3m        */
11462
}
10417
}
11463
 
10418
 
11464
 
-
 
11465
static void
-
 
11466
get_molstat ()
10419
static void get_molstat ()
11467
{
10420
{
11468
  int i;
10421
  int i;
11469
  str2 elem;
10422
  str2 elem;
11470
  str3 atype;
10423
  str3 atype;
11471
  int a1, a2;
10424
  int a1, a2;
Line 11476... Line 10429...
11476
  int FORLIM;
10429
  int FORLIM;
11477
 
10430
 
11478
  if (n_atoms == 0)
10431
  if (n_atoms == 0)
11479
    return;
10432
    return;
11480
  FORLIM = n_atoms;
10433
  FORLIM = n_atoms;
11481
  for (i = 0; i < FORLIM; i++)
10434
  for (i = 0; i < FORLIM; i++) {
11482
    {
-
 
11483
      if (atom[i].heavy)
10435
    if (atom[i].heavy) {
11484
        {
-
 
11485
          strcpy (elem, atom[i].element);
10436
            strcpy (elem, atom[i].element);
11486
          strcpy (atype, atom[i].atype);
10437
            strcpy (atype, atom[i].atype);
11487
          if (!strcmp (atype, "C1 "))
10438
            if (!strcmp (atype, "C1 "))
11488
            molstat.n_C1++;
10439
              molstat.n_C1++;
11489
          if (!strcmp (atype, "C2 ") || !strcmp (atype, "CAR"))
10440
            if (!strcmp (atype, "C2 ") || !strcmp (atype, "CAR"))
11490
            molstat.n_C2++;
10441
              molstat.n_C2++;
11491
          if (!strcmp (elem, "C "))
10442
            if (!strcmp (elem, "C "))
11492
            molstat.n_C++;
10443
              molstat.n_C++;
11493
          if (!strcmp (atype, "O2 "))
10444
            if (!strcmp (atype, "O2 "))
11494
            molstat.n_O2++;
10445
              molstat.n_O2++;
11495
          if (!strcmp (atype, "O3 "))
10446
            if (!strcmp (atype, "O3 "))
11496
            molstat.n_O3++;
10447
              molstat.n_O3++;
11497
          if (!strcmp (atype, "N1 "))
10448
            if (!strcmp (atype, "N1 "))
11498
            molstat.n_N1++;
10449
              molstat.n_N1++;
11499
          if (!strcmp (atype, "N2 ") || !strcmp (atype, "NAR") ||
10450
            if (!strcmp (atype, "N2 ") || !strcmp (atype, "NAR") ||
11500
              (!strcmp (atype, "NAM") && atom[i].arom == true))
10451
                (!strcmp (atype, "NAM") && atom[i].arom == true))
11501
            /* v0.3n */
10452
              /* v0.3n */
11502
            molstat.n_N2++;
10453
              molstat.n_N2++;
11503
          if (!strcmp (atype, "N3 ") || !strcmp (atype, "NPL") ||
10454
            if (!strcmp (atype, "N3 ") || !strcmp (atype, "NPL") ||
11504
              !strcmp (atype, "N3+") ||
10455
                !strcmp (atype, "N3+") ||
11505
              (!strcmp (atype, "NAM") && atom[i].arom == false))
10456
                (!strcmp (atype, "NAM") && atom[i].arom == false))
11506
            /* v0.3n */
10457
              /* v0.3n */
11507
            molstat.n_N3++;
10458
              molstat.n_N3++;
11508
          if (!strcmp (elem, "A "))     /* query atom */
10459
            if (!strcmp (elem, "A "))   /* query atom */
11509
            molstat.n_QA++;
10460
              molstat.n_QA++;
11510
          if (!strcmp (elem, "Q "))     /* query atom */
10461
            if (!strcmp (elem, "Q "))   /* query atom */
11511
            molstat.n_QA++;
10462
              molstat.n_QA++;
11512
          if (!strcmp (elem, "X "))     /* query atom */
10463
            if (!strcmp (elem, "X "))   /* query atom */
11513
            molstat.n_QA++;
10464
              molstat.n_QA++;
11514
          if (!strcmp (elem, "S "))
10465
            if (!strcmp (elem, "S "))
11515
            molstat.n_S++;
10466
              molstat.n_S++;
11516
          if (!strcmp (elem, "SE"))
10467
            if (!strcmp (elem, "SE"))
11517
            molstat.n_SeTe++;
-
 
11518
          if (!strcmp (elem, "TE"))
-
 
11519
            molstat.n_SeTe++;
10468
            molstat.n_SeTe++;
-
 
10469
            if (!strcmp (elem, "TE"))
-
 
10470
              molstat.n_SeTe++;
11520
          if (!strcmp (elem, "F "))
10471
            if (!strcmp (elem, "F "))
11521
            molstat.n_F++;
10472
              molstat.n_F++;
11522
          if (!strcmp (elem, "CL"))
10473
            if (!strcmp (elem, "CL"))
11523
            molstat.n_Cl++;
10474
              molstat.n_Cl++;
11524
          if (!strcmp (elem, "BR"))
10475
            if (!strcmp (elem, "BR"))
11525
            molstat.n_Br++;
10476
              molstat.n_Br++;
11526
          if (!strcmp (elem, "I "))
10477
            if (!strcmp (elem, "I "))
11527
            molstat.n_I++;
10478
              molstat.n_I++;
11528
          if (!strcmp (elem, "P "))
10479
            if (!strcmp (elem, "P "))
11529
            molstat.n_P++;
10480
              molstat.n_P++;
11530
          if (!strcmp (elem, "B "))
10481
            if (!strcmp (elem, "B "))
11531
            molstat.n_B++;
10482
              molstat.n_B++;
11532
          /* check for known metals */
10483
            /* check for known metals */
11533
          if (atom[i].metal)    /* v0.3l */
10484
            if (atom[i].metal)  /* v0.3l */
11534
            molstat.n_Met++;
10485
              molstat.n_Met++;
11535
          /* still missing: unknown elements */
10486
            /* still missing: unknown elements */
11536
 
10487
 
11537
          /* check number of heteroatom bonds per C atom */
10488
            /* check number of heteroatom bonds per C atom */
11538
          if (!strcmp (elem, "C "))
10489
            if (!strcmp (elem, "C ")) {
11539
            {
-
 
11540
              hbc = raw_hetbond_count (i + 1);
10490
              hbc = raw_hetbond_count (i + 1);
11541
              /* new in v0.2j (replaces hetbond_count) */
10491
              /* new in v0.2j (replaces hetbond_count) */
11542
              if (hbc >= 1)
10492
              if (hbc >= 1)
11543
                molstat.n_CHB1p++;
10493
                      molstat.n_CHB1p++;
11544
              if (hbc >= 2)
10494
              if (hbc >= 2)
11545
                molstat.n_CHB2p++;
10495
                      molstat.n_CHB2p++;
11546
              if (hbc >= 3)
10496
              if (hbc >= 3)
11547
                molstat.n_CHB3p++;
10497
                      molstat.n_CHB3p++;
11548
              if (hbc == 4)
10498
              if (hbc == 4)
11549
                molstat.n_CHB4++;
10499
                      molstat.n_CHB4++;
11550
            }
10500
            }
11551
          if (atom[i].formal_charge != 0)
10501
            if (atom[i].formal_charge != 0) {
11552
            {
-
 
11553
              molstat.n_chg++;
10502
              molstat.n_chg++;
11554
              //n_charges++;
10503
              //n_charges++;
11555
            }
10504
            }
11556
          if (atom[i].nucleon_number != 0)
10505
            if (atom[i].nucleon_number != 0) {
11557
            {
-
 
11558
              molstat.n_iso++;
10506
              molstat.n_iso++;
11559
            }
10507
            }
11560
          if (atom[i].radical_type != 0)
10508
            if (atom[i].radical_type != 0) {
11561
            {
-
 
11562
              molstat.n_rad++;
10509
              molstat.n_rad++;
11563
            }
10510
            }
11564
          /* check for "other" elements;  v0.3l */
10511
            /* check for "other" elements;  v0.3l */
11565
          if (!atom[i].metal && strcmp (elem, "C ") && strcmp (elem, "N ")
10512
            if (!atom[i].metal && strcmp (elem, "C ") && strcmp (elem, "N ")
11566
              && strcmp (elem, "O ") && strcmp (elem, "S ")
10513
                && strcmp (elem, "O ") && strcmp (elem, "S ")
11567
              && strcmp (elem, "SE") && strcmp (elem, "TE")
10514
                && strcmp (elem, "SE") && strcmp (elem, "TE")
11568
              && strcmp (elem, "P ") && strcmp (elem, "B ")
10515
                && strcmp (elem, "P ") && strcmp (elem, "B ")
11569
              && strcmp (elem, "A ") && strcmp (elem, "Q "))
10516
                && strcmp (elem, "A ") && strcmp (elem, "Q "))
11570
            molstat.n_X++;
10517
              molstat.n_X++;
11571
          /*(elem = 'F ') or (elem = 'CL') or (elem = 'BR') or (elem = 'I ') or  (* leave halogens as type X, v0.3m */
10518
            /*(elem = 'F ') or (elem = 'CL') or (elem = 'BR') or (elem = 'I ') or  (* leave halogens as type X, v0.3m */
11572
/* p2c: checkmol.pas, line 8353:
10519
      /* p2c: checkmol.pas, line 8353:
11573
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
10520
        * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11574
          /*$IFDEF extended_molstat */
10521
            /*$IFDEF extended_molstat */
11575
          if (!strcmp (elem, "LI") || !strcmp (elem, "NA")
10522
            if (!strcmp (elem, "LI") || !strcmp (elem, "NA")
11576
              || !strcmp (elem, "K ") || !strcmp (elem, "RB")
10523
                || !strcmp (elem, "K ") || !strcmp (elem, "RB")
11577
              || !strcmp (elem, "CS") || !strcmp (elem, "FR"))
10524
                || !strcmp (elem, "CS") || !strcmp (elem, "FR"))
11578
            molstat.n_psg01++;
10525
              molstat.n_psg01++;
11579
          if (!strcmp (elem, "BE") || !strcmp (elem, "MG")
10526
            if (!strcmp (elem, "BE") || !strcmp (elem, "MG")
11580
              || !strcmp (elem, "CA") || !strcmp (elem, "SR")
10527
                || !strcmp (elem, "CA") || !strcmp (elem, "SR")
11581
              || !strcmp (elem, "BA") || !strcmp (elem, "RA"))
10528
                || !strcmp (elem, "BA") || !strcmp (elem, "RA"))
11582
            molstat.n_psg02++;
10529
              molstat.n_psg02++;
11583
          if (!strcmp (elem, "B ") || !strcmp (elem, "AL")
10530
            if (!strcmp (elem, "B ") || !strcmp (elem, "AL")
11584
              || !strcmp (elem, "GA") || !strcmp (elem, "IN")
10531
                || !strcmp (elem, "GA") || !strcmp (elem, "IN")
11585
              || !strcmp (elem, "TL"))
10532
                || !strcmp (elem, "TL"))
11586
            molstat.n_psg13++;
10533
              molstat.n_psg13++;
11587
          if (!strcmp (elem, "C ") || !strcmp (elem, "SI")
10534
            if (!strcmp (elem, "C ") || !strcmp (elem, "SI")
11588
              || !strcmp (elem, "GE") || !strcmp (elem, "SN")
10535
                || !strcmp (elem, "GE") || !strcmp (elem, "SN")
11589
              || !strcmp (elem, "PB"))
10536
                || !strcmp (elem, "PB"))
11590
            molstat.n_psg14++;
10537
              molstat.n_psg14++;
11591
          if (!strcmp (elem, "N ") || !strcmp (elem, "P ")
10538
            if (!strcmp (elem, "N ") || !strcmp (elem, "P ")
11592
              || !strcmp (elem, "AS") || !strcmp (elem, "SB")
10539
              || !strcmp (elem, "AS") || !strcmp (elem, "SB")
11593
              || !strcmp (elem, "BI"))
10540
              || !strcmp (elem, "BI"))
11594
            molstat.n_psg15++;
10541
            molstat.n_psg15++;
11595
          if (!strcmp (elem, "O ") || !strcmp (elem, "S ")
10542
            if (!strcmp (elem, "O ") || !strcmp (elem, "S ")
11596
              || !strcmp (elem, "SE") || !strcmp (elem, "TE")
10543
                || !strcmp (elem, "SE") || !strcmp (elem, "TE")
11597
              || !strcmp (elem, "PO"))
10544
                || !strcmp (elem, "PO"))
11598
            molstat.n_psg16++;
10545
              molstat.n_psg16++;
11599
          if (!strcmp (elem, "F ") || !strcmp (elem, "CL")
10546
            if (!strcmp (elem, "F ") || !strcmp (elem, "CL")
11600
              || !strcmp (elem, "BR") || !strcmp (elem, "I ")
10547
                || !strcmp (elem, "BR") || !strcmp (elem, "I ")
11601
              || !strcmp (elem, "AT"))
10548
                || !strcmp (elem, "AT"))
11602
            molstat.n_psg17++;
10549
              molstat.n_psg17++;
11603
          if (!strcmp (elem, "HE") || !strcmp (elem, "NE")
10550
            if (!strcmp (elem, "HE") || !strcmp (elem, "NE")
11604
              || !strcmp (elem, "AR") || !strcmp (elem, "KR")
10551
                || !strcmp (elem, "AR") || !strcmp (elem, "KR")
11605
              || !strcmp (elem, "XE") || !strcmp (elem, "RN"))
10552
                || !strcmp (elem, "XE") || !strcmp (elem, "RN"))
11606
            molstat.n_psg18++;
10553
              molstat.n_psg18++;
11607
          if (!strcmp (elem, "SC") || !strcmp (elem, "Y ")
10554
            if (!strcmp (elem, "SC") || !strcmp (elem, "Y ")
11608
              || !strcmp (elem, "LU") || !strcmp (elem, "LR")
10555
                || !strcmp (elem, "LU") || !strcmp (elem, "LR")
11609
              || !strcmp (elem, "TI") || !strcmp (elem, "ZR")
10556
                || !strcmp (elem, "TI") || !strcmp (elem, "ZR")
11610
              || !strcmp (elem, "HF") || !strcmp (elem, "RF")
10557
                || !strcmp (elem, "HF") || !strcmp (elem, "RF")
11611
              || !strcmp (elem, "V ") || !strcmp (elem, "NB")
10558
                || !strcmp (elem, "V ") || !strcmp (elem, "NB")
11612
              || !strcmp (elem, "TA") || !strcmp (elem, "DB")
10559
                || !strcmp (elem, "TA") || !strcmp (elem, "DB")
11613
              || !strcmp (elem, "CR") || !strcmp (elem, "MO")
10560
                || !strcmp (elem, "CR") || !strcmp (elem, "MO")
11614
              || !strcmp (elem, "W ") || !strcmp (elem, "SG")
10561
                || !strcmp (elem, "W ") || !strcmp (elem, "SG")
11615
              || !strcmp (elem, "MN") || !strcmp (elem, "TC")
10562
                || !strcmp (elem, "MN") || !strcmp (elem, "TC")
11616
              || !strcmp (elem, "RE") || !strcmp (elem, "BH")
10563
                || !strcmp (elem, "RE") || !strcmp (elem, "BH")
11617
              || !strcmp (elem, "FE") || !strcmp (elem, "RU")
10564
                || !strcmp (elem, "FE") || !strcmp (elem, "RU")
11618
              || !strcmp (elem, "OS") || !strcmp (elem, "HS")
10565
                || !strcmp (elem, "OS") || !strcmp (elem, "HS")
11619
              || !strcmp (elem, "CO") || !strcmp (elem, "RH")
10566
                || !strcmp (elem, "CO") || !strcmp (elem, "RH")
11620
              || !strcmp (elem, "IR") || !strcmp (elem, "MT")
10567
                || !strcmp (elem, "IR") || !strcmp (elem, "MT")
11621
              || !strcmp (elem, "NI") || !strcmp (elem, "PD")
10568
                || !strcmp (elem, "NI") || !strcmp (elem, "PD")
11622
              || !strcmp (elem, "PT") || !strcmp (elem, "DS")
10569
                || !strcmp (elem, "PT") || !strcmp (elem, "DS")
11623
              || !strcmp (elem, "CU") || !strcmp (elem, "AG")
10570
                || !strcmp (elem, "CU") || !strcmp (elem, "AG")
11624
              || !strcmp (elem, "AU") || !strcmp (elem, "RG")
10571
                || !strcmp (elem, "AU") || !strcmp (elem, "RG")
11625
              || !strcmp (elem, "ZN") || !strcmp (elem, "CD")
10572
                || !strcmp (elem, "ZN") || !strcmp (elem, "CD")
11626
              || !strcmp (elem, "HG"))
10573
                || !strcmp (elem, "HG"))
11627
/* p2c: checkmol.pas, line 8439:
10574
        /* p2c: checkmol.pas, line 8439:
11628
 * Note: Line breaker spent 0.0 seconds, 5000 tries on line 10035 [251] */
10575
        * Note: Line breaker spent 0.0 seconds, 5000 tries on line 10035 [251] */
11629
            molstat.n_pstm++;
10576
              molstat.n_pstm++;
11630
          if (!strcmp (elem, "LA") || !strcmp (elem, "CE")
10577
            if (!strcmp (elem, "LA") || !strcmp (elem, "CE")
11631
              || !strcmp (elem, "PR") || !strcmp (elem, "ND")
10578
                || !strcmp (elem, "PR") || !strcmp (elem, "ND")
11632
              || !strcmp (elem, "PM") || !strcmp (elem, "SM")
10579
                || !strcmp (elem, "PM") || !strcmp (elem, "SM")
11633
              || !strcmp (elem, "EU") || !strcmp (elem, "GD")
10580
                || !strcmp (elem, "EU") || !strcmp (elem, "GD")
11634
              || !strcmp (elem, "TB") || !strcmp (elem, "DY")
10581
                || !strcmp (elem, "TB") || !strcmp (elem, "DY")
11635
              || !strcmp (elem, "HO") || !strcmp (elem, "ER")
10582
                || !strcmp (elem, "HO") || !strcmp (elem, "ER")
11636
              || !strcmp (elem, "TM") || !strcmp (elem, "YB")
10583
                || !strcmp (elem, "TM") || !strcmp (elem, "YB")
11637
              || !strcmp (elem, "AC") || !strcmp (elem, "TH")
10584
                || !strcmp (elem, "AC") || !strcmp (elem, "TH")
11638
              || !strcmp (elem, "PA") || !strcmp (elem, "U ")
10585
                || !strcmp (elem, "PA") || !strcmp (elem, "U ")
11639
              || !strcmp (elem, "NP") || !strcmp (elem, "PU")
10586
                || !strcmp (elem, "NP") || !strcmp (elem, "PU")
11640
              || !strcmp (elem, "AM") || !strcmp (elem, "CM")
10587
                || !strcmp (elem, "AM") || !strcmp (elem, "CM")
11641
              || !strcmp (elem, "BK") || !strcmp (elem, "CF")
10588
                || !strcmp (elem, "BK") || !strcmp (elem, "CF")
11642
              || !strcmp (elem, "ES") || !strcmp (elem, "FM")
10589
                || !strcmp (elem, "ES") || !strcmp (elem, "FM")
11643
              || !strcmp (elem, "MD") || !strcmp (elem, "NO"))
10590
                || !strcmp (elem, "MD") || !strcmp (elem, "NO"))
11644
/* p2c: checkmol.pas, line 8439:
10591
      /* p2c: checkmol.pas, line 8439:
11645
 * Note: Line breaker spent 0.0 seconds, 5000 tries on line 10048 [251] */
10592
      * Note: Line breaker spent 0.0 seconds, 5000 tries on line 10048 [251] */
11646
            molstat.n_psla++;
10593
              molstat.n_psla++;
11647
          /*$ENDIF */
10594
            /*$ENDIF */
11648
        }                       /* is heavy */
10595
          }                     /* is heavy */
11649
    }                           /* atoms */
10596
  }                             /* atoms */
11650
  if (n_bonds > 0)
10597
  if (n_bonds > 0) {
11651
    {
-
 
11652
      FORLIM = n_bonds;
10598
    FORLIM = n_bonds;
11653
      for (i = 0; i < FORLIM; i++)
10599
    for (i = 0; i < FORLIM; i++) {
11654
        {
-
 
11655
          a1 = bond[i].a1;
10600
            a1 = bond[i].a1;
11656
          a2 = bond[i].a2;
10601
            a2 = bond[i].a2;
11657
          strcpy (a1el, atom[a1 - 1].element);
10602
            strcpy (a1el, atom[a1 - 1].element);
11658
          strcpy (a2el, atom[a2 - 1].element);
10603
            strcpy (a2el, atom[a2 - 1].element);
11659
          btype = bond[i].btype;
10604
            btype = bond[i].btype;
11660
          if (bond[i].arom)
10605
            if (bond[i].arom)
11661
            molstat.n_bar++;
10606
              molstat.n_bar++;
11662
          else
10607
            else {
11663
            {
-
 
11664
              if (btype == 'S' && atom[a1 - 1].heavy && atom[a2 - 1].heavy)
10608
              if (btype == 'S' && atom[a1 - 1].heavy && atom[a2 - 1].heavy)
11665
                molstat.n_b1++;
10609
                      molstat.n_b1++;
11666
              if (btype == 'D')
10610
              if (btype == 'D')
11667
                molstat.n_b2++;
10611
                     molstat.n_b2++;
11668
              if (btype == 'T')
10612
              if (btype == 'T')
11669
                molstat.n_b3++;
10613
                      molstat.n_b3++;
11670
            }
10614
            }
11671
          /* v0.3n: ignore bonds to (explicit) hydrogens */
10615
            /* v0.3n: ignore bonds to (explicit) hydrogens */
11672
          if ((!strcmp (a1el, "C ") && !strcmp (a2el, "O ")) ||
10616
            if ((!strcmp (a1el, "C ") && !strcmp (a2el, "O ")) ||
11673
              (!strcmp (a1el, "O ") && !strcmp (a2el, "C ")))
10617
                (!strcmp (a1el, "O ") && !strcmp (a2el, "C "))) {
11674
            {
-
 
11675
              if (btype == 'S')
10618
              if (btype == 'S')
11676
                molstat.n_C1O++;
10619
                      molstat.n_C1O++;
11677
              if (btype == 'D')
10620
              if (btype == 'D')
11678
                molstat.n_C2O++;
10621
                      molstat.n_C2O++;
11679
            }
10622
            }
11680
          if ((!strcmp (a1el, "C ") && !strcmp (a2el, "N ")) ||
10623
            if ((!strcmp (a1el, "C ") && !strcmp (a2el, "N ")) ||
11681
              (!strcmp (a1el, "N ") && !strcmp (a2el, "C ")))
10624
                (!strcmp (a1el, "N ") && !strcmp (a2el, "C ")))
11682
            molstat.n_CN++;
10625
              molstat.n_CN++;
11683
          if (strcmp (a1el, "C ") && atom[a1 - 1].heavy
10626
            if (strcmp (a1el, "C ") && atom[a1 - 1].heavy
11684
              && strcmp (a2el, "C ") && atom[a2 - 1].heavy)
10627
                && strcmp (a2el, "C ") && atom[a2 - 1].heavy)
11685
            molstat.n_XY++;
10628
              molstat.n_XY++;
11686
          /* new in v0.3n: number of bonds belonging to more than one ring */
10629
            /* new in v0.3n: number of bonds belonging to more than one ring */
11687
          if (bond[i].ring_count > 1)
10630
            if (bond[i].ring_count > 1)
11688
            molstat.n_br2p++;
10631
              molstat.n_br2p++;
11689
        }
10632
          }
11690
    }                           /* bonds */
10633
  }                             /* bonds */
11691
  if (n_rings <= 0)
10634
  if (n_rings <= 0) {
11692
    {
-
 
11693
      return;
10635
      return;
11694
    }                           /* rings */
10636
  }                             /* rings */
11695
  /* v0.3n */
10637
  /* v0.3n */
11696
  n_countablerings = 0;         /* v0.3n */
10638
  n_countablerings = 0;         /* v0.3n */
11697
  FORLIM = n_rings;
10639
  FORLIM = n_rings;
11698
  for (i = 1; i <= FORLIM; i++)
10640
  for (i = 1; i <= FORLIM; i++) {
11699
    {
-
 
11700
      if (ringprop[i - 1].envelope == false)    /* v0.3n */
10641
    if (ringprop[i - 1].envelope == false)      /* v0.3n */
11701
        n_countablerings++;
10642
            n_countablerings++;
11702
      if (is_arene (i) && ringprop[i - 1].envelope == false)
10643
    if (is_arene (i) && ringprop[i - 1].envelope == false) {
11703
        {                       /* v0.3n: ignore envelope rings */
10644
      /* v0.3n: ignore envelope rings */
11704
          molstat.n_rAr++;
10645
            molstat.n_rAr++;
11705
          if ((ringprop[i - 1].size == 6) && (is_heterocycle (i) == false))
10646
            if ((ringprop[i - 1].size == 6) && (is_heterocycle (i) == false))
11706
            /* v0.3l */
10647
              /* v0.3l */
11707
            molstat.n_rBz++;
10648
              molstat.n_rBz++;
11708
        }
10649
          }
11709
      get_ringstat (i);
10650
    get_ringstat (i);
11710
      if (ringprop[i - 1].arom == true && ringprop[i - 1].envelope == false)
10651
    if (ringprop[i - 1].arom == true && ringprop[i - 1].envelope == false)
11711
        /* new in v0.3n; replaces assignment below */
10652
            /* new in v0.3n; replaces assignment below */
11712
        n_b2formal++;
10653
            n_b2formal++;
11713
    }
10654
  }
11714
  /*n_b2formal := n_rar;  (* new in v0.2e; adds 1 formal double bond for each aromatic ring */
10655
  /*n_b2formal := n_rar;  (* new in v0.2e; adds 1 formal double bond for each aromatic ring */
11715
  /* in order to allow an isolated double bond in the needle */
10656
  /* in order to allow an isolated double bond in the needle */
11716
  /* to be matched as a ring fragment of an aromatic ring */
10657
  /* to be matched as a ring fragment of an aromatic ring */
11717
  if (n_b2formal > molstat.n_bar / 2)
10658
  if (n_b2formal > molstat.n_bar / 2)
11718
    n_b2formal = molstat.n_bar / 2;
10659
    n_b2formal = molstat.n_bar / 2;
11719
  molstat.n_b2 += n_b2formal;
10660
  molstat.n_b2 += n_b2formal;
11720
}
10661
}
11721
 
10662
 
11722
 
-
 
11723
static void
-
 
11724
fix_ssr_ringcounts ()
10663
static void fix_ssr_ringcounts ()
11725
{
10664
{
11726
  /* new in v0.3n */
10665
  /* new in v0.3n */
11727
  /* if SAR -> SSR fallback happens, set some molstat values */
10666
  /* if SAR -> SSR fallback happens, set some molstat values */
11728
  /* to a maximum (ring counts for various ring sizes); */
10667
  /* to a maximum (ring counts for various ring sizes); */
11729
  /* this should be necessary only for ring sizes which */
10668
  /* this should be necessary only for ring sizes which */
Line 11749... Line 10688...
11749
    molstat.n_r12 = max_rings;
10688
    molstat.n_r12 = max_rings;
11750
  if (molstat.n_r13p == 0)
10689
  if (molstat.n_r13p == 0)
11751
    molstat.n_r13p = max_rings;
10690
    molstat.n_r13p = max_rings;
11752
}
10691
}
11753
 
10692
 
11754
 
-
 
11755
 
-
 
11756
static void
-
 
11757
write_molstat ()
10693
static void write_molstat ()
11758
{
10694
{
11759
  if (auto_ssr)                 /* v0.3n */
10695
  if (auto_ssr)                 /* v0.3n */
11760
    fix_ssr_ringcounts ();
10696
    fix_ssr_ringcounts ();
11761
  printf ("n_atoms:%d;", n_heavyatoms);
10697
  printf ("n_atoms:%d;", n_heavyatoms);
11762
  /* count only non-H atoms (some molfiles contain explicit H's) */
10698
  /* count only non-H atoms (some molfiles contain explicit H's) */
11763
  if (n_bonds > 0)              /* count only bonds between non-H atoms */
10699
  if (n_bonds > 0)              /* count only bonds between non-H atoms */
11764
    printf ("n_bonds:%d;", n_heavybonds);
10700
    printf ("n_bonds:%d;", n_heavybonds);
11765
/* p2c: checkmol.pas, line 8471:
10701
  /* p2c: checkmol.pas, line 8471:
11766
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
10702
  * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11767
#ifdef REDUCED_SAR
10703
#ifdef REDUCED_SAR
11768
  if (n_rings > 0)              /* changed to non-envelope rings in v0.3n */
10704
  if (n_rings > 0)              /* changed to non-envelope rings in v0.3n */
11769
    printf ("n_rings:%d;", n_countablerings);
10705
    printf ("n_rings:%d;", n_countablerings);
11770
#else
10706
#else
11771
  if (n_rings > 0)              /* changed to non-envelope rings in v0.3n */
10707
  if (n_rings > 0)              /* changed to non-envelope rings in v0.3n */
Line 11913... Line 10849...
11913
    printf ("n_rad:%d;", molstat.n_rad);
10849
    printf ("n_rad:%d;", molstat.n_rad);
11914
  /*$ENDIF */
10850
  /*$ENDIF */
11915
  putchar ('\n');
10851
  putchar ('\n');
11916
}
10852
}
11917
 
10853
 
11918
 
-
 
11919
static void
-
 
11920
write_molstat_X ()
10854
static void write_molstat_X ()
11921
{
10855
{
11922
  if (auto_ssr)                 /* v0.3n */
10856
  if (auto_ssr)                 /* v0.3n */
11923
    fix_ssr_ringcounts ();
10857
    fix_ssr_ringcounts ();
11924
/* p2c: checkmol.pas, line 8556:
10858
    /* p2c: checkmol.pas, line 8556:
11925
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
10859
    * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11926
#ifdef REDUCED_SAR
10860
#ifdef REDUCED_SAR
11927
  printf ("%d,", n_heavyatoms);
10861
  printf ("%d,", n_heavyatoms);
11928
  printf ("%d,", n_heavybonds);
10862
  printf ("%d,", n_heavybonds);
11929
  printf ("%d,", n_countablerings);
10863
  printf ("%d,", n_countablerings);
11930
  /* v0.3n: n_rings =?> n_countablerings */
10864
    /* v0.3n: n_rings =?> n_countablerings */
11931
#else
10865
#else
11932
  printf ("%d,", n_heavyatoms);
10866
  printf ("%d,", n_heavyatoms);
11933
  printf ("%d,", n_heavybonds);
10867
  printf ("%d,", n_heavybonds);
11934
  printf ("%d,", n_rings);      /* v0.3n: n_rings ==> n_countablerings */
10868
  printf ("%d,", n_rings);      /* v0.3n: n_rings ==> n_countablerings */
11935
#endif
10869
#endif
11936
  printf ("%d,", molstat.n_QA);
10870
  printf ("%d,", molstat.n_QA);
11937
  printf ("%d,", molstat.n_QB);
10871
  printf ("%d,", molstat.n_QB);
11938
 
10872
 
11939
  /* 0.3x */
10873
  /* 0.3x */
11940
  printf ("%d,", molstat.n_chg);
10874
  printf ("%d,", molstat.n_chg);
11941
 
-
 
11942
 
10875
 
11943
  printf ("%d,", molstat.n_C1);
10876
  printf ("%d,", molstat.n_C1);
11944
  printf ("%d,", molstat.n_C2);
10877
  printf ("%d,", molstat.n_C2);
11945
  printf ("%d,", molstat.n_C);
10878
  printf ("%d,", molstat.n_C);
11946
  printf ("%d,", molstat.n_CHB1p);
10879
  printf ("%d,", molstat.n_CHB1p);
Line 11989... Line 10922...
11989
  printf ("%d,", molstat.n_rO1);
10922
  printf ("%d,", molstat.n_rO1);
11990
  printf ("%d,", molstat.n_rO2p);
10923
  printf ("%d,", molstat.n_rO2p);
11991
  printf ("%d,", molstat.n_rS);
10924
  printf ("%d,", molstat.n_rS);
11992
  printf ("%d,", molstat.n_rX);
10925
  printf ("%d,", molstat.n_rX);
11993
  printf ("%d", molstat.n_rAr);
10926
  printf ("%d", molstat.n_rAr);
11994
/* p2c: checkmol.pas, line 8579:
10927
  /* p2c: checkmol.pas, line 8579:
11995
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
10928
  * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11996
  /*$IFDEF extended_molstat */
10929
  /*$IFDEF extended_molstat */
11997
  printf (",%d", molstat.n_rBz);
10930
  printf (",%d", molstat.n_rBz);
11998
  printf (",%d", molstat.n_br2p);
10931
  printf (",%d", molstat.n_br2p);
11999
  printf (",%d", molstat.n_psg01);
10932
  printf (",%d", molstat.n_psg01);
12000
  printf (",%d", molstat.n_psg02);
10933
  printf (",%d", molstat.n_psg02);
Line 12008... Line 10941...
12008
  printf (",%d", molstat.n_psla);
10941
  printf (",%d", molstat.n_psla);
12009
  printf (",%d", molstat.n_iso);
10942
  printf (",%d", molstat.n_iso);
12010
  printf (",%d\n", molstat.n_rad);
10943
  printf (",%d\n", molstat.n_rad);
12011
  /*$ENDIF */
10944
  /*$ENDIF */
12012
}
10945
}
12013
 
-
 
12014
 
10946
 
12015
/* routines for substructure matching */
10947
/* routines for substructure matching */
12016
 
10948
 
12017
 
-
 
12018
static int
-
 
12019
find_ndl_ref_atom ()
10949
static int find_ndl_ref_atom ()
12020
{
10950
{
12021
  int i;
10951
  int i;
12022
  int score = -1, index = 0;
10952
  int score = -1, index = 0;
12023
  int n_nb, n_hc, FORLIM;
10953
  int n_nb, n_hc, FORLIM;
12024
 
10954
 
Line 12033... Line 10963...
12033
  /* refined in v0.3f: exclude only alkene-C as reference atoms */
10963
  /* refined in v0.3f: exclude only alkene-C as reference atoms */
12034
  /* added in v0.3o: needle atom must be "tagged" in order to be */
10964
  /* added in v0.3o: needle atom must be "tagged" in order to be */
12035
  /* selected (prevents unconnected fragments from being overlooked) */
10965
  /* selected (prevents unconnected fragments from being overlooked) */
12036
  if (ndl_n_atoms == 0)
10966
  if (ndl_n_atoms == 0)
12037
    return false;
10967
    return false;
12038
  if (ez_search && ndl_n_heavyatoms > 2)
10968
  if (ez_search && ndl_n_heavyatoms > 2) {
12039
    {
-
 
12040
      FORLIM = ndl_n_atoms;
10969
    FORLIM = ndl_n_atoms;
12041
      for (i = 1; i <= FORLIM; i++)
-
 
12042
        {                       /* ignore sp2-carbons if not aromatic */
10970
    for (i = 1; i <= FORLIM; i++) {                     /* ignore sp2-carbons if not aromatic */
12043
          /*if ((ndl_atom^[i].atype <> 'C2 ') or (ndl_atom^[i].arom = true)) then */
10971
           /*if ((ndl_atom^[i].atype <> 'C2 ') or (ndl_atom^[i].arom = true)) then */
12044
          if (ndl_alkene_C (i) == false && ndl_atom[i - 1].tag)
10972
            if (ndl_alkene_C (i) == false && ndl_atom[i - 1].tag) {                     /* v0.3o */
12045
            {                   /* v0.3o */
-
 
12046
              n_nb = ndl_atom[i - 1].neighbor_count;
10973
              n_nb = ndl_atom[i - 1].neighbor_count;
12047
              n_hc = ndl_hetatom_count (i);
10974
              n_hc = ndl_hetatom_count (i);
12048
              if (n_nb * 11 + n_hc * 7 > score && ndl_atom[i - 1].heavy)
10975
              if (n_nb * 11 + n_hc * 7 > score && ndl_atom[i - 1].heavy) {
12049
                {
-
 
12050
                  /* v0.3j */
10976
                /* v0.3j */
12051
                  index = i;
10977
                index = i;
12052
                  score = n_nb * 11 + n_hc * 7; /* changed in v0.3j */
10978
                score = n_nb * 11 + n_hc * 7;   /* changed in v0.3j */
12053
                }
10979
              }
12054
            }
10980
            }
12055
        }
10981
          }
12056
    }
10982
  }
12057
  /* it is possible that no suitable reference atom has been found here */
10983
  /* it is possible that no suitable reference atom has been found here */
12058
  /* (e.g., with "pure" polyenes), so we need a fallback option anyway */
10984
  /* (e.g., with "pure" polyenes), so we need a fallback option anyway */
12059
  if (index == 0)
10985
  if (index == 0) {
12060
    {
-
 
12061
      ez_search = false;        /* just in case it was true */
10986
    ez_search = false;  /* just in case it was true */
12062
      opt_geom = false;         /* just in case it was true */
10987
    opt_geom = false;           /* just in case it was true */
12063
      FORLIM = ndl_n_atoms;
10988
    FORLIM = ndl_n_atoms;
12064
      for (i = 1; i <= FORLIM; i++)
10989
    for (i = 1; i <= FORLIM; i++) {
12065
        {
-
 
12066
          n_nb = ndl_atom[i - 1].neighbor_count;
10990
            n_nb = ndl_atom[i - 1].neighbor_count;
12067
          n_hc = ndl_hetatom_count (i);
10991
            n_hc = ndl_hetatom_count (i);
12068
          if (n_nb * 11 + n_hc * 7 > score && ndl_atom[i - 1].heavy &&
10992
            if (n_nb * 11 + n_hc * 7 > score && ndl_atom[i - 1].heavy &&
12069
              ndl_atom[i - 1].tag)
10993
                ndl_atom[i - 1].tag) {                  /* v0.3j */
12070
            {                   /* v0.3j */
-
 
12071
              index = i;
10994
              index = i;
12072
              score = n_nb * 11 + n_hc * 7;     /* changed in v0.3j */
10995
              score = n_nb * 11 + n_hc * 7;     /* changed in v0.3j */
12073
            }
10996
            }
12074
          /* v0.3o */
10997
            /* v0.3o */
12075
        }
10998
          }
12076
    }
10999
  }
12077
  /* now index must be > 0 in any case (except for H2, or all tags have been cleared) */
11000
  /* now index must be > 0 in any case (except for H2, or all tags have been cleared) */
12078
  if (index == 0)               /* just to be sure... */
11001
  if (index == 0)               /* just to be sure... */
12079
    index++;
11002
    index++;
12080
  return index;
11003
  return index;
12081
}
11004
}
12082
 
11005
 
12083
 
-
 
12084
static void
11006
static void cv_init ()
12085
cv_init ()
-
 
12086
{
11007
{
12087
  /* new in v0.3j */
11008
  /* new in v0.3j */
12088
  int i;
11009
  int i;
12089
 
11010
 
12090
  if (cv == NULL)
11011
  if (cv == NULL)
Line 12093... Line 11014...
12093
 
11014
 
12094
  for (i = 0; i < ndl_n_atoms; i++)
11015
  for (i = 0; i < ndl_n_atoms; i++)
12095
    cv[i].def = ndl_atom[i].neighbor_count;
11016
    cv[i].def = ndl_atom[i].neighbor_count;
12096
}
11017
}
12097
 
11018
 
12098
 
-
 
12099
static int
-
 
12100
cv_count ()
11019
static int cv_count ()
12101
{
11020
{
12102
  /* new in v0.3j, modified in v0.3m */
11021
  /* new in v0.3j, modified in v0.3m */
12103
  int i, j;
11022
  int i, j;
12104
  int cvlist[max_atoms];
11023
  int cvlist[max_atoms];
12105
  int cvdef;
11024
  int cvdef;
Line 12108... Line 11027...
12108
  int FORLIM;
11027
  int FORLIM;
12109
 
11028
 
12110
  if (cv == NULL)
11029
  if (cv == NULL)
12111
    return 0;
11030
    return 0;
12112
  memset (cvlist, 0, sizeof (int) * max_atoms);
11031
  memset (cvlist, 0, sizeof (int) * max_atoms);
12113
  FORLIM = ndl_n_atoms;
11032
  FORLIM = ndl_n_atoms;
12114
  for (i = 0; i < FORLIM; i++)
11033
  for (i = 0; i < FORLIM; i++) {
12115
    {
-
 
12116
      if (ndl_atom[i].heavy == true)
11034
    if (ndl_atom[i].heavy == true) {
12117
        {
-
 
12118
          cvdef = cv[i].def;
11035
            cvdef = cv[i].def;
12119
          isnew = true;
11036
            isnew = true;
12120
          if (entries > 0)
11037
            if (entries > 0) {
12121
            {
-
 
12122
              for (j = 0; j < entries; j++)
11038
              for (j = 0; j < entries; j++) {
12123
                {
-
 
12124
                  if (cvlist[j] == cvdef)
11039
                      if (cvlist[j] == cvdef)
12125
                    isnew = false;
11040
                        isnew = false;
12126
                }
11041
                    }
-
 
11042
            }
-
 
11043
            if (isnew) {
-
 
11044
                entries++;
-
 
11045
                cvlist[entries - 1] = cvdef;
12127
            }
11046
            }
12128
          if (isnew)
-
 
12129
            {
-
 
12130
              entries++;
-
 
12131
              cvlist[entries - 1] = cvdef;
-
 
12132
            }
-
 
12133
          /* now we have a list of unique connection values */
11047
            /* now we have a list of unique connection values */
12134
        }
11048
          }
12135
    }
11049
  }
12136
  return entries;
11050
  return entries;
12137
}
11051
}
12138
 
11052
 
12139
 
-
 
12140
static int
-
 
12141
cv_iterate (n_cv_prev)
11053
static int cv_iterate (n_cv_prev)
12142
     int n_cv_prev;
11054
     int n_cv_prev;
12143
{
11055
{
12144
  /* new in v0.3j, modified in v0.3m */
11056
  /* new in v0.3j, modified in v0.3m */
12145
  int i, j;
11057
  int i, j;
12146
  neighbor_rec nb;
11058
  neighbor_rec nb;
Line 12151... Line 11063...
12151
  FORLIM = ndl_n_atoms;
11063
  FORLIM = ndl_n_atoms;
12152
  /* update the connection values (Morgan algorithm) */
11064
  /* update the connection values (Morgan algorithm) */
12153
 
11065
 
12154
  memset (nb, 0, sizeof (neighbor_rec));
11066
  memset (nb, 0, sizeof (neighbor_rec));
12155
 
11067
 
12156
  for (i = 1; i <= FORLIM; i++)
11068
  for (i = 1; i <= FORLIM; i++) {
12157
    {
-
 
12158
      if (ndl_atom[i - 1].heavy == true)
11069
    if (ndl_atom[i - 1].heavy == true) {
12159
        {
-
 
12160
          get_ndl_neighbors (nb, i);
11070
            get_ndl_neighbors (nb, i);
12161
          nnb = ndl_atom[i - 1].neighbor_count;
11071
            nnb = ndl_atom[i - 1].neighbor_count;
12162
          nsum = 0;
11072
            nsum = 0;
12163
          if (nnb > 0)
11073
            if (nnb > 0) {
12164
            {
-
 
12165
              for (j = 0; j < nnb; j++)
11074
              for (j = 0; j < nnb; j++) {
12166
                {
-
 
12167
                  if (ndl_atom[nb[j] - 1].heavy == true)
11075
                if (ndl_atom[nb[j] - 1].heavy == true)
12168
                    nsum += cv[nb[j] - 1].def;
11076
                  nsum += cv[nb[j] - 1].def;
12169
                }
11077
              }
12170
            }
11078
            }
12171
          cv[i - 1].tmp = nsum;
11079
            cv[i - 1].tmp = nsum;
12172
        }
11080
          }
12173
    }
11081
  }
12174
  n_cv = cv_count ();
11082
  n_cv = cv_count ();
12175
  if (n_cv > n_cv_prev)
11083
  if (n_cv > n_cv_prev) {
12176
    {
-
 
12177
      FORLIM = ndl_n_atoms;
11084
    FORLIM = ndl_n_atoms;
12178
      for (i = 0; i < FORLIM; i++)
11085
    for (i = 0; i < FORLIM; i++)
12179
        cv[i].def = cv[i].tmp;
11086
            cv[i].def = cv[i].tmp;
12180
    }
11087
  }
12181
  return n_cv;
11088
  return n_cv;
12182
}
11089
}
12183
 
11090
 
12184
 
-
 
12185
static int
-
 
12186
find_ndl_ref_atom_cv ()
11091
static int find_ndl_ref_atom_cv ()
12187
{
11092
{
12188
  /* new in v0.3j, modified in v0.3m */
11093
  /* new in v0.3j, modified in v0.3m */
12189
  int Result, i;
11094
  int Result, i;
12190
  int res = 1, it = 0;
11095
  int res = 1, it = 0;
12191
  int n_cv;
11096
  int n_cv;
Line 12206... Line 11111...
12206
     debugoutput('memory allocation for connection values failed, reverting to standard procedure');
11111
     debugoutput('memory allocation for connection values failed, reverting to standard procedure');
12207
     $ENDIF
11112
     $ENDIF
12208
     end;
11113
     end;
12209
     end; */
11114
     end; */
12210
  cv_init ();
11115
  cv_init ();
12211
  do
-
 
12212
    {
11116
  do {
12213
      it++;                     /* iteration counter (a safeguard against infinite loops) */
11117
    it++;                       /* iteration counter (a safeguard against infinite loops) */
12214
      n_cv = cv_iterate (n_cv_prev);
11118
    n_cv = cv_iterate (n_cv_prev);
12215
      if (n_cv <= n_cv_prev)
11119
    if (n_cv <= n_cv_prev)
12216
        finished = true;
11120
            finished = true;
12217
      n_cv_prev = n_cv;
11121
    n_cv_prev = n_cv;
12218
    }
11122
  }
12219
  while (!(finished || it > 10000));
11123
  while (!(finished || it > 10000));
12220
  FORLIM = ndl_n_atoms;
11124
  FORLIM = ndl_n_atoms;
12221
  /* now that we have canonical connection values (Morgan algorithm), */
11125
  /* now that we have canonical connection values (Morgan algorithm), */
12222
  /* pick the atom with the highest value */
11126
  /* pick the atom with the highest value */
12223
  /* added in v0.3o: atom must be "tagged" */
11127
  /* added in v0.3o: atom must be "tagged" */
12224
  for (i = 1; i <= FORLIM; i++)
11128
  for (i = 1; i <= FORLIM; i++) {
12225
    {
-
 
12226
      /*writeln('cv for atom ',i,': ',cv^[i].def); */
11129
      /*writeln('cv for atom ',i,': ',cv^[i].def); */
12227
      if (((cv[i - 1].def > cvmax) && (ndl_alkene_C (i) == false ||
11130
    if (((cv[i - 1].def > cvmax) && (ndl_alkene_C (i) == false || ez_search == false))
12228
                                       ez_search == false))
-
 
12229
          && ndl_atom[i - 1].tag)
11131
              && ndl_atom[i - 1].tag) {                 /* v0.3o */
12230
        {                       /* v0.3o */
-
 
12231
          cvmax = cv[i - 1].def;
11132
            cvmax = cv[i - 1].def;
12232
          res = i;
11133
            res = i;
12233
        }
11134
          }
12234
    }
11135
  }
12235
  Result = res;
11136
  Result = res;
12236
  /* try */
11137
  /* try */
12237
  if (cv != NULL)
11138
  if (cv != NULL) {
12238
    {
-
 
12239
      free (cv);
11139
      free (cv);
12240
      cv = NULL;
11140
      cv = NULL;
12241
    }
11141
    }
12242
  /* except
11142
  /* except
12243
     on e:Einvalidpointer do begin end;
11143
     on e:Einvalidpointer do begin end;
12244
     end; */
11144
     end; */
12245
  return Result;
11145
  return Result;
12246
}
11146
}
12247
 
11147
 
12248
 
-
 
12249
static boolean
-
 
12250
atomtypes_OK_strict (ndl_a, hst_a)
11148
static boolean atomtypes_OK_strict (ndl_a, hst_a)
12251
     int ndl_a, hst_a;
11149
     int ndl_a, hst_a;
12252
{
11150
{
12253
  /* new in v0.2f */
11151
  /* new in v0.2f */
12254
  str2 ndl_el;
11152
  str2 ndl_el;
12255
  str3 ndl_atype;
11153
  str3 ndl_atype;
Line 12262... Line 11160...
12262
  strcpy (ndl_atype, ndl_atom[ndl_a - 1].atype);
11160
  strcpy (ndl_atype, ndl_atom[ndl_a - 1].atype);
12263
  ndl_nbc = ndl_atom[ndl_a - 1].neighbor_count;
11161
  ndl_nbc = ndl_atom[ndl_a - 1].neighbor_count;
12264
  ndl_Hexp = ndl_atom[ndl_a - 1].Hexp;
11162
  ndl_Hexp = ndl_atom[ndl_a - 1].Hexp;
12265
  strcpy (hst_el, atom[hst_a - 1].element);
11163
  strcpy (hst_el, atom[hst_a - 1].element);
12266
  strcpy (hst_atype, atom[hst_a - 1].atype);
11164
  strcpy (hst_atype, atom[hst_a - 1].atype);
12267
  hst_nbc = atom[hst_a - 1].neighbor_count;
11165
  hst_nbc = atom[hst_a - 1].neighbor_count;
12268
  hst_Htot = atom[hst_a - 1].Htot;
11166
  hst_Htot = atom[hst_a - 1].Htot;
12269
  /* v0.3o: formal charges must be the same */
11167
  /* v0.3o: formal charges must be the same */
12270
 
11168
 
12271
  if (ndl_atom[ndl_a - 1].formal_charge != atom[hst_a - 1].formal_charge)
11169
  if (ndl_atom[ndl_a - 1].formal_charge != atom[hst_a - 1].formal_charge)
12272
    return false;
11170
    return false;
12273
 
11171
 
12274
  /* v0.3x: isotope nucleon numbers must be the same */
11172
  /* v0.3x: isotope nucleon numbers must be the same */
12275
 
11173
 
12276
  if (ndl_atom[ndl_a - 1].nucleon_number != atom[hst_a - 1].nucleon_number)
11174
  if (ndl_atom[ndl_a - 1].nucleon_number != atom[hst_a - 1].nucleon_number)
12277
    return false;
11175
    return false;
12278
 
11176
 
12279
  /* v0.3x: radicals must be the same */
11177
  /* v0.3x: radicals must be the same */
12280
 
11178
 
12281
  if (ndl_atom[ndl_a - 1].radical_type != atom[hst_a - 1].radical_type)
11179
  if (ndl_atom[ndl_a - 1].radical_type != atom[hst_a - 1].radical_type)
12282
    return false;
11180
    return false;
12283
 
11181
 
12284
  if (!strcmp (ndl_atype, hst_atype))
11182
  if (!strcmp (ndl_atype, hst_atype))
12285
    res = true;
11183
    res = true;
12286
  else
11184
  else {
12287
    {
-
 
12288
      if (!strcmp (ndl_el, hst_el) && ndl_atom[ndl_a - 1].arom &&
11185
    if (!strcmp (ndl_el, hst_el) && ndl_atom[ndl_a - 1].arom && atom[hst_a - 1].arom)
12289
          atom[hst_a - 1].arom)
-
 
12290
        res = true;
11186
            res = true;
12291
      if (ndl_querymol
-
 
12292
          && (ndl_atom[ndl_a - 1].q_arom && atom[hst_a - 1].arom))
11187
    if (ndl_querymol && (ndl_atom[ndl_a - 1].q_arom && atom[hst_a - 1].arom))
12293
        res = true;             /* 0.3 p */
11188
            res = true;         /* 0.3 p */
12294
    }
11189
  }
12295
  if (!strcmp (ndl_el, "A ") && atom[hst_a - 1].heavy)
11190
  if (!strcmp (ndl_el, "A ") && atom[hst_a - 1].heavy)
12296
    res = true;
11191
    res = true;
12297
  if (!strcmp (ndl_el, "Q "))
11192
  if (!strcmp (ndl_el, "Q ")) {
12298
    {
-
 
12299
      if (atom[hst_a - 1].heavy && strcmp (hst_el, "C "))
11193
    if (atom[hst_a - 1].heavy && strcmp (hst_el, "C "))
12300
        res = true;
11194
            res = true;
12301
    }
11195
  }
12302
  if (!strcmp (ndl_el, "X "))
11196
  if (!strcmp (ndl_el, "X ")) {
12303
    {
-
 
12304
      if (!strcmp (hst_el, "F ") || !strcmp (hst_el, "CL") ||
11197
    if (!strcmp (hst_el, "F ") || !strcmp (hst_el, "CL") ||
12305
          !strcmp (hst_el, "BR") || !strcmp (hst_el, "I ")
11198
            !strcmp (hst_el, "BR") || !strcmp (hst_el, "I ")
12306
          || !strcmp (hst_el, "AT"))
11199
            || !strcmp (hst_el, "AT"))
12307
        res = true;
11200
          res = true;
12308
    }
11201
  }
12309
  /* if needle atom has more substituents than haystack atom ==> no match */
11202
  /* if needle atom has more substituents than haystack atom ==> no match */
12310
  if (ndl_nbc > hst_nbc)
11203
  if (ndl_nbc > hst_nbc)
12311
    res = false;
11204
    res = false;
12312
  /* check for explicit hydrogens */
11205
  /* check for explicit hydrogens */
12313
  if (ndl_Hexp > hst_Htot)
11206
  if (ndl_Hexp > hst_Htot)
12314
    res = false;
11207
    res = false;
12315
/* p2c: checkmol.pas, line 8859:
11208
    /* p2c: checkmol.pas, line 8859:
12316
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11209
    * Note: Turbo Pascal conditional compilation directive was ignored [218] */
12317
  /*$IFDEF debug */
11210
    /*$IFDEF debug */
12318
  /* if res then debugoutput('atom types OK ('+inttostr(ndl_a)+'/'+inttostr(hst_a)+')')
11211
    /* if res then debugoutput('atom types OK ('+inttostr(ndl_a)+'/'+inttostr(hst_a)+')')
12319
     else debugoutput('atom types not OK ('+inttostr(ndl_a)+':'+ndl_atype+'/'+inttostr(hst_a)+':'+hst_atype+')'); */
11212
     else debugoutput('atom types not OK ('+inttostr(ndl_a)+':'+ndl_atype+'/'+inttostr(hst_a)+':'+hst_atype+')'); */
12320
  /*$ENDIF */
11213
    /*$ENDIF */
12321
  /* new in v0.3m: in "fingerprint mode", also query atom symbols must match */
11214
    /* new in v0.3m: in "fingerprint mode", also query atom symbols must match */
12322
  if (opt_fp)
11215
  if (opt_fp) {
12323
    {
-
 
12324
      if (strcmp (ndl_el, hst_el))
11216
    if (strcmp (ndl_el, hst_el))
12325
        res = false;
11217
            res = false;
12326
    }
11218
  }
12327
  return res;
11219
  return res;
12328
}
11220
}
12329
 
-
 
12330
 
11221
 
12331
static boolean
-
 
12332
atomtypes_OK (ndl_a, hst_a)
11222
static boolean atomtypes_OK (ndl_a, hst_a)
12333
     int ndl_a, hst_a;
11223
     int ndl_a, hst_a;
12334
{
11224
{
12335
  str2 ndl_el, hst_el;
11225
  str2 ndl_el, hst_el;
12336
  int ndl_nbc, hst_nbc, ndl_Hexp, hst_Htot;
11226
  int ndl_nbc, hst_nbc, ndl_Hexp, hst_Htot;
12337
  boolean res = false;
11227
  boolean res = false;
Line 12339... Line 11229...
12339
  if (ndl_a < 1 || ndl_a > ndl_n_atoms || hst_a < 1 || hst_a > n_atoms)
11229
  if (ndl_a < 1 || ndl_a > ndl_n_atoms || hst_a < 1 || hst_a > n_atoms)
12340
    return false;
11230
    return false;
12341
  /* check for opposite charges;  v0.3l, refined in v0.3o, 0.3x */
11231
  /* check for opposite charges;  v0.3l, refined in v0.3o, 0.3x */
12342
  /* except in strict mode, matching pairs of charged+uncharged atoms  */
11232
  /* except in strict mode, matching pairs of charged+uncharged atoms  */
12343
  /* are tolerated (this is a feature, not a bug) */
11233
  /* are tolerated (this is a feature, not a bug) */
12344
  if (opt_chg)
11234
  if (opt_chg) {
12345
    {
-
 
12346
      if (ndl_atom[ndl_a - 1].formal_charge != atom[hst_a - 1].formal_charge)
11235
    if (ndl_atom[ndl_a - 1].formal_charge != atom[hst_a - 1].formal_charge)
12347
        return false;
11236
        return false;
12348
    }
11237
  }
12349
//  else
11238
  //  else
12350
//    {
11239
  //    {
12351
//      if (ndl_atom[ndl_a - 1].formal_charge != 0 &&
11240
  //      if (ndl_atom[ndl_a - 1].formal_charge != 0 &&
12352
//        atom[hst_a - 1].formal_charge != 0 &&
11241
  //        atom[hst_a - 1].formal_charge != 0 &&
12353
//        ndl_atom[ndl_a - 1].formal_charge != atom[hst_a - 1].formal_charge)
11242
  //        ndl_atom[ndl_a - 1].formal_charge != atom[hst_a - 1].formal_charge)
12354
//      return false;
11243
  //      return false;
12355
//    }
11244
  //    }
12356
//
11245
  //
12357
//  /* v0.3x: isotopes must be the same */
11246
  //  /* v0.3x: isotopes must be the same */
12358
  if (opt_iso)
11247
  if (opt_iso) {
12359
    {
-
 
12360
      if (ndl_atom[ndl_a - 1].nucleon_number !=
11248
    if (ndl_atom[ndl_a - 1].nucleon_number != atom[hst_a - 1].nucleon_number)
12361
          atom[hst_a - 1].nucleon_number)
-
 
12362
        return false;
11249
            return false;
12363
    }
11250
  }
12364
//  else
11251
  //  else
12365
//    {
11252
  //    {
12366
//      if (ndl_atom[ndl_a - 1].nucleon_number != 0 &&
11253
  //      if (ndl_atom[ndl_a - 1].nucleon_number != 0 &&
12367
//        atom[hst_a - 1].nucleon_number != 0 &&
11254
  //        atom[hst_a - 1].nucleon_number != 0 &&
12368
//        ndl_atom[ndl_a - 1].nucleon_number !=
11255
  //        ndl_atom[ndl_a - 1].nucleon_number !=
12369
//        atom[hst_a - 1].nucleon_number)
11256
  //        atom[hst_a - 1].nucleon_number)
12370
//      return false;
11257
  //      return false;
12371
//    }
11258
  //    }
12372
//
11259
  //
12373
//  /* v0.3x: radicals must be the same */
11260
  //  /* v0.3x: radicals must be the same */
12374
  if (opt_rad)
11261
  if (opt_rad) {
12375
    {
-
 
12376
      if (ndl_atom[ndl_a - 1].radical_type != atom[hst_a - 1].radical_type)
11262
    if (ndl_atom[ndl_a - 1].radical_type != atom[hst_a - 1].radical_type)
12377
        return false;
11263
            return false;
12378
    }
11264
  }
12379
//  else
11265
  //  else
12380
//    {
11266
  //    {
12381
//      if (ndl_atom[ndl_a - 1].radical_type != 0 &&
11267
  //      if (ndl_atom[ndl_a - 1].radical_type != 0 &&
12382
//        atom[hst_a - 1].radical_type != 0 &&
11268
  //        atom[hst_a - 1].radical_type != 0 &&
12383
//        ndl_atom[ndl_a - 1].radical_type != atom[hst_a - 1].radical_type)
11269
  //        ndl_atom[ndl_a - 1].radical_type != atom[hst_a - 1].radical_type)
12384
//      return false;
11270
  //      return false;
12385
//    }
11271
  //    }
12386
 
11272
 
12387
  /* in exact mode, check if (disconnected) fragment is already tagged; v0.3o */
11273
  /* in exact mode, check if (disconnected) fragment is already tagged; v0.3o */
12388
  if (opt_exact && atom[hst_a - 1].tag == true)
11274
  if (opt_exact && atom[hst_a - 1].tag == true) {
12389
    {
-
 
12390
/* p2c: checkmol.pas, line 8899:
11275
    /* p2c: checkmol.pas, line 8899:
12391
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11276
  * Note: Turbo Pascal conditional compilation directive was ignored [218] */
12392
      /*$IFDEF debug */
11277
      /*$IFDEF debug */
12393
      /* debugoutput('fragmnet already tagged at '+inttostr(hst_a)); */
11278
      /* debugoutput('fragmnet already tagged at '+inttostr(hst_a)); */
12394
      /*$ENDIF */
11279
      /*$ENDIF */
12395
      return false;
11280
      return false;
12396
    }
11281
  }
12397
  if (opt_strict)               /* new in v0.2f */
11282
  if (opt_strict)               /* new in v0.2f */
12398
    return (atomtypes_OK_strict (ndl_a, hst_a));
11283
    return (atomtypes_OK_strict (ndl_a, hst_a));
12399
  strcpy (ndl_el, ndl_atom[ndl_a - 1].element);
11284
  strcpy (ndl_el, ndl_atom[ndl_a - 1].element);
12400
  ndl_nbc = ndl_atom[ndl_a - 1].neighbor_count;
11285
  ndl_nbc = ndl_atom[ndl_a - 1].neighbor_count;
12401
  ndl_Hexp = ndl_atom[ndl_a - 1].Hexp;
11286
  ndl_Hexp = ndl_atom[ndl_a - 1].Hexp;
12402
  strcpy (hst_el, atom[hst_a - 1].element);
11287
  strcpy (hst_el, atom[hst_a - 1].element);
12403
  hst_nbc = atom[hst_a - 1].neighbor_count;
11288
  hst_nbc = atom[hst_a - 1].neighbor_count;
12404
  hst_Htot = atom[hst_a - 1].Htot;
11289
  hst_Htot = atom[hst_a - 1].Htot;
12405
  if (!strcmp (ndl_el, hst_el)) /* very simplified... */
11290
  if (!strcmp (ndl_el, hst_el)) /* very simplified... */
12406
    res = true;
11291
    res = true;
12407
  if (!strcmp (ndl_el, "A ") && atom[hst_a - 1].heavy)
11292
  if (!strcmp (ndl_el, "A ") && atom[hst_a - 1].heavy)
12408
    res = true;
11293
    res = true;
12409
  if (!strcmp (ndl_el, "Q "))
11294
  if (!strcmp (ndl_el, "Q ")) {
12410
    {
-
 
12411
      if (atom[hst_a - 1].heavy && strcmp (hst_el, "C "))
11295
    if (atom[hst_a - 1].heavy && strcmp (hst_el, "C "))
12412
        res = true;
11296
            res = true;
12413
    }
11297
  }
12414
  if (!strcmp (ndl_el, "X "))
11298
  if (!strcmp (ndl_el, "X ")) {
12415
    {
-
 
12416
      if (!strcmp (hst_el, "F ") || !strcmp (hst_el, "CL") ||
11299
    if (!strcmp (hst_el, "F ") || !strcmp (hst_el, "CL") ||
12417
          !strcmp (hst_el, "BR") || !strcmp (hst_el, "I ")
11300
              !strcmp (hst_el, "BR") || !strcmp (hst_el, "I ")
12418
          || !strcmp (hst_el, "AT"))
11301
              || !strcmp (hst_el, "AT"))
12419
        res = true;
11302
            res = true;
12420
    }
11303
  }
12421
  /* v0.3o: in exact mode, check for identical neighbor_count */
11304
  /* v0.3o: in exact mode, check for identical neighbor_count */
12422
  if (opt_exact)
11305
  if (opt_exact) {
12423
    {
-
 
12424
      if (ndl_nbc != hst_nbc)
11306
    if (ndl_nbc != hst_nbc) {
12425
        {
-
 
12426
          res = false;
11307
          res = false;
12427
/* p2c: checkmol.pas, line 8934:
11308
    /* p2c: checkmol.pas, line 8934:
12428
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11309
     * Note: Turbo Pascal conditional compilation directive was ignored [218] */
12429
          /*$IFDEF debug */
11310
          /*$IFDEF debug */
12430
          //debugoutput
11311
          //debugoutput
12431
          //  ("exact match failed: different number of neighbor atoms");
11312
          //  ("exact match failed: different number of neighbor atoms");
12432
          /*$ENDIF */
11313
          /*$ENDIF */
12433
        }
11314
          }
12434
    }
11315
  }
12435
  /* if needle atom has more substituents than haystack atom ==> no match */
11316
  /* if needle atom has more substituents than haystack atom ==> no match */
12436
  if (ndl_nbc > hst_nbc)
11317
  if (ndl_nbc > hst_nbc)
12437
    res = false;
11318
    res = false;
12438
  /* check for explicit hydrogens */
11319
  /* check for explicit hydrogens */
12439
  if (ndl_Hexp > hst_Htot)
11320
  if (ndl_Hexp > hst_Htot)
12440
    res = false;
11321
    res = false;
12441
/* p2c: checkmol.pas, line 8943:
11322
  /* p2c: checkmol.pas, line 8943:
12442
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11323
  * Note: Turbo Pascal conditional compilation directive was ignored [218] */
12443
  /*$IFDEF debug */
11324
  /*$IFDEF debug */
12444
  /* if res then debugoutput('atom types OK ('+inttostr(ndl_a)+'/'+inttostr(hst_a)+')')
11325
  /* if res then debugoutput('atom types OK ('+inttostr(ndl_a)+'/'+inttostr(hst_a)+')')
12445
     else debugoutput('atom types not OK ('+inttostr(ndl_a)+'/'+inttostr(hst_a)+')'); */
11326
     else debugoutput('atom types not OK ('+inttostr(ndl_a)+'/'+inttostr(hst_a)+')'); */
12446
  /*$ENDIF */
11327
  /*$ENDIF */
12447
  return res;
11328
  return res;
12448
}
11329
}
12449
 
11330
 
12450
 
-
 
12451
static boolean
-
 
12452
bondtypes_OK_strict (ndl_b, hst_b)
11331
static boolean bondtypes_OK_strict (ndl_b, hst_b)
12453
     int ndl_b, hst_b;
11332
     int ndl_b, hst_b;
12454
{
11333
{
12455
  boolean ndl_arom, hst_arom;
11334
  boolean ndl_arom, hst_arom;
12456
  char ndl_btype, hst_btype;
11335
  char ndl_btype, hst_btype;
12457
  int ndl_rc;                   /* new in v0.3d */
11336
  int ndl_rc;                   /* new in v0.3d */
12458
  int hst_rc;                   /* new in v0.3d */
11337
  int hst_rc;                   /* new in v0.3d */
12459
  int ndl_btopo;                /* new in v0.3d */
11338
  int ndl_btopo;                /* new in v0.3d */
12460
  boolean res = false;
11339
  boolean res = false;
12461
/* p2c: checkmol.pas, line 8960:
11340
  /* p2c: checkmol.pas, line 8960:
12462
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11341
  * Note: Turbo Pascal conditional compilation directive was ignored [218] */
12463
  /*$IFDEF debug */
11342
  /*$IFDEF debug */
12464
  /*char na[256]; char ha[256];*/
11343
  /*char na[256]; char ha[256];*/
12465
  char tstr[256];
11344
  char tstr[256];
12466
 
11345
 
12467
  /*$ENDIF */
11346
  /*$ENDIF */
12468
/* p2c: checkmol.pas, line 8966:
11347
  /* p2c: checkmol.pas, line 8966:
12469
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11348
  * Note: Turbo Pascal conditional compilation directive was ignored [218] */
12470
  /*$IFDEF debug */
11349
  /*$IFDEF debug */
12471
  *tstr = '\0';                 /* for debugging purposes only */
11350
  *tstr = '\0';                 /* for debugging purposes only */
12472
  /*$ENDIF */
11351
  /*$ENDIF */
12473
  ndl_arom = ndl_bond[ndl_b - 1].arom;
11352
  ndl_arom = ndl_bond[ndl_b - 1].arom;
12474
  ndl_btype = ndl_bond[ndl_b - 1].btype;
11353
  ndl_btype = ndl_bond[ndl_b - 1].btype;
12475
  ndl_rc = ndl_bond[ndl_b - 1].ring_count;
11354
  ndl_rc = ndl_bond[ndl_b - 1].ring_count;
12476
  ndl_btopo = ndl_bond[ndl_b - 1].topo;
11355
  ndl_btopo = ndl_bond[ndl_b - 1].topo;
12477
  hst_arom = bond[hst_b - 1].arom;
11356
  hst_arom = bond[hst_b - 1].arom;
12478
  hst_btype = bond[hst_b - 1].btype;
11357
  hst_btype = bond[hst_b - 1].btype;
12479
  hst_rc = bond[hst_b - 1].ring_count;
11358
  hst_rc = bond[hst_b - 1].ring_count;
12480
/* p2c: checkmol.pas, line 8976:
11359
  /* p2c: checkmol.pas, line 8976:
12481
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11360
  * Note: Turbo Pascal conditional compilation directive was ignored [218] */
12482
  /*$IFDEF debug */
11361
   /*$IFDEF debug */
12483
  /*if (ndl_arom)
11362
   /*if (ndl_arom)
12484
    strcpy (na, "(ar)");
11363
     strcpy (na, "(ar)");
12485
  else
11364
   else
12486
    *na = '\0';
11365
     *na = '\0';
12487
  if (hst_arom)
11366
   if (hst_arom)
12488
    strcpy (ha, "(ar)");
11367
     strcpy (ha, "(ar)");
12489
  else
11368
   else
12490
    *ha = '\0';*/
11369
     *ha = '\0';*/
12491
  /*$ENDIF */
11370
   /*$ENDIF */
12492
  if (ndl_arom == true && hst_arom == true)
11371
  if (ndl_arom == true && hst_arom == true)
12493
    res = true;
11372
    res = true;
12494
  if (ndl_arom == false && hst_arom == false)
11373
  if (ndl_arom == false && hst_arom == false) {
12495
    {
-
 
12496
      if (ndl_btype == hst_btype)
11374
    if (ndl_btype == hst_btype)
12497
        res = true;
11375
            res = true;
12498
      if (ndl_btype == 'l' && (hst_btype == 'S' || hst_btype == 'D'))
11376
    if (ndl_btype == 'l' && (hst_btype == 'S' || hst_btype == 'D'))
12499
        res = true;
11377
            res = true;
12500
      if (ndl_btype == 's' && hst_btype == 'S')
11378
    if (ndl_btype == 's' && hst_btype == 'S')
12501
        res = true;
11379
            res = true;
12502
      if (ndl_btype == 'd' && hst_btype == 'D')
11380
    if (ndl_btype == 'd' && hst_btype == 'D')
12503
        res = true;
11381
            res = true;
12504
    }
11382
  }
12505
  /* a little exception: */
11383
  /* a little exception: */
12506
  if (ndl_arom == false && hst_arom == true)
11384
  if (ndl_arom == false && hst_arom == true) {
12507
    {
-
 
12508
      if (ndl_btype == 'A')
11385
    if (ndl_btype == 'A')
12509
        res = true;
11386
            res = true;
12510
      if (ndl_btype == 's' || ndl_btype == 'd')
11387
    if (ndl_btype == 's' || ndl_btype == 'd')
12511
        res = true;
11388
            res = true;
12512
      if (ndl_bond[ndl_b - 1].q_arom)
11389
    if (ndl_bond[ndl_b - 1].q_arom)
12513
        res = true;             /* 0.3p */
11390
            res = true;         /* 0.3p */
12514
    }
11391
  }
12515
  if (ndl_btype == 'a')
11392
  if (ndl_btype == 'a')
12516
    res = true;
11393
    res = true;
12517
  /* new in v0.3d: strict comparison of topology (and even ring_count!) */
11394
  /* new in v0.3d: strict comparison of topology (and even ring_count!) */
12518
  if (ndl_btopo < btopo_always_any || ndl_btopo == btopo_exact_rc)
11395
  if (ndl_btopo < btopo_always_any || ndl_btopo == btopo_exact_rc) {
12519
    {
-
 
12520
      if (ndl_rc != hst_rc)
11396
    if (ndl_rc != hst_rc) {
12521
        {
-
 
12522
          res = false;          /* this excludes further ring annulations as well as */
11397
            res = false;                /* this excludes further ring annulations as well as */
12523
/* p2c: checkmol.pas, line 9001:
11398
      /* p2c: checkmol.pas, line 9001:
12524
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11399
      * Note: Turbo Pascal conditional compilation directive was ignored [218] */
12525
          /*$IFDEF debug */
11400
            /*$IFDEF debug */
12526
          /* open-chains query structures to be found in rings */
11401
            /* open-chains query structures to be found in rings */
12527
          /*
11402
            /*
12528
             tstr := ' ringcount mismatch ('+inttostr(ndl_rc)+'/'+inttostr(hst_rc)+')';   */
11403
               tstr := ' ringcount mismatch ('+inttostr(ndl_rc)+'/'+inttostr(hst_rc)+')';   */
12529
          /*$ENDIF */
11404
            /*$ENDIF */
12530
        }
11405
          }
12531
    }
11406
  }
12532
  else
11407
  else {
12533
    {
-
 
12534
      if (ndl_btopo == btopo_excess_rc && hst_rc <= ndl_rc)
11408
    if (ndl_btopo == btopo_excess_rc && hst_rc <= ndl_rc) {
12535
        {
-
 
12536
          res = false;
11409
            res = false;
12537
/* p2c: checkmol.pas, line 9010:
11410
    /* p2c: checkmol.pas, line 9010:
12538
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11411
    * Note: Turbo Pascal conditional compilation directive was ignored [218] */
12539
          /*$IFDEF debug */
11412
          /*$IFDEF debug */
12540
          /* tstr := ' ringcount mismatch ('+inttostr(ndl_rc)+'/'+inttostr(hst_rc)+')'; */
11413
          /* tstr := ' ringcount mismatch ('+inttostr(ndl_rc)+'/'+inttostr(hst_rc)+')'; */
12541
          /*$ENDIF */
11414
          /*$ENDIF */
12542
        }
11415
          }
12543
    }
11416
  }
12544
/* p2c: checkmol.pas, line 9015:
11417
  /* p2c: checkmol.pas, line 9015:
12545
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11418
   * Note: Turbo Pascal conditional compilation directive was ignored [218] */
12546
  /*$IFDEF debug */
11419
    /*$IFDEF debug */
12547
  /* if res then debugoutput('bond types OK ('+inttostr(ndl_b)+':'+ndl_btype+na+'/'+inttostr(hst_b)+':'+hst_btype+ha+')') else
11420
    /* if res then debugoutput('bond types OK ('+inttostr(ndl_b)+':'+ndl_btype+na+'/'+inttostr(hst_b)+':'+hst_btype+ha+')') else
12548
     debugoutput('bond types not OK ('+inttostr(ndl_b)+':'+ndl_btype+na+'/'+inttostr(hst_b)+':'+hst_btype+ha+tstr+')'); */
11421
       debugoutput('bond types not OK ('+inttostr(ndl_b)+':'+ndl_btype+na+'/'+inttostr(hst_b)+':'+hst_btype+ha+tstr+')'); */
12549
  /*$ENDIF */
11422
    /*$ENDIF */
12550
  return res;
11423
  return res;
12551
}
11424
}
12552
 
-
 
12553
 
11425
 
12554
static boolean
-
 
12555
bondtypes_OK (ndl_b, hst_b)
11426
static boolean bondtypes_OK (ndl_b, hst_b)
12556
     int ndl_b, hst_b;
11427
     int ndl_b, hst_b;
12557
{
11428
{
12558
  boolean ndl_arom, hst_arom;
11429
  boolean ndl_arom, hst_arom;
12559
  char ndl_btype, hst_btype;
11430
  char ndl_btype, hst_btype;
12560
  int ndl_rc;                   /* new in v0.3d */
11431
  int ndl_rc;                   /* new in v0.3d */
12561
  int hst_rc;                   /* new in v0.3d */
11432
  int hst_rc;                   /* new in v0.3d */
12562
  int ndl_btopo;                /* new in v0.3d */
11433
  int ndl_btopo;                /* new in v0.3d */
12563
  boolean res = false;
11434
  boolean res = false;
12564
/* p2c: checkmol.pas, line 9032:
11435
  /* p2c: checkmol.pas, line 9032:
12565
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11436
  * Note: Turbo Pascal conditional compilation directive was ignored [218] */
12566
  /*$IFDEF debug */
11437
  /*$IFDEF debug */
12567
  /*char na[256], ha[256];*/
11438
  /*char na[256], ha[256];*/
12568
  char tstr[256];
11439
  char tstr[256];
12569
  /*$ENDIF */
11440
  /*$ENDIF */
12570
  int a1, a2;
11441
  int a1, a2;
12571
  str2 a1_el, a2_el;
11442
  str2 a1_el, a2_el;
12572
 
11443
 
12573
  if (ndl_b < 1 || ndl_b > ndl_n_bonds || hst_b < 1 || hst_b > n_bonds)
11444
  if (ndl_b < 1 || ndl_b > ndl_n_bonds || hst_b < 1 || hst_b > n_bonds)
12574
    return false;
11445
    return false;
12575
  if (opt_strict)               /* new in v0.2f */
11446
  if (opt_strict)               /* new in v0.2f */
12576
    return (bondtypes_OK_strict (ndl_b, hst_b));
11447
    return (bondtypes_OK_strict (ndl_b, hst_b));
12577
/* p2c: checkmol.pas, line 9051:
11448
  /* p2c: checkmol.pas, line 9051:
12578
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11449
  * Note: Turbo Pascal conditional compilation directive was ignored [218] */
12579
  /*$IFDEF debug */
11450
  /*$IFDEF debug */
12580
  *tstr = '\0';                 /* for debug purposes only */
11451
  *tstr = '\0';                 /* for debug purposes only */
12581
  /*$ENDIF */
11452
  /*$ENDIF */
12582
  ndl_arom = ndl_bond[ndl_b - 1].arom;
11453
  ndl_arom = ndl_bond[ndl_b - 1].arom;
12583
  ndl_btype = ndl_bond[ndl_b - 1].btype;
11454
  ndl_btype = ndl_bond[ndl_b - 1].btype;
12584
  hst_arom = bond[hst_b - 1].arom;
11455
  hst_arom = bond[hst_b - 1].arom;
12585
  hst_btype = bond[hst_b - 1].btype;
11456
  hst_btype = bond[hst_b - 1].btype;
12586
  ndl_rc = ndl_bond[ndl_b - 1].ring_count;
11457
  ndl_rc = ndl_bond[ndl_b - 1].ring_count;
12587
  hst_rc = bond[hst_b - 1].ring_count;
11458
  hst_rc = bond[hst_b - 1].ring_count;
12588
  ndl_btopo = ndl_bond[ndl_b - 1].topo;
11459
  ndl_btopo = ndl_bond[ndl_b - 1].topo;
12589
/* p2c: checkmol.pas, line 9061:
11460
  /* p2c: checkmol.pas, line 9061:
12590
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11461
  * Note: Turbo Pascal conditional compilation directive was ignored [218] */
12591
  /*$IFDEF debug */
11462
    /*$IFDEF debug */
12592
  //if (ndl_arom)
11463
    //if (ndl_arom)
12593
//    strcpy (na, "(ar)");
11464
  //    strcpy (na, "(ar)");
12594
//  else
11465
  //  else
12595
//    *na = '\0';
11466
  //    *na = '\0';
12596
//  if (hst_arom)
11467
  //  if (hst_arom)
12597
//    strcpy (ha, "(ar)");
11468
  //    strcpy (ha, "(ar)");
12598
//  else
11469
  //  else
12599
//    *ha = '\0';
11470
  //    *ha = '\0';
12600
  /*$ENDIF */
11471
  /*$ENDIF */
12601
  if (ndl_arom == true && hst_arom == true)
11472
  if (ndl_arom == true && hst_arom == true)
12602
    res = true;
11473
    res = true;
12603
  if (ndl_arom == false && hst_arom == false)
11474
  if (ndl_arom == false && hst_arom == false) {
12604
    {
-
 
12605
      if (ndl_btype == hst_btype)
11475
    if (ndl_btype == hst_btype)
12606
        res = true;
11476
            res = true;
12607
      if (ndl_btype == 'l' && (hst_btype == 'S' || hst_btype == 'D'))
11477
    if (ndl_btype == 'l' && (hst_btype == 'S' || hst_btype == 'D'))
12608
        res = true;
11478
            res = true;
12609
      if (ndl_btype == 's' && hst_btype == 'S')
11479
    if (ndl_btype == 's' && hst_btype == 'S')
12610
        res = true;
11480
            res = true;
12611
      if (ndl_btype == 'd' && hst_btype == 'D')
11481
    if (ndl_btype == 'd' && hst_btype == 'D')
12612
        res = true;
11482
            res = true;
12613
    }
11483
  }
12614
  /* a little exception: */
11484
  /* a little exception: */
12615
  if (ndl_arom == false && hst_arom == true)
11485
  if (ndl_arom == false && hst_arom == true) {
12616
    {
-
 
12617
      if (ndl_btype == 'A')
11486
    if (ndl_btype == 'A')
12618
        res = true;
-
 
12619
      if (ndl_btype == 's' || ndl_btype == 'd')
-
 
12620
        res = true;
-
 
12621
      if (ndl_btype == 'D')
-
 
12622
        {                       /* added in 0.2d: do not accept C=O etc. as C-O/arom */
-
 
12623
          a1 = ndl_bond[ndl_b - 1].a1;
-
 
12624
          a2 = ndl_bond[ndl_b - 1].a2;
-
 
12625
          strcpy (a1_el, ndl_atom[a1 - 1].element);
-
 
12626
          strcpy (a2_el, ndl_atom[a2 - 1].element);
-
 
12627
          if (strcmp (a1_el, "O ") && strcmp (a2_el, "O ")
-
 
12628
              && strcmp (a1_el, "S ") && strcmp (a2_el, "S ")
-
 
12629
              && strcmp (a1_el, "SE") && strcmp (a2_el, "SE")
-
 
12630
              && strcmp (a1_el, "TE") && strcmp (a2_el, "TE"))
-
 
12631
            res = true;
11487
            res = true;
-
 
11488
    if (ndl_btype == 's' || ndl_btype == 'd')
-
 
11489
            res = true;
-
 
11490
    if (ndl_btype == 'D') {                     /* added in 0.2d: do not accept C=O etc. as C-O/arom */
-
 
11491
            a1 = ndl_bond[ndl_b - 1].a1;
-
 
11492
            a2 = ndl_bond[ndl_b - 1].a2;
-
 
11493
            strcpy (a1_el, ndl_atom[a1 - 1].element);
-
 
11494
            strcpy (a2_el, ndl_atom[a2 - 1].element);
-
 
11495
            if (strcmp (a1_el, "O ") && strcmp (a2_el, "O ")
-
 
11496
                && strcmp (a1_el, "S ") && strcmp (a2_el, "S ")
-
 
11497
                && strcmp (a1_el, "SE") && strcmp (a2_el, "SE")
-
 
11498
                && strcmp (a1_el, "TE") && strcmp (a2_el, "TE"))
-
 
11499
              res = true;
12632
        }
11500
          }
12633
      if (ndl_bond[ndl_b - 1].q_arom)
11501
    if (ndl_bond[ndl_b - 1].q_arom)
12634
        res = true;             /* 0.3p */
11502
            res = true;         /* 0.3p */
12635
    }
11503
  }
12636
  if (ndl_btype == 'a')
11504
  if (ndl_btype == 'a')
12637
    res = true;
11505
    res = true;
12638
  /* new in v0.3d: obey topology requirements in query structure */
11506
  /* new in v0.3d: obey topology requirements in query structure */
12639
  if (ndl_btopo != btopo_any && ndl_btopo != btopo_always_any)
11507
  if (ndl_btopo != btopo_any && ndl_btopo != btopo_always_any) {
12640
    {
-
 
12641
  if (ndl_btopo == btopo_ring && hst_rc == 0)
11508
    if (ndl_btopo == btopo_ring && hst_rc == 0)
12642
    res = false;
11509
      res = false;
12643
  if (ndl_btopo == btopo_chain && hst_rc > 0)
11510
    if (ndl_btopo == btopo_chain && hst_rc > 0)
12644
    res = false;
11511
      res = false;
12645
  if (ndl_btopo == btopo_excess_rc && hst_rc <= ndl_rc)
11512
    if (ndl_btopo == btopo_excess_rc && hst_rc <= ndl_rc)
12646
    res = false;
11513
      res = false;
12647
  if (ndl_btopo == btopo_exact_rc && hst_rc != ndl_rc)
11514
    if (ndl_btopo == btopo_exact_rc && hst_rc != ndl_rc)
12648
    res = false;
11515
      res = false;
12649
}    
11516
  }
12650
/* p2c: checkmol.pas, line 9098:
11517
  /* p2c: checkmol.pas, line 9098:
12651
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11518
   * Note: Turbo Pascal conditional compilation directive was ignored [218] */
12652
  /*$IFDEF debug */
11519
    /*$IFDEF debug */
12653
  /* if res = false then tstr := ' bond topology mismatch '+inttostr(ndl_rc)+'/'+inttostr(hst_rc); */
11520
    /* if res = false then tstr := ' bond topology mismatch '+inttostr(ndl_rc)+'/'+inttostr(hst_rc); */
12654
  /*$ENDIF */
11521
    /*$ENDIF */
12655
/* p2c: checkmol.pas, line 9102:
11522
  /* p2c: checkmol.pas, line 9102:
12656
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11523
   * Note: Turbo Pascal conditional compilation directive was ignored [218] */
12657
  /*$IFDEF debug */
11524
    /*$IFDEF debug */
12658
  /*
11525
    /*
12659
     if res then debugoutput('bond types OK ('+inttostr(ndl_b)+':'+ndl_btype+na+'/'+inttostr(hst_b)+':'+hst_btype+ha+')') else
11526
       if res then debugoutput('bond types OK ('+inttostr(ndl_b)+':'+ndl_btype+na+'/'+inttostr(hst_b)+':'+hst_btype+ha+')') else
12660
     debugoutput('bond types not OK ('+inttostr(ndl_b)+':'+ndl_btype+na+'/'+inttostr(hst_b)+':'+hst_btype+ha+tstr+')'); */
11527
       debugoutput('bond types not OK ('+inttostr(ndl_b)+':'+ndl_btype+na+'/'+inttostr(hst_b)+':'+hst_btype+ha+tstr+')'); */
12661
  /*$ENDIF */
11528
    /*$ENDIF */
12662
  return res;
11529
  return res;
12663
}
11530
}
12664
 
-
 
12665
 
11531
 
12666
static boolean
-
 
12667
matrix_OK (m, ndl_dim, hst_dim)
11532
static boolean matrix_OK (m, ndl_dim, hst_dim)
12668
boolean (*m)[max_neighbors];
11533
boolean (*m)[max_neighbors];
12669
     int ndl_dim, hst_dim;
11534
     int ndl_dim, hst_dim;
12670
{
11535
{
12671
  /* new, recursive version in v0.2i: can handle up to max_neighbors substituents */
11536
  /* new, recursive version in v0.2i: can handle up to max_neighbors substituents */
12672
  boolean mr = false;
11537
  boolean mr = false;
Line 12674... Line 11539...
12674
  int i, ii, j, lndl_dim, lhst_dim;
11539
  int i, ii, j, lndl_dim, lhst_dim;
12675
 
11540
 
12676
  if (ndl_dim < 1 || ndl_dim > max_neighbors || hst_dim < 1 ||
11541
  if (ndl_dim < 1 || ndl_dim > max_neighbors || hst_dim < 1 ||
12677
      hst_dim > max_neighbors || ndl_dim > hst_dim)
11542
      hst_dim > max_neighbors || ndl_dim > hst_dim)
12678
    return false;
11543
    return false;
12679
  if (ndl_dim == 1)
11544
  if (ndl_dim == 1) {
12680
    {
-
 
12681
      for (i = 0; i < hst_dim; i++)
11545
    for (i = 0; i < hst_dim; i++) {
12682
        {
-
 
12683
          if (m[0][i])
11546
            if (m[0][i])
12684
            mr = true;
11547
              mr = true;
12685
        }
11548
          }
12686
      return mr;
11549
    return mr;
12687
    }
11550
  }
12688
  for (i = 1; i <= hst_dim; i++)
11551
  for (i = 1; i <= hst_dim; i++) {
12689
    {
-
 
12690
      if (m[0][i - 1])
11552
    if (m[0][i - 1]) {
12691
        {
-
 
12692
          /* write remaining fields into a new matchmatrix which is smaller by 1x1 */
11553
            /* write remaining fields into a new matchmatrix which is smaller by 1x1 */
12693
          memset (lm, false, sizeof (matchmatrix));
11554
            memset (lm, false, sizeof (matchmatrix));
12694
          for (j = 2; j <= ndl_dim; j++)
11555
            for (j = 2; j <= ndl_dim; j++) {
12695
            {
-
 
12696
              lhst_dim = 0;
11556
              lhst_dim = 0;
12697
              for (ii = 1; ii <= hst_dim; ii++)
11557
              for (ii = 1; ii <= hst_dim; ii++) {
12698
                {
-
 
12699
                  if (ii != i)
11558
                if (ii != i) {
12700
                    {
-
 
12701
                      lhst_dim++;
11559
                  lhst_dim++;
12702
                      lm[j - 2][lhst_dim - 1] = m[j - 1][ii - 1];
11560
                  lm[j - 2][lhst_dim - 1] = m[j - 1][ii - 1];
12703
                    }
11561
                }
12704
                }
11562
              }
12705
            }
11563
            }
12706
          lndl_dim = ndl_dim - 1;
11564
            lndl_dim = ndl_dim - 1;
12707
          if (matrix_OK (lm, lndl_dim, lhst_dim))
11565
            if (matrix_OK (lm, lndl_dim, lhst_dim)) {                   /* recursive call to matrix_OK */
12708
            {                   /* recursive call to matrix_OK */
-
 
12709
              return true;
11566
              return true;
12710
              /* stop any further work immediately */
11567
            /* stop any further work immediately */
12711
            }
11568
            }
12712
        }
11569
          }
12713
    }
11570
  }
12714
  return false;
11571
  return false;
12715
}
11572
}
12716
 
-
 
12717
 
11573
 
12718
static boolean
-
 
12719
is_flat (angle_deg)
11574
static boolean is_flat (angle_deg)
12720
     double angle_deg;
11575
     double angle_deg;
12721
{
11576
{
12722
  /* new in v0.3j */
11577
  /* new in v0.3j */
12723
  if (fabs (angle_deg) > 5 && fabs (angle_deg) < 175)
11578
  if (fabs (angle_deg) > 5 && fabs (angle_deg) < 175)
12724
    return false;
11579
    return false;
12725
  else
11580
  else
12726
    return true;
11581
    return true;
12727
}
11582
}
12728
 
11583
 
12729
 
-
 
12730
static boolean
-
 
12731
chirality_OK (ndl_cp, hst_cp)
11584
static boolean chirality_OK (ndl_cp, hst_cp)
12732
     int *ndl_cp, *hst_cp;
11585
     int *ndl_cp, *hst_cp;
12733
{
11586
{
12734
  boolean res = true;
11587
  boolean res = true;
12735
  double ndl_ct, hst_ct, ndl_ct_deg, hst_ct_deg;
11588
  double ndl_ct, hst_ct, ndl_ct_deg, hst_ct_deg;
12736
  p_3d np1, np2, np3, np4, hp1, hp2, hp3, hp4;
11589
  p_3d np1, np2, np3, np4, hp1, hp2, hp3, hp4;
Line 12757... Line 11610...
12757
  np3.z = ndl_atom[ta3 - 1].z;
11610
  np3.z = ndl_atom[ta3 - 1].z;
12758
  np4.x = ndl_atom[ta4 - 1].x;
11611
  np4.x = ndl_atom[ta4 - 1].x;
12759
  np4.y = ndl_atom[ta4 - 1].y;
11612
  np4.y = ndl_atom[ta4 - 1].y;
12760
  np4.z = ndl_atom[ta4 - 1].z;
11613
  np4.z = ndl_atom[ta4 - 1].z;
12761
  /* now check all needle bonds if we should care about up/down bonds */
11614
  /* now check all needle bonds if we should care about up/down bonds */
12762
  if (ndl_n_bonds > 0)
11615
  if (ndl_n_bonds > 0) {
12763
    {
-
 
12764
      FORLIM = ndl_n_bonds;
11616
    FORLIM = ndl_n_bonds;
12765
      for (i = 0; i < FORLIM; i++)
11617
    for (i = 0; i < FORLIM; i++) {
12766
        {
-
 
12767
          if (ndl_bond[i].stereo == bstereo_up ||
11618
            if (ndl_bond[i].stereo == bstereo_up ||
12768
              ndl_bond[i].stereo == bstereo_down)
11619
                  ndl_bond[i].stereo == bstereo_down) {
12769
            {
-
 
12770
              ba1 = ndl_bond[i].a1;
11620
              ba1 = ndl_bond[i].a1;
12771
              ba2 = ndl_bond[i].a2;
11621
              ba2 = ndl_bond[i].a2;
12772
              if (ba1 == ta1 && ndl_bond[i].stereo == bstereo_up)
11622
              if (ba1 == ta1 && ndl_bond[i].stereo == bstereo_up) {
-
 
11623
                      up = true;
-
 
11624
                      if (ba2 == ta2 || ba2 == ta3 || ba2 == ta4) {
-
 
11625
                        updown = true;
-
 
11626
                        if (ba2 == ta2)
-
 
11627
                                np1.z += 0.8;
-
 
11628
                        if (ba2 == ta3)
-
 
11629
                                np3.z += 0.8;
-
 
11630
                        if (ba2 == ta4)
-
 
11631
                                np4.z += 0.8;
-
 
11632
                      }
-
 
11633
                      else
-
 
11634
                        level++;
12773
                {
11635
                    }
-
 
11636
              if (ba1 == ta1 && ndl_bond[i].stereo == bstereo_down) {
12774
                  up = true;
11637
                      down = true;
12775
                  if (ba2 == ta2 || ba2 == ta3 || ba2 == ta4)
11638
                      if (ba2 == ta2 || ba2 == ta3 || ba2 == ta4) {
-
 
11639
                        updown = true;
-
 
11640
                        if (ba2 == ta2)
-
 
11641
                                np1.z -= 0.8;
-
 
11642
                        if (ba2 == ta3)
-
 
11643
                                np3.z -= 0.8;
-
 
11644
                        if (ba2 == ta4)
-
 
11645
                                np4.z -= 0.8;
-
 
11646
                      }
-
 
11647
                      else
-
 
11648
                        level--;
-
 
11649
                    }
-
 
11650
              if (ba2 == ta1 && ndl_bond[i].stereo == bstereo_up) {
-
 
11651
                      down = true;
-
 
11652
                      if (ba1 == ta2 || ba1 == ta3 || ba1 == ta4) {
-
 
11653
                        updown = true;
-
 
11654
                        if (ba1 == ta2)
-
 
11655
                          np1.z -= 0.8;
-
 
11656
                        if (ba1 == ta3)
-
 
11657
                          np3.z -= 0.8;
-
 
11658
                        if (ba1 == ta4)
-
 
11659
                          np4.z -= 0.8;
-
 
11660
                      }
-
 
11661
                      else
-
 
11662
                        level--;
12776
                    {
11663
                    }
-
 
11664
              if (ba2 == ta1 && ndl_bond[i].stereo == bstereo_down) {
-
 
11665
                      up = true;
-
 
11666
                      if (ba1 == ta2 || ba1 == ta3 || ba1 == ta4) {
12777
                      updown = true;
11667
                        updown = true;
12778
                      if (ba2 == ta2)
11668
                        if (ba1 == ta2)
12779
                        np1.z += 0.8;
11669
                                np1.z += 0.8;
12780
                      if (ba2 == ta3)
11670
                        if (ba1 == ta3)
12781
                        np3.z += 0.8;
11671
                                np3.z += 0.8;
12782
                      if (ba2 == ta4)
11672
                        if (ba1 == ta4)
12783
                        np4.z += 0.8;
11673
                                np4.z += 0.8;
-
 
11674
                      }
-
 
11675
                      else
-
 
11676
                        level++;
12784
                    }
11677
                    }
12785
                  else
-
 
12786
                    level++;
-
 
12787
                }
-
 
12788
              if (ba1 == ta1 && ndl_bond[i].stereo == bstereo_down)
-
 
12789
                {
-
 
12790
                  down = true;
-
 
12791
                  if (ba2 == ta2 || ba2 == ta3 || ba2 == ta4)
-
 
12792
                    {
-
 
12793
                      updown = true;
-
 
12794
                      if (ba2 == ta2)
-
 
12795
                        np1.z -= 0.8;
-
 
12796
                      if (ba2 == ta3)
-
 
12797
                        np3.z -= 0.8;
-
 
12798
                      if (ba2 == ta4)
-
 
12799
                        np4.z -= 0.8;
-
 
12800
                    }
-
 
12801
                  else
-
 
12802
                    level--;
-
 
12803
                }
-
 
12804
              if (ba2 == ta1 && ndl_bond[i].stereo == bstereo_up)
-
 
12805
                {
-
 
12806
                  down = true;
-
 
12807
                  if (ba1 == ta2 || ba1 == ta3 || ba1 == ta4)
-
 
12808
                    {
-
 
12809
                      updown = true;
-
 
12810
                      if (ba1 == ta2)
-
 
12811
                        np1.z -= 0.8;
-
 
12812
                      if (ba1 == ta3)
-
 
12813
                        np3.z -= 0.8;
-
 
12814
                      if (ba1 == ta4)
-
 
12815
                        np4.z -= 0.8;
-
 
12816
                    }
-
 
12817
                  else
-
 
12818
                    level--;
-
 
12819
                }
-
 
12820
              if (ba2 == ta1 && ndl_bond[i].stereo == bstereo_down)
-
 
12821
                {
-
 
12822
                  up = true;
-
 
12823
                  if (ba1 == ta2 || ba1 == ta3 || ba1 == ta4)
-
 
12824
                    {
-
 
12825
                      updown = true;
-
 
12826
                      if (ba1 == ta2)
-
 
12827
                        np1.z += 0.8;
-
 
12828
                      if (ba1 == ta3)
-
 
12829
                        np3.z += 0.8;
-
 
12830
                      if (ba1 == ta4)
-
 
12831
                        np4.z += 0.8;
-
 
12832
                    }
-
 
12833
                  else
-
 
12834
                    level++;
-
 
12835
                }
-
 
12836
            }
11678
            }
12837
        }                       /* for i ... */
11679
          }                     /* for i ... */
12838
      if (updown == false && level != 0)
11680
    if (updown == false && level != 0) {
12839
        {
-
 
12840
          if (level > 0)
11681
            if (level > 0)
12841
            np2.z += 0.3;
11682
              np2.z += 0.3;
12842
          if (level < 0)
11683
            if (level < 0)
12843
            np2.z -= 0.3;
11684
              np2.z -= 0.3;
12844
        }
11685
          }
12845
      else
11686
    else {
12846
        {
-
 
12847
          if (up)
11687
            if (up)
12848
            np2.z += 0.1;
11688
              np2.z += 0.1;
12849
          if (down)
11689
            if (down)
12850
            np2.z -= 0.1;
11690
              np2.z -= 0.1;
12851
        }
11691
          }
12852
    }
11692
  }
12853
  /* fill temporary atom variables again */
11693
  /* fill temporary atom variables again */
12854
  ta1 = hst_cp[0];
11694
  ta1 = hst_cp[0];
12855
  ta2 = hst_cp[1];
11695
  ta2 = hst_cp[1];
12856
  ta3 = hst_cp[2];
11696
  ta3 = hst_cp[2];
12857
  ta4 = hst_cp[3];
11697
  ta4 = hst_cp[3];
Line 12872... Line 11712...
12872
  /* now check all haystack bonds if we should care about up/down bonds */
11712
  /* now check all haystack bonds if we should care about up/down bonds */
12873
  level = 0;
11713
  level = 0;
12874
  updown = false;
11714
  updown = false;
12875
  up = false;
11715
  up = false;
12876
  down = false;
11716
  down = false;
12877
  if (n_bonds > 0)
11717
  if (n_bonds > 0) {
12878
    {
-
 
12879
      FORLIM = n_bonds;
11718
    FORLIM = n_bonds;
12880
      for (i = 0; i < FORLIM; i++)
11719
    for (i = 0; i < FORLIM; i++) {
12881
        {
-
 
12882
          if (bond[i].stereo == bstereo_up || bond[i].stereo == bstereo_down)
11720
            if (bond[i].stereo == bstereo_up || bond[i].stereo == bstereo_down) {
12883
            {
-
 
12884
              ba1 = bond[i].a1;
11721
              ba1 = bond[i].a1;
12885
              ba2 = bond[i].a2;
11722
              ba2 = bond[i].a2;
12886
              if (ba1 == ta1 && bond[i].stereo == bstereo_up)
11723
              if (ba1 == ta1 && bond[i].stereo == bstereo_up) {
12887
                {
-
 
12888
                  up = true;
11724
                      up = true;
12889
                  if (ba2 == ta2 || ba2 == ta3 || ba2 == ta4)
11725
                      if (ba2 == ta2 || ba2 == ta3 || ba2 == ta4) {
12890
                    {
-
 
12891
                      updown = true;
11726
                        updown = true;
12892
                      if (ba2 == ta2)
11727
                        if (ba2 == ta2)
12893
                        hp1.z += 0.8;
11728
                                hp1.z += 0.8;
12894
                      if (ba2 == ta3)
11729
                        if (ba2 == ta3)
12895
                        hp3.z += 0.8;
11730
                                hp3.z += 0.8;
12896
                      if (ba2 == ta4)
11731
                        if (ba2 == ta4)
12897
                        hp4.z += 0.8;
11732
                                hp4.z += 0.8;
12898
                    }
11733
                      }
12899
                  else
11734
                      else
12900
                    level++;
11735
                        level++;
12901
                }
-
 
12902
              if (ba1 == ta1 && bond[i].stereo == bstereo_down)
-
 
12903
                {
-
 
12904
                  down = true;
-
 
12905
                  if (ba2 == ta2 || ba2 == ta3 || ba2 == ta4)
-
 
12906
                    {
-
 
12907
                      updown = true;
-
 
12908
                      if (ba2 == ta2)
-
 
12909
                        hp1.z -= 0.8;
-
 
12910
                      if (ba2 == ta3)
-
 
12911
                        hp3.z -= 0.8;
-
 
12912
                      if (ba2 == ta4)
-
 
12913
                        hp4.z -= 0.8;
-
 
12914
                    }
11736
                    }
12915
                  else
-
 
12916
                    level--;
-
 
12917
                }
-
 
12918
              if (ba2 == ta1 && bond[i].stereo == bstereo_up)
11737
              if (ba1 == ta1 && bond[i].stereo == bstereo_down) {
12919
                {
-
 
12920
                  down = true;
11738
                      down = true;
12921
                  if (ba1 == ta2 || ba1 == ta3 || ba1 == ta4)
11739
                      if (ba2 == ta2 || ba2 == ta3 || ba2 == ta4) {
12922
                    {
-
 
12923
                      updown = true;
11740
                        updown = true;
12924
                      if (ba1 == ta2)
11741
                        if (ba2 == ta2)
12925
                        hp1.z -= 0.8;
11742
                              hp1.z -= 0.8;
12926
                      if (ba1 == ta3)
11743
                        if (ba2 == ta3)
12927
                        hp3.z -= 0.8;
11744
                                hp3.z -= 0.8;
12928
                      if (ba1 == ta4)
11745
                        if (ba2 == ta4)
12929
                        hp4.z -= 0.8;
11746
                              hp4.z -= 0.8;
-
 
11747
                     }
-
 
11748
                    else
-
 
11749
                      level--;
12930
                    }
11750
                    }
-
 
11751
              if (ba2 == ta1 && bond[i].stereo == bstereo_up) {
-
 
11752
                      down = true;
-
 
11753
                      if (ba1 == ta2 || ba1 == ta3 || ba1 == ta4) {
-
 
11754
                        updown = true;
-
 
11755
                        if (ba1 == ta2)
-
 
11756
                               hp1.z -= 0.8;
-
 
11757
                        if (ba1 == ta3)
-
 
11758
                                hp3.z -= 0.8;
-
 
11759
                        if (ba1 == ta4)
-
 
11760
                                hp4.z -= 0.8;
-
 
11761
                      }
12931
                  else
11762
                      else
12932
                    level--;
11763
                        level--;
12933
                }
11764
                    }
12934
              if (ba2 == ta1 && bond[i].stereo == bstereo_down)
11765
              if (ba2 == ta1 && bond[i].stereo == bstereo_down) {
12935
                {
-
 
12936
                  up = true;
11766
                      up = true;
12937
                  if (ba1 == ta2 || ba1 == ta3 || ba1 == ta4)
11767
                      if (ba1 == ta2 || ba1 == ta3 || ba1 == ta4) {
12938
                    {
-
 
12939
                      updown = true;
11768
                        updown = true;
12940
                      if (ba1 == ta2)
11769
                        if (ba1 == ta2)
12941
                        hp1.z += 0.8;
11770
                                hp1.z += 0.8;
12942
                      if (ba1 == ta3)
11771
                        if (ba1 == ta3)
12943
                        hp3.z += 0.8;
11772
                                hp3.z += 0.8;
12944
                      if (ba1 == ta4)
11773
                        if (ba1 == ta4)
12945
                        hp4.z += 0.8;
11774
                                hp4.z += 0.8;
-
 
11775
                      }
-
 
11776
                      else
-
 
11777
                        level++;
12946
                    }
11778
                    }
12947
                  else
-
 
12948
                    level++;
-
 
12949
                }
-
 
12950
            }
11779
            }
12951
        }                       /* for i ... */
11780
          }                     /* for i ... */
12952
      if (updown == false && level != 0)
11781
    if (updown == false && level != 0) {
12953
        {
-
 
12954
          if (level > 0)
11782
            if (level > 0)
12955
            hp2.z += 0.3;
11783
              hp2.z += 0.3;
12956
          if (level < 0)
11784
            if (level < 0)
12957
            hp2.z -= 0.3;
11785
              hp2.z -= 0.3;
12958
        }
11786
          }
12959
      else
11787
    else {
12960
        {
-
 
12961
          if (up)
11788
            if (up)
12962
            hp2.z += 0.1;
11789
              hp2.z += 0.1;
12963
          if (down)
11790
            if (down)
12964
            hp2.z -= 0.1;
11791
              hp2.z -= 0.1;
12965
        }
11792
          }
12966
    }
11793
  }
12967
  /* get the pseudo-torsion angles */
11794
  /* get the pseudo-torsion angles */
12968
  ndl_ct = ctorsion (np1, np2, np3, np4);
11795
  ndl_ct = ctorsion (np1, np2, np3, np4);
12969
  hst_ct = ctorsion (hp1, hp2, hp3, hp4);
11796
  hst_ct = ctorsion (hp1, hp2, hp3, hp4);
12970
  ndl_ct_deg = radtodeg (ndl_ct);
11797
  ndl_ct_deg = radtodeg (ndl_ct);
12971
  hst_ct_deg = radtodeg (hst_ct);
11798
  hst_ct_deg = radtodeg (hst_ct);
Line 12977... Line 11804...
12977
     (ndl_ct_deg * hst_ct_deg < 0) then res := false;
11804
     (ndl_ct_deg * hst_ct_deg < 0) then res := false;
12978
   */
11805
   */
12979
  if (((!is_flat (ndl_ct_deg)) && (!is_flat (hst_ct_deg))) &&
11806
  if (((!is_flat (ndl_ct_deg)) && (!is_flat (hst_ct_deg))) &&
12980
      ndl_ct_deg * hst_ct_deg < 0)
11807
      ndl_ct_deg * hst_ct_deg < 0)
12981
    res = false;
11808
    res = false;
12982
  if (rs_strict)
11809
  if (rs_strict) {
12983
    {
-
 
12984
      if (((is_flat (ndl_ct_deg) && (!is_flat (hst_ct_deg))) |
11810
      if (((is_flat (ndl_ct_deg) && (!is_flat (hst_ct_deg))) |
12985
           (is_flat (hst_ct_deg) && (!is_flat (ndl_ct_deg)))) ||
11811
                (is_flat (hst_ct_deg) && (!is_flat (ndl_ct_deg)))) ||
12986
          ndl_ct_deg * hst_ct_deg < 0)
11812
                ndl_ct_deg * hst_ct_deg < 0)
12987
        res = false;
11813
              res = false;
12988
    }
11814
  }
12989
  return res;
11815
  return res;
12990
}
11816
}
12991
 
11817
 
12992
 
-
 
12993
static boolean
-
 
12994
ndl_maybe_chiral (na)
11818
static boolean ndl_maybe_chiral (na)
12995
     int na;
11819
     int na;
12996
{
11820
{
12997
  /* new in v0.3h */
11821
  /* new in v0.3h */
12998
  boolean res = false;
11822
  boolean res = false;
12999
  str2 el;
11823
  str2 el;
Line 13003... Line 11827...
13003
  strcpy (el, ndl_atom[na - 1].element);
11827
  strcpy (el, ndl_atom[na - 1].element);
13004
  strcpy (at, ndl_atom[na - 1].atype);
11828
  strcpy (at, ndl_atom[na - 1].atype);
13005
  n_nb = ndl_atom[na - 1].neighbor_count;
11829
  n_nb = ndl_atom[na - 1].neighbor_count;
13006
  if (!strcmp (at, "C3 ") && n_nb > 2)
11830
  if (!strcmp (at, "C3 ") && n_nb > 2)
13007
    res = true;
11831
    res = true;
13008
  if (!strcmp (el, "N "))
11832
  if (!strcmp (el, "N ")) {
13009
    {
-
 
13010
      if (!strcmp (at, "N3+") && n_nb == 4)
11833
    if (!strcmp (at, "N3+") && n_nb == 4)
13011
        res = true;
11834
            res = true;
13012
    }
11835
  }
13013
  if (!strcmp (el, "S "))
11836
  if (!strcmp (el, "S ")) {                             /* sulfoxide */
13014
    {                           /* sulfoxide */
-
 
13015
      if ((n_nb == 3) && (ndl_hetatom_count (na) == 1))
11837
    if ((n_nb == 3) && (ndl_hetatom_count (na) == 1))
13016
        res = true;
11838
            res = true;
13017
    }
11839
  }
13018
  if (strcmp (el, "P ") && strcmp (el, "AS"))   /* "As" added in v0.3j */
11840
  if (strcmp (el, "P ") && strcmp (el, "AS"))   /* "As" added in v0.3j */
13019
    return res;
11841
    return res;
13020
  if (n_nb > 3)                 /* are we missing something here? */
11842
  if (n_nb > 3)                 /* are we missing something here? */
13021
    res = true;
11843
    res = true;
13022
  if (ndl_hetatom_count (na) >= 2)      /* v0.3m; ignore phosphates etc. */
11844
  if (ndl_hetatom_count (na) >= 2)      /* v0.3m; ignore phosphates etc. */
13023
    res = false;
11845
    res = false;
13024
  return res;
11846
  return res;
13025
}
11847
}
13026
 
11848
 
13027
 
-
 
13028
static boolean
-
 
13029
is_matching (ndl_xmp, hst_xmp)
11849
static boolean is_matching (ndl_xmp, hst_xmp)
13030
     int *ndl_xmp, *hst_xmp;
11850
     int *ndl_xmp, *hst_xmp;
13031
{
11851
{
13032
  int i, j, k, l, m, ndl_n_nb, n_nb, ndl_a, hst_a;
11852
  int i, j, k, l, m, ndl_n_nb, n_nb, ndl_a, hst_a;
13033
  int ndl_b = 0, hst_b = 0, prev_ndl_a = 0, prev_hst_a = 0;
11853
  int ndl_b = 0, hst_b = 0, prev_ndl_a = 0, prev_hst_a = 0;
13034
  int next_ndl_a, next_hst_a;
11854
  int next_ndl_a, next_hst_a;
Line 13043... Line 11863...
13043
  int prev_hst_b;
11863
  int prev_hst_b;
13044
  p_3d p1, p2, p3, p4;
11864
  p_3d p1, p2, p3, p4;
13045
  /*hst_torsion, ndl_torsion : double; */
11865
  /*hst_torsion, ndl_torsion : double; */
13046
  chirpath_type ncp, hcp;
11866
  chirpath_type ncp, hcp;
13047
  int n_hits, n_singlehits;
11867
  int n_hits, n_singlehits;
13048
/* p2c: checkmol.pas, line 9433:
11868
  /* p2c: checkmol.pas, line 9433:
13049
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11869
  * Note: Turbo Pascal conditional compilation directive was ignored [218] */
13050
  /*$IFDEF debug */
11870
  /*$IFDEF debug */
13051
  //char tmpstr[256];
11871
  //char tmpstr[256];
13052
 
11872
 
13053
  /*$ENDIF */
11873
  /*$ENDIF */
13054
  /* initialize local matchpath variables */
11874
  /* initialize local matchpath variables */
Line 13061... Line 11881...
13061
  /*for (i = 0; i < max_matchpath_length; i++)
11881
  /*for (i = 0; i < max_matchpath_length; i++)
13062
     {
11882
     {
13063
     ndl_mp[i] = ndl_xmp[i];
11883
     ndl_mp[i] = ndl_xmp[i];
13064
     hst_mp[i] = hst_xmp[i];
11884
     hst_mp[i] = hst_xmp[i];
13065
     } */
11885
     } */
13066
 
-
 
13067
 
11886
 
13068
  ndl_mp_len = matchpath_length (ndl_mp);
11887
  ndl_mp_len = matchpath_length (ndl_mp);
13069
  hst_mp_len = matchpath_length (hst_mp);
11888
  hst_mp_len = matchpath_length (hst_mp);
13070
  if (ndl_mp_len != hst_mp_len)
11889
  if (ndl_mp_len != hst_mp_len) {
13071
    {
-
 
13072
      /* this should never happen.... */
11890
      /* this should never happen.... */
13073
/* p2c: checkmol.pas, line 9451:
11891
  /* p2c: checkmol.pas, line 9451:
13074
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11892
  * Note: Turbo Pascal conditional compilation directive was ignored [218] */
13075
      /*$IFDEF debug */
11893
      /*$IFDEF debug */
13076
      //debugoutput ("needle and haystack matchpaths are of different length");
11894
      //debugoutput ("needle and haystack matchpaths are of different length");
13077
      /*$ENDIF */
11895
      /*$ENDIF */
13078
      return false;
11896
    return false;
13079
    }
11897
  }
13080
  ndl_a = ndl_mp[ndl_mp_len - 1];
11898
  ndl_a = ndl_mp[ndl_mp_len - 1];
13081
  hst_a = hst_mp[hst_mp_len - 1];
11899
  hst_a = hst_mp[hst_mp_len - 1];
13082
  ndl_atom[ndl_a - 1].tag = false;
11900
  ndl_atom[ndl_a - 1].tag = false;
13083
  /* new in v0.3o: mark the last needle atom as "visited" */
11901
  /* new in v0.3o: mark the last needle atom as "visited" */
13084
  if (ndl_mp_len > 1)
11902
  if (ndl_mp_len > 1) {
13085
    {
-
 
13086
      prev_ndl_a = ndl_mp[ndl_mp_len - 2];
11903
    prev_ndl_a = ndl_mp[ndl_mp_len - 2];
13087
      prev_hst_a = hst_mp[hst_mp_len - 2];
11904
    prev_hst_a = hst_mp[hst_mp_len - 2];
13088
    }
11905
    }
13089
  /* if geometry checking is on, check it here */
11906
  /* if geometry checking is on, check it here */
13090
  if (ez_search == true && ndl_mp_len > 3)
11907
  if (ez_search == true && ndl_mp_len > 3) {
13091
    {
-
 
13092
      na1 = ndl_mp[ndl_mp_len - 1];
11908
    na1 = ndl_mp[ndl_mp_len - 1];
13093
      na2 = ndl_mp[ndl_mp_len - 2];
11909
    na2 = ndl_mp[ndl_mp_len - 2];
13094
      na3 = ndl_mp[ndl_mp_len - 3];
11910
    na3 = ndl_mp[ndl_mp_len - 3];
13095
      na4 = ndl_mp[ndl_mp_len - 4];
11911
    na4 = ndl_mp[ndl_mp_len - 4];
13096
      ha1 = hst_mp[hst_mp_len - 1];
11912
    ha1 = hst_mp[hst_mp_len - 1];
13097
      ha2 = hst_mp[hst_mp_len - 2];
11913
    ha2 = hst_mp[hst_mp_len - 2];
13098
      ha3 = hst_mp[hst_mp_len - 3];
11914
    ha3 = hst_mp[hst_mp_len - 3];
13099
      ha4 = hst_mp[hst_mp_len - 4];
11915
    ha4 = hst_mp[hst_mp_len - 4];
13100
      prev_ndl_b = get_ndl_bond (na2, na3);
11916
    prev_ndl_b = get_ndl_bond (na2, na3);
13101
      prev_hst_b = get_bond (ha2, ha3);
11917
    prev_hst_b = get_bond (ha2, ha3);
13102
      if (ndl_bond[prev_ndl_b - 1].btype == 'D' &&
11918
    if (ndl_bond[prev_ndl_b - 1].btype == 'D' && bond[prev_hst_b - 1].arom == false
13103
          bond[prev_hst_b - 1].arom == false
-
 
13104
          && (ndl_bond[prev_ndl_b - 1].stereo !=
11919
              && (ndl_bond[prev_ndl_b - 1].stereo != bstereo_double_either
13105
              bstereo_double_either && bond[prev_hst_b - 1].stereo !=
11920
              && bond[prev_hst_b - 1].stereo != bstereo_double_either)
13106
              bstereo_double_either)
-
 
13107
          /* 0.3x always match if needle and/or haystack bond is double_either */
11921
              /* 0.3x always match if needle and/or haystack bond is double_either */
13108
          &&
-
 
13109
          (!strcmp (atom[ha2 - 1].element, "C ")
11922
              && (!strcmp (atom[ha2 - 1].element, "C ")
13110
           || !strcmp (atom[ha2 - 1].element, "N "))
11923
              || !strcmp (atom[ha2 - 1].element, "N "))
13111
          && (!strcmp (atom[ha3 - 1].element, "C ")
11924
              && (!strcmp (atom[ha3 - 1].element, "C ")
13112
              || !strcmp (atom[ha3 - 1].element, "N ")))
11925
              || !strcmp (atom[ha3 - 1].element, "N "))){
13113
        {                       /* v0.3g; check C=C, C=N, N=N bonds */
11926
                /* v0.3g; check C=C, C=N, N=N bonds */
13114
          p1.x = atom[ha1 - 1].x;
11927
            p1.x = atom[ha1 - 1].x;
13115
          p1.y = atom[ha1 - 1].y;
11928
            p1.y = atom[ha1 - 1].y;
13116
          p1.z = atom[ha1 - 1].z;
11929
            p1.z = atom[ha1 - 1].z;
13117
          p2.x = atom[ha2 - 1].x;
11930
            p2.x = atom[ha2 - 1].x;
13118
          p2.y = atom[ha2 - 1].y;
11931
            p2.y = atom[ha2 - 1].y;
13119
          p2.z = atom[ha2 - 1].z;
11932
            p2.z = atom[ha2 - 1].z;
13120
          p3.x = atom[ha3 - 1].x;
11933
            p3.x = atom[ha3 - 1].x;
13121
          p3.y = atom[ha3 - 1].y;
11934
            p3.y = atom[ha3 - 1].y;
13122
          p3.z = atom[ha3 - 1].z;
11935
            p3.z = atom[ha3 - 1].z;
13123
          p4.x = atom[ha4 - 1].x;
11936
            p4.x = atom[ha4 - 1].x;
13124
          p4.y = atom[ha4 - 1].y;
11937
            p4.y = atom[ha4 - 1].y;
13125
          p4.z = atom[ha4 - 1].z;
11938
            p4.z = atom[ha4 - 1].z;
13126
          hst_cis = is_cis (p1, p2, p3, p4);
11939
            hst_cis = is_cis (p1, p2, p3, p4);
13127
          /*hst_torsion := torsion(p1,p2,p3,p4); */
11940
            /*hst_torsion := torsion(p1,p2,p3,p4); */
13128
          p1.x = ndl_atom[na1 - 1].x;
11941
            p1.x = ndl_atom[na1 - 1].x;
13129
          p1.y = ndl_atom[na1 - 1].y;
11942
            p1.y = ndl_atom[na1 - 1].y;
13130
          p1.z = ndl_atom[na1 - 1].z;
11943
            p1.z = ndl_atom[na1 - 1].z;
13131
          p2.x = ndl_atom[na2 - 1].x;
11944
            p2.x = ndl_atom[na2 - 1].x;
13132
          p2.y = ndl_atom[na2 - 1].y;
11945
            p2.y = ndl_atom[na2 - 1].y;
13133
          p2.z = ndl_atom[na2 - 1].z;
11946
            p2.z = ndl_atom[na2 - 1].z;
13134
          p3.x = ndl_atom[na3 - 1].x;
11947
            p3.x = ndl_atom[na3 - 1].x;
13135
          p3.y = ndl_atom[na3 - 1].y;
11948
            p3.y = ndl_atom[na3 - 1].y;
13136
          p3.z = ndl_atom[na3 - 1].z;
11949
            p3.z = ndl_atom[na3 - 1].z;
13137
          p4.x = ndl_atom[na4 - 1].x;
11950
            p4.x = ndl_atom[na4 - 1].x;
13138
          p4.y = ndl_atom[na4 - 1].y;
11951
            p4.y = ndl_atom[na4 - 1].y;
13139
          p4.z = ndl_atom[na4 - 1].z;
11952
            p4.z = ndl_atom[na4 - 1].z;
13140
          /*ndl_torsion := torsion(p1,p2,p3,p4); */
11953
            /*ndl_torsion := torsion(p1,p2,p3,p4); */
13141
          ndl_cis = is_cis (p1, p2, p3, p4);
11954
            ndl_cis = is_cis (p1, p2, p3, p4);
13142
          if (ndl_cis != hst_cis)
11955
            if (ndl_cis != hst_cis) {
13143
            {
-
 
13144
/* p2c: checkmol.pas, line 9501:
11956
        /* p2c: checkmol.pas, line 9501:
13145
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11957
        * Note: Turbo Pascal conditional compilation directive was ignored [218] */
13146
              /*$IFDEF debug */
11958
              /*$IFDEF debug */
13147
              //debugoutput ("E/Z geometry mismatch");
11959
              //debugoutput ("E/Z geometry mismatch");
13148
              /*$ENDIF */
11960
              /*$ENDIF */
13149
              return false;
11961
              return false;
13150
            }
11962
            }
13151
        }
11963
          }
13152
    }                           /* end of E/Z geometry check */
11964
  }                             /* end of E/Z geometry check */
13153
  /* check whatever can be checked as early as now: */
11965
  /* check whatever can be checked as early as now: */
13154
  /* e.g. different elements or more substituents on needle atom than on haystack */
11966
  /* e.g. different elements or more substituents on needle atom than on haystack */
13155
  if (!atomtypes_OK (ndl_a, hst_a))
11967
  if (!atomtypes_OK (ndl_a, hst_a))
13156
    return false;
11968
    return false;
13157
  /* positive scenarios, e.g. one-atom fragments  (v0.3o) */
11969
  /* positive scenarios, e.g. one-atom fragments  (v0.3o) */
13158
  if (atom[hst_a - 1].neighbor_count == 0 &&
-
 
13159
      ndl_atom[ndl_a - 1].neighbor_count == 0)
11970
  if (atom[hst_a - 1].neighbor_count == 0 && ndl_atom[ndl_a - 1].neighbor_count == 0) {
13160
    {
-
 
13161
      if (!atomtypes_OK (ndl_a, hst_a))
11971
    if (!atomtypes_OK (ndl_a, hst_a))
13162
        return false;
11972
            return false;
13163
/* p2c: checkmol.pas: Note: Eliminated unused assignment statement [338] */
11973
    /* p2c: checkmol.pas: Note: Eliminated unused assignment statement [338] */
13164
      atom[hst_a - 1].tag = true;
11974
    atom[hst_a - 1].tag = true;
13165
      return true;
11975
    return true;
13166
    }
11976
  }
13167
  /* and other possibilities: */
11977
  /* and other possibilities: */
13168
  ndl_b = get_ndl_bond (prev_ndl_a, ndl_a);
11978
  ndl_b = get_ndl_bond (prev_ndl_a, ndl_a);
13169
  hst_b = get_bond (prev_hst_a, hst_a);
11979
  hst_b = get_bond (prev_hst_a, hst_a);
13170
/* p2c: checkmol.pas, line 9529:
11980
  /* p2c: checkmol.pas, line 9529:
13171
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11981
   * Note: Turbo Pascal conditional compilation directive was ignored [218] */
13172
  /*$IFDEF debug */
11982
  /*$IFDEF debug */
13173
  /* debugoutput('Now checking atoms '+inttostr(ndl_a)+'/'+inttostr(hst_a)+', bonds '+inttostr(ndl_b)+'/'+inttostr(hst_b)); */
11983
  /* debugoutput('Now checking atoms '+inttostr(ndl_a)+'/'+inttostr(hst_a)+', bonds '+inttostr(ndl_b)+'/'+inttostr(hst_b)); */
13174
  /*$ENDIF */
11984
  /*$ENDIF */
13175
  if (ndl_b > 0 && hst_b > 0)
11985
  if (ndl_b > 0 && hst_b > 0) {
13176
    {
-
 
13177
      /* do a quick check if bond types match */
11986
    /* do a quick check if bond types match */
13178
      if (!bondtypes_OK (ndl_b, hst_b))
11987
    if (!bondtypes_OK (ndl_b, hst_b)) {
13179
        {
-
 
13180
/* p2c: checkmol.pas, line 9537:
11988
      /* p2c: checkmol.pas, line 9537:
13181
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
11989
      * Note: Turbo Pascal conditional compilation directive was ignored [218] */
13182
          /*$IFDEF debug */
11990
            /*$IFDEF debug */
13183
          /*
11991
            /*
13184
             debugoutput('  failed match of bonds '+inttostr(ndl_b)+'/'+inttostr(hst_b)); */
11992
             debugoutput('  failed match of bonds '+inttostr(ndl_b)+'/'+inttostr(hst_b)); */
13185
          /*$ENDIF */
11993
           /*$ENDIF */
13186
          return false;
11994
            return false;
13187
        }
11995
          }
13188
    }
11996
  }
13189
  /* a) we reached the end of our needle fragment (and atom/bond types match) */
11997
  /* a) we reached the end of our needle fragment (and atom/bond types match) */
13190
  if ((ndl_atom[ndl_a - 1].neighbor_count == 1) && atomtypes_OK (ndl_a,
11998
  if ((ndl_atom[ndl_a - 1].neighbor_count == 1) && atomtypes_OK (ndl_a, hst_a) &&
13191
                                                                 hst_a) &&
-
 
13192
      bondtypes_OK (ndl_b, hst_b))
11999
      bondtypes_OK (ndl_b, hst_b)) {
13193
    {
-
 
13194
      return true;
12000
    return true;
13195
/* p2c: checkmol.pas, line 9549:
12001
  /* p2c: checkmol.pas, line 9549:
13196
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
12002
  * Note: Turbo Pascal conditional compilation directive was ignored [218] */
13197
      /*$IFDEF debug */
12003
      /*$IFDEF debug */
13198
      /* debugoutput('  ==> end of needle fragment at atom '+inttostr(ndl_a)+' (match)'); */
12004
      /* debugoutput('  ==> end of needle fragment at atom '+inttostr(ndl_a)+' (match)'); */
13199
      /*$ENDIF */
12005
      /*$ENDIF */
13200
    }
12006
  }
13201
  /* a.1) haystack fragment forms a ring, but needle does not;  v0.3m */
12007
  /* a.1) haystack fragment forms a ring, but needle does not;  v0.3m */
13202
  if ((matchpath_pos (ndl_a, ndl_mp) == matchpath_length (ndl_mp)) &&
12008
  if ((matchpath_pos (ndl_a, ndl_mp) == matchpath_length (ndl_mp)) &&
13203
      (matchpath_pos (hst_a, hst_mp) < matchpath_length (hst_mp)))
12009
        (matchpath_pos (hst_a, hst_mp) < matchpath_length (hst_mp))) {
13204
    {
-
 
13205
      return false;
12010
    return false;
13206
/* p2c: checkmol.pas, line 9559:
12011
    /* p2c: checkmol.pas, line 9559:
13207
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
12012
    * Note: Turbo Pascal conditional compilation directive was ignored [218] */
13208
      /*$IFDEF debug */
12013
      /*$IFDEF debug */
13209
      /*
12014
      /*
13210
         debugoutput('  haystack forms a ring and needle does not at '+inttostr(hst_a));
12015
         debugoutput('  haystack forms a ring and needle does not at '+inttostr(hst_a));
13211
         {$ENDIF */
12016
         {$ENDIF */
13212
    }
12017
  }
13213
  /* b) a ring is formed (ndl_a is already in the path) and atom/bond types match */
12018
  /* b) a ring is formed (ndl_a is already in the path) and atom/bond types match */
13214
  if ((matchpath_pos (ndl_a, ndl_mp) > 0) &&
12019
  if ((matchpath_pos (ndl_a, ndl_mp) > 0) &&
13215
      (matchpath_pos (ndl_a, ndl_mp) < matchpath_length (ndl_mp)))
12020
      (matchpath_pos (ndl_a, ndl_mp) < matchpath_length (ndl_mp))) {
13216
    {
-
 
13217
      if ((matchpath_pos (ndl_a, ndl_mp) == matchpath_pos (hst_a, hst_mp)) &&
12021
    if ((matchpath_pos (ndl_a, ndl_mp) == matchpath_pos (hst_a, hst_mp)) &&
13218
          atomtypes_OK (ndl_a, hst_a) && bondtypes_OK (ndl_b, hst_b))
12022
              atomtypes_OK (ndl_a, hst_a) && bondtypes_OK (ndl_b, hst_b)) {
13219
        {
-
 
13220
          /* 1st chirality check */
12023
              /* 1st chirality check */
13221
          if (!((matchpath_pos (ndl_a, ndl_mp) > 1 && (rs_search ||
12024
            if (!((matchpath_pos (ndl_a, ndl_mp) > 1 && (rs_search ||
13222
                                                       ndl_atom[ndl_a -
-
 
13223
                                                                1].
-
 
13224
                                                       stereo_care)) &&
12025
                                                       ndl_atom[ndl_a -1].stereo_care)) && ndl_maybe_chiral (ndl_a))) {
13225
                ndl_maybe_chiral (ndl_a)))
-
 
13226
            {                   /* new in v0.3h */
12026
                                        /* new in v0.3h */
13227
              return true;
12027
              return true;
13228
            }                   /* end of 1st chirality check */
12028
            }                   /* end of 1st chirality check */
13229
          na1 = ndl_a;          /* the (potential) chiral center (v0.3f) */
12029
            na1 = ndl_a;                /* the (potential) chiral center (v0.3f) */
13230
          na2 = ndl_mp[matchpath_pos (ndl_a, ndl_mp) - 2];
12030
            na2 = ndl_mp[matchpath_pos (ndl_a, ndl_mp) - 2];
13231
          na3 = ndl_mp[matchpath_pos (ndl_a, ndl_mp)];
12031
            na3 = ndl_mp[matchpath_pos (ndl_a, ndl_mp)];
13232
          na4 = ndl_mp[matchpath_length (ndl_mp) - 2];
12032
            na4 = ndl_mp[matchpath_length (ndl_mp) - 2];
13233
          ha1 = hst_a;
12033
            ha1 = hst_a;
13234
          ha2 = hst_mp[matchpath_pos (hst_a, hst_mp) - 2];
12034
            ha2 = hst_mp[matchpath_pos (hst_a, hst_mp) - 2];
13235
          ha3 = hst_mp[matchpath_pos (hst_a, hst_mp)];
12035
            ha3 = hst_mp[matchpath_pos (hst_a, hst_mp)];
13236
          ha4 = hst_mp[matchpath_length (hst_mp) - 2];
12036
            ha4 = hst_mp[matchpath_length (hst_mp) - 2];
13237
          memset (ncp, 0, sizeof (chirpath_type));
12037
            memset (ncp, 0, sizeof (chirpath_type));
13238
          memset (hcp, 0, sizeof (chirpath_type));
12038
            memset (hcp, 0, sizeof (chirpath_type));
13239
          ncp[0] = na1;
12039
            ncp[0] = na1;
13240
          ncp[1] = na2;
12040
            ncp[1] = na2;
13241
          ncp[2] = na3;
12041
            ncp[2] = na3;
13242
          ncp[3] = na4;
12042
            ncp[3] = na4;
13243
          hcp[0] = ha1;
12043
            hcp[0] = ha1;
13244
          hcp[1] = ha2;
12044
            hcp[1] = ha2;
13245
          hcp[2] = ha3;
12045
            hcp[2] = ha3;
13246
          hcp[3] = ha4;
12046
            hcp[3] = ha4;
13247
          if (!chirality_OK (ncp, hcp))
12047
            if (!chirality_OK (ncp, hcp)) {
13248
            {
-
 
13249
/* p2c: checkmol.pas, line 9589:
12048
        /* p2c: checkmol.pas, line 9589:
13250
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
12049
         * Note: Turbo Pascal conditional compilation directive was ignored [218] */
13251
              /*$IFDEF debug */
12050
                      /*$IFDEF debug */
13252
              //debugoutput ("chirality check failed at ring junction");
12051
                      //debugoutput ("chirality check failed at ring junction");
13253
              /*$ENDIF */
12052
                      /*$ENDIF */
13254
              return false;
12053
        return false;
13255
            }
12054
      }
13256
/* p2c: checkmol.pas, line 9596:
12055
      /* p2c: checkmol.pas, line 9596:
13257
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
12056
       * Note: Turbo Pascal conditional compilation directive was ignored [218] */
13258
          /*$IFDEF debug */
12057
          /*$IFDEF debug */
13259
          //debugoutput ("chirality check succeeded at ring junction");
12058
          //debugoutput ("chirality check succeeded at ring junction");
13260
          /*$ENDIF */
12059
          /*$ENDIF */
13261
          return true;
12060
      return true;
13262
/* p2c: checkmol.pas, line 9602:
12061
      /* p2c: checkmol.pas, line 9602:
13263
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
12062
       * Note: Turbo Pascal conditional compilation directive was ignored [218] */
13264
          /*$IFDEF debug */
12063
            /*$IFDEF debug */
13265
          /* debugoutput('matchpath forms ring at: '+inttostr(ndl_a)+' (match)'); */
12064
            /* debugoutput('matchpath forms ring at: '+inttostr(ndl_a)+' (match)'); */
13266
          /*$ENDIF */
12065
            /*$ENDIF */
13267
        }
12066
          }
13268
      else
12067
    else {
13269
        {
-
 
13270
          return false;
12068
            return false;
13271
/* p2c: checkmol.pas, line 9609:
12069
      /* p2c: checkmol.pas, line 9609:
13272
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
12070
      * Note: Turbo Pascal conditional compilation directive was ignored [218] */
13273
          /*$IFDEF debug */
12071
            /*$IFDEF debug */
13274
          /*
12072
            /*
13275
             debugoutput('matchpath forms ring at: '+inttostr(ndl_a)+' (no match)'); */
12073
               debugoutput('matchpath forms ring at: '+inttostr(ndl_a)+' (no match)'); */
13276
          /*$ENDIF */
12074
            /*$ENDIF */
13277
        }
12075
          }
13278
    }
12076
  }
13279
  /* in all other cases, do the hard work: */
12077
  /* in all other cases, do the hard work: */
13280
  /* first, get all heavy-atom neighbors of needle and haystack; */
12078
  /* first, get all heavy-atom neighbors of needle and haystack; */
13281
  /* at the beginning of the search, this means all neighbors, then it means */
12079
  /* at the beginning of the search, this means all neighbors, then it means */
13282
  /* all but the previous atom (where we came from) */
12080
  /* all but the previous atom (where we came from) */
13283
  memset (ndl_nb, 0, sizeof (neighbor_rec));
12081
  memset (ndl_nb, 0, sizeof (neighbor_rec));
13284
  memset (hst_nb, 0, sizeof (neighbor_rec));
12082
  memset (hst_nb, 0, sizeof (neighbor_rec));
13285
 
12083
 
13286
  if (matchpath_length (ndl_mp) == 1)
12084
  if (matchpath_length (ndl_mp) == 1) {
13287
    {
-
 
13288
      ndl_n_nb = ndl_atom[ndl_a - 1].neighbor_count;
12085
    ndl_n_nb = ndl_atom[ndl_a - 1].neighbor_count;
13289
      n_nb = atom[hst_a - 1].neighbor_count;
12086
    n_nb = atom[hst_a - 1].neighbor_count;
13290
      get_ndl_neighbors (ndl_nb, ndl_a);
12087
    get_ndl_neighbors (ndl_nb, ndl_a);
13291
      get_neighbors (hst_nb, hst_a);
12088
    get_neighbors (hst_nb, hst_a);
13292
    }
12089
  }
13293
  else
12090
  else {
13294
    {
-
 
13295
      ndl_n_nb = ndl_atom[ndl_a - 1].neighbor_count - 1;
12091
    ndl_n_nb = ndl_atom[ndl_a - 1].neighbor_count - 1;
13296
      n_nb = atom[hst_a - 1].neighbor_count - 1;
12092
    n_nb = atom[hst_a - 1].neighbor_count - 1;
13297
      get_ndl_nextneighbors (ndl_nb, ndl_a, prev_ndl_a);
12093
    get_ndl_nextneighbors (ndl_nb, ndl_a, prev_ndl_a);
13298
      get_nextneighbors (hst_nb, hst_a, prev_hst_a);
12094
    get_nextneighbors (hst_nb, hst_a, prev_hst_a);
13299
    }
12095
  }
13300
  /* v0.3o: mark all neighbor atoms as "visited" */
12096
  /* v0.3o: mark all neighbor atoms as "visited" */
13301
  for (i = 0; i < ndl_n_nb; i++)
12097
  for (i = 0; i < ndl_n_nb; i++)
13302
    ndl_atom[ndl_nb[i] - 1].tag = false;
12098
    ndl_atom[ndl_nb[i] - 1].tag = false;
13303
  /* now that the neighbor-arrays are filled, get all */
12099
  /* now that the neighbor-arrays are filled, get all */
13304
  /* combinations of matches recursively; */
12100
  /* combinations of matches recursively; */
13305
  /* first, initialize the match matrix */
12101
  /* first, initialize the match matrix */
13306
  memset (mm, false, sizeof (matchmatrix));     /* new in v0.2i */
12102
  memset (mm, false, sizeof (matchmatrix));     /* new in v0.2i */
13307
  /* make sure there are not too many neighbors (max. max_neighbors)   */
12103
  /* make sure there are not too many neighbors (max. max_neighbors)   */
13308
  if (ndl_n_nb > max_neighbors || n_nb > max_neighbors)
12104
  if (ndl_n_nb > max_neighbors || n_nb > max_neighbors) {                               /* updated in v0.2i */
13309
    {                           /* updated in v0.2i */
-
 
13310
/* p2c: checkmol.pas, line 9644:
12105
    /* p2c: checkmol.pas, line 9644:
13311
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
12106
    * Note: Turbo Pascal conditional compilation directive was ignored [218] */
13312
      /*$IFDEF debug */
12107
      /*$IFDEF debug */
13313
      //debugoutput ("too many neighbors - exiting");
12108
      //debugoutput ("too many neighbors - exiting");
13314
      /*$ENDIF */
12109
      /*$ENDIF */
13315
      return false;
12110
    return false;
13316
    }
12111
  }
13317
  /* check if matchpath is not already filled up */
12112
  /* check if matchpath is not already filled up */
13318
  if (matchpath_length (ndl_mp) == max_matchpath_length)
12113
  if (matchpath_length (ndl_mp) == max_matchpath_length) {
13319
    {
-
 
13320
/* p2c: checkmol.pas, line 9653:
12114
    /* p2c: checkmol.pas, line 9653:
13321
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
12115
    * Note: Turbo Pascal conditional compilation directive was ignored [218] */
13322
      /*$IFDEF debug */
12116
      /*$IFDEF debug */
13323
      //debugoutput ("matchpath too int - exiting");
12117
      //debugoutput ("matchpath too int - exiting");
13324
      /*$ENDIF */
12118
      /*$ENDIF */
13325
      return false;
12119
    return false;
13326
    }
12120
  }
13327
  /* next, check which chain of the needle matches which chain of the haystack  */
12121
  /* next, check which chain of the needle matches which chain of the haystack  */
13328
  for (i = 0; i < ndl_n_nb; i++)
12122
  for (i = 0; i < ndl_n_nb; i++) {
13329
    {
-
 
13330
      emptyline = true;
12123
    emptyline = true;
13331
      next_ndl_a = ndl_nb[i];
12124
    next_ndl_a = ndl_nb[i];
13332
      for (j = 0; j < n_nb; j++)
12125
    for (j = 0; j < n_nb; j++) {
13333
        {
-
 
13334
          next_hst_a = hst_nb[j];
12126
            next_hst_a = hst_nb[j];
13335
          ndl_mp[ndl_mp_len] = next_ndl_a;
12127
            ndl_mp[ndl_mp_len] = next_ndl_a;
13336
          hst_mp[hst_mp_len] = next_hst_a;
12128
            hst_mp[hst_mp_len] = next_hst_a;
13337
          if (is_matching (ndl_mp, hst_mp))
-
 
13338
            {                   /* recursive function call */
12129
            if (is_matching (ndl_mp, hst_mp)) {                 /* recursive function call */
13339
 
-
 
13340
              if (max_match_recursion_depth != 0
12130
              if (max_match_recursion_depth != 0
13341
                  && ++recursion_depth > max_match_recursion_depth)
12131
                          && ++recursion_depth > max_match_recursion_depth) {
13342
                {
-
 
13343
#ifndef MAKE_SHARED_LIBRARY
12132
#ifndef MAKE_SHARED_LIBRARY
13344
                  if (opt_verbose)
12133
                      if (opt_verbose)
13345
#endif
12134
#endif
13346
                    printf
12135
                        printf
13347
                      ("Warning: max. number of match recursions (%i) reached, reverting to non-exhaustive match\n",
12136
                      ("Warning: max. number of match recursions (%i) reached, reverting to non-exhaustive match\n",
13348
                       max_match_recursion_depth);
12137
                      max_match_recursion_depth);
13349
                  //n_rings = max_rings;
12138
                      //n_rings = max_rings;
13350
                  return true;
12139
                     return true;
13351
                }
12140
                    }
13352
 
-
 
13353
              mm[i][j] = true;
12141
              mm[i][j] = true;
13354
              emptyline = false;
12142
              emptyline = false;
13355
            }
12143
            }
13356
        }
12144
          }
13357
      /* if a needle substituent does not match any of the haystack substituents, */
12145
    /* if a needle substituent does not match any of the haystack substituents, */
13358
      /* stop any further work immediately */
12146
    /* stop any further work immediately */
13359
      if (emptyline)
12147
    if (emptyline)
13360
        return false;
12148
            return false;
13361
    }
12149
  }
13362
  /* finally, check the content of the matrix */
12150
  /* finally, check the content of the matrix */
13363
  res = matrix_OK (mm, ndl_n_nb, n_nb);
12151
  res = matrix_OK (mm, ndl_n_nb, n_nb);
13364
  /* optional: chirality check */
12152
  /* optional: chirality check */
13365
  if (!((res && (rs_search || ndl_atom[ndl_a - 1].stereo_care)) &&
12153
  if (!((res && (rs_search || ndl_atom[ndl_a - 1].stereo_care)) && ndl_maybe_chiral (ndl_a)))
13366
        ndl_maybe_chiral (ndl_a)))
-
 
13367
    return res;
12154
    return res;
13368
  /* first, we have to clean up the match matrix in order to remove */
12155
  /* first, we have to clean up the match matrix in order to remove */
13369
  /* "impossible" multiple matches (new in v0.3h) */
12156
  /* "impossible" multiple matches (new in v0.3h) */
13370
  for (i = 1; i <= 3; i++)
12157
  for (i = 1; i <= 3; i++) {
13371
    {
-
 
13372
      for (j = 1; j <= max_neighbors; j++)
12158
    for (j = 1; j <= max_neighbors; j++) {                      /* haystack dimension */
13373
        {                       /* haystack dimension */
-
 
13374
          n_hits = 0;
12159
            n_hits = 0;
13375
          l = 0;
12160
            l = 0;
13376
          for (k = 1; k <= max_neighbors; k++)
12161
            for (k = 1; k <= max_neighbors; k++) {                      /* needle dimension */
13377
            {                   /* needle dimension */
-
 
13378
              if (mm[k - 1][j - 1])
12162
              if (mm[k - 1][j - 1]) {
13379
                {
-
 
13380
                  n_hits++;
12163
                      n_hits++;
13381
                  l = k;
12164
                      l = k;
-
 
12165
                    }
-
 
12166
            }
-
 
12167
            if (n_hits == 1) {                  /* a unique match ==> kick out any other match at this pos. */
-
 
12168
              for (m = 1; m <= max_neighbors; m++) {
-
 
12169
                      if (m != j)
-
 
12170
                        mm[l - 1][m - 1] = false;
13382
                }
12171
                    }
13383
            }
12172
            }
13384
          if (n_hits == 1)
-
 
13385
            {                   /* a unique match ==> kick out any other match at this pos. */
-
 
13386
              for (m = 1; m <= max_neighbors; m++)
-
 
13387
                {
-
 
13388
                  if (m != j)
-
 
13389
                    mm[l - 1][m - 1] = false;
-
 
13390
                }
-
 
13391
            }
12173
          }
13392
        }
-
 
13393
    }
12174
  }
13394
  /* end of match matrix clean-up */
12175
  /* end of match matrix clean-up */
13395
  if (prev_ndl_a > 0)
12176
  if (prev_ndl_a > 0) {
13396
    {
-
 
13397
      n_singlehits = 1;
12177
    n_singlehits = 1;
13398
      ncp[1] = prev_ndl_a;
12178
    ncp[1] = prev_ndl_a;
13399
      hcp[1] = prev_hst_a;
12179
    hcp[1] = prev_hst_a;
13400
    }
12180
  }
13401
  else
12181
  else
13402
    n_singlehits = 0;
12182
    n_singlehits = 0;
13403
  ncp[0] = ndl_a;
12183
  ncp[0] = ndl_a;
13404
  hcp[0] = hst_a;
12184
  hcp[0] = hst_a;
13405
  i = 0;
12185
  i = 0;
13406
  l = 0;
12186
  l = 0;
13407
  while (n_singlehits < 3 && i < 4)
12187
  while (n_singlehits < 3 && i < 4) {
13408
    {
-
 
13409
      i++;
12188
    i++;
13410
      n_hits = 0;
12189
    n_hits = 0;
13411
      for (k = 1; k <= n_nb; k++)
12190
    for (k = 1; k <= n_nb; k++) {
13412
        {
-
 
13413
          if (mm[i - 1][k - 1])
12191
            if (mm[i - 1][k - 1]) {
13414
            {
-
 
13415
              n_hits++;
12192
              n_hits++;
13416
              l = k;
12193
              l = k;
13417
            }
12194
            }
13418
        }
12195
          }
13419
      if (n_hits == 1)
12196
    if (n_hits == 1) {
13420
        {
-
 
13421
          n_singlehits++;
12197
            n_singlehits++;
13422
          ncp[n_singlehits] = ndl_nb[i - 1];
12198
            ncp[n_singlehits] = ndl_nb[i - 1];
13423
          hcp[n_singlehits] = hst_nb[l - 1];
12199
            hcp[n_singlehits] = hst_nb[l - 1];
13424
        }
12200
          }
13425
    }
12201
  }
13426
  if (n_singlehits != 3)
12202
  if (n_singlehits != 3)
13427
    return res;
12203
    return res;
13428
  if (!chirality_OK (ncp, hcp))
12204
  if (!chirality_OK (ncp, hcp)) {
13429
    {
-
 
13430
/* p2c: checkmol.pas, line 9749:
12205
    /* p2c: checkmol.pas, line 9749:
13431
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
12206
     * Note: Turbo Pascal conditional compilation directive was ignored [218] */
13432
      /*$IFDEF debug */
12207
          /*$IFDEF debug */
13433
      //debugoutput ("chirality check failed");
12208
          //debugoutput ("chirality check failed");
13434
      /*$ENDIF */
12209
          /*$ENDIF */
13435
      res = false;
12210
          res = false;
13436
    }
12211
  }
13437
  else
12212
  else {
13438
    {
-
 
13439
/* p2c: checkmol.pas, line 9755:
12213
/* p2c: checkmol.pas, line 9755:
13440
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
12214
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
13441
      /*$IFDEF debug */
12215
      /*$IFDEF debug */
13442
      //debugoutput ("chirality check OK");
12216
      //debugoutput ("chirality check OK");
13443
      /*$ENDIF */
12217
      /*$ENDIF */
13444
    }
12218
  }
13445
  return res;
12219
  return res;
13446
/* p2c: checkmol.pas, line 9762:
12220
  /* p2c: checkmol.pas, line 9762:
13447
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
12221
   * Note: Turbo Pascal conditional compilation directive was ignored [218] */
13448
  /*$IFDEF debug */
12222
    /*$IFDEF debug */
13449
  /* if res then tmpstr := ' MATCH' else tmpstr := ' NO MATCH';
12223
    /* if res then tmpstr := ' MATCH' else tmpstr := ' NO MATCH';
13450
     debugoutput('result for atoms '+inttostr(ndl_a)+'/'+inttostr(hst_a)+', bonds '+inttostr(ndl_b)+'/'+inttostr(hst_b)+':'+tmpstr); */
12224
       debugoutput('result for atoms '+inttostr(ndl_a)+'/'+inttostr(hst_a)+', bonds '+inttostr(ndl_b)+'/'+inttostr(hst_b)+':'+tmpstr); */
13451
  /*$ENDIF */
12225
    /*$ENDIF */
13452
}
12226
}
13453
 
12227
 
13454
 
-
 
13455
static boolean
-
 
13456
quick_match ()
12228
static boolean quick_match ()
13457
{
12229
{
13458
  /* added in v0.2c */
12230
  /* added in v0.2c */
13459
  int i;
12231
  int i;
13460
  boolean res = true;
12232
  boolean res = true;
13461
 /* str3 ndl_atype;*/
12233
  /* str3 ndl_atype;*/
13462
  str2 ndl_el;                  /* v0.3l */
12234
  str2 ndl_el;                  /* v0.3l */
13463
  int ndl_chg = 0;              /* v0.3l */
12235
  int ndl_chg = 0;              /* v0.3l */
13464
  int ndl_rad = 0;              /* v0.3x */
12236
  int ndl_rad = 0;              /* v0.3x */
13465
  int ndl_iso = 0;              /* v0.3x */
12237
  int ndl_iso = 0;              /* v0.3x */
13466
 
-
 
13467
 
12238
 
13468
  if ((ez_search || rs_search) && ndl_n_heavyatoms > 3)
12239
  if ((ez_search || rs_search) && ndl_n_heavyatoms > 3)
13469
    /* v0.3f, v0.3m, v0.3o */
12240
    /* v0.3f, v0.3m, v0.3o */
13470
    return false;
12241
    return false;
13471
  if (ndl_n_atoms < 1 || n_atoms < 1 || ndl_n_atoms > n_atoms ||
12242
  if (ndl_n_atoms < 1 || n_atoms < 1 || ndl_n_atoms > n_atoms ||
13472
      ndl_n_bonds > n_bonds)
-
 
13473
    {                           /* just to be sure... */
12243
        ndl_n_bonds > n_bonds) {                                /* just to be sure... */
13474
/* p2c: checkmol.pas, line 9786:
12244
    /* p2c: checkmol.pas, line 9786:
13475
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
12245
     * Note: Turbo Pascal conditional compilation directive was ignored [218] */
13476
      /*$IFDEF debug */
12246
          /*$IFDEF debug */
13477
/* p2c: checkmol.pas: Note: Eliminated unused assignment statement [338] */
12247
    /* p2c: checkmol.pas: Note: Eliminated unused assignment statement [338] */
13478
      //debugoutput (" ==> quick_match failed");
12248
          //debugoutput (" ==> quick_match failed");
13479
      /*$ENDIF */
12249
          /*$ENDIF */
13480
      return false;
12250
    return false;
13481
    }
12251
  }
13482
 
12252
 
13483
  if (ndl_n_heavyatoms > 1)
12253
  if (ndl_n_heavyatoms > 1) {
13484
    {
-
 
13485
      for (i = 0; i < ndl_n_atoms; i++)
12254
    for (i = 0; i < ndl_n_atoms; i++) {
13486
        {
-
 
13487
          /*if atom^[i].atype <> ndl_atom^[i].atype then res := false;    (* changed in */
12255
            /*if atom^[i].atype <> ndl_atom^[i].atype then res := false;    (* changed in */
13488
          if (strcmp (atom[i].element, ndl_atom[i].element))    /* v0.2k */
12256
            if (strcmp (atom[i].element, ndl_atom[i].element))  /* v0.2k */
13489
            return false;
12257
              return false;
13490
          //  if (atom[i].formal_charge != ndl_atom[i].formal_charge) /* v0.3o */
12258
            //  if (atom[i].formal_charge != ndl_atom[i].formal_charge) /* v0.3o */
13491
          //res = false;
12259
            //res = false;
13492
 
-
 
13493
 
12260
 
13494
          if (opt_chg)
12261
            if (opt_chg) {
13495
            {
-
 
13496
              if (ndl_atom[i].formal_charge != atom[i].formal_charge)
12262
              if (ndl_atom[i].formal_charge != atom[i].formal_charge)
13497
                return false;
12263
                      return false;
13498
            }
12264
            }
13499
/*  else
12265
      /*  else {
13500
    {
-
 
13501
      if (ndl_atom[i].formal_charge != 0 &&
12266
            if (ndl_atom[i].formal_charge != 0 &&
13502
          atom[i].formal_charge != 0 &&
12267
          atom[i].formal_charge != 0 &&
13503
          ndl_atom[i].formal_charge != atom[i].formal_charge)
12268
          ndl_atom[i].formal_charge != atom[i].formal_charge)
13504
        return false;
12269
        return false;
13505
    } */
12270
          } */
13506
 
12271
 
13507
          /* v0.3x: isotopes must be the same */
12272
          /* v0.3x: isotopes must be the same */
13508
          if (opt_iso)
12273
            if (opt_iso) {
13509
            {
-
 
13510
              if (ndl_atom[i].nucleon_number != atom[i].nucleon_number)
12274
              if (ndl_atom[i].nucleon_number != atom[i].nucleon_number)
13511
                return false;
12275
                      return false;
13512
            }
12276
            }
13513
/*  else
12277
          /*  else {
13514
    {
-
 
13515
      if (ndl_atom[i].nucleon_number != 0 &&
12278
          if (ndl_atom[i].nucleon_number != 0 &&
13516
          atom[i].nucleon_number != 0 &&
12279
          atom[i].nucleon_number != 0 &&
13517
          ndl_atom[i].nucleon_number !=
12280
          ndl_atom[i].nucleon_number !=
13518
          atom[i].nucleon_number)
12281
          atom[i].nucleon_number)
13519
        return false;
12282
        return false;
13520
    }*/
12283
        }*/
13521
 
12284
 
13522
          /* v0.3x: radicals must be the same */
12285
            /* v0.3x: radicals must be the same */
13523
          if (opt_rad)
12286
            if (opt_rad) {
13524
            {
-
 
13525
              if (ndl_atom[i].radical_type != atom[i].radical_type)
12287
              if (ndl_atom[i].radical_type != atom[i].radical_type)
13526
                return false;
12288
                      return false;
13527
            }
12289
            }
13528
/*  else
12290
      /*  else {
13529
    {
-
 
13530
      if (ndl_atom[i].radical_type != 0 &&
12291
         if (ndl_atom[i].radical_type != 0 &&
13531
          atom[i].radical_type != 0 &&
12292
             atom[i].radical_type != 0 &&
13532
          ndl_atom[i].radical_type != atom[i].radical_type)
12293
             ndl_atom[i].radical_type != atom[i].radical_type)
13533
        return false;
12294
           return false;
13534
    }*/
12295
       }*/
13535
 
-
 
13536
        }
-
 
13537
/* p2c: checkmol.pas, line 9798:
-
 
13538
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
-
 
13539
      /*$IFDEF debug */
-
 
13540
      //if (res)
-
 
13541
      //debugoutput (" ==> quick_match: atoms OK");
-
 
13542
      //else
-
 
13543
      //  debugoutput (" ==> quick_match: atoms not OK");
-
 
13544
      /*$ENDIF */
-
 
13545
      if (ndl_n_bonds > 0)
-
 
13546
        {
-
 
13547
 
12296
 
13548
          for (i = 0; i < ndl_n_bonds; i++)
-
 
13549
            {
-
 
13550
              if (ndl_bond[i].a1 != bond[i].a1 || ndl_bond[i].a2 != bond[i].a2
-
 
13551
                  || ndl_bond[i].btype != bond[i].btype)
-
 
13552
                return false;
-
 
13553
            }
-
 
13554
        }
12297
        }
13555
/* p2c: checkmol.pas, line 9810:
12298
  /* p2c: checkmol.pas, line 9798:
13556
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
12299
  * Note: Turbo Pascal conditional compilation directive was ignored [218] */
13557
      /*$IFDEF debug */
12300
      /*$IFDEF debug */
13558
      //if (res)
12301
      //if (res)
13559
      //  debugoutput (" ==> quick_match: bonds OK");
12302
      //debugoutput (" ==> quick_match: atoms OK");
13560
      //else
12303
      //else
13561
      //  debugoutput (" ==> quick_match: bonds not OK");
12304
      //  debugoutput (" ==> quick_match: atoms not OK");
13562
      /*$ENDIF */
12305
      /*$ENDIF */
-
 
12306
    if (ndl_n_bonds > 0) {
-
 
12307
            for (i = 0; i < ndl_n_bonds; i++) {
13563
      /* added in v0.2d: special case: needle contains only one heavy atom; refined in v0.3l, v0.3o */
12308
              if (ndl_bond[i].a1 != bond[i].a1 || ndl_bond[i].a2 != bond[i].a2
-
 
12309
                        || ndl_bond[i].btype != bond[i].btype)
-
 
12310
                      return false;
13564
    }
12311
            }
13565
  else
12312
          }
-
 
12313
    /* p2c: checkmol.pas, line 9810:
-
 
12314
    * Note: Turbo Pascal conditional compilation directive was ignored [218] */
-
 
12315
         /*$IFDEF debug */
-
 
12316
         //if (res)
-
 
12317
         //  debugoutput (" ==> quick_match: bonds OK");
-
 
12318
         //else
-
 
12319
         //  debugoutput (" ==> quick_match: bonds not OK");
-
 
12320
         /*$ENDIF */
-
 
12321
         /* added in v0.2d: special case: needle contains only one heavy atom; refined in v0.3l, v0.3o */
13566
    {
12322
   }
13567
 
12323
  else {
13568
      /* first, find out the element and atom type of the only heavy atom       */
12324
    /* first, find out the element and atom type of the only heavy atom       */
13569
      for (i = 0; i < ndl_n_atoms; i++)
12325
    for (i = 0; i < ndl_n_atoms; i++) {
13570
        {
-
 
13571
          if (ndl_atom[i].heavy)
12326
            if (ndl_atom[i].heavy) {
13572
            {
-
 
13573
              //strcpy (ndl_atype, ndl_atom[i].atype);
12327
              //strcpy (ndl_atype, ndl_atom[i].atype);
13574
              strcpy (ndl_el, ndl_atom[i].element);     /* v0.3l */
12328
              strcpy (ndl_el, ndl_atom[i].element);     /* v0.3l */
13575
              ndl_chg = ndl_atom[i].formal_charge;      /* v0.3l */
12329
              ndl_chg = ndl_atom[i].formal_charge;      /* v0.3l */
13576
              ndl_iso = ndl_atom[i].nucleon_number;     /* 0.3x */
12330
              ndl_iso = ndl_atom[i].nucleon_number;     /* 0.3x */
13577
              ndl_rad = ndl_atom[i].radical_type;       /* 0.3x */
12331
              ndl_rad = ndl_atom[i].radical_type;       /* 0.3x */
13578
            }
12332
            }
13579
        }
12333
          }
13580
 
-
 
13581
      for (i = 0; i < n_atoms; i++)
12334
    for (i = 0; i < n_atoms; i++) {                     /* v0.3l, v0.3o */
13582
        {                       /* v0.3l, v0.3o */
-
 
13583
          if (          /     !strcmp (atom[i].atype, ndl_atype) && 
12335
            if (                /     !strcmp (atom[i].atype, ndl_atype) &&
13584
               !strcmp (atom[i].element, ndl_el))
12336
                !strcmp (atom[i].element, ndl_el)) {
13585
            {
-
 
13586
           
-
 
13587
 
-
 
13588
              if (opt_chg || opt_strict)
12337
              if (opt_chg || opt_strict) {
13589
                {
-
 
13590
                  if (ndl_chg != atom[i].formal_charge)
12338
                      if (ndl_chg != atom[i].formal_charge)
13591
                    return false;
12339
                        return false;
13592
                }
12340
                    }
13593
 
-
 
13594
 
-
 
13595
              if (opt_iso || opt_strict)
12341
              if (opt_iso || opt_strict) {
13596
                {
-
 
13597
                  if (ndl_iso != atom[i].nucleon_number)
12342
                      if (ndl_iso != atom[i].nucleon_number)
13598
                    return false;
12343
                        return false;
13599
                }
12344
                    }
13600
 
-
 
13601
 
-
 
13602
 
12345
 
13603
              if (opt_rad || opt_strict)
12346
              if (opt_rad || opt_strict) {
13604
                {
-
 
13605
                  if (ndl_rad != atom[i].radical_type)
12347
                      if (ndl_rad != atom[i].radical_type)
13606
                    return false;
12348
                        return false;
13607
                }
12349
                    }
13608
                  return true;
12350
                    return true;
-
 
12351
            }
13609
            } else {
12352
            else {
13610
                res=false;
12353
              res=false;
13611
            }    
12354
            }
13612
        }
12355
          }
13613
    }
12356
  }
13614
/* p2c: checkmol.pas, line 9828:
12357
  /* p2c: checkmol.pas, line 9828:
13615
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
12358
  * Note: Turbo Pascal conditional compilation directive was ignored [218] */
13616
  /*$IFDEF debug */
12359
  /*$IFDEF debug */
13617
  //if (res)
12360
  //if (res)
13618
  //  debugoutput (" ==> quick_match succeeded");
12361
  //  debugoutput (" ==> quick_match succeeded");
13619
  //else
12362
  //else
13620
  //  debugoutput (" ==> quick_match failed (2)");
12363
  //  debugoutput (" ==> quick_match failed (2)");
13621
  /*$ENDIF */
12364
  /*$ENDIF */
13622
  return res;
12365
  return res;
13623
}
12366
}
13624
 
12367
 
13625
static void
-
 
13626
perform_match ()
12368
static void perform_match ()
13627
{
12369
{
13628
  int i = 0;
12370
  int i = 0;
13629
  int j;
12371
  int j;
13630
  /*ndl_ref_atom : integer;  (* since v0.3j as a global variable */
12372
  /*ndl_ref_atom : integer;  (* since v0.3j as a global variable */
13631
  int ndl_n_nb, ndl_n_hc, n_nb, n_hc;
12373
  int ndl_n_nb, ndl_n_hc, n_nb, n_hc;
13632
  boolean qm;                   /* v0.3l */
12374
  boolean qm;                   /* v0.3l */
13633
  /* check for NoStruct (0 atoms);  v0.3l */
12375
  /* check for NoStruct (0 atoms);  v0.3l */
13634
  if (n_atoms == 0 || ndl_n_atoms == 0)
12376
  if (n_atoms == 0 || ndl_n_atoms == 0) {
13635
    {
-
 
13636
      matchresult = false;
12377
      matchresult = false;
13637
/* p2c: checkmol.pas, line 9849:
12378
  /* p2c: checkmol.pas, line 9849:
13638
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
12379
  * Note: Turbo Pascal conditional compilation directive was ignored [218] */
13639
      /*$IFDEF debug */
12380
      /*$IFDEF debug */
13640
      //debugoutput ("NoStruct encountered - aborted match routine");
12381
      //debugoutput ("NoStruct encountered - aborted match routine");
13641
      /*$ENDIF */
12382
      /*$ENDIF */
13642
      return;
12383
    return;
13643
    }
12384
  }
13644
  /* if we perform an exact match, needle and haystack must have */
12385
  /* if we perform an exact match, needle and haystack must have */
13645
  /* the same number of atoms, bonds, and rings */
12386
  /* the same number of atoms, bonds, and rings */
13646
  if (opt_exact && opt_iso)     /* 0.3x */
12387
  if (opt_exact && opt_iso)     /* 0.3x */ {
13647
    {
-
 
13648
      if (n_heavyatoms != ndl_n_heavyatoms
12388
      if (n_heavyatoms != ndl_n_heavyatoms || n_heavybonds != ndl_n_heavybonds) {
13649
          || n_heavybonds != ndl_n_heavybonds)
-
 
13650
        {
-
 
13651
          matchresult = false;
12389
              matchresult = false;
13652
/* p2c: checkmol.pas, line 9861:
12390
      /* p2c: checkmol.pas, line 9861:
13653
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
12391
      * Note: Turbo Pascal conditional compilation directive was ignored [218] */
13654
          /*$IFDEF debug */
12392
          /*$IFDEF debug */
13655
          //debugoutput ("different number of heavy atoms and/or bonds");
12393
          //debugoutput ("different number of heavy atoms and/or bonds");
13656
          /*$ENDIF */
12394
          /*$ENDIF */
13657
          //return;
12395
          //return;
13658
        }
12396
          }
13659
    }
12397
  }
13660
 
12398
 
13661
  /* have a quick look if needle and haystack are identical molfiles */
12399
  /* have a quick look if needle and haystack are identical molfiles */
13662
  qm = quick_match ();          /* v0.3l */
12400
  qm = quick_match ();          /* v0.3l */
13663
  if (qm)
12401
  if (qm) {
13664
    {
-
 
13665
      matchresult = true;
12402
    matchresult = true;
13666
      clear_ndl_atom_tags ();   /* v0.3o */
12403
    clear_ndl_atom_tags ();     /* v0.3o */
13667
      return;
12404
    return;
13668
    }
12405
  }
13669
  /* if we have only one heavy atom and quick_match fails, return "false";  v0.3l */
12406
  /* if we have only one heavy atom and quick_match fails, return "false";  v0.3l */
13670
  if (ndl_n_heavyatoms == 1)
12407
  if (ndl_n_heavyatoms == 1) {
13671
    {
-
 
13672
      matchresult = false;
12408
    matchresult = false;
13673
      return;
12409
    return;
13674
    }
12410
  }
13675
/* p2c: checkmol.pas, line 9881:
12411
  /* p2c: checkmol.pas, line 9881:
13676
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
12412
  * Note: Turbo Pascal conditional compilation directive was ignored [218] */
13677
  /*$IFDEF debug */
12413
  /*$IFDEF debug */
13678
  /* debugoutput('needle reference atom: '+inttostr(ndl_ref_atom)+' ('+ndl_atom^[ndl_ref_atom].atype+')'); */
12414
  /* debugoutput('needle reference atom: '+inttostr(ndl_ref_atom)+' ('+ndl_atom^[ndl_ref_atom].atype+')'); */
13679
  /*$ENDIF */
12415
  /*$ENDIF */
13680
  ndl_n_nb = ndl_atom[ndl_ref_atom - 1].neighbor_count;
12416
  ndl_n_nb = ndl_atom[ndl_ref_atom - 1].neighbor_count;
13681
  ndl_n_hc = ndl_hetatom_count (ndl_ref_atom);
12417
  ndl_n_hc = ndl_hetatom_count (ndl_ref_atom);
13682
/* p2c: checkmol.pas, line 9886:
12418
  /* p2c: checkmol.pas, line 9886:
13683
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
12419
  * Note: Turbo Pascal conditional compilation directive was ignored [218] */
13684
  /*$IFDEF debug */
12420
  /*$IFDEF debug */
13685
  /* debugoutput('neighbor atoms: '+inttostr(ndl_n_nb)+'  heteroatom neighbors: '+inttostr(ndl_n_hc)); */
12421
  /* debugoutput('neighbor atoms: '+inttostr(ndl_n_nb)+'  heteroatom neighbors: '+inttostr(ndl_n_hc)); */
13686
  /*$ENDIF */
12422
  /*$ENDIF */
13687
  matchresult = false;
12423
  matchresult = false;
13688
  for (j = 0; j < max_matchpath_length; j++)
12424
  for (j = 0; j < max_matchpath_length; j++) {
13689
    {
-
 
13690
      ndl_matchpath[j] = 0;
12425
    ndl_matchpath[j] = 0;
13691
      hst_matchpath[j] = 0;
12426
    hst_matchpath[j] = 0;
13692
    }
12427
  }
13693
  ndl_matchpath[0] = ndl_ref_atom;
12428
  ndl_matchpath[0] = ndl_ref_atom;
13694
  while (i < n_atoms && matchresult == false)
12429
  while (i < n_atoms && matchresult == false) {
13695
    {
-
 
13696
      i++;
12430
    i++;
13697
      n_nb = atom[i - 1].neighbor_count;
12431
    n_nb = atom[i - 1].neighbor_count;
13698
      n_hc = hetatom_count (i);
12432
    n_hc = hetatom_count (i);
13699
      if (n_nb >= ndl_n_nb && n_hc >= ndl_n_hc)
12433
    if (n_nb >= ndl_n_nb && n_hc >= ndl_n_hc) {
13700
        {
-
 
13701
/* p2c: checkmol.pas, line 9904:
12434
      /* p2c: checkmol.pas, line 9904:
13702
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
12435
      * Note: Turbo Pascal conditional compilation directive was ignored [218] */
13703
          /*$IFDEF debug */
12436
              /*$IFDEF debug */
13704
          /* debugoutput('trying atom '+inttostr(i)+'; neighbor atoms: '+inttostr(n_nb)+' heteroatom neighbors: '+inttostr(n_hc)); */
12437
              /* debugoutput('trying atom '+inttostr(i)+'; neighbor atoms: '+inttostr(n_nb)+' heteroatom neighbors: '+inttostr(n_hc)); */
13705
          /*$ENDIF */
12438
              /*$ENDIF */
13706
 
12439
 
13707
          recursion_depth = 0;
12440
            recursion_depth = 0;
13708
          hst_matchpath[0] = i;
12441
            hst_matchpath[0] = i;
13709
          matchresult = is_matching (ndl_matchpath, hst_matchpath);
12442
            matchresult = is_matching (ndl_matchpath, hst_matchpath);
13710
/* p2c: checkmol.pas, line 9909:
12443
      /* p2c: checkmol.pas, line 9909:
13711
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
12444
       * Note: Turbo Pascal conditional compilation directive was ignored [218] */
13712
          /*$IFDEF debug */
12445
          /*$IFDEF debug */
13713
          /* if matchresult then debugoutput('matching atom in haystack: '+inttostr(i)+' ('+atom^[i].atype+')'); */
12446
          /* if matchresult then debugoutput('matching atom in haystack: '+inttostr(i)+' ('+atom^[i].atype+')'); */
13714
          /*$ENDIF */
12447
          /*$ENDIF */
13715
          if (matchresult)      /* v0.3o; mark this fragment as matched */
12448
      if (matchresult)  /* v0.3o; mark this fragment as matched */
13716
            atom[i - 1].tag = true;
12449
        atom[i - 1].tag = true;
13717
        }
12450
          }
13718
    }
12451
  }
13719
}
12452
}
13720
 
12453
 
13721
 
-
 
13722
static void
-
 
13723
clear_rings ()
12454
static void clear_rings ()
13724
{
12455
{
13725
  int i, FORLIM;
12456
  int i, FORLIM;
13726
  n_rings = 0;
12457
  n_rings = 0;
13727
  memset (ring, 0, sizeof (ringlist));
12458
  memset (ring, 0, sizeof (ringlist));
13728
  for (i = 0; i < max_rings; i++)
12459
  for (i = 0; i < max_rings; i++) {                             /* new in v0.3 */
13729
    {                           /* new in v0.3 */
-
 
13730
      ringprop[i].size = 0;
12460
    ringprop[i].size = 0;
13731
      ringprop[i].arom = false;
12461
    ringprop[i].arom = false;
13732
      ringprop[i].envelope = false;
12462
    ringprop[i].envelope = false;
13733
    }
12463
  }
13734
  if (n_atoms > 0)
12464
  if (n_atoms > 0) {
13735
    {
-
 
13736
      FORLIM = n_atoms;
12465
    FORLIM = n_atoms;
13737
      for (i = 0; i < FORLIM; i++)
12466
    for (i = 0; i < FORLIM; i++)
13738
        atom[i].ring_count = 0;
12467
            atom[i].ring_count = 0;
13739
    }
12468
  }
13740
  if (n_bonds > 0)
12469
  if (n_bonds > 0) {
13741
    {
-
 
13742
      FORLIM = n_bonds;
12470
    FORLIM = n_bonds;
13743
      for (i = 0; i < FORLIM; i++)
12471
    for (i = 0; i < FORLIM; i++)
13744
        bond[i].ring_count = 0;
12472
            bond[i].ring_count = 0;
13745
    }
12473
  }
13746
}
12474
}
13747
 
12475
 
13748
 
-
 
13749
static int
-
 
13750
ring_lastpos (s)
12476
static int ring_lastpos (s)
13751
     int *s;
12477
     int *s;
13752
{
12478
{
13753
  int i, rc;
12479
  int i, rc;
13754
  int rlp = 0;
12480
  int rlp = 0;
13755
  int FORLIM;
12481
  int FORLIM;
13756
  if (n_rings <= 0)
12482
  if (n_rings <= 0)
13757
    return rlp;
12483
    return rlp;
13758
  FORLIM = n_rings;
12484
  FORLIM = n_rings;
13759
  for (i = 1; i <= FORLIM; i++)
12485
  for (i = 1; i <= FORLIM; i++) {
13760
    {
-
 
13761
      rc = ringcompare (s, ring[i - 1]);
12486
    rc = ringcompare (s, ring[i - 1]);
13762
      if (rc_identical (rc))
12487
    if (rc_identical (rc))
13763
        rlp = i;
12488
            rlp = i;
13764
    }
12489
  }
13765
  return rlp;
12490
  return rlp;
13766
}
12491
}
13767
 
12492
 
13768
 
-
 
13769
static void
-
 
13770
remove_redundant_rings ()
12493
static void remove_redundant_rings ()
13771
{
12494
{
13772
  int i, j, k, rlp;
12495
  int i, j, k, rlp;
13773
  ringpath_type tmp_path;
12496
  ringpath_type tmp_path;
13774
  int FORLIM, FORLIM1;
12497
  int FORLIM, FORLIM1;
13775
  if (n_rings < 2)
12498
  if (n_rings < 2)
13776
    return;
12499
    return;
13777
  FORLIM = n_rings;
12500
  FORLIM = n_rings;
13778
  for (i = 1; i < FORLIM; i++)
12501
  for (i = 1; i < FORLIM; i++) {
13779
    {
-
 
13780
      memcpy (tmp_path, ring[i - 1], sizeof (ringpath_type));
12502
    memcpy (tmp_path, ring[i - 1], sizeof (ringpath_type));
13781
      rlp = ring_lastpos (tmp_path);
12503
    rlp = ring_lastpos (tmp_path);
13782
      while (rlp > i)
12504
    while (rlp > i) {
13783
        {
-
 
13784
          FORLIM1 = n_rings;
12505
           FORLIM1 = n_rings;
13785
/* p2c: checkmol.pas, line 9970:
12506
      /* p2c: checkmol.pas, line 9970:
13786
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
12507
    * Note: Turbo Pascal conditional compilation directive was ignored [218] */
13787
          /*$IFDEF debug */
12508
          /*$IFDEF debug */
13788
          /* debugoutput('removing redundant ring: '+inttostr(rlp)+' (identical to ring '+inttostr(i)+')'); */
12509
          /* debugoutput('removing redundant ring: '+inttostr(rlp)+' (identical to ring '+inttostr(i)+')'); */
13789
          /*$ENDIF */
12510
          /*$ENDIF */
13790
          for (j = rlp; j < FORLIM1; j++)
12511
            for (j = rlp; j < FORLIM1; j++) {
13791
            {
-
 
13792
              memcpy (ring[j - 1], ring[j], sizeof (ringpath_type));
12512
              memcpy (ring[j - 1], ring[j], sizeof (ringpath_type));
13793
              ringprop[j - 1].size = ringprop[j].size;  /* new in v0.3 */
12513
              ringprop[j - 1].size = ringprop[j].size;  /* new in v0.3 */
13794
              ringprop[j - 1].arom = ringprop[j].arom;
12514
              ringprop[j - 1].arom = ringprop[j].arom;
13795
              ringprop[j - 1].envelope = ringprop[j].envelope;
12515
              ringprop[j - 1].envelope = ringprop[j].envelope;
13796
            }
12516
            }
13797
          for (k = 0; k < max_ringsize; k++)
12517
            for (k = 0; k < max_ringsize; k++)
13798
            ring[n_rings - 1][k] = 0;
12518
              ring[n_rings - 1][k] = 0;
13799
          n_rings--;
12519
            n_rings--;
13800
          rlp = ring_lastpos (tmp_path);
12520
            rlp = ring_lastpos (tmp_path);
13801
        }
12521
          }
13802
    }
12522
  }
13803
}
12523
}
13804
 
12524
 
13805
 
-
 
13806
static int
-
 
13807
count_aromatic_rings ()
12525
static int count_aromatic_rings ()
13808
{
12526
{
13809
  int i;
12527
  int i;
13810
  int n = 0;
12528
  int n = 0;
13811
  int FORLIM;
12529
  int FORLIM;
13812
  if (n_rings <= 0)
12530
  if (n_rings <= 0)
13813
    return n;
12531
    return n;
13814
  FORLIM = n_rings;
12532
  FORLIM = n_rings;
13815
  for (i = 0; i < FORLIM; i++)
12533
  for (i = 0; i < FORLIM; i++) {
13816
    {
-
 
13817
      if (ringprop[i].arom)
12534
    if (ringprop[i].arom)
13818
        n++;
12535
            n++;
13819
    }
12536
  }
13820
  return n;
12537
  return n;
13821
}
12538
}
13822
 
12539
 
13823
 
-
 
13824
static void
-
 
13825
chk_envelopes ()
12540
static void chk_envelopes ()
13826
{
12541
{
13827
  /* new in v0.3d */
12542
  /* new in v0.3d */
13828
  /* checks if a ring completely contains one or more other rings */
12543
  /* checks if a ring completely contains one or more other rings */
13829
  int a, i, j, k, l, pl, pli;
12544
  int a, i, j, k, l, pl, pli;
13830
  boolean found_atom, found_all_atoms, found_ring;
12545
  boolean found_atom, found_all_atoms, found_ring;
13831
  int FORLIM;
12546
  int FORLIM;
13832
  if (n_rings < 2)
12547
  if (n_rings < 2)
13833
    return;
12548
    return;
13834
  FORLIM = n_rings;
12549
  FORLIM = n_rings;
13835
  for (i = 1; i < FORLIM; i++)
12550
  for (i = 1; i < FORLIM; i++) {
13836
    {
-
 
13837
      found_ring = false;
12551
    found_ring = false;
13838
      j = 0;
12552
    j = 0;
13839
      pli = ringprop[i].size;   /* path_length(ring^[i]); */
12553
    pli = ringprop[i].size;     /* path_length(ring^[i]); */
13840
      while (j < i && found_ring == false)
12554
    while (j < i && found_ring == false) {
13841
        {
-
 
13842
          j++;
12555
            j++;
13843
          found_all_atoms = true;
12556
            found_all_atoms = true;
13844
          pl = ringprop[j - 1].size;    /* path_length(ring^[j]); */
12557
            pl = ringprop[j - 1].size;  /* path_length(ring^[j]); */
13845
          for (k = 0; k < pl; k++)
12558
            for (k = 0; k < pl; k++) {
13846
            {
-
 
13847
              found_atom = false;
12559
              found_atom = false;
13848
              a = ring[j - 1][k];
12560
              a = ring[j - 1][k];
13849
              for (l = 0; l < pli; l++)
12561
              for (l = 0; l < pli; l++) {
13850
                {
-
 
13851
                  if (ring[i][l] == a)
12562
                      if (ring[i][l] == a)
13852
                    found_atom = true;
12563
                        found_atom = true;
13853
                }
12564
                    }
13854
              if (found_atom == false)
12565
              if (found_atom == false)
13855
                found_all_atoms = false;
12566
                      found_all_atoms = false;
13856
            }
12567
            }
13857
          if (found_all_atoms)
12568
            if (found_all_atoms)
13858
            found_ring = true;
12569
              found_ring = true;
13859
        }
12570
          }
13860
      if (found_ring)
12571
    if (found_ring)
13861
        ringprop[i].envelope = true;
12572
            ringprop[i].envelope = true;
13862
    }
12573
  }
13863
}
12574
}
13864
 
12575
 
13865
 
-
 
13866
static void
-
 
13867
update_ringcount ()
12576
static void update_ringcount ()
13868
{
12577
{
13869
  int i, j, a1, a2, b, pl, FORLIM;
12578
  int i, j, a1, a2, b, pl, FORLIM;
13870
  if (n_rings <= 0)
12579
  if (n_rings <= 0)
13871
    return;
12580
    return;
13872
  chk_envelopes ();
12581
  chk_envelopes ();
13873
  FORLIM = n_rings;
12582
  FORLIM = n_rings;
13874
  for (i = 0; i < FORLIM; i++)
12583
  for (i = 0; i < FORLIM; i++) {
13875
    {
-
 
13876
      if (ringprop[i].envelope == false)
12584
      if (ringprop[i].envelope == false) {
13877
        {
-
 
13878
          pl = ringprop[i].size;        /* path_length(ring^[i]);  (* v0.3d */
12585
            pl = ringprop[i].size;      /* path_length(ring^[i]);  (* v0.3d */
13879
          a2 = ring[i][pl - 1];
12586
            a2 = ring[i][pl - 1];
13880
          for (j = 0; j < pl; j++)
12587
            for (j = 0; j < pl; j++) {
13881
            {
-
 
13882
              a1 = ring[i][j];
12588
              a1 = ring[i][j];
13883
              atom[a1 - 1].ring_count++;
12589
              atom[a1 - 1].ring_count++;
13884
              b = get_bond (a1, a2);
12590
              b = get_bond (a1, a2);
13885
              bond[b - 1].ring_count++;
12591
              bond[b - 1].ring_count++;
13886
              a2 = a1;
12592
              a2 = a1;
13887
            }
12593
            }
13888
        }
12594
          }
13889
    }
12595
  }
13890
}
12596
}
13891
 
12597
 
13892
 
-
 
13893
static boolean
-
 
13894
normalize_ionic_bonds ()
12598
static boolean normalize_ionic_bonds ()
13895
{
12599
{
13896
  /* v0.3k */
12600
  /* v0.3k */
13897
  /* changed from a procedure into a function in v0.3m */
12601
  /* changed from a procedure into a function in v0.3m */
13898
  int i, a1, a2, fc1, fc2;
12602
  int i, a1, a2, fc1, fc2;
13899
  char bt;
12603
  char bt;
Line 13901... Line 12605...
13901
  int FORLIM;
12605
  int FORLIM;
13902
  /* v0.3m */
12606
  /* v0.3m */
13903
  if (n_bonds == 0)
12607
  if (n_bonds == 0)
13904
    return false;
12608
    return false;
13905
  FORLIM = n_bonds;
12609
  FORLIM = n_bonds;
13906
  for (i = 0; i < FORLIM; i++)
12610
  for (i = 0; i < FORLIM; i++) {
13907
    {
-
 
13908
      a1 = bond[i].a1;
12611
    a1 = bond[i].a1;
13909
      a2 = bond[i].a2;
12612
    a2 = bond[i].a2;
13910
      bt = bond[i].btype;
12613
    bt = bond[i].btype;
13911
      fc1 = atom[a1 - 1].formal_charge;
12614
    fc1 = atom[a1 - 1].formal_charge;
13912
      fc2 = atom[a2 - 1].formal_charge;
12615
    fc2 = atom[a2 - 1].formal_charge;
13913
      if (fc1 * fc2 == -1 && (bt == 'S' || bt == 'D'))
12616
    if (fc1 * fc2 == -1 && (bt == 'S' || bt == 'D')) {
13914
        {
-
 
13915
          atom[a1 - 1].formal_charge = 0;
12617
            atom[a1 - 1].formal_charge = 0;
13916
          atom[a2 - 1].formal_charge = 0;
12618
            atom[a2 - 1].formal_charge = 0;
13917
          if (!strcmp (atom[a1 - 1].atype, "N3+"))      /* v0.3m */
12619
            if (!strcmp (atom[a1 - 1].atype, "N3+"))    /* v0.3m */
13918
            strcpy (atom[a1 - 1].atype, "N3 ");
12620
              strcpy (atom[a1 - 1].atype, "N3 ");
13919
          if (!strcmp (atom[a2 - 1].atype, "N3+"))      /* v0.3m */
12621
            if (!strcmp (atom[a2 - 1].atype, "N3+"))    /* v0.3m */
13920
            strcpy (atom[a2 - 1].atype, "N3 ");
12622
              strcpy (atom[a2 - 1].atype, "N3 ");
13921
          if (bt == 'D')
12623
            if (bt == 'D')
13922
            bond[i].btype = 'T';
12624
              bond[i].btype = 'T';
13923
          if (bt == 'S')
12625
            if (bt == 'S')
13924
            bond[i].btype = 'D';
12626
              bond[i].btype = 'D';
13925
          res = true;           /* v0.3m */
12627
            res = true;         /* v0.3m */
13926
        }
12628
          }
13927
    }
12629
  }
13928
  return res;                   /* v0.3m (return true if any change was made */
12630
  return res;                   /* v0.3m (return true if any change was made */
13929
}
12631
}
13930
 
12632
 
13931
#if 0
12633
#if 0
13932
static void
-
 
13933
chk_wildcard_rings ()           // new in v0.3p
12634
static void chk_wildcard_rings ()               // new in v0.3p
13934
// checks if there are any wildcard atom types or bond types
12635
// checks if there are any wildcard atom types or bond types
13935
// in a ring of the needle; if yes ==> set the q_arom flag in the
12636
// in a ring of the needle; if yes ==> set the q_arom flag in the
13936
// atom and bond record of all ring members in order to perform the 
12637
// atom and bond record of all ring members in order to perform the
13937
// match a bit more generously
12638
// match a bit more generously
13938
{
12639
{
13939
 
12640
 
13940
  int i, j, rs;
12641
  int i, j, rs;
13941
  int a1, a2, b;
12642
  int a1, a2, b;
13942
  boolean wcr;
12643
  boolean wcr;
13943
  str3 at;
12644
  str3 at;
13944
  char bt;
12645
  char bt;
13945
 
12646
 
13946
  if (ndl_querymol == false)
12647
  if (ndl_querymol == false)
13947
    return;
12648
    return;
13948
  if (ndl_n_rings == 0)
12649
  if (ndl_n_rings == 0)
13949
    return;
12650
    return;
13950
  // now look for any not-yet-aromatic rings which contain a wildcard
12651
  // now look for any not-yet-aromatic rings which contain a wildcard
13951
  for (i = 0; i < ndl_n_rings; i++)
12652
  for (i = 0; i < ndl_n_rings; i++) {
13952
    {
-
 
13953
      wcr = false;
12653
    wcr = false;
13954
      if (ndl_ringprop[i].arom == false)
12654
    if (ndl_ringprop[i].arom == false) {
13955
        {
-
 
13956
          rs = ndl_ringprop[i].size;
12655
            rs = ndl_ringprop[i].size;
13957
          a2 = ndl_ring[i][rs];
12656
            a2 = ndl_ring[i][rs];
13958
          for (j = 0; j < rs; j++)
12657
            for (j = 0; j < rs; j++) {
13959
            {
-
 
13960
              a1 = ndl_ring[i][j];
12658
              a1 = ndl_ring[i][j];
13961
              b = get_ndl_bond (a1, a2);
12659
              b = get_ndl_bond (a1, a2);
13962
              strcpy (at, ndl_atom[a1].atype);
12660
              strcpy (at, ndl_atom[a1].atype);
13963
              bt = ndl_bond[b].btype;
12661
              bt = ndl_bond[b].btype;
13964
              if (!strcmp (at, "A  ") || !strcmp (at, "Q  "))
12662
              if (!strcmp (at, "A  ") || !strcmp (at, "Q  "))
13965
                wcr = true;
12663
                      wcr = true;
13966
              if (bt == 'l' || bt == 's' || bt == 'd' || bt == 'a')
12664
              if (bt == 'l' || bt == 's' || bt == 'd' || bt == 'a')
13967
                wcr = true;
12665
                      wcr = true;
13968
              a2 = a1;
12666
              a2 = a1;
13969
            }
12667
            }
13970
          if (wcr)
-
 
13971
            {                   // if yes, flag all atoms and bonds in this ring as "potentially" aromatic
12668
            if (wcr) {                  // if yes, flag all atoms and bonds in this ring as "potentially" aromatic
13972
              // {$IFDEF debug}
12669
              // {$IFDEF debug}
13973
              // debugoutput('wildcard ring found');
12670
              // debugoutput('wildcard ring found');
13974
              // {$ENDIF}
12671
              // {$ENDIF}
13975
              a2 = ndl_ring[i][rs];
12672
              a2 = ndl_ring[i][rs];
13976
              for (j = 0; j < rs; j++)
12673
              for (j = 0; j < rs; j++) {
13977
                {
-
 
13978
                  a1 = ndl_ring[i][j];
12674
                      a1 = ndl_ring[i][j];
13979
                  b = get_ndl_bond (a1, a2);
12675
                      b = get_ndl_bond (a1, a2);
13980
                  strcpy (at, ndl_atom[a1].atype);
12676
                      strcpy (at, ndl_atom[a1].atype);
13981
                  bt = ndl_bond[b].btype;
12677
                      bt = ndl_bond[b].btype;
13982
                  ndl_atom[a1].q_arom = true;
12678
                      ndl_atom[a1].q_arom = true;
13983
                  ndl_bond[b].q_arom = true;
12679
                      ndl_bond[b].q_arom = true;
13984
                  a2 = a1;
12680
                      a2 = a1;
13985
                }
12681
                    }
13986
            }
12682
            }
13987
        }
12683
          }
13988
    }
12684
  }
13989
  // and now undo this flagging for all rings which contain no wildcard
12685
  // and now undo this flagging for all rings which contain no wildcard
13990
  for (i = 0; i < ndl_n_rings; i++)
12686
  for (i = 0; i < ndl_n_rings; i++) {
13991
    {
-
 
13992
      wcr = false;
12687
    wcr = false;
13993
      rs = ndl_ringprop[i].size;
12688
    rs = ndl_ringprop[i].size;
13994
      a2 = ndl_ring[i][rs];
12689
    a2 = ndl_ring[i][rs];
13995
      for (j = 0; j < rs; j++)
12690
    for (j = 0; j < rs; j++) {
13996
        {
-
 
13997
          a1 = ndl_ring[i][j];
12691
            a1 = ndl_ring[i][j];
13998
          b = get_ndl_bond (a1, a2);
12692
            b = get_ndl_bond (a1, a2);
13999
          strcpy (at, ndl_atom[a1].atype);
12693
            strcpy (at, ndl_atom[a1].atype);
14000
          bt = ndl_bond[b].btype;
12694
            bt = ndl_bond[b].btype;
14001
          if (!strcmp (at, "A  ") || !strcmp (at, "Q  "))
12695
            if (!strcmp (at, "A  ") || !strcmp (at, "Q  "))
14002
            wcr = true;
12696
              wcr = true;
14003
          if (bt == 'l' || bt == 's' || bt == 'd' || bt == 'a')
12697
            if (bt == 'l' || bt == 's' || bt == 'd' || bt == 'a')
14004
            wcr = true;
12698
              wcr = true;
14005
          a2 = a1;
12699
            a2 = a1;
14006
        }
12700
          }
14007
      if (!wcr)
-
 
14008
        {                       // if yes, unflag all atoms and bonds in this ring
12701
    if (!wcr) {                 // if yes, unflag all atoms and bonds in this ring
14009
          a2 = ndl_ring[i][rs];
12702
            a2 = ndl_ring[i][rs];
14010
          for (j = 0; j < rs; j++)
12703
            for (j = 0; j < rs; j++) {
14011
            {
-
 
14012
              a1 = ndl_ring[i][j];
12704
              a1 = ndl_ring[i][j];
14013
              b = get_ndl_bond (a1, a2);
12705
              b = get_ndl_bond (a1, a2);
14014
              strcpy (at, ndl_atom[a1].atype);
12706
              strcpy (at, ndl_atom[a1].atype);
14015
              bt = ndl_bond[b].btype;
12707
              bt = ndl_bond[b].btype;
14016
              ndl_atom[a1].q_arom = false;
12708
              ndl_atom[a1].q_arom = false;
14017
              ndl_bond[b].q_arom = false;
12709
              ndl_bond[b].q_arom = false;
14018
              a2 = a1;
12710
              a2 = a1;
14019
            }
12711
            }
14020
        }
12712
          }
14021
    }
12713
  }
14022
  // some further refinement would be necessary here in order to unflag everything
12714
  // some further refinement would be necessary here in order to unflag everything
14023
  // which contains a wildcard but which definitely cannot be aromatic
12715
  // which contains a wildcard but which definitely cannot be aromatic
14024
}
12716
}
14025
#endif
12717
#endif
14026
 
12718
 
14027
#ifndef MAKE_SHARED_LIBRARY
12719
#ifndef MAKE_SHARED_LIBRARY
14028
 
12720
 
14029
int
-
 
14030
main (int argc, char *argv[])
12721
int main (int argc, char *argv[])
14031
{                               /* main routine */
12722
{                               /* main routine */
14032
  char STR1[256], STR6[256];
12723
  char STR1[256], STR6[256];
14033
  int FORLIM;
12724
  int FORLIM;
14034
  /* progmode = pmMatchMol */
12725
  /* progmode = pmMatchMol */
14035
  rfile = NULL;
12726
  rfile = NULL;
14036
  strcpy (progname, argv[0]);
12727
  strcpy (progname, argv[0]);
14037
  strncpy (STR1, progname, 253);
12728
  strncpy (STR1, progname, 253);
14038
  if (strstr (STR1, "matchmol") != NULL)
12729
  if (strstr (STR1, "matchmol") != NULL)
14039
    progmode = pmMatchMol;
12730
    progmode = pmMatchMol;
14040
  else
12731
  else {
14041
    {
-
 
14042
      strncpy (STR6, progname, 253);
12732
    strncpy (STR6, progname, 253);
14043
      if (strstr (STR6, "checkmol") == NULL)
12733
    if (strstr (STR6, "checkmol") == NULL) {
14044
        {
-
 
14045
          printf ("THOU SHALLST NOT RENAME ME!\n");
12734
            printf ("THOU SHALLST NOT RENAME ME!\n");
14046
          exit (9);
12735
            exit (9);
14047
        }
12736
          }
14048
      progmode = pmCheckMol;
12737
    progmode = pmCheckMol;
14049
    }
12738
  }
14050
  if (argc == 1)
12739
  if (argc == 1) {
14051
    {
-
 
14052
      show_usage ();
12740
    show_usage ();
14053
      exit (1);
12741
    exit (1);
14054
    }
12742
  }
14055
  init_globals ();
12743
  init_globals ();
14056
  init_molstat (&molstat);
12744
  init_molstat (&molstat);
14057
  parse_args (argc, argv);
12745
  parse_args (argc, argv);
14058
  if (ringsearch_mode == rs_sar)
12746
  if (ringsearch_mode == rs_sar)
14059
    max_vringsize = max_ringsize;
12747
    max_vringsize = max_ringsize;
14060
  else
12748
  else
14061
    max_vringsize = ssr_vringsize;
12749
    max_vringsize = ssr_vringsize;
14062
  /* v0.3n (was: 10) */
12750
  /* v0.3n (was: 10) */
14063
  /*if opt_verbose then writeln(progname+' v',version,'  N. Haider 2003-2007'); */
12751
  /*if opt_verbose then writeln(progname+' v',version,'  N. Haider 2003-2007'); */
14064
  if (progmode == pmMatchMol)
12752
  if (progmode == pmMatchMol) {
14065
    {
-
 
14066
      left_trim (ndl_molfilename);
12753
    left_trim (ndl_molfilename);
14067
      left_trim (molfilename);
12754
    left_trim (molfilename);
14068
      if ((*molfilename == '\0' || *ndl_molfilename == '\0'
12755
    if ((*molfilename == '\0' || *ndl_molfilename == '\0' || argc < 3) && !opt_stdin) {
14069
           || argc < 3) && !opt_stdin)
-
 
14070
        {
-
 
14071
 
-
 
14072
          show_usage ();
-
 
14073
          exit (2);             /* new in v0.2k */
-
 
14074
        }
-
 
14075
      if (!(file_exists (ndl_molfilename)) && !opt_stdin)
-
 
14076
        {                       /*not  fileexists(ndl_molfilename) REPLACE!!! */
-
 
14077
                                   printf("2");
-
 
14078
                                   /* p2c: checkmol.pas, line 10128:
-
 
14079
                                   * Warning: Expected an expression, found a ')' [227] */
-
 
14080
          if (strlen (ndl_molfilename) > 1 && ndl_molfilename[0] == '-')
-
 
14081
            show_usage ();
12756
            show_usage ();
-
 
12757
            exit (2);           /* new in v0.2k */
-
 
12758
          }
-
 
12759
    if (!(file_exists (ndl_molfilename)) && !opt_stdin) {
-
 
12760
      /*not  fileexists(ndl_molfilename) REPLACE!!! */
-
 
12761
                  printf("2");
-
 
12762
                  /* p2c: checkmol.pas, line 10128:
-
 
12763
                  * Warning: Expected an expression, found a ')' [227] */
-
 
12764
            if (strlen (ndl_molfilename) > 1 && ndl_molfilename[0] == '-')
-
 
12765
              show_usage ();
14082
          else
12766
            else
14083
            printf ("file %s not found!\n", ndl_molfilename);
12767
              printf ("file %s not found!\n", ndl_molfilename);
14084
          /* new in v0.2k */
12768
            /* new in v0.2k */
14085
          exit (2);
12769
            exit (2);
14086
        }
12770
          }
14087
    }
12771
  }
-
 
12772
 
-
 
12773
  if (!(file_exists (molfilename)) && !opt_stdin) {                             /*not  fileexists(ndl_molfilename) REPLACE!!! */
-
 
12774
    /* p2c: checkmol.pas, line 10128:
-
 
12775
    * Warning: Expected an expression, found a ')' [227] */
14088
 
12776
 
14089
  if (!(file_exists (molfilename)) && !opt_stdin)
-
 
14090
    {                           /*not  fileexists(ndl_molfilename) REPLACE!!! */
-
 
14091
/* p2c: checkmol.pas, line 10128:
-
 
14092
 * Warning: Expected an expression, found a ')' [227] */
-
 
14093
 
-
 
14094
      if (strlen (molfilename) > 1 && molfilename[0] == '-')
12777
    if (strlen (molfilename) > 1 && molfilename[0] == '-')
14095
        show_usage ();
12778
            show_usage ();
14096
      else
12779
    else
14097
        printf ("file %s not found!\n", molfilename);
12780
            printf ("file %s not found!\n", molfilename);
14098
      /* new in v0.2k */
12781
      /* new in v0.2k */
14099
      exit (2);
12782
      exit (2);
14100
    }
12783
  }
14101
 
12784
 
14102
  /* read the first molecule and process it; if we are in "matchmol" mode, */
12785
  /* read the first molecule and process it; if we are in "matchmol" mode, */
14103
  /* this is the "needle" */
12786
  /* this is the "needle" */
14104
  if (progmode == pmMatchMol)
12787
  if (progmode == pmMatchMol)
14105
    readinputfile (ndl_molfilename);
12788
    readinputfile (ndl_molfilename);
14106
  else
12789
  else
14107
    readinputfile (molfilename);
12790
    readinputfile (molfilename);
14108
  li = 1;                       /* initialize line pointer for input buffer */
12791
  li = 1;                       /* initialize line pointer for input buffer */
14109
  get_filetype (filetype, ndl_molfilename);
12792
  get_filetype (filetype, ndl_molfilename);
14110
  if (!strcmp (filetype, "unknown"))
12793
  if (!strcmp (filetype, "unknown")) {
14111
    {
-
 
14112
      printf ("unknown query file format!\n");
12794
    printf ("unknown query file format!\n");
14113
      if (!opt_verbose)
12795
    if (!opt_verbose)
14114
        exit (3);
12796
            exit (3);
14115
      printf ("===========================================\n");
12797
    printf ("===========================================\n");
14116
      FORLIM = molbufindex;
12798
    FORLIM = molbufindex;
14117
      for (i = 1; i <= FORLIM; i++)
12799
    for (i = 1; i <= FORLIM; i++)
14118
        puts (molbuf[i - 1]);
12800
            puts (molbuf[i - 1]);
14119
      exit (3);
12801
    exit (3);
14120
    }
12802
  }
14121
  mol_OK = true;                /* added in v0.2i */
12803
  mol_OK = true;                /* added in v0.2i */
14122
  if (!strcmp (filetype, "alchemy"))
12804
  if (!strcmp (filetype, "alchemy"))
14123
    read_molfile (ndl_molfilename);
12805
    read_molfile (ndl_molfilename);
14124
  if (!strcmp (filetype, "sybyl"))
12806
  if (!strcmp (filetype, "sybyl"))
14125
    read_mol2file (ndl_molfilename);
12807
    read_mol2file (ndl_molfilename);
14126
  if (!strcmp (filetype, "mdl"))
12808
  if (!strcmp (filetype, "mdl"))
14127
    read_MDLmolfile (ndl_molfilename);
12809
    read_MDLmolfile (ndl_molfilename);
14128
  count_neighbors ();
12810
  count_neighbors ();
14129
  if (!mol_OK || n_atoms < 1)
-
 
14130
    {                           /* v0.3g; check if this is a valid query structure */
12811
  if (!mol_OK || n_atoms < 1) {                                 /* v0.3g; check if this is a valid query structure */
14131
      printf ("invalid molecule\n");
12812
    printf ("invalid molecule\n");
14132
      exit (3);
12813
    exit (3);
14133
    }
12814
  }
14134
  if (!found_arominfo || progmode == pmCheckMol)
12815
  if (!found_arominfo || progmode == pmCheckMol) {                              /* added in v0.2b/0.2c */
14135
    {                           /* added in v0.2b/0.2c */
-
 
14136
/* p2c: checkmol.pas, line 10172:
12816
  /* p2c: checkmol.pas, line 10172:
14137
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
12817
  * Note: Turbo Pascal conditional compilation directive was ignored [218] */
14138
      /*$IFDEF debug
12818
      /*$IFDEF debug
14139
         if (!found_arominfo)
12819
         if (!found_arominfo)
14140
         debugoutput
12820
         debugoutput
14141
         ("no aromaticity information found - checking myself...");
12821
         ("no aromaticity information found - checking myself...");
14142
         else
12822
         else
14143
         debugoutput ("performing full aromaticity check");
12823
         debugoutput ("performing full aromaticity check");
14144
         // new in v0.3d
12824
         // new in v0.3d
14145
      $ENDIF */
12825
      $ENDIF */
14146
      chk_ringbonds ();
12826
    chk_ringbonds ();
14147
      if (ringsearch_mode == rs_ssr)
12827
    if (ringsearch_mode == rs_ssr)
14148
        remove_redundant_rings ();
12828
            remove_redundant_rings ();
14149
      if (n_rings >= max_rings)
12829
    if (n_rings >= max_rings) {
14150
        {
-
 
14151
          if (opt_verbose)
12830
            if (opt_verbose)
14152
            printf
-
 
14153
              ("Warning: max. number of rings (%i) reached, reverting to SSR search\n",
12831
              printf ("Warning: max. number of rings (%i) reached, reverting to SSR search\n",
14154
               max_rings);
12832
                 max_rings);
14155
          ringsearch_mode = rs_ssr;
12833
            ringsearch_mode = rs_ssr;
14156
          auto_ssr = true;      /* v0.3n */
12834
            auto_ssr = true;    /* v0.3n */
14157
          clear_rings ();
12835
            clear_rings ();
14158
          max_vringsize = ssr_vringsize;        /* v0.3n (was: 10) */
12836
            max_vringsize = ssr_vringsize;      /* v0.3n (was: 10) */
14159
          chk_ringbonds ();
12837
            chk_ringbonds ();
14160
          remove_redundant_rings ();
12838
            remove_redundant_rings ();
14161
        }
12839
          }
14162
      update_ringcount ();
12840
    update_ringcount ();
14163
      /* new in v0.3k: if output is a molfile, leave the original */
12841
    /* new in v0.3k: if output is a molfile, leave the original */
14164
      /* representation of N-oxides, S-oxides, nitro groups, etc. */
12842
    /* representation of N-oxides, S-oxides, nitro groups, etc. */
14165
      /* unchanged (ionic or non-ionic), in any other case make covalent bonds */
12843
    /* unchanged (ionic or non-ionic), in any other case make covalent bonds */
14166
      if (!opt_xmdlout)         /* v0.3k */
12844
    if (!opt_xmdlout)           /* v0.3k */
14167
        normalize_ionic_bonds ();
12845
            normalize_ionic_bonds ();
14168
      update_atypes ();
12846
    update_atypes ();
14169
      update_Htotal ();         /* added in v0.3 */
12847
    update_Htotal ();           /* added in v0.3 */
14170
      chk_arom ();
12848
    chk_arom ();
14171
      if (ringsearch_mode == rs_ssr)
12849
    if (ringsearch_mode == rs_ssr) {                    /* new in v0.3 */
14172
        {                       /* new in v0.3 */
-
 
14173
          do
-
 
14174
            {
12850
            do {
14175
              prev_n_ar = count_aromatic_rings ();
12851
              prev_n_ar = count_aromatic_rings ();
14176
              chk_arom ();
12852
              chk_arom ();
14177
              n_ar = count_aromatic_rings ();
12853
              n_ar = count_aromatic_rings ();
14178
            }
12854
            }
14179
          while (prev_n_ar - n_ar != 0);
12855
            while (prev_n_ar - n_ar != 0);
14180
        }
12856
          }
14181
    }
12857
  }
14182
  else
-
 
14183
    {                           /* v0.3k */
12858
  else {                                /* v0.3k */
14184
/* p2c: checkmol.pas, line 10206:
12859
    /* p2c: checkmol.pas, line 10206:
14185
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
12860
    * Note: Turbo Pascal conditional compilation directive was ignored [218] */
14186
      /*$IFDEF debug
12861
      /*$IFDEF debug
14187
         debugoutput ("found aromaticity information in input file");
12862
         debugoutput ("found aromaticity information in input file");
14188
         $ENDIF */
12863
         $ENDIF */
14189
      if (!opt_xmdlout)
12864
    if (!opt_xmdlout)
14190
        normalize_ionic_bonds ();
12865
            normalize_ionic_bonds ();
14191
      update_atypes ();         /* added in v0.2f */
12866
    update_atypes ();           /* added in v0.2f */
14192
      update_Htotal ();         /* end v0.2b snippet */
12867
    update_Htotal ();           /* end v0.2b snippet */
14193
    }
12868
  }
14194
  if (progmode == pmCheckMol)
12869
  if (progmode == pmCheckMol) {
14195
    {
-
 
14196
      if (opt_verbose)
12870
    if (opt_verbose)
14197
        write_mol ();
12871
            write_mol ();
14198
      get_molstat ();
12872
    get_molstat ();
14199
      if (opt_molstat)
12873
    if (opt_molstat) {
14200
        {
-
 
14201
          if (opt_molstat_X)
12874
            if (opt_molstat_X)
14202
            write_molstat_X ();
12875
              write_molstat_X ();
14203
          else
12876
            else
14204
            write_molstat ();
12877
              write_molstat ();
14205
        }
12878
          }
14206
      else
12879
    else {
14207
        {
-
 
14208
          if (found_querymol)
12880
            if (found_querymol) {
14209
            {
-
 
14210
              printf ("input structure contains query atom or query bond!\n");
12881
                printf ("input structure contains query atom or query bond!\n");
14211
              exit (1);
12882
                exit (1);
14212
            }
12883
            }
14213
          chk_functionalgroups ();
12884
            chk_functionalgroups ();
14214
          if (opt_none)
12885
            if (opt_none)
14215
            opt_text = true;
12886
              opt_text = true;
14216
          if (opt_text)
12887
            if (opt_text)
14217
            write_fg_text ();
12888
              write_fg_text ();
14218
          if (opt_text_de)
12889
            if (opt_text_de)
14219
            write_fg_text_de ();
12890
              write_fg_text_de ();
14220
          if (opt_code)
12891
            if (opt_code)
14221
            write_fg_code ();
12892
              write_fg_code ();
14222
          if (opt_bin)
12893
            if (opt_bin)
14223
            write_fg_binary ();
12894
              write_fg_binary ();
14224
          if (opt_bitstring)
12895
            if (opt_bitstring)
14225
            write_fg_bitstring ();
12896
              write_fg_bitstring ();
14226
          if (opt_xmdlout)
12897
            if (opt_xmdlout)
14227
            write_MDLmolfile ();
12898
              write_MDLmolfile ();
14228
        }
12899
          }
14229
      /*if opt_verbose   then write_mol; */
12900
      /*if opt_verbose   then write_mol; */
14230
      zap_molecule ();
12901
    zap_molecule ();
14231
    }
12902
  }
14232
  else
12903
  else {
14233
    {
-
 
14234
      /* now transfer all data to the "needle" set of variables, except for "fingerprint" mode */
12904
      /* now transfer all data to the "needle" set of variables, except for "fingerprint" mode */
14235
      if (!opt_fp)
-
 
14236
        {                       /* v0.3m */
12905
    if (!opt_fp) {                      /* v0.3m */
14237
          copy_mol_to_needle ();
12906
            copy_mol_to_needle ();
14238
          //chk_wildcard_rings (); /* 0.3p */
12907
            //chk_wildcard_rings (); /* 0.3p */
14239
          set_ndl_atom_tags (); /* v0.3o */
12908
            set_ndl_atom_tags ();       /* v0.3o */
14240
          if (opt_verbose)
12909
            if (opt_verbose)
14241
            write_needle_mol ();
12910
              write_needle_mol ();
14242
          if (rs_strict)        /* v0.3j */
12911
            if (rs_strict)      /* v0.3j */
14243
            ndl_ref_atom = find_ndl_ref_atom_cv ();
12912
              ndl_ref_atom = find_ndl_ref_atom_cv ();
14244
          else
12913
            else
14245
            ndl_ref_atom = find_ndl_ref_atom ();
12914
              ndl_ref_atom = find_ndl_ref_atom ();
14246
        }
12915
          }
14247
      else
12916
    else {
14248
        {
-
 
14249
          copy_mol_to_tmp ();   /* v0.3m */
12917
            copy_mol_to_tmp (); /* v0.3m */
14250
          if (opt_verbose)
12918
            if (opt_verbose)
14251
            printf ("1st molecule stored in buffer: %s\n", tmp_molname);
12919
              printf ("1st molecule stored in buffer: %s\n", tmp_molname);
14252
        }
12920
          }
14253
      /* next, read the "haystack" file and process it */
12921
    /* next, read the "haystack" file and process it */
14254
      li = 1;
12922
    li = 1;
14255
      mol_count = 0;
12923
    mol_count = 0;
14256
      fpdecimal = 0;            /* v0.3m */
12924
    fpdecimal = 0;              /* v0.3m */
14257
      fpindex = 0;              /* v0.3m */
12925
    fpindex = 0;                /* v0.3m */
14258
      do
12926
    do {
14259
        {
-
 
14260
          /* new in v0.3i: reset ringsearch_mode to its initial value */
12927
            /* new in v0.3i: reset ringsearch_mode to its initial value */
14261
          /* for each new molecule */
12928
            /* for each new molecule */
14262
          ringsearch_mode = opt_rs;
12929
            ringsearch_mode = opt_rs;
14263
          if (ringsearch_mode == rs_sar)
12930
            if (ringsearch_mode == rs_sar)
14264
            max_vringsize = max_ringsize;
12931
              max_vringsize = max_ringsize;
14265
          else
12932
            else
14266
            max_vringsize = ssr_vringsize;
12933
              max_vringsize = ssr_vringsize;
14267
          /* v0.3n (was: 10) */
12934
            /* v0.3n (was: 10) */
14268
          readinputfile (molfilename);
12935
            readinputfile (molfilename);
14269
          li = 1;
12936
            li = 1;
14270
          get_filetype (filetype, molfilename);
12937
            get_filetype (filetype, molfilename);
14271
          if (strcmp (filetype, "unknown"))
12938
            if (strcmp (filetype, "unknown")) {
14272
            {
-
 
14273
              found_arominfo = false;   /* added in v0.2b */
12939
              found_arominfo = false;   /* added in v0.2b */
14274
              mol_OK = true;    /* added in v0.2i */
12940
              mol_OK = true;    /* added in v0.2i */
14275
              if (!strcmp (filetype, "alchemy"))
12941
              if (!strcmp (filetype, "alchemy"))
14276
                read_molfile (molfilename);
12942
                      read_molfile (molfilename);
14277
              if (!strcmp (filetype, "sybyl"))
12943
              if (!strcmp (filetype, "sybyl"))
14278
                read_mol2file (molfilename);
12944
                      read_mol2file (molfilename);
14279
              if (!strcmp (filetype, "mdl"))
12945
              if (!strcmp (filetype, "mdl"))
14280
                read_MDLmolfile (molfilename);
12946
                      read_MDLmolfile (molfilename);
14281
              mol_count++;
12947
              mol_count++;
14282
              fpindex++;
12948
              fpindex++;
14283
              count_neighbors ();
12949
              count_neighbors ();
14284
              /*if (not mol_OK) or (n_atoms < 1) then writeln(mol_count,':no valid structure found') else */
12950
              /*if (not mol_OK) or (n_atoms < 1) then writeln(mol_count,':no valid structure found') else */
14285
              if (!mol_OK || (n_atoms < 1
-
 
14286
                  && !(opt_fp && fpformat == fpf_decimal)))
12951
              if (!mol_OK || (n_atoms < 1 && !(opt_fp && fpformat == fpf_decimal)))
14287
                printf ("%i:F\n", mol_count);
12952
                      printf ("%i:F\n", mol_count);
14288
              else
12953
              else {
14289
                {
-
 
14290
                  if (opt_exact
-
 
14291
                      && (n_Ctot != ndl_n_Ctot || n_Otot != ndl_n_Otot
12954
                      if (opt_exact && (n_Ctot != ndl_n_Ctot || n_Otot != ndl_n_Otot
14292
                          || n_Ntot != ndl_n_Ntot))
12955
                                || n_Ntot != ndl_n_Ntot)) {             /* new in v0.3g */
14293
                    {           /* new in v0.3g */
-
 
14294
                      if (!opt_molout && !(opt_fp && fpformat == fpf_decimal))
12956
                        if (!opt_molout && !(opt_fp && fpformat == fpf_decimal))
14295
                        printf ("%i:F\n", mol_count);
12957
                                printf ("%i:F\n", mol_count);
14296
                    }
12958
                      }
14297
                  else
12959
                      else {
14298
                    {
-
 
14299
                      if (!found_arominfo || (opt_strict && tmfmismatch))
12960
                        if (!found_arominfo || (opt_strict && tmfmismatch)) {   /* added in v0.3m */
14300
                        {       /* added in v0.3m */
-
 
14301
/* p2c: checkmol.pas, line 10294:
12961
              /* p2c: checkmol.pas, line 10294:
14302
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
12962
               * Note: Turbo Pascal conditional compilation directive was ignored [218] */
14303
                          /*$IFDEF debug
12963
                                  /*$IFDEF debug
14304
                             debugoutput
12964
                              debugoutput
14305
                             ("no aromaticity information found (or tweak mismatch) - checking myself...");
12965
                              ("no aromaticity information found (or tweak mismatch) - checking myself...");
14306
                            *$ENDIF */
12966
                              *$ENDIF */
14307
                          chk_ringbonds ();
-
 
14308
                          if (ringsearch_mode == rs_ssr)
-
 
14309
                            remove_redundant_rings ();
-
 
14310
                          if (n_rings == max_rings)
-
 
14311
                            {
-
 
14312
                              if (opt_verbose)
-
 
14313
                                printf
-
 
14314
                                  ("Warning: max. number of rings (%i) reached, reverting to SSR search\n",
-
 
14315
                                   max_rings);
-
 
14316
                              ringsearch_mode = rs_ssr;
-
 
14317
                              clear_rings ();
-
 
14318
                              max_vringsize = ssr_vringsize;    /* v0.3n (was: 10) */
-
 
14319
                              chk_ringbonds ();
12967
                              chk_ringbonds ();
-
 
12968
                              if (ringsearch_mode == rs_ssr)
14320
                              remove_redundant_rings ();
12969
                                remove_redundant_rings ();
-
 
12970
                               if (n_rings == max_rings) {
-
 
12971
                                if (opt_verbose)
-
 
12972
                                        printf ("Warning: max. number of rings (%i) reached, reverting to SSR search\n",
-
 
12973
                                         max_rings);
-
 
12974
                                ringsearch_mode = rs_ssr;
-
 
12975
                                clear_rings ();
-
 
12976
                                max_vringsize = ssr_vringsize;  /* v0.3n (was: 10) */
-
 
12977
                                chk_ringbonds ();
-
 
12978
                                remove_redundant_rings ();
14321
                            }
12979
                              }
14322
                          update_ringcount ();
12980
                              update_ringcount ();
14323
                          update_atypes ();
12981
                              update_atypes ();
14324
                          update_Htotal ();     /* added in v0.3 */
12982
                              update_Htotal (); /* added in v0.3 */
14325
                          chk_arom ();
12983
                              chk_arom ();
14326
                          if (ringsearch_mode == rs_ssr)
12984
                              if (ringsearch_mode == rs_ssr) {  /* new in v0.3 */
14327
                            {   /* new in v0.3 */
-
 
14328
                              do
12985
                                do {
14329
                                {
-
 
14330
                                  prev_n_ar = count_aromatic_rings ();
12986
                                        prev_n_ar = count_aromatic_rings ();
14331
                                  chk_arom ();
12987
                                        chk_arom ();
14332
                                  n_ar = count_aromatic_rings ();
12988
                                        n_ar = count_aromatic_rings ();
14333
                                }
12989
                                      }
14334
                              while (prev_n_ar - n_ar != 0);
12990
                                while (prev_n_ar - n_ar != 0);
-
 
12991
                              }
14335
                            }
12992
                            }
14336
                        }
-
 
14337
                      else
-
 
14338
                        {       /* added in v0.2f */
12993
                      else {    /* added in v0.2f */
14339
/* p2c: checkmol.pas, line 10322:
12994
            /* p2c: checkmol.pas, line 10322:
14340
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
12995
            * Note: Turbo Pascal conditional compilation directive was ignored [218] */
14341
                          /*$IFDEF debug
12996
                            /*$IFDEF debug
14342
                             debugoutput
12997
                             debugoutput
14343
                             ("found aromaticity information in input file");
12998
                             ("found aromaticity information in input file");
14344
                             $ENDIF */
12999
                             $ENDIF */
14345
                          if (opt_strict)
13000
                              if (opt_strict)
14346
                            update_atypes ();
13001
                                update_atypes ();
14347
                          update_Htotal ();
13002
                              update_Htotal ();
14348
                        }
13003
                            }
14349
                      init_molstat (&ndl_molstat);
13004
                      init_molstat (&ndl_molstat);
14350
                      if (normalize_ionic_bonds ())
13005
                      if (normalize_ionic_bonds ())
14351
                        /* new in v0.3k, modified in v0.3m */
13006
                              /* new in v0.3k, modified in v0.3m */
14352
                        update_atypes ();
13007
                              update_atypes ();
14353
                      if (opt_verbose && !opt_fp)
13008
                      if (opt_verbose && !opt_fp)
14354
                        write_mol ();
13009
                              write_mol ();
14355
                      /* if in "fingerprint mode", exchange needle and haystack */
13010
                      /* if in "fingerprint mode", exchange needle and haystack */
14356
                      if (opt_fp)
13011
                      if (opt_fp) {     /* v0.3m */
14357
                        {       /* v0.3m */
-
 
14358
                          zap_needle ();
13012
                              zap_needle ();
14359
                          copy_mol_to_needle ();
13013
                              copy_mol_to_needle ();
14360
                          //chk_wildcard_rings (); /* 0.3p */
13014
                              //chk_wildcard_rings (); /* 0.3p */
14361
                          zap_molecule ();
13015
                              zap_molecule ();
14362
                          copy_tmp_to_mol ();
13016
                              copy_tmp_to_mol ();
14363
                          if (opt_verbose)
13017
                              if (opt_verbose)
14364
                            write_needle_mol ();
13018
                                write_needle_mol ();
14365
                          if (rs_strict)        /* v0.3j */
13019
                              if (rs_strict)    /* v0.3j */
14366
                            ndl_ref_atom = find_ndl_ref_atom_cv ();
13020
                                ndl_ref_atom = find_ndl_ref_atom_cv ();
14367
                          else
13021
                              else
14368
                            ndl_ref_atom = find_ndl_ref_atom ();
13022
                                ndl_ref_atom = find_ndl_ref_atom ();
14369
                          if (opt_verbose)
13023
                              if (opt_verbose)
14370
                            write_mol ();
13024
                                write_mol ();
14371
                        }       /* v0.3m */
13025
                            }   /* v0.3m */
14372
                      /* now that we have both molecules, perform the comparison */
13026
                      /* now that we have both molecules, perform the comparison */
14373
                      /* v0.3o: takes care of disconnected fragment... */
13027
                      /* v0.3o: takes care of disconnected fragment... */
14374
                      clear_atom_tags ();
13028
                      clear_atom_tags ();
14375
                      set_ndl_atom_tags ();
13029
                      set_ndl_atom_tags ();
14376
                      matchsummary = true;
13030
                      matchsummary = true;
14377
                      perform_match ();
13031
                      perform_match ();
14378
                      matchsummary = matchresult;
13032
                      matchsummary = matchresult;
14379
                      if (count_tagged_ndl_heavyatoms () > 0
13033
                      if (count_tagged_ndl_heavyatoms () > 0 && matchsummary == true) {
14380
                          && matchsummary == true)
-
 
14381
                        {
-
 
14382
                          do
-
 
14383
                            {
13034
                              do {
14384
                              if (rs_strict)
13035
                                if (rs_strict)
14385
                                ndl_ref_atom = find_ndl_ref_atom_cv ();
13036
                                        ndl_ref_atom = find_ndl_ref_atom_cv ();
14386
                              else
13037
                                else
14387
                                ndl_ref_atom = find_ndl_ref_atom ();
13038
                                        ndl_ref_atom = find_ndl_ref_atom ();
14388
                              perform_match ();
13039
                                perform_match ();
14389
                              if (matchresult == false)
13040
                                if (matchresult == false)
14390
                                matchsummary = false;
13041
                                        matchsummary = false;
-
 
13042
                              }
-
 
13043
                              while (count_tagged_ndl_heavyatoms () != 0 && matchsummary != false);
14391
                            }
13044
                            }
14392
                          while (count_tagged_ndl_heavyatoms () != 0 &&
-
 
14393
                                 matchsummary != false);
-
 
14394
                        }
-
 
14395
                      /* end of disconnected-fragment matching (v0.3o) */
13045
                      /* end of disconnected-fragment matching (v0.3o) */
14396
                      if (matchsummary == true)
13046
                      if (matchsummary == true) {       /* v0.3o */
-
 
13047
                              if (opt_molout) {
-
 
13048
                                FORLIM = molbufindex;
-
 
13049
                                for (i = 1; i <= FORLIM; i++)
-
 
13050
                                        puts (molbuf[i - 1]);
-
 
13051
                              }
14397
                        {       /* v0.3o */
13052
                              else {
-
 
13053
                                if (!opt_fp)    /* inttostr(mol_count) REPLACE!!!, */
-
 
13054
                                        printf ("%i:T\n", mol_count);
-
 
13055
                                else {
-
 
13056
                                        if (ndl_n_heavyatoms == n_heavyatoms &&
-
 
13057
                                            ndl_n_heavybonds == n_heavybonds)
-
 
13058
                                          fp_exacthit = true;
-
 
13059
                                        else
-
 
13060
                                          fp_exacthit = false;
14398
                          if (opt_molout)
13061
                                        if (fp_exacthit)
-
 
13062
                                          fp_exactblock = true;
-
 
13063
                                        if (fpformat == fpf_boolean) {
-
 
13064
                                          if (fp_exacthit)      /* inttostr(mol_count), REPACE!!! */
-
 
13065
                                                  printf ("%i:TX\n", mol_count);
-
 
13066
                                          else
-
 
13067
                                                  printf ("%i:T\n", mol_count);
14399
                            {
13068
                                        }
-
 
13069
                                        /* inttostr(mol_count), REPLACE!!! */
-
 
13070
                                        if (fpformat == fpf_decimal) {
-
 
13071
                                          fpincrement = 1;
14400
                              FORLIM = molbufindex;
13072
                                          FORLIM = fpindex;
14401
                              for (i = 1; i <= FORLIM; i++)
13073
                                          for (i = 1; i <= FORLIM; i++)
14402
                                puts (molbuf[i - 1]);
13074
                                                  fpincrement <<= 1;
-
 
13075
                                          fpdecimal += fpincrement;
-
 
13076
                                        }
-
 
13077
                                      }
-
 
13078
                              }
14403
                            }
13079
                            }
14404
                          else
-
 
14405
                            {
-
 
14406
                              if (!opt_fp)      /* inttostr(mol_count) REPLACE!!!, */
-
 
14407
                                printf ("%i:T\n", mol_count);
-
 
14408
                              else
13080
                      else {
14409
                                {
-
 
14410
                                  if (ndl_n_heavyatoms == n_heavyatoms &&
-
 
14411
                                      ndl_n_heavybonds == n_heavybonds)
-
 
14412
                                    fp_exacthit = true;
-
 
14413
                                  else
-
 
14414
                                    fp_exacthit = false;
-
 
14415
                                  if (fp_exacthit)
-
 
14416
                                    fp_exactblock = true;
-
 
14417
                                  if (fpformat == fpf_boolean)
13081
                              if (!(opt_molout || (opt_fp && fpformat == fpf_decimal)))
14418
                                    {
-
 
14419
                                      if (fp_exacthit)  /* inttostr(mol_count), REPACE!!! */
13082
                                /* inttostr(mol_count), REPLACE!!! */
14420
                                        printf ("%i:TX\n", mol_count);
-
 
14421
                                      else
-
 
14422
                                        printf ("%i:T\n", mol_count);
13083
                               printf ("%i:F\n", mol_count);
14423
                                    }
13084
                            }
14424
                                  /* inttostr(mol_count), REPLACE!!! */
-
 
14425
                                  if (fpformat == fpf_decimal)
13085
                      if (opt_fp && fpformat == fpf_decimal && fpindex == fp_blocksize) {
14426
                                    {
-
 
14427
                                      fpincrement = 1;
13086
                              if (fp_exactblock)
14428
                                      FORLIM = fpindex;
13087
                                fpdecimal++;
14429
                                      for (i = 1; i <= FORLIM; i++)
13088
                              printf ("%lld\n", fpdecimal);
14430
                                        fpincrement <<= 1;
13089
                              fpindex = 0;
14431
                                      fpdecimal += fpincrement;
13090
                              fpdecimal = 0;
14432
                                    }
13091
                              fp_exactblock = false;
14433
                                }
-
 
14434
                            }
13092
                            }
14435
                        }
-
 
14436
                      else
-
 
14437
                        {
-
 
14438
                          if (!
-
 
14439
                              (opt_molout || (opt_fp
-
 
14440
                               && fpformat == fpf_decimal)))
-
 
14441
                            /* inttostr(mol_count), REPLACE!!! */
-
 
14442
                            printf ("%i:F\n", mol_count);
-
 
14443
                        }
-
 
14444
                      if (opt_fp && fpformat == fpf_decimal
-
 
14445
                          && fpindex == fp_blocksize)
-
 
14446
                        {
-
 
14447
                          if (fp_exactblock)
-
 
14448
                            fpdecimal++;
-
 
14449
                          printf ("%lld\n", fpdecimal);
-
 
14450
                          fpindex = 0;
-
 
14451
                          fpdecimal = 0;
-
 
14452
                          fp_exactblock = false;
-
 
14453
                        }
-
 
14454
                      zap_molecule ();
13093
                      zap_molecule ();
14455
                      molbufindex = 0;
13094
                      molbufindex = 0;
14456
                    }
13095
                    }
14457
                }
13096
                  }
14458
            }
13097
          }
14459
          else
13098
          else {
14460
            {
-
 
14461
              /* v0.3l */
13099
            /* v0.3l */
14462
              /* mol_OK */
13100
            /* mol_OK */
14463
              printf ("%i:unknown file format\n", mol_count);
13101
            printf ("%i:unknown file format\n", mol_count);
14464
            }
13102
          }
14465
        }
-
 
14466
      while (mol_in_queue != false);
-
 
14467
      /* if filetype <> 'unknown' */
-
 
14468
      if (opt_fp && fpformat == fpf_decimal && fpindex > 0)
-
 
14469
        {
-
 
14470
          if (fp_exactblock)
-
 
14471
            fpdecimal++;
-
 
14472
          printf ("%lld\n", fpdecimal);
-
 
14473
        }
-
 
14474
      zap_needle ();
-
 
14475
      if (rfile_is_open)
-
 
14476
        {                       /* new in v0.2g */
-
 
14477
          if (rfile != NULL)
-
 
14478
            fclose (rfile);
-
 
14479
          rfile = NULL;
-
 
14480
        }
13103
        }
-
 
13104
  while (mol_in_queue != false);
-
 
13105
    /* if filetype <> 'unknown' */
-
 
13106
    if (opt_fp && fpformat == fpf_decimal && fpindex > 0) {
-
 
13107
            if (fp_exactblock)
-
 
13108
              fpdecimal++;
-
 
13109
            printf ("%lld\n", fpdecimal);
14481
    }
13110
          }
-
 
13111
    zap_needle ();
-
 
13112
    if (rfile_is_open){                 /* new in v0.2g */
-
 
13113
            if (rfile != NULL)
-
 
13114
              fclose (rfile);
-
 
13115
            rfile = NULL;
-
 
13116
          }
-
 
13117
  }
14482
  if (rfile != NULL)
13118
  if (rfile != NULL)
14483
    fclose (rfile);
13119
    fclose (rfile);
14484
  exit (0);
13120
  exit (0);
14485
}
13121
}
14486
 
13122
 
14487
#else
13123
#else
14488
 
13124
 
14489
static void
-
 
14490
init_globals_dll (void)
13125
static void init_globals_dll (void)
14491
{
13126
{
14492
 
13127
 
14493
//printf("init_globals_dll\n");
13128
//printf("init_globals_dll\n");
14494
 
13129
 
14495
  int i;
13130
  int i;
Line 14519... Line 13154...
14519
  n_Ntot = 0;                   /* new in v0.3g */
13154
  n_Ntot = 0;                   /* new in v0.3g */
14520
  //for (i = 0; i < max_fg; i++)
13155
  //for (i = 0; i < max_fg; i++)
14521
  //  fg[i] = false;
13156
  //  fg[i] = false;
14522
  memset (fg, 0, sizeof (fglist));
13157
  memset (fg, 0, sizeof (fglist));
14523
 
13158
 
14524
  if (!yet_initialized)
13159
  if (!yet_initialized) {
14525
    {
-
 
14526
      molbuf = (void *) safe_malloc (sizeof (molbuftype));
13160
    molbuf = (void *) safe_malloc (sizeof (molbuftype));
14527
      opt_exact = false;
13161
    opt_exact = false;
14528
      opt_strict = false;       /* new in v0.2f */
13162
    opt_strict = false; /* new in v0.2f */
14529
      opt_metalrings = false;   /* new in v0.3 */
13163
    opt_metalrings = false;     /* new in v0.3 */
14530
      opt_geom = false;         /* new in v0.3d */
13164
    opt_geom = false;           /* new in v0.3d */
14531
      opt_chiral = false;       /* new in v0.3f */
13165
    opt_chiral = false; /* new in v0.3f */
14532
      opt_iso = false;          /* new in v0.3x */
13166
    opt_iso = false;            /* new in v0.3x */
14533
      opt_chg = false;          /* new in v0.3x */
13167
    opt_chg = false;            /* new in v0.3x */
14534
      opt_rad = false;          /* new in v0.3x */
13168
    opt_rad = false;            /* new in v0.3x */
14535
      ez_search = false;        /* new in v0.3d */
13169
    ez_search = false;  /* new in v0.3d */
14536
      rs_search = false;        /* new in v0.3f */
13170
    rs_search = false;  /* new in v0.3f */
14537
      rs_strict = false;        /* new in v0.3j */
13171
    rs_strict = false;  /* new in v0.3j */
14538
      ndl_n_Ctot = 0;
13172
    ndl_n_Ctot = 0;
14539
      ndl_n_Otot = 0;
13173
    ndl_n_Otot = 0;
14540
      ndl_n_Ntot = 0;           /* new in v0.3g */
13174
    ndl_n_Ntot = 0;             /* new in v0.3g */
14541
      yet_initialized = true;
13175
    yet_initialized = true;
14542
    }
13176
  }
14543
 
13177
 
14544
  ether_generic = false;        /* v0.3j */
13178
  ether_generic = false;        /* v0.3j */
14545
  amine_generic = false;        /* v0.3j */
13179
  amine_generic = false;        /* v0.3j */
14546
  hydroxy_generic = false;      /* v0.3j */
13180
  hydroxy_generic = false;      /* v0.3j */
14547
  fpformat = fpf_decimal;       /* v0.3m */
13181
  fpformat = fpf_decimal;       /* v0.3m */
14548
  fpindex = 0;                  /* v0.3m */
13182
  fpindex = 0;                  /* v0.3m */
Line 14552... Line 13186...
14552
  tmfmismatch = false;          /* v0.3m */
13186
  tmfmismatch = false;          /* v0.3m */
14553
  auto_ssr = false;
13187
  auto_ssr = false;
14554
  recursion_depth = 0;
13188
  recursion_depth = 0;
14555
}
13189
}
14556
 
13190
 
14557
static void
-
 
14558
mm_init_mol (void)
13191
static void mm_init_mol (void)
14559
{
13192
{
14560
 
-
 
14561
//printf("mm_init_mol\n");
13193
//printf("mm_init_mol\n");
14562
  init_globals_dll ();
13194
  init_globals_dll ();
14563
  init_molstat (&molstat);
13195
  init_molstat (&molstat);
14564
  if (opt_rs_dll == RPA_DEFAULT)
13196
  if (opt_rs_dll == RPA_DEFAULT) {
14565
    {
-
 
14566
      ringsearch_mode = opt_rs;
13197
    ringsearch_mode = opt_rs;
14567
      //printf("DEFAULT: %i\n",ringsearch_mode);
13198
    //printf("DEFAULT: %i\n",ringsearch_mode);
14568
    }
13199
  }
14569
  else
13200
  else {
14570
    {
-
 
14571
      ringsearch_mode = opt_rs_dll;
13201
    ringsearch_mode = opt_rs_dll;
14572
    }
13202
  }
14573
  //printf("RPA: %i\n",ringsearch_mode);
13203
  //printf("RPA: %i\n",ringsearch_mode);
14574
 
13204
 
14575
  if (ringsearch_mode == rs_sar)
13205
  if (ringsearch_mode == rs_sar) {
14576
    {
-
 
14577
      max_vringsize = max_ringsize;
13206
      max_vringsize = max_ringsize;
14578
    }
13207
  }
14579
  else
13208
  else {
14580
    {
-
 
14581
      max_vringsize = ssr_vringsize;
13209
      max_vringsize = ssr_vringsize;
14582
    }
13210
  }
14583
  zap_molecule ();
13211
  zap_molecule ();
14584
  molbufindex = 0;
13212
  molbufindex = 0;
14585
  mol_count = 0;
13213
  mol_count = 0;
14586
//printf("mm_init_mol\n");
13214
//printf("mm_init_mol\n");
14587
}
13215
}
14588
 
13216
 
14589
static void
-
 
14590
mm_elab_mol (boolean checkmol_mode, boolean normalize_ionic_bnds)
13217
static void mm_elab_mol (boolean checkmol_mode, boolean normalize_ionic_bnds)
14591
{
13218
{
14592
//printf("mm_elab_mol\n");
13219
//printf("mm_elab_mol\n");
14593
 
13220
 
14594
  li = 1;                       // initialize line pointer for input buffer
13221
  li = 1;                       // initialize line pointer for input buffer
14595
  get_filetype (filetype, ndl_molfilename);
13222
  get_filetype (filetype, ndl_molfilename);
14596
  if (strcmp (filetype, "unknown") == 0)
13223
  if (strcmp (filetype, "unknown") == 0) {
14597
    {
-
 
14598
      //messagebox (0,'Error in mm_ElabMol: Unknown file format','MATCHMOLDLL ERROR',0);
13224
    //messagebox (0,'Error in mm_ElabMol: Unknown file format','MATCHMOLDLL ERROR',0);
14599
      exit (3);
13225
    exit (3);
14600
    }
13226
  }
14601
 
13227
 
14602
  if (checkmol_mode == true)
13228
  if (checkmol_mode == true)
14603
    progmode = pmCheckMol;
13229
    progmode = pmCheckMol;
14604
  else
13230
  else
14605
    progmode = pmMatchMol;
13231
    progmode = pmMatchMol;
Line 14607... Line 13233...
14607
    read_molfile (ndl_molfilename);
13233
    read_molfile (ndl_molfilename);
14608
  if (strcmp (filetype, "sybyl") == 0)
13234
  if (strcmp (filetype, "sybyl") == 0)
14609
    read_mol2file (ndl_molfilename);
13235
    read_mol2file (ndl_molfilename);
14610
  if (strcmp (filetype, "mdl") == 0)
13236
  if (strcmp (filetype, "mdl") == 0)
14611
    read_MDLmolfile (ndl_molfilename);
13237
    read_MDLmolfile (ndl_molfilename);
14612
  if (checkmol_mode)
13238
  if (checkmol_mode) {
14613
    {
-
 
14614
      if (found_querymol)
13239
    if (found_querymol) {
14615
        {
-
 
14616
          printf
-
 
14617
            ("Warning: Input structure contains query atom or query bond.\n");
13240
            printf ("Warning: Input structure contains query atom or query bond.\n");
14618
        }
13241
          }
14619
    }
13242
  }
14620
 
13243
 
14621
  count_neighbors ();
13244
  count_neighbors ();
14622
  if (!found_arominfo || checkmol_mode || opt_strict)
13245
  if (!found_arominfo || checkmol_mode || opt_strict) {
14623
    {
-
 
14624
      //printf("No arom found or checkmol mode\n");
13246
    //printf("No arom found or checkmol mode\n");
14625
      chk_ringbonds ();
13247
    chk_ringbonds ();
14626
      if (ringsearch_mode == rs_ssr)
13248
    if (ringsearch_mode == rs_ssr)
14627
        remove_redundant_rings ();
13249
            remove_redundant_rings ();
14628
      if (n_rings >= max_rings)
13250
    if (n_rings >= max_rings) {
14629
        {
-
 
14630
 
-
 
14631
          printf
-
 
14632
            ("Warning: max. number of rings (%i) reached, reverting to SSR search\n",
13251
            printf ("Warning: max. number of rings (%i) reached, reverting to SSR search\n",
14633
             max_rings);
13252
               max_rings);
14634
          ringsearch_mode = rs_ssr;
13253
            ringsearch_mode = rs_ssr;
14635
          auto_ssr = true;
13254
            auto_ssr = true;
14636
          clear_rings ();
13255
            clear_rings ();
14637
          max_vringsize = ssr_vringsize;
13256
            max_vringsize = ssr_vringsize;
14638
          chk_ringbonds ();
13257
            chk_ringbonds ();
14639
          remove_redundant_rings ();
13258
            remove_redundant_rings ();
14640
        }
13259
          }
14641
 
13260
 
14642
      update_ringcount ();
13261
    update_ringcount ();
14643
      if (normalize_ionic_bnds) /* v0.3k */
13262
    if (normalize_ionic_bnds)   /* v0.3k */
14644
        normalize_ionic_bonds ();
13263
            normalize_ionic_bonds ();
14645
      update_atypes ();
13264
    update_atypes ();
14646
      update_Htotal ();
13265
    update_Htotal ();
14647
      chk_arom ();
13266
    chk_arom ();
14648
      if (ringsearch_mode == rs_ssr)
13267
    if (ringsearch_mode == rs_ssr) {                    /* new in v0.3 */
14649
        {                       /* new in v0.3 */
-
 
14650
          do
-
 
14651
            {
13268
            do {
14652
              prev_n_ar = count_aromatic_rings ();
13269
              prev_n_ar = count_aromatic_rings ();
14653
              chk_arom ();
13270
              chk_arom ();
14654
              n_ar = count_aromatic_rings ();
13271
              n_ar = count_aromatic_rings ();
14655
            }
13272
            }
14656
          while (prev_n_ar - n_ar != 0);
13273
            while (prev_n_ar - n_ar != 0);
14657
        }
13274
          }
14658
    }
13275
  }
14659
  else
13276
  else {
14660
    {
-
 
14661
      if (normalize_ionic_bnds) /* v0.3k  */
13277
    if (normalize_ionic_bnds)   /* v0.3k  */
14662
        normalize_ionic_bonds ();
13278
            normalize_ionic_bonds ();
14663
      //if (opt_strict)
13279
    //if (opt_strict)
14664
      update_atypes ();
13280
    update_atypes ();
14665
      update_Htotal ();
13281
    update_Htotal ();
14666
    }
13282
  }
14667
 
-
 
14668
 
-
 
14669
 
-
 
14670
//printf("mm_elab_mol\n");
13283
  //printf("mm_elab_mol\n");
14671
}
13284
}
14672
 
13285
 
14673
DLLEXPORT void
-
 
14674
mm_set_current_mol_as_query (void)
13286
DLLEXPORT void mm_set_current_mol_as_query (void)
14675
{
13287
{
14676
//printf("mm_set_current_mol_as_query\n");
13288
  //printf("mm_set_current_mol_as_query\n");
14677
  zap_needle ();
13289
  zap_needle ();
14678
//mm_ElabMol;
13290
  //mm_ElabMol;
14679
  copy_mol_to_needle ();
13291
  copy_mol_to_needle ();
14680
  //chk_wildcard_rings (); /* 0.3p */
13292
  //chk_wildcard_rings (); /* 0.3p */
14681
  set_ndl_atom_tags ();         /* v0.3o */
13293
  set_ndl_atom_tags ();         /* v0.3o */
14682
  if (opt_geom)                 /* v0.3d */
13294
  if (opt_geom)                 /* v0.3d */
14683
    ez_search = true;
13295
    ez_search = true;
14684
  else if (!ez_flag && ez_search)
13296
  else if (!ez_flag && ez_search)
14685
    ez_search = false;          //chir_flag initialized in read_MDLmolfile, otherwise we lose that info
13297
    ez_search = false;          //chir_flag initialized in read_MDLmolfile, otherwise we lose that info
14686
  if (opt_chiral)
-
 
14687
    {                           /* v0.3f */
13298
  if (opt_chiral) {                             /* v0.3f */
14688
      rs_search = true;
13299
      rs_search = true;
14689
 
-
 
14690
      //printf("%i\n",rs_search);
13300
      //printf("%i\n",rs_search);
14691
    }
13301
  }
-
 
13302
  else
14692
  else if (!chir_flag && rs_search)
13303
    if (!chir_flag && rs_search) {
14693
    {
-
 
14694
      rs_search = false;        //chir_flag initialized in read_MDLmolfile, otherwise we lose that info
13304
      rs_search = false;        //chir_flag initialized in read_MDLmolfile, otherwise we lose that info
14695
      //printf("%i\n",rs_search);
13305
      //printf("%i\n",rs_search);
14696
    }
13306
    }
14697
  if (opt_chiral && opt_strict && opt_exact)    /* new in v0.3j */
13307
  if (opt_chiral && opt_strict && opt_exact)    /* new in v0.3j */
14698
    rs_strict = true;
13308
    rs_strict = true;
14699
  else
13309
  else
14700
    rs_strict = false;
13310
    rs_strict = false;
14701
  /* if (rs_strict)              // v0.3j
13311
    /* if (rs_strict)              // v0.3j
14702
     ndl_ref_atom = find_ndl_ref_atom_cv ();
13312
       ndl_ref_atom = find_ndl_ref_atom_cv ();
14703
     //ndl_ref_atom = find_ndl_ref_atom ();
13313
       //ndl_ref_atom = find_ndl_ref_atom ();
14704
     else
13314
       else
14705
     ndl_ref_atom = find_ndl_ref_atom (); */
13315
       ndl_ref_atom = find_ndl_ref_atom (); */
14706
 
-
 
14707
 
-
 
14708
 
13316
 
14709
  molbufindex = 0;
13317
  molbufindex = 0;
14710
  mol_count = 0;
13318
  mol_count = 0;
14711
/*printf("mm_set_current_mol_as_query\n");*/
13319
  /*printf("mm_set_current_mol_as_query\n");*/
14712
}
13320
}
14713
 
13321
 
14714
DLLEXPORT int
-
 
14715
mm_get_rings (void)
13322
DLLEXPORT int mm_get_rings (void)
14716
{
13323
{
14717
  return n_rings;
13324
  return n_rings;
14718
}
13325
}
14719
 
13326
 
14720
DLLEXPORT void
-
 
14721
xm_version (char *buffer)
13327
DLLEXPORT void xm_version (char *buffer)
14722
{
13328
{
14723
  buffer[0] = '\0';
13329
  buffer[0] = '\0';
14724
  strncpy (buffer, version, 255);
13330
  strncpy (buffer, version, 255);
14725
}
13331
}
14726
 
13332
 
14727
DLLEXPORT int
-
 
14728
mm_get_atom_ring (int atom_number)
13333
DLLEXPORT int mm_get_atom_ring (int atom_number)
14729
{
13334
{
14730
 
13335
 
14731
  int i, j, a1, pl;
13336
  int i, j, a1, pl;
14732
  int ret = 0;
13337
  int ret = 0;
14733
  a1 = atom[atom_number].ring_count;
13338
  a1 = atom[atom_number].ring_count;
14734
  if (n_rings > 0)
13339
  if (n_rings > 0) {
14735
    {
-
 
14736
      for (i = 1; i < n_rings; i++)
13340
    for (i = 1; i < n_rings; i++) {
14737
        {
-
 
14738
 
-
 
14739
          pl = path_length (ring[i]);
13341
            pl = path_length (ring[i]);
14740
//          a2 := ring^[i,pl];
13342
      //          a2 := ring^[i,pl];
14741
          for (j = 1; j < pl; j++)
13343
            for (j = 1; j < pl; j++) {
14742
            {
-
 
14743
 
-
 
14744
              a1 = ring[i][j];
13344
              a1 = ring[i][j];
14745
              if (atom_number == a1)
13345
              if (atom_number == a1)
14746
                ret = i;
13346
                      ret = i;
14747
//
13347
          //
14748
//              inc(atom^[a1].ring_count);
13348
          //              inc(atom^[a1].ring_count);
14749
//              b := get_bond(a1,a2);
13349
          //              b := get_bond(a1,a2);
14750
//              inc(bond^[b].ring_count);
13350
          //              inc(bond^[b].ring_count);
14751
//              a2 := a1;
13351
          //              a2 := a1;
14752
            }
13352
            }
14753
        }
13353
          }
14754
    }
13354
  }
14755
  return ret;
13355
  return ret;
14756
}
13356
}
14757
 
13357
 
14758
static void
-
 
14759
mm_read_input_line (char *st)
13358
static void mm_read_input_line (char *st)
14760
{
13359
{
14761
//printf("mm_read_input_line_in\n");
13360
//printf("mm_read_input_line_in\n");
14762
//var
13361
//var
14763
//yyy:pchar;
13362
//yyy:pchar;
14764
 
13363
 
14765
  mol_in_queue = false;
13364
  mol_in_queue = false;
14766
  if (molbufindex < (max_atoms + max_bonds + slack))
13365
  if (molbufindex < (max_atoms + max_bonds + slack)) {
14767
    {
-
 
14768
 
13366
 
14769
//yyy:=Pchar(IntToStr(molbufindex));
13367
    //yyy:=Pchar(IntToStr(molbufindex));
14770
//messagebox (0,yyy,'',0);
13368
    //messagebox (0,yyy,'',0);
14771
//printf("%i\n",molbufindex);
13369
    //printf("%i\n",molbufindex);
14772
//printf("B:%s\n",st);
13370
    //printf("B:%s\n",st);
14773
      strcpy (molbuf[molbufindex++], st);
13371
          strcpy (molbuf[molbufindex++], st);
14774
//printf("%x %x\n",&molbuf,molbuf);
13372
    //printf("%x %x\n",&molbuf,molbuf);
14775
//printf("%s\n",molbuf[molbufindex-1]);
13373
    //printf("%s\n",molbuf[molbufindex-1]);
14776
      //  molbufindex++;
13374
          //  molbufindex++;
14777
    }
13375
  }
14778
  else
13376
  else {
14779
    {
-
 
14780
      //messagebox(0,'Error in mm_Readinputline; memory problem','ERROR',0);
13377
    //messagebox(0,'Error in mm_Readinputline; memory problem','ERROR',0);
14781
      printf ("Not enough memory for molfile! %i\n", molbufindex);
13378
    printf ("Not enough memory for molfile! %i\n", molbufindex);
14782
      exit (1);
13379
    exit (1);
14783
    }
13380
  }
14784
//printf("mm_read_input_line_out\n");
13381
//printf("mm_read_input_line_out\n");
14785
}
13382
}
14786
 
13383
 
14787
 
-
 
14788
static void
-
 
14789
mm_set_mol_dll (const char *st, boolean checkmol_mode,
13384
static void mm_set_mol_dll (const char *st, boolean checkmol_mode,
14790
                boolean normalize_ionic_bnds)
13385
                boolean normalize_ionic_bnds)
14791
{
13386
{
14792
//printf("mm_set_mol\n");
13387
  //printf("mm_set_mol\n");
14793
//printf("%s\n",st);
13388
  //printf("%s\n",st);
14794
  char bb;
13389
  char bb;
14795
  char aa;
13390
  char aa;
14796
  int i;
13391
  int i;
14797
  int k;
13392
  int k;
14798
  int J;
13393
  int J;
Line 14800... Line 13395...
14800
  char tt[256];
13395
  char tt[256];
14801
  char bb10 = '\n';
13396
  char bb10 = '\n';
14802
  char bb13 = '\r';
13397
  char bb13 = '\r';
14803
  char bb0 = '\0';
13398
  char bb0 = '\0';
14804
  int lenst;
13399
  int lenst;
14805
//char d[256];
13400
  //char d[256];
14806
  lenst = strlen (st);
13401
  lenst = strlen (st);
14807
//tt=(char*)safe_malloc(256*sizeof(char));
13402
  //tt=(char*)safe_malloc(256*sizeof(char));
14808
  tt[0] = '\0';
13403
  tt[0] = '\0';
14809
//messagebox(0,st,'',0);
13404
  //messagebox(0,st,'',0);
14810
  mm_init_mol ();
13405
  mm_init_mol ();
14811
  for (i = spt; i < lenst; i++)
13406
  for (i = spt; i < lenst; i++) {
14812
    {
-
 
14813
      bb = st[i];
13407
    bb = st[i];
14814
      if ((bb == bb10) || (i == lenst))
13408
    if ((bb == bb10) || (i == lenst)) {
14815
        {
-
 
14816
          J = 0;
13409
            J = 0;
14817
          // d:='';
13410
            // d:='';
14818
          for (k = spt; k < i; k++)
13411
            for (k = spt; k < i; k++) {
14819
            {
-
 
14820
 
-
 
14821
              aa = st[k];
13412
              aa = st[k];
14822
              if ((aa != bb10) && (aa != bb13))
13413
              if ((aa != bb10) && (aa != bb13)) {
14823
                {
-
 
14824
                  //d:=d+aa;
13414
                      //d:=d+aa;
14825
                  tt[J] = aa;
13415
                      tt[J] = aa;
14826
                  J++;
13416
                      J++;
14827
                }
13417
                    }
14828
            }
13418
            }
14829
          tt[J] = bb0;
13419
            tt[J] = bb0;
14830
          spt = i;
13420
            spt = i;
14831
          //messagebox (0,tt,tt,0);
13421
            //messagebox (0,tt,tt,0);
14832
//printf("A:%s\n",tt);
13422
      //printf("A:%s\n",tt);
14833
          mm_read_input_line (tt);
13423
            mm_read_input_line (tt);
14834
        }
13424
          }
14835
    }
13425
  }
14836
//free(tt);
13426
//free(tt);
14837
  mm_elab_mol (checkmol_mode, normalize_ionic_bnds);
13427
  mm_elab_mol (checkmol_mode, normalize_ionic_bnds);
14838
//printf("mm_set_mol\n");
13428
//printf("mm_set_mol\n");
14839
}
13429
}
14840
 
13430
 
14841
DLLEXPORT void
-
 
14842
cm_set_mol (const char *st, int normalize_ionic_bnds)
13431
DLLEXPORT void cm_set_mol (const char *st, int normalize_ionic_bnds)
14843
{
13432
{
14844
  mm_set_mol_dll (st, true, (normalize_ionic_bnds != FEATURE_OFF));
13433
  mm_set_mol_dll (st, true, (normalize_ionic_bnds != FEATURE_OFF));
14845
}
13434
}
14846
 
13435
 
14847
DLLEXPORT void
-
 
14848
mm_set_mol (const char *st)
13436
DLLEXPORT void mm_set_mol (const char *st)
14849
{
13437
{
14850
  mm_set_mol_dll (st, false, true);
13438
  mm_set_mol_dll (st, false, true);
14851
}
13439
}
14852
 
13440
 
14853
DLLEXPORT void
-
 
14854
xm_set_strict_typing (int strict_typing)
13441
DLLEXPORT void xm_set_strict_typing (int strict_typing)
14855
{
13442
{
14856
  if (!yet_initialized)
13443
  if (!yet_initialized)
14857
    init_globals_dll ();
13444
    init_globals_dll ();
14858
  opt_strict = (strict_typing != FEATURE_OFF);
13445
  opt_strict = (strict_typing != FEATURE_OFF);
14859
  //opt_strict=false; //This never worked right and is harmful
13446
  //opt_strict=false; //This never worked right and is harmful
14860
}
13447
}
14861
 
13448
 
14862
DLLEXPORT void
-
 
14863
mm_set_r_s_check (int r_s_check)
13449
DLLEXPORT void mm_set_r_s_check (int r_s_check)
14864
{
13450
{
14865
  if (!yet_initialized)
13451
  if (!yet_initialized)
14866
    init_globals_dll ();
13452
    init_globals_dll ();
14867
  opt_chiral = (r_s_check != FEATURE_OFF);
13453
  opt_chiral = (r_s_check != FEATURE_OFF);
14868
}
13454
}
14869
 
13455
 
14870
DLLEXPORT void
-
 
14871
mm_set_e_z_check (int e_z_check)
13456
DLLEXPORT void mm_set_e_z_check (int e_z_check)
14872
{
13457
{
14873
  if (!yet_initialized)
13458
  if (!yet_initialized)
14874
    init_globals_dll ();
13459
    init_globals_dll ();
14875
  opt_geom = (e_z_check != FEATURE_OFF);
13460
  opt_geom = (e_z_check != FEATURE_OFF);
14876
}
13461
}
14877
 
13462
 
14878
DLLEXPORT void
-
 
14879
mm_set_chg_check (int chg_check)
13463
DLLEXPORT void mm_set_chg_check (int chg_check)
14880
{
13464
{
14881
  if (!yet_initialized)
13465
  if (!yet_initialized)
14882
    init_globals_dll ();
13466
    init_globals_dll ();
14883
  opt_chg = (chg_check != FEATURE_OFF);
13467
  opt_chg = (chg_check != FEATURE_OFF);
14884
}
13468
}
14885
 
13469
 
14886
DLLEXPORT void
-
 
14887
mm_set_iso_check (int iso_check)
13470
DLLEXPORT void mm_set_iso_check (int iso_check)
14888
{
13471
{
14889
  if (!yet_initialized)
13472
  if (!yet_initialized)
14890
    init_globals_dll ();
13473
    init_globals_dll ();
14891
  opt_iso = (iso_check != FEATURE_OFF);
13474
  opt_iso = (iso_check != FEATURE_OFF);
14892
}
13475
}
14893
 
13476
 
14894
DLLEXPORT void
-
 
14895
mm_set_rad_check (int rad_check)
13477
DLLEXPORT void mm_set_rad_check (int rad_check)
14896
{
13478
{
14897
  if (!yet_initialized)
13479
  if (!yet_initialized)
14898
    init_globals_dll ();
13480
    init_globals_dll ();
14899
  opt_rad = (rad_check != FEATURE_OFF);
13481
  opt_rad = (rad_check != FEATURE_OFF);
14900
}
13482
}
14901
 
13483
 
14902
DLLEXPORT void
-
 
14903
mm_set_exact_match (int exact)
13484
DLLEXPORT void mm_set_exact_match (int exact)
14904
{
13485
{
14905
  if (!yet_initialized)
13486
  if (!yet_initialized)
14906
    init_globals_dll ();
13487
    init_globals_dll ();
14907
  opt_exact = (exact != FEATURE_OFF);
13488
  opt_exact = (exact != FEATURE_OFF);
14908
}
13489
}
14909
 
13490
 
14910
DLLEXPORT int
13491
DLLEXPORT int mm_match ()
14911
mm_match ()
-
 
14912
{
13492
{
14913
  mol_count = 1;
13493
  mol_count = 1;
14914
//     mm_ElabMol;
13494
  //     mm_ElabMol;
14915
/*printf("%i\n",opt_exact);
13495
  /*printf("%i\n",opt_exact);
14916
printf("%i\n",n_Ctot);
13496
  printf("%i\n",n_Ctot);
14917
printf("%i\n",ndl_n_Ctot);
13497
  printf("%i\n",ndl_n_Ctot);
14918
printf("%i\n",n_Otot);
13498
  printf("%i\n",n_Otot);
14919
printf("%i\n",ndl_n_Otot);
13499
  printf("%i\n",ndl_n_Otot);
14920
printf("%i\n",n_Ntot);
13500
  printf("%i\n",n_Ntot);
14921
printf("%i\n",ndl_n_Ntot);*/
13501
  printf("%i\n",ndl_n_Ntot);*/
14922
  if (opt_exact
13502
  if (opt_exact
14923
      && (n_Ctot != ndl_n_Ctot || n_Otot != ndl_n_Otot
13503
      && (n_Ctot != ndl_n_Ctot || n_Otot != ndl_n_Otot
14924
          || n_Ntot != ndl_n_Ntot))
13504
            || n_Ntot != ndl_n_Ntot))
14925
    return 0;
13505
    return 0;
14926
  init_molstat (&ndl_molstat);
13506
  init_molstat (&ndl_molstat);
14927
  //perform_match ();
13507
  //perform_match ();
14928
  //---------------------------------------------------- 0.3o
13508
  //---------------------------------------------------- 0.3o
14929
  if (rs_strict)                /* v0.3j */
13509
  if (rs_strict)                /* v0.3j */
Line 14934... Line 13514...
14934
  clear_atom_tags ();
13514
  clear_atom_tags ();
14935
  set_ndl_atom_tags ();
13515
  set_ndl_atom_tags ();
14936
  matchsummary = true;
13516
  matchsummary = true;
14937
  perform_match ();
13517
  perform_match ();
14938
  matchsummary = matchresult;
13518
  matchsummary = matchresult;
14939
  if (count_tagged_ndl_heavyatoms () > 0 && matchsummary == true)
13519
  if (count_tagged_ndl_heavyatoms () > 0 && matchsummary == true) {
14940
    {
13520
    do {
14941
      do
-
 
14942
        {
-
 
14943
          if (rs_strict)
13521
            if (rs_strict)
14944
            ndl_ref_atom = find_ndl_ref_atom_cv ();
13522
              ndl_ref_atom = find_ndl_ref_atom_cv ();
14945
          else
13523
            else
14946
            ndl_ref_atom = find_ndl_ref_atom ();
13524
              ndl_ref_atom = find_ndl_ref_atom ();
14947
          perform_match ();
13525
            perform_match ();
14948
          if (matchresult == false)
13526
            if (matchresult == false)
14949
            matchsummary = false;
13527
             matchsummary = false;
14950
        }
13528
          }
14951
      while (count_tagged_ndl_heavyatoms () != 0 && matchsummary != false);
13529
    while (count_tagged_ndl_heavyatoms () != 0 && matchsummary != false);
14952
    }
13530
  }
14953
 
13531
 
14954
  //-----------------------------------------------------
13532
  //-----------------------------------------------------
14955
 
13533
 
14956
  //mol_count = 0;
13534
  //mol_count = 0;
14957
 
13535
 
14958
  //molbufindex = 0;
13536
  //molbufindex = 0;
14959
 
13537
 
14960
  //return matchresult ? 1 : 0;
13538
  //return matchresult ? 1 : 0;
14961
 
13539
 
14962
  return matchsummary ? 1 : 0;
13540
  return matchsummary ? 1 : 0;
14963
}
13541
}
-
 
13542
 
-
 
13543
//-------------------------
14964
 
13544
 
14965
//-------------------------
-
 
14966
 
-
 
14967
DLLEXPORT void
-
 
14968
xm_set_ring_perception_algorithm (int algo)
13545
DLLEXPORT void xm_set_ring_perception_algorithm (int algo)
14969
{
13546
{
14970
  switch (algo)
13547
  switch (algo) {
14971
    {
-
 
14972
    case RPA_SAR:
13548
    case RPA_SAR:
14973
      opt_rs_dll = rs_sar;
13549
      opt_rs_dll = rs_sar;
14974
      break;
13550
      break;
14975
    case RPA_SSR:
13551
    case RPA_SSR:
14976
      opt_rs_dll = rs_ssr;
13552
      opt_rs_dll = rs_ssr;
14977
      break;
13553
      break;
14978
    default:
13554
    default:
14979
      opt_rs_dll = RPA_DEFAULT;
13555
      opt_rs_dll = RPA_DEFAULT;
14980
      break;
13556
      break;
14981
    }
13557
    }
14982
  //printf("RPA_SET: %i\n",opt_rs_dll);
13558
  //printf("RPA_SET: %i\n",opt_rs_dll);
14983
}
13559
}
14984
 
13560
 
14985
static void
-
 
14986
write_molstat_X_dll (char *out_buffer)
13561
static void write_molstat_X_dll (char *out_buffer)
14987
{
13562
{
14988
  char tmp_buf[256];
13563
  char tmp_buf[256];
14989
  out_buffer[0] = '\0';
13564
  out_buffer[0] = '\0';
14990
  if (auto_ssr)                 /* v0.3n */
13565
  if (auto_ssr)                 /* v0.3n */
14991
    fix_ssr_ringcounts ();
13566
    fix_ssr_ringcounts ();
Line 15001... Line 13576...
15001
  strcat (out_buffer, tmp_buf);
13576
  strcat (out_buffer, tmp_buf);
15002
#endif
13577
#endif
15003
  sprintf (tmp_buf, "%d,", molstat.n_QA);
13578
  sprintf (tmp_buf, "%d,", molstat.n_QA);
15004
  strcat (out_buffer, tmp_buf);
13579
  strcat (out_buffer, tmp_buf);
15005
  sprintf (tmp_buf, "%d,", molstat.n_QB);
13580
  sprintf (tmp_buf, "%d,", molstat.n_QB);
15006
  strcat (out_buffer, tmp_buf);
13581
  strcat (out_buffer, tmp_buf);
15007
  //if (opt_chg)
13582
  //if (opt_chg)
15008
//    {                         /* 0.3x */
13583
//    {                         /* 0.3x */
15009
//      sprintf (tmp_buf, "%d,", molstat.n_chg);
13584
//      sprintf (tmp_buf, "%d,", molstat.n_chg);
15010
//    }
13585
//    }
15011
//  else
13586
//  else
15012
//    {
13587
//    {
15013
  sprintf (tmp_buf, "%d,", molstat.n_chg);
13588
  sprintf (tmp_buf, "%d,", molstat.n_chg);
15014
  //   }
13589
  //   }
15015
  strcat (out_buffer, tmp_buf);
13590
  strcat (out_buffer, tmp_buf);
15016
  sprintf (tmp_buf, "%d,", molstat.n_C1);
13591
  sprintf (tmp_buf, "%d,", molstat.n_C1);
15017
  strcat (out_buffer, tmp_buf);
13592
  strcat (out_buffer, tmp_buf);
15018
  sprintf (tmp_buf, "%d,", molstat.n_C2);
13593
  sprintf (tmp_buf, "%d,", molstat.n_C2);
15019
  strcat (out_buffer, tmp_buf);
13594
  strcat (out_buffer, tmp_buf);
15020
  sprintf (tmp_buf, "%d,", molstat.n_C);
13595
  sprintf (tmp_buf, "%d,", molstat.n_C);
15021
  strcat (out_buffer, tmp_buf);
13596
  strcat (out_buffer, tmp_buf);
15022
  sprintf (tmp_buf, "%d,", molstat.n_CHB1p);
13597
  sprintf (tmp_buf, "%d,", molstat.n_CHB1p);
15023
  strcat (out_buffer, tmp_buf);
13598
  strcat (out_buffer, tmp_buf);
15024
  sprintf (tmp_buf, "%d,", molstat.n_CHB2p);
13599
  sprintf (tmp_buf, "%d,", molstat.n_CHB2p);
15025
  strcat (out_buffer, tmp_buf);
13600
  strcat (out_buffer, tmp_buf);
15026
  sprintf (tmp_buf, "%d,", molstat.n_CHB3p);
13601
  sprintf (tmp_buf, "%d,", molstat.n_CHB3p);
15027
  strcat (out_buffer, tmp_buf);
13602
  strcat (out_buffer, tmp_buf);
15028
  sprintf (tmp_buf, "%d,", molstat.n_CHB4);
13603
  sprintf (tmp_buf, "%d,", molstat.n_CHB4);
15029
  strcat (out_buffer, tmp_buf);
-
 
15030
  sprintf (tmp_buf, "%d,", molstat.n_O2);
-
 
15031
  strcat (out_buffer, tmp_buf);
13604
  strcat (out_buffer, tmp_buf);
-
 
13605
  sprintf (tmp_buf, "%d,", molstat.n_O2);
-
 
13606
  strcat (out_buffer, tmp_buf);
15032
  sprintf (tmp_buf, "%d,", molstat.n_O3);
13607
  sprintf (tmp_buf, "%d,", molstat.n_O3);
15033
  strcat (out_buffer, tmp_buf);
13608
  strcat (out_buffer, tmp_buf);
15034
  sprintf (tmp_buf, "%d,", molstat.n_N1);
13609
  sprintf (tmp_buf, "%d,", molstat.n_N1);
15035
  strcat (out_buffer, tmp_buf);
13610
  strcat (out_buffer, tmp_buf);
15036
  sprintf (tmp_buf, "%d,", molstat.n_N2);
13611
  sprintf (tmp_buf, "%d,", molstat.n_N2);
15037
  strcat (out_buffer, tmp_buf);
13612
  strcat (out_buffer, tmp_buf);
15038
  sprintf (tmp_buf, "%d,", molstat.n_N3);
13613
  sprintf (tmp_buf, "%d,", molstat.n_N3);
15039
  strcat (out_buffer, tmp_buf);
13614
  strcat (out_buffer, tmp_buf);
15040
  sprintf (tmp_buf, "%d,", molstat.n_S);
13615
  sprintf (tmp_buf, "%d,", molstat.n_S);
15041
  strcat (out_buffer, tmp_buf);
13616
  strcat (out_buffer, tmp_buf);
15042
  sprintf (tmp_buf, "%d,", molstat.n_SeTe);
13617
  sprintf (tmp_buf, "%d,", molstat.n_SeTe);
15043
  strcat (out_buffer, tmp_buf);
13618
  strcat (out_buffer, tmp_buf);
15044
  sprintf (tmp_buf, "%d,", molstat.n_F);
13619
  sprintf (tmp_buf, "%d,", molstat.n_F);
15045
  strcat (out_buffer, tmp_buf);
13620
  strcat (out_buffer, tmp_buf);
15046
  sprintf (tmp_buf, "%d,", molstat.n_Cl);
13621
  sprintf (tmp_buf, "%d,", molstat.n_Cl);
15047
  strcat (out_buffer, tmp_buf);
-
 
15048
  sprintf (tmp_buf, "%d,", molstat.n_Br);
-
 
15049
  strcat (out_buffer, tmp_buf);
13622
  strcat (out_buffer, tmp_buf);
-
 
13623
  sprintf (tmp_buf, "%d,", molstat.n_Br);
-
 
13624
  strcat (out_buffer, tmp_buf);
15050
  sprintf (tmp_buf, "%d,", molstat.n_I);
13625
  sprintf (tmp_buf, "%d,", molstat.n_I);
15051
  strcat (out_buffer, tmp_buf);
13626
  strcat (out_buffer, tmp_buf);
15052
  sprintf (tmp_buf, "%d,", molstat.n_P);
13627
  sprintf (tmp_buf, "%d,", molstat.n_P);
15053
  strcat (out_buffer, tmp_buf);
13628
  strcat (out_buffer, tmp_buf);
15054
  sprintf (tmp_buf, "%d,", molstat.n_B);
13629
  sprintf (tmp_buf, "%d,", molstat.n_B);
15055
  strcat (out_buffer, tmp_buf);
13630
  strcat (out_buffer, tmp_buf);
15056
  sprintf (tmp_buf, "%d,", molstat.n_Met);
13631
  sprintf (tmp_buf, "%d,", molstat.n_Met);
15057
  strcat (out_buffer, tmp_buf);
13632
  strcat (out_buffer, tmp_buf);
15058
  sprintf (tmp_buf, "%d,", molstat.n_X);
13633
  sprintf (tmp_buf, "%d,", molstat.n_X);
15059
  strcat (out_buffer, tmp_buf);
13634
  strcat (out_buffer, tmp_buf);
15060
  sprintf (tmp_buf, "%d,", molstat.n_b1);
13635
  sprintf (tmp_buf, "%d,", molstat.n_b1);
15061
  strcat (out_buffer, tmp_buf);
13636
  strcat (out_buffer, tmp_buf);
15062
  sprintf (tmp_buf, "%d,", molstat.n_b2);
13637
  sprintf (tmp_buf, "%d,", molstat.n_b2);
15063
  strcat (out_buffer, tmp_buf);
13638
  strcat (out_buffer, tmp_buf);
15064
  sprintf (tmp_buf, "%d,", molstat.n_b3);
13639
  sprintf (tmp_buf, "%d,", molstat.n_b3);
15065
  strcat (out_buffer, tmp_buf);
13640
  strcat (out_buffer, tmp_buf);
15066
  sprintf (tmp_buf, "%d,", molstat.n_bar);
13641
  sprintf (tmp_buf, "%d,", molstat.n_bar);
Line 15103... Line 13678...
15103
  strcat (out_buffer, tmp_buf);
13678
  strcat (out_buffer, tmp_buf);
15104
  sprintf (tmp_buf, "%d,", molstat.n_rN3p);
13679
  sprintf (tmp_buf, "%d,", molstat.n_rN3p);
15105
  strcat (out_buffer, tmp_buf);
13680
  strcat (out_buffer, tmp_buf);
15106
  sprintf (tmp_buf, "%d,", molstat.n_rO);
13681
  sprintf (tmp_buf, "%d,", molstat.n_rO);
15107
  strcat (out_buffer, tmp_buf);
13682
  strcat (out_buffer, tmp_buf);
15108
  sprintf (tmp_buf, "%d,", molstat.n_rO1);
13683
  sprintf (tmp_buf, "%d,", molstat.n_rO1);
15109
  strcat (out_buffer, tmp_buf);
-
 
15110
  sprintf (tmp_buf, "%d,", molstat.n_rO2p);
-
 
15111
  strcat (out_buffer, tmp_buf);
13684
  strcat (out_buffer, tmp_buf);
15112
  sprintf (tmp_buf, "%d,", molstat.n_rS);
13685
  sprintf (tmp_buf, "%d,", molstat.n_rO2p);
15113
  strcat (out_buffer, tmp_buf);
13686
  strcat (out_buffer, tmp_buf);
15114
  sprintf (tmp_buf, "%d,", molstat.n_rX);
13687
  sprintf (tmp_buf, "%d,", molstat.n_rS);
15115
  strcat (out_buffer, tmp_buf);
13688
  strcat (out_buffer, tmp_buf);
15116
  sprintf (tmp_buf, "%d,", molstat.n_rAr);
13689
  sprintf (tmp_buf, "%d,", molstat.n_rX);
15117
  strcat (out_buffer, tmp_buf);
13690
  strcat (out_buffer, tmp_buf);
-
 
13691
  sprintf (tmp_buf, "%d,", molstat.n_rAr);
-
 
13692
  strcat (out_buffer, tmp_buf);
15118
  sprintf (tmp_buf, "%d,", molstat.n_rBz);
13693
  sprintf (tmp_buf, "%d,", molstat.n_rBz);
15119
  strcat (out_buffer, tmp_buf);
13694
  strcat (out_buffer, tmp_buf);
15120
  sprintf (tmp_buf, "%d,", molstat.n_br2p);
13695
  sprintf (tmp_buf, "%d,", molstat.n_br2p);
15121
  strcat (out_buffer, tmp_buf);
13696
  strcat (out_buffer, tmp_buf);
15122
  sprintf (tmp_buf, "%d,", molstat.n_psg01);
13697
  sprintf (tmp_buf, "%d,", molstat.n_psg01);
15123
  strcat (out_buffer, tmp_buf);
13698
  strcat (out_buffer, tmp_buf);
15124
  sprintf (tmp_buf, "%d,", molstat.n_psg02);
13699
  sprintf (tmp_buf, "%d,", molstat.n_psg02);
15125
  strcat (out_buffer, tmp_buf);
-
 
15126
  sprintf (tmp_buf, "%d,", molstat.n_psg13);
-
 
15127
  strcat (out_buffer, tmp_buf);
13700
  strcat (out_buffer, tmp_buf);
15128
  sprintf (tmp_buf, "%d,", molstat.n_psg14);
13701
  sprintf (tmp_buf, "%d,", molstat.n_psg13);
15129
  strcat (out_buffer, tmp_buf);
13702
  strcat (out_buffer, tmp_buf);
15130
  sprintf (tmp_buf, "%d,", molstat.n_psg15);
13703
  sprintf (tmp_buf, "%d,", molstat.n_psg14);
15131
  strcat (out_buffer, tmp_buf);
13704
  strcat (out_buffer, tmp_buf);
15132
  sprintf (tmp_buf, "%d,", molstat.n_psg16);
13705
  sprintf (tmp_buf, "%d,", molstat.n_psg15);
15133
  strcat (out_buffer, tmp_buf);
13706
  strcat (out_buffer, tmp_buf);
-
 
13707
  sprintf (tmp_buf, "%d,", molstat.n_psg16);
-
 
13708
  strcat (out_buffer, tmp_buf);
15134
  sprintf (tmp_buf, "%d,", molstat.n_psg17);
13709
  sprintf (tmp_buf, "%d,", molstat.n_psg17);
15135
  strcat (out_buffer, tmp_buf);
13710
  strcat (out_buffer, tmp_buf);
15136
  sprintf (tmp_buf, "%d,", molstat.n_psg18);
13711
  sprintf (tmp_buf, "%d,", molstat.n_psg18);
15137
  strcat (out_buffer, tmp_buf);
13712
  strcat (out_buffer, tmp_buf);
15138
  sprintf (tmp_buf, "%d,", molstat.n_pstm);
13713
  sprintf (tmp_buf, "%d,", molstat.n_pstm);
15139
  strcat (out_buffer, tmp_buf);
13714
  strcat (out_buffer, tmp_buf);
15140
  sprintf (tmp_buf, "%d,", molstat.n_psla);
13715
  sprintf (tmp_buf, "%d,", molstat.n_psla);
15141
  strcat (out_buffer, tmp_buf);
13716
  strcat (out_buffer, tmp_buf);
15142
  sprintf (tmp_buf, "%d,", molstat.n_iso);
13717
  sprintf (tmp_buf, "%d,", molstat.n_iso);
15143
  strcat (out_buffer, tmp_buf);
13718
  strcat (out_buffer, tmp_buf);
15144
  sprintf (tmp_buf, "%d", molstat.n_rad);
13719
  sprintf (tmp_buf, "%d", molstat.n_rad);
15145
  strcat (out_buffer, tmp_buf);
13720
  strcat (out_buffer, tmp_buf);
15146
}
13721
}
15147
 
13722
 
15148
static void
-
 
15149
write_molstat_dll (char *out_buffer, int mode)
13723
static void write_molstat_dll (char *out_buffer, int mode) {
15150
{
-
 
15151
  char tmp_buf[256];
13724
  char tmp_buf[256];
15152
  char *sep1;
13725
  char *sep1;
15153
  char *sep2;
13726
  char *sep2;
15154
  switch (mode)
13727
  switch (mode) {
15155
    {
-
 
15156
    case 1:
13728
    case 1:
15157
      sep1 = "=";
13729
      sep1 = "=";
15158
      sep2 = " AND ";
13730
      sep2 = " AND ";
15159
      break;
13731
      break;
15160
    case 2:
13732
    case 2:
Line 15163... Line 13735...
15163
      break;
13735
      break;
15164
    default:
13736
    default:
15165
      sep1 = ":";
13737
      sep1 = ":";
15166
      sep2 = ";";
13738
      sep2 = ";";
15167
      break;
13739
      break;
15168
    }
13740
    }
15169
 
-
 
15170
 
-
 
15171
 
13741
 
15172
  out_buffer[0] = '\0';
13742
  out_buffer[0] = '\0';
15173
 
13743
 
15174
  if (auto_ssr)                 /* v0.3n */
13744
  if (auto_ssr)                 /* v0.3n */
15175
    fix_ssr_ringcounts ();
13745
    fix_ssr_ringcounts ();
15176
  sprintf (tmp_buf, "n_atoms%s%d%s", sep1, n_heavyatoms, sep2);
13746
  sprintf (tmp_buf, "n_atoms%s%d%s", sep1, n_heavyatoms, sep2);
15177
  strcat (out_buffer, tmp_buf);
13747
  strcat (out_buffer, tmp_buf);
15178
  if (n_bonds > 0)
13748
  if (n_bonds > 0) {
15179
    {
-
 
15180
      sprintf (tmp_buf, "n_bonds%s%d%s", sep1, n_heavybonds, sep2);
13749
      sprintf (tmp_buf, "n_bonds%s%d%s", sep1, n_heavybonds, sep2);
15181
      strcat (out_buffer, tmp_buf);
13750
      strcat (out_buffer, tmp_buf);
15182
    }
13751
    }
15183
 
13752
 
15184
#ifdef REDUCED_SAR
13753
#ifdef REDUCED_SAR
15185
  if (n_rings > 0)
13754
  if (n_rings > 0) {
15186
    {
-
 
15187
      sprintf (tmp_buf, "n_rings%s%d%s", sep1, n_countablerings, sep2);
13755
      sprintf (tmp_buf, "n_rings%s%d%s", sep1, n_countablerings, sep2);
15188
      strcat (out_buffer, tmp_buf);
13756
      strcat (out_buffer, tmp_buf);
15189
    }
13757
    }
15190
#else
13758
#else
15191
  if (n_rings > 0)
13759
  if (n_rings > 0) {
15192
    {
-
 
15193
      sprintf (tmp_buf, "n_rings%s%d%s", sep1, n_rings, sep2);
13760
      sprintf (tmp_buf, "n_rings%s%d%s", sep1, n_rings, sep2);
15194
      strcat (out_buffer, tmp_buf);
13761
      strcat (out_buffer, tmp_buf);
15195
    }
13762
    }
15196
#endif
13763
#endif
15197
 
13764
 
15198
  if (opt_chg && molstat.n_chg > 0)     /* 0.3x */
13765
  if (opt_chg && molstat.n_chg > 0)     /* 0.3x */ {
15199
    {
13766
    sprintf (tmp_buf, "n_chg%s%d%s", sep1, molstat.n_chg, sep2);
15200
      sprintf (tmp_buf, "n_chg%s%d%s", sep1, molstat.n_chg, sep2);
13767
    strcat (out_buffer, tmp_buf);
15201
      strcat (out_buffer, tmp_buf);
13768
  }
15202
    }
13769
  if (molstat.n_C1 > 0) {
15203
  if (molstat.n_C1 > 0)
13770
    sprintf (tmp_buf, "n_C1%s%d%s", sep1, molstat.n_C1, sep2);
15204
    {
13771
    strcat (out_buffer, tmp_buf);
15205
      sprintf (tmp_buf, "n_C1%s%d%s", sep1, molstat.n_C1, sep2);
13772
  }
15206
      strcat (out_buffer, tmp_buf);
13773
  if (molstat.n_C2 > 0) {
15207
    }
13774
    sprintf (tmp_buf, "n_C2%s%d%s", sep1, molstat.n_C2, sep2);
15208
  if (molstat.n_C2 > 0)
13775
    strcat (out_buffer, tmp_buf);
15209
    {
13776
  }
15210
      sprintf (tmp_buf, "n_C2%s%d%s", sep1, molstat.n_C2, sep2);
13777
 
15211
      strcat (out_buffer, tmp_buf);
13778
  if (molstat.n_C > 0) {
15212
    }
13779
    sprintf (tmp_buf, "n_C%s%d%s", sep1, molstat.n_C, sep2);
15213
 
13780
    strcat (out_buffer, tmp_buf);
15214
 
13781
  }
15215
  if (molstat.n_C > 0)
13782
  if (molstat.n_CHB1p > 0) {
15216
    {
13783
    sprintf (tmp_buf, "n_CHB1p%s%d%s", sep1, molstat.n_CHB1p, sep2);
15217
      sprintf (tmp_buf, "n_C%s%d%s", sep1, molstat.n_C, sep2);
13784
    strcat (out_buffer, tmp_buf);
15218
      strcat (out_buffer, tmp_buf);
13785
  }
15219
    }
13786
  if (molstat.n_CHB2p > 0) {
15220
  if (molstat.n_CHB1p > 0)
13787
    sprintf (tmp_buf, "n_CHB2p%s%d%s", sep1, molstat.n_CHB2p, sep2);
15221
    {
13788
    strcat (out_buffer, tmp_buf);
15222
      sprintf (tmp_buf, "n_CHB1p%s%d%s", sep1, molstat.n_CHB1p, sep2);
13789
  }
15223
      strcat (out_buffer, tmp_buf);
13790
  if (molstat.n_CHB3p > 0) {
15224
    }
13791
    sprintf (tmp_buf, "n_CHB3p%s%d%s", sep1, molstat.n_CHB3p, sep2);
15225
  if (molstat.n_CHB2p > 0)
13792
    strcat (out_buffer, tmp_buf);
15226
    {
13793
  }
15227
      sprintf (tmp_buf, "n_CHB2p%s%d%s", sep1, molstat.n_CHB2p, sep2);
13794
  if (molstat.n_CHB4 > 0) {
15228
      strcat (out_buffer, tmp_buf);
13795
    sprintf (tmp_buf, "n_CHB4%s%d%s", sep1, molstat.n_CHB4, sep2);
15229
    }
13796
    strcat (out_buffer, tmp_buf);
15230
  if (molstat.n_CHB3p > 0)
13797
  }
15231
    {
13798
  if (molstat.n_O2 > 0) {
15232
      sprintf (tmp_buf, "n_CHB3p%s%d%s", sep1, molstat.n_CHB3p, sep2);
13799
    sprintf (tmp_buf, "n_O2%s%d%s", sep1, molstat.n_O2, sep2);
15233
      strcat (out_buffer, tmp_buf);
13800
    strcat (out_buffer, tmp_buf);
15234
    }
13801
  }
15235
  if (molstat.n_CHB4 > 0)
13802
  if (molstat.n_O3 > 0) {
15236
    {
13803
    sprintf (tmp_buf, "n_O3%s%d%s", sep1, molstat.n_O3, sep2);
15237
      sprintf (tmp_buf, "n_CHB4%s%d%s", sep1, molstat.n_CHB4, sep2);
13804
    strcat (out_buffer, tmp_buf);
15238
      strcat (out_buffer, tmp_buf);
13805
  }
15239
    }
13806
  if (molstat.n_N1 > 0) {
15240
  if (molstat.n_O2 > 0)
13807
    sprintf (tmp_buf, "n_N1%s%d%s", sep1, molstat.n_N1, sep2);
15241
    {
13808
    strcat (out_buffer, tmp_buf);
15242
      sprintf (tmp_buf, "n_O2%s%d%s", sep1, molstat.n_O2, sep2);
13809
  }
15243
      strcat (out_buffer, tmp_buf);
13810
  if (molstat.n_N2 > 0) {
15244
    }
13811
    sprintf (tmp_buf, "n_N2%s%d%s", sep1, molstat.n_N2, sep2);
15245
  if (molstat.n_O3 > 0)
13812
    strcat (out_buffer, tmp_buf);
15246
    {
13813
  }
15247
      sprintf (tmp_buf, "n_O3%s%d%s", sep1, molstat.n_O3, sep2);
13814
  if (molstat.n_N3 > 0) {
15248
      strcat (out_buffer, tmp_buf);
13815
    sprintf (tmp_buf, "n_N3%s%d%s", sep1, molstat.n_N3, sep2);
15249
    }
13816
    strcat (out_buffer, tmp_buf);
15250
  if (molstat.n_N1 > 0)
13817
  }
15251
    {
13818
  if (molstat.n_S > 0) {
15252
      sprintf (tmp_buf, "n_N1%s%d%s", sep1, molstat.n_N1, sep2);
13819
    sprintf (tmp_buf, "n_S%s%d%s", sep1, molstat.n_S, sep2);
15253
      strcat (out_buffer, tmp_buf);
13820
    strcat (out_buffer, tmp_buf);
15254
    }
13821
  }
15255
  if (molstat.n_N2 > 0)
13822
  if (molstat.n_SeTe > 0) {
15256
    {
13823
    sprintf (tmp_buf, "n_SeTe%s%d%s", sep1, molstat.n_SeTe, sep2);
15257
      sprintf (tmp_buf, "n_N2%s%d%s", sep1, molstat.n_N2, sep2);
13824
    strcat (out_buffer, tmp_buf);
15258
      strcat (out_buffer, tmp_buf);
13825
  }
15259
    }
13826
  if (molstat.n_F > 0) {
15260
  if (molstat.n_N3 > 0)
13827
    sprintf (tmp_buf, "n_F%s%d%s", sep1, molstat.n_F, sep2);
15261
    {
13828
    strcat (out_buffer, tmp_buf);
15262
      sprintf (tmp_buf, "n_N3%s%d%s", sep1, molstat.n_N3, sep2);
13829
  }
15263
      strcat (out_buffer, tmp_buf);
13830
  if (molstat.n_Cl > 0) {
15264
    }
13831
    sprintf (tmp_buf, "n_Cl%s%d%s", sep1, molstat.n_Cl, sep2);
15265
  if (molstat.n_S > 0)
13832
    strcat (out_buffer, tmp_buf);
15266
    {
13833
  }
15267
      sprintf (tmp_buf, "n_S%s%d%s", sep1, molstat.n_S, sep2);
13834
  if (molstat.n_Br > 0) {
15268
      strcat (out_buffer, tmp_buf);
13835
    sprintf (tmp_buf, "n_Br%s%d%s", sep1, molstat.n_Br, sep2);
15269
    }
13836
    strcat (out_buffer, tmp_buf);
15270
  if (molstat.n_SeTe > 0)
13837
  }
15271
    {
13838
  if (molstat.n_I > 0) {
15272
      sprintf (tmp_buf, "n_SeTe%s%d%s", sep1, molstat.n_SeTe, sep2);
13839
    sprintf (tmp_buf, "n_I%s%d%s", sep1, molstat.n_I, sep2);
15273
      strcat (out_buffer, tmp_buf);
13840
    strcat (out_buffer, tmp_buf);
15274
    }
13841
  }
15275
  if (molstat.n_F > 0)
13842
  if (molstat.n_P > 0) {
15276
    {
13843
    sprintf (tmp_buf, "n_P%s%d%s", sep1, molstat.n_P, sep2);
15277
      sprintf (tmp_buf, "n_F%s%d%s", sep1, molstat.n_F, sep2);
13844
    strcat (out_buffer, tmp_buf);
15278
      strcat (out_buffer, tmp_buf);
13845
  }
15279
    }
13846
  if (molstat.n_B > 0) {
15280
  if (molstat.n_Cl > 0)
13847
    sprintf (tmp_buf, "n_B%s%d%s", sep1, molstat.n_B, sep2);
15281
    {
13848
    strcat (out_buffer, tmp_buf);
15282
      sprintf (tmp_buf, "n_Cl%s%d%s", sep1, molstat.n_Cl, sep2);
13849
  }
15283
      strcat (out_buffer, tmp_buf);
13850
  if (molstat.n_Met > 0) {
15284
    }
13851
    sprintf (tmp_buf, "n_Met%s%d%s", sep1, molstat.n_Met, sep2);
15285
  if (molstat.n_Br > 0)
13852
    strcat (out_buffer, tmp_buf);
15286
    {
13853
  }
15287
      sprintf (tmp_buf, "n_Br%s%d%s", sep1, molstat.n_Br, sep2);
13854
  if (molstat.n_X > 0) {
15288
      strcat (out_buffer, tmp_buf);
13855
    sprintf (tmp_buf, "n_X%s%d%s", sep1, molstat.n_X, sep2);
15289
    }
13856
    strcat (out_buffer, tmp_buf);
15290
  if (molstat.n_I > 0)
13857
  }
15291
    {
13858
  if (molstat.n_b1 > 0) {
15292
      sprintf (tmp_buf, "n_I%s%d%s", sep1, molstat.n_I, sep2);
13859
    sprintf (tmp_buf, "n_b1%s%d%s", sep1, molstat.n_b1, sep2);
15293
      strcat (out_buffer, tmp_buf);
13860
    strcat (out_buffer, tmp_buf);
15294
    }
13861
  }
15295
  if (molstat.n_P > 0)
13862
  if (molstat.n_b2 > 0) {
15296
    {
13863
    sprintf (tmp_buf, "n_b2%s%d%s", sep1, molstat.n_b2, sep2);
15297
      sprintf (tmp_buf, "n_P%s%d%s", sep1, molstat.n_P, sep2);
13864
    strcat (out_buffer, tmp_buf);
15298
      strcat (out_buffer, tmp_buf);
13865
  }
15299
    }
13866
  if (molstat.n_b3 > 0) {
15300
  if (molstat.n_B > 0)
13867
    sprintf (tmp_buf, "n_b3%s%d%s", sep1, molstat.n_b3, sep2);
15301
    {
13868
    strcat (out_buffer, tmp_buf);
15302
      sprintf (tmp_buf, "n_B%s%d%s", sep1, molstat.n_B, sep2);
13869
  }
15303
      strcat (out_buffer, tmp_buf);
13870
  if (molstat.n_bar > 0) {
15304
    }
13871
   sprintf (tmp_buf, "n_bar%s%d%s", sep1, molstat.n_bar, sep2);
15305
  if (molstat.n_Met > 0)
13872
   strcat (out_buffer, tmp_buf);
15306
    {
13873
  }
15307
      sprintf (tmp_buf, "n_Met%s%d%s", sep1, molstat.n_Met, sep2);
13874
  if (molstat.n_C1O > 0) {
15308
      strcat (out_buffer, tmp_buf);
13875
    sprintf (tmp_buf, "n_C1O%s%d%s", sep1, molstat.n_C1O, sep2);
15309
    }
13876
    strcat (out_buffer, tmp_buf);
15310
  if (molstat.n_X > 0)
13877
  }
15311
    {
13878
  if (molstat.n_C2O > 0) {
15312
      sprintf (tmp_buf, "n_X%s%d%s", sep1, molstat.n_X, sep2);
-
 
15313
      strcat (out_buffer, tmp_buf);
-
 
15314
    }
-
 
15315
  if (molstat.n_b1 > 0)
-
 
15316
    {
-
 
15317
      sprintf (tmp_buf, "n_b1%s%d%s", sep1, molstat.n_b1, sep2);
-
 
15318
      strcat (out_buffer, tmp_buf);
-
 
15319
    }
-
 
15320
  if (molstat.n_b2 > 0)
-
 
15321
    {
-
 
15322
      sprintf (tmp_buf, "n_b2%s%d%s", sep1, molstat.n_b2, sep2);
-
 
15323
      strcat (out_buffer, tmp_buf);
-
 
15324
    }
-
 
15325
  if (molstat.n_b3 > 0)
-
 
15326
    {
-
 
15327
      sprintf (tmp_buf, "n_b3%s%d%s", sep1, molstat.n_b3, sep2);
-
 
15328
      strcat (out_buffer, tmp_buf);
-
 
15329
    }
-
 
15330
  if (molstat.n_bar > 0)
-
 
15331
    {
-
 
15332
      sprintf (tmp_buf, "n_bar%s%d%s", sep1, molstat.n_bar, sep2);
-
 
15333
      strcat (out_buffer, tmp_buf);
-
 
15334
    }
-
 
15335
  if (molstat.n_C1O > 0)
-
 
15336
    {
-
 
15337
      sprintf (tmp_buf, "n_C1O%s%d%s", sep1, molstat.n_C1O, sep2);
-
 
15338
      strcat (out_buffer, tmp_buf);
-
 
15339
    }
-
 
15340
  if (molstat.n_C2O > 0)
-
 
15341
    {
-
 
15342
      sprintf (tmp_buf, "n_C2O%s%d%s", sep1, molstat.n_C2O, sep2);
13879
      sprintf (tmp_buf, "n_C2O%s%d%s", sep1, molstat.n_C2O, sep2);
15343
      strcat (out_buffer, tmp_buf);
13880
      strcat (out_buffer, tmp_buf);
15344
    }
13881
    }
15345
  if (molstat.n_CN > 0)
13882
  if (molstat.n_CN > 0) {
15346
    {
-
 
15347
      sprintf (tmp_buf, "n_CN%s%d%s", sep1, molstat.n_CN, sep2);
13883
      sprintf (tmp_buf, "n_CN%s%d%s", sep1, molstat.n_CN, sep2);
15348
      strcat (out_buffer, tmp_buf);
13884
      strcat (out_buffer, tmp_buf);
15349
    }
13885
    }
15350
  if (molstat.n_XY > 0)
13886
  if (molstat.n_XY > 0) {
-
 
13887
    sprintf (tmp_buf, "n_XY%s%d%s", sep1, molstat.n_XY, sep2);
-
 
13888
    strcat (out_buffer, tmp_buf);
15351
    {
13889
  }
-
 
13890
  if (molstat.n_r3 > 0) {
15352
      sprintf (tmp_buf, "n_XY%s%d%s", sep1, molstat.n_XY, sep2);
13891
    sprintf (tmp_buf, "n_r3%s%d%s", sep1, molstat.n_r3, sep2);
15353
      strcat (out_buffer, tmp_buf);
13892
    strcat (out_buffer, tmp_buf);
15354
    }
13893
  }
15355
  if (molstat.n_r3 > 0)
13894
  if (molstat.n_r4 > 0) {
-
 
13895
    sprintf (tmp_buf, "n_r4%s%d%s", sep1, molstat.n_r4, sep2);
-
 
13896
    strcat (out_buffer, tmp_buf);
15356
    {
13897
  }
-
 
13898
  if (molstat.n_r5 > 0) {
15357
      sprintf (tmp_buf, "n_r3%s%d%s", sep1, molstat.n_r3, sep2);
13899
    sprintf (tmp_buf, "n_r5%s%d%s", sep1, molstat.n_r5, sep2);
15358
      strcat (out_buffer, tmp_buf);
13900
    strcat (out_buffer, tmp_buf);
15359
    }
13901
  }
15360
  if (molstat.n_r4 > 0)
13902
  if (molstat.n_r6 > 0) {
-
 
13903
    sprintf (tmp_buf, "n_r6%s%d%s", sep1, molstat.n_r6, sep2);
-
 
13904
    strcat (out_buffer, tmp_buf);
15361
    {
13905
  }
-
 
13906
  if (molstat.n_r7 > 0) {
15362
      sprintf (tmp_buf, "n_r4%s%d%s", sep1, molstat.n_r4, sep2);
13907
    sprintf (tmp_buf, "n_r7%s%d%s", sep1, molstat.n_r7, sep2);
15363
      strcat (out_buffer, tmp_buf);
13908
    strcat (out_buffer, tmp_buf);
15364
    }
13909
  }
15365
  if (molstat.n_r5 > 0)
13910
  if (molstat.n_r8 > 0) {
-
 
13911
    sprintf (tmp_buf, "n_r8%s%d%s", sep1, molstat.n_r8, sep2);
-
 
13912
    strcat (out_buffer, tmp_buf);
15366
    {
13913
  }
-
 
13914
  if (molstat.n_r9 > 0) {
15367
      sprintf (tmp_buf, "n_r5%s%d%s", sep1, molstat.n_r5, sep2);
13915
    sprintf (tmp_buf, "n_r9%s%d%s", sep1, molstat.n_r9, sep2);
15368
      strcat (out_buffer, tmp_buf);
13916
    strcat (out_buffer, tmp_buf);
15369
    }
13917
  }
15370
  if (molstat.n_r6 > 0)
13918
  if (molstat.n_r10 > 0) {
-
 
13919
    sprintf (tmp_buf, "n_r10%s%d%s", sep1, molstat.n_r10, sep2);
-
 
13920
    strcat (out_buffer, tmp_buf);
15371
    {
13921
  }
-
 
13922
  if (molstat.n_r11 > 0) {
15372
      sprintf (tmp_buf, "n_r6%s%d%s", sep1, molstat.n_r6, sep2);
13923
    sprintf (tmp_buf, "n_r11%s%d%s", sep1, molstat.n_r11, sep2);
15373
      strcat (out_buffer, tmp_buf);
13924
    strcat (out_buffer, tmp_buf);
15374
    }
13925
  }
15375
  if (molstat.n_r7 > 0)
13926
  if (molstat.n_r12 > 0) {
-
 
13927
    sprintf (tmp_buf, "n_r12%s%d%s", sep1, molstat.n_r12, sep2);
-
 
13928
    strcat (out_buffer, tmp_buf);
15376
    {
13929
  }
-
 
13930
  if (molstat.n_r13p > 0) {
15377
      sprintf (tmp_buf, "n_r7%s%d%s", sep1, molstat.n_r7, sep2);
13931
      sprintf (tmp_buf, "n_r13p%s%d%s", sep1, molstat.n_r13p, sep2);
15378
      strcat (out_buffer, tmp_buf);
13932
      strcat (out_buffer, tmp_buf);
15379
    }
13933
    }
15380
  if (molstat.n_r8 > 0)
13934
  if (molstat.n_rN > 0) {
-
 
13935
    sprintf (tmp_buf, "n_rN%s%d%s", sep1, molstat.n_rN, sep2);
-
 
13936
    strcat (out_buffer, tmp_buf);
15381
    {
13937
  }
-
 
13938
  if (molstat.n_rN1 > 0) {
15382
      sprintf (tmp_buf, "n_r8%s%d%s", sep1, molstat.n_r8, sep2);
13939
    sprintf (tmp_buf, "n_rN1%s%d%s", sep1, molstat.n_rN1, sep2);
15383
      strcat (out_buffer, tmp_buf);
13940
    strcat (out_buffer, tmp_buf);
15384
    }
13941
  }
15385
  if (molstat.n_r9 > 0)
13942
  if (molstat.n_rN2 > 0) {
-
 
13943
    sprintf (tmp_buf, "n_rN2%s%d%s", sep1, molstat.n_rN2, sep2);
-
 
13944
    strcat (out_buffer, tmp_buf);
-
 
13945
  }
-
 
13946
  if (molstat.n_rN3p > 0) {
-
 
13947
    sprintf (tmp_buf, "n_rN3p%s%d%s", sep1, molstat.n_rN3p, sep2);
-
 
13948
    strcat (out_buffer, tmp_buf);
15386
    {
13949
  }
-
 
13950
  if (molstat.n_rO > 0) {
15387
      sprintf (tmp_buf, "n_r9%s%d%s", sep1, molstat.n_r9, sep2);
13951
    sprintf (tmp_buf, "n_rO%s%d%s", sep1, molstat.n_rO, sep2);
15388
      strcat (out_buffer, tmp_buf);
13952
    strcat (out_buffer, tmp_buf);
15389
    }
13953
  }
15390
  if (molstat.n_r10 > 0)
13954
  if (molstat.n_rO1 > 0) {
-
 
13955
    sprintf (tmp_buf, "n_rO1%s%d%s", sep1, molstat.n_rO1, sep2);
-
 
13956
    strcat (out_buffer, tmp_buf);
15391
    {
13957
  }
-
 
13958
  if (molstat.n_rO2p > 0) {
15392
      sprintf (tmp_buf, "n_r10%s%d%s", sep1, molstat.n_r10, sep2);
13959
    sprintf (tmp_buf, "n_rO2p%s%d%s", sep1, molstat.n_rO2p, sep2);
15393
      strcat (out_buffer, tmp_buf);
13960
    strcat (out_buffer, tmp_buf);
15394
    }
13961
  }
15395
  if (molstat.n_r11 > 0)
13962
  if (molstat.n_rS > 0) {
-
 
13963
    sprintf (tmp_buf, "n_rS%s%d%s", sep1, molstat.n_rS, sep2);
-
 
13964
    strcat (out_buffer, tmp_buf);
15396
    {
13965
  }
-
 
13966
  if (molstat.n_rX > 0) {
15397
      sprintf (tmp_buf, "n_r11%s%d%s", sep1, molstat.n_r11, sep2);
13967
    sprintf (tmp_buf, "n_rX%s%d%s", sep1, molstat.n_rX, sep2);
15398
      strcat (out_buffer, tmp_buf);
13968
    strcat (out_buffer, tmp_buf);
15399
    }
13969
  }
15400
  if (molstat.n_r12 > 0)
13970
  if (molstat.n_rAr > 0) {
-
 
13971
    sprintf (tmp_buf, "n_rar%s%d%s", sep1, molstat.n_rAr, sep2);
-
 
13972
    strcat (out_buffer, tmp_buf);
15401
    {
13973
  }
-
 
13974
 
-
 
13975
  if (molstat.n_rBz > 0) {
15402
      sprintf (tmp_buf, "n_r12%s%d%s", sep1, molstat.n_r12, sep2);
13976
    sprintf (tmp_buf, "n_rbz%s%d%s", sep1, molstat.n_rBz, sep2);
15403
      strcat (out_buffer, tmp_buf);
13977
    strcat (out_buffer, tmp_buf);
15404
    }
13978
  }
-
 
13979
 
15405
  if (molstat.n_r13p > 0)
13980
  if (molstat.n_br2p > 0) {
-
 
13981
    sprintf (tmp_buf, "n_br2p%s%d%s", sep1, molstat.n_br2p, sep2);
-
 
13982
    strcat (out_buffer, tmp_buf);
-
 
13983
  }
-
 
13984
 
-
 
13985
  if (molstat.n_psg01 > 0) {
-
 
13986
    sprintf (tmp_buf, "n_psg01%s%d%s", sep1, molstat.n_psg01, sep2);
-
 
13987
    strcat (out_buffer, tmp_buf);
-
 
13988
  }
-
 
13989
 
-
 
13990
  if (molstat.n_psg02 > 0) {
-
 
13991
    sprintf (tmp_buf, "n_psg02%s%d%s", sep1, molstat.n_psg02, sep2);
-
 
13992
    strcat (out_buffer, tmp_buf);
-
 
13993
  }
-
 
13994
 
-
 
13995
  if (molstat.n_psg13 > 0) {
-
 
13996
    sprintf (tmp_buf, "n_psg13%s%d%s", sep1, molstat.n_psg13, sep2);
-
 
13997
    strcat (out_buffer, tmp_buf);
-
 
13998
  }
-
 
13999
 
-
 
14000
  if (molstat.n_psg14 > 0) {
-
 
14001
    sprintf (tmp_buf, "n_psg14%s%d%s", sep1, molstat.n_psg14, sep2);
-
 
14002
    strcat (out_buffer, tmp_buf);
-
 
14003
  }
-
 
14004
 
-
 
14005
  if (molstat.n_psg15 > 0) {
-
 
14006
    sprintf (tmp_buf, "n_psg15%s%d%s", sep1, molstat.n_psg15, sep2);
-
 
14007
    strcat (out_buffer, tmp_buf);
-
 
14008
  }
-
 
14009
 
-
 
14010
  if (molstat.n_psg16 > 0) {
-
 
14011
    sprintf (tmp_buf, "n_psg16%s%d%s", sep1, molstat.n_psg16, sep2);
-
 
14012
    strcat (out_buffer, tmp_buf);
-
 
14013
  }
-
 
14014
 
-
 
14015
  if (molstat.n_psg17 > 0) {
-
 
14016
    sprintf (tmp_buf, "n_psg17%s%d%s", sep1, molstat.n_psg17, sep2);
-
 
14017
    strcat (out_buffer, tmp_buf);
-
 
14018
  }
-
 
14019
 
-
 
14020
  if (molstat.n_psg18 > 0) {
-
 
14021
    sprintf (tmp_buf, "n_psg18%s%d%s", sep1, molstat.n_psg18, sep2);
-
 
14022
    strcat (out_buffer, tmp_buf);
15406
    {
14023
  }
-
 
14024
 
-
 
14025
  if (molstat.n_pstm > 0) {
15407
      sprintf (tmp_buf, "n_r13p%s%d%s", sep1, molstat.n_r13p, sep2);
14026
      sprintf (tmp_buf, "n_pstm%s%d%s", sep1, molstat.n_pstm, sep2);
15408
      strcat (out_buffer, tmp_buf);
14027
      strcat (out_buffer, tmp_buf);
15409
    }
-
 
15410
  if (molstat.n_rN > 0)
-
 
15411
    {
-
 
15412
      sprintf (tmp_buf, "n_rN%s%d%s", sep1, molstat.n_rN, sep2);
-
 
15413
      strcat (out_buffer, tmp_buf);
-
 
15414
    }
-
 
15415
  if (molstat.n_rN1 > 0)
-
 
15416
    {
-
 
15417
      sprintf (tmp_buf, "n_rN1%s%d%s", sep1, molstat.n_rN1, sep2);
-
 
15418
      strcat (out_buffer, tmp_buf);
-
 
15419
    }
-
 
15420
  if (molstat.n_rN2 > 0)
-
 
15421
    {
-
 
15422
      sprintf (tmp_buf, "n_rN2%s%d%s", sep1, molstat.n_rN2, sep2);
-
 
15423
      strcat (out_buffer, tmp_buf);
-
 
15424
    }
-
 
15425
  if (molstat.n_rN3p > 0)
-
 
15426
    {
-
 
15427
      sprintf (tmp_buf, "n_rN3p%s%d%s", sep1, molstat.n_rN3p, sep2);
-
 
15428
      strcat (out_buffer, tmp_buf);
-
 
15429
    }
-
 
15430
  if (molstat.n_rO > 0)
-
 
15431
    {
-
 
15432
      sprintf (tmp_buf, "n_rO%s%d%s", sep1, molstat.n_rO, sep2);
-
 
15433
      strcat (out_buffer, tmp_buf);
-
 
15434
    }
-
 
15435
  if (molstat.n_rO1 > 0)
-
 
15436
    {
-
 
15437
      sprintf (tmp_buf, "n_rO1%s%d%s", sep1, molstat.n_rO1, sep2);
-
 
15438
      strcat (out_buffer, tmp_buf);
-
 
15439
    }
-
 
15440
  if (molstat.n_rO2p > 0)
-
 
15441
    {
-
 
15442
      sprintf (tmp_buf, "n_rO2p%s%d%s", sep1, molstat.n_rO2p, sep2);
-
 
15443
      strcat (out_buffer, tmp_buf);
-
 
15444
    }
-
 
15445
  if (molstat.n_rS > 0)
-
 
15446
    {
-
 
15447
      sprintf (tmp_buf, "n_rS%s%d%s", sep1, molstat.n_rS, sep2);
-
 
15448
      strcat (out_buffer, tmp_buf);
-
 
15449
    }
-
 
15450
  if (molstat.n_rX > 0)
-
 
15451
    {
-
 
15452
      sprintf (tmp_buf, "n_rX%s%d%s", sep1, molstat.n_rX, sep2);
-
 
15453
      strcat (out_buffer, tmp_buf);
-
 
15454
    }
-
 
15455
  if (molstat.n_rAr > 0)
-
 
15456
    {
-
 
15457
      sprintf (tmp_buf, "n_rar%s%d%s", sep1, molstat.n_rAr, sep2);
-
 
15458
      strcat (out_buffer, tmp_buf);
-
 
15459
    }
-
 
15460
 
-
 
15461
  if (molstat.n_rBz > 0)
-
 
15462
    {
-
 
15463
      sprintf (tmp_buf, "n_rbz%s%d%s", sep1, molstat.n_rBz, sep2);
-
 
15464
      strcat (out_buffer, tmp_buf);
-
 
15465
    }
-
 
15466
 
-
 
15467
  if (molstat.n_br2p > 0)
-
 
15468
    {
-
 
15469
      sprintf (tmp_buf, "n_br2p%s%d%s", sep1, molstat.n_br2p, sep2);
-
 
15470
      strcat (out_buffer, tmp_buf);
-
 
15471
    }
-
 
15472
 
-
 
15473
  if (molstat.n_psg01 > 0)
-
 
15474
    {
-
 
15475
      sprintf (tmp_buf, "n_psg01%s%d%s", sep1, molstat.n_psg01, sep2);
-
 
15476
      strcat (out_buffer, tmp_buf);
-
 
15477
    }
-
 
15478
 
-
 
15479
  if (molstat.n_psg02 > 0)
-
 
15480
    {
-
 
15481
      sprintf (tmp_buf, "n_psg02%s%d%s", sep1, molstat.n_psg02, sep2);
-
 
15482
      strcat (out_buffer, tmp_buf);
-
 
15483
    }
-
 
15484
 
-
 
15485
  if (molstat.n_psg13 > 0)
-
 
15486
    {
-
 
15487
      sprintf (tmp_buf, "n_psg13%s%d%s", sep1, molstat.n_psg13, sep2);
-
 
15488
      strcat (out_buffer, tmp_buf);
-
 
15489
    }
-
 
15490
 
-
 
15491
  if (molstat.n_psg14 > 0)
-
 
15492
    {
-
 
15493
      sprintf (tmp_buf, "n_psg14%s%d%s", sep1, molstat.n_psg14, sep2);
-
 
15494
      strcat (out_buffer, tmp_buf);
-
 
15495
    }
-
 
15496
 
-
 
15497
  if (molstat.n_psg15 > 0)
-
 
15498
    {
-
 
15499
      sprintf (tmp_buf, "n_psg15%s%d%s", sep1, molstat.n_psg15, sep2);
-
 
15500
      strcat (out_buffer, tmp_buf);
-
 
15501
    }
-
 
15502
 
-
 
15503
  if (molstat.n_psg16 > 0)
-
 
15504
    {
-
 
15505
      sprintf (tmp_buf, "n_psg16%s%d%s", sep1, molstat.n_psg16, sep2);
-
 
15506
      strcat (out_buffer, tmp_buf);
-
 
15507
    }
-
 
15508
 
-
 
15509
  if (molstat.n_psg17 > 0)
-
 
15510
    {
-
 
15511
      sprintf (tmp_buf, "n_psg17%s%d%s", sep1, molstat.n_psg17, sep2);
-
 
15512
      strcat (out_buffer, tmp_buf);
-
 
15513
    }
-
 
15514
 
-
 
15515
  if (molstat.n_psg18 > 0)
-
 
15516
    {
-
 
15517
      sprintf (tmp_buf, "n_psg18%s%d%s", sep1, molstat.n_psg18, sep2);
-
 
15518
      strcat (out_buffer, tmp_buf);
-
 
15519
    }
-
 
15520
 
-
 
15521
  if (molstat.n_pstm > 0)
-
 
15522
    {
-
 
15523
      sprintf (tmp_buf, "n_pstm%s%d%s", sep1, molstat.n_pstm, sep2);
-
 
15524
      strcat (out_buffer, tmp_buf);
-
 
15525
    }
14028
    }
15526
 
14029
 
15527
  if (molstat.n_psla > 0)
14030
  if (molstat.n_psla > 0) {
15528
    {
-
 
15529
      sprintf (tmp_buf, "n_psla%s%d%s", sep1, molstat.n_psla, sep2);
14031
      sprintf (tmp_buf, "n_psla%s%d%s", sep1, molstat.n_psla, sep2);
15530
      strcat (out_buffer, tmp_buf);
14032
      strcat (out_buffer, tmp_buf);
15531
    }
14033
    }
15532
 
14034
 
15533
  if (opt_iso && molstat.n_iso > 0)
14035
  if (opt_iso && molstat.n_iso > 0) {
15534
    {
-
 
15535
      sprintf (tmp_buf, "n_iso%s%d%s", sep1, molstat.n_iso, sep2);
14036
    sprintf (tmp_buf, "n_iso%s%d%s", sep1, molstat.n_iso, sep2);
15536
      strcat (out_buffer, tmp_buf);
14037
    strcat (out_buffer, tmp_buf);
15537
    }
14038
  }
15538
 
14039
 
15539
  if (opt_rad && molstat.n_rad > 0)
14040
  if (opt_rad && molstat.n_rad > 0) {
15540
    {
-
 
15541
      sprintf (tmp_buf, "n_rad%s%d%s", sep1, molstat.n_rad, sep2);
14041
    sprintf (tmp_buf, "n_rad%s%d%s", sep1, molstat.n_rad, sep2);
15542
      strcat (out_buffer, tmp_buf);
14042
    strcat (out_buffer, tmp_buf);
15543
    }
14043
  }
15544
}
14044
}
15545
 
14045
 
15546
static void
14046
static void
15547
write_fg_code_dll (char *out_buffer)
14047
write_fg_code_dll (char *out_buffer)
15548
{
14048
{
15549
  char tmp_buf[256];
14049
  char tmp_buf[256];
15550
  out_buffer[0] = '\0';
14050
  out_buffer[0] = '\0';
15551
  if (fg[fg_cation - 1])
14051
  if (fg[fg_cation - 1]) {
15552
    {
14052
    sprintf (tmp_buf, "000000T2;");
15553
      sprintf (tmp_buf, "000000T2;");
14053
    strcat (out_buffer, tmp_buf);
15554
      strcat (out_buffer, tmp_buf);
14054
  }
15555
    }
14055
  if (fg[fg_anion - 1]) {
15556
  if (fg[fg_anion - 1])
14056
    sprintf (tmp_buf, "000000T1;");
15557
    {
14057
    strcat (out_buffer, tmp_buf);
15558
      sprintf (tmp_buf, "000000T1;");
14058
  }
15559
      strcat (out_buffer, tmp_buf);
14059
 
15560
    }
14060
  if (fg[fg_aldehyde - 1]) {
15561
 
14061
    sprintf (tmp_buf, "C2O1H000;");
15562
  if (fg[fg_aldehyde - 1])
14062
    strcat (out_buffer, tmp_buf);
15563
    {
14063
  }
15564
      sprintf (tmp_buf, "C2O1H000;");
14064
  if (fg[fg_ketone - 1]) {
15565
      strcat (out_buffer, tmp_buf);
14065
    sprintf (tmp_buf, "C2O1C000;");
15566
    }
14066
    strcat (out_buffer, tmp_buf);
15567
  if (fg[fg_ketone - 1])
14067
  }
15568
    {
14068
 
15569
      sprintf (tmp_buf, "C2O1C000;");
14069
  if (fg[fg_thioaldehyde - 1]) {
15570
      strcat (out_buffer, tmp_buf);
14070
    sprintf (tmp_buf, "C2S1H000;");
15571
    }
14071
    strcat (out_buffer, tmp_buf);
15572
 
14072
  }
15573
  if (fg[fg_thioaldehyde - 1])
14073
  if (fg[fg_thioketone - 1]) {
15574
    {
14074
    sprintf (tmp_buf, "C2S1C000;");
15575
      sprintf (tmp_buf, "C2S1H000;");
14075
    strcat (out_buffer, tmp_buf);
15576
      strcat (out_buffer, tmp_buf);
14076
  }
15577
    }
14077
  if (fg[fg_imine - 1]) {
15578
  if (fg[fg_thioketone - 1])
14078
    sprintf (tmp_buf, "C2N10000;");
15579
    {
14079
    strcat (out_buffer, tmp_buf);
15580
      sprintf (tmp_buf, "C2S1C000;");
14080
  }
15581
      strcat (out_buffer, tmp_buf);
14081
  if (fg[fg_hydrazone - 1]) {
15582
    }
14082
    sprintf (tmp_buf, "C2N1N000;");
15583
  if (fg[fg_imine - 1])
14083
    strcat (out_buffer, tmp_buf);
15584
    {
14084
  }
15585
      sprintf (tmp_buf, "C2N10000;");
14085
  if (fg[fg_semicarbazone - 1]) {
15586
      strcat (out_buffer, tmp_buf);
14086
    sprintf (tmp_buf, "C2NNC4ON;");
15587
    }
14087
    strcat (out_buffer, tmp_buf);
15588
  if (fg[fg_hydrazone - 1])
14088
  }
15589
    {
14089
  if (fg[fg_thiosemicarbazone - 1]) {
15590
      sprintf (tmp_buf, "C2N1N000;");
14090
    sprintf (tmp_buf, "C2NNC4SN;");
15591
      strcat (out_buffer, tmp_buf);
14091
    strcat (out_buffer, tmp_buf);
15592
    }
14092
  }
15593
  if (fg[fg_semicarbazone - 1])
14093
  if (fg[fg_oxime - 1]) {
15594
    {
14094
    sprintf (tmp_buf, "C2N1OH00;");
15595
      sprintf (tmp_buf, "C2NNC4ON;");
14095
    strcat (out_buffer, tmp_buf);
15596
      strcat (out_buffer, tmp_buf);
14096
  }
15597
    }
14097
  if (fg[fg_oxime_ether - 1]) {
15598
  if (fg[fg_thiosemicarbazone - 1])
14098
    sprintf (tmp_buf, "C2N1OC00;");
15599
    {
14099
    strcat (out_buffer, tmp_buf);
15600
      sprintf (tmp_buf, "C2NNC4SN;");
14100
  }
15601
      strcat (out_buffer, tmp_buf);
14101
  if (fg[fg_ketene - 1]) {
15602
    }
14102
    sprintf (tmp_buf, "C3OC0000;");
15603
  if (fg[fg_oxime - 1])
14103
    strcat (out_buffer, tmp_buf);
15604
    {
14104
  }
15605
      sprintf (tmp_buf, "C2N1OH00;");
14105
  if (fg[fg_ketene_acetal_deriv - 1]) {
15606
      strcat (out_buffer, tmp_buf);
14106
    sprintf (tmp_buf, "C3OCC000;");
15607
    }
14107
    strcat (out_buffer, tmp_buf);
15608
  if (fg[fg_oxime_ether - 1])
14108
  }
15609
    {
14109
  if (fg[fg_carbonyl_hydrate - 1]) {
15610
      sprintf (tmp_buf, "C2N1OC00;");
14110
    sprintf (tmp_buf, "C2O2H200;");
15611
      strcat (out_buffer, tmp_buf);
14111
    strcat (out_buffer, tmp_buf);
15612
    }
14112
  }
15613
  if (fg[fg_ketene - 1])
14113
  if (fg[fg_hemiacetal - 1]) {
15614
    {
14114
    sprintf (tmp_buf, "C2O2HC00;");
15615
      sprintf (tmp_buf, "C3OC0000;");
14115
    strcat (out_buffer, tmp_buf);
15616
      strcat (out_buffer, tmp_buf);
14116
  }
15617
    }
14117
  if (fg[fg_acetal - 1]) {
15618
  if (fg[fg_ketene_acetal_deriv - 1])
14118
   sprintf (tmp_buf, "C2O2CC00;");
15619
    {
14119
   strcat (out_buffer, tmp_buf);
15620
      sprintf (tmp_buf, "C3OCC000;");
14120
  }
15621
      strcat (out_buffer, tmp_buf);
14121
  if (fg[fg_hemiaminal - 1]) {
15622
    }
14122
    sprintf (tmp_buf, "C2NOHC10;");
15623
  if (fg[fg_carbonyl_hydrate - 1])
14123
    strcat (out_buffer, tmp_buf);
15624
    {
14124
  }
15625
      sprintf (tmp_buf, "C2O2H200;");
14125
  if (fg[fg_aminal - 1]) {
15626
      strcat (out_buffer, tmp_buf);
14126
    sprintf (tmp_buf, "C2N2CC10;");
15627
    }
14127
    strcat (out_buffer, tmp_buf);
15628
  if (fg[fg_hemiacetal - 1])
14128
  }
15629
    {
14129
  if (fg[fg_thiohemiaminal - 1]) {
15630
      sprintf (tmp_buf, "C2O2HC00;");
14130
    sprintf (tmp_buf, "C2NSHC10;");
15631
      strcat (out_buffer, tmp_buf);
14131
    strcat (out_buffer, tmp_buf);
15632
    }
14132
  }
15633
  if (fg[fg_acetal - 1])
14133
  if (fg[fg_thioacetal - 1]) {
15634
    {
14134
    sprintf (tmp_buf, "C2S2CC00;");
15635
      sprintf (tmp_buf, "C2O2CC00;");
14135
    strcat (out_buffer, tmp_buf);
15636
      strcat (out_buffer, tmp_buf);
14136
  }
15637
    }
14137
  if (fg[fg_enamine - 1]) {
15638
  if (fg[fg_hemiaminal - 1])
14138
    sprintf (tmp_buf, "C2CNH000;");
15639
    {
14139
    strcat (out_buffer, tmp_buf);
15640
      sprintf (tmp_buf, "C2NOHC10;");
14140
  }
15641
      strcat (out_buffer, tmp_buf);
14141
  if (fg[fg_enol - 1]) {
15642
    }
14142
    sprintf (tmp_buf, "C2COH000;");
15643
  if (fg[fg_aminal - 1])
14143
    strcat (out_buffer, tmp_buf);
15644
    {
14144
  }
15645
      sprintf (tmp_buf, "C2N2CC10;");
14145
  if (fg[fg_enolether - 1]) {
15646
      strcat (out_buffer, tmp_buf);
14146
    sprintf (tmp_buf, "C2COC000;");
15647
    }
14147
    strcat (out_buffer, tmp_buf);
15648
  if (fg[fg_thiohemiaminal - 1])
14148
  }
15649
    {
14149
 
15650
      sprintf (tmp_buf, "C2NSHC10;");
14150
  if (fg[fg_prim_alcohol - 1]) {
15651
      strcat (out_buffer, tmp_buf);
14151
    sprintf (tmp_buf, "O1H1C000;");
15652
    }
14152
    strcat (out_buffer, tmp_buf);
15653
  if (fg[fg_thioacetal - 1])
14153
  }
15654
    {
14154
  if (fg[fg_sec_alcohol - 1]) {
15655
      sprintf (tmp_buf, "C2S2CC00;");
14155
    sprintf (tmp_buf, "O1H2C000;");
15656
      strcat (out_buffer, tmp_buf);
14156
    strcat (out_buffer, tmp_buf);
15657
    }
14157
  }
15658
  if (fg[fg_enamine - 1])
14158
  if (fg[fg_tert_alcohol - 1]) {
15659
    {
14159
    sprintf (tmp_buf, "O1H3C000;");
15660
      sprintf (tmp_buf, "C2CNH000;");
14160
    strcat (out_buffer, tmp_buf);
15661
      strcat (out_buffer, tmp_buf);
14161
  }
15662
    }
14162
  if (fg[fg_1_2_diol - 1]) {
15663
  if (fg[fg_enol - 1])
14163
    sprintf (tmp_buf, "O1H0CO1H;");
15664
    {
14164
    strcat (out_buffer, tmp_buf);
15665
      sprintf (tmp_buf, "C2COH000;");
14165
  }
15666
      strcat (out_buffer, tmp_buf);
14166
  if (fg[fg_1_2_aminoalcohol - 1]) {
15667
    }
14167
    sprintf (tmp_buf, "O1H0CN1C;");
15668
  if (fg[fg_enolether - 1])
14168
    strcat (out_buffer, tmp_buf);
15669
    {
14169
  }
15670
      sprintf (tmp_buf, "C2COC000;");
14170
  if (fg[fg_phenol - 1]) {
15671
      strcat (out_buffer, tmp_buf);
14171
    sprintf (tmp_buf, "O1H1A000;");
15672
    }
14172
    strcat (out_buffer, tmp_buf);
15673
 
14173
  }
15674
 
14174
  if (fg[fg_1_2_diphenol - 1]) {
15675
  if (fg[fg_prim_alcohol - 1])
14175
    sprintf (tmp_buf, "O1H2A000;");
15676
    {
14176
    strcat (out_buffer, tmp_buf);
15677
      sprintf (tmp_buf, "O1H1C000;");
14177
  }
15678
      strcat (out_buffer, tmp_buf);
14178
  if (fg[fg_enediol - 1]) {
15679
    }
14179
    sprintf (tmp_buf, "C2COH200;");
15680
  if (fg[fg_sec_alcohol - 1])
14180
    strcat (out_buffer, tmp_buf);
15681
    {
14181
  }
15682
      sprintf (tmp_buf, "O1H2C000;");
14182
 
15683
      strcat (out_buffer, tmp_buf);
14183
  if (fg[fg_dialkylether - 1]) {
15684
    }
14184
    sprintf (tmp_buf, "O1C0CC00;");
15685
  if (fg[fg_tert_alcohol - 1])
14185
    strcat (out_buffer, tmp_buf);
15686
    {
14186
  }
15687
      sprintf (tmp_buf, "O1H3C000;");
14187
  if (fg[fg_alkylarylether - 1]) {
15688
      strcat (out_buffer, tmp_buf);
14188
    sprintf (tmp_buf, "O1C0CA00;");
15689
    }
14189
    strcat (out_buffer, tmp_buf);
15690
  if (fg[fg_1_2_diol - 1])
14190
  }
15691
    {
14191
  if (fg[fg_diarylether - 1]) {
15692
      sprintf (tmp_buf, "O1H0CO1H;");
14192
    sprintf (tmp_buf, "O1C0AA00;");
15693
      strcat (out_buffer, tmp_buf);
14193
    strcat (out_buffer, tmp_buf);
15694
    }
14194
  }
15695
  if (fg[fg_1_2_aminoalcohol - 1])
14195
  if (fg[fg_thioether - 1]) {
15696
    {
14196
    sprintf (tmp_buf, "S1C00000;");
15697
      sprintf (tmp_buf, "O1H0CN1C;");
14197
    strcat (out_buffer, tmp_buf);
15698
      strcat (out_buffer, tmp_buf);
14198
  }
15699
    }
14199
  if (fg[fg_disulfide - 1]) {
15700
  if (fg[fg_phenol - 1])
14200
    sprintf (tmp_buf, "S1S1C000;");
15701
    {
14201
    strcat (out_buffer, tmp_buf);
15702
      sprintf (tmp_buf, "O1H1A000;");
14202
  }
15703
      strcat (out_buffer, tmp_buf);
14203
  if (fg[fg_peroxide - 1]) {
15704
    }
14204
    sprintf (tmp_buf, "O1O1C000;");
15705
  if (fg[fg_1_2_diphenol - 1])
14205
    strcat (out_buffer, tmp_buf);
15706
    {
14206
  }
15707
      sprintf (tmp_buf, "O1H2A000;");
14207
  if (fg[fg_hydroperoxide - 1]) {
15708
      strcat (out_buffer, tmp_buf);
14208
    sprintf (tmp_buf, "O1O1H000;");
15709
    }
14209
    strcat (out_buffer, tmp_buf);
15710
  if (fg[fg_enediol - 1])
14210
  }
15711
    {
14211
  if (fg[fg_hydrazine - 1]) {
15712
      sprintf (tmp_buf, "C2COH200;");
14212
    sprintf (tmp_buf, "N1N10000;");
15713
      strcat (out_buffer, tmp_buf);
14213
    strcat (out_buffer, tmp_buf);
15714
    }
14214
  }
15715
 
14215
  if (fg[fg_hydroxylamine - 1]) {
15716
  if (fg[fg_dialkylether - 1])
14216
    sprintf (tmp_buf, "N1O1H000;");
15717
    {
14217
    strcat (out_buffer, tmp_buf);
15718
      sprintf (tmp_buf, "O1C0CC00;");
14218
  }
15719
      strcat (out_buffer, tmp_buf);
14219
 
15720
    }
14220
  if (fg[fg_prim_aliph_amine - 1]) {
15721
  if (fg[fg_alkylarylether - 1])
14221
    sprintf (tmp_buf, "N1C1C000;");
15722
    {
14222
    strcat (out_buffer, tmp_buf);
15723
      sprintf (tmp_buf, "O1C0CA00;");
14223
  }
15724
      strcat (out_buffer, tmp_buf);
14224
  if (fg[fg_prim_arom_amine - 1]) {
15725
    }
14225
    sprintf (tmp_buf, "N1C1A000;");
15726
  if (fg[fg_diarylether - 1])
14226
    strcat (out_buffer, tmp_buf);
15727
    {
14227
  }
15728
      sprintf (tmp_buf, "O1C0AA00;");
14228
 
15729
      strcat (out_buffer, tmp_buf);
14229
  if (fg[fg_sec_aliph_amine - 1]) {
15730
    }
14230
    sprintf (tmp_buf, "N1C2CC00;");
15731
  if (fg[fg_thioether - 1])
14231
    strcat (out_buffer, tmp_buf);
15732
    {
14232
  }
15733
      sprintf (tmp_buf, "S1C00000;");
14233
  if (fg[fg_sec_mixed_amine - 1]) {
15734
      strcat (out_buffer, tmp_buf);
14234
    sprintf (tmp_buf, "N1C2AC00;");
15735
    }
14235
    strcat (out_buffer, tmp_buf);
15736
  if (fg[fg_disulfide - 1])
14236
  }
15737
    {
14237
  if (fg[fg_sec_arom_amine - 1]) {
15738
      sprintf (tmp_buf, "S1S1C000;");
14238
    sprintf (tmp_buf, "N1C2AA00;");
15739
      strcat (out_buffer, tmp_buf);
14239
    strcat (out_buffer, tmp_buf);
15740
    }
14240
  }
15741
  if (fg[fg_peroxide - 1])
14241
 
15742
    {
14242
  if (fg[fg_tert_aliph_amine - 1]) {
15743
      sprintf (tmp_buf, "O1O1C000;");
14243
    sprintf (tmp_buf, "N1C3CC00;");
15744
      strcat (out_buffer, tmp_buf);
14244
    strcat (out_buffer, tmp_buf);
15745
    }
14245
  }
15746
  if (fg[fg_hydroperoxide - 1])
14246
  if (fg[fg_tert_mixed_amine - 1]) {
15747
    {
14247
    sprintf (tmp_buf, "N1C3AC00;");
15748
      sprintf (tmp_buf, "O1O1H000;");
14248
    strcat (out_buffer, tmp_buf);
15749
      strcat (out_buffer, tmp_buf);
14249
  }
15750
    }
14250
  if (fg[fg_tert_arom_amine - 1]) {
15751
  if (fg[fg_hydrazine - 1])
14251
    sprintf (tmp_buf, "N1C3AA00;");
15752
    {
14252
    strcat (out_buffer, tmp_buf);
15753
      sprintf (tmp_buf, "N1N10000;");
14253
  }
15754
      strcat (out_buffer, tmp_buf);
14254
  if (fg[fg_quart_ammonium - 1]) {
15755
    }
14255
    sprintf (tmp_buf, "N1C400T2;");
15756
  if (fg[fg_hydroxylamine - 1])
14256
    strcat (out_buffer, tmp_buf);
15757
    {
14257
  }
15758
      sprintf (tmp_buf, "N1O1H000;");
14258
  if (fg[fg_n_oxide - 1]) {
15759
      strcat (out_buffer, tmp_buf);
14259
    sprintf (tmp_buf, "N0O10000;");
15760
    }
14260
    strcat (out_buffer, tmp_buf);
15761
 
14261
  }
15762
 
14262
 
15763
  if (fg[fg_prim_aliph_amine - 1])
14263
  if (fg[fg_halogen_deriv - 1]) {
15764
    {
14264
    if (!fg[fg_alkyl_halide - 1] && !fg[fg_aryl_halide - 1] && !fg[fg_acyl_halide - 1]) {
15765
      sprintf (tmp_buf, "N1C1C000;");
14265
            sprintf (tmp_buf, "XX000000;");
15766
      strcat (out_buffer, tmp_buf);
14266
            strcat (out_buffer, tmp_buf);
15767
    }
14267
          }
15768
  if (fg[fg_prim_arom_amine - 1])
14268
  }
15769
    {
14269
 
15770
      sprintf (tmp_buf, "N1C1A000;");
14270
  if (fg[fg_alkyl_fluoride - 1]) {
15771
      strcat (out_buffer, tmp_buf);
14271
    sprintf (tmp_buf, "XF00C000;");
15772
    }
14272
    strcat (out_buffer, tmp_buf);
15773
 
14273
  }
15774
  if (fg[fg_sec_aliph_amine - 1])
14274
  if (fg[fg_alkyl_chloride - 1]) {
15775
    {
14275
    sprintf (tmp_buf, "XC00C000;");
15776
      sprintf (tmp_buf, "N1C2CC00;");
14276
    strcat (out_buffer, tmp_buf);
15777
      strcat (out_buffer, tmp_buf);
14277
  }
15778
    }
14278
  if (fg[fg_alkyl_bromide - 1]) {
15779
  if (fg[fg_sec_mixed_amine - 1])
14279
    sprintf (tmp_buf, "XB00C000;");
15780
    {
14280
    strcat (out_buffer, tmp_buf);
15781
      sprintf (tmp_buf, "N1C2AC00;");
14281
  }
15782
      strcat (out_buffer, tmp_buf);
14282
  if (fg[fg_alkyl_iodide - 1]) {
15783
    }
14283
    sprintf (tmp_buf, "XI00C000;");
15784
  if (fg[fg_sec_arom_amine - 1])
14284
    strcat (out_buffer, tmp_buf);
15785
    {
14285
  }
15786
      sprintf (tmp_buf, "N1C2AA00;");
14286
 
15787
      strcat (out_buffer, tmp_buf);
14287
  if (fg[fg_aryl_fluoride - 1]) {
15788
    }
14288
    sprintf (tmp_buf, "XF00A000;");
15789
 
14289
    strcat (out_buffer, tmp_buf);
15790
  if (fg[fg_tert_aliph_amine - 1])
14290
  }
15791
    {
14291
  if (fg[fg_aryl_chloride - 1]) {
15792
      sprintf (tmp_buf, "N1C3CC00;");
14292
    sprintf (tmp_buf, "XC00A000;");
15793
      strcat (out_buffer, tmp_buf);
14293
    strcat (out_buffer, tmp_buf);
15794
    }
14294
  }
15795
  if (fg[fg_tert_mixed_amine - 1])
14295
  if (fg[fg_aryl_bromide - 1]) {
15796
    {
14296
    sprintf (tmp_buf, "XB00A000;");
15797
      sprintf (tmp_buf, "N1C3AC00;");
14297
    strcat (out_buffer, tmp_buf);
15798
      strcat (out_buffer, tmp_buf);
14298
  }
15799
    }
14299
  if (fg[fg_aryl_iodide - 1]) {
15800
  if (fg[fg_tert_arom_amine - 1])
14300
    sprintf (tmp_buf, "XI00A000;");
15801
    {
14301
    strcat (out_buffer, tmp_buf);
15802
      sprintf (tmp_buf, "N1C3AA00;");
14302
  }
15803
      strcat (out_buffer, tmp_buf);
14303
  if (fg[fg_organometallic - 1]) {
15804
    }
14304
    sprintf (tmp_buf, "000000MX;");
15805
  if (fg[fg_quart_ammonium - 1])
14305
    strcat (out_buffer, tmp_buf);
15806
    {
14306
  }
15807
      sprintf (tmp_buf, "N1C400T2;");
14307
  if (fg[fg_organolithium - 1]) {
15808
      strcat (out_buffer, tmp_buf);
14308
    sprintf (tmp_buf, "000000ML;");
15809
    }
14309
    strcat (out_buffer, tmp_buf);
15810
  if (fg[fg_n_oxide - 1])
14310
  }
15811
    {
14311
  if (fg[fg_organomagnesium - 1]) {
15812
      sprintf (tmp_buf, "N0O10000;");
14312
    sprintf (tmp_buf, "000000MM;");
15813
      strcat (out_buffer, tmp_buf);
14313
    strcat (out_buffer, tmp_buf);
15814
    }
14314
  }
15815
 
14315
 
15816
 
14316
  if (fg[fg_carboxylic_acid - 1]) {
15817
  if (fg[fg_halogen_deriv - 1])
14317
    sprintf (tmp_buf, "C3O2H000;");
15818
    {
14318
    strcat (out_buffer, tmp_buf);
15819
      if (!fg[fg_alkyl_halide - 1] && !fg[fg_aryl_halide - 1] &&
14319
  }
15820
          !fg[fg_acyl_halide - 1])
14320
  if (fg[fg_carboxylic_acid_salt - 1]) {
15821
        {
14321
    sprintf (tmp_buf, "C3O200T1;");
15822
          sprintf (tmp_buf, "XX000000;");
14322
    strcat (out_buffer, tmp_buf);
15823
          strcat (out_buffer, tmp_buf);
14323
  }
15824
        }
14324
  if (fg[fg_carboxylic_acid_ester - 1]) {
15825
    }
14325
    sprintf (tmp_buf, "C3O2C000;");
15826
 
14326
    strcat (out_buffer, tmp_buf);
15827
  if (fg[fg_alkyl_fluoride - 1])
14327
  }
15828
    {
14328
  if (fg[fg_lactone - 1]) {
15829
      sprintf (tmp_buf, "XF00C000;");
14329
    sprintf (tmp_buf, "C3O2CZ00;");
15830
      strcat (out_buffer, tmp_buf);
14330
    strcat (out_buffer, tmp_buf);
15831
    }
14331
  }
15832
  if (fg[fg_alkyl_chloride - 1])
14332
 
15833
    {
14333
  if (fg[fg_carboxylic_acid_prim_amide - 1]) {
15834
      sprintf (tmp_buf, "XC00C000;");
14334
    sprintf (tmp_buf, "C3ONC100;");
15835
      strcat (out_buffer, tmp_buf);
14335
    strcat (out_buffer, tmp_buf);
15836
    }
14336
  }
15837
  if (fg[fg_alkyl_bromide - 1])
14337
  if (fg[fg_carboxylic_acid_sec_amide - 1]) {
15838
    {
14338
    sprintf (tmp_buf, "C3ONC200;");
15839
      sprintf (tmp_buf, "XB00C000;");
14339
    strcat (out_buffer, tmp_buf);
15840
      strcat (out_buffer, tmp_buf);
14340
  }
15841
    }
14341
  if (fg[fg_carboxylic_acid_tert_amide - 1]) {
15842
  if (fg[fg_alkyl_iodide - 1])
14342
    sprintf (tmp_buf, "C3ONC300;");
15843
    {
14343
    strcat (out_buffer, tmp_buf);
15844
      sprintf (tmp_buf, "XI00C000;");
14344
  }
15845
      strcat (out_buffer, tmp_buf);
14345
  if (fg[fg_lactam - 1]) {
15846
    }
14346
    sprintf (tmp_buf, "C3ONCZ00;");
15847
 
14347
    strcat (out_buffer, tmp_buf);
15848
  if (fg[fg_aryl_fluoride - 1])
14348
  }
15849
    {
14349
  if (fg[fg_carboxylic_acid_hydrazide - 1]) {
15850
      sprintf (tmp_buf, "XF00A000;");
14350
    sprintf (tmp_buf, "C3ONN100;");
15851
      strcat (out_buffer, tmp_buf);
14351
    strcat (out_buffer, tmp_buf);
15852
    }
14352
  }
15853
  if (fg[fg_aryl_chloride - 1])
14353
  if (fg[fg_carboxylic_acid_azide - 1]) {
15854
    {
14354
    sprintf (tmp_buf, "C3ONN200;");
15855
      sprintf (tmp_buf, "XC00A000;");
14355
    strcat (out_buffer, tmp_buf);
15856
      strcat (out_buffer, tmp_buf);
14356
  }
15857
    }
14357
  if (fg[fg_hydroxamic_acid - 1]) {
15858
  if (fg[fg_aryl_bromide - 1])
14358
    sprintf (tmp_buf, "C3ONOH00;");
15859
    {
14359
    strcat (out_buffer, tmp_buf);
15860
      sprintf (tmp_buf, "XB00A000;");
14360
  }
15861
      strcat (out_buffer, tmp_buf);
14361
  if (fg[fg_carboxylic_acid_amidine - 1]) {
15862
    }
14362
    sprintf (tmp_buf, "C3N2H000;");
15863
  if (fg[fg_aryl_iodide - 1])
14363
    strcat (out_buffer, tmp_buf);
15864
    {
14364
  }
15865
      sprintf (tmp_buf, "XI00A000;");
14365
  if (fg[fg_carboxylic_acid_amidrazone - 1]) {
15866
      strcat (out_buffer, tmp_buf);
14366
    sprintf (tmp_buf, "C3NNN100;");
15867
    }
14367
    strcat (out_buffer, tmp_buf);
15868
  if (fg[fg_organometallic - 1])
14368
  }
15869
    {
14369
  if (fg[fg_nitrile - 1]) {
15870
      sprintf (tmp_buf, "000000MX;");
14370
    sprintf (tmp_buf, "C3N00000;");
15871
      strcat (out_buffer, tmp_buf);
14371
    strcat (out_buffer, tmp_buf);
15872
    }
14372
  }
15873
  if (fg[fg_organolithium - 1])
14373
 
15874
    {
14374
  if (fg[fg_acyl_fluoride - 1]) {
15875
      sprintf (tmp_buf, "000000ML;");
14375
    sprintf (tmp_buf, "C3OXF000;");
15876
      strcat (out_buffer, tmp_buf);
14376
    strcat (out_buffer, tmp_buf);
15877
    }
14377
  }
15878
  if (fg[fg_organomagnesium - 1])
14378
  if (fg[fg_acyl_chloride - 1]) {
15879
    {
14379
    sprintf (tmp_buf, "C3OXC000;");
15880
      sprintf (tmp_buf, "000000MM;");
14380
    strcat (out_buffer, tmp_buf);
15881
      strcat (out_buffer, tmp_buf);
14381
  }
15882
    }
14382
  if (fg[fg_acyl_bromide - 1]) {
15883
 
14383
    sprintf (tmp_buf, "C3OXB000;");
15884
  if (fg[fg_carboxylic_acid - 1])
14384
    strcat (out_buffer, tmp_buf);
15885
    {
14385
  }
15886
      sprintf (tmp_buf, "C3O2H000;");
14386
  if (fg[fg_acyl_iodide - 1]) {
15887
      strcat (out_buffer, tmp_buf);
14387
    sprintf (tmp_buf, "C3OXI000;");
15888
    }
14388
    strcat (out_buffer, tmp_buf);
15889
  if (fg[fg_carboxylic_acid_salt - 1])
14389
  }
15890
    {
14390
  if (fg[fg_acyl_cyanide - 1]) {
15891
      sprintf (tmp_buf, "C3O200T1;");
14391
    sprintf (tmp_buf, "C2OC3N00;");
15892
      strcat (out_buffer, tmp_buf);
14392
    strcat (out_buffer, tmp_buf);
15893
    }
14393
  }
15894
  if (fg[fg_carboxylic_acid_ester - 1])
14394
  if (fg[fg_imido_ester - 1]) {
15895
    {
14395
    sprintf (tmp_buf, "C3NOC000;");
15896
      sprintf (tmp_buf, "C3O2C000;");
14396
    strcat (out_buffer, tmp_buf);
15897
      strcat (out_buffer, tmp_buf);
14397
  }
15898
    }
14398
  if (fg[fg_imidoyl_halide - 1]) {
15899
  if (fg[fg_lactone - 1])
14399
    sprintf (tmp_buf, "C3NXX000;");
15900
    {
14400
    strcat (out_buffer, tmp_buf);
15901
      sprintf (tmp_buf, "C3O2CZ00;");
14401
  }
15902
      strcat (out_buffer, tmp_buf);
14402
 
15903
    }
14403
  if (fg[fg_thiocarboxylic_acid - 1]) {
15904
 
14404
    sprintf (tmp_buf, "C3SOH000;");
15905
  if (fg[fg_carboxylic_acid_prim_amide - 1])
14405
    strcat (out_buffer, tmp_buf);
15906
    {
14406
  }
15907
      sprintf (tmp_buf, "C3ONC100;");
14407
  if (fg[fg_thiocarboxylic_acid_ester - 1]) {
15908
      strcat (out_buffer, tmp_buf);
14408
    sprintf (tmp_buf, "C3SOC000;");
15909
    }
14409
    strcat (out_buffer, tmp_buf);
15910
  if (fg[fg_carboxylic_acid_sec_amide - 1])
14410
  }
15911
    {
14411
  if (fg[fg_thiolactone - 1]) {
15912
      sprintf (tmp_buf, "C3ONC200;");
14412
    sprintf (tmp_buf, "C3SOCZ00;");
15913
      strcat (out_buffer, tmp_buf);
14413
    strcat (out_buffer, tmp_buf);
15914
    }
14414
  }
15915
  if (fg[fg_carboxylic_acid_tert_amide - 1])
14415
  if (fg[fg_thiocarboxylic_acid_amide - 1]) {
15916
    {
14416
    sprintf (tmp_buf, "C3SNH000;");
15917
      sprintf (tmp_buf, "C3ONC300;");
14417
    strcat (out_buffer, tmp_buf);
15918
      strcat (out_buffer, tmp_buf);
14418
  }
15919
    }
14419
  if (fg[fg_thiolactam - 1]) {
15920
  if (fg[fg_lactam - 1])
14420
    sprintf (tmp_buf, "C3SNCZ00;");
15921
    {
14421
    strcat (out_buffer, tmp_buf);
15922
      sprintf (tmp_buf, "C3ONCZ00;");
14422
  }
15923
      strcat (out_buffer, tmp_buf);
14423
  if (fg[fg_imido_thioester - 1]) {
15924
    }
14424
    sprintf (tmp_buf, "C3NSC000;");
15925
  if (fg[fg_carboxylic_acid_hydrazide - 1])
14425
    strcat (out_buffer, tmp_buf);
15926
    {
14426
  }
15927
      sprintf (tmp_buf, "C3ONN100;");
14427
  if (fg[fg_oxohetarene - 1]) {
15928
      strcat (out_buffer, tmp_buf);
14428
    sprintf (tmp_buf, "C3ONAZ00;");
15929
    }
14429
    strcat (out_buffer, tmp_buf);
15930
  if (fg[fg_carboxylic_acid_azide - 1])
14430
  }
15931
    {
14431
  if (fg[fg_thioxohetarene - 1]) {
15932
      sprintf (tmp_buf, "C3ONN200;");
14432
    sprintf (tmp_buf, "C3SNAZ00;");
15933
      strcat (out_buffer, tmp_buf);
14433
    strcat (out_buffer, tmp_buf);
15934
    }
14434
  }
15935
  if (fg[fg_hydroxamic_acid - 1])
14435
  if (fg[fg_iminohetarene - 1]) {
15936
    {
14436
    sprintf (tmp_buf, "C3NNAZ00;");
15937
      sprintf (tmp_buf, "C3ONOH00;");
14437
    strcat (out_buffer, tmp_buf);
15938
      strcat (out_buffer, tmp_buf);
14438
  }
15939
    }
14439
  if (fg[fg_orthocarboxylic_acid_deriv - 1]) {
15940
  if (fg[fg_carboxylic_acid_amidine - 1])
14440
    sprintf (tmp_buf, "C3O30000;");
15941
    {
14441
    strcat (out_buffer, tmp_buf);
15942
      sprintf (tmp_buf, "C3N2H000;");
14442
  }
15943
      strcat (out_buffer, tmp_buf);
14443
  if (fg[fg_carboxylic_acid_orthoester - 1]) {
15944
    }
14444
    sprintf (tmp_buf, "C3O3C000;");
15945
  if (fg[fg_carboxylic_acid_amidrazone - 1])
14445
    strcat (out_buffer, tmp_buf);
15946
    {
14446
  }
15947
      sprintf (tmp_buf, "C3NNN100;");
14447
  if (fg[fg_carboxylic_acid_amide_acetal - 1]) {
15948
      strcat (out_buffer, tmp_buf);
14448
    sprintf (tmp_buf, "C3O3NC00;");
15949
    }
14449
    strcat (out_buffer, tmp_buf);
15950
  if (fg[fg_nitrile - 1])
14450
  }
15951
    {
14451
  if (fg[fg_carboxylic_acid_anhydride - 1]) {
15952
      sprintf (tmp_buf, "C3N00000;");
14452
    sprintf (tmp_buf, "C3O2C3O2;");
15953
      strcat (out_buffer, tmp_buf);
14453
    strcat (out_buffer, tmp_buf);
15954
    }
14454
  }
15955
 
-
 
15956
  if (fg[fg_acyl_fluoride - 1])
-
 
15957
    {
-
 
15958
      sprintf (tmp_buf, "C3OXF000;");
-
 
15959
      strcat (out_buffer, tmp_buf);
-
 
15960
    }
-
 
15961
  if (fg[fg_acyl_chloride - 1])
-
 
15962
    {
-
 
15963
      sprintf (tmp_buf, "C3OXC000;");
-
 
15964
      strcat (out_buffer, tmp_buf);
-
 
15965
    }
-
 
15966
  if (fg[fg_acyl_bromide - 1])
-
 
15967
    {
-
 
15968
      sprintf (tmp_buf, "C3OXB000;");
-
 
15969
      strcat (out_buffer, tmp_buf);
-
 
15970
    }
-
 
15971
  if (fg[fg_acyl_iodide - 1])
-
 
15972
    {
-
 
15973
      sprintf (tmp_buf, "C3OXI000;");
-
 
15974
      strcat (out_buffer, tmp_buf);
-
 
15975
    }
-
 
15976
  if (fg[fg_acyl_cyanide - 1])
-
 
15977
    {
-
 
15978
      sprintf (tmp_buf, "C2OC3N00;");
-
 
15979
      strcat (out_buffer, tmp_buf);
-
 
15980
    }
-
 
15981
  if (fg[fg_imido_ester - 1])
-
 
15982
    {
-
 
15983
      sprintf (tmp_buf, "C3NOC000;");
-
 
15984
      strcat (out_buffer, tmp_buf);
-
 
15985
    }
-
 
15986
  if (fg[fg_imidoyl_halide - 1])
-
 
15987
    {
-
 
15988
      sprintf (tmp_buf, "C3NXX000;");
-
 
15989
      strcat (out_buffer, tmp_buf);
-
 
15990
    }
-
 
15991
 
-
 
15992
  if (fg[fg_thiocarboxylic_acid - 1])
-
 
15993
    {
-
 
15994
      sprintf (tmp_buf, "C3SOH000;");
-
 
15995
      strcat (out_buffer, tmp_buf);
-
 
15996
    }
-
 
15997
  if (fg[fg_thiocarboxylic_acid_ester - 1])
-
 
15998
    {
-
 
15999
      sprintf (tmp_buf, "C3SOC000;");
-
 
16000
      strcat (out_buffer, tmp_buf);
-
 
16001
    }
-
 
16002
  if (fg[fg_thiolactone - 1])
-
 
16003
    {
-
 
16004
      sprintf (tmp_buf, "C3SOCZ00;");
-
 
16005
      strcat (out_buffer, tmp_buf);
-
 
16006
    }
-
 
16007
  if (fg[fg_thiocarboxylic_acid_amide - 1])
-
 
16008
    {
-
 
16009
      sprintf (tmp_buf, "C3SNH000;");
-
 
16010
      strcat (out_buffer, tmp_buf);
-
 
16011
    }
-
 
16012
  if (fg[fg_thiolactam - 1])
-
 
16013
    {
-
 
16014
      sprintf (tmp_buf, "C3SNCZ00;");
-
 
16015
      strcat (out_buffer, tmp_buf);
-
 
16016
    }
-
 
16017
  if (fg[fg_imido_thioester - 1])
-
 
16018
    {
-
 
16019
      sprintf (tmp_buf, "C3NSC000;");
-
 
16020
      strcat (out_buffer, tmp_buf);
-
 
16021
    }
-
 
16022
  if (fg[fg_oxohetarene - 1])
-
 
16023
    {
-
 
16024
      sprintf (tmp_buf, "C3ONAZ00;");
-
 
16025
      strcat (out_buffer, tmp_buf);
-
 
16026
    }
-
 
16027
  if (fg[fg_thioxohetarene - 1])
-
 
16028
    {
-
 
16029
      sprintf (tmp_buf, "C3SNAZ00;");
-
 
16030
      strcat (out_buffer, tmp_buf);
-
 
16031
    }
-
 
16032
  if (fg[fg_iminohetarene - 1])
-
 
16033
    {
-
 
16034
      sprintf (tmp_buf, "C3NNAZ00;");
-
 
16035
      strcat (out_buffer, tmp_buf);
-
 
16036
    }
-
 
16037
  if (fg[fg_orthocarboxylic_acid_deriv - 1])
-
 
16038
    {
-
 
16039
      sprintf (tmp_buf, "C3O30000;");
-
 
16040
      strcat (out_buffer, tmp_buf);
-
 
16041
    }
-
 
16042
  if (fg[fg_carboxylic_acid_orthoester - 1])
-
 
16043
    {
-
 
16044
      sprintf (tmp_buf, "C3O3C000;");
-
 
16045
      strcat (out_buffer, tmp_buf);
-
 
16046
    }
-
 
16047
  if (fg[fg_carboxylic_acid_amide_acetal - 1])
-
 
16048
    {
-
 
16049
      sprintf (tmp_buf, "C3O3NC00;");
-
 
16050
      strcat (out_buffer, tmp_buf);
-
 
16051
    }
-
 
16052
  if (fg[fg_carboxylic_acid_anhydride - 1])
-
 
16053
    {
-
 
16054
      sprintf (tmp_buf, "C3O2C3O2;");
-
 
16055
      strcat (out_buffer, tmp_buf);
-
 
16056
    }
-
 
16057
 
14455
 
16058
  if (fg[fg_carboxylic_acid_unsubst_imide - 1])
14456
  if (fg[fg_carboxylic_acid_unsubst_imide - 1]) {
16059
    {
14457
    sprintf (tmp_buf, "C3ONCH10;");
16060
      sprintf (tmp_buf, "C3ONCH10;");
14458
    strcat (out_buffer, tmp_buf);
16061
      strcat (out_buffer, tmp_buf);
14459
  }
16062
    }
14460
  if (fg[fg_carboxylic_acid_subst_imide - 1]) {
16063
  if (fg[fg_carboxylic_acid_subst_imide - 1])
14461
    sprintf (tmp_buf, "C3ONCC10;");
16064
    {
14462
    strcat (out_buffer, tmp_buf);
16065
      sprintf (tmp_buf, "C3ONCC10;");
14463
  }
16066
      strcat (out_buffer, tmp_buf);
14464
  if (fg[fg_co2_deriv - 1]) {
16067
    }
14465
    sprintf (tmp_buf, "C4000000;");
16068
  if (fg[fg_co2_deriv - 1])
14466
    strcat (out_buffer, tmp_buf);
16069
    {
14467
  }
16070
      sprintf (tmp_buf, "C4000000;");
14468
  if (fg[fg_carbonic_acid_deriv - 1]) {
16071
      strcat (out_buffer, tmp_buf);
14469
    sprintf (tmp_buf, "C4O30000;");
16072
    }
14470
    strcat (out_buffer, tmp_buf);
16073
  if (fg[fg_carbonic_acid_deriv - 1])
14471
  }
16074
    {
14472
  if (fg[fg_carbonic_acid_monoester - 1]) {
16075
      sprintf (tmp_buf, "C4O30000;");
14473
    sprintf (tmp_buf, "C4O3C100;");
16076
      strcat (out_buffer, tmp_buf);
14474
    strcat (out_buffer, tmp_buf);
16077
    }
14475
  }
16078
  if (fg[fg_carbonic_acid_monoester - 1])
14476
  if (fg[fg_carbonic_acid_diester - 1]) {
16079
    {
14477
    sprintf (tmp_buf, "C4O3C200;");
16080
      sprintf (tmp_buf, "C4O3C100;");
14478
    strcat (out_buffer, tmp_buf);
16081
      strcat (out_buffer, tmp_buf);
14479
  }
16082
    }
14480
  if (fg[fg_carbonic_acid_ester_halide - 1]) {
16083
  if (fg[fg_carbonic_acid_diester - 1])
14481
    sprintf (tmp_buf, "C4O3CX00;");
16084
    {
14482
    strcat (out_buffer, tmp_buf);
16085
      sprintf (tmp_buf, "C4O3C200;");
14483
  }
16086
      strcat (out_buffer, tmp_buf);
14484
  if (fg[fg_thiocarbonic_acid_deriv - 1]) {
16087
    }
14485
    sprintf (tmp_buf, "C4SO0000;");
16088
  if (fg[fg_carbonic_acid_ester_halide - 1])
14486
    strcat (out_buffer, tmp_buf);
16089
    {
14487
  }
16090
      sprintf (tmp_buf, "C4O3CX00;");
14488
  if (fg[fg_thiocarbonic_acid_monoester - 1]) {
16091
      strcat (out_buffer, tmp_buf);
14489
    sprintf (tmp_buf, "C4SOC100;");
16092
    }
14490
    strcat (out_buffer, tmp_buf);
16093
  if (fg[fg_thiocarbonic_acid_deriv - 1])
14491
  }
16094
    {
14492
  if (fg[fg_thiocarbonic_acid_diester - 1]) {
16095
      sprintf (tmp_buf, "C4SO0000;");
14493
    sprintf (tmp_buf, "C4SOC200;");
16096
      strcat (out_buffer, tmp_buf);
14494
    strcat (out_buffer, tmp_buf);
16097
    }
14495
  }
16098
  if (fg[fg_thiocarbonic_acid_monoester - 1])
14496
  if (fg[fg_thiocarbonic_acid_ester_halide - 1]) {
16099
    {
14497
    sprintf (tmp_buf, "C4SOX_00;");
16100
      sprintf (tmp_buf, "C4SOC100;");
14498
    strcat (out_buffer, tmp_buf);
16101
      strcat (out_buffer, tmp_buf);
14499
  }
16102
    }
14500
  if (fg[fg_carbamic_acid_deriv - 1]) {
16103
  if (fg[fg_thiocarbonic_acid_diester - 1])
14501
    sprintf (tmp_buf, "C4O2N000;");
16104
    {
14502
    strcat (out_buffer, tmp_buf);
16105
      sprintf (tmp_buf, "C4SOC200;");
14503
  }
16106
      strcat (out_buffer, tmp_buf);
14504
  if (fg[fg_carbamic_acid - 1]) {
16107
    }
14505
    sprintf (tmp_buf, "C4O2NH00;");
16108
  if (fg[fg_thiocarbonic_acid_ester_halide - 1])
14506
    strcat (out_buffer, tmp_buf);
16109
    {
14507
  }
16110
      sprintf (tmp_buf, "C4SOX_00;");
14508
  if (fg[fg_carbamic_acid_ester - 1]) {
16111
      strcat (out_buffer, tmp_buf);
14509
    sprintf (tmp_buf, "C4O2NC00;");
16112
    }
14510
    strcat (out_buffer, tmp_buf);
16113
  if (fg[fg_carbamic_acid_deriv - 1])
14511
  }
16114
    {
14512
  if (fg[fg_carbamic_acid_halide - 1]) {
16115
      sprintf (tmp_buf, "C4O2N000;");
14513
    sprintf (tmp_buf, "C4O2NX00;");
16116
      strcat (out_buffer, tmp_buf);
14514
    strcat (out_buffer, tmp_buf);
16117
    }
14515
  }
16118
  if (fg[fg_carbamic_acid - 1])
14516
  if (fg[fg_thiocarbamic_acid_deriv - 1]) {
16119
    {
14517
    sprintf (tmp_buf, "C4SN0000;");
16120
      sprintf (tmp_buf, "C4O2NH00;");
14518
    strcat (out_buffer, tmp_buf);
16121
      strcat (out_buffer, tmp_buf);
14519
  }
16122
    }
14520
  if (fg[fg_thiocarbamic_acid - 1]) {
16123
  if (fg[fg_carbamic_acid_ester - 1])
14521
    sprintf (tmp_buf, "C4SNOH00;");
16124
    {
14522
    strcat (out_buffer, tmp_buf);
16125
      sprintf (tmp_buf, "C4O2NC00;");
14523
  }
16126
      strcat (out_buffer, tmp_buf);
14524
  if (fg[fg_thiocarbamic_acid_ester - 1]) {
16127
    }
14525
    sprintf (tmp_buf, "C4SNOC00;");
16128
  if (fg[fg_carbamic_acid_halide - 1])
14526
    strcat (out_buffer, tmp_buf);
16129
    {
14527
  }
16130
      sprintf (tmp_buf, "C4O2NX00;");
14528
  if (fg[fg_thiocarbamic_acid_halide - 1]) {
16131
      strcat (out_buffer, tmp_buf);
14529
    sprintf (tmp_buf, "C4SNXX00;");
16132
    }
14530
    strcat (out_buffer, tmp_buf);
16133
  if (fg[fg_thiocarbamic_acid_deriv - 1])
14531
  }
16134
    {
14532
  if (fg[fg_urea - 1]) {
16135
      sprintf (tmp_buf, "C4SN0000;");
14533
    sprintf (tmp_buf, "C4O1N200;");
16136
      strcat (out_buffer, tmp_buf);
14534
    strcat (out_buffer, tmp_buf);
16137
    }
14535
  }
16138
  if (fg[fg_thiocarbamic_acid - 1])
14536
  if (fg[fg_isourea - 1]) {
16139
    {
14537
    sprintf (tmp_buf, "C4N2O100;");
16140
      sprintf (tmp_buf, "C4SNOH00;");
14538
    strcat (out_buffer, tmp_buf);
16141
      strcat (out_buffer, tmp_buf);
14539
  }
16142
    }
14540
  if (fg[fg_thiourea - 1]) {
16143
  if (fg[fg_thiocarbamic_acid_ester - 1])
14541
    sprintf (tmp_buf, "C4S1N200;");
16144
    {
14542
    strcat (out_buffer, tmp_buf);
16145
      sprintf (tmp_buf, "C4SNOC00;");
14543
  }
16146
      strcat (out_buffer, tmp_buf);
14544
  if (fg[fg_isothiourea - 1]) {
16147
    }
14545
    sprintf (tmp_buf, "C4N2S100;");
16148
  if (fg[fg_thiocarbamic_acid_halide - 1])
14546
    strcat (out_buffer, tmp_buf);
16149
    {
14547
  }
16150
      sprintf (tmp_buf, "C4SNXX00;");
14548
  if (fg[fg_guanidine - 1]) {
16151
      strcat (out_buffer, tmp_buf);
14549
    sprintf (tmp_buf, "C4N30000;");
16152
    }
14550
    strcat (out_buffer, tmp_buf);
16153
  if (fg[fg_urea - 1])
14551
  }
16154
    {
14552
  if (fg[fg_semicarbazide - 1]) {
16155
      sprintf (tmp_buf, "C4O1N200;");
14553
    sprintf (tmp_buf, "C4ON2N00;");
16156
      strcat (out_buffer, tmp_buf);
14554
    strcat (out_buffer, tmp_buf);
16157
    }
14555
  }
16158
  if (fg[fg_isourea - 1])
14556
  if (fg[fg_thiosemicarbazide - 1]) {
16159
    {
14557
    sprintf (tmp_buf, "C4SN2N00;");
16160
      sprintf (tmp_buf, "C4N2O100;");
14558
    strcat (out_buffer, tmp_buf);
16161
      strcat (out_buffer, tmp_buf);
14559
  }
16162
    }
14560
  if (fg[fg_azide - 1]) {
16163
  if (fg[fg_thiourea - 1])
14561
    sprintf (tmp_buf, "N4N20000;");
16164
    {
14562
    strcat (out_buffer, tmp_buf);
16165
      sprintf (tmp_buf, "C4S1N200;");
14563
  }
16166
      strcat (out_buffer, tmp_buf);
14564
  if (fg[fg_azo_compound - 1]) {
16167
    }
14565
    sprintf (tmp_buf, "N2N10000;");
16168
  if (fg[fg_isothiourea - 1])
14566
    strcat (out_buffer, tmp_buf);
16169
    {
14567
  }
16170
      sprintf (tmp_buf, "C4N2S100;");
14568
  if (fg[fg_diazonium_salt - 1]) {
16171
      strcat (out_buffer, tmp_buf);
14569
    sprintf (tmp_buf, "N3N100T2;");
16172
    }
14570
    strcat (out_buffer, tmp_buf);
16173
  if (fg[fg_guanidine - 1])
14571
  }
16174
    {
14572
  if (fg[fg_isonitrile - 1]) {
16175
      sprintf (tmp_buf, "C4N30000;");
14573
    sprintf (tmp_buf, "N3C10000;");
16176
      strcat (out_buffer, tmp_buf);
14574
    strcat (out_buffer, tmp_buf);
16177
    }
14575
  }
16178
  if (fg[fg_semicarbazide - 1])
14576
  if (fg[fg_cyanate - 1]) {
16179
    {
14577
    sprintf (tmp_buf, "C4NO1000;");
16180
      sprintf (tmp_buf, "C4ON2N00;");
14578
    strcat (out_buffer, tmp_buf);
16181
      strcat (out_buffer, tmp_buf);
14579
  }
16182
    }
14580
  if (fg[fg_isocyanate - 1]) {
16183
  if (fg[fg_thiosemicarbazide - 1])
14581
    sprintf (tmp_buf, "C4NO2000;");
16184
    {
14582
    strcat (out_buffer, tmp_buf);
16185
      sprintf (tmp_buf, "C4SN2N00;");
14583
  }
16186
      strcat (out_buffer, tmp_buf);
14584
  if (fg[fg_thiocyanate - 1]) {
16187
    }
14585
    sprintf (tmp_buf, "C4NS1000;");
16188
  if (fg[fg_azide - 1])
14586
    strcat (out_buffer, tmp_buf);
16189
    {
14587
  }
16190
      sprintf (tmp_buf, "N4N20000;");
14588
  if (fg[fg_isothiocyanate - 1]) {
16191
      strcat (out_buffer, tmp_buf);
14589
    sprintf (tmp_buf, "C4NS2000;");
16192
    }
14590
    strcat (out_buffer, tmp_buf);
16193
  if (fg[fg_azo_compound - 1])
14591
  }
16194
    {
14592
  if (fg[fg_carbodiimide - 1]) {
16195
      sprintf (tmp_buf, "N2N10000;");
14593
    sprintf (tmp_buf, "C4N20000;");
16196
      strcat (out_buffer, tmp_buf);
14594
    strcat (out_buffer, tmp_buf);
16197
    }
14595
  }
16198
  if (fg[fg_diazonium_salt - 1])
14596
  if (fg[fg_nitroso_compound - 1]) {
16199
    {
14597
    sprintf (tmp_buf, "N2O10000;");
16200
      sprintf (tmp_buf, "N3N100T2;");
14598
    strcat (out_buffer, tmp_buf);
16201
      strcat (out_buffer, tmp_buf);
14599
  }
16202
    }
14600
  if (fg[fg_nitro_compound - 1]) {
16203
  if (fg[fg_isonitrile - 1])
14601
    sprintf (tmp_buf, "N4O20000;");
16204
    {
14602
    strcat (out_buffer, tmp_buf);
16205
      sprintf (tmp_buf, "N3C10000;");
14603
  }
16206
      strcat (out_buffer, tmp_buf);
14604
  if (fg[fg_nitrite - 1]) {
16207
    }
14605
    sprintf (tmp_buf, "N3O20000;");
16208
  if (fg[fg_cyanate - 1])
14606
    strcat (out_buffer, tmp_buf);
16209
    {
14607
  }
16210
      sprintf (tmp_buf, "C4NO1000;");
14608
  if (fg[fg_nitrate - 1]) {
16211
      strcat (out_buffer, tmp_buf);
14609
    sprintf (tmp_buf, "N4O30000;");
16212
    }
14610
    strcat (out_buffer, tmp_buf);
16213
  if (fg[fg_isocyanate - 1])
14611
  }
16214
    {
14612
  if (fg[fg_sulfuric_acid_deriv - 1]) {
16215
      sprintf (tmp_buf, "C4NO2000;");
14613
    sprintf (tmp_buf, "S6O00000;");
16216
      strcat (out_buffer, tmp_buf);
14614
    strcat (out_buffer, tmp_buf);
16217
    }
14615
  }
16218
  if (fg[fg_thiocyanate - 1])
14616
  if (fg[fg_sulfuric_acid - 1]) {
16219
    {
14617
    sprintf (tmp_buf, "S6O4H000;");
16220
      sprintf (tmp_buf, "C4NS1000;");
14618
    strcat (out_buffer, tmp_buf);
16221
      strcat (out_buffer, tmp_buf);
14619
  }
16222
    }
14620
  if (fg[fg_sulfuric_acid_monoester - 1]) {
16223
  if (fg[fg_isothiocyanate - 1])
14621
    sprintf (tmp_buf, "S6O4HC00;");
16224
    {
14622
    strcat (out_buffer, tmp_buf);
16225
      sprintf (tmp_buf, "C4NS2000;");
14623
  }
16226
      strcat (out_buffer, tmp_buf);
14624
  if (fg[fg_sulfuric_acid_diester - 1]) {
16227
    }
14625
    sprintf (tmp_buf, "S6O4CC00;");
16228
  if (fg[fg_carbodiimide - 1])
14626
    strcat (out_buffer, tmp_buf);
16229
    {
14627
  }
16230
      sprintf (tmp_buf, "C4N20000;");
14628
  if (fg[fg_sulfuric_acid_amide_ester - 1]) {
16231
      strcat (out_buffer, tmp_buf);
14629
    sprintf (tmp_buf, "S6O3NC00;");
16232
    }
14630
    strcat (out_buffer, tmp_buf);
16233
  if (fg[fg_nitroso_compound - 1])
14631
  }
16234
    {
14632
  if (fg[fg_sulfuric_acid_amide - 1]) {
16235
      sprintf (tmp_buf, "N2O10000;");
14633
    sprintf (tmp_buf, "S6O3N100;");
16236
      strcat (out_buffer, tmp_buf);
14634
    strcat (out_buffer, tmp_buf);
16237
    }
14635
  }
16238
  if (fg[fg_nitro_compound - 1])
14636
  if (fg[fg_sulfuric_acid_diamide - 1]) {
16239
    {
14637
    sprintf (tmp_buf, "S6O2N200;");
16240
      sprintf (tmp_buf, "N4O20000;");
14638
    strcat (out_buffer, tmp_buf);
16241
      strcat (out_buffer, tmp_buf);
14639
  }
16242
    }
14640
  if (fg[fg_sulfuryl_halide - 1]) {
16243
  if (fg[fg_nitrite - 1])
14641
    sprintf (tmp_buf, "S6O3XX00;");
16244
    {
14642
    strcat (out_buffer, tmp_buf);
16245
      sprintf (tmp_buf, "N3O20000;");
14643
  }
16246
      strcat (out_buffer, tmp_buf);
14644
  if (fg[fg_sulfonic_acid_deriv - 1]) {
16247
    }
14645
    sprintf (tmp_buf, "S5O00000;");
16248
  if (fg[fg_nitrate - 1])
14646
    strcat (out_buffer, tmp_buf);
16249
    {
14647
  }
16250
      sprintf (tmp_buf, "N4O30000;");
14648
  if (fg[fg_sulfonic_acid - 1]) {
16251
      strcat (out_buffer, tmp_buf);
14649
    sprintf (tmp_buf, "S5O3H000;");
16252
    }
14650
    strcat (out_buffer, tmp_buf);
16253
  if (fg[fg_sulfuric_acid_deriv - 1])
14651
  }
16254
    {
14652
  if (fg[fg_sulfonic_acid_ester - 1]) {
16255
      sprintf (tmp_buf, "S6O00000;");
14653
    sprintf (tmp_buf, "S5O3C000;");
16256
      strcat (out_buffer, tmp_buf);
14654
    strcat (out_buffer, tmp_buf);
16257
    }
14655
  }
16258
  if (fg[fg_sulfuric_acid - 1])
14656
  if (fg[fg_sulfonamide - 1]) {
16259
    {
14657
    sprintf (tmp_buf, "S5O2N000;");
16260
      sprintf (tmp_buf, "S6O4H000;");
14658
    strcat (out_buffer, tmp_buf);
16261
      strcat (out_buffer, tmp_buf);
14659
  }
16262
    }
14660
  if (fg[fg_sulfonyl_halide - 1]) {
16263
  if (fg[fg_sulfuric_acid_monoester - 1])
14661
    sprintf (tmp_buf, "S5O2XX00;");
16264
    {
14662
    strcat (out_buffer, tmp_buf);
16265
      sprintf (tmp_buf, "S6O4HC00;");
14663
  }
16266
      strcat (out_buffer, tmp_buf);
14664
  if (fg[fg_sulfone - 1]) {
16267
    }
14665
    sprintf (tmp_buf, "S4O20000;");
16268
  if (fg[fg_sulfuric_acid_diester - 1])
14666
    strcat (out_buffer, tmp_buf);
16269
    {
14667
  }
16270
      sprintf (tmp_buf, "S6O4CC00;");
14668
  if (fg[fg_sulfoxide - 1]) {
16271
      strcat (out_buffer, tmp_buf);
14669
    sprintf (tmp_buf, "S2O10000;");
16272
    }
14670
    strcat (out_buffer, tmp_buf);
16273
  if (fg[fg_sulfuric_acid_amide_ester - 1])
14671
  }
16274
    {
14672
  if (fg[fg_sulfinic_acid_deriv - 1]) {
16275
      sprintf (tmp_buf, "S6O3NC00;");
14673
    sprintf (tmp_buf, "S3O00000;");
16276
      strcat (out_buffer, tmp_buf);
14674
    strcat (out_buffer, tmp_buf);
16277
    }
14675
  }
16278
  if (fg[fg_sulfuric_acid_amide - 1])
14676
  if (fg[fg_sulfinic_acid - 1]) {
16279
    {
14677
    sprintf (tmp_buf, "S3O2H000;");
16280
      sprintf (tmp_buf, "S6O3N100;");
14678
    strcat (out_buffer, tmp_buf);
16281
      strcat (out_buffer, tmp_buf);
14679
  }
16282
    }
14680
  if (fg[fg_sulfinic_acid_ester - 1]) {
16283
  if (fg[fg_sulfuric_acid_diamide - 1])
14681
    sprintf (tmp_buf, "S3O2C000;");
16284
    {
14682
    strcat (out_buffer, tmp_buf);
16285
      sprintf (tmp_buf, "S6O2N200;");
14683
  }
16286
      strcat (out_buffer, tmp_buf);
14684
  if (fg[fg_sulfinic_acid_halide - 1]) {
16287
    }
14685
    sprintf (tmp_buf, "S3O1XX00;");
16288
  if (fg[fg_sulfuryl_halide - 1])
14686
    strcat (out_buffer, tmp_buf);
16289
    {
14687
  }
16290
      sprintf (tmp_buf, "S6O3XX00;");
14688
  if (fg[fg_sulfinic_acid_amide - 1]) {
16291
      strcat (out_buffer, tmp_buf);
-
 
16292
    }
-
 
16293
  if (fg[fg_sulfonic_acid_deriv - 1])
-
 
16294
    {
-
 
16295
      sprintf (tmp_buf, "S5O00000;");
-
 
16296
      strcat (out_buffer, tmp_buf);
-
 
16297
    }
-
 
16298
  if (fg[fg_sulfonic_acid - 1])
-
 
16299
    {
-
 
16300
      sprintf (tmp_buf, "S5O3H000;");
-
 
16301
      strcat (out_buffer, tmp_buf);
-
 
16302
    }
-
 
16303
  if (fg[fg_sulfonic_acid_ester - 1])
-
 
16304
    {
-
 
16305
      sprintf (tmp_buf, "S5O3C000;");
-
 
16306
      strcat (out_buffer, tmp_buf);
-
 
16307
    }
-
 
16308
  if (fg[fg_sulfonamide - 1])
-
 
16309
    {
-
 
16310
      sprintf (tmp_buf, "S5O2N000;");
-
 
16311
      strcat (out_buffer, tmp_buf);
-
 
16312
    }
-
 
16313
  if (fg[fg_sulfonyl_halide - 1])
-
 
16314
    {
-
 
16315
      sprintf (tmp_buf, "S5O2XX00;");
-
 
16316
      strcat (out_buffer, tmp_buf);
-
 
16317
    }
-
 
16318
  if (fg[fg_sulfone - 1])
-
 
16319
    {
-
 
16320
      sprintf (tmp_buf, "S4O20000;");
-
 
16321
      strcat (out_buffer, tmp_buf);
-
 
16322
    }
-
 
16323
  if (fg[fg_sulfoxide - 1])
-
 
16324
    {
-
 
16325
      sprintf (tmp_buf, "S2O10000;");
-
 
16326
      strcat (out_buffer, tmp_buf);
-
 
16327
    }
-
 
16328
  if (fg[fg_sulfinic_acid_deriv - 1])
-
 
16329
    {
-
 
16330
      sprintf (tmp_buf, "S3O00000;");
-
 
16331
      strcat (out_buffer, tmp_buf);
-
 
16332
    }
-
 
16333
  if (fg[fg_sulfinic_acid - 1])
-
 
16334
    {
-
 
16335
      sprintf (tmp_buf, "S3O2H000;");
-
 
16336
      strcat (out_buffer, tmp_buf);
-
 
16337
    }
-
 
16338
  if (fg[fg_sulfinic_acid_ester - 1])
-
 
16339
    {
-
 
16340
      sprintf (tmp_buf, "S3O2C000;");
-
 
16341
      strcat (out_buffer, tmp_buf);
-
 
16342
    }
-
 
16343
  if (fg[fg_sulfinic_acid_halide - 1])
-
 
16344
    {
-
 
16345
      sprintf (tmp_buf, "S3O1XX00;");
-
 
16346
      strcat (out_buffer, tmp_buf);
-
 
16347
    }
-
 
16348
  if (fg[fg_sulfinic_acid_amide - 1])
-
 
16349
    {
-
 
16350
      sprintf (tmp_buf, "S3O1N000;");
14689
      sprintf (tmp_buf, "S3O1N000;");
16351
      strcat (out_buffer, tmp_buf);
14690
      strcat (out_buffer, tmp_buf);
16352
    }
14691
    }
16353
  if (fg[fg_sulfenic_acid_deriv - 1])
14692
  if (fg[fg_sulfenic_acid_deriv - 1]) {
16354
    {
14693
    sprintf (tmp_buf, "S1O00000;");
16355
      sprintf (tmp_buf, "S1O00000;");
14694
    strcat (out_buffer, tmp_buf);
16356
      strcat (out_buffer, tmp_buf);
14695
  }
16357
    }
14696
  if (fg[fg_sulfenic_acid - 1]) {
16358
  if (fg[fg_sulfenic_acid - 1])
14697
    sprintf (tmp_buf, "S1O1H000;");
16359
    {
14698
    strcat (out_buffer, tmp_buf);
16360
      sprintf (tmp_buf, "S1O1H000;");
14699
  }
16361
      strcat (out_buffer, tmp_buf);
14700
  if (fg[fg_sulfenic_acid_ester - 1]) {
16362
    }
14701
    sprintf (tmp_buf, "S1O1C000;");
16363
  if (fg[fg_sulfenic_acid_ester - 1])
14702
    strcat (out_buffer, tmp_buf);
16364
    {
14703
  }
16365
      sprintf (tmp_buf, "S1O1C000;");
14704
  if (fg[fg_sulfenic_acid_halide - 1]) {
16366
      strcat (out_buffer, tmp_buf);
14705
    sprintf (tmp_buf, "S1O0XX00;");
16367
    }
14706
    strcat (out_buffer, tmp_buf);
16368
  if (fg[fg_sulfenic_acid_halide - 1])
14707
  }
16369
    {
14708
  if (fg[fg_sulfenic_acid_amide - 1]) {
16370
      sprintf (tmp_buf, "S1O0XX00;");
14709
    sprintf (tmp_buf, "S1O0N100;");
16371
      strcat (out_buffer, tmp_buf);
14710
    strcat (out_buffer, tmp_buf);
16372
    }
14711
  }
16373
  if (fg[fg_sulfenic_acid_amide - 1])
14712
 
16374
    {
14713
  if (fg[fg_alkylthiol - 1]) {
16375
      sprintf (tmp_buf, "S1O0N100;");
14714
    sprintf (tmp_buf, "S1H1C000;");
16376
      strcat (out_buffer, tmp_buf);
14715
    strcat (out_buffer, tmp_buf);
16377
    }
14716
  }
16378
 
14717
  if (fg[fg_arylthiol - 1]) {
16379
  if (fg[fg_alkylthiol - 1])
14718
    sprintf (tmp_buf, "S1H1A000;");
16380
    {
14719
    strcat (out_buffer, tmp_buf);
16381
      sprintf (tmp_buf, "S1H1C000;");
14720
  }
16382
      strcat (out_buffer, tmp_buf);
14721
  if (fg[fg_phosphoric_acid_deriv - 1]) {
16383
    }
14722
    sprintf (tmp_buf, "P5O0H000;");
16384
  if (fg[fg_arylthiol - 1])
14723
    strcat (out_buffer, tmp_buf);
16385
    {
14724
  }
16386
      sprintf (tmp_buf, "S1H1A000;");
14725
  if (fg[fg_phosphoric_acid - 1]) {
16387
      strcat (out_buffer, tmp_buf);
14726
    sprintf (tmp_buf, "P5O4H200;");
16388
    }
14727
    strcat (out_buffer, tmp_buf);
16389
  if (fg[fg_phosphoric_acid_deriv - 1])
14728
  }
16390
    {
14729
  if (fg[fg_phosphoric_acid_ester - 1]) {
16391
      sprintf (tmp_buf, "P5O0H000;");
14730
    sprintf (tmp_buf, "P5O4HC00;");
16392
      strcat (out_buffer, tmp_buf);
14731
    strcat (out_buffer, tmp_buf);
16393
    }
14732
  }
16394
  if (fg[fg_phosphoric_acid - 1])
14733
  if (fg[fg_phosphoric_acid_halide - 1]) {
16395
    {
14734
    sprintf (tmp_buf, "P5O3HX00;");
16396
      sprintf (tmp_buf, "P5O4H200;");
14735
    strcat (out_buffer, tmp_buf);
16397
      strcat (out_buffer, tmp_buf);
14736
  }
16398
    }
14737
  if (fg[fg_phosphoric_acid_amide - 1]) {
16399
  if (fg[fg_phosphoric_acid_ester - 1])
14738
    sprintf (tmp_buf, "P5O3HN00;");
16400
    {
14739
    strcat (out_buffer, tmp_buf);
16401
      sprintf (tmp_buf, "P5O4HC00;");
14740
  }
16402
      strcat (out_buffer, tmp_buf);
14741
  if (fg[fg_thiophosphoric_acid_deriv - 1]) {
16403
    }
14742
    sprintf (tmp_buf, "P5O0S000;");
16404
  if (fg[fg_phosphoric_acid_halide - 1])
14743
    strcat (out_buffer, tmp_buf);
16405
    {
14744
  }
16406
      sprintf (tmp_buf, "P5O3HX00;");
14745
  if (fg[fg_thiophosphoric_acid - 1]) {
16407
      strcat (out_buffer, tmp_buf);
14746
    sprintf (tmp_buf, "P5O3SH00;");
16408
    }
14747
    strcat (out_buffer, tmp_buf);
16409
  if (fg[fg_phosphoric_acid_amide - 1])
14748
  }
16410
    {
14749
  if (fg[fg_thiophosphoric_acid_ester - 1]) {
16411
      sprintf (tmp_buf, "P5O3HN00;");
14750
    sprintf (tmp_buf, "P5O3SC00;");
16412
      strcat (out_buffer, tmp_buf);
14751
    strcat (out_buffer, tmp_buf);
16413
    }
14752
  }
16414
  if (fg[fg_thiophosphoric_acid_deriv - 1])
14753
  if (fg[fg_thiophosphoric_acid_halide - 1]) {
16415
    {
14754
    sprintf (tmp_buf, "P5O2SX00;");
16416
      sprintf (tmp_buf, "P5O0S000;");
14755
    strcat (out_buffer, tmp_buf);
16417
      strcat (out_buffer, tmp_buf);
14756
  }
16418
    }
14757
  if (fg[fg_thiophosphoric_acid_amide - 1]) {
16419
  if (fg[fg_thiophosphoric_acid - 1])
14758
    sprintf (tmp_buf, "P5O2SN00;");
16420
    {
14759
    strcat (out_buffer, tmp_buf);
16421
      sprintf (tmp_buf, "P5O3SH00;");
14760
  }
16422
      strcat (out_buffer, tmp_buf);
14761
  if (fg[fg_phosphonic_acid_deriv - 1]) {
16423
    }
14762
    sprintf (tmp_buf, "P4O30000;");
16424
  if (fg[fg_thiophosphoric_acid_ester - 1])
14763
    strcat (out_buffer, tmp_buf);
16425
    {
14764
  }
16426
      sprintf (tmp_buf, "P5O3SC00;");
14765
  if (fg[fg_phosphonic_acid - 1]) {
16427
      strcat (out_buffer, tmp_buf);
14766
    sprintf (tmp_buf, "P4O3H000;");
16428
    }
14767
    strcat (out_buffer, tmp_buf);
16429
  if (fg[fg_thiophosphoric_acid_halide - 1])
14768
  }
16430
    {
14769
  if (fg[fg_phosphonic_acid_ester - 1]) {
16431
      sprintf (tmp_buf, "P5O2SX00;");
14770
    sprintf (tmp_buf, "P4O3C000;");
16432
      strcat (out_buffer, tmp_buf);
14771
    strcat (out_buffer, tmp_buf);
16433
    }
14772
  }
16434
  if (fg[fg_thiophosphoric_acid_amide - 1])
14773
  if (fg[fg_phosphine - 1]) {
16435
    {
14774
    sprintf (tmp_buf, "P3000000;");
16436
      sprintf (tmp_buf, "P5O2SN00;");
14775
    strcat (out_buffer, tmp_buf);
16437
      strcat (out_buffer, tmp_buf);
14776
  }
16438
    }
14777
  if (fg[fg_phosphinoxide - 1]) {
16439
  if (fg[fg_phosphonic_acid_deriv - 1])
14778
    sprintf (tmp_buf, "P2O00000;");
16440
    {
14779
    strcat (out_buffer, tmp_buf);
16441
      sprintf (tmp_buf, "P4O30000;");
14780
  }
16442
      strcat (out_buffer, tmp_buf);
14781
  if (fg[fg_boronic_acid_deriv - 1]) {
16443
    }
14782
    sprintf (tmp_buf, "B2O20000;");
16444
  if (fg[fg_phosphonic_acid - 1])
14783
    strcat (out_buffer, tmp_buf);
16445
    {
14784
  }
16446
      sprintf (tmp_buf, "P4O3H000;");
14785
  if (fg[fg_boronic_acid - 1]) {
16447
      strcat (out_buffer, tmp_buf);
14786
    sprintf (tmp_buf, "B2O2H000;");
16448
    }
14787
    strcat (out_buffer, tmp_buf);
16449
  if (fg[fg_phosphonic_acid_ester - 1])
14788
  }
16450
    {
14789
  if (fg[fg_boronic_acid_ester - 1]) {
16451
      sprintf (tmp_buf, "P4O3C000;");
14790
    sprintf (tmp_buf, "B2O2C000;");
16452
      strcat (out_buffer, tmp_buf);
14791
    strcat (out_buffer, tmp_buf);
16453
    }
14792
  }
16454
  if (fg[fg_phosphine - 1])
14793
  if (fg[fg_alkene - 1]) {
16455
    {
14794
    sprintf (tmp_buf, "000C2C00;");
16456
      sprintf (tmp_buf, "P3000000;");
14795
    strcat (out_buffer, tmp_buf);
16457
      strcat (out_buffer, tmp_buf);
14796
  }
16458
    }
14797
  if (fg[fg_alkyne - 1]) {
16459
  if (fg[fg_phosphinoxide - 1])
14798
    sprintf (tmp_buf, "000C3C00;");
16460
    {
14799
    strcat (out_buffer, tmp_buf);
16461
      sprintf (tmp_buf, "P2O00000;");
14800
  }
16462
      strcat (out_buffer, tmp_buf);
14801
  if (fg[fg_aromatic - 1]) {
16463
    }
14802
    sprintf (tmp_buf, "0000A000;");
16464
  if (fg[fg_boronic_acid_deriv - 1])
14803
    strcat (out_buffer, tmp_buf);
16465
    {
14804
  }
16466
      sprintf (tmp_buf, "B2O20000;");
14805
  if (fg[fg_heterocycle - 1]) {
16467
      strcat (out_buffer, tmp_buf);
14806
    sprintf (tmp_buf, "0000CZ00;");
16468
    }
14807
    strcat (out_buffer, tmp_buf);
16469
  if (fg[fg_boronic_acid - 1])
14808
  }
16470
    {
14809
  if (fg[fg_alpha_aminoacid - 1]) {
16471
      sprintf (tmp_buf, "B2O2H000;");
14810
    sprintf (tmp_buf, "C3O2HN1C;");
16472
      strcat (out_buffer, tmp_buf);
14811
    strcat (out_buffer, tmp_buf);
16473
    }
14812
  }
16474
  if (fg[fg_boronic_acid_ester - 1])
14813
  if (fg[fg_alpha_hydroxyacid - 1]) {
16475
    {
14814
    sprintf (tmp_buf, "C3O2HO1H;");
16476
      sprintf (tmp_buf, "B2O2C000;");
14815
    strcat (out_buffer, tmp_buf);
16477
      strcat (out_buffer, tmp_buf);
14816
  }
16478
    }
-
 
16479
  if (fg[fg_alkene - 1])
-
 
16480
    {
-
 
16481
      sprintf (tmp_buf, "000C2C00;");
-
 
16482
      strcat (out_buffer, tmp_buf);
-
 
16483
    }
-
 
16484
  if (fg[fg_alkyne - 1])
-
 
16485
    {
-
 
16486
      sprintf (tmp_buf, "000C3C00;");
-
 
16487
      strcat (out_buffer, tmp_buf);
-
 
16488
    }
-
 
16489
  if (fg[fg_aromatic - 1])
-
 
16490
    {
-
 
16491
      sprintf (tmp_buf, "0000A000;");
-
 
16492
      strcat (out_buffer, tmp_buf);
-
 
16493
    }
-
 
16494
  if (fg[fg_heterocycle - 1])
-
 
16495
    {
-
 
16496
      sprintf (tmp_buf, "0000CZ00;");
-
 
16497
      strcat (out_buffer, tmp_buf);
-
 
16498
    }
-
 
16499
  if (fg[fg_alpha_aminoacid - 1])
-
 
16500
    {
-
 
16501
      sprintf (tmp_buf, "C3O2HN1C;");
-
 
16502
      strcat (out_buffer, tmp_buf);
-
 
16503
    }
-
 
16504
  if (fg[fg_alpha_hydroxyacid - 1])
-
 
16505
    {
-
 
16506
      sprintf (tmp_buf, "C3O2HO1H;");
-
 
16507
      strcat (out_buffer, tmp_buf);
-
 
16508
    }
-
 
16509
}
14817
}
16510
 
14818
 
16511
/*static void mm_elab_molstat(void)
14819
/*static void mm_elab_molstat(void)
16512
{
14820
{
16513
                count_neighbors();
14821
                count_neighbors();
Line 16523... Line 14831...
16523
      clear_rings();
14831
      clear_rings();
16524
      max_vringsize = 10;
14832
      max_vringsize = 10;
16525
      chk_ringbonds();
14833
      chk_ringbonds();
16526
      remove_redundant_rings();
14834
      remove_redundant_rings();
16527
    }
14835
    }
16528
   
14836
 
16529
    update_ringcount();
14837
    update_ringcount();
16530
    update_atypes();
14838
    update_atypes();
16531
    update_Htotal();
14839
    update_Htotal();
16532
    chk_arom();
14840
    chk_arom();
16533
 
14841
 
Line 16538... Line 14846...
16538
        n_ar = count_aromatic_rings();
14846
        n_ar = count_aromatic_rings();
16539
      } while (prev_n_ar - n_ar != 0);
14847
      } while (prev_n_ar - n_ar != 0);
16540
    }
14848
    }
16541
        } else {
14849
        } else {
16542
 update_atypes();
14850
 update_atypes();
16543
    update_Htotal();  
14851
    update_Htotal();
16544
               
14852
 
16545
        }
14853
        }
16546
 
14854
 
16547
 // get_molstat();
14855
 // get_molstat();
16548
}*/
14856
}*/
16549
 
14857
 
16550
DLLEXPORT void
14858
DLLEXPORT void
16551
cm_molstat_X (char *buf)
14859
cm_molstat_X (char *buf)
16552
{
14860
{
16553
  init_molstat (&molstat);
14861
  init_molstat (&molstat);
16554
//mm_elab_molstat();
14862
//mm_elab_molstat();
16555
  get_molstat ();
14863
  get_molstat ();
16556
  write_molstat_X_dll (buf);
14864
  write_molstat_X_dll (buf);
16557
}
14865
}
16558
 
14866
 
16559
DLLEXPORT void
14867
DLLEXPORT void
16560
cm_molstat (char *buf)
14868
cm_molstat (char *buf)
16561
{
14869
{
16562
  init_molstat (&molstat);
14870
  init_molstat (&molstat);
16563
//mm_elab_molstat();
14871
//mm_elab_molstat();
16564
  get_molstat ();
14872
  get_molstat ();
16565
  write_molstat_dll (buf, 0);
14873
  write_molstat_dll (buf, 0);
16566
}
14874
}
16567
 
14875
 
Line 16589... Line 14897...
16589
//mm_elab_molstat();
14897
//mm_elab_molstat();
16590
  chk_functionalgroups ();
14898
  chk_functionalgroups ();
16591
  write_fg_code_dll (buf);
14899
  write_fg_code_dll (buf);
16592
}
14900
}
16593
 
14901
 
16594
static void
-
 
16595
write_MDLmolfile_dll (char *out_buffer)
14902
static void write_MDLmolfile_dll (char *out_buffer)
16596
{
14903
{
16597
  int i;
14904
  int i;
16598
  char tmpstr[256];
14905
  char tmpstr[256];
16599
  char wline[256];
14906
  char wline[256];
16600
  int a_chg;
14907
  int a_chg;
Line 16628... Line 14935...
16628
  sprintf (tmpstr, "%d", n_atoms);
14935
  sprintf (tmpstr, "%d", n_atoms);
16629
  lblank (3L, tmpstr);
14936
  lblank (3L, tmpstr);
16630
  strcat (wline, tmpstr);
14937
  strcat (wline, tmpstr);
16631
  /* first 3 digits: number of atoms */
14938
  /* first 3 digits: number of atoms */
16632
  sprintf (tmpstr, "%d", n_bonds);
14939
  sprintf (tmpstr, "%d", n_bonds);
16633
  lblank (3L, tmpstr);
14940
  lblank (3L, tmpstr);
16634
  strcat (wline, tmpstr);
14941
  strcat (wline, tmpstr);
16635
  *tmpstr = '\0';               /* next 3 digits: number of bonds */
14942
  *tmpstr = '\0';               /* next 3 digits: number of bonds */
16636
  strcpy (tmpstr, "  0");
14943
  strcpy (tmpstr, "  0");
16637
  strcat (wline, tmpstr);
14944
  strcat (wline, tmpstr);
16638
  /* next 3 digits: number of atom lists (not used by us) */
14945
  /* next 3 digits: number of atom lists (not used by us) */
16639
/* p2c: checkmol.pas, line 2388:
14946
  /* p2c: checkmol.pas, line 2388:
16640
 * Note: Turbo Pascal conditional compilation directive was ignored [218] */
14947
  * Note: Turbo Pascal conditional compilation directive was ignored [218] */
16641
#ifdef REDUCED_SAR
14948
#ifdef REDUCED_SAR
16642
  sprintf (tmpstr, "%d", n_countablerings);
14949
  sprintf (tmpstr, "%d", n_countablerings);
16643
  /* v0.3n; changed n_rings into n_countablerings */
14950
  /* v0.3n; changed n_rings into n_countablerings */
16644
#else
14951
#else
16645
  sprintf (tmpstr, "%d", n_rings);
14952
  sprintf (tmpstr, "%d", n_rings);
Line 16655... Line 14962...
16655
  /* v0.3n */
14962
  /* v0.3n */
16656
  strcat (wline, "               999 V2000\n");
14963
  strcat (wline, "               999 V2000\n");
16657
  /* v0.3n (adjust string length) */
14964
  /* v0.3n (adjust string length) */
16658
  strcat (out_buffer, wline);
14965
  strcat (out_buffer, wline);
16659
  FORLIM = n_atoms;
14966
  FORLIM = n_atoms;
16660
  for (i = 0; i < FORLIM; i++)
14967
  for (i = 0; i < FORLIM; i++) {
16661
    {
-
 
16662
      *wline = '\0';
14968
    *wline = '\0';
16663
      *tmpstr = '\0';
14969
    *tmpstr = '\0';
16664
      sprintf (tmpstr, "%1.4f", atom[i].x);
14970
    sprintf (tmpstr, "%1.4f", atom[i].x);
16665
      lblank (10L, tmpstr);
14971
    lblank (10L, tmpstr);
16666
      strcat (wline, tmpstr);
14972
    strcat (wline, tmpstr);
16667
      sprintf (tmpstr, "%1.4f", atom[i].y);
14973
    sprintf (tmpstr, "%1.4f", atom[i].y);
16668
      lblank (10L, tmpstr);
14974
    lblank (10L, tmpstr);
16669
      strcat (wline, tmpstr);
14975
    strcat (wline, tmpstr);
16670
      sprintf (tmpstr, "%1.4f", atom[i].z);
14976
    sprintf (tmpstr, "%1.4f", atom[i].z);
16671
      lblank (10L, tmpstr);
14977
    lblank (10L, tmpstr);
16672
      strcat (wline, tmpstr);
14978
    strcat (wline, tmpstr);
16673
      strcpy (tmpstr, atom[i].element);
14979
    strcpy (tmpstr, atom[i].element);
16674
      /* tmpstr := lowercase(tmpstr); REPLACE!!! */
14980
    /* tmpstr := lowercase(tmpstr); REPLACE!!! */
16675
      //tmpstr[0] = toupper (tmpstr[0]);
14981
    //tmpstr[0] = toupper (tmpstr[0]);
16676
      all_lowercase (tmpstr);
14982
    all_lowercase (tmpstr);
16677
      tmpstr[0] = toupper (tmpstr[0]);
14983
    tmpstr[0] = toupper (tmpstr[0]);
16678
      /*wline := wline + ' '+atom^[i].element+' '; */
14984
    /*wline := wline + ' '+atom^[i].element+' '; */
16679
      sprintf (wline + strlen (wline), " %s ", tmpstr);
14985
    sprintf (wline + strlen (wline), " %s ", tmpstr);
16680
      strcat (wline, " 0");     /* mass difference (isotopes) */
14986
    strcat (wline, " 0");       /* mass difference (isotopes) */
16681
      /* now we code aromaticity into the old-style charge column (charges are now in the M  CHG line) */
14987
    /* now we code aromaticity into the old-style charge column (charges are now in the M  CHG line) */
16682
      if (atom[i].arom)
14988
    if (atom[i].arom)
16683
        strcpy (tmpstr, " 00");
14989
            strcpy (tmpstr, " 00");
16684
      else
14990
    else
16685
        strcpy (tmpstr, "  0");
14991
            strcpy (tmpstr, "  0");
16686
      strcat (wline, tmpstr);
14992
    strcat (wline, tmpstr);
16687
      strcat (wline, "  0  0  0  0  0  0  0  0  0  0\n");
14993
    strcat (wline, "  0  0  0  0  0  0  0  0  0  0\n");
16688
      strcat (out_buffer, wline);
14994
    strcat (out_buffer, wline);
16689
    }
14995
  }
16690
  FORLIM = n_bonds;
14996
  FORLIM = n_bonds;
16691
  for (i = 0; i < FORLIM; i++)
14997
  for (i = 0; i < FORLIM; i++) {
16692
    {
-
 
16693
      *wline = '\0';
14998
    *wline = '\0';
16694
      *tmpstr = '\0';
14999
    *tmpstr = '\0';
16695
      sprintf (tmpstr, "%d", bond[i].a1);
15000
    sprintf (tmpstr, "%d", bond[i].a1);
16696
      lblank (3L, tmpstr);
15001
    lblank (3L, tmpstr);
16697
      strcat (wline, tmpstr);
15002
    strcat (wline, tmpstr);
16698
      sprintf (tmpstr, "%d", bond[i].a2);
15003
    sprintf (tmpstr, "%d", bond[i].a2);
16699
      lblank (3L, tmpstr);
15004
    lblank (3L, tmpstr);
16700
      strcat (wline, tmpstr);
15005
    strcat (wline, tmpstr);
16701
      if (bond[i].btype == 'S')
15006
    if (bond[i].btype == 'S')
16702
        strcpy (tmpstr, "  1");
15007
            strcpy (tmpstr, "  1");
16703
      if (bond[i].btype == 'D')
15008
    if (bond[i].btype == 'D')
16704
        strcpy (tmpstr, "  2");
15009
            strcpy (tmpstr, "  2");
16705
      if (bond[i].btype == 'T')
15010
    if (bond[i].btype == 'T')
16706
        strcpy (tmpstr, "  3");
15011
            strcpy (tmpstr, "  3");
16707
      if (bond[i].btype == 'A')
15012
    if (bond[i].btype == 'A')
16708
        strcpy (tmpstr, "  4");
15013
            strcpy (tmpstr, "  4");
16709
      if (bond[i].btype == 'l')
15014
    if (bond[i].btype == 'l')
16710
        strcpy (tmpstr, "  5");
15015
            strcpy (tmpstr, "  5");
16711
      if (bond[i].btype == 's')
15016
    if (bond[i].btype == 's')
16712
        strcpy (tmpstr, "  6");
15017
            strcpy (tmpstr, "  6");
16713
      if (bond[i].btype == 'd')
15018
    if (bond[i].btype == 'd')
16714
        strcpy (tmpstr, "  7");
15019
            strcpy (tmpstr, "  7");
16715
      if (bond[i].btype == 'a')
15020
    if (bond[i].btype == 'a')
16716
        strcpy (tmpstr, "  8");
15021
            strcpy (tmpstr, "  8");
16717
      /* now encode our own aromaticity information */
15022
        /* now encode our own aromaticity information */
16718
      if (bond[i].arom)
15023
    if (bond[i].arom)
16719
        tmpstr[1] = '0';
15024
            tmpstr[1] = '0';
16720
      strcat (wline, tmpstr);   /* next, encode bond stereo property (v0.3f) */
15025
    strcat (wline, tmpstr);     /* next, encode bond stereo property (v0.3f) */
16721
      /*if (bond^[i].stereo = bstereo_up) then wline := wline + '  1' else */
15026
    /*if (bond^[i].stereo = bstereo_up) then wline := wline + '  1' else */
16722
      /*  if (bond^[i].stereo = bstereo_down) then wline := wline + '  6' else */
15027
    /*  if (bond^[i].stereo = bstereo_down) then wline := wline + '  6' else */
16723
      /*    wline := wline + '  0'; */
15028
    /*    wline := wline + '  0'; */
16724
      /* restore original value from MDL molfile (v0.3n) */
15029
    /* restore original value from MDL molfile (v0.3n) */
16725
      /* wline := wline + '  ' + inttostr(bond^[i].mdl_stereo);    REPLACE!!! */
15030
    /* wline := wline + '  ' + inttostr(bond^[i].mdl_stereo);    REPLACE!!! */
16726
      *tmpstr = '\0';
15031
    *tmpstr = '\0';
16727
      sprintf (tmpstr, "%i", bond[i].mdl_stereo);
15032
    sprintf (tmpstr, "%i", bond[i].mdl_stereo);
16728
      strcat (wline, "  ");
15033
    strcat (wline, "  ");
16729
      strcat (wline, tmpstr);
15034
    strcat (wline, tmpstr);
16730
      *tmpstr = '\0';
15035
    *tmpstr = '\0';
16731
      /* now encode the ring_count of this bond (using a field which officially is "not used") */
15036
    /* now encode the ring_count of this bond (using a field which officially is "not used") */
16732
      /* tmpstr := inttostr(bond^[i].ring_count); REPLACE!!! */
15037
    /* tmpstr := inttostr(bond^[i].ring_count); REPLACE!!! */
16733
      sprintf (tmpstr, "%i", bond[i].ring_count);
15038
    sprintf (tmpstr, "%i", bond[i].ring_count);
16734
      while (strlen (tmpstr) < 3)
15039
    while (strlen (tmpstr) < 3)
16735
        sprintf (tmpstr, " %s", strcpy (STR1, tmpstr));
15040
            sprintf (tmpstr, " %s", strcpy (STR1, tmpstr));
16736
      sprintf (wline + strlen (wline), "%s  0  0\n", tmpstr);
15041
    sprintf (wline + strlen (wline), "%s  0  0\n", tmpstr);
16737
      strcat (out_buffer, wline);
15042
    strcat (out_buffer, wline);
16738
    }
15043
  }
16739
  FORLIM = n_atoms;
15044
  FORLIM = n_atoms;
16740
  for (i = 1; i <= FORLIM; i++)
15045
  for (i = 1; i <= FORLIM; i++) {
16741
    {
-
 
16742
      a_chg = atom[i - 1].formal_charge;
15046
    a_chg = atom[i - 1].formal_charge;
16743
      if (a_chg != 0)
15047
    if (a_chg != 0) {
16744
        {
-
 
16745
          strcpy (wline, "M  CHG  1 ");
15048
            strcpy (wline, "M  CHG  1 ");
16746
          sprintf (tmpstr, "%d", i);
15049
            sprintf (tmpstr, "%d", i);
16747
          lblank (3L, tmpstr);
15050
            lblank (3L, tmpstr);
16748
          sprintf (wline + strlen (wline), "%s ", tmpstr);
15051
            sprintf (wline + strlen (wline), "%s ", tmpstr);
16749
          sprintf (tmpstr, "%d", a_chg);
15052
            sprintf (tmpstr, "%d", a_chg);
16750
          lblank (3L, tmpstr);
15053
            lblank (3L, tmpstr);
16751
          strcat (wline, tmpstr);
15054
            strcat (wline, tmpstr);
16752
          strcat (out_buffer, wline);
15055
            strcat (out_buffer, wline);
16753
          strcat (out_buffer, "\n");
15056
            strcat (out_buffer, "\n");
16754
        }
15057
          }
16755
    }
15058
  }
16756
  for (i = 1; i <= FORLIM; i++) /* 0.3x */
15059
  for (i = 1; i <= FORLIM; i++) /* 0.3x */ {
16757
    {
-
 
16758
      a_iso = atom[i - 1].nucleon_number;
15060
    a_iso = atom[i - 1].nucleon_number;
16759
      if (a_iso != 0)
15061
    if (a_iso != 0) {
16760
        {
-
 
16761
          strcpy (wline, "M  ISO  1 ");
15062
            strcpy (wline, "M  ISO  1 ");
16762
          sprintf (tmpstr, "%d", i);
15063
            sprintf (tmpstr, "%d", i);
16763
          lblank (3L, tmpstr);
15064
            lblank (3L, tmpstr);
16764
          sprintf (wline + strlen (wline), "%s ", tmpstr);
15065
            sprintf (wline + strlen (wline), "%s ", tmpstr);
16765
          sprintf (tmpstr, "%d", a_iso);
15066
            sprintf (tmpstr, "%d", a_iso);
16766
          lblank (3L, tmpstr);
15067
            lblank (3L, tmpstr);
16767
          strcat (wline, tmpstr);
15068
            strcat (wline, tmpstr);
16768
          strcat (out_buffer, wline);
15069
            strcat (out_buffer, wline);
16769
          strcat (out_buffer, "\n");
15070
            strcat (out_buffer, "\n");
16770
        }
15071
          }
16771
    }
15072
  }
16772
  for (i = 1; i <= FORLIM; i++) /* 0.3x */
15073
  for (i = 1; i <= FORLIM; i++) /* 0.3x */ {
16773
    {
-
 
16774
      a_rad = atom[i - 1].radical_type;
15074
    a_rad = atom[i - 1].radical_type;
16775
      if (a_rad != 0)
15075
    if (a_rad != 0) {
16776
        {
-
 
16777
          strcpy (wline, "M  RAD  1 ");
15076
            strcpy (wline, "M  RAD  1 ");
16778
          sprintf (tmpstr, "%d", i);
15077
            sprintf (tmpstr, "%d", i);
16779
          lblank (3L, tmpstr);
15078
            lblank (3L, tmpstr);
16780
          sprintf (wline + strlen (wline), "%s ", tmpstr);
15079
            sprintf (wline + strlen (wline), "%s ", tmpstr);
16781
          sprintf (tmpstr, "%d", a_rad);
15080
            sprintf (tmpstr, "%d", a_rad);
16782
          lblank (3L, tmpstr);
15081
            lblank (3L, tmpstr);
16783
          strcat (wline, tmpstr);
15082
            strcat (wline, tmpstr);
16784
          strcat (out_buffer, wline);
15083
            strcat (out_buffer, wline);
16785
          strcat (out_buffer, "\n");
15084
            strcat (out_buffer, "\n");
16786
        }
15085
          }
16787
    }
15086
  }
16788
  strcat (out_buffer, "M  END\n");
15087
  strcat (out_buffer, "M  END\n");
16789
}
15088
}
16790
 
15089
 
16791
DLLEXPORT void
15090
DLLEXPORT void
16792
cm_tweak_molfile (char *buf)
15091
cm_tweak_molfile (char *buf)