forked from TrinhLab/CASPERapp
-
Notifications
You must be signed in to change notification settings - Fork 1
/
annotation_functions.py
47 lines (42 loc) · 1.41 KB
/
annotation_functions.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
import Bio
def check_key(key,dict):
if key in dict.keys():
return True
else:
return False
def get_id(feature):
if check_key('locus_tag',feature.qualifiers):
return feature.qualifiers['locus_tag'][0]
elif check_key('db_xref',feature.qualifiers):
return feature.qualifiers['db_xref'][0]
elif check_key('protein_id',feature.qualifiers):
return feature.qualifiers['protein_id'][0]
elif check_key('old_locus_tag',feature.qualifiers):
return feature.qualifiers['old_locus_tag'][0]
else:
return "N/A"
def get_name(feature):
if check_key('gene',feature.qualifiers):
return feature.qualifiers['gene'][0]
elif check_key('gene_synonym',feature.qualifiers):
return feature.qualifiers['gene_synonym'][0]
elif check_key('product',feature.qualifiers):
return feature.qualifiers['product'][0]
else:
return "N/A"
def get_description(feature):
if check_key('product',feature.qualifiers):
return feature.qualifiers['product'][0]
elif check_key('note',feature.qualifiers):
return feature.qualifiers['note'][0]
# elif check_key('gene',feature.qualifiers):
# return feature.qualifiers['gene'][0]
else:
return "N/A"
def get_strand(feature):
if feature.location.strand == 1:
return "+"
elif feature.location.strand == -1:
return "-"
else:
return