+ changed PipelinHeuristic to support new data access functions
[qpalma.git] / cparser / test.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3
4 import qparser
5 import pdb
6
7 from qpalma.parsers import *
8
9
10 def cpu():
11 return (resource.getrusage(resource.RUSAGE_SELF).ru_utime+\
12 resource.getrusage(resource.RUSAGE_SELF).ru_stime)
13
14
15 def compare_entries(elem_1,elem_2):
16 all_eq = True
17
18 att = "chr"
19 eq = elem_1[att] == elem_2[att]
20 att = "seq"
21 eq = eq and elem_1[att] == elem_2[att]
22 att = "strand"
23 eq = eq and elem_1[att] == elem_2[att]
24 att = "splitpos"
25 eq = eq and elem_1[att] == elem_2[att]
26 att = "read_size"
27 eq = eq and elem_1[att] == elem_2[att]
28 att = "true_cut"
29 eq = eq and elem_1[att] == elem_2[att]
30
31
32 att = "prb"
33 eq = eq and elem_1[att] == elem_2[att]
34 att = "cal_prb"
35 eq = eq and elem_1[att] == elem_2[att]
36 att = "chastity"
37 eq = eq and elem_1[att] == elem_2[att]
38
39
40 att = "gene_id"
41 eq = eq and elem_1[att] == elem_2[att]
42 att = "p_start"
43 eq = eq and elem_1[att] == elem_2[att]
44 att = "exon_stop"
45 eq = eq and elem_1[att] == elem_2[att]
46 att = "exon_start"
47 eq = eq and elem_1[att] == elem_2[att]
48 att = "p_stop"
49 eq = eq and elem_1[att] == elem_2[att]
50
51 all_eq = all_eq and eq
52
53 return all_eq
54
55
56 def test_module():
57 #filename = 'allReads.full_20'
58 filename = '/fml/ag-raetsch/share/projects/qpalma/solexa/new_run/allReads.full'
59
60 start = cpu()
61 num_reads = qparser.parse_reads(filename)
62 stop = cpu()
63
64 print 'found %d num reads' % num_reads
65
66 #start = cpu()
67 #result_2 = parse_filtered_reads(filename)
68 #stop = cpu()
69
70 #for current_key in result_2.keys():
71 # current_read_1 = qparser.fetch_read(current_key)
72
73 # current_read_2 = result_2[current_key]
74
75 # print compare_entries(current_read_1,current_read_2)
76 # #pdb.set_trace()
77
78 def _test_module():
79 filename = '/fml/ag-raetsch/share/projects/qpalma/solexa/new_run/allReads.full_10k'
80
81 start = cpu()
82 map,result_1 = qparser.parse_reads(filename)
83 stop = cpu()
84
85 print stop - start
86
87 start = cpu()
88 result_2 = parse_filtered_reads(filename)
89 stop = cpu()
90
91 print stop - start
92
93 keys_1 = result_1.keys()
94 keys_2 = result_2.keys()
95
96 assert keys_1 == keys_2
97
98
99 print all_eq
100
101 if __name__ == '__main__':
102 test_module()