00001
00002 #include "../headers/pertable.h"
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062 static const int ST_nelem = 112 ;
00063
00064 static const char *ST_pte_symbol[] = {
00065 "X", "H", "He", "Li", "Be", "B", "C", "N", "O", "F", "Ne",
00066 "Na", "Mg", "Al", "Si", "P" , "S", "Cl", "Ar", "K", "Ca", "Sc",
00067 "Ti", "V", "Cr", "Mn", "Fe", "Co", "Ni", "Cu", "Zn", "Ga", "Ge",
00068 "As", "Se", "Br", "Kr", "Rb", "Sr", "Y", "Zr", "Nb", "Mo", "Tc",
00069 "Ru", "Rh", "Pd", "Ag", "Cd", "In", "Sn", "Sb", "Te", "I", "Xe",
00070 "Cs", "Ba", "La", "Ce", "Pr", "Nd", "Pm", "Sm", "Eu", "Gd", "Tb",
00071 "Dy", "Ho", "Er", "Tm", "Yb", "Lu", "Hf", "Ta", "W", "Re", "Os",
00072 "Ir", "Pt", "Au", "Hg", "Tl", "Pb", "Bi", "Po", "At", "Rn", "Fr",
00073 "Ra", "Ac", "Th", "Pa", "U", "Np", "Pu", "Am", "Cm", "Bk", "Cf",
00074 "Es", "Fm", "Md", "No", "Lr", "Rf", "Db", "Sg", "Bh", "Hs", "Mt",
00075 "Ds", "Rg"
00076 } ;
00077
00078
00079 static const int ST_prot_nelem = 5 ;
00080 static const char *ST_pte_prot_symbol[] = {
00081 "H", "C", "N", "O", "S"
00082 } ;
00083
00084 static const int ST_nucl_acid_nelem = 5 ;
00085 static const char *ST_pte_nucl_acid_symbol[] = {
00086 "H", "C", "N", "O", "P"
00087 } ;
00088
00089 static const int ST_n_standard_res_names = 23;
00090 static const char *ST_standard_res_names [] = {
00091 "GLY", "LEU", "ILE", "TRP", "MET", "SER", "THR", "LYS", "ARG", "ASN",
00092 "GLN", "GLU", "ASP", "CYS", "PRO", "HIS", "TYR", "PHE", "VAL", "ALA",
00093 "HIE", "HID", "HIP", "HSD", "HSE", "HSP"
00094 } ;
00095
00096 static const int ST_n_standard_nucl_acid_names = 9;
00097 static const char *ST_standard_nucl_acid_names [] = {
00098 "dG","dC", "dT","dA","A","C","T","G","U"
00099 } ;
00100
00101
00102 static const float ST_pte_electronegativity[] = {
00103 0.0, 2.1, 0.98, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, -1.0,
00104 0.9, 1.2, 1.5, 1.8, 2.1, 2.5, 3.0, -1.0, 0.8, 1.0, 1.3,
00105 1.5, 1.6, 1.6, 1.5, 1.8, 1.8, 1.9, 1.9, 1.6, 1.8, 2.0,
00106 2.2, 2.4, 2.9, -1.0, 0.8, 1.0, 1.2, 1.3, 1.6, 2.0, 1.9,
00107 2.2, 2.2, 2.3, 1.9, 1.7, 1.7, 1.8, 2.0, 2.1, 2.6, 2.6,
00108 0.8, 0.9, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0,
00109 -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, 1.3, 1.5, 1.7, 1.9, 2.2,
00110 2.2, 2.2, 2.4, 1.9, 1.8, 1.8, 1.9, 2.0, 2.2, -1.0, 0.7,
00111 0.9, 1.1, 1.3, 1.5, 1.7, 1.3, 1.3, 1.3, 1.3, 1.3, 1.3,
00112 1.3, 1.3, 1.3, 1.3, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0,
00113 -1.0, -1.0
00114 } ;
00115
00116 static const float ST_pte_mass[] = {
00117 0.00000, 1.00794, 4.00260, 6.941, 9.012182, 10.811,
00118 12.0107, 14.0067, 15.9994, 18.9984032, 20.1797,
00119 22.989770, 24.3050, 26.981538, 28.0855, 30.973761,
00120 32.065, 35.453, 39.948, 39.0983, 40.078, 44.955910,
00121 47.867, 50.9415, 51.9961, 54.938049, 55.845, 58.9332,
00122 58.6934, 63.546, 65.409, 69.723, 72.64, 74.92160,
00123 78.96, 79.904, 83.798, 85.4678, 87.62, 88.90585,
00124 91.224, 92.90638, 95.94, 98.0, 101.07, 102.90550,
00125 106.42, 107.8682, 112.411, 114.818, 118.710, 121.760,
00126 127.60, 126.90447, 131.293, 132.90545, 137.327,
00127 138.9055, 140.116, 140.90765, 144.24, 145.0, 150.36,
00128 151.964, 157.25, 158.92534, 162.500, 164.93032,
00129 167.259, 168.93421, 173.04, 174.967, 178.49, 180.9479,
00130 183.84, 186.207, 190.23, 192.217, 195.078, 196.96655,
00131 200.59, 204.3833, 207.2, 208.98038, 209.0, 210.0, 222.0,
00132 223.0, 226.0, 227.0, 232.0381, 231.03588, 238.02891,
00133 237.0, 244.0, 243.0, 247.0, 247.0, 251.0, 252.0, 257.0,
00134 258.0, 259.0, 262.0, 261.0, 262.0, 266.0, 264.0, 269.0,
00135 268.0, 271.0, 272.0
00136 };
00137
00138
00139
00140
00141
00142 static const float ST_pte_rvdw[] = {
00143 1.5, 1.2, 1.4, 1.82, 2.0, 2.0,
00144 1.7, 1.55, 1.52, 1.47, 1.54,
00145 2.27, 1.73, 2.0, 2.1, 1.8,
00146 1.8, 1.75, 1.88, 2.75, 2.0, 2.0,
00147 2.0, 2.0, 2.0, 2.0, 2.0, 2.0,
00148 1.63, 1.4, 1.39, 1.07, 2.0, 1.85,
00149 1.9, 1.85, 2.02, 2.0, 2.0, 2.0,
00150 2.0, 2.0, 2.0, 2.0, 2.0, 2.0,
00151 1.63, 1.72, 1.58, 1.93, 2.17, 2.0,
00152 2.06, 1.98, 2.16, 2.0, 2.0,
00153 2.0, 2.0, 2.0, 2.0, 2.0, 2.0,
00154 2.0, 2.0, 2.0, 2.0, 2.0,
00155 2.0, 2.0, 2.0, 2.0, 2.0, 2.0,
00156 2.0, 2.0, 2.0, 2.0, 1.72, 1.66,
00157 1.55, 1.96, 2.02, 2.0, 2.0, 2.0, 2.0,
00158 2.0, 2.0, 2.0, 2.0, 2.0, 1.86,
00159 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0,
00160 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0,
00161 2.0, 2.0, 2.0
00162 };
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178 float pte_get_mass(const char *symbol)
00179 {
00180 char atom[3] ;
00181 if (symbol != NULL) {
00182 atom[0] = (char) toupper((int) symbol[0]);
00183 atom[1] = (char) tolower((int) symbol[1]);
00184 atom[2] = '\0' ;
00185
00186 int i ;
00187 for (i = 0; i < ST_nelem ; i++) {
00188 if ( (ST_pte_symbol[i][0] == atom[0]) && (ST_pte_symbol[i][1] == atom[1]) ) {
00189
00190 return ST_pte_mass[i] ;
00191 }
00192 }
00193 }
00194
00195
00196 return -1 ;
00197 }
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213 float pte_get_vdw_ray(const char *symbol)
00214 {
00215 char atom[3] ;
00216
00217 if (symbol != NULL) {
00218 atom[0] = (char) toupper((int) symbol[0]);
00219 atom[1] = (char) tolower((int) symbol[1]);
00220 atom[2] = '\0' ;
00221
00222 int i ;
00223 for (i = 0; i < ST_nelem ; i++) {
00224 if ( (ST_pte_symbol[i][0] == atom[0]) && (ST_pte_symbol[i][1] == atom[1]) ) {
00225 return ST_pte_rvdw[i] ;
00226 }
00227 }
00228 }
00229
00230 return -1 ;
00231 }
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247 float pte_get_enegativity(const char *symbol)
00248 {
00249 char atom[3] = "" ;
00250
00251 if (symbol != NULL) {
00252 atom[0] = (char) toupper((int) symbol[0]);
00253 atom[1] = (char) tolower((int) symbol[1]);
00254 atom[2] = '\0' ;
00255
00256 int i ;
00257 for (i = 0; i < ST_nelem ; i++) {
00258 if ( (ST_pte_symbol[i][0] == atom[0]) && (ST_pte_symbol[i][1] == atom[1]) ) {
00259 return ST_pte_electronegativity[i] ;
00260 }
00261 }
00262 }
00263
00264 return -1 ;
00265 }
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282 int is_valid_element(const char *str, int ignore_case)
00283 {
00284 if(str == NULL) return -1 ;
00285 if(strlen(str) <= 0) return -1 ;
00286
00287
00288 int i ;
00289 char str_tmp[strlen(str)+1] ;
00290 strcpy(str_tmp, str) ;
00291
00292
00293 str_trim(str_tmp) ;
00294 if(ignore_case == 1) {
00295 str_tmp[0] = tolower(str_tmp[0]) ;
00296 str_tmp[1] = tolower(str_tmp[1]) ;
00297 }
00298
00299
00300 for (i = 0; i < ST_nelem ; i++) {
00301 char tmp[3] ;
00302 tmp[0] = ST_pte_symbol[i][0] ;
00303 tmp[1] = ST_pte_symbol[i][1] ;
00304
00305
00306 if(ignore_case == 1) {
00307 tmp[0] = tolower(tmp[0]) ;
00308 tmp[1] = tolower(tmp[1]) ;
00309 }
00310 tmp[2] = '\0' ;
00311
00312
00313 if(strcmp(str_tmp, tmp) == 0) return i ;
00314 }
00315
00316 return -1 ;
00317 }
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333 int element_in_std_res(char *res_name){
00334 int i;
00335 for(i=0;i<ST_n_standard_res_names;i++){
00336 if(!strncmp(res_name, ST_standard_res_names[i],3)) return 1;
00337 }
00338 return 0;
00339 }
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355 int element_in_nucl_acid(char *res_name){
00356 int i;
00357 for(i=0;i<ST_n_standard_nucl_acid_names;i++){
00358 if(!strncmp(res_name, ST_standard_nucl_acid_names[i],3)) return 1;
00359 }
00360 return 0;
00361 }
00362
00363 int is_water(char *res_name){
00364 if(!strncmp(res_name, "HOH",3)||!strncmp(res_name, "WAT",3)) return 1;
00365 return 0;
00366 }
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384 int is_valid_prot_element(const char *str, int ignore_case)
00385 {
00386 if(str == NULL) return -1 ;
00387 if(strlen(str) <= 0) return -1 ;
00388
00389 int i ;
00390 char str_tmp[strlen(str)+1] ;
00391 strcpy(str_tmp, str) ;
00392
00393
00394
00395 str_trim(str_tmp) ;
00396 if(ignore_case == 1) {
00397 str_tmp[0] = tolower(str_tmp[0]) ;
00398 str_tmp[1] = tolower(str_tmp[1]) ;
00399 }
00400
00401
00402 for (i = 0; i < ST_prot_nelem ; i++) {
00403 char tmp[3] ;
00404 tmp[0] = ST_pte_prot_symbol[i][0] ;
00405 tmp[1] = ST_pte_prot_symbol[i][1] ;
00406
00407
00408 if(ignore_case == 1) {
00409 tmp[0] = tolower(tmp[0]) ;
00410 tmp[1] = tolower(tmp[1]) ;
00411 }
00412 tmp[2] = '\0' ;
00413
00414
00415 if(strncmp(str_tmp, tmp,1) == 0) return i ;
00416 }
00417
00418 return -1 ;
00419 }
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437 int is_valid_nucl_acid_element(const char *str, int ignore_case)
00438 {
00439 if(str == NULL) return -1 ;
00440 if(strlen(str) <= 0) return -1 ;
00441
00442 int i ;
00443 char str_tmp[strlen(str)+1] ;
00444 strcpy(str_tmp, str) ;
00445
00446
00447
00448 str_trim(str_tmp) ;
00449 if(ignore_case == 1) {
00450 str_tmp[0] = tolower(str_tmp[0]) ;
00451 str_tmp[1] = tolower(str_tmp[1]) ;
00452 }
00453
00454
00455 for (i = 0; i < ST_nucl_acid_nelem ; i++) {
00456 char tmp[3] ;
00457 tmp[0] = ST_pte_nucl_acid_symbol[i][0] ;
00458 tmp[1] = ST_pte_nucl_acid_symbol[i][1] ;
00459
00460
00461 if(ignore_case == 1) {
00462 tmp[0] = tolower(tmp[0]) ;
00463 tmp[1] = tolower(tmp[1]) ;
00464 }
00465 tmp[2] = '\0' ;
00466
00467
00468 if(strncmp(str_tmp, tmp,1) == 0) return i ;
00469 }
00470
00471 return -1 ;
00472 }
00473
00474