我有一个名为的文件c_FROM_V_273_008245_50_neighbours_SYMREMO.out
,看起来像:
NEIGHBORS OF THE NON-EQUIVALENT ATOMS
N = NUMBER OF NEIGHBORS AT DISTANCE R
ATOM N R/ANG R/AU NEIGHBORS (ATOM LABELS AND CELL INDICES)
1 CA 1 2.4055 4.5458 7 O 0 0 0
1 CA 1 2.4058 4.5463 10 O 0-1 0
1 CA 1 2.4356 4.6026 14 O 0 0 0
.
.
.
如果我想搜索的距离R/ANG
的1 CA 7 O
,这将是2.4055
我创建了以下脚本:search_for_distance.awk:
{if ($0 ~ "NEIGHBORS OF THE NON-EQUIVALENT ATOMS") {FLAG=1}};
# If the current line of the file begins with that string, we asign it a FLAG=1
{if (FLAG==1)
{if ($0 ~ "^ 1 CA"){LINE=$0;
exit}
}
};
# Here I am searching for "1 CA" on each line
END{VOL=FILENAME;
# The filename is: "c_FROM_V_273_008245_50_neighbours_SYMREMO.out"
# My intention is to end up with a new file with 2 columns:
# "volume" and "distance".
# Notice that the filename contains the volume: 273.008245
gsub("^.*_V_","",VOL);
gsub("_",".",VOL);
gsub(".50.neighbours.SYMREMO.out"," ",VOL);
# Some substitutions to make "c_FROM_V_273_008245_50_neighbours_SYMREMO.out"
# to be "273.008245"
# Up to now the output of running:
# search_for_distance.awk -f c_FROM_V_273_008245_50_neighbours_SYMREMO.out
# is the following:
# 273.008245 1 CA 1 2.4055 4.5458 7 O 0 0 0
# So, I need to take LINE and only extract column "4".
# This is done by a "split" command:
{split(LINE,array," ")}
print VOL,array[4]}
running:的输出search_for_distance.awk -f c_FROM_V_273_008245_50_neighbours_SYMREMO.out
如下:
273.008245 2.4055
请注意,脚本正在打印的1st外观1 CA
,恰好是1 CA 7O
,这是我想要的。
但是现在我需要运行它以搜索许多距离的首次出现...
我想搜索该1 CA
14 O
距离的首次出现。我只需要将我从行首搜索到的代码的第一位修改为1 CA
:
{if ($0 ~ "NEIGHBORS OF THE NON-EQUIVALENT ATOMS") {FLAG=1}};
# If the current line begins with that string, we asign it a FLAG=1
{if (FLAG==1)
{if ($0 ~ "^ 1 CA"){LINE=$0;
exit}
}
};
我该如何介绍要搜索的订单1 CA
14 O
?
就像是
{if (FLAG==1)
{if ($0 ~ "/1 CA && /14 O"){LINE=$0;
exit}
}
};
非常感谢您的帮助
我想在R / ANG中搜索1 CA 7 O的距离,在这种情况下为2.4055
$ awk '$1==1 && $2=="CA" && $6==7 && $7=="O" {print $4}' file
2.4055
查找1 CA 14 O的R / Ang:
$ awk '$1==1 && $2=="CA" && $6==14 && $7=="O" {print $4}' file
2.4356
$1==1 && $2=="CA" && $6==7 && $8==0
这将选择满足上述四个条件的行。
print $4
对于选定的行,这将打印第四个字段。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句