-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathbdgToWig.py
executable file
·45 lines (43 loc) · 1.35 KB
/
bdgToWig.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#from __future__ import division, with_statement
'''
Copyright 2010, 陈同 ([email protected]).
Please see the license file for legal information.
===========================================================
'''
__author__ = 'chentong & ct586[9]'
__author_email__ = '[email protected]'
#=========================================================
import sys
def main():
print >>sys.stderr, "Print the result to screen"
if len(sys.argv) != 2:
print >>sys.stderr, 'Using python %s bdgfile' % sys.argv[0]
sys.exit(0)
#------------------------------------------------
"""
bdg: zero-based, half-open.
wig: 1-based
bed: zero-based, half-open.
"""
chr = ''
for line in open(sys.argv[1]):
lineL = line.strip().split()
assert(len(lineL) == 4)
if chr:
if chr != lineL[0]:
chr = lineL[0]
print 'variableStep chrom=%s' % (chr)
else:
chr = lineL[0]
print 'variableStep chrom=%s' % (chr)
#----------------------------------------
start = int(lineL[1]) + 1
end = int(lineL[2]) + 1
assert(start < end)
value = lineL[3]
for i in range(start, end):
print "%d\t%s" % (i, value)
if __name__ == '__main__':
main()