have a folder with roughly 1000 vcf files which have divided the human genome into chunks, the folder looks like this:
- main_programme_aggregated_chr1_1_194789237.vcf.gz
....
- main_programme_aggregated_chrX_14235_8759493845.vcf.gz
etc
I will divide this file name into:
*_chr[1-22, X,Y]_A_B.*
I have a separate tab divided file with the names of genes and their genomic coordinates (all the genes in the human genome on build 38) - file1:
chr1 19853 90835 WASH7P ENSG0000022454
...
chr10 38732 390853 JHBF ENSG0000578382
..
chrX 9532 908032 LOTY ENSG00005847
etc
I would like to use the gene name from the 4th column of file1 to find the relevant chunked file it falls within. So I would need to take column 1 of file 1, match it to chr[1-22, X or Y] and then find the chunk were the range of columns2+3 fall between (A-B) in the file name.
I do not need to go into the files themselves, just use their names.
I have been just manually looking up the gene coordinates and the relevant chunk but am sure this can be automated.
An example would be that I want to get the chunk file that the gene WASH7P falls under, so the relevant file would be main_programme_aggregated_chr1_1_194789237.vcf.gz.
Ideally I could do this from the command line and the relevant chunk file then be inputted as a variable into some downstream workflows I have.
Would anyone be able to help? Many thanks for your time