Subversion Repositories wimsdev

Rev

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

Rev 14249 Rev 14626
Line 1037... Line 1037...
1037
  char *trimstr;
1037
  char *trimstr;
1038
{
1038
{
1039
  while (*trimstr != '\0' && (trimstr[0] == ' ' || trimstr[0] == TAB))
1039
  while (*trimstr != '\0' && (trimstr[0] == ' ' || trimstr[0] == TAB))
1040
    strdelete (trimstr, 1, 1);
1040
    strdelete (trimstr, 1, 1);
1041
}
1041
}
1042
 
-
 
1043
static int left_int (trimstr)
1042
/* left_int fixed by D. Bernardi (2020-02-01) */
1044
  char *trimstr;
1043
static int left_int (char *trimstr)
1045
{
1044
{
1046
  char numstr[256];
-
 
1047
  char auxstr[256];
1045
  char *s = trimstr;
1048
  int auxint = 0;
1046
  int r = 0;
1049
  char STR1[256];
1047
  int sg = 1;
1050
 
1048
 
1051
  strcpy (numstr, "-+0123456789");
-
 
1052
  *auxstr = '\0';
-
 
1053
  while (*trimstr != '\0' && (trimstr[0] == ' ' || trimstr[0] == TAB))
1049
  while (*s == ' ' || *s == '\t' || *s == '+' || *s == '-')
1054
    strdelete (trimstr, 1, 1);
1050
    {if (*s == '-') sg = -sg; s++;}
1055
  while ((*trimstr != '\0') &&
1051
  while (*s >= '0' && *s <= '9')
1056
    (strpos2 (numstr, (sprintf (STR1, "%c", trimstr[0]), STR1), 1) > 0)){
-
 
1057
    sprintf (auxstr + strlen (auxstr), "%c", trimstr[0]);
1052
    r = 10*r + *s++ - '0';
1058
    strdelete (trimstr, 1, 1);
1053
  while ((*trimstr++ = *s++)); /* gag! */
1059
  }
-
 
1060
  return auxint;
1054
  return sg * r;
1061
}
1055
}
1062
 
1056
 
1063
static int path_pos (int id, int *a_path)
1057
static int path_pos (int id, int *a_path)
1064
{
1058
{
1065
  int i = 0;
1059
  int i = 0;
Line 1108... Line 1102...
1108
  }
1102
  }
1109
}
1103
}
1110
 
1104
 
1111
#if 0
1105
#if 0
1112
static void set_atom_tags ()
1106
static void set_atom_tags ()
1113
{
1107
{
1114
  int i, FORLIM;
1108
  int i, FORLIM;
1115
 
1109
 
1116
  if (n_atoms > 0){
1110
  if (n_atoms > 0){
1117
    FORLIM = n_atoms;
1111
    FORLIM = n_atoms;
1118
    for (i = 0; i < FORLIM; i++)
1112
    for (i = 0; i < FORLIM; i++)
Line 1190... Line 1184...
1190
     ndl_atom[i].tag = true;
1184
     ndl_atom[i].tag = true;
1191
  }
1185
  }
1192
}
1186
}
1193
 
1187
 
1194
static int count_tagged_ndl_heavyatoms ()
1188
static int count_tagged_ndl_heavyatoms ()
1195
{
1189
{
1196
  int i;
1190
  int i;
1197
  int n = 0;
1191
  int n = 0;
1198
 
1192
 
1199
  if (ndl_n_atoms < 1)
1193
  if (ndl_n_atoms < 1)
1200
    return n;
1194
    return n;
1201
 
1195
 
1202
  for (i = 0; i < ndl_n_atoms; i++){
1196
  for (i = 0; i < ndl_n_atoms; i++){
1203
    if (ndl_atom[i].heavy && ndl_atom[i].tag)
1197
    if (ndl_atom[i].heavy && ndl_atom[i].tag)
1204
    n++;
1198
    n++;
1205
  }
1199
  }
1206
  return n;
1200
  return n;
1207
}
1201
}
1208
 
