I have two tab-delimited files where I need to match text in the first column of file 1 to any position in lines of file 2. Upon a match I then want to print what's in the second column of the matching line of file 1 to the end of the matching line in file 2 (example below).
I know this can almost certainly be done with awk, but I'm not very competent in using awk or sed and searching related questions on here and trying to adapt their script hasn't worked out for me. Any input would be much appreciated.
File 1
protein_1.p1 note "PJD5F7, match to databaseID=64575, (species X)";
protein_1.p2 note "PJD5F7, match to databaseID=64575, (species X)";
protein_3.p1 note "PA5F9H, match to databaseID=93689, (species W)";
protein_4.p1 note "Q7GT5J, match to databaseID=89045, (species Y)";
protein_4.p3 note "YE6G3L, match to databaseID=44968, (species Z)";
File 2
chromosome_1 programID transcript_id "protein_1.p1"; parent "protein_1";
chromosome_1 programID transcript_id "protein_1.p2"; parent "protein_1";
chromosome_1 programID transcript_id "protein_2.p1"; parent "protein_2";
chromosome_1 programID transcript_id "protein_2.p2"; parent "protein_2";
chromosome_1 programID transcript_id "protein_3.p1"; parent "protein_3";
chromosome_1 programID transcript_id "protein_4.p1"; parent "protein_4";
chromosome_1 programID transcript_id "protein_4.p2"; parent "protein_4";
chromosome_1 programID transcript_id "protein_4.p3"; parent "protein_4";
Desired output
chromosome_1 programID transcript_id "protein_1.p1"; parent "protein_1"; note "PJD5F7, match to databaseID=64575, (species X)";
chromosome_1 programID transcript_id "protein_1.p2"; parent "protein_1"; note "PJD5F7, match to databaseID=64575, (species X)";
chromosome_1 programID transcript_id "protein_2.p1"; parent "protein_2";
chromosome_1 programID transcript_id "protein_2.p2"; parent "protein_2";
chromosome_1 programID transcript_id "protein_3.p1"; parent "protein_3"; note "PA5F9H, match to databaseID=93689, (species W)";
chromosome_1 programID transcript_id "protein_4.p1"; parent "protein_4"; note "Q7GT5J, match to databaseID=89045, (species Y)";
chromosome_1 programID transcript_id "protein_4.p2"; parent "protein_4";
chromosome_1 programID transcript_id "protein_4.p3"; parent "protein_4"; note "YE6G3L, match to databaseID=44968, (species Z)";
protein_3.p1
appear outside quotes in file2 and, if it does, is that a match?thisisnotprotein_3.p1
be considered a match? Or do we need to find it as a "word", so surrounded by spaces or other non-word characters?chromosome_1 programID transcript_id "protein_1.p1"; parent "protein_2";
right? Because it would have two matches "for any position". So it has a unique match into file1/filed1. Is this always in a specific field of file2? for example the 4th or the last field.