二话不说,上代码,需要安装 BioPerl
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
use Bio::SeqIO; | |
# Author: Liu hualin | |
# Date: Oct 9, 2021 | |
# Usage: perl get_gbk_features.pl <in> <out> | |
my $in = shift; | |
my $out = shift; | |
my $seqin = Bio::SeqIO->new( -format => 'genbank', -file => "$in"); | |
open OUT, ">$out" || die; | |
while( (my $seq = $seqin->next_seq) ) { | |
foreach my $sf ( $seq->get_SeqFeatures ) { | |
if( $sf->primary_tag eq 'CDS' ) { | |
my @tags = $sf ->get_all_tags(); | |
#print join("\t", @tags) . "\n"; | |
print OUT $sf->get_tag_values('locus_tag'), "\t", $sf->start, "\t", $sf->end, "\t", $sf->strand, "\t", $sf->get_tag_values('product'), "\t", $sf->get_tag_values('translation'),"\n"; | |
} | |
} | |
} |
运行:
perl get_gbk_features.pl examples/INPUT/LHL010.gbk LHL010.list |
# 脚本获取
关注公众号 “生信之巅”,聊天窗口回复 “3a23” 获取下载链接。
敬告:使用文中脚本请引用本文网址,请尊重本人的劳动成果,谢谢!