-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRunx1_2_fa.py
46 lines (33 loc) · 994 Bytes
/
Runx1_2_fa.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
45
46
#!/usr/bin/env python
import re, os, sys, shutil
from math import *
from string import *
from optparse import OptionParser
import operator
import bisect
plus = re.compile("\+");
minus = re.compile("\-");
Dir = os.getcwd();
'''
This module is to separate BED file into 2, according to the size of each region.
'''
def main(argv):
parser = OptionParser()
parser.add_option("-b", "--sample", action="store", type="string", dest="infile", metavar="<file>", help="sample name")
parser.add_option("-o", "--output", action="store", type="string", dest="out_file", metavar="<file>", help="name of output file")
(opt, args) = parser.parse_args(argv)
if len(argv) < 4:
parser.print_help()
sys.exit(1)
f = open(opt.infile, 'r')
u = open(opt.out_file, 'w')
for line in f:
if not re.search("#", line):
line = line.strip()
sline = line.split(":")
u.write(">\n")
u.write(sline[5]+"\n")
f.close()
u.close()
if __name__ == "__main__":
main(sys.argv)