{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# crysolの対話モードの自動応答での実行\n", "\n", "できるだけわかりやすいように、無駄な部分は省いている。\n", "\n", "出力の文字列が乱れているが、気になるのなら`print`がある文をコメントアウトすればよい。" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "def auto_crysol(pdb_base,dat_base):\n", " \n", " import pexpect\n", " \n", " \n", " p = pexpect.spawn(\"crysol\")\n", " #2-1. Enter your option ...................... < 0 >:\n", " p.expect(r\">:\") \n", " print (p.before+p.after)\n", " p.sendline(\"\")\n", " #2-2. Brookhaven file name ................... < .pdb >:\n", " p.expect(r\">:\") \n", " print (p.before+p.after)\n", " p.sendline(pdb_base)\n", " #2-3. Maximum order of harmonics ........... < 15 >:\n", " p.expect(r\">:\") \n", " print (p.before+p.after)\n", " p.sendline(\"\")\n", " #2-4. Order of Fibonacci grid ............... < 17 >: \n", " p.expect(r\">:\") \n", " print (p.before+p.after)\n", " p.sendline(\"\")\n", " #2-5. Maximum s value ........................ < .5000 >: \n", " p.expect(r\">:\") \n", " print (p.before+p.after)\n", " p.sendline(\"\")\n", " #2-6. Number of points ....................... < 51 >:\n", " p.expect(r\">:\") \n", " print (p.before+p.after)\n", " p.sendline(\"201\")\n", " #2-7. Account for explicit hydrogens? [ Y / N ] < No >: \n", " p.expect(r\">:\") \n", " print (p.before+p.after)\n", " p.sendline(\"\")\n", " \n", " #4-1. Fit the experimental curve [ Y / N ] .. < Yes >:\n", " p.expect(r\">:\") \n", " print (p.before+p.after)\n", " p.sendline(\"\")\n", " #4-2. Enter data file ........................ < .dat >:\n", " p.expect(r\">:\") \n", " print (p.before+p.after)\n", " p.sendline(dat_base)\n", " #5-1. Subtract constant ...................... < no >: \n", " p.expect(r\">:\") \n", " print (p.before+p.after)\n", " p.sendline(\"N\")\n", " \n", " #5-2. 2 * sin(theta)/lambda [1/nm] (4) ..... < 1 >: \n", " p.expect(r\">:\") \n", " print (p.before+p.after)\n", " p.sendline(\"\")\n", " \n", " #6. Electron density of the solvent, e/A**3 < .3340 >:\n", " p.expect(r\">:\") \n", " print (p.before+p.after)\n", " p.sendline(\"\")\n", " \n", " #7. Plot the fit [ Y / N ] ................. < Yes >:\n", " p.expect(r\">:\") \n", " print (p.before+p.after)\n", " p.sendline(\"N\")\n", " \n", " #8-1. Another set of parameters [ Y / N ] .... < No >:\n", " p.expect(r\">:\") \n", " print (p.before+p.after)\n", " p.sendline(\"Y\")\n", " \n", " #8-2. Minimize again with new limits [ Y / N ] < No >: \n", " p.expect(r\">:\") \n", " print (p.before+p.after)\n", " p.sendline(\"Y\")\n", "\n", "\n", " p.expect(r\"Minimum\")\n", " ret=str(p.before)\n", " # print ('ret',ret)\n", " #Average atomic radius is ............................... :\n", " m=ret.split(':')\n", " # print('m',m[-1].split(\"\\\\\")[0])\n", " Ra=float(m[-1].split(\"\\\\\")[0])\n", " \n", " # 9-1. Minimum radius of atomic group ......... < 1.400 >:\n", " p.expect(r\">:\") \n", " print (p.before+p.after)\n", " p.sendline(str(Ra))\n", " \n", " # 9-2. Maximum radius of atomic group ......... < 1.800 >:\n", " p.expect(r\">:\") \n", " print (p.before+p.after)\n", " p.sendline(str(Ra)) \n", " \n", " # 9-3. Smax in the fitting range .............. < 0.4984 >:\n", " p.expect(r\">:\") \n", " print (p.before+p.after)\n", " p.sendline(\"\")\n", " \n", " # 9-4. Minimum contrast in the shell .......... < 0.000 >: \n", " p.expect(r\">:\") \n", " print (p.before+p.after)\n", " p.sendline(\"\")\n", "\n", " # 9-5. Maximum contrast in the shell .......... < 7.5000E-002 >: \n", " p.expect(r\">:\") \n", " print (p.before+p.after)\n", " p.sendline(\"\")\n", " \n", " p.expect(r\"Minimum\")\n", " ret=str(p.before)\n", " # print ('ret',ret)\n", " #Van der Waals volume is ................................ :\n", " m=ret.split(':')\n", " # print('m',m[-1].split(\"\\\\\")[0])\n", " ExVol=float(m[-1].split(\"\\\\\")[0])\n", " \n", " # 9-6 Minimum excluded volume ................ < 1.6108E+004 >:\n", " p.expect(r\">:\") \n", " print (p.before+p.after)\n", " p.sendline(str(ExVol)) \n", " \n", " # 9-7. Maximum excluded volume ................ < 1.8720E+004 >:\n", " p.expect(r\">:\") \n", " print (p.before+p.after)\n", " p.sendline(str(ExVol)) \n", "\n", " # 9-7. Subtract constant ...................... < no >:\n", " p.expect(r\">:\") \n", " print (p.before+p.after)\n", " p.sendline(\"\")\n", "\n", " # 10-1. Plot the fit [ Y / N ] ................. < Yes >:\n", " p.expect(r\">:\") \n", " print (p.before+p.after)\n", " p.sendline(\"N\") \n", " \n", " # 10-2. Another set of parameters [ Y / N ] .... < No >: \n", " p.expect(r\">:\") \n", " print (p.before+p.after)\n", " p.sendline(\"\")\n", " \n", " #p.terminate()\n", " p.expect(pexpect.EOF)\n", " \n", " return" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "- `6lyz.pdb` : 結晶構造\n", "\n", "- `lyzexp.dat` : 実験データ\n", "\n", "を入力して上の関数`auto_crysol`を実行する。" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "auto_crysol('6lyz.pdb','lyzexp.dat')" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.5" } }, "nbformat": 4, "nbformat_minor": 2 }