+ added small program for intron-position comparison
[qpalma.git] / qpalma / set_param_palma.py
index 0508a98..17740fd 100644 (file)
@@ -5,31 +5,30 @@ import math
 import numpy.matlib
 import QPalmaDP
 import pdb
-import Configuration as Conf
 from Plif import *
 
-def set_param_palma(param, train_with_intronlengthinformation,\
-                                               min_intron_len=None, max_intron_len=None, min_svm_score=None, max_svm_score=None):
+import qpalma.Configuration as Conf
+
+def set_param_palma(param, train_with_intronlengthinformation, run):
 
    print 'Setting parameters ...'
    
-   min_intron_len = Conf.min_intron_len 
-   max_intron_len = Conf.max_intron_len
+   min_intron_len = run['min_intron_len'] 
+   max_intron_len = run['max_intron_len']
 
-   min_svm_score = Conf.min_svm_score 
-   max_svm_score = Conf.max_svm_score 
+   min_svm_score = run['min_svm_score'] 
+   max_svm_score = run['max_svm_score'] 
 
    h = Plf()
    d = Plf()
    a = Plf()
-   qualityPlifs = [None]*Conf.numQualPlifs
 
-   donSP       = Conf.numDonSuppPoints
-   accSP       = Conf.numAccSuppPoints
-   lengthSP    = Conf.numLengthSuppPoints
-   mmatrixSP   = Conf.sizeMatchmatrix[0]\
-   *Conf.sizeMatchmatrix[1]
-   totalQualSP = Conf.totalQualSuppPoints
+   qualityPlifs = [None]*run['numQualPlifs']
+   donSP       = run['numDonSuppPoints']
+   accSP       = run['numAccSuppPoints']
+   lengthSP    = run['numLengthSuppPoints']
+   mmatrixSP   = run['matchmatrixRows']*run['matchmatrixCols']
+   totalQualSP = run['totalQualSuppPoints']
 
    ####################
    # Gapfunktion
@@ -77,21 +76,29 @@ def set_param_palma(param, train_with_intronlengthinformation,\
    # Matchmatrix
    ####################
    mmatrix = numpy.matlib.mat(param[lengthSP+donSP+accSP:lengthSP+donSP+accSP+mmatrixSP])
-   mmatrix.reshape(Conf.sizeMatchmatrix[0],Conf.sizeMatchmatrix[1]) 
+
+
+
+   mmatrix.reshape(run['matchmatrixRows'],run['matchmatrixCols'])
+
+
 
    ####################
    # Quality Plifs
    ####################
-   for idx in range(Conf.numQualPlifs):
+   for idx in range(run['numQualPlifs']):
       currentPlif = Plf()
-      currentPlif.limits    = linspace(Conf.min_qual,Conf.max_qual,Conf.numQualSuppPoints) 
-      begin                 = lengthSP+donSP+accSP+mmatrixSP+(idx*Conf.numQualSuppPoints)
-      end                   = lengthSP+donSP+accSP+mmatrixSP+((idx+1)*Conf.numQualSuppPoints)
+      currentPlif.limits    = linspace(run['min_qual'],run['max_qual'],run['numQualSuppPoints']) 
+      begin                 = lengthSP+donSP+accSP+mmatrixSP+(idx*run['numQualSuppPoints'])
+      end                   = lengthSP+donSP+accSP+mmatrixSP+((idx+1)*run['numQualSuppPoints'])
+
       currentPlif.penalties = param[begin:end].flatten().tolist()[0]
       currentPlif.transform = '' 
       currentPlif.name      = 'q' 
-      currentPlif.max_len   = Conf.max_qual 
-      currentPlif.min_len   = Conf.min_qual
+
+      currentPlif.max_len   = run['max_qual'] 
+      currentPlif.min_len   = run['min_qual']
+
       qualityPlifs[idx] = currentPlif
 
    return h,d,a,mmatrix,qualityPlifs