Subversion Repositories wimsdev

Rev

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

Rev 6788 Rev 6789
Line 4704... Line 4704...
4704
 
4704
 
4705
static boolean
4705
static boolean
4706
is_true_exocyclic_imino_C (int id, int r_id)
4706
is_true_exocyclic_imino_C (int id, int r_id)
4707
{
4707
{
4708
  /* v0.3j */
4708
  /* v0.3j */
4709
  boolean Result;
-
 
4710
  int i, j;
4709
  int i, j;
4711
  boolean r = false;
4710
  boolean r = false;
4712
  neighbor_rec nb;
4711
  neighbor_rec nb;
4713
  ringpath_type testring;
4712
  ringpath_type testring;
4714
  int ring_size, b, FORLIM;
4713
  int ring_size, b, FORLIM;
4715
 
4714
 
4716
  memset (nb, 0, sizeof (neighbor_rec));
4715
  memset (nb, 0, sizeof (neighbor_rec));
4717
  if (id < 1 || id > n_atoms)
4716
  if (id < 1 || id > n_atoms)
4718
    return Result;
4717
    return false;
4719
  get_neighbors (nb, id);
4718
  get_neighbors (nb, id);
4720
  memset (testring, 0, sizeof (ringpath_type));
4719
  memset (testring, 0, sizeof (ringpath_type));
4721
  ring_size = ringprop[r_id - 1].size;  /* v0.3j */
4720
  ring_size = ringprop[r_id - 1].size;  /* v0.3j */
4722
  for (j = 0; j < ring_size; j++)       /* v0.3j */
4721
  for (j = 0; j < ring_size; j++)       /* v0.3j */
4723
    testring[j] = ring[r_id - 1][j];
4722
    testring[j] = ring[r_id - 1][j];
Line 4726... Line 4725...
4726
  FORLIM = atom[id - 1].neighbor_count;
4725
  FORLIM = atom[id - 1].neighbor_count;
4727
  for (i = 0; i < FORLIM; i++)
4726
  for (i = 0; i < FORLIM; i++)
4728
    {
4727
    {
4729
      b = get_bond (id, nb[i]);
4728
      b = get_bond (id, nb[i]);
4730
      if (bond[b - 1].btype == 'D' && bond[b - 1].arom == false &&
4729
      if (bond[b - 1].btype == 'D' && bond[b - 1].arom == false &&
4731
          !strcmp (atom[nb[i] - 1].element, "N "))
4730
          !strcmp (atom[nb[i] - 1].element, "N "))
4732
        {
4731
        {
4733
          r = true;
4732
          r = true;
4734
          for (j = 0; j < ring_size; j++)
4733
          for (j = 0; j < ring_size; j++)
4735
            {
4734
            {
4736
              if (nb[i] == ring[r_id - 1][j])
4735
              if (nb[i] == ring[r_id - 1][j])
4737
                r = false;
4736
                r = false;
4738
            }
4737
            }
4739
        }
4738
        }
4740
    }
4739
    }
4741
  return r;
4740
  return r;
4742
}
4741
}
4743
 
4742
 
4744
 
4743
 
4745
static boolean
4744
static boolean
4746
is_exocyclic_imino_C (int id, int r_id)
4745
is_exocyclic_imino_C (int id, int r_id)
4747
{
4746
{
4748
  boolean Result;
-
 
4749
  int i, j;
4747
  int i, j;
4750
  boolean r = false;
4748
  boolean r = false;
4751
  neighbor_rec nb;
4749
  neighbor_rec nb;
4752
  ringpath_type testring;
4750
  ringpath_type testring;
4753
  int ring_size, FORLIM;
4751
  int ring_size, FORLIM;
4754
 
4752
 
4755
  memset (nb, 0, sizeof (neighbor_rec));
4753
  memset (nb, 0, sizeof (neighbor_rec));
4756
  if (id < 1 || id > n_atoms)
4754
  if (id < 1 || id > n_atoms)
4757
    return Result;
4755
    return false;
4758
  get_neighbors (nb, id);
4756
  get_neighbors (nb, id);
4759
  memset (testring, 0, sizeof (ringpath_type));
4757
  memset (testring, 0, sizeof (ringpath_type));
4760
  ring_size = ringprop[r_id - 1].size;  /* v0.3j */
4758
  ring_size = ringprop[r_id - 1].size;  /* v0.3j */
4761
  for (j = 0; j < ring_size; j++)       /* v0.3j */
4759
  for (j = 0; j < ring_size; j++)       /* v0.3j */
4762
    testring[j] = ring[r_id - 1][j];
4760
    testring[j] = ring[r_id - 1][j];
4763
  if (strcmp (atom[id - 1].element, "C ") || atom[id - 1].neighbor_count <= 0)
4761
  if (strcmp (atom[id - 1].element, "C ") || atom[id - 1].neighbor_count <= 0)
4764
    return false;
4762
    return false;
4765
  FORLIM = atom[id - 1].neighbor_count;
4763
  FORLIM = atom[id - 1].neighbor_count;
4766
  for (i = 0; i < FORLIM; i++)
4764
  for (i = 0; i < FORLIM; i++)
4767
    {
4765
    {
4768
      if (bond[get_bond (id, nb[i]) - 1].btype == 'D' &&
4766
      if (bond[get_bond (id, nb[i]) - 1].btype == 'D' &&
4769
          !strcmp (atom[nb[i] - 1].element, "N "))
4767
          !strcmp (atom[nb[i] - 1].element, "N "))
4770
        {
4768
        {
4771
          r = true;
4769
          r = true;
4772
          for (j = 0; j < ring_size; j++)
4770
          for (j = 0; j < ring_size; j++)
4773
            {
4771
            {
4774
              if (nb[i] == ring[r_id - 1][j])
4772
              if (nb[i] == ring[r_id - 1][j])
4775
                r = false;
4773
                r = false;
4776
            }
4774
            }
4777
        }
4775
        }
4778
    }
4776
    }
4779
  return r;
4777
  return r;
4780
}
4778
}
4781
 
