我正在尝试使用awk
来查找使用file1
作为匹配条件的file2
和$5
之间的差异。我认为awk
会起作用,但截至目前,它似乎输出了两个文件之间的共同点。我也尝试用相同的结果反转文件。谢谢你:)。
awk with current output
awk 'FNR==NR {a[$5]; next} $5 in a' file1 file2
chr10 102586755 102586862 chr10:102586755-102586862 PAX2-1650|gc=63
chr10 102587289 102587450 chr10:102587289-102587450 PAX2-1651|gc=65
awk 'FNR==NR {a[$5]; next} $5 in a' file2 file1
chr10 102586755 102586862 chr10:102586755-102586862 PAX2-1650|gc=63
chr10 102587289 102587450 chr10:102587289-102587450 PAX2-1651|gc=65
文件1
chr10 102586755 102586862 chr10:102586755-102586862 PAX2-1650|gc=63
chr10 102587289 102587450 chr10:102587289-102587450 PAX2-1651|gc=65
chr10 102732659 102732803 chr10:102732659-102732803 unknown-1652|gc=59.4
chr10 102732875 102733044 chr10:102732875-102733044 unknown-1653|gc=61.3
file2的
chr10 102586755 102586862 chr10:102586755-102586862 PAX2-1650|gc=63
chr10 102587289 102587450 chr10:102587289-102587450 PAX2-1651|gc=65
chr10 102732659 102732803 chr10:102732659-102732803 C10ORF2-1652|gc=59.4
chr10 102732875 102733044 chr10:102732875-102733044 C10ORF2-1653|gc=61.3
所需的输出
chr10 102732659 102732803 chr10:102732659-102732803 C10ORF2-1652|gc=59.4
chr10 102732875 102733044 chr10:102732875-102733044 C10ORF2-1653|gc=61.3
编辑:也许这是awk
awk 'NR==FNR{a[$5];next} !($5 in a)' file1 file2
答案 0 :(得分:1)
您似乎只需使用faces[i].x = faces[i].x >= 0 ? faces[i].x : 0;
faces[i].y = faces[i].y >= 0 ? faces[i].y : 0;
faces[i].width = faces[i].x + faces[i].width > testMat.cols ? testMat.cols - faces[i].x : faces[i].width;
faces[i].height = faces[i].y + faces[i].height > testMat.rows ? testMat.rows - faces[i].y : faces[i].height;
而不是!($5 in a)
作为打印条件:
$5 in a