- python code is now checked and complete
authorfabio <fabio@e1793c9e-67f9-0310-80fc-b846ff1f7b36>
Wed, 5 Dec 2007 10:10:18 +0000 (10:10 +0000)
committerfabio <fabio@e1793c9e-67f9-0310-80fc-b846ff1f7b36>
Wed, 5 Dec 2007 10:10:18 +0000 (10:10 +0000)
- interface is complete
TODO

- Change logic in the myalign function
- Modify training loop accordingly

git-svn-id: http://svn.tuebingen.mpg.de/ag-raetsch/projects/QPalma@6927 e1793c9e-67f9-0310-80fc-b846ff1f7b36

python/.qpalma.py.swp
python/computeSpliceWeights.py
python/compute_donacc.py
python/penalty_lookup_new.py
python/qpalma.log
python/qpalma.py

index 67c7d20..37f0ebb 100644 (file)
Binary files a/python/.qpalma.py.swp and b/python/.qpalma.py.swp differ
index 20f9a9b..ba82fb5 100644 (file)
@@ -29,19 +29,21 @@ def calculateWeights(plf, scores):
       Lower = len([elem for elem in plf.limits if elem <= value])
       Upper = Lower+1 ; # x-werte bleiben fest
 
-      print value,Lower,Upper
+      Lower = Lower - 1
+      Upper = Upper - 1
 
       if Lower == 0:
-         currentWeight[0] = currentWeight[0] + 1
+         currentWeight[0] += 1
       elif Lower == len(plf.limits):
-         currentWeight[-1] = currentWeight[-1] + 1
+         currentWeight[-1] += 1
       else:
-         weightup  = (value - plf.limits[Lower]) / (plf.limits[Upper] - plf.limits[Lower])
-         weightlow = (plf.limits[Upper] - value) / (plf.limits[Upper] - plf.limits[Lower])
+         weightup  = 1.0*(value - plf.limits[Lower]) / (plf.limits[Upper] - plf.limits[Lower])
+         weightlow = 1.0*(plf.limits[Upper] - value) / (plf.limits[Upper] - plf.limits[Lower])
          currentWeight[Upper] = currentWeight[Upper] + weightup
          currentWeight[Lower] = currentWeight[Lower] + weightlow
 
-      print weightup,weightlow,currentWeight[Upper],currentWeight[Lower]
+      #print value,plf.limits[Lower],plf.limits[Upper]
+      #print weightup,weightlow,currentWeight[Upper],currentWeight[Lower]
 
    return currentWeight
 
index 534b1e3..b198877 100644 (file)
@@ -2,23 +2,25 @@
 # -*- coding: utf-8 -*-
 
 import math
-from numpy.matlib import zeros,inf
+from numpy.matlib import zeros,isinf
 from penalty_lookup_new import *
 
 def compute_donacc(donor_supp, acceptor_supp, d, a):
 
    assert(len(donor_supp)==len(acceptor_supp))
   
-   donor = zeros((len(donor_supp),1))
-   acceptor= zeros((len(acceptor_supp),1))
+   #donor = zeros((len(donor_supp),1))
+   #acceptor= zeros((len(acceptor_supp),1))
+   donor = [0.0]*len(donor_supp)
+   acceptor= [0.0]*len(acceptor_supp)
 
    for idx in range(len(donor_supp)):
-     if donor_supp[idx] == inf:
+     if isinf(donor_supp[idx]):
        donor[idx] = donor_supp[idx]
      else:
        donor[idx] = penalty_lookup_new(d, donor_supp[idx])
 
-     if acceptor_supp[idx] == inf:
+     if isinf(acceptor_supp[idx]):
        acceptor[idx] = acceptor_supp[idx]
      else:
        acceptor[idx] = penalty_lookup_new(a,acceptor_supp[idx])
index 81ffbc0..351ba73 100644 (file)
@@ -17,8 +17,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 +36,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
index 0bf5031..e69de29 100644 (file)
@@ -1,4 +0,0 @@
-genome_info.basedir is /fml/ag-raetsch/share/projects/palma/elegans_uncut/
-Number of training examples: 4604
-Starting training...Initializing problem...
-Starting training...
index 217561b..cc69c5f 100644 (file)
@@ -6,7 +6,7 @@ import subprocess
 import scipy.io
 from paths_load_data import *
 import pdb
-from numpy.matlib import mat,zeros,ones
+from numpy.matlib import mat,zeros,ones,inf
 from set_param_palma import *
 from computeSpliceAlign import *
 
@@ -161,28 +161,11 @@ def run():
          acc_supp = Acceptors[exampleId] 
 
          # Berechne die Parameter des wirklichen Alignments (but with untrained d,a,h ...)    
-
-         # trueSpliceAlign is equal
-         # trueWeightMatch is equal
          trueSpliceAlign, trueWeightMatch = computeSpliceAlign(dna, exons)
 
-         #print d.limits
-         #print d.penalties
-         #print a.limits
-         #print a.penalties
-         #print h.limits
-         #print h.penalties
-
-         ####################### checked above values ##########################################
-      
          # Calculate
          trueWeightDon, trueWeightAcc, trueWeightIntron = computeSpliceWeights(d, a, h, trueSpliceAlign, don_supp, acc_supp)
 
-         #print trueWeightDon.T
-         #print trueWeightAcc.T
-         #print trueWeightIntron.T
-
-         pdb.set_trace()
 
          # Reshape currentW param 
          currentW = zeros((numFeatures,1))
@@ -210,18 +193,21 @@ def run():
          # Compute donor, acceptor with penalty_lookup_new
          # returns two double lists
          donor, acceptor = compute_donacc(don_supp, acc_supp, d, a)
-       
+
          #myalign wants the acceptor site on the g of the ag
          #acceptor = [acceptor(2:end) -Inf] ;
+         acceptor = acceptor[1:]
+         acceptor.append(-inf)
 
+         ####################### checked above values ##########################################
          nr_paths = 2
-         dna = 'acgtagct'
-         dna_len = len(dna)
 
-         est = 'acgtagct'
+         dna = str(dna)
+         est = str(est)
+         dna_len = len(dna)
          est_len = len(est)
 
-         matchmatrix = QPalmaDP.createDoubleArrayFromList([1.0]*36)
+         matchmatrix = QPalmaDP.createDoubleArrayFromList(mmatrix.flatten().tolist()[0])
          mm_len = 36
          donor = QPalmaDP.createDoubleArrayFromList([1,2.0,4])
          d_len = 3
@@ -236,6 +222,8 @@ def run():
          currentAlignment.setQualityMatrix(qualityMat,numQualSuppPoints)
          ps = h.convert2SWIG()
 
+         pdb.set_trace()
+
          currentAlignment.myalign( nr_paths, dna, dna_len,\
          est, est_len, ps, matchmatrix, mm_len, donor, d_len,\
          acceptor, a_len, remove_duplicate_scores, print_matrix)
@@ -245,7 +233,7 @@ def run():
          #  SpliceAlign = double(SpliceAlign') ; %column
          #  weightMatch = double(weightMatch') ;
 
-
+         break
       iteration_nr += 1
       break