import pymol from pymol import cmd cmd.load("6oqh.cif", "6oqh" , state=0) to_print = [] for i in range(1, 11): dist_list = [] dist_list.append(cmd.get_distance("47/N", "36/O", state=i)) dist_list.append(min(cmd.get_distance("170/ND2", "154/OE1", state=i), cmd.get_distance("170/ND2", "154/OE2", state=i))) dist_list.append(min(cmd.get_distance("179/N", "148/OD1", state=i), cmd.get_distance("179/N", "148/OD2", state=i))) to_print.append("\t".join(map(lambda x: str(round(x, 2)), dist_list))) with open("./dist.txt", "w") as file: print("47_36\t170_154\t179_148", file=file) print(*to_print, sep="\n", file=file)