@@ -44,7 +44,7 @@ __inline__ static void print_torsion(Str *pdb, int t1, int t2, int t3, int t4)
4444/** init topology */
4545void 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 }
0 commit comments