Skip to content

Commit 95e1006

Browse files
committed
correct residue numbers in CA distance matrix
1 parent 45a3988 commit 95e1006

5 files changed

Lines changed: 54 additions & 10 deletions

File tree

POPSC/src/pops

2.21 KB
Binary file not shown.

POPSC/src/putDistMatCA.c

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,36 @@ Read the COPYING file for license information.
1212
/** print Calpha distance matrix */
1313
void print_distMatCA(Arg *arg, Topol *topol)
1414
{
15+
int i, j;
16+
1517
arg->distMatCAOutFile = safe_open(arg->distMatCAOutFileName, "w");
16-
print_mat2D_float(arg->distMatCAOutFileName, topol->distMatCA, topol->nCA1, topol->nCA2);
18+
19+
/* print residue numbers as column names */
20+
for (j = 0; j < topol->nCA2; ++ j) {
21+
if (j > 0) {
22+
fprintf(arg->distMatCAOutFile, " %d", topol->resCA2[j]);
23+
} else {
24+
fprintf(arg->distMatCAOutFile, "%d", topol->resCA2[j]);
25+
}
26+
}
27+
fprintf(arg->distMatCAOutFile, "\n");
28+
29+
for (i = 0; i < topol->nCA1; ++ i) {
30+
if (i > 0) fprintf(arg->distMatCAOutFile, "\n");
31+
32+
/* print residue numbers as row names */
33+
fprintf(arg->distMatCAOutFile, "%d ", topol->resCA1[i]);
34+
35+
for (j = 0; j < topol->nCA2; ++ j) {
36+
if (j < topol->nCA2 - 1) {
37+
fprintf(arg->distMatCAOutFile, "%3.2f ", topol->distMatCA[i][j]);
38+
} else {
39+
fprintf(arg->distMatCAOutFile, "%3.2f", topol->distMatCA[i][j]);
40+
}
41+
}
42+
}
43+
fprintf(arg->distMatCAOutFile, "\n");
44+
1745
fclose(arg->distMatCAOutFile);
1846
}
1947

POPSC/src/topol.c

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ __inline__ static void print_torsion(Str *pdb, int t1, int t2, int t3, int t4)
4444
/** init topology */
4545
void init_topology(Arg *arg, Str *pdb, Topol *topol)
4646
{
47-
unsigned int i;
47+
unsigned int i, j;
4848
int *nCA = NULL;
4949
char *chain1 = NULL;
5050
/* assuming an upper limit of 63 bonded interactions per atom */
@@ -73,8 +73,18 @@ void init_topology(Arg *arg, Str *pdb, Topol *topol)
7373
}
7474
}
7575
printf("CA distance matrix has dimensions %d x %d \n", topol->nCA1, topol->nCA2);
76+
/* allocate Calpha distance matrix */
7677
topol->distMatCA = alloc_mat2D_float(topol->distMatCA, topol->nCA1, topol->nCA2);
7778
init_mat2D_float(topol->distMatCA, topol->nCA1, topol->nCA2, 0.);
79+
/* array of residue numbers for each chain */
80+
topol->resCA1 = safe_malloc(topol->nCA1 * sizeof(int));
81+
for (i = 0; i < topol->nCA1; ++ i) {
82+
topol->resCA1[i] = -999;
83+
}
84+
topol->resCA2 = safe_malloc(topol->nCA2 * sizeof(int));
85+
for (j = 0; j < topol->nCA2; ++ j) {
86+
topol->resCA2[j] = -999;
87+
}
7888

7989
for (i = 0; i < pdb->nAtom; ++ i) {
8090
topol->bondState[i][0] = 0; /* no bonded pairs recorded */
@@ -110,6 +120,8 @@ void free_topology(Str *pdb, Topol *topol)
110120
free(topol->interfaceNn);
111121
free(topol->interfaceNnDist);
112122
free_mat2D_float(topol->distMatCA, topol->nCA1);
123+
free(topol->resCA1);
124+
free(topol->resCA2);
113125
}
114126

