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 atoms.

Related to #96.
  • Loading branch information
mittinatten committed Dec 10, 2023
1 parent ceed1b0 commit 34a3a34
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/freesasa.h
Original file line number Diff line number Diff line change
Expand Up @@ -1130,6 +1130,22 @@ freesasa_structure_atom_res_number(const freesasa_structure *structure,
char freesasa_structure_atom_chain(const freesasa_structure *structure,
int i);

/**
\private
Get long form chain label.
Asserts that index i is within bounds.
@param structure The structure.
@param i Atom index.
@return Chain label (`'A'`, `'B'`, etc.)
@ingroup structure
*/
const char *
freesasa_structure_atom_chain_lcl(const freesasa_structure *structure,
int i);

/**
Get atom symbol.
Expand Down
10 changes: 10 additions & 0 deletions src/structure.c
Original file line number Diff line number Diff line change
Expand Up @@ -1068,6 +1068,16 @@ char freesasa_structure_atom_chain(const freesasa_structure *structure,
assert(i < structure->atoms.n && i >= 0);
return structure->atoms.atom[i]->chain_label[0];
}

const char *
freesasa_structure_atom_chain_lcl(const freesasa_structure *structure,
int i)
{
assert(structure);
assert(i < structure->atoms.n && i >= 0);
return structure->atoms.atom[i]->chain_label;
}

const char *
freesasa_structure_atom_symbol(const freesasa_structure *structure,
int i)
Expand Down
1 change: 1 addition & 0 deletions tests/test_structure.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ START_TEST(test_cif)
ck_assert_str_eq(freesasa_structure_atom_res_number(s, i), rnu[i]);
ck_assert_str_eq(freesasa_structure_atom_symbol(s, i), symbol[i]);
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]);
}

struct freesasa_cif_atom_lcl atom = {
Expand Down

0 comments on commit 34a3a34

Please sign in to comment.