#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "atom.h"
#include "pertable.h"
#include "utils.h"
#include "memhandler.h"
Go to the source code of this file.
Data Structures | |
struct | s_pdb |
Defines | |
#define | M_PDB_LINE_LEN 80 |
#define | M_PDB_BUF_LEN 83 |
#define | M_KEEP_LIG 1 |
#define | M_DONT_KEEP_LIG 0 |
#define | M_PDB_HEADER 1 |
#define | M_PDB_REMARK 2 |
#define | M_PDB_ATOM 3 |
#define | M_PDB_CONECT 4 |
#define | M_PDB_HETATM 5 |
#define | M_PDB_CRYST1 6 |
#define | M_PDB_EOF 7 |
#define | M_PDB_END 8 |
#define | M_PDB_UNKNOWN 9 |
Functions | |
s_pdb * | rpdb_open (char *fpath, const char *ligan, const int keep_lig) |
void | rpdb_read (s_pdb *pdb, const char *ligan, const int keep_lig) |
void | rpdb_extract_atm_resname (char *pdb_line, char *res_name) |
int | element_in_kept_res (char *res_name) |
void | guess_element (char *aname, char *element, char *res_name) |
void | rpdb_extract_cryst1 (char *rstr, float *alpha, float *beta, float *gamma, float *a, float *b, float *c) |
void | rpdb_extract_atom_values (char *pdb_line, float *x, float *y, float *z, float *occ, float *beta) |
void | rpdb_extract_pdb_atom (char *pdb_line, char *type, int *atm_id, char *name, char *alt_loc, char *res_name, char *chain, int *res_id, char *insert, float *x, float *y, float *z, float *occ, float *bfactor, char *symbol, int *charge, int *guess_flag) |
void | free_pdb_atoms (s_pdb *pdb) |
#define M_DONT_KEEP_LIG 0 |
Don't keep ligand flag
Definition at line 50 of file rpdb.h.
Referenced by check_fpocket(), desc_pocket(), mdpocket_characterize(), mdpocket_detect(), mdprocess_pdb(), open_pdb_file(), process_pdb(), and test_set().
#define M_KEEP_LIG 1 |
Keep ligand flag
Definition at line 49 of file rpdb.h.
Referenced by check_fpocket(), desc_pocket(), process_pdb(), and test_set().
#define M_PDB_BUF_LEN 83 |
size need to buffer + CR, LF, and NUL
Definition at line 47 of file rpdb.h.
Referenced by rpdb_open(), and rpdb_read().
#define M_PDB_LINE_LEN 80 |
actual record size
Definition at line 46 of file rpdb.h.
Referenced by rpdb_open(), and rpdb_read().
int element_in_kept_res | ( | char * | res_name | ) |
Definition at line 189 of file rpdb.c.
References ST_keep_hetatm, and ST_nb_keep_hetatm.
Referenced by set_atom_based_descriptors(), and set_pocket_contacted_lig_name().
00189 { 00190 int i; 00191 for(i=0;i<ST_nb_keep_hetatm;i++){ 00192 if(!strncmp(res_name, ST_keep_hetatm[i],3)) return 1; 00193 } 00194 return 0; 00195 }
void free_pdb_atoms | ( | s_pdb * | pdb | ) |
## FUNCTION: free_pdb_atoms
## SPECIFICATION: Free memory for s_pdb structure
## PARAMETRES: @ s_pdb *pdb: pdb struct to free
## RETURN: void
Definition at line 794 of file rpdb.c.
References s_pdb::fpdb, s_pdb::latm_lig, s_pdb::latoms, s_pdb::latoms_p, s_pdb::lhetatm, and my_free().
Referenced by desc_pocket(), mdpocket_characterize(), mdpocket_detect(), and test_set().
00795 { 00796 if(pdb) { 00797 if(pdb->lhetatm) { 00798 my_free(pdb->lhetatm) ; 00799 pdb->lhetatm = NULL ; 00800 } 00801 00802 if(pdb->latoms) { 00803 my_free(pdb->latoms) ; 00804 pdb->latoms = NULL ; 00805 } 00806 if(pdb->latm_lig) { 00807 my_free(pdb->latm_lig) ; 00808 pdb->latm_lig = NULL ; 00809 } 00810 if(pdb->fpdb) { 00811 fclose(pdb->fpdb) ; 00812 pdb->fpdb = NULL ; 00813 } 00814 00815 if(pdb->latoms_p) { 00816 my_free(pdb->latoms_p) ; 00817 pdb->latoms_p = NULL ; 00818 } 00819 00820 my_free(pdb) ; 00821 } 00822 }
void guess_element | ( | char * | aname, | |
char * | element, | |||
char * | res_name | |||
) |
## FUNCTION: guess_element
## SPECIFICATION: Guess the element of the atom based on atom name. The pattern matched here have been taken from the MOE PDB reader.
' CL#' => Chlorine (use El field if it matches ' @?' && HETATAM) CH2T from CT !!! => what not
const AtomPatterns = [ N:'[A-G,I-L,N-Z]N#*', O:['[A-B,D-G,I-L,N-Z]O*','OP[A-C]#','CO[A-Z,0-9]*','OE##'], P:'[A-G,I-K,M-N,P-Z]P*', C:['[A-G,I-Z]C#*','C[B-G,I-K,M,P-T,V-Z]#*','CH#', 'BC '], H:['H[0-9,A-E,H-Z]*','#[0-9,A-Z]H*','?H[A-Z,0-9]*', 'HG##'], CL:'CL#', // check this S:'[P,N]S#*', SE:'NSE1' ];
## PARAMETRES: @ char *atom_name : The atom name @ char *res_name : OUTPUT the element guessed
## RETURN: void (element is the output)
Definition at line 228 of file rpdb.c.
References element_in_nucl_acid(), element_in_std_res(), is_valid_element(), is_valid_nucl_acid_element(), is_valid_prot_element(), and str_trim().
Referenced by rpdb_extract_pdb_atom().
00229 { 00230 /* Use a temporary variable for atomname, mainly to remove spaces */ 00231 char tmp[strlen(aname)+1] ; 00232 strcpy(tmp, aname) ; 00233 00234 str_trim(tmp) ; 00235 char *ptmp = tmp ; 00236 00237 /* Move to the second caracter if we find a number */ 00238 if(isdigit(tmp[0])) ptmp = ptmp+1 ; 00239 00240 if(element_in_std_res(res_name)){ 00241 /* Check if its a valid element for standard residues in proteins */ 00242 00243 int index = is_valid_prot_element(ptmp, 1) ; 00244 if(index != -1) { 00245 element[0] = ptmp[0]; 00246 element[1] = '\0'; 00247 //element[2] = '\0'; 00248 return ; 00249 } 00250 } 00251 else if(element_in_nucl_acid(res_name)) { 00252 int index = is_valid_nucl_acid_element(ptmp, 1) ; 00253 if(index != -1) { 00254 element[0] = ptmp[0]; 00255 element[1] = '\0'; 00256 //element[2] = '\0'; 00257 return ; 00258 } 00259 } 00260 else { 00261 int index = is_valid_element(ptmp, 1) ; 00262 if(index != -1) { 00263 strcpy(element,ptmp); 00264 return ; 00265 } 00266 } 00267 /* Here we have a special case... So take the first and second */ 00268 element[0] = ptmp[0]; 00269 element[1] = ptmp[1]; 00270 element[2] = '\0'; 00271 }
void rpdb_extract_atm_resname | ( | char * | pdb_line, | |
char * | res_name | |||
) |
## FUNCTION: rpdb_extract_atm_resname
## SPECIFICATION: Extract the residu name for an ATOM or HETATM pdb record. To remember:
COLUMNS DATA TYPE FIELD DEFINITION
18 - 20 Residue name resName Residue name.
The memory to store the name has to be provided by the user.
## PARAMETRES: @ char *pdb_line : The PDB line containings info @ char *res_name : Pointer to residue name
## RETURN: void
Definition at line 332 of file rpdb.c.
References str_trim().
Referenced by rpdb_extract_pdb_atom(), rpdb_open(), and rpdb_read().
00333 { 00334 /* Position: 1 2 3 4 5 6 */ 00335 /* Position: 123456789012345678901234567890123456789012345678901234567890 */ 00336 /* Record: ATOM 145 N VAL A 25 32.433 16.336 57.540 1.00 */ 00337 00338 /* Position: 6 7 8 */ 00339 /* Position: 012345678901234567890 */ 00340 /* Record: 0 11.92 N */ 00341 00342 /* Residue name */ 00343 strncpy(res_name, pdb_line + 17, 4); 00344 res_name[4] = '\0'; 00345 str_trim(res_name); 00346 }
void rpdb_extract_atom_values | ( | char * | pdb_line, | |
float * | x, | |||
float * | y, | |||
float * | z, | |||
float * | occ, | |||
float * | bfactor | |||
) |
## FUNCTION: rpdb_extract_atom_values
## SPECIFICATION: Extract coordinates, occupancy and bfactor values from a pdb ATOM or HETATM line, and store them in given pointers.
## PARAMETRES: @ char *pdb_line : The PDB line containings info @ float *x, *y, *z : Pointer to coordinates @ float *occ : Pointer to occupency @ float *bfactor : Pointer to b-factor
## RETURN: void
Definition at line 365 of file rpdb.c.
Referenced by rpdb_extract_pdb_atom().
00367 { 00368 /* Position: 1 2 3 4 5 6 */ 00369 /* Position: 123456789012345678901234567890123456789012345678901234567890 */ 00370 /* Record: ATOM 145 N VAL A 25 32.433 16.336 57.540 1.00 */ 00371 00372 /* Position: 6 7 8 */ 00373 /* Position: 012345678901234567890 */ 00374 /* Record: 0 11.92 N */ 00375 00376 char *ptr, 00377 ctmp ; 00378 00379 ptr = pdb_line + 30 ; 00380 ctmp = pdb_line[38] ; pdb_line[38] = '\0' ; 00381 *x = (float) atof(ptr) ; pdb_line[38] = ctmp ; 00382 00383 ptr = pdb_line + 38 ; 00384 ctmp = pdb_line[46] ; pdb_line[46] = '\0' ; 00385 *y = (float) atof(ptr) ; pdb_line[46] = ctmp ; 00386 00387 ptr = pdb_line + 46 ; 00388 ctmp = pdb_line[54] ; pdb_line[54] = '\0' ; 00389 *z = (float) atof(ptr) ; pdb_line[54] = ctmp ; 00390 00391 ptr = pdb_line + 54 ; 00392 ctmp = pdb_line[60] ; pdb_line[60] = '\0' ; 00393 *occ = (float) atof(ptr) ; pdb_line[60] = ctmp ; 00394 00395 ptr = pdb_line + 60 ; 00396 ctmp = pdb_line[66] ; pdb_line[66] = '\0' ; 00397 *bfactor = (float) atof(ptr) ; pdb_line[66] = ctmp ; 00398 }
void rpdb_extract_cryst1 | ( | char * | pdb_line, | |
float * | alpha, | |||
float * | beta, | |||
float * | gamma, | |||
float * | a, | |||
float * | b, | |||
float * | c | |||
) |
## FUNCTION: rpdb_extract_cryst1
## SPECIFICATION: Extract information on a box size from a pdb CRYSTL line, and store them in given pointers.
## PARAMETRES: @ char *pdb_line : The PDB line containings info @ float *alpha, *beta, *gamma : Pointer to angles @ float *A, B, C : Pointer sides length
## RETURN: void
Definition at line 416 of file rpdb.c.
Referenced by rpdb_read().
00418 { 00419 /* Position: 1 2 3 4 5 6 */ 00420 /* Position: 123456789012345678901234567890123456789012345678901234567890 */ 00421 /* Record: ATOM 145 N VAL A 25 32.433 16.336 57.540 1.00 */ 00422 00423 /* Position: 6 7 8 */ 00424 /* Position: 012345678901234567890 */ 00425 /* Record: 0 11.92 N */ 00426 00427 char ch, *s; 00428 00429 s = pdb_line+6 ; 00430 ch = pdb_line[15] ; pdb_line[15] = '\0' ; 00431 *a = (float) atof(s) ; 00432 00433 s = pdb_line+15 ; 00434 *s = ch ; ch = pdb_line[24]; pdb_line[24] = '\0' ; 00435 *b = (float) atof(s) ; 00436 00437 s = pdb_line+24 ; 00438 *s = ch; ch = pdb_line[33]; pdb_line[33] = '\0' ; 00439 *c = (float) atof(s) ; 00440 00441 s = pdb_line+33; 00442 *s = ch; ch = pdb_line[40]; pdb_line[40] = '\0' ; 00443 *alpha = (float) atof(s) ; 00444 00445 s = pdb_line+40; 00446 *s = ch; ch = pdb_line[47]; pdb_line[47] = '\0' ; 00447 *beta = (float) atof(s) ; 00448 00449 s = pdb_line+47; 00450 *s = ch; ch = pdb_line[54]; pdb_line[54] = '\0' ; 00451 *gamma = (float) atof(s) ; 00452 }
void rpdb_extract_pdb_atom | ( | char * | pdb_line, | |
char * | type, | |||
int * | atm_id, | |||
char * | name, | |||
char * | alt_loc, | |||
char * | res_name, | |||
char * | chain, | |||
int * | res_id, | |||
char * | insert, | |||
float * | x, | |||
float * | y, | |||
float * | z, | |||
float * | occ, | |||
float * | bfactor, | |||
char * | symbol, | |||
int * | charge, | |||
int * | guess_flag | |||
) |
## FUNCTION: rpdb_extract_pdb_atom
## SPECIFICATION: Extract all information given in a pdb ATOM or HETATM line, and store them in given pointers. User must therefore provide enough memory in parameter. PDB last known standart:
COLUMNS DATA TYPE FIELD DEFINITION
1 - 6 Record name "ATOM " 7 - 11 Integer serial Atom serial number. 13 - 16 Atom name Atom name. 17 Character altLoc Alternate location indicator. 18 - 20 Residue name resName Residue name. 22 Character chainID Chain identifier. 23 - 26 Integer resSeq Residue sequence number. 27 AChar iCode Code for insertion of residues. 31 - 38 Real(8.3) x Orthogonal coordinates for X in Angstroms 39 - 46 Real(8.3) y Orthogonal coordinates for Y in Angstroms 47 - 54 Real(8.3) z Orthogonal coordinates for Z in Angstroms 55 - 60 Real(6.2) occupancy Occupancy. 61 - 66 Real(6.2) tempFactor Temperature factor. 77 - 78 LString(2) element Element symbol, right-justified. 79 - 80 LString(2) charge Charge on the atom.
## PARAMETRES: @ char *pdb_line : The PDB line containings info @ int *atm_id : Pointer to atom ID @ char *name : Pointer to atom name @ char *res_name : Pointer to residue name @ char *chain : Pointer to chain name @ char *seg_name : Pointer to segment @ int *res_id : Pointer to residue ID @ char *insert : Pointer to insertion code @ char *alt_loc : Pointer to alternate location @ char *elem_symbol : Pointer to element symbol @ float *x, *y, *z : Pointer to coordinates @ float *occ : Pointer to occupency @ float *bfactor : Pointer to b-factor @ char *symbol : Pointer to symbol @ float *bfactor : Pointer to charge @ int guess_flag : Flag if elements were guessed
## RETURN: void
Definition at line 101 of file rpdb.c.
References guess_element(), rpdb_extract_atm_resname(), rpdb_extract_atom_values(), and str_trim().
Referenced by load_pdb_line(), and rpdb_read().
00106 { 00107 /* Position: 1 2 3 4 5 6 */ 00108 /* Position: 123456789012345678901234567890123456789012345678901234567890 */ 00109 /* Record: ATOM 145 N VAL A 25 32.433 16.336 57.540 1.00 */ 00110 00111 /* Position: 6 7 8 */ 00112 /* Position: 012345678901234567890 */ 00113 /* Record: 0 11.92 N */ 00114 00115 int rlen = strlen(pdb_line) ; 00116 00117 char *prt, 00118 ctmp ; 00119 00120 /* Record type */ 00121 strncpy(type, pdb_line, 6) ; 00122 00123 /* Atom ID */ 00124 prt = pdb_line + 6 ; 00125 ctmp = pdb_line[11] ; pdb_line[11] = '\0' ; 00126 *atm_id = atoi(prt) ; pdb_line[11] = ctmp ; 00127 00128 /* Atom name */ 00129 strncpy(name, pdb_line + 12, 4); 00130 name[4] = '\0'; 00131 str_trim(name) ; 00132 00133 /* Alternate location identifier */ 00134 *alt_loc = pdb_line[16] ; 00135 00136 /* Residue name */ 00137 rpdb_extract_atm_resname(pdb_line, res_name) ; 00138 00139 /* Chain name */ 00140 chain[0] = pdb_line[21]; 00141 chain[1] = '\0'; 00142 00143 /* Residue id number */ 00144 prt = pdb_line + 22 ; 00145 ctmp = pdb_line[26] ; pdb_line[26] = '\0' ; 00146 *res_id = atoi(prt) ; pdb_line[26] = ctmp ; 00147 00148 /* Insertion code */ 00149 *insert = pdb_line[26]; 00150 00151 /* x, y, and z coordinates, occupancy and b-factor */ 00152 rpdb_extract_atom_values(pdb_line, x, y, z, occ, bfactor); 00153 00154 /* Atomic element symbol (if does not exists, guess it based on 00155 * atom name */ 00156 if (rlen >= 77) { 00157 strncpy(symbol, pdb_line + 76, 2); 00158 symbol[2] = '\0'; 00159 str_trim(symbol); /* remove spaces */ 00160 if(strlen(symbol) < 1) { 00161 guess_element(name, symbol,res_name) ; 00162 *guess_flag+=1; 00163 } 00164 } 00165 else { 00166 guess_element(name, symbol,res_name) ; 00167 *guess_flag+=1; 00168 } 00169 str_trim(symbol); /* remove spaces */ 00170 00171 /* Charge */ 00172 if(rlen >= 79) { 00173 char buf[4] = " " ; 00174 if((pdb_line[78] == ' ' && pdb_line[79] == ' ') || pdb_line[78] == '\n'){ 00175 *charge = 0 ; 00176 } 00177 else { 00178 buf[0] = pdb_line[78] ; 00179 buf[1] = pdb_line[79] ; 00180 buf[2] = '\0' ; 00181 *charge = (int) atoi(buf) ; 00182 } 00183 } 00184 else *charge = 0 ; 00185 00186 }
s_pdb* rpdb_open | ( | char * | fpath, | |
const char * | ligan, | |||
const int | keep_lig | |||
) |
## FUNCTION: rpdb_open
## SPECIFICATION: Open a PDB file, alloc memory for all information on this pdb, and store several information like the number of atoms, the header, the remark... This first reading of PDB rewinds the FILE* pointer. No coordinates are actually read.
Hydrogens are conserved. All HETATM are removed, except the given ligand if we have to keep it, and important HETATM listed in the static structure at the top of this file.
## PARAMETRES: @ const char *fpath : The pdb path. @ const char *ligan : Ligand resname. @ const char *keep_lig : Keep the given ligand or not?
## RETURN: s_pdb: data containing PDB info.
Definition at line 478 of file rpdb.c.
References fopen_pdb_check_case(), s_pdb::fpdb, s_pdb::latm_lig, s_pdb::latoms, s_pdb::latoms_p, s_pdb::lhetatm, M_PDB_BUF_LEN, M_PDB_LINE_LEN, my_calloc(), my_free(), my_malloc(), s_pdb::natm_lig, s_pdb::natoms, s_pdb::nhetatm, rpdb_extract_atm_resname(), ST_keep_hetatm, and ST_nb_keep_hetatm.
Referenced by check_fpocket(), desc_pocket(), mdpocket_characterize(), open_pdb_file(), process_pdb(), and test_set().
00479 { 00480 s_pdb *pdb = NULL ; 00481 00482 char buf[M_PDB_BUF_LEN], 00483 resb[5] ; 00484 00485 int nhetatm = 0, 00486 natoms = 0, 00487 natm_lig = 0 ; 00488 int i ; 00489 00490 pdb = (s_pdb *) my_malloc(sizeof(s_pdb)) ; ; 00491 00492 /* Open the PDB file in read-only mode */ 00493 pdb->fpdb = fopen_pdb_check_case(fpath, "r"); 00494 if (!pdb->fpdb) { 00495 my_free(pdb) ; 00496 fprintf(stderr, "! File %s does not exist\n", fpath) ; 00497 return NULL ; 00498 } 00499 00500 while(fgets(buf, M_PDB_LINE_LEN + 2, pdb->fpdb)) { 00501 if (!strncmp(buf, "ATOM ", 5)) { 00502 /* Check if this is the first occurence of this atom*/ 00503 if(buf[16]==' ' || buf[16]=='A'){ 00504 /* Atom entry: check if there is a ligand in there (just in case)... */ 00505 rpdb_extract_atm_resname(buf, resb) ; 00506 if( ligan && ligan[0] == resb[0] && ligan[1] == resb[1] 00507 && ligan[2] == resb[2]){ 00508 00509 if(keep_lig) { 00510 natm_lig ++ ; 00511 natoms++ ; 00512 } 00513 } 00514 else { 00515 natoms++ ; 00516 } 00517 } 00518 } 00519 else if(!strncmp(buf, "HETATM", 6)) { 00520 /*Check again for the first occurence*/ 00521 if(buf[16]==' ' || buf[16]=='A'){ 00522 /* Hetatom entry: check if there is a ligand in there too... */ 00523 rpdb_extract_atm_resname(buf, resb) ; 00524 if( keep_lig && ligan && ligan[0] == resb[0] && ligan[1] == resb[1] 00525 && ligan[2] == resb[2]){ 00526 natm_lig ++ ; natoms++ ; 00527 } 00528 else { 00529 /* Keep specific HETATM given in the static list ST_keep_hetatm */ 00530 if (keep_lig && ! ligan && strncmp(resb,"HOH",3) && strncmp(resb,"WAT",3)){ 00531 natoms++ ; nhetatm++ ; 00532 } 00533 else { 00534 for(i = 0 ; i < ST_nb_keep_hetatm ; i++) { 00535 if(ST_keep_hetatm[i][0] == resb[0] && ST_keep_hetatm[i][1] 00536 == resb[1] && ST_keep_hetatm[i][2] == resb[2]) { 00537 nhetatm++ ; natoms++ ; 00538 break ; 00539 } 00540 } 00541 } 00542 } 00543 } 00544 } 00545 /* 00546 else if (!strncmp(buf, "HEADER", 6)) 00547 strncpy(pdb->header, buf, M_PDB_BUF_LEN) ; 00548 */ 00549 00550 else if (!strncmp(buf, "END", 3)) break ; 00551 } 00552 00553 if (natoms == 0) { 00554 fprintf(stderr, "! File '%s' contains no atoms...\n", fpath) ; 00555 my_free(pdb) ; 00556 00557 return NULL ; 00558 } 00559 00560 /* Alloc needed memory */ 00561 pdb->latoms = (s_atm*) my_calloc(natoms, sizeof(s_atm)) ; 00562 pdb->latoms_p = (s_atm**) my_calloc(natoms, sizeof(s_atm*)) ; 00563 00564 if(nhetatm > 0) pdb->lhetatm = (s_atm**) my_calloc(nhetatm, sizeof(s_atm*)) ; 00565 else pdb->lhetatm = NULL ; 00566 00567 if(natm_lig > 0) pdb->latm_lig = (s_atm**) my_calloc(natm_lig, sizeof(s_atm*)) ; 00568 else pdb->latm_lig = NULL ; 00569 00570 pdb->natoms = natoms ; 00571 pdb->nhetatm = nhetatm ; 00572 pdb->natm_lig = natm_lig ; 00573 rewind(pdb->fpdb) ; 00574 00575 return pdb ; 00576 }
void rpdb_read | ( | s_pdb * | pdb, | |
const char * | ligan, | |||
const int | keep_lig | |||
) |
## FUNCTION: rpdb_read
## SPECIFICATION: Read and store information on atoms for a pdb file. Curently:
## PARAMETRES: @ s_pdb *pdb : The structure to fill @ const char *ligand : The ligand resname @ const char *keep_lig : Keep the given ligand or not?
## RETURN:
Definition at line 599 of file rpdb.c.
References s_pdb::A, s_pdb::alpha, s_pdb::B, s_pdb::beta, s_atm::bfactor, s_pdb::C, s_atm::chain, s_atm::charge, s_atm::electroneg, s_pdb::fpdb, s_pdb::gamma, s_atm::id, s_pdb::latm_lig, s_pdb::latoms, s_pdb::latoms_p, s_pdb::lhetatm, M_PDB_BUF_LEN, M_PDB_LINE_LEN, s_atm::mass, s_atm::name, s_pdb::natm_lig, s_atm::occupancy, s_atm::pdb_aloc, s_atm::pdb_insert, pte_get_enegativity(), pte_get_mass(), pte_get_vdw_ray(), s_atm::radius, s_atm::res_id, s_atm::res_name, rpdb_extract_atm_resname(), rpdb_extract_cryst1(), rpdb_extract_pdb_atom(), s_atm::sort_x, ST_keep_hetatm, ST_nb_keep_hetatm, s_atm::symbol, s_atm::type, s_atm::x, s_atm::y, and s_atm::z.
Referenced by check_fpocket(), desc_pocket(), mdpocket_characterize(), mdpocket_detect(), mdprocess_pdb(), process_pdb(), and test_set().
00600 { 00601 int i, 00602 iatoms, 00603 ihetatm, 00604 iatm_lig, 00605 ligfound ; 00606 00607 char pdb_line[M_PDB_BUF_LEN], 00608 resb[5] ; /* Buffer for the current residue name */ 00609 00610 s_atm *atom = NULL ; 00611 s_atm *atoms = pdb->latoms ; 00612 s_atm **atoms_p = pdb->latoms_p ; 00613 s_atm **atm_lig = pdb->latm_lig ; 00614 int guess_flag=0; 00615 iatoms = 0 ; 00616 ihetatm = 0 ; 00617 iatm_lig = 0 ; 00618 ligfound = 0 ; 00619 00620 /* Loop over the pdb file */ 00621 while(fgets(pdb_line, M_PDB_LINE_LEN + 2, pdb->fpdb)) { 00622 if (strncmp(pdb_line, "ATOM ", 5) == 0) { 00623 if(pdb_line[16]==' ' || pdb_line[16]=='A'){ /*if within first occurence*/ 00624 /* Store ATOM entry */ 00625 rpdb_extract_atm_resname(pdb_line, resb) ; 00626 /* Check if the desired ligand is in such entry */ 00627 if( ligan && ligan[0] == resb[0] && ligan[1] == resb[1] 00628 && ligan[2] == resb[2]){ 00629 if(keep_lig) { 00630 atom = atoms + iatoms ; 00631 00632 /* Read atom information */ 00633 rpdb_extract_pdb_atom(pdb_line, atom->type, &(atom->id), 00634 atom->name, &(atom->pdb_aloc), atom->res_name, 00635 atom->chain, &(atom->res_id), &(atom->pdb_insert), 00636 &(atom->x), &(atom->y), &(atom->z), 00637 &(atom->occupancy), &(atom->bfactor), atom->symbol, 00638 &(atom->charge), &guess_flag); 00639 00640 /* Store additional information not given in the pdb */ 00641 atom->mass = pte_get_mass(atom->symbol) ; 00642 atom->radius = pte_get_vdw_ray(atom->symbol) ; 00643 atom->electroneg = pte_get_enegativity(atom->symbol) ; 00644 atom->sort_x = -1 ; 00645 00646 atoms_p[iatoms] = atom ; 00647 iatoms++ ; 00648 00649 atm_lig[iatm_lig] = atom ; 00650 iatm_lig ++ ; 00651 ligfound = 1 ; 00652 } 00653 } 00654 else { 00655 /* A simple atom not supposed to be stored as a ligand */ 00656 atom = atoms + iatoms ; 00657 rpdb_extract_pdb_atom(pdb_line, atom->type, &(atom->id), 00658 atom->name, &(atom->pdb_aloc), atom->res_name, 00659 atom->chain, &(atom->res_id), &(atom->pdb_insert), 00660 &(atom->x), &(atom->y), &(atom->z), &(atom->occupancy), 00661 &(atom->bfactor), atom->symbol, &(atom->charge), &guess_flag); 00662 00663 /* Store additional information not given in the pdb */ 00664 atom->mass = pte_get_mass(atom->symbol) ; 00665 atom->radius = pte_get_vdw_ray(atom->symbol) ; 00666 atom->electroneg = pte_get_enegativity(atom->symbol) ; 00667 atom->sort_x = -1 ; 00668 00669 atoms_p[iatoms] = atom ; 00670 iatoms++ ; 00671 } 00672 } 00673 } 00674 else if(strncmp(pdb_line, "HETATM", 6) == 0) { 00675 if(pdb_line[16]==' ' || pdb_line[16]=='A'){/*first occurence*/ 00676 /* Check HETATM entry */ 00677 rpdb_extract_atm_resname(pdb_line, resb) ; 00678 /* Check if the desired ligand is in HETATM entry */ 00679 if( ligan && keep_lig && ligan[0] == resb[0] && ligan[1] == resb[1] 00680 && ligan[2] == resb[2]){ 00681 00682 atom = atoms + iatoms ; 00683 rpdb_extract_pdb_atom(pdb_line, atom->type, &(atom->id), 00684 atom->name, &(atom->pdb_aloc), atom->res_name, 00685 atom->chain, &(atom->res_id), &(atom->pdb_insert), 00686 &(atom->x), &(atom->y), &(atom->z), &(atom->occupancy), 00687 &(atom->bfactor), atom->symbol, &(atom->charge), &guess_flag); 00688 00689 /* Store additional information not given in the pdb */ 00690 atom->mass = pte_get_mass(atom->symbol) ; 00691 atom->radius = pte_get_vdw_ray(atom->symbol) ; 00692 atom->electroneg = pte_get_enegativity(atom->symbol) ; 00693 atom->sort_x = -1 ; 00694 00695 atoms_p[iatoms] = atom ; 00696 atm_lig[iatm_lig] = atom ; 00697 00698 iatm_lig ++ ; iatoms++ ; 00699 ligfound = 1 ; 00700 } 00701 else if(pdb->lhetatm) { 00702 00703 /* Keep specific HETATM given in the static list ST_keep_hetatm. */ 00704 if (keep_lig && ! ligan && strncmp(resb,"HOH",3) && strncmp(resb,"WAT",3)){ 00705 atom = atoms + iatoms ; 00706 rpdb_extract_pdb_atom(pdb_line, atom->type, &(atom->id), 00707 atom->name, &(atom->pdb_aloc), atom->res_name, 00708 atom->chain, &(atom->res_id), &(atom->pdb_insert), 00709 &(atom->x), &(atom->y), &(atom->z), 00710 &(atom->occupancy), &(atom->bfactor), 00711 atom->symbol, &(atom->charge), &guess_flag); 00712 00713 /* Store additional information not given in the pdb */ 00714 atom->mass = pte_get_mass(atom->symbol) ; 00715 atom->radius = pte_get_vdw_ray(atom->symbol) ; 00716 atom->electroneg = pte_get_enegativity(atom->symbol) ; 00717 atom->sort_x = -1 ; 00718 00719 atoms_p[iatoms] = atom ; 00720 pdb->lhetatm[ihetatm] = atom ; 00721 ihetatm ++ ; iatoms++ ; 00722 } 00723 else { 00724 for(i = 0 ; i < ST_nb_keep_hetatm ; i++) { 00725 if( ST_keep_hetatm[i][0] == resb[0] && ST_keep_hetatm[i][1] 00726 == resb[1] && ST_keep_hetatm[i][2] == resb[2]) { 00727 atom = atoms + iatoms ; 00728 rpdb_extract_pdb_atom(pdb_line, atom->type, &(atom->id), 00729 atom->name, &(atom->pdb_aloc), atom->res_name, 00730 atom->chain, &(atom->res_id), &(atom->pdb_insert), 00731 &(atom->x), &(atom->y), &(atom->z), 00732 &(atom->occupancy), &(atom->bfactor), 00733 atom->symbol, &(atom->charge), &guess_flag); 00734 00735 /* Store additional information not given in the pdb */ 00736 atom->mass = pte_get_mass(atom->symbol) ; 00737 atom->radius = pte_get_vdw_ray(atom->symbol) ; 00738 atom->electroneg = pte_get_enegativity(atom->symbol) ; 00739 atom->sort_x = -1 ; 00740 00741 atoms_p[iatoms] = atom ; 00742 pdb->lhetatm[ihetatm] = atom ; 00743 ihetatm ++ ; iatoms++ ; 00744 break ; 00745 } 00746 } 00747 } 00748 } 00749 } 00750 } 00751 else if (strncmp(pdb_line, "CRYST1", 6) == 0) { 00752 rpdb_extract_cryst1(pdb_line, &(pdb->alpha), &(pdb->beta), &(pdb->gamma), 00753 &(pdb->A), &(pdb->B), &(pdb->C)); 00754 } 00755 else if (!strncmp(pdb_line, "END", 3)) break ; 00756 } 00757 00758 00759 /*if(guess_flag>0) { 00760 fprintf(stderr, ">! Warning: You did not provide a standard PDB file.\nElements were guessed by fpocket, because not provided in the PDB file. \nThere is no guarantee on the results!\n"); 00761 }*/ 00762 00763 if(ligan && keep_lig && (ligfound == 0 || pdb->natm_lig <= 0)) { 00764 fprintf(stderr, ">! Warning: ligand '%s' not found in the pdb...\n", ligan) ; 00765 if(pdb->latm_lig) fprintf(stderr, "! Ligand list is not NULL however...\n") ; 00766 if(ligfound == 1) fprintf(stderr, "! And ligfound == 1!! :-/\n") ; 00767 } 00768 else if(ligfound == 1 && iatm_lig <= 0) { 00769 fprintf(stderr, ">! Warning: ligand '%s' has been detected but no atoms \ 00770 has been stored!\n", ligan) ; 00771 } 00772 else if((ligfound == 1 && pdb->natm_lig <= 0) || (pdb->natm_lig <=0 00773 && iatm_lig > 0)) { 00774 fprintf(stderr, ">! Warning: ligand '%s' has been detected in rpdb_read \ 00775 but not in rpdb_open!\n", ligan) ; 00776 } 00777 00778 }