1202
 
1209
/*============================= geometry functions ========================== */
1203
/*============================= geometry functions ========================== */
1210
 
1204
 
1211
static double dist3d (p1, p2)
1205
static double dist3d (p1, p2)
1212
     p_3d p1, p2;
1206
     p_3d p1, p2;
Line 1216... Line 1210...
1216
  TEMP = p1.x - p2.x;
1210
  TEMP = p1.x - p2.x;
1217
  TEMP1 = p1.y - p2.y;
1211
  TEMP1 = p1.y - p2.y;
1218
  TEMP2 = p1.z - p2.z;
1212
  TEMP2 = p1.z - p2.z;
1219
  res = sqrt (TEMP * TEMP + TEMP1 * TEMP1 + TEMP2 * TEMP2);
1213
  res = sqrt (TEMP * TEMP + TEMP1 * TEMP1 + TEMP2 * TEMP2);
1220
  return res;
1214
  return res;
1221
}
1215
}
1222
 
1216
 
1223
/*
1217
/*
1224
function is_cis(p1,p2,p3,p4:p_3d):boolean;  (* new in v0.3d
1218
function is_cis(p1,p2,p3,p4:p_3d):boolean;  (* new in v0.3d
1225
var                         (* just a simple, distance-based estimation
1219
var                         (* just a simple, distance-based estimation
1226
  total_dist  : double;     (* instead of calculating the dihedral angle
1220
  total_dist  : double;     (* instead of calculating the dihedral angle
1227
  direct_dist : double;
1221
  direct_dist : double;
Line 1238... Line 1232...
1238
 
1232
 
1239
static p_3d subtract_3d (p1, p2)
1233
static p_3d subtract_3d (p1, p2)
1240
     p_3d p1, p2;
1234
     p_3d p1, p2;
1241
{
1235
{
1242
  p_3d p;
1236
  p_3d p;
1243
 
1237
 
1244
  p.x = p1.x - p2.x;
1238
  p.x = p1.x - p2.x;
1245
  p.y = p1.y - p2.y;
1239
  p.y = p1.y - p2.y;
1246
  p.z = p1.z - p2.z;
1240
  p.z = p1.z - p2.z;
1247
  return p;
1241
  return p;
1248
}
1242
}
1249
 
1243
 
1250
static p_3d add_3d (p1, p2)
1244
static p_3d add_3d (p1, p2)
1251
     p_3d p1, p2;
1245
     p_3d p1, p2;
1252
{
1246
{
1253
  p_3d p;
1247
  p_3d p;
1254
 
1248
 
1255
  p.x = p1.x + p2.x;
1249
  p.x = p1.x + p2.x;
1256
  p.y = p1.y + p2.y;
1250
  p.y = p1.y + p2.y;
1257
  p.z = p1.z + p2.z;
1251
  p.z = p1.z + p2.z;
1258
  return p;
1252
  return p;
1259
}
1253
}
1260
 
1254
 
1261
#if 0
1255
#if 0
1262
static void vec2origin (p1, p2)
1256
static void vec2origin (p1, p2)
1263
     p_3d *p1, *p2;
1257
     p_3d *p1, *p2;
1264
{
1258
{
1265
  p_3d p;
1259
  p_3d p;
1266
 
1260
 
1267
  p = subtract_3d (*p2, *p1);
1261
  p = subtract_3d (*p2, *p1);
1268
  *p2 = p;
1262
  *p2 = p;
1269
  p1->x = 0.0;
1263
  p1->x = 0.0;
1270
  p1->y = 0.0;
1264
  p1->y = 0.0;
1271
  p1->z = 0.0;
1265
  p1->z = 0.0;
1272
}
1266
}
1273
#endif
1267
#endif
1274
 
1268
 
1275
static double scalar_prod (p1, p2, p3)
1269
static double scalar_prod (p1, p2, p3)
1276
     p_3d p1, p2, p3;
1270
     p_3d p1, p2, p3;
1277
{
1271
{
1278
  p_3d p;
1272
  p_3d p;
1279
  double res;
1273
  double res;
1280
 
1274
 
1281
  p = subtract_3d (p2, p1);
1275
  p = subtract_3d (p2, p1);
Line 1925... Line 1919...
1925
              (strcmp (strsub (STR6, rline, 20, 5), "BONDS") == 0) &&
1919
              (strcmp (strsub (STR6, rline, 20, 5), "BONDS") == 0) &&
1926
              (strcmp (strsub (STR7, rline, 33, 7), "CHARGES") == 0))
1920
              (strcmp (strsub (STR7, rline, 33, 7), "CHARGES") == 0))
1927
            strcpy (auxstr, "alchemy");
1921
            strcpy (auxstr, "alchemy");
1928
    if ((i == li + 3) && (strcmp (strsub (STR1, rline, 35, 5), "V2000") == 0))
1922
    if ((i == li + 3) && (strcmp (strsub (STR1, rline, 35, 5), "V2000") == 0))
1929
            /* and (copy(rline,31,3)='999') */
