Skip to content

Commit

Permalink
Merge pull request #128 from Discngine/issue-127
Browse files Browse the repository at this point in the history
fixing mmcif writing for db mode
  • Loading branch information
pschmidtke authored Jan 25, 2024
2 parents 9ff11f6 + c87362f commit beb472b
Show file tree
Hide file tree
Showing 214 changed files with 22,448 additions and 43 deletions.
9,565 changes: 9,565 additions & 0 deletions data/sample/123abc.cif

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions headers/writepocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ void write_pdb_atoms(FILE *f, s_atm *atoms, int natoms) ;
void write_each_pocket_for_DB(const char out_path[], c_lst_pockets *pockets,s_pdb *pdb);
void write_pocket_pqr_DB(const char out[], s_pocket *pocket);
void write_pocket_pdb_DB(const char out[], s_pocket *pocket,s_pdb *pdb);
void write_pocket_mmcif_DB(const char out[], s_pocket *pocket, s_pdb *pdb);

void write_mmcif_atoms(FILE *f, s_atm *atoms, int natoms);
void write_pockets_single_mmcif(const char out[], s_pdb *pdb, c_lst_pockets *pockets);
Expand Down
111 changes: 68 additions & 43 deletions src/writepocket.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ void write_each_pocket_for_DB(const char out_path[], c_lst_pockets *pockets, s_p
out[0] = '\0';

node_pocket *pcur;

int i = 0;
if (pockets) {
pcur = pockets->first;
Expand All @@ -92,12 +91,25 @@ void write_each_pocket_for_DB(const char out_path[], c_lst_pockets *pockets, s_p
sprintf(out, "%s/pocket%d_vert.pqr", out_path, i + 1);
write_pocket_pqr_DB(out, pcur->pocket);

if(write_mode[0] == 'p' || write_mode[0] == 'b'){

sprintf(out, "%s/pocket%d_atm.pdb", out_path, i + 1);
write_pocket_pdb(out, pcur->pocket);

sprintf(out, "%s/pocket%d_env_atm.pdb", out_path, i + 1);
write_pocket_pdb_DB(out, pcur->pocket, pdb);
// sprintf(out, "%s/pocket%d_atm.pdb", out_path, i+1);
// write_pocket_pdb_DB(out, pcur->pocket);
}

if(write_mode[0] == 'm' || write_mode[0] == 'b'){
sprintf(out, "%s/pocket%d_atm.cif", out_path, i + 1);
write_pocket_mmcif(out, pcur->pocket);

sprintf(out, "%s/pocket%d_env_atm.cif", out_path, i+1);
write_pocket_mmcif_DB(out, pcur->pocket,pdb);
}


sprintf(out, "%s/pocket%d_atm.pdb", out_path, i + 1);
write_pocket_pdb(out, pcur->pocket);

pcur = pcur->next;
i++;
Expand Down Expand Up @@ -144,59 +156,22 @@ void write_pocket_pdb_DB(const char out[], s_pocket *pocket, s_pdb *pdb) {

node_vertice *nvcur = pocket->v_lst->first;

/*
fprintf(stdout, "A Pocket:\n") ;
*/
while (nvcur) {
/*
fprintf(stdout, "Vertice %d: %p %d %f\n", i, nvcur->vertice, nvcur->vertice->id, nvcur->vertice->ray) ;
fprintf(stdout, "Atom %s\n", nvcur->vertice->neigh[0]->name) ;
*/

tab_vert[nvert] = nvcur->vertice;
nvcur = nvcur->next;
nvert++;
}
sa = (int *) get_surrounding_atoms_idx(tab_vert, nvert, pdb, &n_sa);
for (i = 0; i < n_sa; i++) {
//atom = pocket->sou_atoms[i] ;
atom = pdb->latoms_p[sa[i]];
write_pdb_atom_line(f, atom->type, atom->id, atom->name, atom->pdb_aloc,
atom->res_name, atom->chain, atom->res_id,
atom->pdb_insert, atom->x, atom->y, atom->z,
atom->dA, atom->a0, atom->abpa, atom->symbol,
atom->charge, atom->abpa_sourrounding_prob);
}
/*
vcur = pocket->v_lst->first ;
while(vcur){
for(i = 0 ; i < 4 ; i++) {
if(!is_in_lst_atm(atms, cur_size, vcur->vertice->neigh[i]->id)) {
if(cur_size >= cur_allocated-1) {
cur_allocated *= 2 ;
atms = (s_atm**) my_realloc(atms, sizeof(s_atm)*cur_allocated) ;
}
atms[cur_size] = vcur->vertice->neigh[i] ;
cur_size ++ ;
}
}
vcur = vcur->next ;
}
*/
// Then write atoms...
/*
for(i = 0 ; i < cur_size ; i++) {
atom = atms[i] ;
write_pdb_atom_line(f, atom->type, atom->id, atom->name, atom->pdb_aloc,
atom->res_name, atom->chain, atom->res_id,
atom->pdb_insert, atom->x, atom->y, atom->z,
atom->occupancy, atom->bfactor, atom->symbol,
atom->charge);
}
*/

fprintf(f, "TER\nEND\n");
fclose(f);
} else {
Expand All @@ -207,6 +182,56 @@ void write_pocket_pdb_DB(const char out[], s_pocket *pocket, s_pdb *pdb) {
my_free(atms);
}



void write_pocket_mmcif_DB(const char out[], s_pocket *pocket, s_pdb *pdb) {
int i = 0, nvert = 0;
s_atm **atms = (s_atm **) my_malloc(sizeof (s_atm*)*10);
s_atm *atom = NULL;
int n_sa = 0;
int *sa = NULL; /*surrounding atoms container*/
s_vvertice **tab_vert = NULL;
char tmp[250];
strcpy(tmp,out);
remove_ext(tmp);
remove_path(tmp);
FILE *f = fopen(out, "w");
fprintf(f,"data_%s\n# \n",tmp);
fprintf(f,"%s",atomSiteHeader);/*print the header*/
if (f && pocket) {
// First get the list of atoms
tab_vert = (s_vvertice **) my_malloc(pocket->v_lst->n_vertices * sizeof (s_vvertice*));

node_vertice *nvcur = pocket->v_lst->first;

while (nvcur) {

tab_vert[nvert] = nvcur->vertice;
nvcur = nvcur->next;
nvert++;
}
sa = (int *) get_surrounding_atoms_idx(tab_vert, nvert, pdb, &n_sa);
for (i = 0; i < n_sa; i++) {
atom = pdb->latoms_p[sa[i]];
write_mmcif_atom_line(f, atom->type, atom->id, atom->name, atom->pdb_aloc,
atom->res_name, atom->chain, atom->res_id,
atom->pdb_insert, atom->x, atom->y, atom->z,
atom->dA, atom->a0, atom->abpa, atom->symbol,
atom->charge, atom->abpa_sourrounding_prob);
}

fprintf(f, "#\n");
fclose(f);
} else {
if (!f) fprintf(stderr, "! The file %s could not be opened!\n", out);
else fprintf(stderr, "! Invalid pocket to write in write_pocket_pqr !\n");
}

my_free(atms);
}



/**
## FUNCTION:
write_single_pdb
Expand Down Expand Up @@ -483,7 +508,7 @@ void write_each_pocket(const char out_path[], c_lst_pockets *pockets) {
int i = 1;
if (pockets) {
pcur = pockets->first;

while (pcur) {
sprintf(out, "%s/pocket%d_vert.pqr", out_path, i);

Expand Down
76 changes: 76 additions & 0 deletions tests/reference_output/123abc_out/pocket10_atm.cif
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
data_pocket10_atm
#
loop_
_struct.pdbx_descriptor
This is a mmcif format file writen by the programm fpocket.
It represents the atoms contacted by the voronoi vertices of the pocket.

Information about the pocket 10:
0 - Pocket Score : 0.0405
1 - Drug Score : 0.0230
2 - Number of alpha spheres : 57
3 - Mean alpha-sphere radius : 3.8604
4 - Mean alpha-sphere Solvent Acc. : 0.4592
5 - Mean B-factor of pocket residues : 0.2769
6 - Hydrophobicity Score : 40.0769
7 - Polarity Score : 6
8 - Amino Acid based volume Score : 3.6154
9 - Pocket volume (Monte Carlo) : 433.6981
10 -Pocket volume (convex hull) : 76.0139
11 - Charge Score : 1
12 - Local hydrophobic density Score : 32.4571
13 - Number of apolar alpha sphere : 35
14 - Proportion of apolar alpha sphere : 0.6140
#
loop_
_atom_site.group_PDB
_atom_site.id
_atom_site.type_symbol
_atom_site.label_atom_id
_atom_site.label_alt_id
_atom_site.label_comp_id
_atom_site.label_asym_id
_atom_site.label_entity_id
_atom_site.label_seq_id
_atom_site.pdbx_PDB_ins_code
_atom_site.Cartn_x
_atom_site.Cartn_y
_atom_site.Cartn_z
_atom_site.occupancy
_atom_site.pdbx_formal_charge
_atom_site.auth_asym_id
ATOM 3335 C CG2 . THR B . 167 ? 23.611 41.302 32.855 0.00 0 B
ATOM 3339 O O . ALA B . 168 ? 21.154 41.582 30.397 0.00 0 B
ATOM 1238 O O . ALA A . 168 ? 20.773 34.081 30.515 0.00 0 A
ATOM 3399 C CD1 . ILE B . 176 ? 22.413 39.457 35.570 0.00 0 B
ATOM 3397 C CG1 . ILE B . 176 ? 21.483 40.079 36.568 0.00 0 B
ATOM 3345 C CB . HIS B . 169 ? 17.804 41.919 30.765 0.00 0 B
ATOM 3378 C CB . PHE B . 174 ? 18.390 43.943 35.478 0.00 0 B
ATOM 3332 O O . THR B . 167 ? 21.633 44.211 32.694 -1.07 0 B
ATOM 3735 C CA . SER B . 219 ? 24.536 33.701 35.059 0.00 0 B
ATOM 3729 O O . LEU B . 218 ? 23.720 35.415 36.830 0.00 0 B
ATOM 1239 C CB . ALA A . 168 ? 21.952 31.542 32.252 0.00 0 A
ATOM 3454 O O . SER B . 183 ? 12.618 40.049 35.823 -1.07 0 B
ATOM 3488 O OD1 . ASN B . 187 ? 12.383 40.631 32.241 -1.07 0 B
ATOM 3380 C CD1 . PHE B . 174 ? 16.492 43.534 33.887 0.00 0 B
ATOM 3460 O O . LEU B . 184 ? 14.089 37.175 34.255 -3.21 0 B
ATOM 3458 C CA . LEU B . 184 ? 14.473 38.083 36.400 0.00 0 B
ATOM 3348 C CD2 . HIS B . 169 ? 16.267 39.878 30.268 0.00 0 B
ATOM 1241 C CA . HIS A . 169 ? 18.086 33.603 31.255 0.00 0 A
ATOM 3760 C CB . TYR B . 222 ? 18.259 32.959 38.062 0.00 0 B
ATOM 3756 N N . TYR B . 222 ? 20.251 33.164 39.466 -1.09 0 B
ATOM 3398 C CG2 . ILE B . 176 ? 21.928 38.594 38.565 0.00 0 B
ATOM 3463 C CD1 . LEU B . 184 ? 17.369 37.208 38.932 0.00 0 B
ATOM 3737 O O . SER B . 219 ? 23.395 31.686 35.276 -1.07 0 B
ATOM 3728 C C . LEU B . 218 ? 24.912 35.395 36.613 0.00 0 B
ATOM 3730 C CB . LEU B . 218 ? 25.994 37.693 36.437 0.00 0 B
ATOM 3738 C CB . SER B . 219 ? 25.152 33.376 33.704 0.00 0 B
ATOM 3346 C CG . HIS B . 169 ? 16.549 41.202 30.364 0.00 0 B
ATOM 3464 C CD2 . LEU B . 184 ? 17.512 38.953 37.066 0.00 0 B
ATOM 3734 N N . SER B . 219 ? 25.438 34.466 35.848 -1.09 0 B
ATOM 1247 C CD2 . HIS A . 169 ? 15.907 36.141 30.193 0.00 0 A
ATOM 3461 C CB . LEU B . 184 ? 15.552 37.271 37.155 0.00 0 B
ATOM 1250 N N . ALA A . 170 ? 17.224 33.325 33.516 -4.79 0 A
ATOM 1255 N N . GLY A . 171 ? 17.151 30.558 34.884 -1.09 0 A
ATOM 1237 C C . ALA A . 168 ? 20.392 32.949 30.818 0.00 0 A
#
91 changes: 91 additions & 0 deletions tests/reference_output/123abc_out/pocket10_env_atm.cif
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
data_pocket10_env_atm
#
loop_
_atom_site.group_PDB
_atom_site.id
_atom_site.type_symbol
_atom_site.label_atom_id
_atom_site.label_alt_id
_atom_site.label_comp_id
_atom_site.label_asym_id
_atom_site.label_entity_id
_atom_site.label_seq_id
_atom_site.pdbx_PDB_ins_code
_atom_site.Cartn_x
_atom_site.Cartn_y
_atom_site.Cartn_z
_atom_site.occupancy
_atom_site.pdbx_formal_charge
_atom_site.auth_asym_id
ATOM 1236 C CA . ALA A . 168 ? 21.345 31.742 30.855 0.00 0 A
ATOM 1237 C C . ALA A . 168 ? 20.392 32.949 30.818 0.00 0 A
ATOM 1238 O O . ALA A . 168 ? 20.773 34.081 30.515 0.00 0 A
ATOM 1239 C CB . ALA A . 168 ? 21.952 31.542 32.252 0.00 0 A
ATOM 1240 N N . HIS A . 169 ? 19.130 32.633 31.043 0.00 0 A
ATOM 1241 C CA . HIS A . 169 ? 18.086 33.603 31.255 0.00 0 A
ATOM 1242 C C . HIS A . 169 ? 17.124 32.937 32.241 0.00 0 A
ATOM 1244 C CB . HIS A . 169 ? 17.333 33.968 29.971 0.00 0 A
ATOM 1245 C CG . HIS A . 169 ? 16.104 34.797 30.229 0.00 0 A
ATOM 1247 C CD2 . HIS A . 169 ? 15.907 36.141 30.193 0.00 0 A
ATOM 1249 N NE2 . HIS A . 169 ? 14.590 36.367 30.529 0.00 0 A
ATOM 1250 N N . ALA A . 170 ? 17.224 33.325 33.516 -4.79 0 A
ATOM 1251 C CA . ALA A . 170 ? 16.342 32.830 34.571 0.00 0 A
ATOM 1252 C C . ALA A . 170 ? 16.105 31.311 34.539 0.00 0 A
ATOM 1254 C CB . ALA A . 170 ? 15.038 33.564 34.528 0.00 0 A
ATOM 1255 N N . GLY A . 171 ? 17.151 30.558 34.884 -1.09 0 A
ATOM 3331 C C . THR B . 167 ? 22.771 43.904 32.327 0.00 0 B
ATOM 3332 O O . THR B . 167 ? 21.633 44.211 32.694 -1.07 0 B
ATOM 3333 C CB . THR B . 167 ? 23.958 42.338 33.911 0.00 0 B
ATOM 3335 C CG2 . THR B . 167 ? 23.611 41.302 32.855 0.00 0 B
ATOM 3338 C C . ALA B . 168 ? 20.955 42.763 30.104 0.00 0 B
ATOM 3339 O O . ALA B . 168 ? 21.154 41.582 30.397 0.00 0 B
ATOM 3341 N N . HIS B . 169 ? 19.743 43.280 29.949 0.00 0 B
ATOM 3342 C CA . HIS B . 169 ? 18.586 42.470 29.578 0.00 0 B
ATOM 3345 C CB . HIS B . 169 ? 17.804 41.919 30.765 0.00 0 B
ATOM 3346 C CG . HIS B . 169 ? 16.549 41.202 30.364 0.00 0 B
ATOM 3347 N ND1 . HIS B . 169 ? 15.399 41.864 29.978 -2.19 0 B
ATOM 3348 C CD2 . HIS B . 169 ? 16.267 39.878 30.268 0.00 0 B
ATOM 3349 C CE1 . HIS B . 169 ? 14.459 40.980 29.690 0.00 0 B
ATOM 3350 N NE2 . HIS B . 169 ? 14.959 39.769 29.859 0.00 0 B
ATOM 3374 N N . PHE B . 174 ? 19.806 45.500 34.237 0.00 0 B
ATOM 3375 C CA . PHE B . 174 ? 19.360 45.109 35.564 0.00 0 B
ATOM 3377 O O . PHE B . 174 ? 21.500 44.304 36.088 0.00 0 B
ATOM 3378 C CB . PHE B . 174 ? 18.390 43.943 35.478 0.00 0 B
ATOM 3379 C CG . PHE B . 174 ? 17.076 44.325 34.855 0.00 0 B
ATOM 3380 C CD1 . PHE B . 174 ? 16.492 43.534 33.887 0.00 0 B
ATOM 3382 C CE1 . PHE B . 174 ? 15.273 43.909 33.319 0.00 0 B
ATOM 3396 C CB . ILE B . 176 ? 21.966 39.989 38.044 0.00 0 B
ATOM 3397 C CG1 . ILE B . 176 ? 21.483 40.079 36.568 0.00 0 B
ATOM 3398 C CG2 . ILE B . 176 ? 21.928 38.594 38.565 0.00 0 B
ATOM 3399 C CD1 . ILE B . 176 ? 22.413 39.457 35.570 0.00 0 B
ATOM 3453 C C . SER B . 183 ? 12.616 39.571 36.930 0.00 0 B
ATOM 3454 O O . SER B . 183 ? 12.618 40.049 35.823 -1.07 0 B
ATOM 3457 N N . LEU B . 184 ? 13.478 38.624 37.304 0.00 0 B
ATOM 3458 C CA . LEU B . 184 ? 14.473 38.083 36.400 0.00 0 B
ATOM 3459 C C . LEU B . 184 ? 13.764 37.165 35.433 0.00 0 B
ATOM 3460 O O . LEU B . 184 ? 14.089 37.175 34.255 -3.21 0 B
ATOM 3461 C CB . LEU B . 184 ? 15.552 37.271 37.155 0.00 0 B
ATOM 3462 C CG . LEU B . 184 ? 16.587 38.098 37.951 0.00 0 B
ATOM 3463 C CD1 . LEU B . 184 ? 17.369 37.208 38.932 0.00 0 B
ATOM 3464 C CD2 . LEU B . 184 ? 17.512 38.953 37.066 0.00 0 B
ATOM 3488 O OD1 . ASN B . 187 ? 12.383 40.631 32.241 -1.07 0 B
ATOM 3727 C CA . LEU B . 218 ? 25.851 36.423 37.264 0.00 0 B
ATOM 3728 C C . LEU B . 218 ? 24.912 35.395 36.613 0.00 0 B
ATOM 3729 O O . LEU B . 218 ? 23.720 35.415 36.830 0.00 0 B
ATOM 3730 C CB . LEU B . 218 ? 25.994 37.693 36.437 0.00 0 B
ATOM 3734 N N . SER B . 219 ? 25.438 34.466 35.848 -1.09 0 B
ATOM 3735 C CA . SER B . 219 ? 24.536 33.701 35.059 0.00 0 B
ATOM 3736 C C . SER B . 219 ? 24.150 32.474 35.811 0.00 0 B
ATOM 3737 O O . SER B . 219 ? 23.395 31.686 35.276 -1.07 0 B
ATOM 3738 C CB . SER B . 219 ? 25.152 33.376 33.704 0.00 0 B
ATOM 3751 C C . VAL B . 221 ? 21.031 32.982 40.538 0.00 0 B
ATOM 3753 C CB . VAL B . 221 ? 22.559 35.077 40.397 0.00 0 B
ATOM 3756 N N . TYR B . 222 ? 20.251 33.164 39.466 -1.09 0 B
ATOM 3757 C CA . TYR B . 222 ? 18.886 32.708 39.432 0.00 0 B
ATOM 3760 C CB . TYR B . 222 ? 18.259 32.959 38.062 0.00 0 B
ATOM 3761 C CG . TYR B . 222 ? 16.811 32.522 38.032 0.00 0 B
ATOM 3762 C CD1 . TYR B . 222 ? 15.795 33.459 38.329 0.00 0 B
ATOM 3768 N N . GLU B . 223 ? 19.652 30.471 39.123 0.00 0 B
ATOM 3773 C CG . GLU B . 223 ? 20.865 28.953 37.013 0.00 0 B
ATOM 3776 O OE2 . GLU B . 223 ? 21.549 28.266 34.820 0.00 0 B
#
Loading

0 comments on commit beb472b

Please sign in to comment.