Skip to content

Commit

Permalink
Add function to allow getting string-valued auth_asym_id/chain-labels…
Browse files Browse the repository at this point in the history
… from residues.

Related to #96.
  • Loading branch information
mittinatten committed Dec 10, 2023
1 parent 34a3a34 commit 4ff453c
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/freesasa.h
Expand Up @@ -945,6 +945,9 @@ int freesasa_structure_add_cif_atom(freesasa_structure *structure,
\private
Add atoms from a mmCIF file to a structure using strings for chain labels (LCL)
This is an intermediate function added in the process of migrating to long chain labels.
It is not meant to be part of the public API for now.
@param structure The structure to add to.
@param atom An atom site from a mmCIF file with long chain labels
@param classifier A ::freesasa_classifier to determine radius of atom and to
Expand Down Expand Up @@ -1136,6 +1139,9 @@ char freesasa_structure_atom_chain(const freesasa_structure *structure,
Asserts that index i is within bounds.
This is an intermediate function added in the process of migrating to long chain labels.
It is not meant to be part of the public API for now.
@param structure The structure.
@param i Atom index.
@return Chain label (`'A'`, `'B'`, etc.)
Expand Down Expand Up @@ -1231,6 +1237,22 @@ freesasa_structure_residue_number(const freesasa_structure *structure,
char freesasa_structure_residue_chain(const freesasa_structure *structure,
int r_i);

/**
\private
Get long form chain residue belongs to.
This is an intermediate function added in the process of migrating to long chain labels.
It is not meant to be part of the public API for now.
@param structure The structure.
@param r_i Residue index (in whole structure).
@return Chain label.
@ingroup structure
*/
const char *
freesasa_structure_residue_chain_lcl(const freesasa_structure *structure,
int r_i);
/**
Get model number for structure.
Expand Down
10 changes: 10 additions & 0 deletions src/structure.c
Expand Up @@ -1182,6 +1182,16 @@ char freesasa_structure_residue_chain(const freesasa_structure *structure,
return structure->atoms.atom[structure->residues.first_atom[r_i]]->chain_label[0];
}

const char *
freesasa_structure_residue_chain_lcl(const freesasa_structure *structure,
int r_i)
{
assert(structure);
assert(r_i < structure->residues.n && r_i >= 0);

return structure->atoms.atom[structure->residues.first_atom[r_i]]->chain_label;
}

int freesasa_structure_n_chains(const freesasa_structure *structure)
{
return structure->chains.n;
Expand Down
2 changes: 2 additions & 0 deletions tests/test_structure.c
Expand Up @@ -148,6 +148,8 @@ START_TEST(test_cif)
ck_assert_int_eq(freesasa_structure_atom_chain(s, i), lcl[i][0]);
ck_assert_str_eq(freesasa_structure_atom_chain_lcl(s, i), lcl[i]);
}
ck_assert_int_eq(freesasa_structure_residue_chain(s, 0), lcl[0][0]);
ck_assert_str_eq(freesasa_structure_residue_chain_lcl(s, 0), lcl[0]);

struct freesasa_cif_atom_lcl atom = {
.group_PDB = "",
Expand Down

0 comments on commit 4ff453c

Please sign in to comment.