1. 程式人生 > 其它 >Gromacs統計原子間距離,生成csv格式檔案

Gromacs統計原子間距離,生成csv格式檔案

技術標籤:gromacsawkbash

遇到的問題:
gmx distance會生成原子間距離隨時間變化的xvg檔案,還會在終端生成平均距離。之前統計突變體動力學模擬原子間距離不可用,現在需要重新統計特定原子間距離,因此記錄一下:

#!/bin/bash

gmx distance -f traj.xtc -s md.tpr -select "resid 285 and name HH21 plus resid 363 and name O8" -oall 285Arg-HH21_UNK-O8.xvg > cmd

gmx distance -f traj.xtc -s md.tpr -select "resid 285 and name HE plus resid 363 and name O7"
-oall 285Arg-HE_UNK-O7.xvg >> cmd gmx distance -f traj.xtc -s md.tpr -select "resid 238 and name HH plus resid 363 and name O8" -oall 238Tyr-HH_UNK-O8.xvg >> cmd gmx distance -f traj.xtc -s md.tpr -select "resid 223 and name HH plus resid 363 and name O8" -oall 223Tyr-HH_UNK-O8.xvg >>
cmd gmx distance -f traj.xtc -s md.tpr -select "resid 335 and name OG plus resid 363 and name H19" -oall 335Ser-OG_UNK-H19.xvg >> cmd gmx distance -f traj.xtc -s md.tpr -select "resid 335 and name O plus resid 363 and name H20" -oall 335Ser-O_UNK-H20.xvg >> cmd gmx distance -f traj.xtc -s md.tpr -select "resid 54 and name H plus resid 363 and name O10"
-oall 54Thr-H_UNK-O10.xvg >> cmd gmx distance -f traj.xtc -s md.tpr -select "resid 362 and name N5 plus resid 363 and name C5" -oall FAD-N5_UNK-C5.xvg >> cmd gmx distance -f traj.xtc -s md.tpr -select "resid 362 and name N5 plus resid 363 and name H17" -oall FAD-N5_UNK-H17.xvg >> cmd grep "resid" cmd |awk '{ORS=" "; print$2 $5"_" $8 $11}' > resid #提取cmd檔案中含有“resid”行,awk提取第2行、第5行、第8行和第11行,中間以“_” 隔開 grep "Average" cmd | awk '{ORS=" "; print$3}' > Average sed -i "s/://g" resid #把resid中的冒號替換成空格 sed -i "1r Average" resid #把Average中的內容插入到resid中第二行 awk 'BEGIN{ FS=" ";OFS=","}{print $1,$2,$3,$4,$5,$6,$7,$8}' resid > resid.csv #把空格換成逗號

最終生成的resid.csv是:
在這裡插入圖片描述
生成的csv檔案匯入windows中可用xlsx直接開啟,參考了這篇博文:Linux的檔案如何匯出成Windows裡的Excel

歡迎大家多提意見,現在這個可以滿足我的需求,大家也許有更簡練的寫法,都可留言哦!