-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetGeneNamesGff.py
More file actions
executable file
·66 lines (55 loc) · 1.69 KB
/
Copy pathgetGeneNamesGff.py
File metadata and controls
executable file
·66 lines (55 loc) · 1.69 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
#!/home/mplace/anaconda3/bin/python
"""
@Program: getGeneNamesGff.py
@Purpose: Create a gff file from Sean's annotation files
@Input: file with list of gene names, Sean's annotation
only does one type at at time, only LIFTOVER or YGAP
so run them separately and cat later.
@Output: GFF file
@author: Mike Place
@Date: 2/19/2015
"""
import sys
import re
def main():
"""
main()
"""
# if no args print help
if len(sys.argv) == 1:
print("file required")
sys.exit(1)
else:
file = sys.argv[1] # list of gene names to parse
annFile = sys.argv[2] # annotation file, csv format
names = set()
with open(file) as f:
for line in f:
line = line.rstrip()
if line.startswith('Homologue'):
#
#nl = line.replace("_ygap", "")
names.add(line)
else:
gname = re.split("_", line)
names.add(gname[0])
with open("homoCheck.txt",'w') as fo:
for x in names:
fo.write("%s\n" %(x))
with open(annFile) as a:
next(a)
for line in a:
line = line.rstrip()
first = line.split(',')
gene = first[9]
#first[9] = gene + "_liftover"
first[9] = gene + "_ygap"
att = first[8].split(';')
att[1] = gene + "_ygap"
#att[1] = gene + "_liftover"
first[8] = ';'.join(att)
if gene in names:
row = first[:10]
print('\t'.join(row))
if __name__ == "__main__":
main()