-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgetRegLoc
More file actions
executable file
·67 lines (53 loc) · 1.73 KB
/
Copy pathgetRegLoc
File metadata and controls
executable file
·67 lines (53 loc) · 1.73 KB
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
#!/usr/bin/python
'''
Obtain the orthologs of a series of regulators, producing a series of "regloc" files
regloc file:
locus_tag REG_NAME
pangenome tab file:
orth_id locus_tag
target locus file:
prot_id locus_tag [dna_id replicon]
'''
def getOptions():
import argparse
# create the top-level parser
description = ('Obtain the orthologs of a series of regulators, producing a series of "regloc" files')
parser = argparse.ArgumentParser(description = description)
parser.add_argument('inregloc', action='store',
help='Seed regloc file')
parser.add_argument('pangenome', action='store',
help='Pangenome tab file')
parser.add_argument('locusfile', action='store',
help='Target locus file')
return parser.parse_args()
options = getOptions()
r = {}
for l in open(options.inregloc):
locus, reg = l.strip().split('\t')
r[reg] = r.get(reg, [])
r[reg].append(locus)
p = {}
o = {}
for l in open(options.pangenome):
if l.strip().startswith('#'):continue
orth, protein = l.strip().split('\t')
p[orth] = p.get(orth, set())
p[orth].add(protein)
o[protein] = orth
g = set()
for l in open(options.locusfile):
s = l.strip().split('\t')
g.add(s[1])
# Cycle through each regulator
for reg, locuses in r.iteritems():
matches = 0
for locus in locuses:
orth = o[locus]
# Is my target organism in this group?
# It may have some paralogs!
for protein in p[orth]:
if protein in g:
matches += 1
print '\t'.join([protein, reg])
if matches == 0:
print '\t'.join(['NA', reg])