I have two files
File 1:
chrom chromStart chromEnd clinSign geneId rcvAcc hgvsCod hgvsProt
chr1 930187 930188 VUS SNV SAMD11 RCV001050361 NM_152486.3:c.106G>A NP_689699.2:p.Ala36Thr
chr1 939398 939446 Benign deletion SAMD11 RCV000948524 NM_152486.2:c.683_706+24delCCCCTCATCACCTCCCCAGCCACGGTGAGGACCCACCCTGGCATGATC
File 2:
CHROM POS REF ALT FILTER GT BD
chr1 1609489 AAC A PASS 0/1 FP
chr1 930188 T G LowGQ 0/1 FP
chr1 939400 TGC T PASS 0/1 FP
I'm trying to query file 2 based on CHROM:POS (1st & 2nd column) against the range of the first three columns from File 1 (chrom:chromStart:ChromEnd) and then have an output
chrom chromStart chromEnd clinSign geneId rcvAcc hgvsCod hgvsProt CHROM POS REF ALT FILTER GT BD
chr1 930187 930188 VUS SNV SAMD11 RCV001050361 NM_152486.3:c.106G>A NP_689699.2:p.Ala36Thr chr1 930188 T G LowGQ 0/1 FP
chr1 939398 939446 Benign deletion SAMD11 RCV000948524 NM_152486.2:c.683_706+24delCCCCTCATCACCTCCCCAGCCACGGTGAGGACCCACCCTGGCATGATC chr1 939400 TGC T PASS 0/1 FP
So far I have tried
awk '
NR==FNR{ start[$1] = $2; end[$1] = $3; next }
(FNR==1) || ( ($1 in start) && ($2 >= start[$1]) && ($2 <= end[$1]) )
' file1 file2> test.txt
awk 'FNR == NR { low[$1] = $2; high[$1] = $3; next }
> $2 > low[$1] && $2 < high[$1] { print }' file1 file2 > test.txt
but both result in an empty file as output
any suggestions are appreciated. thank you