x、y 和 z 坐标的组合(存储在三个不同的文件中)
我正在编写一个用于自动盲对接(查找蛋白质内的结合位点)的 bash 脚本。为此,我将一个大的 3D 网格划分为较小的重叠网格。
我创建了三个文件,分别包含子网格中心的 x、y 和 z 坐标。换句话说,一个文件包含所有可能的 x 坐标(每行一个),第二个文件包含所有 y 坐标,第三个文件包含所有 z 坐标。坐标具有三位小数,可以是正值也可以是负值。
现在我想找到 x、y 和 z 的所有可能组合。对于每个组合,我想创建一个文件夹(称为 x1y1z1、x1y2z1、x1y3z1 等),其中包含一个文本文件,其中 x、y 和 z 坐标对应于该特定组合。
我已经使用Python找到了相关问题的解决方案。但是,由于我不熟悉 Python 并且我已经有一个定义了很多变量的大型 bash 脚本,我想知道是否有一种简单的方法可以在 bash 或任何其他我可以轻松集成的语言中执行此操作在我现有的 bash 脚本中。
亲切的问候,
Miro
更新:
这是 Matt D 指出的解决方案的改编版本(感谢一百万):
for x in $(cat centrex.tmp) ; do
for y in $(cat centrey.tmp) ; do
for z in $(cat centrez.tmp) ; do
xvar=$(expr "$x" : '\(.*\)=.*')
yvar=$(expr "$y" : '\(.*\)=.*')
zvar=$(expr "$z" : '\(.*\)=.*')
folder="${xvar}${yvar}${zvar}"
mkdir $folder
echo "center_x = "${x#*=} >> vinapar.conf
echo "center_y = "${y#*=} >> vinapar.conf
echo "center_z = "${z#*=} >> vinapar.conf
cp vinapar.conf $folder/
rm vinapar.conf
done
done
done
这样做的原因是最终我以这种方式格式化了我的 centerX.tmp 文件:
x00=-15.349
x01=-10.349
x02=-5.349
...
这允许我命名文件夹根据等号(x01y23z09)之前的块,然后创建包含实际坐标的文件。
I am writing a bash script for automatising blind docking (finding binding sites within a protein). For so doing, I have divided a big 3D grid in smaller overlapping grids.
I have created three files containing the x, y and z coordinates of the sub-grids centres, respectively. In other words, one file contains all the possible x coordinates (one per line), the second all the y coordinates and the third all the z coordinates. The coordinates have three decimal places and can be positive or negative.
Now I would like to find all possible combinations of x,y and z. For each combination I would like to create a folder (called something like x1y1z1, x1y2z1, x1y3z1, etc) containing a text file with x, y and z coordinates that correspond to that particular combination.
I have found solutions to related problems using Python. However, as I am not familiar with Python and I have already a large bash script with a lot of variables defined, I would like to know if there is an easy way for doing this in bash or in any other language that I can easily integrate in my existing bash script.
Kind regards,
Miro
UPDATE:
This is the adapted version of the solution indicated by Matt D (thanks a million):
for x in $(cat centrex.tmp) ; do
for y in $(cat centrey.tmp) ; do
for z in $(cat centrez.tmp) ; do
xvar=$(expr "$x" : '\(.*\)=.*')
yvar=$(expr "$y" : '\(.*\)=.*')
zvar=$(expr "$z" : '\(.*\)=.*')
folder="${xvar}${yvar}${zvar}"
mkdir $folder
echo "center_x = "${x#*=} >> vinapar.conf
echo "center_y = "${y#*=} >> vinapar.conf
echo "center_z = "${z#*=} >> vinapar.conf
cp vinapar.conf $folder/
rm vinapar.conf
done
done
done
The reason to do this is that finally I formated my centreX.tmp files in this way:
x00=-15.349
x01=-10.349
x02=-5.349
...
This allows me to name the folders according to the chunk before the equals sign (x01y23z09) and then create files containing the actual coordinates.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您想要内容的所有组合,这将是一个三重嵌套循环。
编辑:此表单将使用
读取
(尚未测试)If you want all the combinations of the contents, this will be a triple-nested loop.
Edit: This form would use
read
(haven't tested)