1923
            /* and (copy(rline,31,3)='999') */
1930
            mdl1 = true;
1924
            mdl1 = true;
1931
    if ((i == li + 1) && (strcmp (strsub (STR1, rline, 3, 6), "-ISIS-") == 0))
1925
    if ((i == li + 1) && (strcmp (strsub (STR1, rline, 3, 6), "-ISIS-") == 0))
1932
            mdl1 = true;
1926
            mdl1 = true;
1933
    if ((i == li + 1) && (strcmp (strsub (STR1, rline, 3, 8), "WLViewer") == 0))
1927
    if ((i == li + 1) && (strcmp (strsub (STR1, rline, 3, 8), "WLViewer") == 0))
1934
            mdl1 = true;
1928
            mdl1 = true;
1935
    if ((i == li + 1) && (strcmp (strsub (STR1, rline, 3, 8), "CheckMol") == 0))
1929
    if ((i == li + 1) && (strcmp (strsub (STR1, rline, 3, 8), "CheckMol") == 0))
Line 2032... Line 2026...
2032
  tmp_n_rings = 0;
2026
  tmp_n_rings = 0;
2033
}
2027
}
2034
#endif
2028
#endif
2035
 
2029
 
2036
static boolean is_heavyatom (id)
2030
static boolean is_heavyatom (id)
2037
     int id;
2031
     int id;
