-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathonego.py
More file actions
24 lines (18 loc) · 1012 Bytes
/
onego.py
File metadata and controls
24 lines (18 loc) · 1012 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import argparse
def process_go_annotations(raw_file, out_file):
with open(raw_file, "r") as infile, open(out_file, "w") as outfile:
for line in infile:
string = line.split("\t")
gene = string[0]
go_terms = string[1].strip().split(",")
for goid in go_terms:
output = gene + '\t' + goid + '\n'
outfile.write(output)
def main():
parser = argparse.ArgumentParser(description="Process a Trinotate output GO annotation file to create a one-to-one relationship between genes and GO terms.")
parser.add_argument('-r', '--raw_file', type=str, help='Path to the Trinotate output raw GO annotation file.')
parser.add_argument('-o', '--out_file', type=str, help='Path to the output file where each gene and GO term will have a one-to-one relationship.')
args = parser.parse_args()
process_go_annotations(args.raw_file, args.out_file)
if __name__ == "__main__":
main()