2 # -*- coding: utf-8 -*-
8 mes
= 'Usage: python spliceScoreConverter.py infile outfile'
10 def convert2binary(in_fn
,out_fn
):
14 # count number of lines
15 file_content
= open(in_fn
).read()
16 size
= len([e
for e
in file_content
if e
== '\n'])
18 positions
= array
.array('I',[0]*size
)
19 scores
= array
.array('f',[0.0]*size
)
21 for idx
,line
in enumerate(open(in_fn
)):
23 pos
,score
= line
.split(' ')
30 positions
.tofile(open('%s.pos'%out
_fn
,'wb'))
31 scores
.tofile(open('%s.Conf'%out
_fn
,'wb'))
33 if __name__
== '__main__':
34 if len(sys
.argv
)-1 != 2:
37 filename
= sys
.argv
[1]
38 assert os
.path
.exists(filename
), mes
40 out_filename
= sys
.argv
[2]
42 convert2binary(filename
,out_filename
)