-
Notifications
You must be signed in to change notification settings - Fork 0
/
homer2MEME.py
31 lines (25 loc) · 934 Bytes
/
homer2MEME.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
import os
import glob
import pandas as pd
out_str = ''
d = []
for fname in glob.glob("./*motif*"):
for line in open(fname, 'r'):
if line.startswith(">"):
if len(d) > 0:
out_str = out_str + '\n' + motif + '\n' + \
pd.DataFrame(d, columns=["A:", "C:", "G:", "T:"]) \
.T \
.to_csv(sep='\t', header=False)
motif = line.rstrip().split("\t")[0].replace(">", "") + "-Homer"
d = []
else:
lines = line.rstrip().split("\t")
d.append([float(i) for i in lines])
out_str = out_str + '\n' + motif + '\n' + \
pd.DataFrame(d, columns=["A:", "C:", "G:", "T:"]) \
.T \
.to_csv(sep='\t', header=False)
with open("tmp_transfac.txt", 'w') as out_fh:
out_fh.write(out_str)
os.system("uniprobe2meme tmp_transfac.txt 1> out.meme 2>log.txt")