Skip to content

Instantly share code, notes, and snippets.

@chrisjurich
Last active September 13, 2021 18:11
Show Gist options
  • Save chrisjurich/965b199a72aef7c2f13a107c948e6c83 to your computer and use it in GitHub Desktop.
Save chrisjurich/965b199a72aef7c2f13a107c948e6c83 to your computer and use it in GitHub Desktop.
import math
def stat_test( lower_avg, lower_err, upper_avg, upper_err ):
# not a real funciton but shoudl return a p value that the
# lower_avg < upper_avg
raise TypeError("not implemented")
def score( structure, reacts, react_errors, critical=0.01 ):
assert critical >= 0 and critical <= 1, f"Critical value must be on range [0-1]"
paired, unpaired = [], []
for idx, db in enumerate( structure ):
if db == '.':
unpaired.append( idx )
else:
paired.append( idx )
denom, numerator = len(paired)*len(unpaired), 0
for p in paired:
for up in unpaired:
ans = -math.log(stat_test(reacts[p], react_errors[p], reacts[up], react_errors[up])/critical)
ans = max(ans, 0)
ans = min(ans, 1)
# TODO need to some checks in case if ans is math.inf or math.Nan
denom += ans
return denom / numerator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment