fasta格式文件转换为 反向互补链

 1 #!/usr/bin/env perl
 2 
 3 use strict;
 4 use warnings;
 5 
 6 local $/ =">";
 7 while(<>){
 8 chomp;
 9 my $lineSepPos = index($_,"
10 ");
11 my $header = substr($_,0,$lineSepPos);
12 if($header){
13 print(">", $header,"(reverse-complemented)
14 ");
15 my $sequence = reverse(substr($_,$lineSepPos));
16 # see http://shootout.alioth.debian.org/u32/performance.php?test=revcomp#about
17 # for ambiguity codes and translation
18 $sequence =~ tr/ACGTUMRWSYKVHDBNacgtumrwsykvhdbn
19 /TGCAAKYWSRMBDHVNtgcaakywsrmbdhvn/d;
20 for(my $pos = 0; $pos < length($sequence);$pos += 60){
21 print(substr($sequence, $pos, 60),"
22 ");
23 }
24 }
25 }

数值60代表每行输出60个碱基。(感谢原作者)

执行命令:perl fasta_re.perl   srr.fasta > srr_re.fasta

如若执行不了,记得查看pl文件是否有可执行权限。

posted @ 2017-09-22 16:56  遗世独立的愚公  阅读(645)  评论(0编辑  收藏  举报