I have 2 tab-separated files which look like this:
file1.txt
chr1 710000 715000 143
chr1 715000 720000 144
chr1 720000 725000 145
chr1 725000 730000 146
chr1 730000 735000 147
chr1 735000 740000 148
chr1 740000 745000 149
chr1 745000 750000 150
chr1 750000 755000 151
chr1 755000 760000 152
chr1 760000 765000 153
file2.txt
143 143 84
143 144 26
143 152 32
143 153 15
144 152 11
The expected output:
output.txt
chr1 710000 715000 chr1 710000 715000 84
chr1 710000 715000 chr1 715000 720000 26
chr1 710000 715000 chr1 755000 760000 32
chr1 710000 715000 chr1 760000 765000 15
chr1 715000 720000 chr1 755000 760000 11
I would like to match the unique numbers in file1.txt (column 4) with the numbers in file2.txt (column 1 and 2) and replace them with values from file1.txt (column 1-3). The output.txt should have 7 columns, where the last one have the corresponding values from the file2.txt (column 3).
How is this related to bioinformatics, please?
The files are outputs of HiC-Pro pipeline that generates intra- and inter-chromosomal contact maps.
Thank you