def parsegene_hbonds_site_reference(c, ref=None): if ref is None: ref = c.structures[0] # First, calculate molecules, molecule sites and hydrogen bonds MoleculeSites.get(ref) HydrogenBonds.get(ref) MoleculeSites.get(c) HydrogenBonds.get(c) # Now for the actual comparison we need to compile a list of Hbonds # for each structure, expressed in terms of molecular sites reflabels = HydrogenBondTypes.get(ref) hblabels = HydrogenBondTypes.get(c) # And now to actually create a comparison distL = [] for hb_lab in hblabels: distL.append(list_distance(hb_lab, reflabels)) return np.array(distL)
def parsegene_hbonds_site_compare(c): # First, calculate molecules, molecule sites and hydrogen bonds MoleculeSites.get(c) HydrogenBonds.get(c) # Now for the actual comparison we need to compile a list of Hbonds # for each structure, expressed in terms of molecular sites hblabels = HydrogenBondTypes.get(c) # And now to actually create a comparison distM = np.zeros((c.length, c.length)) for hb_i1, hb_lab1 in enumerate(hblabels): for hb_i2, hb_lab2 in enumerate(hblabels[hb_i1 + 1:]): d = list_distance(hb_lab1, hb_lab2) d /= (len(hb_lab1) + len(hb_lab2)) * 0.5 distM[hb_i1, hb_i1 + hb_i2 + 1] = d distM[hb_i1 + hb_i2 + 1, hb_i1] = d return distM
def test_labelprops(self): from soprano.properties.labeling import (MoleculeSites, HydrogenBondTypes) a = read(os.path.join(_TESTDATA_DIR, 'nh3.cif')) nh3_sites = MoleculeSites.get(a)[0] # Check the name self.assertEqual(nh3_sites['name'], 'H[N[H,H]]') # Check the sites self.assertEqual(set(nh3_sites['sites'].values()), set(['N_1', 'H_1'])) # Now we test hydrogen bond types with alanine a = read(os.path.join(_TESTDATA_DIR, 'mol_crystal.cif')) # We expect 12 identical ones hbtypes = ['C[C[C[H,H,H],H,N[H,H,H]],O,O]<N_1,H_2>' '..C[C[C[H,H,H],H,N[H,H,H]],O,O]<O_1>']*12 self.assertEqual(HydrogenBondTypes.get(a), hbtypes)