我有一个文件,里面有7000个分子,以及它们的名字和能量。每个分子从关键字模型1开始,第二线有能量(下面的例子是-9.102,第一分子),第七条线有该分子的名称(下面的例子是第一分子,S3670头孢苏林(钠).cdx)。我想根据所有分子的能量对它们进行排序,这样最低的(最负的)分子将是产生的文本文件中的第一个分子以及分子的名字。能量和名字可以是相同的,也可以是不同的。我想使用grep进行解析,但没有根据句子中嵌入的值进行排序的经验。有人能帮忙吗。谢谢。
MODEL 1
REMARK VINA RESULT: -9.102 0.000 0.000
REMARK INTER + INTRA: -13.194
REMARK INTER: -12.767
REMARK INTRA: -0.427
REMARK UNBOUND: 0.165
REMARK Name = S3670 Cefsulodin (sodium).cdx
REMARK 8 active torsions:
REMARK status: ('A' for Active; 'I' for Inactive)
REMARK 1 A between atoms: CA_3 and C_8
REMARK 2 A between atoms: CA_5 and N_10
REMARK 3 A between atoms: C_7 and C_12
REMARK 4 A between atoms: C_12 and N_16
REMARK 5 A between atoms: C_15 and C_17
REMARK 6 A between atoms: C_17 and C_21
REMARK 7 A between atoms: C_17 and S_22
REMARK 8 A between atoms: C_30 and C_33
REMARK x y z vdW Elec q Type
REMARK _______ _______ _______ _____ _____ ______ ____
ROOT
ATOM 1 N UNL 1 92.970 106.706 73.996 0.00 0.00 +0.000 N
ATOM 2 C UNL 1 93.751 107.062 75.160 0.00 0.00 +0.000 C
MODEL 1
REMARK VINA RESULT: -6.812 0.000 0.000
REMARK INTER + INTRA: -12.561
REMARK INTER: -11.387
REMARK INTRA: -1.175
REMARK UNBOUND: -1.767
REMARK Name = S3836 6-Gingerol.cdx
REMARK 10 active torsions:
REMARK status: ('A' for Active; 'I' for Inactive)
REMARK 1 A between atoms: C_1 and C_2
REMARK 2 A between atoms: C_1 and C_12
REMARK 3 A between atoms: C_2 and C_3
REMARK 4 A between atoms: C_3 and C_4
REMARK 5 A between atoms: C_4 and C_5
REMARK 6 A between atoms: C_5 and C_6
REMARK 7 A between atoms: C_6 and C_7
REMARK 8 A between atoms: C_7 and C_8
REMARK 9 A between atoms: C_8 and C_9
REMARK 10 A between atoms: C_14 and O_18
REMARK x y z vdW Elec q Type
REMARK _______ _______ _______ _____ _____ ______ ____
ROOT
ATOM 1 C UNL 1 89.880 102.122 75.634 0.00 0.00 +0.000 C
ENDROOT发布于 2022-10-21 03:06:52
您必须执行以下步骤:
ENERGY MODEL_NAME
。
所有这些在其他地方都有详细的解释,但是这里有一些您可以使用的通用Unix命令:
grep,sed,awk和许多其他人可以做How do I split a string on a delimiter in Bash?head/tail/cut或sed Getting n-th line of text output和Bash + sed/awk/cut to delete nth characterxargs或parallel https://savannah.gnu.org/projects/parallel/sort https://en.wikipedia.org/wiki/Sort_(Unix)尽管如此,这是一个很好的例子,说明在Bash中完成任务是非常痛苦的,但是在Python这样的更好的语言中,这是一件轻而易举的事情。只需从STDIN、.split("MODEL 1").splitlines()读取文件,并使用基本Python /list切片/索引来提取数据。您也可以在Python中进行排序。
https://stackoverflow.com/questions/74148156
复制相似问题