-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path23_alignment_stats.py
executable file
·71 lines (56 loc) · 2.19 KB
/
23_alignment_stats.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
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/python3
#
# This file is part of Progesterone pipeline.
#
# Progesterone pipeline is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Progesterone pipeline is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Progesterone pipeline. If not, see <https://www.gnu.org/licenses/>.
#
from utils.utils import *
from utils.mysqldb import *
#########################################
def main():
species = ['human','mouse']
tf_names = ['PGR', 'ESR1']
conf_file = "/home/ivana/.mysql_conf"
db = connect_to_mysql(conf_file)
cursor = db.cursor()
switch_to_db(cursor,'progesterone')
for sp in species:
print()
print(sp)
for tf_name in tf_names:
print("\t",tf_name)
# number of binding sites
qry = "select count(1) from binding_sites as b, regions as r "
qry += "where b.tf_name='%s' " % tf_name
qry += "and r.species='%s' " % sp
qry += "and b.region_id=r.id "
number_of_bs = search_db(cursor,qry)[0][0]
print("number of (chipseq) binding sites:", number_of_bs)
# number of binding sites with motif assigned
subqry = "select count(1) from binding_site2motif where binding_site_id=b.id"
qry += "and (%s)>0 " % subqry
bs_w_motif = search_db(cursor,qry)[0][0]
print("number of binding sites w motif:", bs_w_motif)
# number of binding sites with motif that has alignment associated
qry = "select count(1) from alignments as a, motifs as m, regions as r "
qry += "where a.id=m.alignment_id and m.region_id=r.id "
qry += "and m.tf_name='%s' and r.species='%s'" % (tf_name, sp)
motif_w_almt = search_db(cursor,qry)[0][0]
print("number of motifs w alignment:", motif_w_almt)
cursor.close()
db.close()
#########################################
########################################
if __name__ == '__main__':
main()