def resname_in_proximity(resname, model, chains, resnums, threshold=5):
    """Search within the proximity of a defined list of residue numbers and their chains for any specifed residue name.

    Args:
        resname (str): Residue name to search for in proximity of specified chains + resnums
        model: Biopython Model object
        chains (str, list): Chain ID or IDs to check
        resnums (int, list): Residue numbers within the chain to check
        threshold (float): Cutoff in Angstroms for returning True if a RESNAME is near

    Returns:
        bool: True if a RESNAME is within the threshold cutoff

    """
    residues = [r for r in model.get_residues() if r.get_resname() == resname]

    chains = ssbio.utils.force_list(chains)
    resnums = ssbio.utils.force_list(resnums)

    for chain in chains:
        for resnum in resnums:
            my_residue_last_atom = model[chain][resnum].child_list[-1]
            for rz in residues:
                distance = rz.child_list[-1] - my_residue_last_atom
                if distance < threshold:
                    # print(resnum, rz, distance)
                    return True

    return False
def resname_in_proximity ( resname , model , chains , resnums , threshold = 5 ) : residues = [ r for r in model . get_residues ( ) if r . get_resname ( ) == resname ] chains = ssbio . utils . force_list ( chains ) resnums = ssbio . utils . force_list ( resnums ) for chain in chains : for resnum in resnums : my_residue_last_atom = model [ chain ] [ resnum ] . child_list [ - 1 ] for rz in residues : distance = rz . child_list [ - 1 ] - my_residue_last_atom if distance < threshold : return True return False
Search within the proximity of a defined list of residue numbers and their chains for any specifed residue name.

    Args:
        resname (str): Residue name to search for in proximity of specified chains + resnums
        model: Biopython Model object
        chains (str, list): Chain ID or IDs to check
        resnums (int, list): Residue numbers within the chain to check
        threshold (float): Cutoff in Angstroms for returning True if a RESNAME is near

    Returns:
        bool: True if a RESNAME is within the threshold cutoff