+ saving results in two files (spliced/unspliced)
authorfabio <fabio@e1793c9e-67f9-0310-80fc-b846ff1f7b36>
Fri, 18 Apr 2008 10:43:28 +0000 (10:43 +0000)
committerfabio <fabio@e1793c9e-67f9-0310-80fc-b846ff1f7b36>
Fri, 18 Apr 2008 10:43:28 +0000 (10:43 +0000)
git-svn-id: http://svn.tuebingen.mpg.de/ag-raetsch/projects/QPalma@8670 e1793c9e-67f9-0310-80fc-b846ff1f7b36

scripts/PipelineHeuristic.py

index 8fee495..5d4c392 100644 (file)
@@ -53,7 +53,7 @@ class PipelineHeuristic:
    vmatch is spliced an should be then newly aligned using QPalma or not.
    """
 
-   def __init__(self,run_fname,data_fname,param_fname):
+   def __init__(self,run_fname,data_fname,param_fname,result_spliced_fname,result_unspliced_fname):
       """
       We need a run object holding information about the nr. of support points
       etc.
@@ -62,6 +62,9 @@ class PipelineHeuristic:
       run = cPickle.load(open(run_fname))
       self.run = run
 
+      self.result_spliced_fh = open(result_spliced_fname,'w+')
+      self.result_unspliced_fh = open(result_unspliced_fname,'w+')
+
       start = cpu()
 
       self.data_fname = data_fname
@@ -175,6 +178,13 @@ class PipelineHeuristic:
 
             id = int(id)
 
+            strand_map = {'+':'D', '-':'P'}
+
+
+            original_line = '%d\t%d\t%d\t%s\t%d\t%d\t%d\t%s\t%s\t%s\t%s\n' %\
+            (id,chr,pos,strand_map[strand],int(mismatch),int(length),int(off),seq.upper(),prb,cal_prb,chastity)
+
+
             if strand == '-':
                continue
 
@@ -236,6 +246,8 @@ class PipelineHeuristic:
             if maxAlternativeAlignmentScore < vMatchScore:
                unspliced_ctr += 1
 
+               self.result_unspliced_fh.write(original_line) 
+
                if unspliced:
                   self.true_neg += 1
                else:
@@ -246,6 +258,8 @@ class PipelineHeuristic:
             else:
                spliced_ctr += 1
 
+               self.result_spliced_fh.write(original_line)
+
                if unspliced:
                   self.false_pos += 1
                else:
@@ -541,7 +555,10 @@ if __name__ == '__main__':
 
    param_fname = jp(dir,'param_500.pickle')
 
-   ph1 = PipelineHeuristic(run_fname,data_fname,param_fname)
+   result_spliced_fname    = 'splicedReads.heuristic'
+   result_unspliced_fname  = 'unsplicedReads.heuristic'
+
+   ph1 = PipelineHeuristic(run_fname,data_fname,param_fname,result_spliced_fname,result_unspliced_fname)
 
    start = cpu()
    ph1.filter()