def measure(self, structure): try: a = lookup(self.descriptionA, structure).center b = lookup(self.descriptionB, structure).center c = lookup(self.descriptionC, structure).center return angle(a, b, c) except AttributeError: print "ANGLE MEASURE FALIURE :", self.descriptionA, self.descriptionB, self.descriptionC return 0.0
def satisfiedBy(self, example): try: a = lookup(self.descriptionA, example).center b = lookup(self.descriptionB, example).center c = lookup(self.descriptionC, example).center except DescriptionException: return False except AttributeError: return False aa = angle(a, b, c) satisfied = self.center - self.range < aa < self.center + self.range if self.negated: satisfied = not satisfied if satisfied: chain.__dict__[self.name] = aa return satisfied # ho ho else: return False
acceptorAtomPosition = lookup(self.acceptorDescription, example).center attachedAtomPosition = lookup(self.attachedDescription, example).center except DescriptionException, d: return False except AttributeError, ae: #sys.stderr.write(str(ae) +"\n") #import traceback #traceback.print_exc(limit=4, file=sys.stdout) return False satisfied = False #h_a, dha, haa = None, None, None h_a = distance(hydrogenAtomPosition, acceptorAtomPosition) if h_a < self.distanceHACutoff: dha = angle(donorAtomPosition, hydrogenAtomPosition, acceptorAtomPosition) if dha > self.angleDHACutoff: haa = angle(hydrogenAtomPosition, acceptorAtomPosition, attachedAtomPosition) if haa > self.angleHAACutoff: satisfied = True #sys.stderr.write("satisfied %s %s %s %s\n" % (satisfied, h_a, dha, haa)) if self.negated: if satisfied: return False else: return True else: if satisfied: example.__dict__[self.name + ":H_A"] = h_a example.__dict__[self.name + ":DHA"] = dha