How to make ".gbk" file from gbff/gff/fna/gb or any Genbank file format?

843 Views Asked by At

I am using a software needs reference geneome in .gbk format (which is obseleted by genebank and is replaced by gbff). I searched to find a file convertor however I failed. I supposed gb and gbk are the same, so I renamed gb to gbk, however didnt help. I appriciate any help.

I am going to share the command I used to convert the gbff to gbk:

from Bio import SeqIO

# Specify input and output filenames
input_file = "GCF_000013425.1_ASM1342v1_genomic.gbff"
output_file = "GCF_000013425.1_ASM1342v1_genomic.gbk"

# Read the GenBank Flat File
records = SeqIO.parse(input_file, "genbank")

# Write records in GenBank format
SeqIO.write(records, output_file, "genbank")
1

There are 1 best solutions below

0
steve_simoni On

The FASTA to GenBank converter requires Python3 and the “Biopython” package (see https://biopython.org/).

Install this as python3 -m pip install biopython.

The Python code (assumes a DNA sequence):

    From Bio import SeqIO

    with open("change_this_name_1.fna") as input_handle, open 
      ("change_this_name_1.gbk", "w") as output _handle:
        sequences = SeqIO.parse(input_handle, "fasta")
        records = list(sequences)
        for i in range(len(records));
            records[i].annotations["molecule_type"] = "DNA"
        count = SeqIO.write(records, output_handle, "genbank")

    print("Converted %i records" % count)