sample file1:
ast578 61218 15755 + C/A
ast579 61218 15856 - A/G/T
ast580 61218 65798 + T/C
ast581 61218 67955 - A/TTA/AT
ast582 61218 68625 + -/G/AT
ast599 61218 68025 + (AT)12/34/32
sample file2:
61218 15755 A > T 0 4 0 0 2 7
61218 15856 T > C 3 2 0 3 1 8
61218 42547 A > G 3 7 5 4 1 6
61218 67955 A > G 0 10 0 9 3 4
61218 68625 G > A 0 10 0 8 1 5
####
61218 15755 A > T 0 4 0 0 2 7 ast578
61218 15856 T > C 3 2 0 3 1 8 ast579
61218 67955 A > G 0 10 0 9 3 4 ast581
####
#!/usr/bin/perl
use warnings;
use strict;
open(FH,"file1.txt")or die "can not open file";
open(FH1,"file2.txt")or die "can not open file";
open(OUT,">result.out")or die "can not create file";
my @file1;
while(my $line1=){
my @list1=split("\t",$line1);
push(@file1,$list1[1]."#".$list1[2],$list1[4]);
}
my %hash1=@file1;
my @file2;
while(my $line2=){
my @list2=split("\t",$line2);
push(@file2,$list2[0]."#".$list2[1],$list2[2]);
}
my %hash2=@file2;
my @allhits;
while(my ($key1,$value1)=each(%hash1)){
while(my ($key2,$value2)=each(%hash2)){
if($key1 eq $key2){
$value2=~s/\s//g;
my @val1=split("/",$value1);
my @val2=split(">",$value2);
foreach(@val1){
if($_ eq $val2[1]){
print "$key1\n"
#push(@allhits,$key1);
}
}
}
}
}
=pod
foreach(@allhits){
while(my $str=){
my($chrom,$position,$var,$one,$two,$three,$four,$five,$six)=split("\t",$str);
my($id,$location)=split("#",$_);
if(($chrom == $id) && ($position==$location)){
print "$_";
}
}
}