【问题标题】:How to count sequences in a fasta file using Bioperl如何使用 Bioperl 计算 fasta 文件中的序列
【发布时间】:2016-05-04 04:59:19
【问题描述】:

晚上好,我有一个 bioperl 代码来计算 fasta 文件中的序列数,但我正在尝试修改代码以计算任何给定 fasta 文件中短于 20 和长于 120 的序列。代码如下

use strict;

use Bio::SeqIO;

my $seqfile = 'sequences.fa';

my $in = Bio::SeqIO->new
        (
                -format => 'fasta',
                -file => $seqfile
        ) ;

my $count = 0;

while (my $seq = $in->next_seq)
{
        $count++;
}

print "There are $count sequences\n";

【问题讨论】:

    标签: bioinformatics bioperl


    【解决方案1】:

    您可以使用序列对象的长度函数在您的 while 循环中构造一个 if 语句。

    my $len = $seq->length();
    if($len < 20 || $len > 120){
        $count++;
    }
    

    【讨论】:

      猜你喜欢
      • 2014-08-02
      • 1970-01-01
      • 1970-01-01
      • 2012-03-31
      • 1970-01-01
      • 1970-01-01
      • 2020-07-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多