<p>{geni在网上找到了一个样本文件}不完整。在</p>
<p>使用这段代码和<a href="http://search.cpan.org/perldoc?Bio::GenBankParser" rel="nofollow noreferrer">^{<cd1>}</a>模块,对它进行解析,猜测您要查找的是结构的哪些部分。在本例中,包含<code>locus_tag</code>字段和<code>product</code>字段的“特性”。在</p>
<pre><code>use strict;
use warnings;
use feature 'say';
use Bio::GenBankParser;
my $file = shift;
my $parser = Bio::GenBankParser->new( file => $file );
while ( my $seq = $parser->next_seq ) {
my $feat = $seq->{'FEATURES'};
for my $f (@$feat) {
my $tag = $f->{'feature'}{'locus_tag'};
my $prod = $f->{'feature'}{'product'};
if (defined $tag and defined $prod) {
say join "\t", $tag, $prod;
}
}
}
</code></pre>
<p><strong>用法:</strong></p>
^{pr2}$
<p><strong>输出:</strong></p>
<pre><code>MG_001 DNA polymerase III, beta subunit
MG_470 CobQ/CobB/MinD/ParA nucleotide binding domain-containing protein
</code></pre>
<p>同一输入的一个行程序的输出将是:</p>
<pre><code>MG_001 DNA polymerase III, beta subunit
MG_470 CobQ/CobB/MinD/ParA nucleotide binding
domain-containing protein
</code></pre>
<p>当然,假设您将<code>/s</code>修饰符添加到regex中以说明多行条目(这是<a href="https://stackoverflow.com/users/1004301/leeduhem">leeduhem</a>在注释中指出的):</p>
<pre><code>m!/(?:locus_tag|product)="(.+?)"!sg
# ^ this
</code></pre>