2038
{
2032
{
2039
  str2 el;
2033
  str2 el;
2040
 
2034
 
2041
  strcpy (el, atom[id - 1].element);
2035
  strcpy (el, atom[id - 1].element);
2042
 
2036
 
2043
  if (!strcmp (el, "DU") || !strcmp (el, "LP"))
2037
  if (!strcmp (el, "DU") || !strcmp (el, "LP"))
2044
    return false;
2038
    return false;
2045
  /*if (progmode == pmCheckMol && !strcmp (el, "H ")
2039
  /*if (progmode == pmCheckMol && !strcmp (el, "H ")
2046
     && atom[id - 1].nucleon_number < 2)
2040
     && atom[id - 1].nucleon_number < 2)
2047
     return false;               0.3x  */
2041
     return false;               0.3x  */
Line 2061... Line 2055...
2061
     int ba;
2055
     int ba;
2062
{
2056
{
2063
  /* new in v0.3f */
2057
  /* new in v0.3f */
2064
  boolean res = false;
2058
  boolean res = false;
2065
  int i, ba2, FORLIM;
2059
  int i, ba2, FORLIM;
2066
 
2060
 
2067
  if (ndl_n_atoms <= 0 || ndl_n_bonds <= 0)
2061
  if (ndl_n_atoms <= 0 || ndl_n_bonds <= 0)
2068
    return false;
2062
    return false;
2069
  FORLIM = ndl_n_bonds;
2063
  FORLIM = ndl_n_bonds;
2070
  for (i = 0; i < FORLIM; i++) {
2064
  for (i = 0; i < FORLIM; i++) {
2071
    if (ndl_bond[i].a1 == ba || ndl_bond[i].a2 == ba) {
2065
    if (ndl_bond[i].a1 == ba || ndl_bond[i].a2 == ba) {
Line 2143... Line 2137...
2143
  if (!strcmp (a_el, "AT"))
2137
  if (!strcmp (a_el, "AT"))
2144
    res = 1;
2138
    res = 1;
2145
  if (!strcmp (a_el, "B "))
2139
  if (!strcmp (a_el, "B "))
2146
    res = 3;
2140
    res = 3;
2147
  if (!strcmp (a_el, "LI"))
2141
  if (!strcmp (a_el, "LI"))
2148
    res = 1;
2142
    res = 1;
2149
  if (!strcmp (a_el, "NA"))
2143
  if (!strcmp (a_el, "NA"))
2150
    res = 1;
2144
    res = 1;
2151
  if (!strcmp (a_el, "K "))
2145
  if (!strcmp (a_el, "K "))
2152
    res = 1;
2146
    res = 1;
2153
  if (!strcmp (a_el, "CA"))
2147
  if (!strcmp (a_el, "CA"))
Line 2578... Line 2572...
2578
    strcpy (rline, molbuf[ri - 1]);
2572
    strcpy (rline, molbuf[ri - 1]);
2579
    strsub (a1str, rline, 9, 3);
2573
    strsub (a1str, rline, 9, 3);
2580
    strsub (a2str, rline, 15, 3);
2574
    strsub (a2str, rline, 15, 3);
2581
    (void)sscanf(a1str, "%d", &a1val);
2575
    (void)sscanf(a1str, "%d", &a1val);
2582
    (void)sscanf(a2str, "%d", &a2val);
2576
    (void)sscanf(a2str, "%d", &a2val);
2583
    WITH1 = &bond[n];
2577
    WITH1 = &bond[n];
2584
    WITH1->a1 = a1val;
2578
    WITH1->a1 = a1val;
2585
    WITH1->a2 = a2val;
2579
    WITH1->a2 = a2val;
2586
    WITH1->btype = rline[19];
2580
    WITH1->btype = rline[19];
2587
    WITH1->ring_count = 0;
2581
    WITH1->ring_count = 0;
2588
    WITH1->arom = false;
2582
    WITH1->arom = false;
2589
    WITH1->topo = btopo_any;
2583
    WITH1->topo = btopo_any;
Line 2778... Line 2772...
2778
    * Note: Turbo Pascal conditional compilation directive was ignored [218] */
2772
    * Note: Turbo Pascal conditional compilation directive was ignored [218] */
2779
  /*$IFDEF debug */
2773
  /*$IFDEF debug */
2780
  /*if (n_chrg == 0)
2774
  /*if (n_chrg == 0)
2781
     debugoutput ("strange... M  CHG present, but no charges found"); */
2775
     debugoutput ("strange... M  CHG present, but no charges found"); */
2782
  /*$ENDIF */
2776
  /*$ENDIF */
-
 
2777
  left_int (chgstring); /* delete the first one, that is the number of atoms */
2783
  while (*chgstring != '\0') {
2778
  while (*chgstring != '\0') {
2784
    a_id = left_int (chgstring);
2779
    a_id = left_int (chgstring);
2785
    a_chg = left_int (chgstring);
2780
    a_chg = left_int (chgstring);
2786
    if (a_id != 0 && a_chg != 0)
2781
    if (a_id != 0 && a_chg != 0)
2787
          atom[a_id - 1].formal_charge = a_chg;
2782
            atom[a_id - 1].formal_charge = a_chg;
2788
      //printf ("CHG %i %i\n", a_id, a_chg);
2783
          //printf ("CHG %i %i\n", a_id, a_chg);
2789
  }
2784
  }
2790
}
2785
}
2791
 
2786
 
2792
static void read_isotopes (char *isotopestring_)
2787
static void read_isotopes (char *isotopestring_)
2793
{
2788
{
Line 2800... Line 2795...
2800
  strcpy (isotopestring, isotopestring_);
2795
  strcpy (isotopestring, isotopestring_);
2801
  if (strpos2 (isotopestring, "M  ISO", 1) <= 0)
2796
  if (strpos2 (isotopestring, "M  ISO", 1) <= 0)
2802
    return;
2797
    return;
2803
  strdelete (isotopestring, 1, 6);
2798
  strdelete (isotopestring, 1, 6);
2804
  left_trim (isotopestring);
2799
  left_trim (isotopestring);
2805
  /*n_isotopes = left_int (isotopestring);*/
2800
  left_int (isotopestring);
2806
  /* this assignment must be kept also in non-debug mode! */
-
 
2807
  /* p2c: checkmol.pas, line 2077:
-
 
2808
  * Note: Turbo Pascal conditional compilation directive was ignored [218] */
-
 
2809
  /*$IFDEF debug */
-
 
2810
  /*if (n_chrg == 0)
-
 
2811
     debugoutput ("strange... M  CHG present, but no charges found"); */
-
 
2812
  /*$ENDIF */
-
 
2813
  while (*isotopestring != '\0') {
2801
  while (*isotopestring != '\0') {
2814
    a_id = left_int (isotopestring);
2802
    a_id = left_int (isotopestring);
2815
    a_nucleon_number = left_int (isotopestring);
2803
    a_nucleon_number = left_int (isotopestring);
2816
    if (a_id != 0 && a_nucleon_number != 0) {
2804
    if (a_id != 0 && a_nucleon_number != 0) {
2817
            atom[a_id - 1].nucleon_number = a_nucleon_number;
2805
            atom[a_id - 1].nucleon_number = a_nucleon_number;
Line 2819... Line 2807...
2819
              atom[a_id - 1].heavy = true;
2807
              atom[a_id - 1].heavy = true;
2820
              n_heavyatoms++;
2808
              n_heavyatoms++;
2821
              strcpy (atom[a_id - 1].atype, "DU ");
2809
              strcpy (atom[a_id - 1].atype, "DU ");
2822
            }
2810
            }
2823
          }
2811
          }
2824
      //printf ("ISO %i %i\n", a_id, a_nucleon_number);
2812
    //printf ("ISO %i, %i\n", a_id, a_nucleon_number);
2825
  }
2813
  }
2826
}
2814
}
2827
 
2815
 
2828
static void read_radicals (radstring_)
2816
static void read_radicals (radstring_)
2829
     char *radstring_;
2817
     char *radstring_;
Line 2836... Line 2824...
2836
  strcpy (radstring, radstring_);
2824
  strcpy (radstring, radstring_);
2837
  if (strpos2 (radstring, "M  RAD", 1) <= 0)
2825
  if (strpos2 (radstring, "M  RAD", 1) <= 0)
2838
    return;
2826
    return;
2839
  strdelete (radstring, 1, 6);
2827
  strdelete (radstring, 1, 6);
2840
  left_trim (radstring);
2828
  left_trim (radstring);
2841
  (void)left_int (radstring);
2829
  left_int (radstring);
2842
  /* this assignment must be kept also in non-debug mode! */
2830
  /* this assignment must be kept also in non-debug mode! */
2843
  /* p2c: checkmol.pas, line 2077:
2831
  /* p2c: checkmol.pas, line 2077:
2844
    * Note: Turbo Pascal conditional compilation directive was ignored [218] */
2832
    * Note: Turbo Pascal conditional compilation directive was ignored [218] */
2845
  /*$IFDEF debug */
2833
  /*$IFDEF debug */
2846
  /*if (n_chrg == 0)
2834
  /*if (n_chrg == 0)