Skip to content

Commit

Permalink
Support longer chain labels in output.
Browse files Browse the repository at this point in the history
  • Loading branch information
mittinatten committed Feb 22, 2024
1 parent 17463b8 commit e6783ae
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 19 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

FreeSASA uses semantic versioning. Changelog added for versions 2.x

## Upcoming release

- Breaking: Support 3-letter chain labels (auth_sym_id) in CIF-files. Default and RSA output formats
have changes in whitespace as a consequence, to give space to the larger labels.

## 2.1.2

- Fix error where CLI options weren't parsed properly on ARM processors.
Expand Down
2 changes: 1 addition & 1 deletion src/cif.cc
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ freesasa_atom_from_site(const gemmi::cif::Table::Row &site)
auth_atom_id = site[5].c_str();
}

return freesasa_cif_atom_lcl {
return freesasa_cif_atom_lcl{
.group_PDB = site[0].c_str(),
.auth_asym_id = site[1].c_str(),
.auth_seq_id = site[2].c_str(),
Expand Down
8 changes: 4 additions & 4 deletions src/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ write_result(FILE *log,
fprintf(log, "atoms : %d\n", freesasa_node_structure_n_atoms(structure));

fprintf(log, "\nRESULTS (A^2)\n");
fprintf(log, "Total : %10.2f\n", area->total);
fprintf(log, "Apolar : %10.2f\n", area->apolar);
fprintf(log, "Polar : %10.2f\n", area->polar);
fprintf(log, "Total : %10.2f\n", area->total);
fprintf(log, "Apolar : %10.2f\n", area->apolar);
fprintf(log, "Polar : %10.2f\n", area->polar);
if (area->unknown > 0) {
fprintf(log, "Unknown : %10.2f\n", area->unknown);
}
Expand All @@ -68,7 +68,7 @@ write_result(FILE *log,
while (chain) {
area = freesasa_node_area(chain);
assert(area);
fprintf(log, "CHAIN %s : %10.2f\n", freesasa_node_name(chain), area->total);
fprintf(log, "CHAIN %3s : %10.2f\n", freesasa_node_name(chain), area->total);
chain = freesasa_node_next(chain);
}

Expand Down
13 changes: 5 additions & 8 deletions src/node.c
Original file line number Diff line number Diff line change
Expand Up @@ -326,15 +326,12 @@ node_chain(const freesasa_structure *structure,
const freesasa_result *result,
int chain_index)
{
const char *chains = freesasa_structure_chain_labels(structure);
char name[2] = {chains[chain_index], '\0'};
const char *name = freesasa_structure_chain_label(structure, chain_index);
freesasa_node *chain = NULL;
int first_atom, last_atom, first_residue, last_residue;

assert(strlen(chains) > chain_index);

freesasa_structure_chain_atoms(structure, chains[chain_index],
&first_atom, &last_atom);
freesasa_structure_chain_atoms_lcl(structure, name,
&first_atom, &last_atom);

chain = node_new(name);
if (chain == NULL) {
Expand All @@ -343,8 +340,8 @@ node_chain(const freesasa_structure *structure,
}

chain->type = FREESASA_NODE_CHAIN;
freesasa_structure_chain_residues(structure, name[0],
&first_residue, &last_residue);
freesasa_structure_chain_residues_lcl(structure, name,
&first_residue, &last_residue);
chain->properties.chain.n_residues = last_residue - first_residue + 1;

if (node_gen_children(chain, structure, result,
Expand Down
12 changes: 6 additions & 6 deletions src/rsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ rsa_print_residue(FILE *output,
freesasa_node *residue)
{
const char *resi_str;
char chain;
const char *chain;

resi_str = freesasa_node_residue_number(residue);
chain = freesasa_node_name(freesasa_node_parent(residue))[0];
chain = freesasa_node_name(freesasa_node_parent(residue));

fprintf(output, "RES %s %c%s ", abs->name, chain, resi_str);
fprintf(output, "RES %s %3s%-4s ", abs->name, chain, resi_str);
if (rel->name != NULL) {
rsa_print_abs_rel(output, abs->total, rel->total);
rsa_print_abs_rel(output, abs->side_chain, rel->side_chain);
Expand Down Expand Up @@ -152,8 +152,8 @@ int freesasa_write_rsa(FILE *output,
const char *name = freesasa_node_name(chain);
abs = freesasa_node_area(chain);

fprintf(output, "CHAIN%3d %c %10.1f %10.1f %10.1f %10.1f %10.1f\n",
chain_index + 1, name[0], abs->total, abs->side_chain,
fprintf(output, "CHAIN%3d %3s %10.1f %10.1f %10.1f %10.1f %10.1f\n",
chain_index + 1, name, abs->total, abs->side_chain,
abs->main_chain, abs->apolar, abs->polar);

++chain_index;
Expand All @@ -162,7 +162,7 @@ int freesasa_write_rsa(FILE *output,

abs = freesasa_node_area(structure_node);
fprintf(output, "END Absolute sums over all chains\n");
fprintf(output, "TOTAL %10.1f %10.1f %10.1f %10.1f %10.1f\n",
fprintf(output, "TOTAL %10.1f %10.1f %10.1f %10.1f %10.1f\n",
abs->total, abs->side_chain, abs->main_chain, abs->apolar, abs->polar);

fflush(output);
Expand Down
1 change: 1 addition & 0 deletions tests/test-cli.in
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ assert_pass "$cli --cif --format=cif --separate-chains $datadir/1ubq.cif > $dump
assert_pass "$cli --cif --format=cif --separate-chains --separate-models $datadir/1ubq.cif > $dump"
assert_fail "$cli --cif --format=pdb $datadir/1ubq.cif > $dump"
assert_fail "$cli --format=cif $datadir/1ubq.pdb > $dump"
assert_pass $cli --cif $datadir/7cma-assembly1.cif | grep 'CHAIN C-2 : 8980.86'

echo
echo "== Testing --separate-chains and --separate-models output are equal between cif and pdb"
Expand Down

0 comments on commit e6783ae

Please sign in to comment.