CmhaDSO python genbank

使用例

#@ from Bio import SeqIO gbk_file = 'test/test.gbk' gbk = SeqIO.parse(gbk_file, 'genbank') r1 = next(gbk) f5 = r1.features[5] print(f5.type) print(f5.location) print(f5.extract(r1.seq)) #@ # GenbankからAA配列のfastaファイル作成 from Bio import SeqIO gbk_file = 'test/test.gbk' out_file = 'tmp.faa' res = '' for r in SeqIO.parse(gbk_file, 'genbank'): for f in r.features: if f.type != 'CDS': continue if 'pseudo' in f.qualifiers: continue locus_tag = f.qualifiers['locus_tag'][0] translation = f.qualifiers['translation'][0] product = f.qualifiers['product'][0] res += f'>{locus_tag} {product}\n{translation}\n' with open(out_file, 'w') as fh: fh.write(res)