当文件的列包含另一个文件给定范围之间的位置时,使用 Awk 和 Condition 捕获行

Using Awk and Condition for catching lines when column of a file contains a position between a given range by another file

我想确定每个基因的分数 然而,为此我需要设置一个条件来识别得分(列 $3 得分列表),该得分位于基因列表的 $3 列和 $4 列的给定范围之间的一个位置

基因列表:

chr1    TAS1R1  6615000 6615100
chr1    TAS1R1  6615130 6615200
chr5    TCERG1  145858055   145858216

成绩单:

rs79923433 chr1 6615060 0.327009537545002 0.177578086220885
rs4908925 chr1 6615107 0.492182375024342 0.278821401692196
rs114220820 chr1 6615172 0.24581165286421 0.129806066087895
rs925345 chr5 145858100 1.22569136462918 0.744498627741366

我想要的:

chr1    TAS1R1  6615000 6615100 0.327009537545002
chr1    TAS1R1  6615130 6615200 0.24581165286421
chr5    TCERG1  145858055   145858216 1.22569136462918

使用 awk:

awk '
    NR == FNR {score[] = ; next}
    {
        for (key in score) 
            if ( <= key && key <= ) 
                print [=10=], score[key]
    }
' score.list gene.list 
chr1    TAS1R1  6615000 6615100 0.327009537545002
chr1    TAS1R1  6615130 6615200 0.24581165286421
chr5    TCERG1  145858055   145858216 1.22569136462918

效率不是很高,因为您必须遍历每一行基因的所有分数,但它非常简单。