def calc_min_dist(res1, res2):
    """Returns the minimum distance between any two atoms in res1 and res2."""
    md = -1
    for atom1 in res1:
        for atom2 in res2:
            dist = atom1-atom2  # biopython defines this operator 
            if md == -1 or dist < md:
                md = dist
    
    return md