知者无忧

NOThing Is Impossible! —— 原创文章,谢绝转载!

RSS Feed

[BioPerl]怎么把fasta格式的DNA序列切割成一定长度的序列

0 Comments
Posted by on 2008-11-06 at 18:41

Q:想请教一下怎么把fasta格式的DNA序列切割成一定长度的序列?
现有一个很长的序列,保存为fasta格式,希望切成一定长度的较短的序列。应该怎么输入呢?比如是一段很长的序列,要切割成一小段一小段的70的序列。为:1-70为第一小段,2-71为第二小段,3-72为第三小段。。。这样滑动切割,最后还是保存为fasta格式。
A:

use strict;
use Bio::SeqIO;
my $filename = 'file.fasta';
my $width = 70;
my $stream = Bio::SeqIO->new(-file => $filename, -format => 'fasta');
my $seq = $stream->next_seq;
my $len = $seq->length;
for(1 .. $len-$width+1) {
    my ($start, $end) = ($_, $_+$width-1);
    print '>',$seq->id," $start:$endn";
    print $seq->subseq($start,$end),"n";
}

相关日志

  • 暂无相关日志

You can leave a comment, or trackback from your own site.

0 Comments

You can be the first to comment!

发表评论

您的电子邮箱不会被公开。 标记为 * 的区域必须填写

*

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

功能

  • 登录
  • 日志 RSS
  • 评论 RSS
  • 中国博客网