-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconvert_gb_to_fasta.py
29 lines (22 loc) · 975 Bytes
/
convert_gb_to_fasta.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
import argparse
import os
from Bio import SeqIO
def parse_args():
parser = argparse.ArgumentParser(description="Iteration over files in directory and convert from genbank to fasta")
parser.add_argument("-i", "--input", required=True,
default="/data",
help=f"directory containing .gbff files")
parser.add_argument("-o", "--output", required=True,
help=f"")
return parser.parse_args()
# Iteration over files in directory and convert from genbank to fasta
def convert_gb_to_fasta(input_path, output_path):
for filename in os.listdir(input_path):
if filename.endswith(".gbff"):
SeqIO.convert(f"{input_path}/{filename}", "genbank", f"{output_path}/{filename}.fasta", "fasta")
continue
else:
continue
if __name__ == '__main__':
args = parse_args()
convert_gb_to_fasta(args.input, args.output)