スクリプトを実行すると、次の行が表示されます。
PyMOL(TM) Molecular Graphics System, Version 1.4.1.
Copyright (c) Schrodinger, LLC.
All Rights Reserved.
Created by Warren L. DeLano, Ph.D.
PyMOL is user-supported open-source software. Although some versions
are freely available, PyMOL is not in the public domain.
If PyMOL is helpful in your work or study, then please volunteer
support for our ongoing efforts to create open and affordable scientific
software by purchasing a PyMOL Maintenance and/or Support subscription.
More information can be found at "http://www.pymol.org".
Enter "help" for a list of commands.
Enter "help <command-name>" for information on a specific command.
Hit ESC anytime to toggle between text and graphics.
Command mode. No graphics front end.
Detected 8 CPU cores. Enabled multithreaded rendering.
PyMOL>align MHC1, MHC2
Match: read scoring matrix.
Match: assigning 385 x 384 pairwise scores.
MatchAlign: aligning residues (385 vs 384)...
ExecutiveAlign: 3810 atoms aligned.
Executive: RMS = 0.000 (3810 to 3810 atoms)
PyMOL>sele EP1, chain M
Selector: selection "EP1" defined with 63 atoms.
PyMOL>sele EP2, chain R
Selector: selection "EP2" defined with 64 atoms.
PyMOL>rms_cur EP1 and n. CA, EP2 and n. CA
Executive: RMS = 7.457 (9 to 9 atoms)
PyMOL: normal program termination.
「Executive:RMS = 7.457(9〜9アトム)」の行から値「7.457」を抽出する必要があります。「7.457」の値と「 9〜9原子」の情報はラウンドごとに異なるため、パターンとして使用することはできません。「Executive:RMS」は可変ではありませんが、上記の数行で繰り返されます。どうやら、私は常に値を持っていますこれは値を抽出するために使用できますが、pythonまたはシェルスクリプトでそれを行う方法がわかりません。
誰かが私を助けることができますか?どうもありがとうございました!
ちなみに、これは私が取り組んでいるスクリプトです(これは特定のPyMolプログラムであり、RMSD値を取得します):
## RUNNING
## Importing PyMol files
from pymol.cgo import *
from pymol import cmd
from pymol import stored
# Loading MHC1
cmd.load ("MHC1.pdb")
#Change chain C to chain M (MHC1 epitope)
cmd.alter (('chain C'),'chain="M"')
# Loading MHC2
cmd.load ("MHC2.pdb")
#Change chain C to chain R (MHC2 epitope)
cmd.alter (('chain C'),'chain="R"')
## Align MHC1 and MHC2
cmd.do ("align MHC1, MHC2")
## MHC1 epitope selection (EP1)
cmd.do ("sele EP1, chain M")
## MHC2 epitope selection (EP2)
cmd.do ("sele EP2, chain R")
## Remove chain names (this is required so 'rms_cur' will work properly)
cmd.alter (("all"),'chain=""')
## Residues numbers aligned (this is required so 'rms_cur' will work properly)
cmd.alter (("all"),'segi=""')
## RMSD Calculation between EP1 and EP2
cmd.do ("rms_cur EP1 and n. CA, EP2 and n. CA")
表示する出力をどのように取得するかについては、完全には明確ではありません。私はそれがあなたが言及したスクリプトによって生成され、あなたがそれを解析するために他の何かを通してそれを単にパイプすることができると仮定しています。もしそうなら、これらのソリューションは機能するはずです:
your_script | tail -n 2 | awk '/RMS/{print $4}'
tail -n 2
は最後の2行を出力し、awk
はRMS
を含む行の4番目のフィールド、つまり後の値を出力します。
または:
your_script | tail -n 2 | grep -oP '[.\d]+' | head -1
これは、数値のセットの場合はgrep
、または.
になり、head
を使用して最初の数値を出力します。
RMS
を含む最後の行が必要であることがわかっているので、次のようにすることもできます。
your_script | awk '/: RMS/{val=$4}END{print val}'
これは各行を通過し、: RMS
を含む行が見つかるたびに、4番目のフィールドをval
として保存します。 END{}
ブロックは、すべての行が処理された後に実行されるため、その時点で、val
が最後に見つかった値になります。
script | sed -n '${x;p};h'
それでいいと思います。常に最後から2番目の行を印刷します。
番号だけが必要な場合:
script | sed -n '${x;s/.*= *//;s/ .*//p};h'
とても大きいH
appends to sed's
ホールドスペース現在のコンテンツパターンスペース、一方、少しh
上書きそれ。したがって、すべての行のhold spaceを上書きすると、$
last line you e x
change hold space with pattern space、次に、最後から2番目の行で作業します。
これは、必要となる可能性のある最小限のリソースを使用するため、私が想像できるこの問題に対する最善の解決策です。いつでもメモリに2行を超えることはありません。