How to use the mdanalysis.AtomHBondType.acc function in MDAnalysis

To help you get started, we’ve selected a few MDAnalysis examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github maxscheurer / pycontact / mdanalysis.py View on Github external
if hydrogen != 0:
                                # print("h bond to atom2")
                                bondindices2 = b2.to_indices()[bondcount2]
                                hydrogenidx = next(
                                    (k for k in bondindices2 if self.type_array[k].startswith("H")), -1)
                                if hydrogenidx != -1:
                                    # print(type_array[hydrogenidx])
                                    hydrogenAtomsBoundToAtom2.append(hydrogenidx)
                            bondcount2 += 1
                        # check hbond criteria for hydrogen atoms bound to first atom
                        for global_hatom in hydrogenAtomsBoundToAtom1:
                            conv_hatom = indices1.index(global_hatom)
                            typeHeavy = next((x.htype for x in heavyatoms if x.name == self.type_array[convindex2]),
                                             AtomHBondType.none)
                            # print(typeHeavy)
                            if typeHeavy == AtomHBondType.acc and (distarray[conv_hatom, idx2] <= hbondcutoff):
                                donorPosition = sel1.positions[idx1]
                                hydrogenPosition = sel1.positions[conv_hatom]
                                acceptorPosition = sel2.positions[idx2]
                                v1 = hydrogenPosition - acceptorPosition
                                v2 = hydrogenPosition - donorPosition
                                v1norm = np.linalg.norm(v1)
                                v2norm = np.linalg.norm(v2)
                                dot = np.dot(v1, v2)
                                angle = np.degrees(np.arccos(dot / (v1norm * v2norm)))
                                if angle >= hbondcutangle:
                                    dist = distarray[conv_hatom, idx2]
                                    new_hbond = HydrogenBond(convindex1, convindex2, global_hatom, dist, angle,
                                                             hbondcutoff,
                                                             hbondcutangle)
                                    hydrogenBonds.append(new_hbond)
                                    # print(str(convindex1) + " " + str(convindex2)