Skip to content

Commit 3244c7e

Browse files
committed
tests are working now
1 parent 1d33cf5 commit 3244c7e

4 files changed

Lines changed: 20 additions & 9 deletions

File tree

POPSC/src/getpdb.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -500,8 +500,7 @@ void read_structure(Arg *arg, Argpdb *argpdb, Str *pdb)
500500
}
501501

502502
/* check for empty pdb structure and exit */
503-
if (pdb->nAtom == 0)
504-
{
503+
if (pdb->nAtom == 0) {
505504
ErrorSpecNoexit("Could not find atoms in input file. Please check input parameters:\nformat (--pdb or --pdbml), compression (--zipped or not) and file name",
506505
arg->pdbInFileName);
507506
free(pdb->atom);

POPSC/src/json.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ void make_resSasaJson(Arg *arg, Str *pdb, ResSasa *resSasa, cJSON *json)
4848

4949
/* indices to iterate through arrays defined below */
5050
unsigned int c = 0; /* chain index */
51-
char isChainLabel[2] = "@"; /* dummy chain name, never in structure */
51+
char isChainLabel[128] = "@"; /* dummy chain name, never in structure */
5252
unsigned int r = 0; /* residue index */
5353

5454
/* header: attached to 'json' */
@@ -60,8 +60,15 @@ void make_resSasaJson(Arg *arg, Str *pdb, ResSasa *resSasa, cJSON *json)
6060
cJSON_AddStringToObject(json, "pdb_id", pdb->pdbID);
6161

6262
/* add Chain array */
63+
64+
if (pdb->nResidue == 0 || pdb->resAtom == NULL || pdb->atom == NULL) {
65+
fprintf(stderr, "No residues/atoms available for JSON output\n");
66+
return;
67+
}
68+
6369
cJSON *chains = cJSON_AddArrayToObject(json, "chains");
64-
strcpy(isChainLabel, pdb->atom[pdb->resAtom[0]].chainIdentifier);
70+
snprintf(isChainLabel, sizeof isChainLabel, "%s",
71+
pdb->atom[pdb->resAtom[0]].chainIdentifier);
6572

6673
/* iterate over all Chains */
6774
for (c = 0; c < pdb->nChain; ++ c) {
@@ -128,7 +135,8 @@ void make_resSasaJson(Arg *arg, Str *pdb, ResSasa *resSasa, cJSON *json)
128135
into enclosing loop for creating a new Chain,
129136
including its cognate Residue array */
130137
r ++;
131-
strcpy(isChainLabel, pdb->atom[pdb->resAtom[r]].chainIdentifier);
138+
snprintf(isChainLabel, sizeof isChainLabel, "%s",
139+
pdb->atom[pdb->resAtom[r]].chainIdentifier);
132140
break;
133141
}
134142
}

POPSC/src/pops

568 Bytes
Binary file not shown.

POPSC/src/pops.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,11 @@ int main(int argc, char *argv[])
179179
print_sfe(&arg, &argpdb, &pdb, &type, &topol, &molSFE, constant_sigma, -1);
180180

181181
/*____________________________________________________________________________*/
182-
/** print Calpha distance matrix */
183-
calpha_distances(&arg, &pdb, &topol);
184-
print_distMatCA(&arg, &topol);
182+
/** compute and print Calpha distance matrix between 2 chains*/
183+
if (pdb.nChain == 2) {
184+
calpha_distances(&arg, &pdb, &topol);
185+
print_distMatCA(&arg, &topol);
186+
}
185187

186188
/*____________________________________________________________________________*/
187189
/** free memory */
@@ -228,7 +230,9 @@ int main(int argc, char *argv[])
228230
free(pdb.resAtom);
229231
free(pdb.atomMap);
230232
free(pdb.sequence.res);
231-
/*free(pdb.sequence.name);*/
233+
if (arg.pdb) {
234+
free(pdb.sequence.name);
235+
}
232236

233237
/* trajectory */
234238
if (arg.trajInFileName) {

0 commit comments

Comments
 (0)