I have two files (two columns each, split by tab) and I want to compare them based on the first column. If the value on the first column is the same on both files, I want to create a new file using second column values. Also, take into account that IDs in the first column of FILE1 can be duplicated. Basically I have:
FILE1:
TRINITY_DN10001_c0_g1_i1 TRINITY_DN10001_c0_g1_TRINITY_DN10001_c0_g1_i1_g.84091_m.84091
TRINITY_DN100032_c0_g2_i1 TRINITY_DN100032_c0_g2_TRINITY_DN100032_c0_g2_i1_g.20078_m.20078
TRINITY_DN100032_c0_g2_i1 TRINITY_DN100032_c0_g2_TRINITY_DN100032_c0_g2_i1_g.42263_m.42263
.....
TRINITY_DN99985_c0_g1_i1 TRINITY_DN99985_c0_g1_TRINITY_DN99985_c0_g1_i1_g.21199_m.21199
FILE2:
TRINITY_DN100007_c0_g1_i1 GO:0001071,GO:0003674
TRINITY_DN100032_c0_g2_i1 GO:0000149,GO:0001775
.....
TRINITY_DN99997_c0_g1_i1 GO:0000166,GO:0001882
And I need this:
TRINITY_DN100032_c0_g2_TRINITY_DN100032_c0_g2_i1_g.20078_m.20078 GO:0000149,GO:0001775
TRINITY_DN100032_c0_g2_TRINITY_DN100032_c0_g2_i1_g.42263_m.42263 GO:0000149,GO:0001775
.....
I think this can be done by combining two hash tables in Perl, somehow similar to this answer.
But I'm quite new with Perl so I exactly don't know how to do this. I would really appreciate if someone can help to modify the previous script (or to solve this problem in a different way).
Thanks in advance! ☺