Entering edit mode
6.3 years ago
kartikayprasad
▴
10
Hello friends, I have two misa file, i want to extract those lines which are showing similar ssrs from both the files. for example: File1:
ID SSR nr. SSR type SSR size start end
P_S1_L001_R1_001_(paired)_150721_contig_1 1 p1 (T)11 11 905 915
P_S1_L001_R1_001_(paired)_150721_contig_1 2 p1 (A)11 11 2102 2112
P_S1_L001_R1_001_(paired)_150721_contig_1 3 p1 (A)11 11 3020 3030
P_S1_L001_R1_001_(paired)_150721_contig_1 4 p1 (T)12 12 3361 3372
P_S1_L001_R1_001_(paired)_150721_contig_1 5 p2 (CT)6 12 3944 3955
File2:
ID SSR nr. SSR type SSR size start end
P_S1_L001_R1_001_1_(paired)_150727_contig_10 1 p1 (A)10 10 5047 5056
P_S1_L001_R1_001_1_(paired)_150727_contig_10 2 p1 (T)10 10 9828 9837
P_S1_L001_R1_001_1_(paired)_150727_contig_10 3 p1 (A)10 10 11634 11643
P_S1_L001_R1_001_1_(paired)_150727_contig_10 4 p2 (TC)7 14 17272 17285
i want to extract those lines which are common in both the files on the basis of ssrs and print both the files with tab separated format in new file
output:
P_S1_L001_R1_001_(paired)_150721_contig_1 1 p1 (T)11 11 905 915 P_S1_L001_R1_001_1_(paired)_150727_contig_10 2 p1 (T)10 10 9828 9837
P_S1_L001_R1_001_(paired)_150721_contig_1 2 p1 (A)11 11 2102 2112 P_S1_L001_R1_001_1_(paired)_150727_contig_10 1 p1 (A)10 10 5047 5056
I tried to use the hash in perl but it is not working.
open(src,"@ARGV[0]");
while($line = <src>)
{
chomp($line);
@a = split(/\t/,$line);
$key = shift(@a);
$value = join("\t",@a);
$hash{$key} = $value;
}
close(src);
open(FILE,"@ARGV[1]");
while($line1 = <FILE>)
{
chomp($line1);
@b = split(/\t/,$line1);
$key1 = shift(@b);
$value1 = join("\t",@b);
if(exists $hash{$key1})
{
print"$key1\t$hash{$key1}\t$key1\t$value1\n";
}
}