-
Notifications
You must be signed in to change notification settings - Fork 1
/
add_abs.py
41 lines (32 loc) · 1011 Bytes
/
add_abs.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
#!/usr/bin/env python
import re, os, sys, shutil
from math import *
from string import *
from optparse import OptionParser
import operator
def add_tag_density(infile, outfile):
f = open(infile,'r')
o = open(outfile, 'w')
for line in f:
if not re.match("#", line):
line = line.strip()
sline = line.split()
corr = atof(sline[2])
abso = abs(corr)
sline.append(str(abso))
o.write('\t'.join(sline)+'\n')
f.close()
o.close()
def main(argv):
parser = OptionParser()
parser.add_option("-b", "--island_bed_file", action="store", type="string",
dest="bed_file", help="island bed file", metavar="<file>")
parser.add_option("-o", "--output_file_name", action="store", type="string",
dest="out_file", help="output file name", metavar="<file>")
(opt, args) = parser.parse_args(argv)
if len(argv) < 4:
parser.print_help()
sys.exit(1)
add_tag_density(opt.bed_file, opt.out_file)
if __name__ == "__main__":
main(sys.argv)