【发布时间】:2020-08-03 06:06:51
【问题描述】:
我的 .fasta 文件包含这种重复模式。
>sp|P20855|HBB_CTEGU Hemoglobin subunit beta OS=Ctenodactylus gundi OX=10166 GN=HBB PE=1 SV=1
asdfaasdfaasdfasdfa
>sp|Q00812|TRHBN_NOSCO Group 1 truncated hemoglobin GlbN OS=Nostoc commune OX=1178 GN=glbN PE=3 SV=1
asdfadfasdfaasdfasdfasdfasd
>sp|P02197|MYG_CHICK Myoglobin OS=Gallus gallus OX=9031 GN=MB PE=1 SV=4
aafdsdfasdfasdfa
我只想过滤掉包含 '>' 的行 THEN 过滤掉 'OS=' 之后和 'OX=' 之前的字符串,(例如 line1=Ctenodactylus gundi)
第一部分('>')很简单:
grep '>' my.fasta | cut -d " " -f 3 >> species.txt
问题是在'OS='之前字段的数量不是恒定的。
但 'OS=' 和 'OX=' 之间的列/字段数为 2。
【问题讨论】:
-
filter out这个词非常含糊 - 它可能意味着output only this或output everything except this。 -
@ed-morton 很高兴知道