src/budeff/force_field.py
def assign_force_field(ampal_obj, ff):
    """Assigns force field parameters to Atoms in the AMPAL object.

    Parameters
    ----------
    ampal_obj : AMPAL Object
        Any AMPAL object with a `get_atoms` method.
    ff: BuffForceField
        The force field to be used for scoring.
    """
    if hasattr(ampal_obj, 'ligands'):
        atoms = ampal_obj.get_atoms(ligands=True, inc_alt_states=True)
    else:
        atoms = ampal_obj.get_atoms(inc_alt_states=True)
    for atom in atoms:
        w_str = None
        a_ff_id = None
        if atom.element == 'H':
            continue
        elif atom.parent.mol_code.upper() in ff:
            if atom.res_label.upper() in ff[atom.parent.mol_code]:
                a_ff_id = (atom.parent.mol_code.upper(),
                           atom.res_label.upper())
            elif atom.res_label.upper() in ff['WLD']:
                a_ff_id = ('WLD', atom.res_label.upper())
            else:
                w_str = ('{} atom is not parameterised in the selected '
                         'force field for {} residues, this will be '
                         'ignored.').format(
                             atom.res_label, atom.parent.mol_code)
        elif atom.res_label.upper() in ff['WLD']:
            a_ff_id = ('WLD', atom.res_label.upper())
        else:
            w_str = ('{} ({}) atom is not parameterised in the selected'
                     ' residue force field.').format(
                         atom.res_label, atom.parent.mol_code)
        if w_str:
            warnings.warn(w_str, NotParameterisedWarning)
        atom.tags['_buff_ff_id'] = a_ff_id
    return
def assign_force_field(ampal_obj, ff):
    """Assigns force field parameters to Atoms in the AMPAL object.

    Parameters
    ----------
    ampal_obj : AMPAL Object
        Any AMPAL object with a `get_atoms` method.
    ff: BuffForceField
        The force field to be used for scoring.
    """
    if hasattr(ampal_obj, 'ligands'):
        atoms = ampal_obj.get_atoms(ligands=True, inc_alt_states=True)
    else:
        atoms = ampal_obj.get_atoms(inc_alt_states=True)
    for atom in atoms:
        w_str = None
        a_ff_id = None
        if atom.element == 'H':
            continue
        elif atom.parent.mol_code.upper() in ff:
            if atom.res_label.upper() in ff[atom.parent.mol_code]:
                a_ff_id = (atom.parent.mol_code.upper(),
                           atom.res_label.upper())
            elif atom.res_label.upper() in ff['WLD']:
                a_ff_id = ('WLD', atom.res_label.upper())
            else:
                w_str = ('{} atom is not parameterised in the selected '
                         'force field for {} residues, this will be '
                         'ignored.').format(
                             atom.res_label, atom.parent.mol_code)
        elif atom.res_label.upper() in ff['WLD']:
            a_ff_id = ('WLD', atom.res_label.upper())
        else:
            w_str = ('{} ({}) atom is not parameterised in the selected'
                     ' residue force field.').format(
                         atom.res_label, atom.parent.mol_code)
        if w_str:
            warnings.warn(w_str, NotParameterisedWarning)
        atom.tags['_buff_ff_id'] = a_ff_id
    return
Assigns force field parameters to Atoms in the AMPAL object.

    Parameters
    ----------
    ampal_obj : AMPAL Object
        Any AMPAL object with a `get_atoms` method.
    ff: BuffForceField
        The force field to be used for scoring.