I have to search the matching numbers in file2,my file2 is have a multiple columns like this
rs3934834 1 1045729 A G 0.1791 0.2054 0.8441
rs3737728 1 1061338 A G 0.2845 0.2809 1.018
rs6687776 1 1070488 A G 0.1768 0.1956 0.8833
rs9651273 1 1071463 A G 0.2743 0.2689 1.028
rs4970405 1 1088878 G A 0.0922 0.0757 1.24
rs1272625 1 1089873 G A 0.1369 0.1231 1.13
rs2298217 1 1104902 A G 0.1448 0.1542 0.9286
rs4970362 1 1134661 A G 0.3793 0.3954 0.9346
the underlined column have to matched with file1..But i dont know how to write a program for this task..I need out put like file2 for matching numbers only...Pls any one help me & give me a program in perl..
my output should be like
rs6596796 6 120522 A G 0.1058 0.09469
rs1535053 6 126089 G A 0.2155 0.2151
rs12192106 6 137664 A G 0.06956 0.07949
rs6913464 6 139090 A G 0.1702 0.1663
rs9405480 6 144199 A G 0.1869 0.1771
rs9392299 6 148909 G A 0.07122 0.06203
rs1418708 6 150610 A G 0.1386 0.1374
rs1418707 6 150800 G A 0.192 0.1631
simply say i have match the file1 & file 2.the file2 have data like as i said before..the third column of file2 have a matching numbers with file1.which means
rs6596796 6 120522 A G 0.1058 0.09469 1.132
rs1535053 6 126089 G A 0.2155 0.2151 1.003
rs12192106 6 137664 A G 0.06956 0.07949 0.86
rs6913464 6 139090 A G 0.1702 0.1663 1.028
rs9405480 6 144199 A G 0.1869 0.1771 1.068
rs9392299 6 148909 G A 0.07122 0.06203 1.16
rs1418708 6 150610 A G 0.1386 0.1374 1.01
rs1418707 6 150800 G A 0.192 0.1631 1.219
the under lined numbers r have to match with file1...and my output should be like this..
rs6596796 6 120522 A G 0.1058 0.09469 1.132
rs1535053 6 126089 G A 0.2155 0.2151 1.003
rs12192106 6 137664 A G 0.06956 0.07949 0.8657
rs6913464 6 139090 A G 0.1702 0.1663 1.028
rs9405480 6 144199 A G 0.1869 0.1771 1.068
rs9392299 6 148909 G A 0.07122 0.06203 1.16
rs1418708 6 150610 A G 0.1386 0.1374 1.01
rs1418707 6 150800 G A 0.192 0.1631 1.219 3.
pls help me nila..this is very urgent..write a program for this task
From the data it looks like the data issorted.
The file1 is sorted.
And file2 is sorted on column 3.
Is this correct?
Then I would consider Unix "paste" is the best command.
use strict;
use warnings;
use Data::Dumper;
open FH1,"file" or die "Can't open the file $!";
open FH2,"file1" or die "Can't open the file $!";
open OUTPUT,"+>output_file" or die "Can't open the file $!";
while (<FH1>)
{
my $line=$_;
while (<FH2>)
{
my ($a,$b,$c)=split(' ');
if($c == $line)
{
print OUTPUT $_ ;
}
}
}