Chinaunix首页 | 论坛 | 博客
  • 博客访问: 221530
  • 博文数量: 36
  • 博客积分: 1188
  • 博客等级: 军士长
  • 技术积分: 802
  • 用 户 组: 普通用户
  • 注册时间: 2010-04-08 21:45
文章分类

全部博文(36)

文章存档

2020年(1)

2017年(2)

2015年(1)

2014年(1)

2013年(1)

2012年(3)

2011年(27)

分类: WINDOWS

2011-04-12 10:14:29

来源于 Bioperl:把Genbank格式的序列转换为基因结构图 | 柳城
 
下面是一个BioPerl的小程序,可以把Genbank格式的序列转换为png图片-基因结构图,显示序列的长度,CDS区,exon区,STS区等。简单地讲就是把该序列的Genbank格式里的信息用图片表示。 这个程序来源于网络。
下面举个例子,以NM_172587为例。
NM_172587的Genbank格式下面的链接,另存为文件名'NM_172587.gb':
下面是Bioperl脚本:
存为文件名:graphics.pl
本文详细出处参考:
  1. #!/usr/bin/perl -w

  2. use Bio::Graphics;
  3. use Bio::SeqIO;
  4. use Bio::SeqFeature::Generic;
  5. my $file = shift
  6.     or die "provide a sequence file as the argument";
  7. my $io = Bio::SeqIO->new(-file=>$file)
  8.     or die "couldn't create Bio::SeqIO";
  9. my $seq = $io->next_seq
  10.     or die "couldn't find a sequence in the file";
  11. my @features = $seq->all_SeqFeatures;
  12. # sort features by their primary tags
  13. my %sorted_features;
  14. for my $f (@features) {
  15.     my $tag = $f->primary_tag;
  16.     push @{$sorted_features{$tag}},$f;
  17. }
  18. my $panel = Bio::Graphics::Panel->new(
  19. -length => $seq->length,
  20. -key_style => 'between',
  21. -width => 800,
  22. -pad_left => 10,
  23.           -pad_right => 10);
  24. $panel->add_track(arrow =>
  25. Bio::SeqFeature::Generic->new(-start => 1,
  26. -end => $seq->length),
  27. -bump => 0,
  28. -double=>1,
  29.     -tick => 2);
  30. $panel->add_track(generic =>
  31. Bio::SeqFeature::Generic->new(-start => 1,
  32. -end => $seq->length,
  33. -bgcolor => 'blue',
  34.          -label => 1));
  35. # general case
  36. my @colors = qw(cyan orange blue purple green
  37.   chartreuse magenta yellow aqua);
  38.     my $idx = 0;
  39.     for my $tag (sort keys %sorted_features) {
  40.         my $features = $sorted_features{$tag};
  41. $panel->add_track($features,
  42. -glyph => 'generic',
  43. -bgcolor => $colors[$idx++ % @colors],
  44. -fgcolor => 'black',
  45. -font2color => 'red',
  46. -key => "${tag}s",
  47. -bump => +1,
  48. -height => 8,
  49. -label => 1,
  50. -description => 1);
  51.     }
  52.  print $panel->png;
  53. 本文详细出处参考:http://liucheng.name/531/
用法:
  1. perl graphics.pl NM_172587.gb >1.png
结果就生成了一个名为1.png的图片,如下图
阅读(4019) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~