How to use the mdanalysis.AtomHBondType.don 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 re.match("H(.*)", self.name_array[convindex1]) or re.match("H(.*)", self.name_array[convindex2]):
                    continue
                    # distance between atom1 and atom2
                distance = distarray[idx1, idx2]
                weight = self.weight_function(distance)
                # read AtomHBondType from heavyatoms list
                type1 = next((x.htype for x in heavyatoms if x.name == self.type_array[convindex1]), AtomHBondType.none)
                type2 = next((x.htype for x in heavyatoms if x.name == self.type_array[convindex2]), AtomHBondType.none)
                ## HydrogenBondAlgorithm
                # TODO: outsource to another file?
                # elongates the current loop a lot...
                hydrogenBonds = []
                if type1 != AtomHBondType.none and type2 != AtomHBondType.none:
                    if (type1 == AtomHBondType.both and type2 == AtomHBondType.both) or \
                            (type1 == AtomHBondType.acc and type2 == AtomHBondType.don) or \
                            (type1 == AtomHBondType.don and type2 == AtomHBondType.acc) or \
                            (type1 == AtomHBondType.both and type2 == AtomHBondType.acc) or \
                            (type1 == AtomHBondType.acc and type2 == AtomHBondType.both) or \
                            (type1 == AtomHBondType.don and type2 == AtomHBondType.both) or \
                            (type1 == AtomHBondType.both and type2 == AtomHBondType.don):
                        # print("hbond? %s - %s" % (type_array[convindex1], type_array[convindex2]))
                        # search for hatom, check numbering in bond!!!!!!!!!!
                        b1 = self.bonds[convindex1]
                        b2 = self.bonds[convindex2]
                        # search for hydrogen atoms bound to atom 1
                        bondcount1 = 0
                        hydrogenAtomsBoundToAtom1 = []
                        # old code, wrong!
                        # for b in b1.types():
                        #     hydrogen = next((x for x in b if x.startswith("H")), 0)
                        #     # print(b)
                        #     if hydrogen != 0: