How to use the mdanalysis.AtomHBondType.none 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
# row = sel1, column = sel2
            distarray = distances.distance_array(sel1.positions, sel2.positions, box=None, result=result)
            contacts = np.where(distarray <= cutoff)
            # idx1 and idx2 correspond to a row,column in contacts, respectively
            # they do NOT correspond to a global atom index!
            for idx1, idx2 in itertools.izip(contacts[0], contacts[1]):
                convindex1 = indices1[idx1]  # idx1 converted to global atom indexing
                convindex2 = indices2[idx2]  # idx2 converted to global atom indexing
                # jump out of loop if hydrogen contacts are found, only contacts between heavy atoms are considered, hydrogen bonds can still be detected!
                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]
github maxscheurer / pycontact / mdanalysis.py View on Github external
convindex1 = indices1[idx1]  # idx1 converted to global atom indexing
                convindex2 = indices2[idx2]  # idx2 converted to global atom indexing
                # jump out of loop if hydrogen contacts are found, only contacts between heavy atoms are considered, hydrogen bonds can still be detected!
                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():