从MEGA进化树分析结果nwk文件提取基因ID

从nwk文件中提取基因ID

之前多次遇到需要从nwk文件中提取基因ID的情况,为此写了一脚本,可以实现此操作。

用法:

perl  nwk_geneid.pl  -i in.nwk  -o out.txt

in.nwk 为输入的nwk文件,out.txt是输出的基因ID文件。

脚本代码;

use Getopt::Long;
use strict;

my %opts;
GetOptions(\%opts,"i=s","o=s","h");
open(IN,"$opts{i}") || die "open $opts{i} failed\n";
open(OUT,">$opts{o}") ||die "open $opts{o} failed\n";
while(<IN>){
chomp;
my $str = $_;
$str =~ s/\d\.\d+//g;
$str =~ s/\(//g;
$str =~ s/\)//g;
$str =~ s/://g;
$str =~ s/;//g;

my @line = split(",",$str);
print OUT join("\n",@line);
}
close(IN);
close(OUT);


  • 发表于 2018-07-27 14:38
  • 阅读 ( 8389 )
  • 分类:perl

0 条评论

请先 登录 后评论
安生水
安生水

328 篇文章

作家榜 »

  1. omicsgene 658 文章
  2. 安生水 328 文章
  3. Daitoue 167 文章
  4. 生物女学霸 120 文章
  5. 红橙子 78 文章
  6. CORNERSTONE 72 文章
  7. xun 68 文章
  8. rzx 67 文章