4779
 
4782
 
4780
 
4783
static int
4781
static int
4784
find_exocyclic_methylene_C (int id, int r_id)
4782
find_exocyclic_methylene_C (int id, int r_id)
4785
{
4783
{
4786
  /* renamed and rewritten in v0.3j */
4784
  /* renamed and rewritten in v0.3j */
4787
  int i, j;
4785
  int i, j;
Line 4832... Line 4830...
4832
    }
4830
    }
4833
  return r;
4831
  return r;
4834
}
4832
}
4835
 
4833
 
4836
 
4834
 
4837
static boolean
4835
static boolean
4838
is_sulfanyl (int a_view, int a_ref)
4836
is_sulfanyl (int a_view, int a_ref)
4839
{
4837
{
4840
  boolean r = false;
4838
  boolean r = false;
4841
 
4839
 
4842
  if (atom[a_view - 1].
4840
  if (atom[a_view - 1].
4843
      heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S'))
4841
      heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S'))
4844
    {
4842
    {
4845
      if (!strcmp (atom[a_ref - 1].atype, "S3 ") &&
4843
      if (!strcmp (atom[a_ref - 1].atype, "S3 ") &&
4846
          atom[a_ref - 1].neighbor_count == 1)
4844
          atom[a_ref - 1].neighbor_count == 1)
4847
        r = true;
4845
        r = true;
4848
    }
4846
    }
4849
  return r;
4847
  return r;
4850
}
4848
}
4851
 
4849
 
4852
 
4850
 
4853
static boolean
4851
static boolean
4854
is_amino (int a_view, int a_ref)
4852
is_amino (int a_view, int a_ref)
4855
{
4853
{
4856
  boolean r = false;
4854
  boolean r = false;
4857
 
4855
 
Line 4860... Line 4858...
4860
    {
4858
    {
4861
      if ((!strcmp (atom[a_ref - 1].atype, "N3 ") ||
4859
      if ((!strcmp (atom[a_ref - 1].atype, "N3 ") ||
4862
           !strcmp (atom[a_ref - 1].atype, "N3+")) &&
4860
           !strcmp (atom[a_ref - 1].atype, "N3+")) &&
4863
          atom[a_ref - 1].neighbor_count == 1)
4861
          atom[a_ref - 1].neighbor_count == 1)
4864
        r = true;
4862
        r = true;
4865
    }
4863
    }
4866
  return r;
4864
  return r;
4867
}
4865
}
4868
 
4866
 
4869
 
4867
 
4870
static boolean
4868
static boolean
4871
is_alkyl (int a_view, int a_ref)
4869
is_alkyl (int a_view, int a_ref)
4872
{
4870
{
4873
  int i;
4871
  int i;
4874
  boolean r = false;
4872
  boolean r = false;
4875
  neighbor_rec nb;
4873
  neighbor_rec nb;
4876
  str2 nb_el;
4874
  str2 nb_el;
4877
  int het_count = 0;
4875
  int het_count = 0;
4878
  int FORLIM;
4876
  int FORLIM;
4879
 
4877
 
4880
  memset (nb, 0, sizeof (neighbor_rec));
4878
  memset (nb, 0, sizeof (neighbor_rec));
4881
  if (!
4879
  if (!
4882
      (atom[a_view - 1].
4880
      (atom[a_view - 1].
4883
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S'))
4881
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S'))
4884
      || strcmp (atom[a_ref - 1].atype, "C3 ")
4882
      || strcmp (atom[a_ref - 1].atype, "C3 ")
4885
      || atom[a_ref - 1].arom != false)
4883
      || atom[a_ref - 1].arom != false)
4886
    return false;
4884
    return false;
4887
  get_nextneighbors (nb, a_ref, a_view);
4885
  get_nextneighbors (nb, a_ref, a_view);
4888
  FORLIM = atom[a_ref - 1].neighbor_count - 2;
4886
  FORLIM = atom[a_ref - 1].neighbor_count - 2;
4889
  for (i = 0; i <= FORLIM; i++)
4887
  for (i = 0; i <= FORLIM; i++)
4890
    {
4888
    {
Line 4894... Line 4892...
4894
          && strcmp (nb_el, "LP"))
4892
          && strcmp (nb_el, "LP"))
4895
        /* added 'D ' in v0.3n */
4893
        /* added 'D ' in v0.3n */
4896
        het_count++;
4894
        het_count++;
4897
    }
4895
    }
4898
  if (het_count <= 1)           /* we consider (e.g.) alkoxyalkyl groups as alkyl */
4896
  if (het_count <= 1)           /* we consider (e.g.) alkoxyalkyl groups as alkyl */
4899
    r = true;
4897
    r = true;
4900
  return r;
4898
  return r;
4901
}
4899
}
4902
 
4900
 
4903
 
4901
 
4904
static boolean
4902
static boolean
4905
is_true_alkyl (int a_view, int a_ref)
4903
is_true_alkyl (int a_view, int a_ref)
4906
{
4904
{
4907
  int i;
4905
  int i;
Line 4927... Line 4925...
4927
          /*&&  strcmp (nb_el, "D ") */  && strcmp (nb_el, "DU"))
4925
          /*&&  strcmp (nb_el, "D ") */  && strcmp (nb_el, "DU"))
4928
        /* added 'D ' in v0.3n */
4926
        /* added 'D ' in v0.3n */
4929
        het_count++;
4927
        het_count++;
4930
    }
4928
    }
4931
  if (het_count == 0)           /* */
