-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathapa.rnamotifs
executable file
·43 lines (39 loc) · 1.71 KB
/
apa.rnamotifs
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
#!/usr/bin/python3
import apa
import os
import sys
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('-comps_id', action="store", dest="comps_id", default=None)
parser.add_argument('-fdr', action="store_true", default=False)
args = parser.parse_args()
if args.comps_id!=None:
comps_id = args.comps_id
comps = apa.comps.Comps(comps_id)
for site in ["proximal", "distal"]:
for pt in ["same", "composite", "skipped", "all"]:
rnamotifs_id = "%s_%s_%s" % (comps_id, site, pt)
folder = os.path.join(apa.path.rnamotifs_folder, "comps", "%s_%s_%s" % (comps_id, site, pt))
try:
os.makedirs(folder)
except:
pass
fname1 = os.path.join(apa.path.comps_folder, comps_id, "motifs", "tab", rnamotifs_id+".tab")
fname2 = os.path.join(apa.path.rnamotifs_folder, "comps", rnamotifs_id, rnamotifs_id+".tab")
os.system("perl -pe 's/r\n/s\n/g' %s > %s" % (fname1, fname2))
fname_config = os.path.join(apa.path.rnamotifs_folder, "comps", rnamotifs_id, rnamotifs_id+".config")
print fname_config
f = open(fname_config, "wt")
f.write("data_type=apa\n")
f.write("hw=15\n")
f.write("flanking=100\n")
f.write("genome=%s\n" % comps.species)
f.write('regions=[("r1", -80, -40), ("r2", 0, 40), ("r3", 40, 80)]\n')
f.write("cores=4\n")
if args.fdr:
f.write("use_FDR=True\n")
else:
f.write("use_FDR=False\n")
f.close()
os.system("rnamotifs2 -comps %s" % rnamotifs_id)
os.system("rnamotifs2.draw_apa -comps %s" % rnamotifs_id)