+ added VECTOR and MAP mode to ParaParser in order to handle entries with same
[qpalma.git] / ParaParser / simple_example.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3
4 import sys
5 from ParaParser import *
6
7 def run(file):
8 parser = ParaParser("%d%s%s%d%d",["field0","field1","field2","field3","field4"],5,IN_MAP)
9 parser.parseFile(file)
10 entry1_dict = parser.fetchEntry(1111)
11 print entry1_dict
12 entry2_dict = parser.fetchEntry(2222)
13 print entry2_dict
14 entry3_dict = parser.fetchEntry(3333)
15 print entry3_dict
16
17 del parser
18
19 parser2 = ParaParser("%d%s",["field0","field1"],2,IN_MAP)
20 file = 'test2.data'
21 parser2.parseFile(file)
22 entry1_dict = parser2.fetchEntry(1111)
23 print entry1_dict
24
25 parser2 = ParaParser("%lu%s",["field0","field1"],2,IN_MAP)
26 file = 'test3.data'
27 parser2.parseFile(file)
28 entry1_dict = parser2.fetchEntry(1000100000503)
29 print entry1_dict
30
31 fields = ['id', 'chr', 'pos', 'strand', 'mismatches', 'length',\
32 'offset', 'seq', 'prb', 'cal_prb', 'chastity']
33
34 parser2 = ParaParser("%lu%d%d%s%d%d%d%s%s%s%s",fields,len(fields),IN_VECTOR)
35 file = '/fml/ag-raetsch/home/fabio/tmp/transcriptome_data/MAP3'
36 parser2.parseFile(file)
37 entry1_dict = parser2.fetchEntry(0)
38 print entry1_dict
39 entry1_dict = parser2.fetchEntry(1)
40 print entry1_dict
41
42 if __name__ == '__main__':
43 run('test.data')