git-svn-id: http://svn.tuebingen.mpg.de/ag-raetsch/projects/QPalma@8640 e1793c9e...
[qpalma.git] / scripts / createAlignmentFileFromPrediction.py
index e089626..78f7ebe 100644 (file)
@@ -27,6 +27,7 @@ def prediction_on(filename):
          strand      = current_pred['strand']
          true_cut    = current_pred['true_cut']
          start_pos   = current_pred['alternative_start_pos']
+         alignment   = current_pred['alignment']
 
          predExons = current_pred['predExons']
          trueExons = current_pred['trueExons']
@@ -41,7 +42,7 @@ def prediction_on(filename):
 
             #line = '%d\t%d\t%d\t%d\t%d\n' % (exampleId,p1,p2,p3,p4)
             #print line
-            allPositions[exampleId] = (chr,strand,start_pos,true_cut,p1,p2,p3,p4)
+            allPositions[exampleId] = (chr,strand,start_pos,true_cut,p1,p2,p3,p4,alignment)
 
 
    return allPositions
@@ -62,16 +63,25 @@ def writePredictions(fname,allPositions):
 
 
    for id,elems in allPositions.items():
-      seq,q1,q2,q3 = allEntries[1000000000000+id]
-      chr,strand,start_pos,true_cut,p1,p2,p3,p4 = elems
+      id += 1000000000000
+      seq,q1,q2,q3 = allEntries[id]
+      chr,strand,start_pos,true_cut,p1,p2,p3,p4,alignment = elems
 
       p1 += start_pos
       p2 += start_pos
       p3 += start_pos
       p4 += start_pos
 
-      new_line = '%d\t%d\t%s\t%s\t%s\t%s\t%s\t%d\t%d\t%d\t%d\t%d\n' %\
-      (id,chr,strand,seq,q1,q2,q3,true_cut,p1,p2,p3,p4)
+      #pdb.set_trace()
+
+      (qStart, qEnd, tStart, tEnd, num_exons, qExonSizes, qStarts, qEnds,\
+      tExonSizes,tStarts, tEnds) = alignment 
+
+      new_line = '%d\t%d\t%s\t%s\t%s\t%d\t%d\t%d\t%d\t%d\t%d\t%s\t%s\t%s\t%s\t%s\t%s\n' %\
+      (id,chr,strand,seq,q1,start_pos,qStart,qEnd,tStart,tEnd,num_exons,\
+      str(qExonSizes)[1:-1].replace(' ',''),str(qStarts)[1:-1].replace(' ',''),\
+      str(qEnds)[1:-1].replace(' ',''),str(tExonSizes)[1:-1].replace(' ',''),\
+      str(tStarts)[1:-1].replace(' ',''),str(tEnds)[1:-1].replace(' ',''))
 
       out_fh.write(new_line)