4929
  if (het_count == 0)           /* */
4932
    r = true;
4930
    r = true;
4933
  return r;
4931
  return r;
4934
}
4932
}
4935
 
4933
 
4936
 
4934
 
4937
static boolean
4935
static boolean
4938
is_alkenyl (int a_view, int a_ref)
4936
is_alkenyl (int a_view, int a_ref)
4939
{
4937
{
4940
  /* new in v0.3j */
4938
  /* new in v0.3j */
Line 4976... Line 4974...
4976
}
4974
}
4977
 
4975
 
4978
 
4976
 
4979
static boolean
4977
static boolean
4980
is_alkynyl (int a_view, int a_ref)
4978
is_alkynyl (int a_view, int a_ref)
4981
{
4979
{
4982
  /* new in v0.3j */
4980
  /* new in v0.3j */
4983
  int i;
4981
  int i;
4984
  boolean r = false;
4982
  boolean r = false;
4985
  neighbor_rec nb;
4983
  neighbor_rec nb;
4986
  str3 nb_at;
4984
  str3 nb_at;
4987
  int c1_count = 0;
4985
  int c1_count = 0;
4988
  int FORLIM;
4986
  int FORLIM;
4989
 
4987
 
Line 4991... Line 4989...
4991
  if (!
4989
  if (!
4992
      (atom[a_view - 1].
4990
      (atom[a_view - 1].
4993
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S'))
4991
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S'))
4994
      || strcmp (atom[a_ref - 1].atype, "C1 ")
4992
      || strcmp (atom[a_ref - 1].atype, "C1 ")
4995
      || atom[a_ref - 1].arom != false)
4993
      || atom[a_ref - 1].arom != false)
4996
    return false;
4994
    return false;
4997
  get_nextneighbors (nb, a_ref, a_view);
4995
  get_nextneighbors (nb, a_ref, a_view);
4998
  FORLIM = atom[a_ref - 1].neighbor_count - 2;
4996
  FORLIM = atom[a_ref - 1].neighbor_count - 2;
4999
  for (i = 0; i <= FORLIM; i++)
4997
  for (i = 0; i <= FORLIM; i++)
5000
    {
4998
    {
5001
      strcpy (nb_at, atom[nb[i] - 1].atype);
4999
      strcpy (nb_at, atom[nb[i] - 1].atype);
5002
      if (!strcmp (nb_at, "C1 "))
5000
      if (!strcmp (nb_at, "C1 "))
Line 5004... Line 5002...
5004
    }
5002
    }
5005
  if (c1_count == 1)
5003
  if (c1_count == 1)
5006
    r = true;
5004
    r = true;
5007
  return r;
5005
  return r;
5008
}
5006
}
5009
 
5007
 
5010
 
5008
 
5011
static boolean
5009
static boolean
5012
is_aryl (int a_view, int a_ref)
5010
is_aryl (int a_view, int a_ref)
5013
{
5011
{
5014
  boolean r = false;
5012
  boolean r = false;
5015
 
5013
 
5016
  if ((atom[a_view - 1].
5014
  if ((atom[a_view - 1].
5017
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S'))
5015
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S'))
5018
      && !strcmp (atom[a_ref - 1].element, "C ")
5016
      && !strcmp (atom[a_ref - 1].element, "C ")
5019
      && atom[a_ref - 1].arom == true)
5017
      && atom[a_ref - 1].arom == true)
5020
    r = true;
5018
    r = true;
5021
  return r;
5019
  return r;
5022
}
5020
}
5023
 
5021
 
5024
 
5022
 
5025
static boolean
5023
static boolean
5026
is_alkoxy (int a_view, int a_ref)
5024
is_alkoxy (int a_view, int a_ref)
5027
{
5025
{
5028
  boolean r = false;
5026
  boolean r = false;
5029
  neighbor_rec nb;
5027
  neighbor_rec nb;
5030
 
5028
 
5031
  memset (nb, 0, sizeof (neighbor_rec));
5029
  memset (nb, 0, sizeof (neighbor_rec));
5032
  if (!
5030
  if (!
5033
      (atom[a_view - 1].
5031
      (atom[a_view - 1].
5034
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5032
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5035
    return false;
5033
    return false;
5036
  if (strcmp (atom[a_ref - 1].atype, "O3 ")
5034
  if (strcmp (atom[a_ref - 1].atype, "O3 ")
5037
      || atom[a_ref - 1].neighbor_count != 2)
5035
      || atom[a_ref - 1].neighbor_count != 2)
5038
    return false;
5036
    return false;
5039
  get_nextneighbors (nb, a_ref, a_view);
5037
  get_nextneighbors (nb, a_ref, a_view);
5040
  if (is_alkyl (a_ref, nb[0]))
5038
  if (is_alkyl (a_ref, nb[0]))
5041
    r = true;
5039
    r = true;
5042
  return r;
5040
  return r;
5043
}
5041
}
5044
 
5042
 
5045
 
5043
 
5046
static boolean
5044
static boolean
5047
is_siloxy (int a_view, int a_ref)
5045
is_siloxy (int a_view, int a_ref)
5048
{
5046
{
5049
  boolean r = false;
5047
  boolean r = false;
5050
  neighbor_rec nb;
5048
  neighbor_rec nb;
5051
 
5049
 
5052
  memset (nb, 0, sizeof (neighbor_rec));
5050
  memset (nb, 0, sizeof (neighbor_rec));
5053
  if (!
5051
  if (!
5054
      (atom[a_view - 1].
5052
      (atom[a_view - 1].
5055
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5053
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5056
    return false;
5054
    return false;
5057
  if (strcmp (atom[a_ref - 1].atype, "O3 ")
5055
  if (strcmp (atom[a_ref - 1].atype, "O3 ")
5058
      || atom[a_ref - 1].neighbor_count != 2)
5056
      || atom[a_ref - 1].neighbor_count != 2)
5059
    return false;
5057
    return false;
5060
  get_nextneighbors (nb, a_ref, a_view);
5058
  get_nextneighbors (nb, a_ref, a_view);
5061
  if (!strcmp (atom[nb[0] - 1].element, "SI"))
5059
  if (!strcmp (atom[nb[0] - 1].element, "SI"))
5062
    r = true;
5060
    r = true;
5063
  return r;
5061
  return r;
5064
}
5062
}
5065
 
5063
 
5066
 
5064
 
5067
static boolean
5065
static boolean
5068
is_true_alkoxy (int a_view, int a_ref)
5066
is_true_alkoxy (int a_view, int a_ref)
5069
{
5067
{
5070
  boolean r = false;
5068
  boolean r = false;
5071
  neighbor_rec nb;
5069
  neighbor_rec nb;
5072
 
5070
 
5073
  memset (nb, 0, sizeof (neighbor_rec));
5071
  memset (nb, 0, sizeof (neighbor_rec));
5074
  if (!
5072
  if (!
5075
      (atom[a_view - 1].
5073
      (atom[a_view - 1].
5076
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5074
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5077
    return false;
5075
    return false;
5078
  if (strcmp (atom[a_ref - 1].atype, "O3 ")
5076
  if (strcmp (atom[a_ref - 1].atype, "O3 ")
5079
      || atom[a_ref - 1].neighbor_count != 2)
5077
      || atom[a_ref - 1].neighbor_count != 2)
5080
    return false;
5078
    return false;
5081
  get_nextneighbors (nb, a_ref, a_view);
5079
  get_nextneighbors (nb, a_ref, a_view);
5082
  if (is_true_alkyl (a_ref, nb[0]))
5080
  if (is_true_alkyl (a_ref, nb[0]))
5083
    r = true;
5081
    r = true;
Line 5106... Line 5104...
5106
}
5104
}
5107
 
5105
 
5108
 
5106
 
5109
static boolean
5107
static boolean
5110
is_alkenyloxy (int a_view, int a_ref)
5108
is_alkenyloxy (int a_view, int a_ref)
5111
{
5109
{
5112
  /* v0.3j */
5110
  /* v0.3j */
5113
  boolean r = false;
5111
  boolean r = false;
5114
  neighbor_rec nb;
5112
  neighbor_rec nb;
5115
 
5113
 
5116
  memset (nb, 0, sizeof (neighbor_rec));
5114
  memset (nb, 0, sizeof (neighbor_rec));
5117
  if (!
5115
  if (!
5118
      (atom[a_view - 1].
5116
      (atom[a_view - 1].
5119
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5117
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5120
    return false;
5118
    return false;
Line 5143... Line 5141...
5143
  if (strcmp (atom[a_ref - 1].atype, "O3 ")
5141
  if (strcmp (atom[a_ref - 1].atype, "O3 ")
5144
      || atom[a_ref - 1].neighbor_count != 2)
5142
      || atom[a_ref - 1].neighbor_count != 2)
5145
    return false;
5143
    return false;
5146
  get_nextneighbors (nb, a_ref, a_view);
5144
  get_nextneighbors (nb, a_ref, a_view);
5147
  if (is_alkynyl (a_ref, nb[0]))
5145
  if (is_alkynyl (a_ref, nb[0]))
5148
    r = true;
5146
    r = true;
5149
  return r;
5147
  return r;
5150
}
5148
}
5151
 
5149
 
5152
 
5150
 
5153
static boolean
5151
static boolean
5154
is_alkylsulfanyl (int a_view, int a_ref)
5152
is_alkylsulfanyl (int a_view, int a_ref)
5155
{
5153
{
5156
  boolean r = false;
5154
  boolean r = false;
5157
  neighbor_rec nb;
5155
  neighbor_rec nb;
5158
 
5156
 
5159
  memset (nb, 0, sizeof (neighbor_rec));
5157
  memset (nb, 0, sizeof (neighbor_rec));
5160
  if (!
5158
  if (!
5161
      (atom[a_view - 1].
5159
      (atom[a_view - 1].
5162
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5160
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5163
    return false;
5161
    return false;
5164
  if (strcmp (atom[a_ref - 1].atype, "S3 ")
5162
  if (strcmp (atom[a_ref - 1].atype, "S3 ")
5165
      || atom[a_ref - 1].neighbor_count != 2)
5163
      || atom[a_ref - 1].neighbor_count != 2)
5166
    return false;
5164
    return false;
5167
  get_nextneighbors (nb, a_ref, a_view);
5165
  get_nextneighbors (nb, a_ref, a_view);
5168
  if (is_alkyl (a_ref, nb[0]))
5166
  if (is_alkyl (a_ref, nb[0]))
5169
    r = true;
5167
    r = true;
5170
  return r;
5168
  return r;
5171
}
5169
}
5172
 
5170
 
5173
 
5171
 
5174
static boolean
5172
static boolean
5175
is_true_alkylsulfanyl (int a_view, int a_ref)
5173
is_true_alkylsulfanyl (int a_view, int a_ref)
5176
{
5174
{
5177
  boolean r = false;
5175
  boolean r = false;
5178
  neighbor_rec nb;
5176
  neighbor_rec nb;
5179
 
5177
 
5180
  memset (nb, 0, sizeof (neighbor_rec));
5178
  memset (nb, 0, sizeof (neighbor_rec));
5181
  if (!
5179
  if (!
5182
      (atom[a_view - 1].
5180
      (atom[a_view - 1].
5183
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5181
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5184
    return false;
5182
    return false;
5185
  if (strcmp (atom[a_ref - 1].atype, "S3 ")
5183
  if (strcmp (atom[a_ref - 1].atype, "S3 ")
5186
      || atom[a_ref - 1].neighbor_count != 2)
5184
      || atom[a_ref - 1].neighbor_count != 2)
5187
    return false;
5185
    return false;
5188
  get_nextneighbors (nb, a_ref, a_view);
5186
  get_nextneighbors (nb, a_ref, a_view);
5189
  if (is_true_alkyl (a_ref, nb[0]))
5187
  if (is_true_alkyl (a_ref, nb[0]))
5190
    r = true;
5188
    r = true;
5191
  return r;
5189
  return r;
5192
}
5190
}
5193
 
5191
 
5194
 
5192
 
5195
static boolean
5193
static boolean
5196
is_arylsulfanyl (int a_view, int a_ref)
5194
is_arylsulfanyl (int a_view, int a_ref)
5197
{
5195
{
5198
  boolean r = false;
5196
  boolean r = false;
5199
  neighbor_rec nb;
5197
  neighbor_rec nb;
5200
 
5198
 
5201
  memset (nb, 0, sizeof (neighbor_rec));
5199
  memset (nb, 0, sizeof (neighbor_rec));
5202
  if (!
5200
  if (!
5203
      (atom[a_view - 1].
5201
      (atom[a_view - 1].
5204
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5202
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5205
    return false;
5203
    return false;
5206
  if (strcmp (atom[a_ref - 1].atype, "S3 ")
5204
  if (strcmp (atom[a_ref - 1].atype, "S3 ")
5207
      || atom[a_ref - 1].neighbor_count != 2)
5205
      || atom[a_ref - 1].neighbor_count != 2)
5208
    return false;
5206
    return false;
5209
  get_nextneighbors (nb, a_ref, a_view);
5207
  get_nextneighbors (nb, a_ref, a_view);
5210
  if (is_aryl (a_ref, nb[0]))
5208
  if (is_aryl (a_ref, nb[0]))
5211
    r = true;
5209
    r = true;
5212
  return r;
5210
  return r;
5213
}
5211
}
5214
 
5212
 
5215
 
5213
 
5216
static boolean
5214
static boolean
5217
is_alkenylsulfanyl (a_view, a_ref)
5215
is_alkenylsulfanyl (a_view, a_ref)
5218
     int a_view, a_ref;
5216
     int a_view, a_ref;
5219
{
5217
{
Line 5239... Line 5237...
5239
static boolean
5237
static boolean
5240
is_alkynylsulfanyl (a_view, a_ref)
5238
is_alkynylsulfanyl (a_view, a_ref)
5241
     int a_view, a_ref;
5239
     int a_view, a_ref;
5242
{
5240
{
5243
  /* v0.3j */
5241
  /* v0.3j */
5244
  boolean r = false;
5242
  boolean r = false;
5245
  neighbor_rec nb;
5243
  neighbor_rec nb;
5246
 
5244
 
5247
  memset (nb, 0, sizeof (neighbor_rec));
5245
  memset (nb, 0, sizeof (neighbor_rec));
5248
  if (!
5246
  if (!
5249
      (atom[a_view - 1].
5247
      (atom[a_view - 1].
5250
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5248
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5251
    return false;
5249
    return false;
5252
  if (strcmp (atom[a_ref - 1].atype, "S3 ")
5250
  if (strcmp (atom[a_ref - 1].atype, "S3 ")
5253
      || atom[a_ref - 1].neighbor_count != 2)
5251
      || atom[a_ref - 1].neighbor_count != 2)
5254
    return false;
5252
    return false;
5255
  get_nextneighbors (nb, a_ref, a_view);
5253
  get_nextneighbors (nb, a_ref, a_view);
5256
  if (is_alkynyl (a_ref, nb[0]))
5254
  if (is_alkynyl (a_ref, nb[0]))
5257
    r = true;
5255
    r = true;
5258
  return r;
5256
  return r;
5259
}
5257
}
5260
 
5258
 
5261
 
5259
 
5262
static boolean
5260
static boolean
5263
is_alkylamino (a_view, a_ref)
5261
is_alkylamino (a_view, a_ref)
5264
     int a_view, a_ref;
5262
     int a_view, a_ref;
5265
{
5263
{
5266
  boolean r = false;
5264
  boolean r = false;
5267
  neighbor_rec nb;
5265
  neighbor_rec nb;
5268
  int alkyl_count = 0;
5266
  int alkyl_count = 0;
5269
 
5267
 
5270
  memset (nb, 0, sizeof (neighbor_rec));
5268
  memset (nb, 0, sizeof (neighbor_rec));
5271
  if (!
5269
  if (!
5272
      (atom[a_view - 1].
5270
      (atom[a_view - 1].
5273
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5271
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5274
    return false;
5272
    return false;
5275
  if (strcmp (atom[a_ref - 1].element, "N ")
5273
  if (strcmp (atom[a_ref - 1].element, "N ")
5276
      || atom[a_ref - 1].neighbor_count != 2)
5274
      || atom[a_ref - 1].neighbor_count != 2)
5277
    return false;
5275
    return false;
5278
  get_nextneighbors (nb, a_ref, a_view);
5276
  get_nextneighbors (nb, a_ref, a_view);
5279
  if (is_alkyl (a_ref, nb[0]))
5277
  if (is_alkyl (a_ref, nb[0]))
5280
    alkyl_count++;
5278
    alkyl_count++;
5281
  if (alkyl_count == 1)
5279
  if (alkyl_count == 1)
5282
    r = true;
5280
    r = true;
5283
  return r;
5281
  return r;
5284
}
5282
}
5285
 
5283
 
5286
 
5284
 
5287
static boolean
5285
static boolean
5288
is_dialkylamino (a_view, a_ref)
5286
is_dialkylamino (a_view, a_ref)
5289
     int a_view, a_ref;
5287
     int a_view, a_ref;
5290
{
5288
{
5291
  int i;
5289
  int i;
5292
  boolean r = false;
5290
  boolean r = false;
5293
  neighbor_rec nb;
5291
  neighbor_rec nb;
5294
  int alkyl_count = 0;
5292
  int alkyl_count = 0;
5295
 
5293
 
5296
  memset (nb, 0, sizeof (neighbor_rec));
5294
  memset (nb, 0, sizeof (neighbor_rec));
Line 5313... Line 5311...
5313
}
5311
}
5314
 
5312
 
5315
 
5313
 
5316
static boolean
5314
static boolean
5317
is_arylamino (a_view, a_ref)
5315
is_arylamino (a_view, a_ref)
5318
     int a_view, a_ref;
5316
     int a_view, a_ref;
5319
{
5317
{
5320
  boolean r = false;
5318
  boolean r = false;
5321
  neighbor_rec nb;
5319
  neighbor_rec nb;
5322
  int aryl_count = 0;
5320
  int aryl_count = 0;
5323
 
5321
 
5324
  memset (nb, 0, sizeof (neighbor_rec));
5322
  memset (nb, 0, sizeof (neighbor_rec));
5325
  if (!
5323
  if (!
5326
      (atom[a_view - 1].
5324
      (atom[a_view - 1].
5327
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5325
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5328
    return false;
5326
    return false;
Line 5331... Line 5329...
5331
    return false;
5329
    return false;
5332
  get_nextneighbors (nb, a_ref, a_view);
5330
  get_nextneighbors (nb, a_ref, a_view);
5333
  if (is_aryl (a_ref, nb[0]))
5331
  if (is_aryl (a_ref, nb[0]))
5334
    aryl_count++;
5332
    aryl_count++;
5335
  if (aryl_count == 1)
5333
  if (aryl_count == 1)
5336
    r = true;
5334
    r = true;
5337
  return r;
5335
  return r;
5338
}
5336
}
5339
 
5337
 
5340
 
5338
 
5341
static boolean
5339
static boolean
5342
is_diarylamino (a_view, a_ref)
5340
is_diarylamino (a_view, a_ref)
5343
     int a_view, a_ref;
5341
     int a_view, a_ref;
5344
{
5342
{
Line 5367... Line 5365...
5367
}
5365
}
5368
 
5366
 
5369
 
5367
 
5370
static boolean
5368
static boolean
5371
is_alkylarylamino (a_view, a_ref)
5369
is_alkylarylamino (a_view, a_ref)
5372
     int a_view, a_ref;
5370
     int a_view, a_ref;
5373
{
5371
{
5374
  int i;
5372
  int i;
5375
  boolean r = false;
5373
  boolean r = false;
5376
  neighbor_rec nb;
5374
  neighbor_rec nb;
5377
  int alkyl_count = 0, aryl_count = 0;
5375
  int alkyl_count = 0, aryl_count = 0;
5378
 
5376
 
5379
  memset (nb, 0, sizeof (neighbor_rec));
5377
  memset (nb, 0, sizeof (neighbor_rec));
5380
  if (!
5378
  if (!
5381
      (atom[a_view - 1].
5379
      (atom[a_view - 1].
5382
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5380
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5383
    return false;
5381
    return false;
5384
  if (strcmp (atom[a_ref - 1].element, "N ")
5382
  if (strcmp (atom[a_ref - 1].element, "N ")
Line 5391... Line 5389...
5391
        alkyl_count++;
5389
        alkyl_count++;
5392
      if (is_aryl (a_ref, nb[i]))
5390
      if (is_aryl (a_ref, nb[i]))
5393
        aryl_count++;
5391
        aryl_count++;
5394
    }
5392
    }
5395
  if (alkyl_count == 1 && aryl_count == 1)
5393
  if (alkyl_count == 1 && aryl_count == 1)
5396
    r = true;
5394
    r = true;
5397
  return r;
5395
  return r;
5398
}
5396
}
5399
 
5397
 
5400
 
5398
 
5401
static boolean
5399
static boolean
5402
is_C_monosubst_amino (a_view, a_ref)
5400
is_C_monosubst_amino (a_view, a_ref)
5403
     int a_view, a_ref;
5401
     int a_view, a_ref;
5404
{
5402
{
5405
  /* new in v0.3j */
5403
  /* new in v0.3j */
5406
  boolean r = false;
5404
  boolean r = false;
5407
  neighbor_rec nb;
5405
  neighbor_rec nb;
5408
  int c_count = 0;
5406
  int c_count = 0;
5409
 
5407
 
5410
  memset (nb, 0, sizeof (neighbor_rec));
5408
  memset (nb, 0, sizeof (neighbor_rec));
5411
  if (!
5409
  if (!
5412
      (atom[a_view - 1].
5410
      (atom[a_view - 1].
5413
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5411
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5414
    return false;
5412
    return false;
5415
  if ((strcmp (atom[a_ref - 1].atype, "N3 ")
5413
  if ((strcmp (atom[a_ref - 1].atype, "N3 ")
5416
      && strcmp (atom[a_ref - 1].atype, "NAM"))
5414
      && strcmp (atom[a_ref - 1].atype, "NAM"))
5417
      || atom[a_ref - 1].neighbor_count != 2)
5415
      || atom[a_ref - 1].neighbor_count != 2)
Line 5471... Line 5469...
5471
}
5469
}
5472
 
5470
 
5473
 
5471
 
5474
static boolean
5472
static boolean
5475
is_true_alkylamino (a_view, a_ref)
5473
is_true_alkylamino (a_view, a_ref)
5476
     int a_view, a_ref;
5474
     int a_view, a_ref;
5477
{
5475
{
5478
  boolean r = false;
5476
  boolean r = false;
5479
  neighbor_rec nb;
5477
  neighbor_rec nb;
5480
  int alkyl_count = 0;
5478
  int alkyl_count = 0;
5481
 
5479
 
5482
  memset (nb, 0, sizeof (neighbor_rec));
5480
  memset (nb, 0, sizeof (neighbor_rec));
5483
  if (!
5481
  if (!
Line 5503... Line 5501...
5503
{
5501
{
5504
  int i;
5502
  int i;
5505
  boolean r = false;
5503
  boolean r = false;
5506
  neighbor_rec nb;
5504
  neighbor_rec nb;
5507
  int alkyl_count = 0;
5505
  int alkyl_count = 0;
5508
 
5506
 
5509
  memset (nb, 0, sizeof (neighbor_rec));
5507
  memset (nb, 0, sizeof (neighbor_rec));
5510
  if (!
5508
  if (!
5511
      (atom[a_view - 1].
5509
      (atom[a_view - 1].
5512
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5510
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5513
    return false;
5511
    return false;
5514
  if ((strcmp (atom[a_ref - 1].atype, "N3 ")
5512
  if ((strcmp (atom[a_ref - 1].atype, "N3 ")
5515
      && strcmp (atom[a_ref - 1].atype, "N3+"))
5513
      && strcmp (atom[a_ref - 1].atype, "N3+"))
5516
      || atom[a_ref - 1].neighbor_count != 3)
5514
      || atom[a_ref - 1].neighbor_count != 3)
5517
    return false;
5515
    return false;
5518
  get_nextneighbors (nb, a_ref, a_view);
5516
  get_nextneighbors (nb, a_ref, a_view);
Line 5520... Line 5518...
5520
    {
5518
    {
5521
      if (is_true_alkyl (a_ref, nb[i]))
5519
      if (is_true_alkyl (a_ref, nb[i]))
5522
        alkyl_count++;
5520
        alkyl_count++;
5523
    }
5521
    }
5524
  if (alkyl_count == 2)
5522
  if (alkyl_count == 2)
5525
    r = true;
5523
    r = true;
5526
  return r;
5524
  return r;
5527
}
5525
}
5528
 
5526
 
5529
#if 0
5527
#if 0
5530
static boolean
5528
static boolean
5531
is_true_alkylarylamino (a_view, a_ref)
5529
is_true_alkylarylamino (a_view, a_ref)
5532
     int a_view, a_ref;
5530
     int a_view, a_ref;
5533
{
5531
{
5534
  int i;
5532
  int i;
5535
  boolean r = false;
5533
  boolean r = false;
5536
  neighbor_rec nb;
5534
  neighbor_rec nb;
5537
  int alkyl_count = 0, aryl_count = 0;
5535
  int alkyl_count = 0, aryl_count = 0;
5538
 
5536
 
5539
  memset (nb, 0, sizeof (neighbor_rec));
5537
  memset (nb, 0, sizeof (neighbor_rec));
5540
  if (!
5538
  if (!
5541
      (atom[a_view - 1].
5539
      (atom[a_view - 1].
5542
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5540
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5543
    return false;
5541
    return false;
5544
  if ((strcmp (atom[a_ref - 1].atype, "N3 ")
5542
  if ((strcmp (atom[a_ref - 1].atype, "N3 ")
5545
      && strcmp (atom[a_ref - 1].atype, "N3+"))
5543
      && strcmp (atom[a_ref - 1].atype, "N3+"))
5546
      || atom[a_ref - 1].neighbor_count != 3)
5544
      || atom[a_ref - 1].neighbor_count != 3)
5547
    return false;
5545
    return false;
5548
  get_nextneighbors (nb, a_ref, a_view);
5546
  get_nextneighbors (nb, a_ref, a_view);
Line 5566... Line 5564...
5566
  int i;
5564
  int i;
5567
  boolean r = false;
5565
  boolean r = false;
5568
  neighbor_rec nb;
5566
  neighbor_rec nb;
5569
  int oh_count = 0, het_count = 0;      /* v0.3k */
5567
  int oh_count = 0, het_count = 0;      /* v0.3k */
5570
  str2 nb_el;                   /* v0.3k */
5568
  str2 nb_el;                   /* v0.3k */
5571
  int FORLIM;
5569
  int FORLIM;
5572
 
5570
 
5573
  memset (nb, 0, sizeof (neighbor_rec));
5571
  memset (nb, 0, sizeof (neighbor_rec));
5574
  if (!
5572
  if (!
5575
      (atom[a_view - 1].
5573
      (atom[a_view - 1].
5576
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5574
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5577
    return false;
5575
    return false;
5578
  if (strcmp (atom[a_ref - 1].element, "N ")
5576
  if (strcmp (atom[a_ref - 1].element, "N ")
5579
      || atom[a_ref - 1].neighbor_count < 2)
5577
      || atom[a_ref - 1].neighbor_count < 2)
5580
    /* v0.3c */
5578
    /* v0.3c */
5581
    return false;
5579
    return false;
Line 5637... Line 5635...
5637
     int a_view, a_ref;
5635
     int a_view, a_ref;
5638
{
5636
{
5639
  boolean r = false;
5637
  boolean r = false;
5640
  neighbor_rec nb;
5638
  neighbor_rec nb;
5641
  int bond_count = 0, n1 = 0, n2 = 0, n3 = 0;
5639
  int bond_count = 0, n1 = 0, n2 = 0, n3 = 0;
5642
 
5640
 
5643
  if (!
5641
  if (!
5644
      (atom[a_view - 1].
5642
      (atom[a_view - 1].
5645
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5643
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5646
    return false;
5644
    return false;
5647
  if (strcmp (atom[a_ref - 1].element, "N ")
5645
  if (strcmp (atom[a_ref - 1].element, "N ")
5648
      || atom[a_ref - 1].neighbor_count != 2)
5646
      || atom[a_ref - 1].neighbor_count != 2)
5649
    return false;
5647
    return false;
5650
  n1 = a_ref;
5648
  n1 = a_ref;
5651
  memset (nb, 0, sizeof (neighbor_rec));
5649
  memset (nb, 0, sizeof (neighbor_rec));
5652
  get_nextneighbors (nb, n1, a_view);
5650
  get_nextneighbors (nb, n1, a_view);
5653
  if (!strcmp (atom[nb[0] - 1].element, "N "))
5651
  if (!strcmp (atom[nb[0] - 1].element, "N "))
5654
    {
5652
    {
5655
      n2 = nb[0];
5653
      n2 = nb[0];
5656
      if (bond[get_bond (n1, n2) - 1].btype == 'S')
5654
      if (bond[get_bond (n1, n2) - 1].btype == 'S')
5657
        bond_count++;
5655
        bond_count++;
5658
      if (bond[get_bond (n1, n2) - 1].btype == 'D')
5656
      if (bond[get_bond (n1, n2) - 1].btype == 'D')
5659
        bond_count += 2;
5657
        bond_count += 2;
5660
      if (bond[get_bond (n1, n2) - 1].btype == 'T')
5658
      if (bond[get_bond (n1, n2) - 1].btype == 'T')
5661
        bond_count += 3;
5659
        bond_count += 3;
5662
    }
5660
    }
5663
  if (n2 > 0 && atom[n2 - 1].neighbor_count == 2)
5661
  if (n2 > 0 && atom[n2 - 1].neighbor_count == 2)
5664
    {
5662
    {
Line 5687... Line 5685...
5687
     int a_view, a_ref;
5685
     int a_view, a_ref;
5688
{
5686
{
5689
  boolean r = false;
5687
  boolean r = false;
5690
  neighbor_rec nb;
5688
  neighbor_rec nb;
5691
  int bond_count = 0, chg_count = 0, n1 = 0, n2 = 0;
5689
  int bond_count = 0, chg_count = 0, n1 = 0, n2 = 0;
5692
 
5690
 
5693
  if (!
5691
  if (!
5694
      (atom[a_view - 1].
5692
      (atom[a_view - 1].
5695
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5693
       heavy && (bond[get_bond (a_view, a_ref) - 1].btype == 'S')))
5696
    return false;
5694
    return false;
5697
  if (strcmp (atom[a_ref - 1].element, "N ")
5695
  if (strcmp (atom[a_ref - 1].element, "N ")
Line 5719... Line 5717...
5719
}
5717
}
5720
 
5718
 
5721
 
5719
 
5722
static boolean
5720
static boolean
5723
is_hydroximino_C (id)
5721
is_hydroximino_C (id)
5724
     int id;
5722
     int id;
5725
{
5723
{
5726
  boolean Result;
-
 
5727
  int i;
5724
  int i;
5728
  boolean r = false;
5725
  boolean r = false;
5729
  neighbor_rec nb;
5726
  neighbor_rec nb;
5730
  int a_het = 0;
5727
  int a_het = 0;
5731
  int FORLIM;
5728
  int FORLIM;
5732
 
5729
 
5733
  memset (nb, 0, sizeof (neighbor_rec));
5730
  memset (nb, 0, sizeof (neighbor_rec));
5734
  if (id < 1 || id > n_atoms)
5731
  if (id < 1 || id > n_atoms)
5735
    return Result;
5732
    return false;
5736
  get_neighbors (nb, id);
5733
  get_neighbors (nb, id);
5737
  if (strcmp (atom[id - 1].element, "C ") || atom[id - 1].neighbor_count <= 0)
5734
  if (strcmp (atom[id - 1].element, "C ") || atom[id - 1].neighbor_count <= 0)
5738
    return false;
5735
    return false;
5739
  FORLIM = atom[id - 1].neighbor_count;
5736
  FORLIM = atom[id - 1].neighbor_count;
5740
  for (i = 0; i < FORLIM; i++)
5737
  for (i = 0; i < FORLIM; i++)
Line 5763... Line 5760...
5763
 
5760
 
5764
static boolean
5761
static boolean
5765
is_hydrazono_C (id)
5762
is_hydrazono_C (id)
5766
     int id;
5763
     int id;
5767
{
5764
{
5768
  boolean Result;
-
 
5769
  int i;
5765
  int i;
5770
  boolean r = false;
5766
  boolean r = false;
5771
  neighbor_rec nb;
5767
  neighbor_rec nb;
5772
  int a_het = 0;
5768
  int a_het = 0;
5773
  int FORLIM;
5769
  int FORLIM;
5774
 
5770
 
5775
  memset (nb, 0, sizeof (neighbor_rec));
5771
  memset (nb, 0, sizeof (neighbor_rec));
5776
  if (id < 1 || id > n_atoms)
5772
  if (id < 1 || id > n_atoms)
5777
    return Result;
5773
    return false;
5778
  get_neighbors (nb, id);
5774
  get_neighbors (nb, id);
5779
  if (strcmp (atom[id - 1].element, "C ") || atom[id - 1].neighbor_count <= 0)
5775
  if (strcmp (atom[id - 1].element, "C ") || atom[id - 1].neighbor_count <= 0)
5780
    return false;
5776
    return false;
5781
  FORLIM = atom[id - 1].neighbor_count;
5777
  FORLIM = atom[id - 1].neighbor_count;
5782
  for (i = 0; i < FORLIM; i++)
5778
  for (i = 0; i < FORLIM; i++)