1
0

More than 1 year has passed since last update.

pymolのpythonスクリプトで複数の構造を同じ方向からまとめて出力するときのpythonスクリプトの例

Posted at

Pymolはタンパク質の構造を解析するためのソフトウェアである。

複数のタンパク質の構造を比較する場合、同じ角度からの画像を出力する必要がある。
比較対象が多いと操作が煩雑になるが、本方法でまとめてpng画像を出力することができる。
pymol上でpythonを動かすことでまとめて画像を出力する方法である。
以下のサイトを参考に記述した。

https://pymolwiki.org/index.php/Python_Integration
https://www.blopig.com/blog/2020/11/using-python-in-pymol/
https://github.com/schrodinger/pymol-open-source
https://pymol.org/pymol-command-ref.html

以下のコードをテキストエディタなどに貼り付け、「XXXX.py」 (XXXXは任意の文字列)と名前をつけ保存する。

#make overall view pymol 実行はspawnで行う。runだと画像が適切に出力しない。
import pymol

#保存先のフォルダを指定する
f_path = '/folder_name/'
#objectの名前のリストを獲得する。
g_obj_l = pymol.cmd.get_object_list('(all)') 

#全てのobjectを一度隠す
pymol.cmd.disable('(all)') 

#pngファイルを連続して出力する。
for i in g_obj_l:
   pymol.cmd.enable(i)
   pymol.cmd.png(f_path + i + '.png')
   #print(i)
   pymol.cmd.disable(i)

pymolのターミナルに以下のコマンドを入力し実行する。
runでもpythonは実行されるが、spawnで実行しないと適切に画像が出力されないので、注意が必要である。

spawn /file_path/XXXX.py
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0