+ changes
authorfabio <fabio@e1793c9e-67f9-0310-80fc-b846ff1f7b36>
Thu, 17 Apr 2008 18:33:36 +0000 (18:33 +0000)
committerfabio <fabio@e1793c9e-67f9-0310-80fc-b846ff1f7b36>
Thu, 17 Apr 2008 18:33:36 +0000 (18:33 +0000)
git-svn-id: http://svn.tuebingen.mpg.de/ag-raetsch/projects/QPalma@8586 e1793c9e-67f9-0310-80fc-b846ff1f7b36

qpalma/computeSpliceAlignWithQuality.py

index 04283d7..6a679e5 100644 (file)
@@ -19,33 +19,41 @@ def  computeSpliceAlignWithQuality(dna, exons, est, original_est, quality, quali
    cccccXXcccccA1cccccE1 ... Em-1cccXXcccccccc
    """
 
-   numberOfExons = 2
-   exonSizes = [-1]*numberOfExons
+   SpliceAlign = []
 
-   exonSizes[0] = exons[0,1] - exons[0,0]
-   exonSizes[1] = exons[1,1] - exons[1,0]
+   if exons.shape == (2,2):
+      numberOfExons = 2
+      exonSizes = [-1]*numberOfExons
 
-   # SpliceAlign vector describes alignment: 
-   # 1:donorpos, 3:intron 2:acceptorpos, 0:exon, 4: dangling end
-   SpliceAlign = []
+      exonSizes[0] = exons[0,1] - exons[0,0]
+      exonSizes[1] = exons[1,1] - exons[1,0]
 
-   if exons[0,0] > 0:
-      SpliceAlign.extend([4]*(exons[0,0]))
+      # SpliceAlign vector describes alignment: 
+      # 1:donorpos, 3:intron 2:acceptorpos, 0:exon, 4: dangling end
 
-   for idx in range(numberOfExons):
-      exonLength = exonSizes[idx]
-      SpliceAlign.extend([0]*exonLength)
-      
-      if idx < numberOfExons-1:
-         intronLength = exons[idx+1,0] - exons[idx,1]
-         SpliceAlign.extend([1]+[3]*(intronLength-2)+[2])
+      if exons[0,0] > 0:
+         SpliceAlign.extend([4]*(exons[0,0]))
 
-   if len(dna) > exons[-1,1]:
-      SpliceAlign.extend([4]*(len(dna)-exons[-1,1]))
+      for idx in range(numberOfExons):
+         exonLength = exonSizes[idx]
+         SpliceAlign.extend([0]*exonLength)
+         
+         if idx < numberOfExons-1:
+            intronLength = exons[idx+1,0] - exons[idx,1]
+            SpliceAlign.extend([1]+[3]*(intronLength-2)+[2])
 
-   assert len(SpliceAlign) == len(dna), pdb.set_trace()
+      if len(dna) > exons[-1,1]:
+         SpliceAlign.extend([4]*(len(dna)-exons[-1,1]))
 
-   #pdb.set_trace()
+
+   elif exons.shape == (2,1):
+      exonSize = exons[1,0] - exons[0,0]
+      SpliceAlign.extend([0]*(exonSize))
+
+   else:
+      pass
+
+   assert len(SpliceAlign) == len(dna), pdb.set_trace()
 
    #  
    # start of label feature generation
@@ -151,8 +159,15 @@ def  computeSpliceAlignWithQuality(dna, exons, est, original_est, quality, quali
    #assert int(featureSum) == len(est_part),pdb.set_trace()
    # 'feature sum is not equal read size!!'
 
-   dna_orig = dna[exons[0,0]:exons[0,1]]
-   dna_orig += dna[exons[1,0]:exons[1,1]]
+   if exons.shape == (2,2):
+      dna_orig = dna[exons[0,0]:exons[0,1]]
+      dna_orig += dna[exons[1,0]:exons[1,1]]
+   elif exons.shape == (2,1):
+      #dna_orig = dna[exons[0,0]:exons[1,0]]
+      pass
+   else:
+      pass
+
    dna_calc = "".join(dna_part)
 
    #assert dna_orig == dna_calc, pdb.set_trace()