def test_rmsd(): n = 4 crds1 = [v3.random_vector() for i in range(n)] random_m = v3.random_rotation() crds2 = [v3.transform(random_m, c) for c in crds1] rms, m = rmsd.calc_rmsd_rot(crds1, crds2) assert v3.is_similar_mag(0, rms) # test the two algorithms separately rms, m = rmsd.pyqcprot_rmsd_rot(crds1, crds2) assert v3.is_similar_mag(0, rms) if rmsd.is_numpy: rms, m = rmsd.numpy_svd_rmsd_rot(crds1, crds2) assert v3.is_similar_mag(0, rms)
for i in range(0, len(indices), 2): yield indices[i:i+2] def get_crds(res_tags, soup): crds = [] i_residues = [soup.get_i_residue(r) for r in res_tags] for j, k in split_pairs(i_residues): for i in range(j, k+1): crds.append(soup.residue(i).atom('CA').pos) center = v3.get_center(crds) crds = [c-center for c in crds] return crds res_tags1 = "A:311 A:318 A:322 A:329 A:335 A:391".split() res_tags2 = "A:158 A:165 A:171 A:178 A:194 A:250".split() rmsd, rot = rmsd.pyqcprot_rmsd_rot( get_crds(res_tags1, soup), get_crds(res_tags2, soup2)) print "RMSD:" print rmsd # select polar/charged residues using regular expresions # and list comprehensions residues = filter( lambda r: re.match('(LY.|AR.|GL.|AS.).?', r.type), soup.residues()) print "Charged residues:" for res in residues: print res.tag()+'-'+res.type
def get_crds(res_tags, soup): crds = [] i_residues = [soup.get_i_residue(r) for r in res_tags] for j, k in split_pairs(i_residues): for i in range(j, k + 1): crds.append(soup.residue(i).atom('CA').pos) center = v3.get_center(crds) crds = [c - center for c in crds] return crds res_tags1 = "A:311 A:318 A:322 A:329 A:335 A:391".split() res_tags2 = "A:158 A:165 A:171 A:178 A:194 A:250".split() rmsd, rot = rmsd.pyqcprot_rmsd_rot(get_crds(res_tags1, soup), get_crds(res_tags2, soup2)) print "RMSD:" print rmsd # select polar/charged residues using regular expresions # and list comprehensions residues = filter(lambda r: re.match('(LY.|AR.|GL.|AS.).?', r.type), soup.residues()) print "Charged residues:" for res in residues: print res.tag() + '-' + res.type # find contact residue pairs by decomposing comparisons # into functions that can be used later