- 论坛徽章:
- 3
|
我自己做了一个比较笨的程序,可以实现功能,大家有什么更好的思路,我也很想学一下!
真实的数据格式:
$pos:
chr11:10521764:T:C: 2
chr11:108183167:A:G: 2
chr11:10819364:T:C: 2
chr11:10822350:C:T: 2
chr11:10823079:T:C: 2
chr11:10828361:C:A: 2
.............
$txt:
11 654043 G A Exonic DEAF1
11 674731 C T Exonic DEAF1
11 822588 C T Exonic PNPLA2
11 824428 G T Exonic PNPLA2
11 824789 T C Exonic PNPLA2
................
open(IN1,"$txt");
open(IN,"$pos");
open(OUT,">$haha");
my %hash_pos;
map{chomp;my @data = split/\t/,$_;$hash_pos{$data[0]}=$data[1];}<IN>;
close IN;
my @hash;
while (<IN1>) {
chomp;
next if $_=~/^$/;
my $line=$_;
my @data1 = split/\t/,$_;
my $tmp = "chr"."$data1[0]".":".$data1[1].":".$data1[2].":".$data1[3];
print $tmp."\t";
if($hash_pos{$tmp}){
print OUT "$line\t$hash_pos{$tmp}\n";
$hash_pos{$tmp}=$hash_pos{$tmp}+1;
}
else {
$hash_pos{$tmp}=1;
print OUT "$line\t$hash_pos{$tmp}\n";
}
}
open(IN,">$pos");
print IN ("$_: $hash_pos{$_}\n") foreach(sort keys(%hash_pos));
close IN;
close IN1;
close OUT; |
|