Skip to content

Instantly share code, notes, and snippets.

@ipetrushin
Created June 30, 2022 05:48
Show Gist options
  • Save ipetrushin/eef0bb2dcded2e5529f2386653911d33 to your computer and use it in GitHub Desktop.
Save ipetrushin/eef0bb2dcded2e5529f2386653911d33 to your computer and use it in GitHub Desktop.
count genes in GenBank file
#!/usr/bin/env python
from Bio import SeqIO
import sys
import os
from collections import OrderedDict
gbk_file = sys.argv[1]
genes_list = ("porQ", "porV")
if not os.path.isfile(gbk_file):
print ("Input file doesn't exists")
sys.exit()
for index, record in enumerate(SeqIO.parse(gbk_file, "genbank")):
for f in record.features:
if ('gene' in f.qualifiers) and (f.qualifiers['gene'][0] in genes_list):
print(f.qualifiers['gene'][0]) #locus_prot[f.qualifiers['protein_id'][0]] = f.qualifiers['old_locus_tag'][0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment