+ parser works now with mmap and sscanf
[qpalma.git] / python / penalty_lookup_new.py
index 81ffbc0..a0f5d1c 100644 (file)
@@ -2,6 +2,7 @@
 # -*- coding: utf-8 -*-
 
 import math
+import pdb
 
 def penalty_lookup_new(penalty_struct, value):
 
@@ -17,8 +18,10 @@ def penalty_lookup_new(penalty_struct, value):
    elif penalty_struct.transform == 'log(+1)':
       value = math.log(value+1)
 
-   elif penalty_struct.transform == '' or\
-        penalty_struct.transform == '(+3)':
+   elif penalty_struct.transform == '':
+      pass
+
+   elif penalty_struct.transform == '(+3)':
       value += 3
          
    elif penalty_struct.transform == 'mod3':
@@ -34,7 +37,7 @@ def penalty_lookup_new(penalty_struct, value):
    elif count == len(limits):
      pen=penalties[-1]
    else:
-     pen = (penalties[count+1]*(value-limits[count]) + penalties[count]\
-         *(limits[count+1]-value)) / (limits[count+1]-limits[count])
+     pen = (penalties[count]*(value-limits[count-1]) + penalties[count-1]\
+         *(limits[count]-value)) / (limits[count]-limits[count-1])
 
    return pen