115127
/*___________________________________________________________________________*/
@@ -701,11 +713,10 @@ int calpha_distances(Arg *arg, Str *pdb, Topol *topol, ConstantSasa *res_sasa) {
701713
found_CA1 = found_CA2 = 0;
702714
r_CA1 = r_CA2 = 0.;
703715
for (k = 0; k < res_sasa->nResidueType; ++ k) {
704-
if (strcmp(pdb->atom[i].residueName, res_sasa->atomDataSasa[k][0].residueName) == 0) {
705-
/* found residue of atom i at index k */
706-
r_CA1 = res_sasa->atomDataSasa[k][0].radius;
707-
++ found_CA1;
708-
}
716+
/* found residue of atom i at index k */
717+
r_CA1 = res_sasa->atomDataSasa[k][0].radius;
718+
++ found_CA1;
719+
709720
if (strcmp(pdb->atom[j].residueName, res_sasa->atomDataSasa[k][0].residueName) == 0) {
710721
/* found residue of atom j at index k */
711722
r_CA2 = res_sasa->atomDataSasa[k][0].radius;
@@ -720,6 +731,9 @@ int calpha_distances(Arg *arg, Str *pdb, Topol *topol, ConstantSasa *res_sasa) {
720731
/* the mean radius across 20 amino acids is 4.35 */
721732
soft_distance_norm = soft_distance * (sqrt(r_CA1 * r_CA2) / 4.35);
722733
topol->distMatCA[n_cai][n_caj] = soft_distance_norm;
734+
735+
topol->resCA1[n_cai] = pdb->atom[i].residueNumber;
736+
topol->resCA2[n_caj] = pdb->atom[j].residueNumber;
723737

724738
++n_caj;
725739
}

POPSC/src/topol.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ typedef struct
5151
int nCA1; /* number of Calpha atoms in chain or domain 1 */
5252
int nCA2; /* number of Calpha atoms in chain or domain 2 */
5353
float **distMatCA; /* Calpha distance matrix */
54+
int *resCA1; /* array of residue numbers of chain or domain 1 */
55+
int *resCA2; /* array of residue numbers of chain or domain 2 */
5456
} Topol;
5557

5658
/*____________________________________________________________________________*/

POPSR/script/popscomp_interface.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ exit_codes = sapply(1:length(chainpair.files), function(x) {
135135
command6 = paste0("pops",
136136
" --rout --routPrefix ", paste0(chainpair.files.short[x], ".pair"),
137137
" --residueOut",
138-
paste0(" --distMatCAOut ", opt$mmcif, "_distMatCA.out"),
138+
paste0(" --distMatCAOut ", pdbConversionName, "_distMatCA.out"),
139139
" --pdb ", chainpair.files[x], " 1> ", "POPScomp_chainpair", x, ".o",
140140
" 2> ", "POPScomp_chainpair", x, ".e")
141141
print(command6)
@@ -201,10 +201,10 @@ iso.rbind.tmp = rbind(iso.sasa.level.files[[1]][[1]],
201201
logratio_Q.SASA = round(log2(iso.rbind.tmp[ , "Q.SASA."] / pair.sasa.level.files[[1]][[1]][ , "Q.SASA."]), digits = 2)
202202
is.lix = logratio_Q.SASA > 0
203203
#Z_Q.SASA = logratio_Q.SASA / sd(logratio_Q.SASA)
204-
is.logratio_Q.SASA = logratio_Q.SASA[is.lix]
204+
#is.logratio_Q.SASA = logratio_Q.SASA[is.lix]
205205
Zrobust_Q.SASA = (logratio_Q.SASA[is.lix] - median(logratio_Q.SASA[is.lix])) / (1.4862 * mad(logratio_Q.SASA[is.lix]))
206206

207-
## final residue selection is SASA <= 0.25 and Zrobust > 1
207+
## final residue selection is Q.SASA <= 0.25 and Zrobust > 1
208208
sel.lix = (pair.sasa.level.files[[1]][[1]][ , "Q.SASA."][is.lix] <= 0.25) & (Zrobust_Q.SASA > 1)
209209
final.ix = (which(is.lix))[sel.lix]
210210

0 commit comments

Comments
 (0)