- 论坛徽章:
- 3
|
本帖最后由 54red 于 2015-08-06 15:39 编辑
有两个输入一个输出 运行命令是 perl gene_change.pl data.txt find.txt
数据.rar
(2.89 KB, 下载次数: 10)
明明应该是替换了15次,但是我这个总是替换不全,先谢谢大家帮我看一下。 (编的很拖沓,十分欢迎提改进意见)
还有个小问题 data.txt 两列中都有重复 所以我不会用hash
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
use File::Basename;
my $gene=shift;
my $gene_new=shift;
my $out= shift;
open (IN,$gene);
open (IN1,"$gene_new");
my @haha=<IN1>;
open(OUT,">$out");
my $n=0;
foreach (@haha)
{
chomp;
my $gene=$_;
my $m=1;
while (<IN>) {
chomp;
my $line = $_;
my @data = split/\t/,$line;
if($gene eq $data[0]){
print OUT "$gene\t$data[1]\n";$n++;print "change\:\t$n\n";
$m++;last;
}
}
if($m==1){print OUT "$gene\tNA\n";
}
}
|
|