尴尬选择具有科学符号的值
尊敬的生物信息学家,
我对价值观的尴尬和科学符号有问题。
我想根据$ 5的最低价值选择尴尬来选择行,以便
Chrpa1_10100 2434 PF00063 des 3.9E-21 IPR001609
Chrpa1_10100 2434 PF03547 des 4.5E-7 IPR004776
Chrpa1_10100 2434 PF07857 des 3.3E-7 IPR012435
Chrpa1_10100 2434 PF13516 des 0.085 IPR001611
在这种情况下只保留一个ID $ 1 ::,我想要:
Chrpa1_10100 2434 PF00063 des 3.9E-21 IPR001609
如果我这样做:
cat file |sort -k1,1|uniq| awk -F'\t' '$5 > max[$1] { max[$1]=$5; row[$1]=$0 } END { for (i in row) print row[i] }'
但是我想要这个:
Chrpa1_10100 2434 PF13516 des 0.085 IPR001611
谢谢您,请提前欢呼,
请
Dear bioinformaticians,
I have a problem with awk and scientific notation of values.
I want to use awk to select rows based on the min value of $5 to keep only one ID of $1 ::
Chrpa1_10100 2434 PF00063 des 3.9E-21 IPR001609
Chrpa1_10100 2434 PF03547 des 4.5E-7 IPR004776
Chrpa1_10100 2434 PF07857 des 3.3E-7 IPR012435
Chrpa1_10100 2434 PF13516 des 0.085 IPR001611
in this particular case, I want :
Chrpa1_10100 2434 PF00063 des 3.9E-21 IPR001609
If I do :
cat file |sort -k1,1|uniq| awk -F'\t' '$5 > max[$1] { max[$1]=$5; row[$1]=$0 } END { for (i in row) print row[i] }'
but I want this one :
Chrpa1_10100 2434 PF13516 des 0.085 IPR001611
Thank you in advance,
Cheers
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以下数字
3.9e-21
最小,0.085
是最大的,此代码选择最大数字,因此它确实找到了使用
0.085
的行。 。如果您想要3.9E-21
您需要实现查找最小价值,但请记住,尽管未知平均值零对于查找正数的最大数字是可以的,但这不是缩影,因此,我建议按照改善说明:更改
max
tomin
和>
to<
和更改条件,因此如果没有密钥$ 1
在最小数组中或的值$ 5
小于min
下的值 $$ 1
。,当
file.txt
内容然后
提供输出
(在GAWK 4.2.1中测试)
Out of following numbers
3.9E-21
is smallest,0.085
is biggest, this codeselects biggest number, hence it did find line with
0.085
. If you want3.9E-21
you need to implement finding minimal value but remembering that while unknown mean zero is fine for finding max of positive numbers, it is not for minumum, therefore I suggest following amelorationExplanation: changed
max
tomin
and>
to<
and altered condition so is true if there is not key$1
in min array or value of$5
is smaller than value inmin
under key$1
.When
file.txt
content isthen
gives output
(tested in gawk 4.2.1)