Skip to content

Commit

Permalink
add naming function for single-atom features
Browse files Browse the repository at this point in the history
  • Loading branch information
martinvoegele committed Jan 16, 2024
1 parent 988fa3c commit 13c638a
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions pensa/features/hbond_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,25 @@
from pensa.preprocessing.density import generate_grid, local_maxima_3D, write_atom_to_pdb


# ----------------------

# -------------------
# Helper Functions
#
# -------------------


def name_atom_features(u, atom_ids, feature_type='H-DON', naming='plain'):
atom_names = []
for id in atom_ids:
at = u.select_atoms('index %i' % id)[0]
if naming == 'chainid':
at_label = '%s %s %s %s' % (at.chainID, at.residue.resname, at.resid, at.name)
elif naming == 'segid':
at_label = '%s %s %s %s' % (at.segid, at.residue.resname, at.resid, at.name)
else:
at_label = '%s %s %s' % (at.residue.resname, at.resid, at.name)
atom_names.append('%s: %s' % (feature_type, at_label))
return atom_names


def name_pairs(u, all_pairs, pair_type='HBOND', naming='plain'):
pair_names = []
Expand All @@ -32,7 +48,8 @@ def name_pairs(u, all_pairs, pair_type='HBOND', naming='plain'):

# ----------------------------------------------------
# Functions based on a distance-and-angle criterion
#
# ----------------------------------------------------


def read_h_bonds(structure_input, xtc_input, selection1, selection2, naming='plain'):
"""
Expand Down Expand Up @@ -92,7 +109,7 @@ def read_h_bonds(structure_input, xtc_input, selection1, selection2, naming='pla

# -----------------------------------------------
# Functions based on a distance-only criterion
#
# -----------------------------------------------


def atg_to_names(atg):
Expand Down

0 comments on commit 13c638a

Please sign in to comment.