+ added small program for intron-position comparison
[qpalma.git] / qpalma / set_param_palma.py
index f760031..17740fd 100644 (file)
@@ -5,107 +5,69 @@ import math
 import numpy.matlib
 import QPalmaDP
 import pdb
-import Configuration
 from Plif import *
 
-def set_params_pa():
-   h = plf()
-   h.len = int(model.intron_len_bins) 
-   h.limits = model.intron_len_limits 
-   h.penalties = model.intron_len_penalties 
-   h.name = 'h'
-   h.max_len   = int(max_intron_len)
-   h.min_len   = int(min_intron_len)
-   h.transform = model.intron_len_transform
-
-   d = plf()
-   d.len = int(model.donor_bins)
-   d.limits = model.donor_limits
-   d.penalties = model.donor_penalties 
-   d.name = 'd'
-   d.max_len   = 100
-   d.min_len   = -100
-
-   a = plf()
-   a.len = int(model.acceptor_bins)
-   a.limits = model.acceptor_limits 
-   a.penalties = model.acceptor_penalties 
-   a.name = 'a'
-   a.max_len   = 100
-   a.min_len   = -100
-
-   mmatrix = model.substitution_matrix 
-
-
-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 ...'
    
-   if min_intron_len == None:
-      if train_with_intronlengthinformation:
-         min_intron_len=20
-         max_intron_len=1000
-      else:
-         min_intron_len = 1
-         max_intron_len = 2
-
-   if min_intron_len != None and max_intron_len != None:
-      min_svm_score=-5
-      max_svm_score=5
+   min_intron_len = run['min_intron_len'] 
+   max_intron_len = run['max_intron_len']
+
+   min_svm_score = run['min_svm_score'] 
+   max_svm_score = run['max_svm_score'] 
 
    h = Plf()
    d = Plf()
    a = Plf()
-   qualityPlifs = [None]*Configuration.numQualPlifs
 
-   donSP       = Configuration.numDonSuppPoints
-   accSP       = Configuration.numAccSuppPoints
-   lengthSP    = Configuration.numLengthSuppPoints
-   mmatrixSP   = Configuration.sizeMatchmatrix[0]\
-   *Configuration.sizeMatchmatrix[1]
-   totalQualSP = Configuration.totalQualSuppPoints
+   qualityPlifs = [None]*run['numQualPlifs']
+   donSP       = run['numDonSuppPoints']
+   accSP       = run['numAccSuppPoints']
+   lengthSP    = run['numLengthSuppPoints']
+   mmatrixSP   = run['matchmatrixRows']*run['matchmatrixCols']
+   totalQualSP = run['totalQualSuppPoints']
 
    ####################
    # Gapfunktion
    ####################
-   h.limits    = logspace(math.log(min_intron_len,10),math.log(max_intron_len,10),30
+   h.limits    = logspace(math.log(min_intron_len,10),math.log(max_intron_len,10),lengthSP
    h.penalties = param[0:lengthSP].flatten().tolist()[0]
    #h.transform = '+1' 
    h.transform = '' 
    h.name      = 'h' 
-   h.max_len   =  100000 
-   h.min_len   =  4 
+   h.max_len   = max_intron_len
+   h.min_len   = min_intron_len
    h.id        = 1 
    h.use_svm   = 0 
    h.next_id   = 0 
 
-
    ####################
    # Donorfunktion
    ####################
-   d.limits    = linspace(min_svm_score,max_svm_score,30) 
+   d.limits    = linspace(min_svm_score,max_svm_score,donSP)
    d.penalties = param[lengthSP:lengthSP+donSP].flatten().tolist()[0]
    #d.transform = '+1' 
    d.transform = '' 
    d.name      = 'd' 
-   d.max_len   = 100 
-   d.min_len   = -100 
+   d.max_len   = max_svm_score
+   d.min_len   = min_svm_score
    d.id        = 1 
    d.use_svm   = 0 
    d.next_id   = 0 
 
-
    ####################
    # Acceptorfunktion
    ####################
-   a.limits    = linspace(min_svm_score,max_svm_score,30) 
+   a.limits    = linspace(min_svm_score,max_svm_score,accSP)
    a.penalties = param[lengthSP+donSP:lengthSP+donSP+accSP].flatten().tolist()[0]
    #a.transform = '+1' 
    a.transform = '' 
    a.name      = 'a' 
-   a.max_len   = 100  
-   a.min_len   = -100  
+   a.max_len   = max_svm_score
+   a.min_len   = min_svm_score
    a.id        = 1 
    a.use_svm   = 0 
    a.next_id   = 0 
@@ -114,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(Configuration.sizeMatchmatrix[0],Configuration.sizeMatchmatrix[1]) 
+
+
+
+   mmatrix.reshape(run['matchmatrixRows'],run['matchmatrixCols'])
+
+
 
    ####################
    # Quality Plifs
    ####################
-   for idx in range(Configuration.numQualPlifs):
+   for idx in range(run['numQualPlifs']):
       currentPlif = Plf()
-      currentPlif.limits    = linspace(Configuration.min_qual,Configuration.max_qual,Configuration.numQualSuppPoints) 
-      begin                 = lengthSP+donSP+accSP+mmatrixSP+(idx*Configuration.numQualSuppPoints)
-      end                   = lengthSP+donSP+accSP+mmatrixSP+((idx+1)*Configuration.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   = Configuration.max_qual 
-      currentPlif.min_len   = Configuration.min_qual
+
+      currentPlif.max_len   = run['max_qual'] 
+      currentPlif.min_len   = run['min_qual']
+
       qualityPlifs[idx] = currentPlif
 
    return h,d,a,mmatrix,qualityPlifs