Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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():
# hydrogen = next((x for x in b if x.startswith("H")), 0)