forked from HyeonbinJoHCho/seqff
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreates.py
59 lines (43 loc) · 1.8 KB
/
creates.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
47
48
49
50
51
52
53
54
55
56
57
58
59
import os
def create_newtemp(newtemp, file, outdir):
"""
Returns nothing
Creates a counts-formatted file as outpath using bincount(=newtemp) dictionary data
:param bincount: dict
:param file: filename of sam file
:param outdir: str
"""
if not os.path.exists(outdir):
os.mkdir(outdir)
outfilename = os.path.join(outdir, os.path.split(file)[1]) + ".newtemp"
with open(outfilename ,'w') as outfile:
for key, val in newtemp.items():
print(key, val, sep="\t", file=outfile)
def create_normalizedbincount(normalizedbincount, file, outdir):
if not os.path.exists(outdir):
os.mkdir(outdir)
outfilename = os.path.join(outdir, os.path.split(file)[1]) + ".normalizedbincount"
with open(outfilename, 'w') as outfile:
for data in normalizedbincount:
print(data, file=outfile)
def create_alluseablebins(alluseablebins, file, outdir):
if not os.path.exists(outdir):
os.mkdir(outdir)
outfilename = os.path.join(outdir, os.path.split(file)[1]) + ".alluseablebins"
with open(outfilename, 'w') as outfile:
for data in alluseablebins:
print(data, file=outfile)
def create_bincounts(bincounts, file, outdir):
if not os.path.exists(outdir):
os.mkdir(outdir)
outfilename = os.path.join(outdir, os.path.split(file)[1]) + ".bincounts"
with open(outfilename, 'w') as outfile:
for data in bincounts:
print(data, file=outfile)
def create_results(lines, file, outdir):
if not os.path.exists(outdir):
os.mkdir(outdir)
outfilename = os.path.join(outdir, os.path.split(file)[1]) + ".results"
with open(outfilename, 'w') as outfile:
for line in lines:
print(line, file=outfile)