Hello, I have the following input file.
gene1 rs1
gene2 rs2
gene1 rs3
gene1 rs4
And I want to write a program to make it looks like:
gene1 rs1, rs3, rs4
gene2 rs2
that is, put all the rs with the same gene number into a row.
I parsed the file and called my gene number column value $gene and I wrote the following script. Please disregard context and syntax errors for now.
...
foreach $gene(@genes){
my $temp="SLCO4A1";
if ($gene eq $temp){
push (@contents,$gene $rs);
$temp=$gene;
}
}
foreach my $line(@contents){
print $line;
}
Thanks a lot,
szzxy