- python code is now checked and complete
[qpalma.git] / python / compute_donacc.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3
4 import math
5 from numpy.matlib import zeros,isinf
6 from penalty_lookup_new import *
7
8 def compute_donacc(donor_supp, acceptor_supp, d, a):
9
10 assert(len(donor_supp)==len(acceptor_supp))
11
12 #donor = zeros((len(donor_supp),1))
13 #acceptor= zeros((len(acceptor_supp),1))
14 donor = [0.0]*len(donor_supp)
15 acceptor= [0.0]*len(acceptor_supp)
16
17 for idx in range(len(donor_supp)):
18 if isinf(donor_supp[idx]):
19 donor[idx] = donor_supp[idx]
20 else:
21 donor[idx] = penalty_lookup_new(d, donor_supp[idx])
22
23 if isinf(acceptor_supp[idx]):
24 acceptor[idx] = acceptor_supp[idx]
25 else:
26 acceptor[idx] = penalty_lookup_new(a,acceptor_supp[idx])
27
28 return donor,acceptor