OSDN Git Service

Copyright and License description for JANPA are included
[molby/Molby.git] / Documents / src / doc_source.html
1 <?xml version="1.0" encoding="utf-8"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml">
4 <head>
5 <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
6 <title>Molby</title>
7 <link rel="stylesheet" href="../etc/style.css" type="text/css" />
8 </head>
9
10 <body>
11
12 <div file="index.html">
13 <link id="#header" />
14 <div class="centered" lang="en">
15 <h1>Molby</h1>
16 <h2>Interactive Molecular Modeling Software<br />with Integrated Ruby Interpreter</h2>
17 <h3>Version 1.1.0</h3> <!-- version -->
18 <h3>Toshi Nagata</h3>
19 <p><a href="http://molby.osdn.jp/index-en.html">http://molby.osdn.jp/index-en.html</a></p>
20 </div>
21 <div class="centered" lang="ja">
22 <h1>Molby</h1>
23 <h2>対話型分子モデリングソフトウェア<br />(Ruby インタプリタ内蔵)</h2>
24 <h3>Version 1.1.0</h3> <!-- version -->
25 <h3>永田 央</h3>
26 <p><a href="http://molby.osdn.jp/index.html">http://molby.osdn.jp/index.html</a></p>
27 </div>
28 <hr />
29 <div class="contents" lang="en">
30 <h2>Table of Contents</h2>
31 <link id="#toc_all" />
32 </div>
33 <div class="contents" lang="ja">
34 <h2>目次</h2>
35 <link id="#toc_all" />
36 </div>
37 <link id="#navigation" />
38 </div>
39
40 <div file="introduction.html">
41 <link rel="Up" href="index.html" />
42 <link id="#header" />
43 <div class="contents" lang="en">
44 <h1>Introduction</h1>
45 <link id="#toc" />
46 </div>
47 <div class="contents" lang="ja">
48 <h1>はじめに</h1>
49 <link id="#toc" />
50 </div>
51 <link id="#navigation" />
52 </div>
53
54 <div file="whatis.html">
55 <link rel="Up" href="introduction.html" />
56 <link id="#header" />
57 <div class="contents" lang="en">
58 <h1>What is Molby?</h1>
59 <p>
60 Molby is an application to visualize and build molecular models interactively through 3D display. It provides the following capability:
61 </p>
62 <ul>
63 <li>Viewing molecular models in either ball-and-stick or "line" display.</li>
64 <li>Interactive modification of molecular models by mouse operation.</li>
65 <li>Optimization of the structure by molecular mechanics calculation. Also capable is the molecular dynamics calculation.</li>
66 <li>Viewing and editing atomic coordinates, molecular mechanics atom typs, and other parameters in tables.</li>
67 <li>Importing and exporting structure/coordinate data for other program packages such as Gaussian, GAMESS, NAMD and SHELX.</li>
68 <li>Embedded Ruby interpreter for automated processing of molecular models.</li>
69 </ul>
70 </div>
71 <div class="contents" lang="ja">
72 <h1>Molbyとは?</h1>
73 <p>
74 Molby は、分子を 3D 表示して、画面上で分子モデルを構築するためのアプリケーションです。以下のような機能があります。
75 </p>
76 <ul>
77 <li>分子を ball-and-stick または「線」で表示できます。</li>
78 <li>分子モデルをマウス操作で編集できます。</li>
79 <li>分子力学計算による構造最適化ができます。分子動力学計算も可能です。</li>
80 <li>原子座標や分子力学の原子タイプなどのパラメータを、テーブルで編集できます。</li>
81 <li>Gaussian, GAMESS, NAMD, SHELX などの他のプログラムパッケージのファイルを読み込み/書き出しできます。</li>
82 <li>分子モデルの操作を自動化できるように Ruby インタプリタを内蔵しています。</li>
83 </ul>
84 </div>
85 <link id="#navigation" />
86 </div>
87
88 <div file="installation.html">
89 <link rel="Up" href="introduction.html" />
90 <link rel="Prev" href="whatis.html" />
91 <link id="#header" />
92 <div class="contents" lang="en">
93 <h1>Installation</h1>
94 <h2>1. Supported Platforms</h2>
95 <p>
96 Molby runs on the following platforms.
97 </p>
98 <ul>
99 <li>Microsoft Windows (7 or later, 32 bit or 64 bit).</li>
100 <li>Mac OS X (10.12 or later, 64 bit Intel).</li>
101 </ul>
102
103 <p>
104 Installation procedures are described below for each of these platforms.
105 </p>
106
107 <h2>2. Get the Software</h2>
108 <p>
109 Download from the official distribution web site, <a href="http://en.osdn.jp/projects/molby/">http://en.osdn.jp/projects/molby/</a>.
110 </p>
111
112 <h2>3. Installation</h2>
113
114 <h3>3-1. Microsoft Windows</h3>
115
116 <p>
117 The Windows version is provided either as a zip archive (<code>MolbyWin32.zip</code>, <code>MolbyWin64.zip</code>) or a standard setup package (<code>SetupMolbyWin32.exe</code>, <code>SetupMolbyWin.exe</code>).
118 </p>
119 <p>
120 To use the zip archive, expand all contents in your favorite place, and double-click the "Molby" icon.
121 </p>
122 <p>
123 To install on your PC, start the setup package, and follow the instructions. After installation is finished, you will find the Molby application registered in the "Start" menu under the item "All Programs."
124 </p>
125
126 <h3>3-2. Mac OS X</h3>
127 <p>
128 The Mac version is provided as a zip archive (<code>MolbyMac.zip</code>, <code>MolbyMacLegacy.zip</code> for MacOS 10.6 to 10.11). Double-click the archive, and you will get a folder including the Molby application. Drag it to the "Applications" folder in your hard drive.
129 </p>
130
131 <h2>4. Uninstallation</h2>
132 <h3>4-1. Microsoft Windows</h3>
133 <p>
134 If you install Molby, use the uninstaller in the Molby folder. You can access the Molby folder from the "Start" menu (Start -&gt; All Programs -&gt; Molby).
135 </p>
136 <h3>4-2. Mac OS X</h3>
137 <p>
138 Trash the Molby application in the "Applications" folder.
139 </p>
140
141 </div>
142 <div class="contents" lang="ja">
143 <h1>インストール</h1>
144 <h2>1. サポートするプラットフォーム</h2>
145 <p>
146 Molbyは以下のプラットフォームで動作します。
147 </p>
148 <ul>
149 <li>Microsoft Windows (7またはそれ以降, 32ビットまたは64ビット).</li>
150 <li>Mac OS X (10.12 またはそれ以降、64ビット).</li>
151 </ul>
152
153 <p>
154 それぞれのプラットフォームでのインストール方法を、以下に説明します。
155 </p>
156
157 <h2>2. ソフトウェアの入手</h2>
158 <p>
159 公式配布サイト <a href="http://osdn.jp/projects/molby/">http://osdn.jp/projects/molby/</a> から最新版をダウンロードしてください。
160 </p>
161
162 <h2>3. インストール</h2>
163
164 <h3>3-1. Microsoft Windows</h3>
165
166 <p>
167 Windows版は、zip アーカイブ(<code>MolbyWin32.zip</code>:32 ビット版, <code>MolbyWin64.zip</code>: 64ビット版)、または標準のセットアップパッケージ (<code>SetupMolbyWin32.exe</code>: 32ビット版、<code>SetupMolbyWin64.exe</code>: 64ビット版) で配布されています。
168 </p>
169 <p>
170 Zip アーカイブを使う時は、最初に内容をすべて展開してください。展開したフォルダの中に Molby アプリケーションがあるので、ダブルクリックして起動してください。
171 </p>
172 <p>
173 セットアップパッケージを使う時は、ダブルクリックして指示に従ってください。インストールが終了したら、「スタート」メニューの「すべてのプログラム」の中に Molby が入っているはずです。
174 </p>
175
176 <h3>3-2. Mac OS X</h3>
177 <p>
178 Mac版は、zip アーカイブ (<code>MolbyMac.zip</code>, <code>MolbyMacLegacy.zip</code> [10.6〜10.11用]) で配布されています。アーカイブをダブルクリックすると、内容が展開されて新しいフォルダができます。Molby アプリケーションがその中にありますので、ハードディスクの「アプリケーション」フォルダにドラッグコピーしてください。
179 </p>
180
181 <h2>4. アンインストール</h2>
182 <h3>4-1. Microsoft Windows</h3>
183 <p>
184 インストールした Molby を PC から除きたい時には、Molbyフォルダの中のアンインストーラを使ってください。「スタート」メニューで「すべてのプログラム」-&gt; Molby とたどってください。
185 </p>
186 <h3>4-2. Mac OS X</h3>
187 <p>
188 「アプリケーション」フォルダの中の Molby アプリケーションをゴミ箱に捨てます。
189 </p>
190
191 </div>
192 <link id="#navigation" />
193 </div>
194
195 <div file="copyright.html">
196 <link rel="Up" href="introduction.html" />
197 <link rel="Prev" href="installation.html" />
198 <link id="#header" />
199 <div class="contents" lang="en">
200 <h1>Copyright and License</h1>
201 <h2>1. Copyright Notice</h2>
202 <p>
203 Molby is a copyrighted product of Toshi Nagata.
204 </p>
205 <p>
206 Copyright (C) 2008-2022 Toshi Nagata <!-- copyright -->
207 </p>
208 <p>
209 I ask for citation of the following paper in published works that utilize Molby:
210 </p>
211 <blockquote>
212 <p>
213 Toshi Nagata, "Molby - Graphical Molecular Modeling Software with Integrated Ruby Interpreter," 
214 <br />
215 <i>Bull. Chem. Soc. Jpn.</i> <b>2014,</b> <i>87,</i> 902-904. DOI:<a href="http://dx.doi.org/10.1246/bcsj.20140093">10.1246/bcsj.20140093</a>
216 </p>
217 </blockquote>
218 <p>
219 Molby includes the following softwares, which are copyrighted products as described below:
220 </p>
221 <ul>
222 <li>
223 <a href="http://ambermd.org/">AmberTools 1.3</a>: Copyright (C) Junmei Wang, Ross C. Walker, Michael F. Crowley, Scott Brozell and David A. Case
224 </li>
225 <li>
226 <a href="http://www.wxwidgets.org/">wxWidgets 3.2.0</a>: Copyright (C) 1992-2022 Julian Smart, Robert Roebling, Vadim Zeitlin and other members of the wxWidgets team. Portions (c) 1996 Artificial Intelligence Applications Institute
227 </li>
228 <li>
229 <a href="http://www.ruby-lang.org/">Ruby 2.0.0</a>: Copyright (C) 1993-2013 Yukihiro Matsumoto
230 </li>
231 <li>
232 <a href="http://www.netlib.org/clapack/">CLAPACK</a>: Copyright (C) 1992-2008 The University of Tennessee.  All rights reserved.
233 </li>
234 <li>
235 <a href="http://www.fftw.org/">FFTW 3.3.2</a>: Copyright (C) 2003, 2007-11 Matteo Frigo and Massachusetts Institute of Technology
236 </li>
237 <li>
238 <a href="http://web.ornl.gov/sci/ortep/">ORTEP III</a>: The citation is made like below. There are no copyright notice, but it is likely to be put in public domain.<br />
239 Burnett, M. N.; Johnson, C. K. <i>ORTEP-III: Oak Ridge Thermal Ellipsoid Plot Program for Crystal Structure Illustrations,</i> Oak Ridge National Laboratory Report ORNL-6895, 1996.
240 </li>
241 <li>
242 <a href="http://janpa.sourceforge.net/">JANPA</a>: Copyright (C) 2014, Tymofii Nikolaienko.<br />
243 See <a href="../etc/JANPA_license.txt">the software license for JANPA package of programs</a>.
244 </li>
245 </ul>
246
247 <h2>2. License</h2>
248 <p>
249 Molby is distributed under the GNU General Public License (version 3).
250 </p>
251 <blockquote>
252 <p>
253 Molby: Interactive Molecular Modeling Software with Integrated Ruby Interpreter
254 </p>
255 <p>
256 Copyright (C) 2008-2022 Toshi Nagata <!-- copyright -->
257 </p>
258 <p>
259 This program is free software; you can redistribute it and/or modify
260 it under the terms of the GNU General Public License as published by
261 the Free Software Foundation; either version 3 of the License, or
262 (at your option) any later version.
263 </p>
264 <p>
265 This program is distributed in the hope that it will be useful,
266 but WITHOUT ANY WARRANTY; without even the implied warranty of
267 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
268 <a href="../etc/gpl.txt">GNU General Public License</a> for more details.
269 </p>
270 </blockquote>
271 </div>
272 <div class="contents" lang="ja">
273 <h1>著作権とライセンス</h1>
274 <h2>1. 著作権表示</h2>
275 <p>
276 Molby の著作権は永田 央が保持しています。
277 </p>
278 <p>
279 Copyright (C) 2008-2022 Toshi Nagata <!-- copyright -->
280 </p>
281 <p>
282 Molby を利用した成果を発表される際は、以下の論文を引用していただくようお願いします。
283 </p>
284 <blockquote>
285 <p>
286 Toshi Nagata, "Molby - Graphical Molecular Modeling Software with Integrated Ruby Interpreter," <br />
287 <i>Bull. Chem. Soc. Jpn.</i> <b>2014,</b> <i>87,</i> 902-904. DOI:<a href="http://dx.doi.org/10.1246/bcsj.20140093">10.1246/bcsj.20140093</a>
288 </p>
289 </blockquote>
290 <p>
291 Molby は以下のソフトウェアを含んでいます。それぞれの著作権表示は下の通りです。
292 </p>
293 <ul>
294 <li>
295 <a href="http://ambermd.org/">AmberTools 1.3</a>: Copyright (C) Junmei Wang, Ross C. Walker, Michael F. Crowley, Scott Brozell and David A. Case
296 </li>
297 <li>
298 <a href="http://www.wxwidgets.org/">wxWidgets 3.2.0</a>: Copyright (C) 1992-2022 Julian Smart, Robert Roebling, Vadim Zeitlin and other members of the wxWidgets team. Portions (c) 1996 Artificial Intelligence Applications Institute
299 </li>
300 <li>
301 <a href="http://www.ruby-lang.org/">Ruby 2.0.0</a>: Copyright (C) 1993-2013 Yukihiro Matsumoto
302 </li>
303 <li>
304 <a href="http://www.netlib.org/clapack/">CLAPACK</a>: Copyright (C) 1992-2008 The University of Tennessee.  All rights reserved.
305 </li>
306 <li>
307 <a href="http://www.fftw.org/">FFTW 3.3.2</a>: Copyright (C) 2003, 2007-11 Matteo Frigo and Massachusetts Institute of Technology
308 </li>
309 <li>
310 <a href="http://web.ornl.gov/sci/ortep/">ORTEP III</a>: The citation is made like below. There are no copyright notice, but it is likely to be put in public domain.<br />
311 Burnett, M. N.; Johnson, C. K. <i>ORTEP-III: Oak Ridge Thermal Ellipsoid Plot Program for Crystal Structure Illustrations,</i> Oak Ridge National Laboratory Report ORNL-6895, 1996.
312 </li>
313 <li>
314 <a href="http://janpa.sourceforge.net/">JANPA</a>: Copyright (C) 2014, Tymofii Nikolaienko.<br />
315 See <a href="../etc/JANPA_license.txt">the software license for JANPA package of programs</a>.
316 </li>
317 </ul>
318
319 <h2>2. ライセンス</h2>
320 <p>
321 Molby は <a href="../etc/gpl.txt">GNU General Public License (GNU 一般公衆利用許諾契約書, version 3)</a> に従って配布します。
322 </p>
323 <blockquote>
324 <p>
325 Molby: 対話型分子モデルソフトウェア(Ruby インタプリタ内蔵)
326 </p>
327 <p>
328 Copyright (C) 2008-2022 Toshi Nagata <!-- copyright -->
329 </p>
330 <p>
331 このプログラムはフリーソフトウェアです。あなたはこれを、フリーソフトウェア財団によって発行された GNU 一般公衆利用許諾契約書(バージョン3か、希望によってはそれ以降のバージョンのうちどれか)の定める条件の下で再頒布または改変することができます。
332 </p>
333 <p>
334 このプログラムは有用であることを願って頒布されますが、*全くの無保証* です。商業可能性の保証や特定の目的への適合性は、言外に示されたものも含め全く存在しません。詳しくはGNU 一般公衆利用許諾契約書をご覧ください。
335 </p>
336 </blockquote>
337 <p>
338 参考のため、GNU 一般公衆利用許諾契約書の<a href="../etc/gpl.ja.html">非公式日本語訳</a>を添付します。ただし、正式な文書は英語版の方です。
339 </p>
340 </div>
341 <link id="#navigation" />
342 </div>
343
344 <div file="tutorials.html">
345 <link rel="Up" href="index.html" />
346 <link rel="Prev" href="introduction.html" />
347 <link id="#header" />
348 <div class="contents" lang="en">
349 <h1>Tutorials</h1>
350 <link id="#toc" />
351 </div>
352 <div class="contents" lang="ja">
353 <h1>チュートリアル</h1>
354 <link id="#toc" />
355 </div>
356 <link id="#navigation" />
357 </div>
358
359 <div file="drawing.html">
360 <link rel="Up" href="tutorials.html" />
361 <link id="#header" />
362 <div class="contents" lang="en">
363 <h1>Step One: Draw a New Molecule</h1>
364 <h2>1. Create a Molecule</h2>
365 <p>
366 Start up Molby. You will see a blank window like below. This is the main window to manipulate your molecule.
367 </p>
368 <p><img src="../etc/draw_01.png" /></p>
369 <p>
370 Suppose you want a benzene molecule. Double-click on the black area, and you will be asked to "enter formula". Type "C6H6" and hit "OK".
371 </p>
372 <p><img src="../etc/draw_02.png" /></p>
373 <p>
374 Then you see a benzene molecule in the black area. The atoms and bonds are drawn in red, which means these atoms and bonds are "selected". On the left to this area, there is a table, which shows in numbers the positions of all atoms, and other useful information. We will get into this part in more details later.
375 </p>
376 <p><img src="../etc/draw_03.png" /></p>
377 <h2>2. Rotate the Molecule</h2>
378 <p>
379 You can rotate the molecule around by use of the three bars on the both sides and the bottom of the black area. Press the left button of the mouse on one of these bars, and try dragging.
380 </p>
381 <p><img src="../etc/draw_04.png" /></p>
382 <ul>
383 <li>Bar 1: rotate the whole molecule around the horizontal axis.</li>
384 <li>Bar 2: rotate the whole molecule around the vertical axis.</li>
385 <li>Bar 3: rotate the selected part of the molecule. (In the present example, the whole molecule is selected, so that the bar 3 works in the same manner as the bar 2.)</li>
386 </ul>
387 <p>
388 Next, look at the buttons above the black area. The left-most button "Rot" is now selected. This means the window is in the "Rotation" mode. In this case, you can drag in the black area to rotate freely the whole molecule.
389 </p>
390 <p class="note">
391 <span class="italic">Note:</span> Be careful not to start drag from a very near point to the molecule. If you start drag on a selected atom or bond, the selected part will move along the mouse, instead of the whole molecule to rotate.
392 </p>
393
394 <h2>3. Translate and Scale</h2>
395 <p>
396 Press the button "Trans" above the black area. The window is now in "Translate" mode. When you drag in the black area, the whole molecule moves along with the mouse movement.
397 </p>
398 <p class="note">
399 <span class="italic">Note:</span> the functions of the rotation bars do not change.
400 </p>
401 <p><img src="../etc/draw_05.png" /></p>
402 <p>
403 Next, press the button "Scale". The window is now in "Scale" mode, and you can expand and shrink the molecule by dragging in the black area.
404 </p>
405 <p><img src="../etc/draw_06.png" /></p>
406 <p>
407 The "Fit to Screen" menu command, avaiable under the "View" menu, is a convenient way to fit the whole molecule to the window.
408 </p>
409 <p><img src="../etc/draw_07.png" /></p>
410 <p>
411 Now you have learned how to move the whole molecule around. In the next chapter, you will learn how to edit the molecule.
412 </p>
413 </div>
414
415 <div class="contents" lang="ja">
416 <h1>第一段階:新しい分子を描く</h1>
417 <h2>1. 分子を作る</h2>
418 <p>
419 Molbyを立ち上げてください。下のような空のウィンドウが現れます。このウィンドウが、分子を取り扱うためのメインウィンドウです。
420 </p>
421 <p><img src="../etc/draw_01.png" /></p>
422 <p>
423 ベンゼン分子を作ってみたいとします。画面の黒いところ(編集エリア)をダブルクリックすると、"enter formula" と指示が出ます。"C6H6" とタイプして、OK を押します。
424 </p>
425 <p><img src="../etc/draw_02.png" /></p>
426 <p>
427 編集エリアにベンゼン分子が現れます。原子と結合は赤色で描かれていますが、これは「選択されている」という表示です。左側には表があり、原子の位置などの情報を数値で表示しています。この部分については、あとで詳しい使い方が出てきます。
428 </p>
429 <p><img src="../etc/draw_03.png" /></p>
430 <h2>2. 分子を回転させる</h2>
431 <p>
432 編集エリアの両側と下には、分子を回転させるバーがあります。このバーでマウスボタンを押し、そのままドラッグしてみてください。
433 </p>
434 <p><img src="../etc/draw_04.png" /></p>
435 <ul>
436 <li>バー1:水平軸の周りに分子を回転させる。</li>
437 <li>バー2:垂直軸の周りに分子を回転させる。</li>
438 <li>バー3:分子の選択部分を回転させる。(今は分子全体が選択されているため、バー2と同じ動作をします。)</li>
439 </ul>
440 <p>
441 次に、編集エリアの上にあるボタンを見てください。一番左の "Rot" が選択されています。これは、このウィンドウが現在「回転 (Rotation)」モードにあることを示しています。この場合、編集エリアでマウスをドラッグすると、分子全体を自由に回転させることができます。
442 </p>
443 <p class="note">
444 <span class="italic">注:</span> 分子に近すぎるところからドラッグを始めないように注意してください。選択している原子・結合の上でドラッグを始めると、選択部分がマウスについて動いてしまい、分子全体を動かすことができません。
445 </p>
446 <h2>3. Translate and scale</h2>
447 <p>
448 "Trans" と書かれたボタンを押してください。ウィンドウは「並進 (Translate)」モードになります。編集エリアでマウスをドラッグすると、分子全体を平行移動させることができます。
449 </p>
450 <p class="note">
451 <span class="italic">注:</span> 回転バーの機能は変わりません。
452 </p>
453 <p><img src="../etc/draw_05.png" /></p>
454 <p>
455 次に、"Scale" と書かれたボタンを押してください。ウィンドウは「拡大縮小 (Scale)」モードになります。編集エリアでマウスをドラッグすると、分子全体を拡大・縮小することができます。
456 </p>
457 <p><img src="../etc/draw_06.png" /></p>
458 <p>
459 "View" メニューの中に "Fit to Screen" メニューコマンドがあります。このコマンドは、分子をウィンドウサイズに合わせて表示したいときに便利です。
460 </p>
461 <p><img src="../etc/draw_07.png" /></p>
462 <p>
463 分子を画面上で動かす方法がわかりました。次は、編集のやり方を説明します。
464 </p>
465 </div>
466 <link id="#navigation" />
467 </div>
468
469 <div file="editing.html">
470 <link rel="Up" href="tutorials.html" />
471 <link rel="Prev" href="drawing.html" />
472 <link id="#header" />
473 <div class="contents" lang="en">
474 <h1>Step Two: Edit a Molecule</h1>
475 <h2>1. Append a Substituent</h2>
476 <p>
477 Suppose you have a benzene molecule now, and want to append a methyl substituent to give a toluene.
478 </p>
479 <p>
480 Press the button "Select", and click on the black area where no atom nor bond is present. The selection becomes canceled.
481 </p>
482 <p><img src="../etc/edit_01.png" /></p>
483 <p>
484 Select one of the hydrogen atoms. There are two ways to do this. You can click on the target atom, or you can drag to select atoms within a rectangular region.
485 </p>
486 <p><img src="../etc/edit_02.png" /> <img src="../etc/edit_03.png" /></p>
487 <p>
488 Double-click on the hydrogen atom. This time, be sure to hit the selection! Then you will see the dialog "enter formula" as shown below. Type "CH3" in the text box and hit "OK".
489 </p>
490 <p><img src="../etc/edit_04.png" /></p>
491 <p>
492 Now you get toluene.
493 </p>
494 <p><img src="../etc/edit_05.png" /></p>
495 <p>
496 You want to save the result to a file. Select "Save as..." from the File menu, choose the file format, enter the filename, and hit "Save".
497 </p>
498 <p>
499 The "native" file format in Molby is "mbsf", i.e. <u>M</u>ol<u>b</u>y <u>S</u>tructure <u>F</u>ile. The mbsf format is a private format with no compatibility with any existing file format for chemistry. Nevertheless, it is a plain text file that is reasonably compact and easy to read. Unless you have a particular reason to choose other formats, it is recommended that you save the structues as a "mbsf" file.
500 </p>
501 <h2>2. Manipulate Molecular Fragments</h2>
502 <p>
503 After building a molecule, you may want to move some part of a molecule. Here are examples how you can do it.
504 </p>
505 <p>
506 Select the methyl group of the toluene, if you have not done so yet <span class="note">(Tip: you can add to the current selection by shift-clicking)</span>. Press the left rotation bar (marked "3" in the previous page), and drag up and down. You will see the methyl group rotates to the right and left.
507 </p>
508 <p><img src="../etc/edit_06.png" /></p>
509 <p>
510 The same manipulation can be achieved by selecting one bond and dragging the left rotation bar. In this case, you can also rotate the benzene ring (with the methyl group fixed) by pressing Option (Mac) or Alt (Win) key when dragging.
511 </p>
512 <p><img src="../etc/edit_07.png" /></p>
513 <p>
514 The selected atoms can be dragged to give a translational move. Use this feature with care, because it may result in a chemically unnatural structure.
515 </p>
516 <p><img src="../etc/edit_08.png" /></p>
517 <h2>3. Adding and Deleting Atoms</h2>
518 <p>
519 We have already learned one way to add atoms: double-clicking on the selected part of the molecule (or on the black area where nothing is present), and type-in the formula. Actually, this is the most convenient way to add atoms in Molby. However, there are also other ways to add atoms.
520 </p>
521 <p>
522 Look at our familiar toluene molecule. Suppose we want to convert it to indane.
523 </p>
524 <p><img src="../etc/indane.png" /> indane</p>
525 <p>
526 Rotate the molecule so that its orientation matches the chemical structure. We will start from C3, add two carbons, and then close the ring.
527 </p>
528 <p><img src="../etc/edit_09.png" /></p>
529 <p>
530 Press the "Erase" button above the black area. Click on the "H3" hydrogen. The hydrogen atom and the bond between C3 and H3 disappear.
531 </p>
532 <p><img src="../etc/edit_10.png" /></p>
533 <p>
534 Press the "Bond" button. Drag from the C3 atom to the right-bottom, and release the mouse button. A new atom and a bond to C3 are created. Drag from the new atom to the right-up, and another atom and bond are created.
535 </p>
536 <p><img src="../etc/edit_11.png" /> <img src="../etc/edit_12.png" /></p>
537 <p>
538 Press the "Erase" button again, and erase one hydrogen from the methyl group. Press the "Select" button, select the benzene-methylene bond, and rotate the methylene group as appropriate for the five-membered ring, by use of the left rotation bar.
539 </p>
540 <p><img src="../etc/edit_13.png" /> <img src="../etc/edit_14.png" /></p>
541 <p>
542 Now you can close the ring. Press the "Bond" button, and drag from the methylene carbon. When the mouse cursor comes close enough to the target carbon, the new atom will snap to the target and make a new bond. Then release the mouse button.
543 </p>
544 <p><img src="../etc/edit_15.png" /></p>
545 <p>
546 Finally, you want to add hydrogens to the newly created carbons. Press the "Select" button, and select these two carbons. Go to the "Edit" menu, and select the "Add Hydrogen" -&gt; "Tetrahedral sp3" menu command.
547 </p>
548 <p><img src="../etc/edit_16.png" /></p>
549 <p>
550 Here is the result.
551 </p>
552 <p><img src="../etc/edit_17.png" /></p>
553 <p class="note">
554 A similar result can be achieved by selecting the hydrogen ortho to the methyl group, double-click it, type "CH2CH3" in, erase one hydrogen atom from each of the methyl groups, and make a bond. This is better because the newly created methylenes have reasonable bond lengths and angles as methylene groups. The above example is just for explanation of the editing features.
555 </p>
556 </div>
557 <div class="contents" lang="ja">
558 <h1>第二段階:分子を編集する</h1>
559 <h2>1. 置換基をつける</h2>
560 <p>
561 ベンゼン分子があり、これにメチル基をつけてトルエンを作りたいとします。
562 </p>
563 <p>
564 "Select"ボタンを押して、編集エリアの原子や結合がないところをクリックします。選択が解除され、分子の表示が赤から原子ごとの色に変わります。
565 </p>
566 <p><img src="../etc/edit_01.png" /></p>
567 <p>
568 水素原子の一つを選択します。やり方は二つあります。選択したい原子をクリックするか、またはドラッグで現れる四角い領域の中の原子を選択します。
569 </p>
570 <p><img src="../etc/edit_02.png" /> <img src="../etc/edit_03.png" /></p>
571 <p>
572 水素原子の上でダブルクリックします。このとき、選択部分の上でダブルクリックするように注意してください。"Enter formula"というダイアログが出てきます。"CH3"と入力し、"OK"を押します。
573 </p>
574 <p><img src="../etc/edit_04.png" /></p>
575 <p>
576 トルエンができました。
577 </p>
578 <p><img src="../etc/edit_05.png" /></p>
579 <p>
580 ファイルに保存しておきたい時は、通常通り File メニューから "Save as..." を選び、ファイルフォーマットを選び、ファイル名をタイプして "Save" を押します。
581 </p>
582 <p>
583 Molby の標準ファイルフォーマットは "mbsf" (<u>M</u>ol<u>b</u>y <u>S</u>tructure <u>F</u>ile) です。Mbsf フォーマットは独自のもので、既存の化学ファイルフォーマットとは互換性がありません。しかし、mbsfはテキストファイルであり、比較的コンパクトで、読みやすいものです。他のフォーマットで保存する積極的な理由がない場合は、"mbsf"フォーマットで保存しておくことをおすすめします。
584 </p>
585
586 <h2>2. 分子の一部を操作する</h2>
587 <p>
588 分子を組み立てたら、その一部を動かしたくなることがあります。ここでは、そのやり方の例を示します。
589 </p>
590 <p>
591 トルエンのメチル基を選択します<span class="note">(コツ:シフトキーを押しながらクリックすると、現在の選択範囲に原子を付け加えることができます)</span>。左の回転バー(前ページで③と書かれていたもの)でマウスボタンを押し、上下にドラッグしてください。メチル基が右左に回転するのがわかります。
592 </p>
593 <p><img src="../etc/edit_06.png" /></p>
594 <p>
595 同じ操作は、結合を1つ選択して左の回転バーをドラッグしてもできます。この場合、メチル基を固定してベンゼン環の方を回すこともできます。ドラッグの時にOptionキー(Mac)、Altキー(Win)を押してください。
596 </p>
597 <p><img src="../etc/edit_07.png" /></p>
598 <p>
599 選択した原子をドラッグすると平行移動できます。化学的に不自然な構造になりますので、注意が必要です。
600 </p>
601 <p><img src="../etc/edit_08.png" /></p>
602 <h2>3. 原子を追加する・削除する</h2>
603 <p>
604 原子を追加する方法はすでに一つ説明しました。選択部分または編集エリアの何もないところをダブルクリックして、構造式をタイプする方法です。実際、Molbyで原子を追加するにはこれが最も便利です。しかし、他の方法もありますので、それを紹介します。
605 </p>
606 <p>
607 先ほどのトルエン分子を使います。これをインダンに変えたいとします。
608 </p>
609 <p><img src="../etc/indane.png" /> インダン</p>
610 <p>
611 分子を回転させて、化学構造式と同じ向きになるようにします。C3から始めて、炭素原子を2つ追加し、環を閉じることにします。
612 </p>
613 <p><img src="../etc/edit_09.png" /></p>
614 <p>
615 編集エリアの上の"Erase"ボタンを押します。"H3"水素をクリックします。この水素原子と、C3-H3の結合が消えます。
616 </p>
617 <p><img src="../etc/edit_10.png" /></p>
618 <p>
619 "Bond"ボタンを押します。C3原子から右下にドラッグし、マウスボタンを離します。新しい原子と、その原子とC3の間の結合が新しく作られます。新しい原子から右上にドラッグすると、もう一つの原子と結合が作られます。
620 </p>
621 <p><img src="../etc/edit_11.png" /> <img src="../etc/edit_12.png" /></p>
622 <p>
623 "Erase"ボタンをもう一度押して、メチル基の原子を一つ消します。"Select"ボタンを押して、ベンゼン環とメチレン炭素(今水素原子を一つ消したところ)の間の結合を選択します。左の回転バーを使って、五員環に適切な向きになるようにメチレン基を回転させます。
624 </p>
625 <p><img src="../etc/edit_13.png" /> <img src="../etc/edit_14.png" /></p>
626 <p>
627 環を閉じます。"Bond"ボタンを押し、メチレン炭素原子から右下の炭素原子へドラッグします。マウスカーソルが目標の炭素原子に近づくと、ドラッグしてできた結合が炭素原子にくっつきます。ここでマウスボタンを離します。
628 </p>
629 <p><img src="../etc/edit_15.png" /></p>
630 <p>
631 最後に、新しく作った二つの炭素原子に水素原子を付加します。"Select"ボタンを押して、マウスを使って二つの炭素原子を選択します。"Edit"メニューから、"Add Hydrogen"-&gt;"Tetrahedral sp3"コマンドを実行します。
632 </p>
633 <p><img src="../etc/edit_16.png" /></p>
634 <p>
635 結果はこのようになります。
636 </p>
637 <p><img src="../etc/edit_17.png" /></p>
638 <p class="note">
639 トルエンからインダンは次のような操作でも作ることができます。メチル基のオルト位の水素原子を選択、ダブルクリック、ダイアログが出たら"CH2CH3"と入力、二つのメチル基からそれぞれ水素原子を一つ削除、結合回転で向きを調整、結合を作成。この方法の方が、新しく作ったメチレン基の結合距離・結合角が正しくなるため、よりよい結果になります。上の例は、編集操作の説明のためのものと考えてください。
640 </p>
641 </div>
642 <link id="#navigation" />
643 </div>
644
645 <div file="cut_copy_paste.html">
646 <link rel="Up" href="tutorials.html" />
647 <link rel="Prev" href="editing.html" />
648 <link id="#header" />
649 <div class="contents" lang="en">
650 <h1>Step Three: Edit a Molecule: Cut/Copy/Paste</h1>
651 <p>
652 Like any other decent "editing" applications, Molby has a capability of cut/copy/paste by use of a clipboard. These functions (especially copy and paste) are also quite useful for building complex molecules.
653 </p>
654 <p>
655 We start from the toluene molecule again. Select the methyl group and do copy.
656 </p>
657 <p><img src="../etc/copy_01.png" /></p>
658 <p>
659 Unselect the methyl group, and do paste. Another methyl group appears, with no connection to the existing atoms. This is how "paste" works when nothing is selected beforehand.
660 </p>
661 <p><img src="../etc/copy_02.png" /></p>
662 <p>
663 Now we will see what happens when something is selected before pasting. As described above, start with the toluene molecule, select the methyl group, and copy it. Unselect the methyl group, and this time select the hydrogen atom that is "ortho" to the methyl group.
664 </p>
665 <p><img src="../etc/copy_03.png" /></p>
666 <p>
667 Do paste. The selected hydrogen atom is replaced with the pasted methyl group. Note that a new bond is created between the pasted methyl carbon and the ortho carbon, with an acceptable bond length and angles. 
668 </p>
669 <p class="note">
670 The dihedral angle may not be acceptable. In that case, you can rotate the pasted fragment by use of the left rotation bar until the dihedral angle looks good.
671 </p>
672 <p><img src="../etc/copy_04.png" /></p>
673 <p>
674 This "select and paste" technique is very useful for building large molecules. Suppose we want to build an oligobenzamide.
675 </p>
676 <p><img src="../etc/copy_05.png" /></p>
677 <p>
678 Create a "monomer", i.e. N-methyl-4-acetamidobenzamide. This is done by (1) create a benzene, (2) select H1, double-click, and enter "CONHCH3", (3) select H4, double-click, and enter "NHCOCH3". After entering each formula, you need to rotate the fragment to make the dihedral angle appropriate.
679 </p>
680 <p><img src="../etc/copy_06.png" /></p>
681 <p>
682 Select the whole molecule except for the COCH3 group at the left. Do copy.
683 </p>
684 <p><img src="../etc/copy_07.png" /></p>
685 <p>
686 Select the NHCH3 group at the right. Do paste.
687 </p>
688 <p><img src="../etc/copy_08.png" /></p>
689 <p>
690 A new amide bond is created and the dimer is formed.
691 </p>
692 <p><img src="../etc/copy_09.png" /></p>
693 <p>
694 Select "Fit to Screen" from the "Show" menu, to make the whole molecule visible.
695 </p>
696 <p><img src="../etc/copy_10.png" /></p>
697 <p>
698 Repeat these procedures to make the tetramer.
699 </p>
700 <p><img src="../etc/copy_11.png" /></p>
701 <p><img src="../etc/copy_12.png" /></p>
702 <p><img src="../etc/copy_13.png" /></p>
703 <p><img src="../etc/copy_14.png" /></p>
704 <p>
705 Make one more iteration to make the octamer.
706 </p>
707 <p><img src="../etc/copy_15.png" /></p>
708 </div>
709 <div class="contents" lang="ja">
710 <h1>第三段階:分子を編集する:カット・コピー・ペースト</h1>
711 <p>
712 他のアプリケーションと同様に、Molby もクリップボードを使ってカット・コピー・ペーストを行う機能があります。これらの機能、特にコピー・ペーストは複雑な分子を作るときにたいへん有用です。
713 </p>
714 <p>
715 ふたたびトルエン分子から始めます。メチル基を選択して、コピーします。
716 </p>
717 <p><img src="../etc/copy_01.png" /></p>
718 <p>
719 メチル基の選択を解除して、ペーストを実行します。他の原子と結合していないメチル基がもう一つ現れます。原子が選択されていない状態で「ペースト」すると、このような動作になります。
720 </p>
721 <p><img src="../etc/copy_02.png" /></p>
722 <p>
723 今度は、ペーストする前に原子が選択されているときにどうなるかを見てみます。上と同じように、トルエンから始めて、メチル基を選択して、コピーします。メチル基の選択を解除して、今度はメチル基のオルト位の水素原子を選択します。
724 </p>
725 <p><img src="../etc/copy_03.png" /></p>
726 <p>
727 ペーストを実行します。選択された水素原子がメチル基に置き換わります。オルト位の炭素とメチル基の間に新しい結合ができ、その長さと結合角が適切なものになっていることがわかります。
728 </p>
729 <p class="note">
730 二面角は適切でないこともあります。その場合は、ペーストされたグループを左の回転バーを使って回転させて、適切な二面角にします。
731 </p>
732 <p><img src="../etc/copy_04.png" /></p>
733 <p>
734 この「選択してペースト」のテクニックは、大きな分子を作るときにたいへん役に立ちます。たとえば、オリゴベンズアミドを作りたいとします。
735 </p>
736 <p><img src="../etc/copy_05.png" /></p>
737 <p>
738 まず、「モノマー」となる N-メチル-4-アセトアミドベンズアミドを作ります。次のようにします:(1) ベンゼンを作る、(2) H1 を選択してダブルクリックし、「CONHCH3」とタイプする、(3) H4 を選択してダブルクリックし、「NHCOCH3」とタイプする。化学式をタイプしたあとは、作成したフラグメントを回転させて二面角を調整しておきます。
739 </p>
740 <p><img src="../etc/copy_06.png" /></p>
741 <p>
742 左端の COCH3 以外全部を選択し、コピーします。
743 </p>
744 <p><img src="../etc/copy_07.png" /></p>
745 <p>
746 右端の NHCH3 を選択し、「ペースト」を実行します。
747 </p>
748 <p><img src="../etc/copy_08.png" /></p>
749 <p>
750 新しくアミド結合が作られ、二量体ができます。
751 </p>
752 <p><img src="../etc/copy_09.png" /></p>
753 <p>
754 "Show" メニューから "Fit to Screen" を選び、分子全体が見えるようにします。
755 </p>
756 <p><img src="../etc/copy_10.png" /></p>
757 <p>
758 この操作を繰り返して、四量体を作ります。
759 </p>
760 <p><img src="../etc/copy_11.png" /></p>
761 <p><img src="../etc/copy_12.png" /></p>
762 <p><img src="../etc/copy_13.png" /></p>
763 <p><img src="../etc/copy_14.png" /></p>
764 <p>
765 もう一度繰り返して、八量体を作ります。
766 </p>
767 <p><img src="../etc/copy_15.png" /></p>
768 </div>
769 <link id="#navigation" />
770 </div>
771
772 <div file="ring_fusion.html">
773 <link rel="Up" href="tutorials.html" />
774 <link rel="Prev" href="cut_copy_paste.html" />
775 <link id="#header" />
776 <div class="contents" lang="en">
777 <h1>Step Four: Ring Fusion</h1>
778 <h2>1. Ring fusion by double-click and type-in</h2>
779 <p>
780 Molby has a capability to create a fused ring structure. As an example, here is presented yet another method to make indane. This time, we start from a benzene.
781 </p>
782 <p><img src="../etc/ring_01.png" /></p>
783 <p>
784 Choose "select" mode, and select C1 and C2 by clicking on the C1-C2 bond.
785 </p>
786 <p><img src="../etc/ring_02.png" /></p>
787 <p>
788 Double-click on the selection, and enter "cyclopentane" in the dialog box.
789 </p>
790 <p><img src="../etc/ring_03.png" /></p>
791 <p>
792 After pressing "OK", you will see a five-membered ring fused to the benzene ring.
793 </p>
794 <p><img src="../etc/ring_04.png" /></p>
795 <p>
796 Ring fusion also works when three or more atoms are selected in the original structure. For example, select the consecutive three carbons in indane as follows.
797 </p>
798 <p><img src="../etc/ring_05.png" /></p>
799 <p>
800 Double-click on the selection, and enter "C6H6" (or "benzene").
801 </p>
802 <p><img src="../etc/ring_06.png" /></p>
803 <p>
804 Now we have acenaphthene...almost.
805 </p>
806 <p><img src="../etc/ring_07.png" /></p>
807 <p>
808 As shown in the above figure, there is an extra, leftover hydrogen atom on one bridgehead carbon. After all, Molby is not so smart --- it just removes one hydrogen from each terminal carbon atoms in the selection, and connect a portion of the fusing fragment ("benzene" in this case) so that the newly created ring has the same number of atoms. Consequently, the stereochemistry may become strange when sp3 carbons are present either in the original structure or in the fusing fragment. You may need to remove/append hydrogen atoms and clean up structures (see <a href="mm_minimize.html">"Energy Minimization"</a> for detail).
809 </p>
810 <h2>2. Ring fusion by copy-and-paste</h2>
811 <p>
812 There is another way to make a ring fused structure, which includes copy and paste. Starting again from a benzene.
813 </p>
814 <p><img src="../etc/ring_08.png" /></p>
815 <p>
816 Open the "File" menu, and select "Open Predefined" &rarr; "Alicyclic" &rarr; "cyclopentane".
817 </p>
818 <p><img src="../etc/ring_09.png" /></p>
819 <p>
820 A new window named "*cyclopentane*" opens with one cyclopentane molecule. Select a portion containing three CH2 groups, and copy it by command-C or ctrl-C.
821 </p>
822 <p><img src="../etc/ring_10.png" /></p>
823 <p>
824 Return to the benzene molecule again, and this time select H1 and H2 (not C1 and C2).
825 </p>
826 <p><img src="../etc/ring_11.png" /></p>
827 <p>
828 Do paste by command-V or ctrl-V. You now get a indane molecule.
829 </p>
830 <p><img src="../etc/ring_12.png" /></p>
831 <p>
832 This "copy-and-paste" actually works in a similar way to previously described example (see <a href="cut-copy-paste.html">"Cut/Copy/Paste"</a>). When both the current selection and the fragment in the pasteboard have two terminals, they are connected and ring fusion takes place. This method of ring fusion is slightly more complicated than the "double-click and type-in" method, but it may be easier to understand.
833 </p>
834 </div>
835 <div class="contents" lang="ja">
836 <h1>第四段階:縮環構造の作成</h1>
837 <h2>1. ダブルクリック/キー入力による縮環</h2>
838 <p>
839 Molby は縮環構造を作るための機能を持っています。例として、インダンを作るもう一つの方法を紹介します。今回は、ベンゼンから始めます。
840 </p>
841 <p><img src="../etc/ring_01.png" /></p>
842 <p>
843 "Select" モードにして、C1-C2 結合をクリックして C1 と C2 を選択します。
844 </p>
845 <p><img src="../etc/ring_02.png" /></p>
846 <p>
847 選択部分をダブルクリックして、ダイアログボックスに "cyclopentane" と入力します。
848 </p>
849 <p><img src="../etc/ring_03.png" /></p>
850 <p>
851 "OK" を押すと、5員環がベンゼン環に縮環します。
852 </p>
853 <p><img src="../etc/ring_04.png" /></p>
854 <p>
855 選択部分が3個以上の原子を含んでいても、縮環は可能です。例えば、インダンで図のように3つの連続した炭素原子を選択してみます。
856 </p>
857 <p><img src="../etc/ring_05.png" /></p>
858 <p>
859 選択部分をダブルクリックして、"C6H6"(または "benzene")と入力します。
860 </p>
861 <p><img src="../etc/ring_06.png" /></p>
862 <p>
863 そうすると、アセナフテンができます...だいたい。
864 </p>
865 <p><img src="../etc/ring_07.png" /></p>
866 <p>
867 上の図に示したように、橋頭位の炭素に1つ余分な水素原子が残ってしまいます。実のところ、Molby はあんまり賢くありません。選択部分の両端の原子から水素原子を1つずつ取り除いて、縮環する分子(この場合はベンゼン)の一部をかわりに結合して、生成する環の原子数が一致するようにしているだけです。このため、元の選択部分または縮環する分子が sp3 炭素を含んでいると、立体化学が変になることがあります。水素原子を除いたり付け加えたりして、さらに構造を最適化する必要があるでしょう(詳しくは「<a href="mm_minimize.html">エネルギー最小化</a>」を見てください)。
868 </p>
869 <h2>2. コピー/ペーストによる縮環</h2>
870 <p>
871 縮環構造を作るには、コピー/ペーストを使ったもう一つの方法があります。またベンゼンから始めましょう。
872 </p>
873 <p><img src="../etc/ring_08.png" /></p>
874 <p>
875 "File" メニューを開き、"Open Predefined" &rarr; "Alicyclic" &rarr; "cyclopentane" を選んでください。
876 </p>
877 <p><img src="../etc/ring_09.png" /></p>
878 <p>
879 "*cyclopentane*"という名前の新しいウィンドウが開き、シクロペンタン分子が入っています。3つのメチレン基を選択して、コマンド-C またはコントロール-C でコピーしてください。
880 </p>
881 <p><img src="../etc/ring_10.png" /></p>
882 <p>
883 ベンゼン分子に戻って、今度は H1 と H2(C1 と C2 ではなく)を選択してください。
884 </p>
885 <p><img src="../etc/ring_11.png" /></p>
886 <p>
887 コマンド-V またはコントロール-V でペーストしてください。インダンができます。
888 </p>
889 <p><img src="../etc/ring_12.png" /></p>
890 <p>
891 この「コピー/ペースト」は、実は前に説明したのと (<a href="cut-copy-paste.html">カット/コピー/ペースト</a>) 同じように機能しています。現在の選択部分とクリップボードの内容がともに「2つの末端」を持っているとき、末端同士がつなぎあわされ、縮環したように見えるのです。この方法による縮環は「ダブルクリック/入力」の方法よりも少し複雑ですが、何が起きているかはこちらの方が理解しやすいかもしれません。
892 </p>
893 </div>
894 <link id="#navigation" />
895 </div>
896
897 <div file="proptable.html">
898 <link rel="Up" href="tutorials.html" />
899 <link rel="Prev" href="ring_fusion.html" />
900 <link id="#header" />
901 <div class="contents" lang="en">
902 <h1>Step Five: Edit a Molecule: Using a Property Table</h1>
903 <h2>1. The Property Table of a Molecule</h2>
904 <p>
905 A molecule has many properties. It has a set of atoms and bonds. An atom has a name, an atom type, an element, a weight (which can be derived from the element), a charge, coordinates, and so on. According to the custom in the biomolecular modeling, atoms are grouped in "residues." It also has a set of parameters used in molecular mechanics. Molby also has a limited support for quantum chemical calculations. In relation to that, a molecule in Molby can retain extra information such as MO coefficients.
906 </p>
907 <p>
908 Many of these information are accessible via the <span class="italic">property table</span>. The table is on the left side of the model window.
909 </p>
910 <p><img src="../etc/table_01.png" /></p>
911 <p>
912 The table now shows the properties of each atom, namely its name, type, element, "residue" name and index, coordinates and partial charge. The property can be edited by double-clicking on the text.
913 </p>
914 <p><img src="../etc/table_02.png" /></p>
915 <p>
916 When return (enter) or tab key is pressed, the edited value is finalized, and editing will continue on another cell. Pressing return, shift-return, tab, or shift-tab should cause editing of the bottom, above, right, or left cell, respectively. If you want to finish editing, use option- (or alt-) return key combination.
917 </p>
918 <p>
919 Several points are worth mentioning here.
920 </p>
921 <p>
922 (1) The atom index (the leftmost column) cannot be edited. If you want to change the order of the atoms, try using a "drag-and-drop" feature, as shown in the figure below.
923 </p>
924 <p><img src="../etc/table_03.png" />
925 <img src="../etc/table_04.png" /></p>
926 <p>
927 (2) The residue column shows the residue name and index separated by a period. Manual editing of this cell may lead to a surprising result. For example, if you change the residue name of atom 0 from "RES" to "XXX", all atoms having residue index "1" will also have the new residue name "XXX".
928 </p>
929 <p><img src="../etc/table_05.png" />
930 <img src="../etc/table_06.png" /></p>
931 <p>
932 This behavior is based on the principle that all residue names and indices should be consistent, <span class="italic">i.e.</span> the atoms having the same residue index should have the same residue name. This is sometimes convenient, but in many cases it causes confusion.
933 </p>
934 <p>
935 A more recommended way to change the residue name and index is to use the menu command "Assign Residue...", in the "Script" menu, after selecting atoms you want to assign one residue name and index.
936 </p>
937 <p>
938 <img src="../etc/table_07.png" />
939 &nbsp;&nbsp;&nbsp;&nbsp;
940 <img src="../etc/table_08.png" />
941 </p>
942 <p>
943 <img src="../etc/table_09.png" />
944 </p>
945
946 <h2>2. The Bond/Angle/Dihedral/Improper Table</h2>
947 <p>
948 The property table can also show other information. The type of information can be selected at the popup menu.
949 </p>
950 <p><img src="../etc/table_10.png" /></p>
951 <p>
952 The bond, angle, dihedral, and improper tables show the indices, names, and types of the constituent atoms. In addition, the quantities (bond lengths, angles, etc.) and the molecular mechanics parameters (only after MM/MD calculation is performed) are also shown.
953 </p>
954 <p><img src="../etc/table_11.png" /></p>
955 <p>
956 The bonds, angles, etc. are not editable in the property table. At present, the only way to create/delete bonds from GUI is to use the mouse operation "Bond" or "Erase".
957 </p>
958
959 <h2>3. The Parameter Table</h2>
960 <p>
961 The parameter table shows the molecular mechanics parameters in one table.
962 </p>
963 <p><img src="../etc/table_12.png" /></p>
964 <p>
965 The parameters are grouped in several classes, namely "VDWs", "Bonds", "Angles", "Dihedrals", "Impropers", and "VDW Pairs".
966 </p>
967 <p>
968 The "VDWs" parameters are for the van der Waals nonbonding interaction, described by "eps" (the  energy at the potential minimum in kcal/mol), "r" (the van der Waals radius in &Aring;, which is half of the interatomic distance at the equilibrium state), "eps14", "r14" (eps and r for the pair of atoms separated by exactly three bonds. In many applications, the same parameters with the ordinary pair are used with a specific factor multiplied), "atomNo" (the atomic number), "weight" (the atomic weight). The last two are usually overridden by the atom parameters.
969 </p>
970 <p>
971 The "Bonds" parameters consist of "k" (the force constant in kcal/mol/&Aring;<sup>2</sup>) and "r0" (the equilibrium bond length). The "Angles" parameters consist of "k" (the force constant in kcal/mol/radian<sup>2</sup>) and "a0" (the equilibrium bond angle). The "Dihedrals" and "Impropers" parameters consist of "k" (the force constant in kcal/mol/radian<sup>2</sup>), "period" (the periodicity), and "phi0" (the equilibrium torsion angle in degree). The "VDW Pairs" parameters are (rarely) used to describe pair-specific van der Waals interactions, and consist of "eps", "r", "eps14", and "r14".
972 </p>
973 <p>
974 There is another important property for each parameter, that is, whether the parameter is taken from the "global" source (i.e. not specific to this molecule), or it is "local" (specific to this molecule), or "undefined". This property is shown by the color of the row. The global parameters are shown in white cells, the local ones in pale yellow, and the undefined ones in red.
975 </p>
976 <p><img src="../etc/table_13.png" /></p>
977 <p>
978 You can edit the parameters (although you need to be familiar with MM parameters and to know what you are doing!), but only if they are "local" or "undefined" parameters. The "global" parameters cannot be edited because it may be also used in other molecules, where the edited parameters may not be appropriate. If you want to modify some parameters but they are "global", then you can make them "local" by copying the parameters and the pasting.
979 </p>
980 <p><img src="../etc/table_14.png" /></p>
981 <p>
982 Another way to create a "local" parameter is to use the "Create New Parameter" menu command in the Edit menu. You can choose the parameter type in the submenu.
983 </p>
984 <p><img src="../etc/table_15.png" />
985 <img src="../etc/table_16.png" /></p>
986 <p>
987 If some parameters are not to be used for calculation, you can "cut" the parameters from the table. This feature is useful when you have many duplicated parameters having different force constants. (In actual calculation, the parameter appearing later in the table will be used.)
988 </p>
989
990 </div>
991 <div class="contents" lang="ja">
992 <h1>第五段階:分子を編集する:属性テーブルを使う</h1>
993 <h2>1. 分子の属性テーブル</h2>
994 <p>
995 分子はいろいろな属性を持っています。まず原子と結合があります。原子は名前、原子タイプ、元素、原子量(元素が決まれば決まる)、電荷、座標、など。また、生化学の習慣に従い、原子は「残基」でグループ化されています。分子はまた、分子力学のパラメータを持っています。Molby はまた量子化学計算も部分的にサポートします。それと関連して、分子に分子軌道係数などの情報を持たせることができます。
996 </p>
997 <p>
998 これらの情報の多くは「属性テーブル」で見ることができます。属性テーブルは、分子モデルのウィンドウの左半分にあります。
999 </p>
1000 <p><img src="../etc/table_01.png" /></p>
1001 <p>
1002 図では、テーブルは原子の属性を表示しています。名前、原子タイプ、元素、残基名と残基番号、座標、部分電荷です。これらの属性はダブルクリックして編集することができます。
1003 </p>
1004 <p><img src="../etc/table_02.png" /></p>
1005 <p>
1006 リターン(エンター)またはタブキーを押すと、編集した値は確定され、別のセルが編集状態になります。リターン、シフト+リターン、タブ、シフト+タブでそれぞれ下・上・右・左のセルに移動します。編集を終了したい時は、オプション(Windows では Alt)+リターンを使ってください。
1007 </p>
1008 <p>
1009 いくつか注意点があります。
1010 </p>
1011 <p>
1012 (1) 原子のインデックス(一番左の列)は編集できません。原子の順序を変えたい時は、下の図にあるように「ドラッグ・アンド・ドロップ」操作を使ってください。
1013 </p>
1014 <p><img src="../etc/table_03.png" />
1015 <img src="../etc/table_04.png" /></p>
1016 <p>
1017 (2) 残基の列には、残基の名前と残基番号がピリオドでつないで表示されています。このセルを編集すると、妙なことが起きて驚くかもしれません。たとえば、原子0の残基名を "RES" から "XXX" に変えると、残基番号が "1" であるすべての原子の残基名が "XXX" に変わります。
1018 </p>
1019 <p><img src="../etc/table_05.png" />
1020 <img src="../etc/table_06.png" /></p>
1021 <p>
1022 この挙動は、すべての残基名と残基番号は統一されていなければならない、という原理によります。つまり、同じ残基番号を持つ原子の残基名は同じでなければなりません。時にはこの挙動が便利に使えますが、混乱を招くことも多くあります。
1023 </p>
1024 <p>
1025 残基名と残基番号を変更するお勧めの方法は、変更したい原子を選択して "Script" メニューの "Assign Residue..." コマンドを使うことです。
1026 </p>
1027 <p>
1028 <img src="../etc/table_07.png" />
1029 &nbsp;&nbsp;&nbsp;&nbsp;
1030 <img src="../etc/table_08.png" />
1031 </p>
1032 <p>
1033 <img src="../etc/table_09.png" />
1034 </p>
1035
1036 <h2>2. Bond/Angle/Dihedral/Improper テーブル</h2>
1037 <p>
1038 属性テーブルは他の情報も表示することができます。テーブルの種類はポップアップメニューで選択できます。
1039 </p>
1040 <p><img src="../etc/table_10.png" /></p>
1041 <p>
1042 Bond, angle, dihedral, improper テーブルは、それぞれ結合・結合角・二面角・improper 二面角の構成原子のインデックス、名前、原子タイプを表示します。また、現在の値(結合長、角度、など)と、分子力学パラメータ(MM/MD 計算を行った直後に限られますが)も表示されます。
1043 </p>
1044 <p><img src="../etc/table_11.png" /></p>
1045 <p>
1046 このテーブルで、結合、結合角などを編集することはできません。現在、画面上のインターフェイスを使って結合を作ったり削除したりする唯一の方法は、"Bond", "Erase" のマウス操作を使うことです。
1047 </p>
1048
1049 <h2>3. パラメータテーブル</h2>
1050 <p>
1051 パラメータテーブルは、分子力学パラメータを表示します。
1052 </p>
1053 <p><img src="../etc/table_12.png" /></p>
1054 <p>
1055 パラメータはいくつかの種類にグループ分けされています。"VDWs", "Bonds", "Angles", "Dihedrals", "Impropers", そして "VDW Pairs" です。
1056 </p>
1057 <p>
1058 "VDWs" パラメータは、van der Waals 相互作用のためのもので、必要な値は "eps"(ポテンシャル極小値、kcal/mol)、"r"(van der Waals 半径、&Aring;。ポテンシャル極小状態での原子間距離の 1/2)、"eps14", "r14"(結合3つで隔てられた2つの原子間の eps と r。多くの分子力学パッケージでは、通常の原子間と同じパラメータに一定の係数をかけて用いることが多い)、"atomNo"(原子番号)、"weight"(原子量)。最後の2つは、ふつうは各原子のパラメータで上書きされます。
1059 </p>
1060 <p>
1061 "Bonds" パラメータは、"k"(結合の力の定数、kcal/mol/&Aring;<sup>2</sup>)、"r0"(平衡結合長さ、&Aring;)から成ります。"Angles" パラメータは、"k"(結合角の力の定数、kcal/mol/radian<sup>2</sup>)、"a0"(平衡結合角、degree)から成ります。'Dihedrals", "Impropers" パラメータは、"k"(力の定数、kcal/mol/radian<sup>2</sup>)、"period"(周期)、"phi0"(平衡二面角、degree)から成ります。"VDW Pairs" パラメータは滅多に使われませんが、ある原子の組み合わせに特有の van der Waals 相互作用を記述するもので、"eps", "r", "eps14", "r14" から成ります。
1062 </p>
1063 <p>
1064 それぞれのパラメータにはもう一つ重要な特性があります。それは、そのパラメータが「グローバル」なのか(つまり、他の分子にも使われる共通の値なのか)、または「ローカル」なのか(この分子に特有)、または「未定義」なのか、です。この特性は、テーブルの行の色で区別できます。「グローバル」なパラメータは白、「ローカル」はうすい黄色、「未定義」は赤色のセルです。
1065 </p>
1066 <p><img src="../etc/table_13.png" /></p>
1067 <p>
1068 パラメータは編集することができます(あなたが分子力学パラメータに詳しくて、何をしているかわかっていればの話だけど!)。ただし、パラメータが「ローカル」「未定義」の場合だけです。「グローバル」パラメータは、他の分子でも使われている可能性があるため、編集できません。「グローバル」なパラメータを編集したい時は、そのパラメータをコピー・ペーストすることで「ローカル」パラメータにすることができます。
1069 </p>
1070 <p><img src="../etc/table_14.png" /></p>
1071 <p>
1072 「ローカル」なパラメータを作るもう1つの方法は、"Edit" メニューの "Create New Parameter" コマンドを使うことです。パラメータの種類をサブメニューから選ぶことができます。
1073 </p>
1074 <p><img src="../etc/table_15.png" />
1075 <img src="../etc/table_16.png" /></p>
1076 <p>
1077 もしあるパラメータは計算に使わないという場合には、そのパラメータをテーブルから削除することができます。この機能は、同じパラメータで異なる値を持つものが複数ある場合に有用です。(実際の計算では、テーブルの後ろの方にあるパラメータが優先されます。)
1078 </p>
1079 </div>
1080 <link id="#navigation" />
1081 </div>
1082
1083 <div file="mm_minimize.html">
1084 <link rel="Up" href="tutorials.html" />
1085 <link rel="Prev" href="proptable.html" />
1086 <link id="#header" />
1087 <div class="contents" lang="en">
1088 <h1>Step Six: Energy Minimization by Molecular Mechanics</h1>
1089 <h2>1. About Molecular Mechanics Implementation in Molby</h2>
1090 <p>
1091 The molecular models built by hand generally include unnatural bond lengths, bond angles, van der Waals contacts, and so on. Molecular mechanics is a useful technique to remove such unnatural structures.
1092 </p>
1093 <p>
1094 Molby implements molecular mechanics calculation by use of basic force fields, including bond stretching, angle bending, dihedral rotation, improper torsions, van der Waals interaction, and electrostatic interaction. With the exception of the electrostatic interaction, the parameters are taken from the predefined table by looking up the "atom types" assigned to the atoms.
1095 </p>
1096 <p>
1097 By default, Molby uses <span class="italic">gaff</span> parameter set. Gaff, "General AMBER Force Field",   is a part of <a href="http://ambermd.org/">AMBER molecular dynamics package</a>; the force field parameters are made public domain by courtesy of the AMBER developers. Molby also includes <span class="italic">parm99</span> parameter set, another AMBER force field that is widely used for biomolecules.
1098 </p>
1099 <p>
1100 The troublesome part in using force fields is how to assign atom types. The AMBER developers provides a useful set of programs to take care of this problem. Thanks again to the AMBER developers, these programs, named AmberTools, are now made public (open source under GPLv2). Molby includes some of these programs, and calls and imports the results.
1101 </p>
1102 <p>
1103 Following are the original papers published by the AMBER team. Please be sure to refer to them in your publication when you use the AMBER parameters or AmberTools.
1104 </p>
1105 <ul>
1106 <li>Wang, J.; Wolf, R.M.; Caldwell, J.W.; Kollamn, P.A.; Case, D.A. Development and testing of a general Amber force field. <span class="italic">J. Comput. Chem.,</span> <span class="bold">2004,</span> <span class="italic">25,</span> 1157–1174.</li>
1107 <li>Wang, B.; Merz, K.M. Jr. A fast QM/MM (quantum mechanical/molecular mechanical) approach to calculate nuclear magnetic resonance chemical shifts for macromolecules. <span class="italic">J. Chem. Theory Comput.,</span> <span class="bold">2006,</span> <span class="italic">2,</span> 209–215. </li>
1108 </ul>
1109 <h2 id="minimize" name="minimize">2. Energy Minimization How-to</h2>
1110 <p>
1111 Now we try energy minimization. We use 2,2'-dimethoxybiphenyl as an example.
1112 </p>
1113 <p><img src="../etc/biphenyl.png" /> 2,2'-dimethoxybiphenyl</p>
1114 <p>
1115 Build this molecule. The easiest way is, (1) double-click the empty editing area and type "C6H5C6H5", (2) select one ortho hydrogen, double-click, and type "OCH3", (3) repeat (2) for another ortho hydrogen on the other ring.
1116 </p>
1117 <p><img src="../etc/minimize_01.png" /></p>
1118 <p>
1119 Open the "MM/MD" menu, and select "Guess MM/MD Parameters..." command.
1120 </p>
1121 <p><img src="../etc/minimize_02.png" /></p>
1122 <p>
1123 A dialog like below shows up. This is for execution of Antechamber on the current molecule. Turn off the "Calculate partial charges" checkbox, and turn on the "Guess atom types" checkbox. The "log" directory is used by AmberTools for storing intermediate files; the default value would be acceptable, but you can change it here.
1124 </p>
1125 <p><img src="../etc/minimize_03.png" /></p>
1126 <p>
1127 After pressing "OK", two dialog boxes appear in turn. They disappear so quickly that you may not recognize what they are saying; actually, the first one says "Running antechamber" and the second one "Running parmchk." These are programs included in AmberTools. In the present case, both programs complete successfully, and the following dialog appears.
1128 </p>
1129 <p><img src="../etc/minimize_04.png" /></p>
1130 <p>
1131 Press "OK", and you will return to the molecule window. Do you notice what change has been made? It is the atom types that are modified. Specifically, the types of the atoms 0 and 10 are changed from "ca" to "cp".
1132 </p>
1133 <p><img src="../etc/minimize_05.png" /></p>
1134 <p>
1135 If you are wondering what "ca" or "cp" mean, look at the global parameter table (MM/MD → View Global Parameters...), and find comment(s) in the "vdw" record.
1136 </p>
1137 <p><img src="../etc/minimize_06.png" /></p>
1138 <p>
1139 Return to the molecule, and select MM/MD → Minimize.
1140 </p>
1141 <p><img src="../etc/minimize_07.png" /></p>
1142 <p>
1143 A setting dialog opens. "Steps per frame" means the screen is updated every this number of steps. "Number of frames" means the maximum number of "frames" (i.e. screen updates) to calculate. If the minimization completes before this number of frames, the calculation will stop. The numbers 10 and 200 are reasonable choice in many cases.
1144 </p>
1145 <p><img src="../etc/minimize_08.png" /></p>
1146 <p>
1147 Press "OK", and minimization starts. As you expect, the dihedral angle between the two phenyl rings becomes large. The calculation will stop after 200 frames. You can see the number "200" at the right bottom of the window, and the slider at the bottom of the window is now active. Move the slider, and you can see how the molecular structure changed during the minimization.
1148 </p>
1149 <p><img src="../etc/minimize_09.png" /></p>
1150 <p>
1151 If you save this molecule at this stage, all the frames will be also saved (when you select the "mbsf" format), and the resulting file may be very large. If you do not want this, then you can remove all the frames by use of "Delete Frames..." command in the "Script" menu.
1152 </p>
1153 <p><img src="../etc/minimize_10.png" /></p>
1154 <p><img src="../etc/minimize_11.png" /></p>
1155 <h2 id="electrostatic" name="electrostatic">3. Handling electrostatic interaction</h2>
1156 <p>
1157 The above description is sufficient for initial cleanup of the molecular structure. However, we should go one further step to take electrostatic interaction into consideration. This is particularly important in molecules with polar functional groups (such as carbonyl).
1158 </p>
1159 <p>
1160 Continue our study on 2,2'-dimethoxybiphenyl. Open "MM/MD" → "Guess MM/MD Parameters...", and this time turn on the top checkbox. Also make sure the net molecular charge is correct.
1161 </p>
1162 <p><img src="../etc/minimize_12.png" /></p>
1163 <p>
1164 Press "OK", and calculation starts. This time the calculation should take much longer than before, because semi-empirical calculation is carried out for optimizing the structure and getting the partial charges.
1165 </p>
1166 <p><img src="../etc/minimize_13.png" /></p>
1167 <p>
1168 When calculation is done, the molecular structure may change, because structure optimization has been done by semi-empirical calculation. However, even more important is the "charge" values. You can see the charge values by scrolling the table to the right. By use of these "charge" values, interaction energies of the polar functional groups can be taken into account.
1169 </p>
1170 <p><img src="../etc/minimize_14.png" /></p>
1171 <p>
1172 Note that the atomic charges given in the above method are derived from semi-empirical quantum chemical calculations. On the other hand, it is generally considered that the charges derived from ab initio calculations are better. Molby does not have capability to perform ab initio calculations, but it can help creating necessary input files for external quantum chemical programs. This will be described <a href="qchem.html#gamess_resp">elsewhere</a> in this User's Manual.
1173 </p>
1174 </div>
1175
1176 <div class="contents" lang="ja">
1177 <h1>第六段階:分子力学計算によるエネルギー最小化</h1>
1178 <h2>1. Molby の分子力学計算について</h2>
1179 <p>
1180 手作業で作成した分子モデルは、不自然な結合長、結合角、van der Waals 接触などを含んでいます。このような不自然な構造を修正するには、分子力学のテクニックが便利です。
1181 </p>
1182 <p>
1183 Molby の分子力学計算は、基本的な分子力場(結合の伸縮、結合角のたわみ、二面角の回転、improper torsion、van der Waals 相互作用、静電相互作用)に基づいています。静電相互作用以外については、パラメータのセットが用意してあり、原子に与えられた「原子タイプ」から必要なパラメータを取り出して計算に使います。
1184 </p>
1185 <p>
1186 デフォルトでは、Molby は <span class="italic">gaff</span> パラメータセットを使います。Gaff は "General AMBER Force Field" の略で、<a href="http://ambermd.org/">AMBER 分子動力学パッケージ</a>の一部です。AMBER 開発者の好意により、分子力場パラメータはパブリックドメインとされています。なお、Molby は <span class="italic">parm99</span> パラメータセットも同梱しています。これも AMBER の分子力場であり、生体分子の計算に広く使われています。
1187 </p>
1188 <p>
1189 分子力場を使うときに厄介なのは、原子タイプをどうやって指定するかです。AMBER には、このための便利なプログラム AmberTools が含まれています。これもまた AMBER 開発者の好意により、AmberTools はフリーソフトウェア(GPLv2)として公開されています。Molby は AmberTools のプログラムの一部を同梱しています。
1190 </p>
1191 <p>
1192 以下の論文は AMBER 開発チームによるものです。AMBER パラメータや AmberTools プログラムの機能を使った場合は、発表論文にこれらの論文を引用してください。
1193 </p>
1194 <ul>
1195 <li>Wang, J.; Wolf, R.M.; Caldwell, J.W.; Kollamn, P.A.; Case, D.A. Development and testing of a general Amber force field. <span class="italic">J. Comput. Chem.,</span> <span class="bold">2004,</span> <span class="italic">25,</span> 1157–1174.</li>
1196 <li>Wang, B.; Merz, K.M. Jr. A fast QM/MM (quantum mechanical/molecular mechanical) approach to calculate nuclear magnetic resonance chemical shifts for macromolecules. <span class="italic">J. Chem. Theory Comput.,</span> <span class="bold">2006,</span> <span class="italic">2,</span> 209–215. </li>
1197 </ul>
1198 <h2 id="minimize" name="minimize">2. エネルギー最小化の方法</h2>
1199 <p>
1200 さて、エネルギー最小化をやってみましょう。例として 2,2'-ジメトキシビフェニルを使うことにします。
1201 </p>
1202 <p><img src="../etc/biphenyl.png" /> 2,2'-ジメトキシビフェニル</p>
1203 <p>
1204 この分子のモデルを作ってください。簡単なやり方は、(1) 空の編集エリアでダブルクリックして "C6H5C6H5" とタイプする。(2) オルト位の水素原子を1つ選択し、ダブルクリックして "OCH3" とタイプする。(3) もう1つの環のオルト位の水素原子について、(2) を繰り返す。
1205 </p>
1206 <p><img src="../etc/minimize_01.png" /></p>
1207 <p>
1208 "MM/MD"メニューを開き、"Guess MM/MD Parameters..." コマンドを実行します。
1209 </p>
1210 <p><img src="../etc/minimize_02.png" /></p>
1211 <p>
1212 下のようなダイアログが現れます。これは現在の分子に対して Antechamber を実行するためのものです。一番上のチェックボックス "Calculate partial charge" をオフ、その下の "Guess Atom Types" をオンにしてください。"Log" ディレクトリは、AmberTools のプログラムが中間ファイルを保存するのに使います。デフォルトの位置で問題はないでしょうが、変更してもかまいません。
1213 </p>
1214 <p><img src="../etc/minimize_03.png" /></p>
1215 <p>
1216 "OK"を押すと、2つのダイアログが順に現れます。すぐに消えてしまうので、何と書いてあるか読めないかも知れません。最初のものは "Running antechamber", 2つめのものは "Running parmchk" と書いてあります。これらは AmberTools に含まれているプログラムです。今の場合は、両方とも正しく実行され、次のダイアログが現れます。
1217 </p>
1218 <p><img src="../etc/minimize_04.png" /></p>
1219 <p>
1220 "OK"を押して、分子のウィンドウに戻ってください。何が変わったかわかるでしょうか? 変わったのは原子タイプです。具体的には、原子0と原子10のタイプが "ca" から "cp" に変わっています。
1221 </p>
1222 <p><img src="../etc/minimize_05.png" /></p>
1223 <p>
1224 "ca" や "cp" が何の意味か知りたければ、"MM/MD" メニューから "View Global Parameters..." を選んでみてください。Molby に同梱されているパラメータの一覧表が出てきます。"vdw" (van der Waals パラメータの意味ですが、原子タイプの定義も兼ねています)の中で "ca", "cp" を見つけて、表の右端にあるコメントを見てみてください。
1225 </p>
1226 <p><img src="../etc/minimize_06.png" /></p>
1227 <p>
1228 分子のウィンドウに戻り、"MM/MD" → "Minimize" を選んでください。
1229 </p>
1230 <p><img src="../etc/minimize_07.png" /></p>
1231 <p>
1232 設定ダイアログが開きます。"Steps per frame" は、構造最適化計算がこのステップ数進んだところで画面を更新する、という意味です。"Number of frames" は、この数だけ画面を更新したら計算を止める、という意味です。その前に構造最適化が終了すれば、その時点で計算は止まります。下の図にある 10, 200 を入れておけば、たいていの場合はよいでしょう。
1233 </p>
1234 <p><img src="../etc/minimize_08.png" /></p>
1235 <p>
1236 "OK" を押すと、構造最適化が始まります。この分子の場合、期待される通り、2つのベンゼン環の間の二面角がだんだん大きくなります。指定通り、200回画面が更新されると計算は止まります。ウィンドウの右下に "200" という数字があり、ウィンドウの下辺にあるスライダーが有効になっています。更新された画面は、それぞれ独立したフレームとして保存されており、このスライダーを動かすと、初期状態からどのように構造が変わって行くかを再現することができます。
1237 </p>
1238 <p><img src="../etc/minimize_09.png" /></p>
1239 <p>
1240 この時点で分子を "mbsf" フォーマットで保存すると、全部のフレームの情報が保存され、ファイルがとても大きくなります。これが好ましくない場合は、現在表示されている以外のフレームを削除することもできます。"Script" メニューから "Delete Frames..." コマンドを使ってください。
1241 </p>
1242 <p><img src="../etc/minimize_10.png" /></p>
1243 <p><img src="../etc/minimize_11.png" /></p>
1244 <h2 id="electrostatic" name="electrostatic">3. 静電相互作用の取り扱い</h2>
1245 <p>
1246 上の説明は、分子構造のひずみを取り除く最初の段階としては十分です。しかしながら、次の段階として、静電相互作用を考慮しなければなりません。特に、カルボニル基などの極性官能基が含まれている場合は、これは重要です。
1247 </p>
1248 <p>
1249 2,2'-ジメトキシビフェニルについて検討を続けましょう。"MM/MD" → "Guess MM/MD Parameters...", を開き、今度は一番上のチェックボックスをオンにします。そして、分子の総電荷が正しいことを確認してください。この場合は中性分子なので、"0" で結構です。
1250 </p>
1251 <p><img src="../etc/minimize_12.png" /></p>
1252 <p>
1253 "OK" を押すと、計算が始まります。今度は、前回よりもずっと長く計算時間がかかります。半経験的分子軌道法により、構造最適化と部分電荷の計算を行うからです。
1254 </p>
1255 <p><img src="../etc/minimize_13.png" /></p>
1256 <p>
1257 計算が終了すると、分子構造は少し変化することがあります。半経験的分子軌道計算で構造最適化が行われたからです。また、"charge" の値が設定されていることがわかります。テーブルを右にスクロールすると、与えられた電荷の値を見ることができます。この電荷の値を用いて静電相互作用の計算を行うことにより、極性官能基の相互作用エネルギーをより正しく見積もることができます。
1258 </p>
1259 <p><img src="../etc/minimize_14.png" /></p>
1260 <p>
1261 上の方法で計算した電荷は、半経験的分子軌道計算によるものです。一方、一般的には ab initio 計算で求めた電荷の方が良いと考えられています。Molby は ab initio 計算を行う機能を持っていませんが、外部の量子化学計算プログラムへの入力ファイルを作成する機能があります。これは、このマニュアルの<a href="qchem.html#gamess_resp">別のところ</a>で解説します。
1262 </p>
1263
1264 </div>
1265 <link id="#navigation" />
1266 </div>
1267
1268 <div file="md.html">
1269 <link rel="Up" href="tutorials.html" />
1270 <link rel="Prev" href="mm_minimize.html" />
1271 <link id="#header" />
1272 <div class="contents" lang="en">
1273 <h1>Step Seven: Molecular Dynamics (MD) Calculation</h1>
1274 <h2>1. MD Calculation within Molby</h2>
1275 <p>
1276 Molby implements molecular dynamics (MD) calculation which uses the same force fields as the energy minimization by molecular mechanics (MM). This implementation is suitable only for preliminary calculations (to check parameters quickly, etc.); for production runs, it is strongly recommended that you use one of the established software packages.
1277 </p>
1278 <p>
1279 An example of preliminary MD run is presented here. We use 2,2'-dimethoxybiphenyl again. In a similar way as in the <a href="mm_minimize.html">step six</a>, create a model and assign MM parameters (including the partial charges on the atoms).
1280 </p>
1281 <p><img src="../etc/md_01.png" /></p>
1282 <p>
1283 Select MM/MD &rarr; Molecular Dynamics. A setting dialog opens. Although this dialog resembles that in MM minimization, it shows different parameters that are relevant to the MD calculation.
1284 </p>
1285 <p><img src="../etc/md_02.png" /></p>
1286 <p>
1287 The "timestep" parameter defines the minimum time increment in solving the equation of motions. The "target temperature" defines the temperature of the system. Before running the MD calculation, all atoms are let to have random velocities with the Boltzmann distribution corresponding to the target temperature. In addition, the velocities are modified so that the temperature is kept constant. The "steps per frame" and "number of frames" parameters have the same meaning as in the MM minimization. The screenshot shows 10 as the "steps per frame"; this is an appropriate value for MM minimization, however for MD calculations a larger value would be more appropriate (like 100). 
1288 </p>
1289 <p>
1290 Pressing the "Advanced..." button opens another dialog with other parameters. The meanings of the parameters are described in the embedded Ruby document, in the <a href="molby_rb/MDArena.html">MDArena</a> page.
1291 </p>
1292 <p><img src="../etc/md_03.png" /></p>
1293 <p>
1294 Return to the original MD dialog (by pressing "Close" in the advanced settings dialog), and press "OK". The MD run starts, and new frames are accumulated. If you find something is wrong, or want to stop before getting the specified number of frames, you can stop the MD run by pressing Command-period (Mac) or Control-period (Windows).
1295 </p>
1296 <h2>2. Using Molby with AMBER: Creating Inputs and Importing Outputs</h2>
1297 <p>
1298 For production runs, you can create AMBER input files from Molby. More specifically, you can create "prmtop" and "inpcrd" files for the SANDER module.
1299 </p>
1300 <p class="note">
1301 <span class="italic">Note:</span> There is no guarantee that Molby creates the exactly same input as the official AMBER modeling tools, nor the generated files are valid inputs for the SANDER module. You may need to modify them by hand.
1302 </p>
1303 <p>
1304 To creat SANDER input files, select "Create SANDER input..." command in the "MM/MD" menu.
1305 </p>
1306 <p><img src="../etc/md_04.png" /></p>
1307 <p>
1308 You will be asked first for the file name for the "prmtop" file. Please be sure to add ".prmtop" extension. The other file, "inpcrd" file, is created as the same name with the ".prmtop" extension replaced by the ".inpcrd" extension.
1309 </p>
1310 <p><img src="../etc/md_05.png" /></p>
1311 <p>
1312 Subsequently, you will be asked to select one of the two versions of the prmtop files. The older one, "AMBER8/NAMD", allows you to use the output file by NAMD (see below).
1313 </p>
1314 <p><img src="../etc/md_06.png" /></p>
1315 <p>
1316 Now you can transfer your files to the workstation running SANDER. To perform the simulation, you still need to create the instruction file for SANDER, which you should already know if you are using AMBER.
1317 </p>
1318 <p>
1319 After the simulation is over, you can get the trajectory file ("mdcrd" file) back and import to Molby. Use "Import..." command in the "File" menu, select "AMBER mdcrd file (*.crd; *.mdcrd)", and specify the file.
1320 </p>
1321 <p><img src="../etc/md_07.png" /></p>
1322 <h2>3. Using Molby with NAMD: Creating Inputs and Importing Outputs</h2>
1323 <p>
1324 You can also use the NAMD software package for production run. NAMD is developed by the Theoretical Biophysics Group in the University of Illinois at Urbana-Champaign, and the official information is found at their web site (<a href="http://www.ks.uiuc.edu/Research/namd/">http://www.ks.uiuc.edu/Research/namd/</a>). NAMD can use the AMBER "prmtop" as the input, by use of the instruction <code>amber yes</code>. See NAMD Users' Guide for details.
1325 </p>
1326 <p>
1327 You can also import the NAMD output by importing the dcd file. The file format is also listed in the "Import..." file dialog.
1328 </p>
1329 <h2>4. Building Solvated Structures</h2>
1330 <p>
1331 When you want to perform MD simulations in explicit solvent, you need to build a box of solvent molecules around the target molecule. Molby can help creating solvated structures.
1332 </p>
1333 <p>
1334 To build a solvated structure, you need to open the file containing the predefined box of the desired solvent. The following solvent box is included in the Molby package, and can be accessed from "File" &rarr; "Open Predefined" &rarr; "Solvent boxes" submenu. The tip3box was taken from the AmberTool package, and other solvent boxes were taken from <a href="http://www.pharmacy.manchester.ac.uk/bryce/amber">Amber parameter database</a>.
1335 </p>
1336 <table border="1" cellspacing="0">
1337 <tr><th>name</th><th>solvent</th><th>reference</th></tr>
1338 <tr><td>tip3pbox</td>
1339 <td>water</td>
1340 <td>Jorgensen, W. L.; Chandrasekhar, J.; Madura, J.; Klein, M. L.<br />
1341 <i>J. Chem. Phys.</i> <b>1983,</b> <i>79,</i> 926.
1342 </td></tr>
1343 <tr><td>chcl3box</td>
1344 <td>chloroform</td>
1345 <td>Cieplak, P.; Caldwell, J. W.; Kollman, P. A.<br />
1346 <i>J. Comp. Chem.</i> <b>2001,</b> <i>22,</i> 1048.<br />
1347 </td></tr>
1348 <tr><td>dmsobox</td>
1349 <td>dimethylsulfoxide</td>
1350 <td>Fox, T.; Kollman, P. A.<br />
1351 <i>J. Phys. Chem. B</i> <b>1998,</b> <i>102,</i> 8070.
1352 </td></tr>
1353 <tr><td>meohbox</td>
1354 <td>methanol</td>
1355 <td>Caldwell, J. W.; Kollman, P. A.<br />
1356 <i>J. Phys. Chem.</i> <b>1995,</b> <i>99,</i> 6208.
1357 </td></tr>
1358 <tr><td>nmabox</td>
1359 <td>N-methylacetamide</td>
1360 <td>Caldwell, J. W.; Kollman, P. A.<br />
1361 <i>J. Phys. Chem.</i> <b>1995,</b> <i>99,</i> 6208.
1362 </td></tr>
1363 </table>
1364 <p><img src="../etc/md_08.png" /><img src="../etc/md_09.png" /></p>
1365 <p>
1366 While keeping the solvent box open, create or open the target (solute) molecule in a separate window. With this solute molecule in the front window, select "Solvate..." command in the "MM/MD" menu.
1367 </p>
1368 <p><img src="../etc/md_10.png" /></p>
1369 <p>
1370 A dialog box opens.
1371 </p>
1372 <p><img src="../etc/md_11.png" /></p>
1373 <p>
1374 In the popup menu "Choose solvent box:", you will find the solvent box you opened earlier. Note that this popup menu lists <span class="italic">all</span> open molecules that have the associated periodic box (or unit cell). This can lead to a confusing situation that, if you have another solvated structure also open, that structure will also be listed in this popup menu, because a solvated structure always have a periodic box. Therefore, please take care so that you choose the right solvent box.</p>
1375 <p class="note">
1376 If you open the solvent box from the "Open Predefined" menu, you can easily recognize it in the popup menu, because the name has asterisks at the beginning and the end, like "*CHCl3*".
1377 </p>
1378 <p>
1379 The "Box offset" parameters define the thickness of the solvent layer surrounding the solute molecule. More specifically, the periodic box of the solvated structure is determined as follows: the minimum cuboid that can surround the solute molecule is defined, and all the faces are offset by the "Box offset" distances to the outside direction. On the other hand, it is possible to define the size of the periodic box explicitly for any of the three (x, y, z) directions. If you wish to do this, give a negative number for that direction. (For example, if you want the periodic box to be 40 &Aring; in the x direction, give -40 as the first "Box offset" parameter.)
1380 </p>
1381 <p class="note">
1382 The size of the periodic box can be checked by selecting "Xtal" &rarr; "Unit Cell..." menu command, or in the property table (the "unit cell" property).
1383 </p>
1384 <p>
1385 The "Exclusion limit distance" defines the minimum allowed distance between the solvent and solute molecules. The solvent molecule is removed when it has atoms with smaller distances than this parameter from the solute molecule.
1386 </p>
1387
1388 </div>
1389 <div class="contents" lang="ja">
1390 <h1>第七段階:分子動力学計算</h1>
1391 <h2>1. Molby 組み込みの分子動力学 (MD) 計算</h2>
1392 <p>
1393 Molby は分子動力学 (MD) 計算を実装しています。これは分子力学によるエネルギー最小化と同じ分子力場を使います。この機能は、パラメータのチェックなどの予備的な計算に使うことを想定しています。本格的な計算には、実績のある他のソフトウェアパッケージを使うことを強くおすすめします。
1394 </p>
1395 <p>
1396 予備的な MD 計算の例を示します。また 2,2'-ジメトキシビフェニルを使います。<a href="mm_minimize.html">第六段階</a>と同様に、モデルを作成して分子力場パラメータを決定してください(原子上の部分電荷も)。
1397 </p>
1398 <p><img src="../etc/md_01.png" /></p>
1399 <p>
1400 MM/MD メニューの "Molecular Dynamics" を選ぶと、設定ダイアログが開きます。このダイアログは分子力場によるエネルギー最小化の時と似ていますが、MD 計算に使う他のパラメータを表示しています。
1401 </p>
1402 <p><img src="../etc/md_02.png" /></p>
1403 <p>
1404 "Timestep" パラメータは、運動方程式を解くときの最小時間刻みを表します。"Target temperature" は系の温度を表します。MD 計算が始まる際に、すべての原子はこの温度に対応するボルツマン分布に従ってランダムな速度を与えられます。さらに、MD 計算中は温度が一定に保たれるように速度が調整されます。"Steps per frame" と "number of frames" パラメータは分子力学によるエネルギー最小化の時と同じ意味を持ちます。このスクリーンショットでは "steps per frame" が 10 になっています。これはエネルギー最小化では適切な値ですが、分子動力学の場合はもう少し大きな値(たとえば 100)の方がより適切です。
1405 </p>
1406 <p>
1407 "Advanced..." ボタンを押すと、他のパラメータを持つ別のダイアログが開きます。これらのパラメータの意味は、内蔵 Ruby インタプリタのリファレンスで <a href="molby_rb/MDArena.html">MDArena</a> のページに書かれています。 
1408 </p>
1409 <p><img src="../etc/md_03.png" /></p>
1410 <p>
1411 元の MD 設定ダイアログに戻り(詳細設定ダイアログで "Close" ボタンを押す)、"OK" を押します。MD 計算が始まり、新しいフレームが追加されて行きます。何か問題があったり、指定したフレーム数よりも前に計算を止めたいときは、コマンド-ピリオド (Mac) かコントロール-ピリオド (Windows) を使ってください。
1412 </p>
1413 <h2>2. AMBER とともに使う:入力の作成と出力結果のインポート</h2>
1414 <p>
1415 本格的な計算を行うために、Molby で AMBER への入力ファイルを作成することができます。具体的には、SANDER モジュールの入力となる "prmtop" と "inpcrd" ファイルを作ることができます。
1416 </p>
1417 <p class="note">
1418 <span class="italic">注:</span> Molby が AMBER 付属のモデリングツールと同じ入力ファイルを作成する保証はありませんし、SANDER モジュールへの正しい入力になっている保証もありません。手作業で修正が必要な場合もあるかもしれません。
1419 </p>
1420 <p>
1421 SANDER の入力ファイルを作るには、"MM/MD" メニューから "Create SANDER input..." コマンドを選んでください。
1422 </p>
1423 <p><img src="../etc/md_04.png" /></p>
1424 <p>
1425 最初に "prmtop" ファイルの名前を聞かれます。必ず ".prmtop" 拡張子をつけるようにしてください。もう一つの "inpcrd" ファイルは、".prmtop" を ".inpcrd" に置き換えた名前で保存されます。
1426 </p>
1427 <p><img src="../etc/md_05.png" /></p>
1428 <p>
1429 次に、prmtop ファイルの2つのバージョンのうち1つを選ぶように促されます。古い方、"AMBER8/NAMD" を使えば、NAMD ソフトウェアパッケージ(下記参照)でも使える入力ファイルができます。
1430 </p>
1431 <p><img src="../etc/md_06.png" /></p>
1432 <p>
1433 これで、SANDER が走るワークステーションにファイルを転送することができます。シミュレーションを実行するためには、SANDER の命令ファイルを作らなければなりませんが、AMBER をお使いの方ならやり方はよくご存知でしょう。
1434 </p>
1435 <p>
1436 計算が終了したら、トラジェクトリファイル ("mdcrd" ファイル) を取得して、Molby にインポートすることができます。"File" メニューの "Import..." コマンドを選び、ファイルタイプとして "AMBER mdcrd file (*.crd; *.mdcrd)" を選んで、ファイルを読み込んでください。
1437 </p>
1438 <p><img src="../etc/md_07.png" /></p>
1439 <h2>3. NAMD とともに使う:入力の作成と出力結果のインポート</h2>
1440 <p>
1441 本格的な計算を行うために NAMD を使うこともできます。NAMD はイリノイ大学アーバナ・シャンペーン校の理論生物物理グループが開発したソフトウェアパッケージです。公式ウェブサイトは <a href="http://www.ks.uiuc.edu/Research/namd/">http://www.ks.uiuc.edu/Research/namd/</a> です。NAMD は AMBER の "prmtop" を入力として使うことができます(<code>amber yes</code> 命令を使う)。詳しくは NAMD のユーザーズガイドをご覧ください。
1442 </p>
1443 <p>
1444 NAMD の出力の dcd ファイルもインポートが可能です。"Import..." コマンドのファイルタイプで選択することができます。
1445 </p>
1446 <h2>4. 溶媒和構造の作成</h2>
1447 <p>
1448 明示的な溶媒中での MD シミュレーションを行うためには、目的分子の回りに溶媒分子の箱を作る必要があります。Molby でこのような溶媒和構造を作成することができます。
1449 </p>
1450 <p>
1451 溶媒和構造を作るためには、まず使用する溶媒の箱を読み込む必要があります。以下の溶媒の箱が Molby に同梱されており、"File" &rarr; "Open Predefined" &rarr; "Solvent boxes" サブメニューから選ぶことができます。Tip3box は AmberTool パッケージから得たものであり、他の溶媒箱は <a href="http://www.pharmacy.manchester.ac.uk/bryce/amber">Amber parameter database</a> で公開されているものです。
1452 </p>
1453 <table border="1" cellspacing="0">
1454 <tr><th>name</th><th>solvent</th><th>reference</th></tr>
1455 <tr><td>tip3pbox</td>
1456 <td>water</td>
1457 <td>Jorgensen, W. L.; Chandrasekhar, J.; Madura, J.; Klein, M. L.<br />
1458 <i>J. Chem. Phys.</i> <b>1983,</b> <i>79,</i> 926.
1459 </td></tr>
1460 <tr><td>chcl3box</td>
1461 <td>chloroform</td>
1462 <td>Cieplak, P.; Caldwell, J. W.; Kollman, P. A.<br />
1463 <i>J. Comp. Chem.</i> <b>2001,</b> <i>22,</i> 1048.<br />
1464 </td></tr>
1465 <tr><td>dmsobox</td>
1466 <td>dimethylsulfoxide</td>
1467 <td>Fox, T.; Kollman, P. A.<br />
1468 <i>J. Phys. Chem. B</i> <b>1998,</b> <i>102,</i> 8070.
1469 </td></tr>
1470 <tr><td>meohbox</td>
1471 <td>methanol</td>
1472 <td>Caldwell, J. W.; Kollman, P. A.<br />
1473 <i>J. Phys. Chem.</i> <b>1995,</b> <i>99,</i> 6208.
1474 </td></tr>
1475 <tr><td>nmabox</td>
1476 <td>N-methylacetamide</td>
1477 <td>Caldwell, J. W.; Kollman, P. A.<br />
1478 <i>J. Phys. Chem.</i> <b>1995,</b> <i>99,</i> 6208.
1479 </td></tr>
1480 </table>
1481 <p><img src="../etc/md_08.png" /><img src="../etc/md_09.png" /></p>
1482 <p>
1483 溶媒箱を開いたまま、目的とする分子(溶質)を新しいウィンドウで開くか作成します。溶質分子のウィンドウを最前面にした状態で、"MM/MD" メニューから "Solvate..." コマンドを選びます。
1484 </p>
1485 <p><img src="../etc/md_10.png" /></p>
1486 <p>
1487 ダイアログが開きます。
1488 </p>
1489 <p><img src="../etc/md_11.png" /></p>
1490 <p>
1491 ポップアップメニュー "Choose solvent box:" には、さきほど開いた溶媒箱がリストされているはずです。注意していただきたいのは、このポップアップメニューには周期境界(または単位格子)を持つすべての分子がリストされることです。このため、紛らわしいことに、別の溶媒和構造を同時に開いていると、その構造もこのポップアップメニューに登場してしまいます(溶媒和構造は必ず周期境界を持っていますから)。ですから、正しい溶媒箱を選ぶように十分に注意してください。
1492 </p>
1493 <p class="note">
1494 "Open Predefined" メニューから選んで開いた溶媒箱はすぐに区別できます。名前の前後に * がついているからです ("*CHCl3*" のように)。
1495 </p>
1496 <p>
1497 "Box offset" パラメータは、溶質分子の回りを囲む溶媒層の厚さを指定します。言い換えると、これから作成する溶媒和構造の周期境界は次のように決められます:まず溶質を囲む最小の直方体を算出し、それぞれの面を外側に向かって Box offsect パラメータ分だけ移動させます。一方、x, y, z のそれぞれの方向に対して、周期境界の大きさを決めたい場合もあります。このときは、その方向の Box offset パラメータに負の値を指定してください。(たとえば、x 方向の周期境界を大きさを 40 &Aring; にしたい時は、"Box offset" の最初のパラメータを -40 にしてください。)
1498 </p>
1499 <p class="note">
1500 周期境界の箱の大きさは、"Xtal" &rarr; "Define Unit Cell" メニューを選ぶと見ることができます。また、属性テーブルの "unit cell" でも見られます。</p>
1501 <p>
1502 "Exclusion limit distance" は、溶質分子と溶媒分子の原子間距離の最小値を定めます。溶媒分子のある原子が溶質分子からこの距離以内に近づいているとき、その溶媒分子は取り除かれます。
1503 </p>
1504 </div>
1505 <link id="#navigation" />
1506 </div>
1507
1508 <div file="coordination.html">
1509 <link rel="Up" href="tutorials.html" />
1510 <link rel="Prev" href="md.html" />
1511 <link id="#header" />
1512 <div class="contents" lang="en">
1513 <h1>Step Eight: MM/MD Calculation of Coordination Compounds</h1>
1514 <h2>1. Use of UFF (Universal Force Field) Parameters</h2>
1515 <p>
1516 Building molecular models of coordination compounds is often problematic. This is mainly due to the lack of appropriate MM parameters for metal atoms. One reasonable approach is to use UFF (universal force field) parameters developed by Rappé and coworkers (<i>J. Am. Chem. Soc.</i> <b>114</b>, 10024-10035 (1992)). Although estimation of the UFF parameters from the molecular structure is rather complicated, it can be automated by computer programs. In the following, you will see how Molby can help modeling of coordination compounds with the UFF parameters.
1517 </p>
1518 <p>
1519 Suppose we want to build a model of (terpy)PtCl, where terpy is 2,2':6',2"-terpyridine.
1520 </p>
1521 <p><img src="../etc/coord_01.png" /></p>
1522 <p>
1523 We need to build the molecular structure first. One approach is to build the organic part (terpy), and put metal atoms afterwards. Here, we will go through another route, namely start from the metal fragment and add ligands afterwards. In general, this approach should be more successful in building models of coordination compounds.
1524 </p>
1525 <p>
1526 Select "Open Predefined..." menu item, and find "MX4 square-planar" like below.
1527 </p>
1528 <p><img src="../etc/coord_02.png" /></p>
1529 <p>
1530 A square planar fragment of "CuCl4" appears on the screen.
1531 </p>
1532 <p><img src="../etc/coord_03.png" /></p>
1533 <p>
1534 Choose the "Select" tool, double click on one of the chlorine atoms, and type "C6H5".
1535 </p>
1536 <p><img style="vertical-align:top;" src="../etc/coord_04.png" /><img src="../etc/coord_05.png" /></p>
1537 <p>
1538 You see now a phenyl group is attached to the metal atom. The orientation of the phenyl ring needs to be fixed. Select the metal-C bond, and rotate the phenyl ring so that the ring is approximately coplanar with the metal-ligand plane.
1539 </p>
1540 <p><img src="../etc/coord_06.png" /></p>
1541 <p>
1542 Attach two other phenyl groups in a similay manner.
1543 </p>
1544 <p><img src="../etc/coord_07.png" /></p>
1545 <p>
1546 Remove the hydrogen atoms and create C-C bonds. Double-click on the carbon atoms connected to the metal, and change them to "N". Double-click on the metal atom and change it to "Pt".
1547 </p>
1548 <p><img style="vertical-align:top;" src="../etc/coord_08.png" /><img style="vertical-align:top;" src="../etc/coord_09.png" /><img src="../etc/coord_10.png" /></p>
1549 <p>
1550 Now the molecular structure is complete. Next we need to assign the MM parameters. To do this, select the "Guess UFF Parameters..." from the "MM/MD" menu.
1551 </p>
1552 <p><img src="../etc/coord_11.png" /></p>
1553 <p>
1554 A dialog like below opens up. Here are listed the atoms that are (1) the metal atoms, (2) the ligand atoms that are connected to the metal atoms, and (3) the ligand atoms that are connected to any of the atoms in (2). In other words, the atoms within "two-bonds" distances are shown in this dialog. The Pt atom is shown in red, because it does not have predefined MM parameters. The ligand atoms already have their MM parameters, but if you look closely not all atoms are correctly recognized. For example, the pyridine N atoms are incorrectly assigned as "n3", which is a sp3 nitrogen.
1555 </p>
1556 <p><img src="../etc/coord_12.png" /></p>
1557 <p>
1558 The UFF parameter estimation consists of two stages. The first stage is to assign the types of the ligand atoms. This is basically the same as the procedure described in <a href="mm_minimize.html">Step 6</a>, but this time we need to run Antechamber for the non-metal part only. By hitting the button "Run Antechamber for Non-Metal Fragment", Antechamber is executed for each non-metal fragments. You may need to assign the charge for each fragment; for example, if you are using catecholato ligand, that fragment should have charge of -2.
1559 </p>
1560 <p><img style="vertical-align:top;" src="../etc/coord_13.png" /><img src="../etc/coord_14.png" /></p>
1561 <p>
1562 The fragment that are being assigned by Antechamber is shown in the main window as the selection. In this example, the first fragment contains only the chlorine atom, and the second fragment is the terpyridine ligand.
1563 </p>
1564 <p><img src="../etc/coord_15.png" /><img src="../etc/coord_16.png" /></p>
1565 <p>
1566 After running Antechamber, the table looks like below. Note that the values in the "type" column have been changed.
1567 </p>
1568 <p><img src="../etc/coord_17.png" /></p>
1569 <p>
1570 Next, we need to assign the "UFF types" to each atoms. In fact, the UFF types are already set in the previous stage. We still need to look at them, and correct the types if necessary. You can select the predefined UFF types from the popup menu.
1571 </p>
1572 <p><img src="../etc/coord_18.png" /></p>
1573 <p>
1574 Now we need to assign UFF parameters for the metal atoms. Click the button "Guess UFF Parameters for Bonds and Angles Including Metal Atoms".
1575 </p>
1576 <p><img src="../etc/coord_24.png" /></p>
1577 <p>
1578 Open the "Bonds" page, and check the columns "k" and "r0". You will find there the proposed values of force constant and equilibrium bond length, according to the UFF force field. If you find, by some reason, the values are not appropriate, then you can change them by hand.
1579 </p>
1580 <p><img src="../etc/coord_25.png" /></p>
1581 <p>
1582 You can check the "Angles" page as well. Check the columns "k" and "a0", for the force constant and equilibrium bond angle. Note that, in the case of square planar or octahedral metal center, there are "cis" and "trans" angles. The program will assign "trans" if the current bond angle is larger than 135 degree, and "cis" otherwise. So, if your starting geometry is not quite optimal, be careful to check the angle parameters.
1583 </p>
1584 <p><img src="../etc/coord_26.png" /></p>
1585 <p>
1586 Close this dialog, and go into MM/MD calculations as usual. For example, you can perform energy minimization and get the structure like below.
1587 </p>
1588 <p><img src="../etc/coord_27.png" /></p>
1589 <h2>2. Compounds Containing Metal-π Bonds</h2>
1590 <p>
1591 Compounds containing metal-π bonds are also problematic in molecular mechanics calculations. The implementation of metal-π bonds in Molby is based on the proposal by Doman and coworkers (<i>J. Am. Chem. Soc.</i> <b>114,</b> 7262-7272 (1992)). Herein we will see how to build a molecular model of ferrocene.
1592 </p>
1593 <p><img src="../etc/ferro_01.png" /></p>
1594 <p>
1595 We start with the predefined structure "cyclopentadienyl."
1596 </p>
1597 <p><img style="vertical-align: top;" src="../etc/ferro_02.png" /><img src="../etc/ferro_03.png" /></p>
1598 <p>
1599 Select the five carbon atoms, and do "Create Pi Anchor" menu command.
1600 </p>
1601 <p><img src="../etc/ferro_04.png" /></p>
1602 <p>
1603 "Pi anchor" is a <i>virtual atom</i>, whose coordinates are defined as the center of mass of the "parent" atoms. In this case, the parent atoms of the pi anchor is the carbon atoms of the Cp ring. In the main screen, the pi anchor is shown as a green dot, and it is connected to the parent atoms by a green thin bonds.
1604 </p>
1605 <p><img src="../etc/ferro_05.png" /></p>
1606 <p>
1607 Rotate the ring to show the "side view" of the ring, while keeping the pi anchor barely visible. Create a bond from the pi anchor to a new atom. Change the new atom to Fe.
1608 </p>
1609 <p><img src="../etc/ferro_06.png" /><img src="../etc/ferro_07.png" /><img src="../etc/ferro_08.png" /></p>
1610 <p>
1611 Copy the cyclopentadienyl ring and the pi anchor, and paste in the same window. Place the new ring to the appropriate position, and bond the Fe atom and the new pi anchor.
1612 </p>
1613 <p><img src="../etc/ferro_09.png" /><img src="../etc/ferro_10.png" /><img src="../etc/ferro_11.png" /></p>
1614 <p>
1615 Finally, make a bond between the two pi anchors. This is necessary to describe the barrier for ring rotation. The anchor-anchor bond is shown as a half-transparent green stick.
1616 </p>
1617 <p class="note">The ring rotation can be described as a dihedral term in the form of "ring atom"-"pi anchor"-"metal"-"X". However, in the case of a linear metallocene, "X" is the other pi anchor. Since the "pi anchor"-"metal"-"pi anchor" angle is always close to 180 degree, the dihedral angle cannot be defined. For this reason, the linear metallocene requires special treatment of the dihedral term in the form of "ring atom"-"pi anchor"-"pi anchor"-"ring atom". That is why we need to make a bond between two pi anchors. This is not the case for the bent metallocenes (like Cp<sub>2</sub>TiCl<sub>2</sub>), or half-sandwich complexes.
1618 </p>
1619 <p><img src="../etc/ferro_12.png" /></p>
1620 <p>
1621 Now we can go on to the UFF dialog as before. This time, we skip the "non-metal fragments" part, because Antechamber cannot handle cyclopentadienyl anion. Our cyclopentadienyl ring already has correct atom types, so we will use them as they are.
1622 </p>
1623 <p>
1624 Change the UFF type of the Fe atom to "Fe2+ octahedral".
1625 </p>
1626 <p><img src="../etc/ferro_13.png" /></p>
1627 <p>
1628 Click on the "Bonds" label, and change the "r0" parameter of the two bonds of "##-fe" or "fe-##" type ("##" represents the pi anchor). This should be the metal-pi distance, which is 1.66 &Aring; for ferrocene.
1629 </p>
1630 <p><img src="../etc/ferro_14.png" /></p>
1631 <p>
1632 The "Angle" page should also be edited. The "a0" parameter is set to 90.0 for the "fe-##-ca" type angles (ten lines from the top), and 180.0 for the "##-fe-##" type angle (the last line).
1633 </p>
1634 <p><img src="../etc/ferro_15.png" /></p>
1635 <p>
1636 Hit the "Guess UFF Parameters..." button to complete the calculation of the UFF parameters.
1637 </p>
1638 <p><img src="../etc/ferro_16.png" /></p>
1639 <p>
1640 You can now try the MM/MD calculation. Energy minimization results in an eclipsed conformation. MD at 298K shows that the Cp rings freely rotate at this temperature.
1641 </p>
1642 <p><img src="../etc/ferro_17.png" /></p>
1643 </div>
1644 <div class="contents" lang="ja">
1645 <h1>第八段階:配位化合物のMM/MD計算</h1>
1646 <h2>1. UFF (Universal Force Field) パラメータを使う</h2>
1647 <p>
1648 配位化合物の分子モデル作成にはいろいろ問題があります。主な問題は、金属原子の分子力学パラメータが用意されていないことです。一つの合理的な方法は、Rappéらによって提案された UFF (universal force field) パラメータを使うことです (<i>J. Am. Chem. Soc.</i> <b>114</b>, 10024-10035 (1992))。 分子構造から UFF パラメータを見積もるのはやや複雑な作業ですが、プログラムによって自動化することは可能です。以下に、UFF を用いた配位化合物のモデルングに Molby がどのように利用できるかを示します。
1649 </p>
1650 <p>
1651 例として、(terpy)PtCl の分子モデルを作ってみましょう。terpy は 2,2':6',2"-terpyridine です。
1652 </p>
1653 <p><img src="../etc/coord_01.png" /></p>
1654 <p>
1655 最初に分子構造を作らなくてはいけません。一つの方法は、まず有機分子の部分 (terpy) を作成し、金属を後から付け加えることです。ここでは、別の方法を使ってみます。つまり、最初に金属回りの配位構造から始め、あとで配位子を付け加えます。一般的には、こちらの方が配位化合物のモデリングには適しています。
1656 </p>
1657 <p>
1658 "File" メニューから "Open Predefined..." を選び、下のように "MX4 square-planar" を見つけてください。
1659 </p>
1660 <p><img src="../etc/coord_02.png" /></p>
1661 <p>
1662 平面四配位の "CuCl4" 構造が現れます。
1663 </p>
1664 <p><img src="../etc/coord_03.png" /></p>
1665 <p>
1666 "Select" ツールを選び、塩素原子の1つをダブルクリックして、"C6H5" とタイプします。
1667 </p>
1668 <p><img style="vertical-align:top;" src="../etc/coord_04.png" /><img src="../etc/coord_05.png" /></p>
1669 <p>
1670 金属原子にフェニル基が結合しました。環はこの向きではいけませんので、金属-炭素結合を選択して、フェニル基を回転させ、環が金属・配位子平面と同一平面になるようにします。
1671 </p>
1672 <p><img src="../etc/coord_06.png" /></p>
1673 <p>
1674 他の2つの塩素原子も同様にフェニル基に置き換えます。
1675 </p>
1676 <p><img src="../etc/coord_07.png" /></p>
1677 <p>
1678 水素原子を削除して炭素−炭素結合を作成します。それから、金属に結合している炭素原子をダブルクリックして、"N"原子に変えます。金属原子をダブルクリックして、 "Pt" に変えます。
1679 </p>
1680 <p><img style="vertical-align:top;" src="../etc/coord_08.png" /><img style="vertical-align:top;" src="../etc/coord_09.png" /><img src="../etc/coord_10.png" /></p>
1681 <p>
1682 これで分子構造はできあがりました。次に、分子力学パラメータを設定します。"MM/MD"メニューから "Guess UFF Parameters..." コマンドを選択します。
1683 </p>
1684 <p><img src="../etc/coord_11.png" /></p>
1685 <p>
1686 下のようなダイアログが開きます。表に原子が並んでいますが、この原子は (1) 金属原子、(2) 金属原子に結合している原子、(3) (2) の原子のいずれかに結合している原子、のどれかです。言い換えれば、金属原子から「結合2つ分」以内の原子が表示されています。Pt 原子の行は赤色で表示されています。分子力学パラメータが定義されていないことを表しています。配位子の原子はすでに分子力学パラメータを持っていますが、よく見ると、間違っているものもあります。例えば、ピリジンの N 原子は "n3" タイプになっていますが、これは sp3 窒素です。
1687 </p>
1688 <p><img src="../etc/coord_12.png" /></p>
1689 <p>
1690 UFF パラメータの作成はいくつかの段階を要します。最初に、配位子の原子タイプを正しく設定します。この作業は、<a href="mm_minimize.html">第六段階</a> で行ったのとほぼ同じですが、今回は金属原子を除いた部分構造について Antechamber を実行する必要があります。"Run Antechamber for Non-Metal Fragment" ボタンを押すと、この作業が自動的に行われます。各部分構造について、電荷を与える必要があるかも知れません。例えば、カテコラト配位子を使っているなら、電荷は -2 となります。
1691 </p>
1692 <p><img style="vertical-align:top;" src="../etc/coord_13.png" /><img src="../etc/coord_14.png" /></p>
1693 <p>
1694 Antechamber を走らせる部分構造は、メインウィンドウで選択されて表示されます。ここの例では、1番目の部分構造は塩素原子1個だけを含み、2番目の部分構造はターピリジンになります。
1695 </p>
1696 <p><img src="../etc/coord_15.png" /><img src="../etc/coord_16.png" /></p>
1697 <p>
1698 Antechamber を走らせると、表は下のようになります。"type" 列の値が変わっていることに注意してください。
1699 </p>
1700 <p><img src="../etc/coord_17.png" /></p>
1701 <p>
1702 次に、各原子の "UFF type" を設定します。前の段階で UFF type を仮に設定してありますが、一通り見直して、必要なら変更してください。UFF type はポップアップメニューで選択することができます。
1703 </p>
1704 <p><img src="../etc/coord_18.png" /></p>
1705
1706 <p>
1707 今度は、金属原子のパラメータを設定します。"Guess UFF Parameters for Bonds and Angles Including Metal Atoms" ボタンを押してください。
1708 </p>
1709 <p><img src="../etc/coord_24.png" /></p>
1710 <p>
1711 "Bonds" ページを開いて、"k" と "r0" の列を見てください。UFF 分子力場から予測された「力の定数」と「結合長」が入っているはずです。何らかの理由で、値が適切ではないと考えた場合は、手動で変更することもできます。
1712 </p>
1713 <p><img src="../etc/coord_25.png" /></p>
1714 <p>
1715 "Angles" ページも同じようにチェックしてください。"k" と "a0" の列に「力の定数」と「結合角」が入っています。金属中心が、平面正方形、または八面体構造の場合は、"cis" と "trans" の角度があります。プログラムは、現在の結合角が 135度よりも大きければ "trans" とみなし、小さければ "cis" とみなします。現在の構造が理想的な構造から離れている場合は、角度のパラメータを注意深くチェックしてください。
1716 </p>
1717 <p><img src="../etc/coord_26.png" /></p>
1718 <p>
1719 このダイアログを閉じて、MM/MD 計算を通常のように進めます。例えば、エネルギー最小化を行うと、下のような構造が得られます。
1720 </p>
1721 <p><img src="../etc/coord_27.png" /></p>
1722 <h2>2. 金属-π 結合を持つ化合物</h2>
1723 <p>
1724 分子力学計算では、金属-π結合を持つ化合物の取り扱いも厄介です。Molby は、Doman らの方法 (<i>J. Am. Chem. Soc.</i> <b>114,</b> 7262-7272 (1992)) に準じて金属-π結合の分子力学計算を実装しています。ここでは、フェロセンの分子モデルを作成してみます。
1725 </p>
1726 <p><img src="../etc/ferro_01.png" /></p>
1727 <p>
1728 "Open Predefined" から "cyclopentadienyl" を選びます。
1729 </p>
1730 <p><img style="vertical-align: top;" src="../etc/ferro_02.png" /><img src="../etc/ferro_03.png" /></p>
1731 <p>
1732 5つの炭素原子を選択し、"Create Pi Anchor" メニューコマンドを実行します。
1733 </p>
1734 <p><img src="../etc/ferro_04.png" /></p>
1735 <p>
1736 "Pi anchor" とは、「親」原子の重心を座標とする仮想的な原子です。今回は、シクロペンタジエニル環の5つの炭素原子(上で選択したもの)が pi anchor の親になります。スクリーン上では、pi anchor は緑色の小さな球で表し、親原子とは緑色の半透明の棒でつないで表示されます。
1737 </p>
1738 <p><img src="../etc/ferro_05.png" /></p>
1739 <p>
1740 環を回転させて、横から見た向きにします。Pi anchor はぎりぎり見えるようにしておきます。Pi anchor から結合を出して、新しい原子を作ります。新しい原子を Fe に変えます。
1741 </p>
1742 <p><img src="../etc/ferro_06.png" /><img src="../etc/ferro_07.png" /><img src="../etc/ferro_08.png" /></p>
1743 <p>
1744 シクロペンタジエニル環と pi anchor をコピーして、同じウィンドウ内にペーストします。新しい環を Fe 原子をはさんで反対側に移動し、新しい pi anchor と Fe 原子を結合させます。
1745 </p>
1746 <p><img src="../etc/ferro_09.png" /><img src="../etc/ferro_10.png" /><img src="../etc/ferro_11.png" /></p>
1747 <p>
1748 最後に、2つの pi anchor の間に結合を作ります。これは、環の回転障壁を正しく見積もるために必要になります。Anchor 同士の結合は、半透明の緑色で示されます。
1749 </p>
1750 <p class="note">
1751 環の回転は「環の原子-pi anchor-金属-他の原子」という二面角項で表されます。メタロセンの場合、「他の原子」はもう一つの pi anchor になります。ところが、直線型のメタロセンだと、「pi anchor-金属-pi anchor」の角度は常に 180°付近であるため、二面角を正しく定義することができません。このため、直線型メタロセンでは、特別に「環の原子-pi anchor-pi anchor-環の原子」という二面角で環の回転を表現します。この理由で、2つの pi anchor の間に結合を作る必要があるのです。曲がったメタロセン (Cp<sub>2</sub>TiCl<sub>2</sub> など) や、ハーフサンドイッチ型の錯体では、このような扱いは不必要です。
1752 </p>
1753 <p><img src="../etc/ferro_12.png" /></p>
1754 <p>
1755 ここからは、前と同じように UFF のダイアログを使うことが出来ます。今回は、"non-metal fragments" の計算は省略します。Antechamber はシクロペンタジエニルアニオンを正しく取り扱うことができないためです。私たちのシクロペンタジエニル環はすでに正しい原子タイプを持っていますので、これをそのまま使います。
1756 </p>
1757 <p>
1758 Fe の UFF タイプを "Fe2+ octahedral" に変更します。
1759 </p>
1760 <p><img src="../etc/ferro_13.png" /></p>
1761 <p>
1762 "Bonds" ラベルをクリックし、"##-fe" または "fe-##" タイプの結合の "r0" パラメータの値を変更します("##" は pi anchor を意味します)。この値は金属-π結合の距離です。フェロセンの場合は 1.66 &Aring; になります。
1763 </p>
1764 <p><img src="../etc/ferro_14.png" /></p>
1765 <p>
1766 "Angles" ページも編集が必要です。今回は手動で金属原子を作成したため、角度が正しくなっていないからです。"fe-##-ca" タイプの角度は 90.0(上から10行分)、"##-fe-##" タイプの角度は 180.0(一番下の行)にします。
1767 </p>
1768 <p><img src="../etc/ferro_15.png" /></p>
1769 <p>
1770 "Guess UFF Parameters..." ボタンを押して、UFF パラメータの計算を行います。
1771 </p>
1772 <p><img src="../etc/ferro_16.png" /></p>
1773 <p>
1774 これで MM/MD 計算を試すことができます。エネルギー最小化を行うと、重なり型の配置が得られます。298K で MD を行うと、Cp 環がこの温度で自由回転していることがわかります。
1775 </p>
1776 <p><img src="../etc/ferro_17.png" /></p>
1777 </div>
1778 <link id="#navigation" />
1779 </div>
1780
1781 <div file="qchem.html">
1782 <link rel="Up" href="tutorials.html" />
1783 <link rel="Prev" href="coordination.html" />
1784 <link id="#header" />
1785 <div class="contents" lang="en">
1786 <h1>Step Nine: Collaboration with Other Quantum Chemistry Softwares</h1>
1787 <p>
1788 Molby has a capability to export and import files for quantum chemistry softwares, namely <a href="http://www.gaussian.com/">Gaussian</a> and <a href="http://www.msg.ameslab.gov/GAMESS/">GAMESS</a>. At present, the capability is quite limited, and in many cases it would be much better to use other established softwares. Nevertheless, if you are already familiar with Molby, you may want to use Molby for creating input files for Gaussian and GAMESS and processing outputs. Here are instructions how to do it.
1789 </p>
1790 <p class="note">
1791 Needless to say, you need to have access to Gaussian or GAMESS program packages. They can be on the same machine or on other machines (workstations) than Molby. Please learn how to use these packages before using Molby as described in this section.
1792 </p>
1793 <h2>1. Using Gaussian</h2>
1794 <p>
1795 The Gaussian input can be created by selecting "Export..." command in the "File" menu. The file extension is either "gjf" (as is the convention in GaussianW) or "com" (as in UNIX version of Gaussian).
1796 </p>
1797 <p><img style="vertical-align:top;" src="../etc/qchem_01.png" /><img src="../etc/qchem_02.png" /></p>
1798 <p>
1799 The output will look like this. Although Molby can create only one type of Gaussian input (optimize with PM3), it should be relatively easy to modify the generated input file by hand.
1800 </p>
1801 <p class="code">%Chk=benzene.chk
1802 # PM3 Opt
1803
1804  unnamed1; created by Molby at Sat Feb 11 00:30:21 +0900 2012
1805
1806  0 1
1807 C       -0.653000   0.585000  -1.068000
1808 H       -1.158000   1.039000  -1.898000
1809 C        0.729000   0.607000  -1.003000
1810 H        1.295000   1.076000  -1.783000
1811 C        1.382000   0.021000   0.069000
1812 H        2.452000   0.038000   0.119000
1813 C        0.651000  -0.586000   1.076000
1814 H        1.156000  -1.039000   1.906000
1815 C       -0.732000  -0.607000   1.012000
1816 H       -1.298000  -1.077000   1.792000
1817 C       -1.384000  -0.021000  -0.060000
1818 H       -2.455000  -0.038000  -0.110000
1819
1820 </p>
1821 <p>
1822 When you do geometrical optimization, you may want to examine how the structure changes as the calculation proceeds. This can be done by importing the Gaussian output file. The extention should be either ".out" or ".log".
1823 </p>
1824 <p><img style="vertical-align:top;" src="../etc/qchem_03.png" /><img src="../etc/qchem_04.png" /></p>
1825 <h2>2. Using GAMESS</h2>
1826 <p>
1827 Creating GAMESS input can be more complicated than Gaussian, so that Molby provides a simple dialog to help creating GAMESS input. The dialog is accessible from the "Creating GAMESS input..." command in the "QChem" menu.
1828 </p>
1829 <p><img src="../etc/qchem_05.png" /></p>
1830 <p>
1831 You can specify various settings in the dialog.
1832 </p>
1833 <p><img src="../etc/qchem_06.png" /></p>
1834 <ul>
1835 <li><b>SCF Type:</b> RHF, ROHF, or UHF.</li>
1836 <li><b>Run Type:</b> Energy, Property, or Optimize.</li>
1837 <li><b>Use internal coordinates for structure optimization:</b> Add instructions for automatic generation of internal Z-matrix. (<i>Note:</i> It cannot be used for linear molecules.)</li>
1838 <li><b>Charge:</b> The (formal) charge of the molecule.</li>
1839 <li><b>Multiplicity:</b> The spin multiplicity.</li>
1840 <li><b>Use DFT:</b> Check if you want to use DFT.</li>
1841 <li><b>DFT type:</b> At present only B3LYP is available in this dialog.</li>
1842 <li><b>Basis set:</b> One of PM3, STO-3G, 3-21G, 6-31G, 6-31G(d), 6-31G(d, p), 6-311G, 6-311G(d, p), or LanL2DZ.</li>
1843 <li><b>Load Basis Set:</b> Additional basis set can be imported from a file. The file should be in the GAMESS standard format. See the "basis_sets" directory in the "Script" directory for examples.</li>
1844 <li><b>Use secondary basis set:</b> Check if you want to use another basis set for certain elements.</li>
1845 <li><b>Elements:</b> The elements (comma separated) to use secondary basis set.</li>
1846 <li><b>Basis set:</b> The secondary basis set.</li>
1847 <li><b>Calculate electrostatic potential:</b> This is used for RESP charge calculation for AMBER.</li>
1848 <li><b>Include NBO instructions:</b> When GAMESS is built with NBO (natural bond orbital) support, these checkboxes generate instructions for running NBO program for the designated properties.</li>
1849 <li><b>Execute GAMESS on this machine:</b> (0.6.5 and later) Execute GAMESS, provided that GAMESS is installed on the same computer. Specify the full path of the GAMESS executable in "Path", and the number of CPU cores for calculation in "N of CPUs."<br />
1850 (Note: GAMESS may not work depending on the version of the executable.)</li>
1851 </ul>
1852 <p>
1853 When the calculation of GAMESS is complete, you will find two output files, namely *.log and *.dat. Either format can be imported by use of the "Import..." menu command. Some informations are included in both (<i>e.g.</i> coordinates during structural optimization), but other informations are only in one of these files (<i>e.g.</i> the full description of gaussian functions is only in the *.log file, whereas the orbital coefficients with full precision are only in the *.dat file). You need to be familiar with the structure of the GAMESS output files to fully utilize the GAMESS import capability of Molby.
1854 </p>
1855 <h2 id="gamess_resp" name="gamess_resp">3. Using GAMESS for calculation of the RESP charges</h2>
1856 <p>
1857 We already saw <a href="mm_minimize.html#electrostatic">how to assign partial charges</a> for evaluation of electrostatic interactions in MM calculations. There we used semi-empirical calculations, although <i>ab initio</i> calculations will give better results if possible. Here are instructions how to do it using GAMESS.
1858 </p>
1859 <p>
1860 Select "MM/MD" &rarr; "GAMESS/RESP...".
1861 </p>
1862 <p><img src="../etc/qchem_07.png" /></p>
1863 <p>
1864 The following window pops up. As the first step, press the "Create GAMESS Input..." button.
1865 </p>
1866 <p><img src="../etc/qchem_08.png" /></p>
1867 <p>
1868 The familiar GAMESS dialog opens up. It is most important to turn on the "Calculate electrostatic potential (ESP)" checkbox (it should be turned on if you follow the steps as described here, but please double-check). Also make sure that the charge and multiplicity are correct, and select a suitable basis set (6-31G(d) is recommended).
1869 </p>
1870 <p><img src="../etc/qchem_09.png" /></p>
1871 <p>
1872 Press OK to create the GAMESS input, and send it to GAMESS. The calculation will take time, so that you can finish Molby (after saving the molecule as a msbf file!), and work on something else at this stage.
1873 </p>
1874 <p>
1875 After the GAMESS calculation is complete, open the same molecule, and select "MM/MD" &rarr; "Tools" &rarr; "GAMESS/RESP..." again. This time, follow the second step by pressing the "Import GAMESS dat..." button.
1876 </p>
1877 <p><img src="../etc/qchem_10.png" /></p>
1878 <p>
1879 Select the GAMESS dat file (which should be available when the GAMESS calculation ends successfully), and import it. When the import is complete, the "Run RESP..." button should be enabled. If it does not, the imported dat file does not have the electrostatic potential information. Start over from the step 1, and make sure that the "Calculate electrostatic potential (ESP)" checkbox is on.
1880 </p>
1881 <p><img src="../etc/qchem_11.png" /></p>
1882 <p>
1883 Press the "Run RESP..." button, and the following dialog opens. This is almost the same as the dialog for Antechamber <a href="mm_minimize.html#minimize">described before</a>.
1884 </p>
1885 <p><img src="../etc/qchem_12.png" /></p>
1886 <p>
1887 Press the "OK" button, and the RESP charge will be assigned to the atoms.
1888 </p>
1889 </div>
1890 <div class="contents" lang="ja">
1891 <h1>第九段階:他の量子化学ソフトウェアとの連携</h1>
1892 <p>
1893 Molby は量子化学計算ソフトウェア  <a href="http://www.gaussian.com/">Gaussian</a>、<a href="http://www.msg.ameslab.gov/GAMESS/">GAMESS</a> のファイルを作成/読み込みする機能を持っています。現状では、Molby には極めて制限された機能しかないため、おそらく他の実績あるソフトウェアを使った方がよいでしょう。しかし、Molby の操作に慣れているなら、Gaussian や GAMESS の入力を作成して結果を読み込むのに Molby を使いたいことがあるかもしれません。どのようにすればよいかを説明します。
1894 </p>
1895 <p class="note">
1896 当然のことながら、Gaussian や GAMESS のプログラムパッケージが使えることが前提です。これらが走るのは、Molby と同じマシン上でも異なるマシン(ワークステーション)上でも構いません。この項で説明するやり方で Molby を使う前に、これらのプログラムパッケージをどのように使うかを学んでおいてください。
1897 </p>
1898 <h2>1. Gaussian を使う</h2>
1899 <p>
1900 Gaussian の入力は "File" &rarr; "Export..." コマンドを使えば作成することができます。ファイルの拡張子は "gjf"(GaussianW での習慣)、または "com"(UNIX 版での習慣)です。
1901 </p>
1902 <p><img style="vertical-align:top;" src="../etc/qchem_01.png" /><img src="../etc/qchem_02.png" /></p>
1903 <p>
1904 できあがったファイルは次のようになります。Molby が作成できるのは、一種類の Gaussian 入力ファイル(PM3 による構造最適化)だけですが、Gaussian の入力ファイルを手作業で修正するのは比較的簡単です。
1905 </p>
1906 <p class="code">%Chk=benzene.chk
1907 # PM3 Opt
1908
1909  unnamed1; created by Molby at Sat Feb 11 00:30:21 +0900 2012
1910
1911  0 1
1912 C       -0.653000   0.585000  -1.068000
1913 H       -1.158000   1.039000  -1.898000
1914 C        0.729000   0.607000  -1.003000
1915 H        1.295000   1.076000  -1.783000
1916 C        1.382000   0.021000   0.069000
1917 H        2.452000   0.038000   0.119000
1918 C        0.651000  -0.586000   1.076000
1919 H        1.156000  -1.039000   1.906000
1920 C       -0.732000  -0.607000   1.012000
1921 H       -1.298000  -1.077000   1.792000
1922 C       -1.384000  -0.021000  -0.060000
1923 H       -2.455000  -0.038000  -0.110000
1924
1925 </p>
1926 <p>
1927 構造最適化を行ったあとは、構造がどのように変化するか見てみたいと思うでしょう。これは、Gaussian 出力ファイルを読み込めば実現できます。拡張子は ".out" または ".log" でなくてはなりません。
1928 </p>
1929 <p><img style="vertical-align:top;" src="../etc/qchem_03.png" /><img src="../etc/qchem_04.png" /></p>
1930 <h2>2. GAMESS を使う</h2>
1931 <p>
1932 GAMESS の入力を作成するのは Gaussian よりもずっと複雑なので、専用のダイアログが用意されています。このダイアログは、"QChem" &rarr; "Creating GAMESS input..." コマンドで開くことができます。
1933 </p>
1934 <p><img src="../etc/qchem_05.png" /></p>
1935 <p>
1936 このダイアログでは、いろいろな設定を決めることができます。
1937 </p>
1938 <p><img src="../etc/qchem_06.png" /></p>
1939 <ul>
1940 <li><b>SCF Type:</b> RHF, ROHF, または UHF.</li>
1941 <li><b>Run Type:</b> Energy, Property, または Optimize.</li>
1942 <li><b>Use internal coordinates for structure optimization:</b> 内部的に Z-matrix を自動生成するための命令を付け加えます。(<i>注:</i> 直線状分子には使えません。)</li>
1943 <li><b>Charge:</b> 分子の形式電荷。</li>
1944 <li><b>Multiplicity:</b> スピン多重度。</li>
1945 <li><b>Use DFT:</b> DFT 計算を行うときチェックします。</li>
1946 <li><b>DFT type:</b> このダイアログでは B3LYP のみ指定できます。</li>
1947 <li><b>Basis set:</b> 以下の基底が指定できます:PM3, STO-3G, 3-21G, 6-31G, 6-31G(d), 6-31G(d, p), 6-311G, 6-311G(d, p), または LanL2DZ.</li>
1948 <li><b>Load Basis Set:</b> ファイルから追加の基底関数を読み込みます。ファイルは GAMESS の標準的なフォーマットに従っている必要があります。ファイルの例として、"Scripts" ディレクトリの中の "basis sets" ディレクトリを見てみてください。</li>
1949 <li><b>Use secondary basis set:</b> 特定の元素のみ別の基底を使いたいときチェックします。</li>
1950 <li><b>Elements:</b> 別の基底を使う元素(コンマで区切って複数指定できます)。</li>
1951 <li><b>Basis set:</b> 別の基底。</li>
1952 <li><b>Calculate electrostatic potential:</b> RESP 電荷を求めるための静電ポテンシャルの計算を行う。</li>
1953 <li><b>Include NBO instructions:</b> GAMESS が NBO (natural bond orbital) をサポートしている場合は、これらのチェックボックスで指定したものを NBO プログラムで計算させるように、コマンドを生成します。</li>
1954 <li><b>Execute GAMESS on this machine:</b> (0.6.5 以降) Molby と同じコンピュータに GAMESS がインストールされているとき、GAMESS を実行することができます。Path に GAMESS の実行ファイルのフルパス名、N of CPUs に使用する CPU のコア数を指定します。<br />
1955 (注: GAMESS のバージョンによっては動作しないことがあります。)</li>
1956 </ul>
1957 <p>
1958 GAMESS の計算が終了すると、*.log と *.dat の2つのファイルができます。どちらも "Import..." コマンドで読み込むことができます。ある種の情報(たとえば構造最適化途中の座標)はどちらのファイルにも含まれていますが、その他の情報はどちらか一方にしか含まれません(たとえば、基底を構成する Gaussian 関数の完全な係数は *.log ファイルにしかなく、精度の高い軌道係数は *.dat にしかありません)。GAMESS 読み込み機能を十分に活用するには、GAMESS の出力が何を含んでいるかをよく理解する必要があります。
1959 </p>
1960 <h2 id="gamess_resp" name="gamess_resp">3. GAMESS を用いて RESP 電荷を計算する</h2>
1961 <p>
1962 分子力学計算で静電相互作用を評価するための部分電荷の計算については<a href="mm_minimize.html#electrostatic">すでに説明しました</a>。そこでは半経験的分子軌道計算を用いましたが、可能ならば ab initio 計算の方がよい結果を与えます。GAMESS を使って計算する方法を説明します。
1963 </p>
1964 <p>
1965 メニューより "MM/MD" &rarr; "GAMESS/RESP..." を選びます。
1966 </p>
1967 <p><img src="../etc/qchem_07.png" /></p>
1968 <p>
1969 次のウィンドウが開きます。第1のステップとして、"Create GAMESS Input..." ボタンを押します。
1970 </p>
1971 <p><img src="../etc/qchem_08.png" /></p>
1972 <p>
1973 GAMESS のダイアログが開きます。大切なのは、"Calculate electrostatic potential (ESP)" チェックボックスをオンにすることです(ここの手順に従えば、自動的にオンになっているはずですが、一応確認してください)。分子の電荷・スピン多重度が正しいことを確かめ,基底関数 (6-31G(d) がおすすめ) を指定してください。
1974 </p>
1975 <p><img src="../etc/qchem_09.png" /></p>
1976 <p>
1977 OK ボタンを押して GAMESS 入力を作成し、GAMESS で計算を実行してください。計算には時間がかかりますから、この時点で Molby を終了して他の作業をしていただいて構いません(ただし、分子ファイルを mbsf 形式で保存することを忘れないで!)。
1978 </p>
1979 <p>
1980 GAMESS 計算が完了したら、同じ分子ファイルを開き、"MM/MD" &rarr; "Tools" &rarr; "GAMESS/RESP..." をもう一度選択してください。今度は、第2ステップの "Import GAMESS dat..." ボタンを押します。
1981 </p>
1982 <p><img src="../etc/qchem_10.png" /></p>
1983 <p>
1984 GAMESS の dat ファイルを選択し(GAMESS の計算が成功すればこれができているはずです)、読み込んでください。読み込みが完了したら、"Run RESP..." ボタンが有効になっているはずです。もしそうならなかったら、読み込んだ dat ファイルに静電ポテンシャルのデータが含まれなかったということです。もう一度第1ステップからやり直し、特に "Calculate electrostatic potential (ESP)" チェックボックスがオンになっていることを確かめてください。
1985 </p>
1986 <p><img src="../etc/qchem_11.png" /></p>
1987 <p>
1988 "Run RESP..." ボタンを押すと、次のダイアログが開きます。これは、<a href="mm_minimize.html#minimize">前に説明した</a> Antechamber のダイアログとほとんど同じです。
1989 </p>
1990 <p><img src="../etc/qchem_12.png" /></p>
1991 <p>
1992 "OK"ボタンを押すと、RESP 部分電荷が各原子に対してアサインされます。
1993 </p>
1994 </div>
1995 <link id="#navigation" />
1996 </div>
1997
1998 <div file="xtal.html">
1999 <link rel="Up" href="tutorials.html" />
2000 <link rel="Prev" href="qchem.html" />
2001 <link id="#header" />
2002 <div class="contents" lang="en">
2003 <h1>Step Ten: Working with Crystal Structures</h1>
2004 <p>
2005 Information obtained from single-crystal X-ray analysis is a very important source of molecular structure. Molby can import crystallographic information files (CIFs) and handle structural data included in them. Although Molby does not have capability of solving structures from diffraction data, it does provide convenient features for viewing and examining crystal structures.
2006 </p>
2007 <h2>1. Importing a CIF file</h2>
2008 <p>
2009 Select "Open..." menu command in the "File" menu, and choose "Crystallographic Information File (CIF)" as the file type.
2010 </p>
2011 <p><img src="../etc/xtal_01.png" /></p>
2012 <p>
2013 Select a CIF file and hit "Open". If the molecule has crystallographic symmetry, it should have bonds including symmetry related atoms. In this case, a dialog like below is shown and you are asked how to handle such bonds.
2014 </p>
2015 <p><img src="../etc/xtal_02.png" /></p>
2016 <p>
2017 If the molecule is discrete with an imposed crystallographic symmetry, the default selection (the second one) should work all right. In other cases, where the molecule is an infinite chain, the first choice may make more sense. Expansion by symmetry is also available as a separate command, so it is also safe to ignore extra bonds at this stage (the third choice) and do symmetry expansion later.
2018 </p>
2019 <p>
2020 After expansion, the molecule looks like this. The atoms with darker colors are "expanded atoms."
2021 </p>
2022 <p><img src="../etc/xtal_03.png" /></p>
2023 <p>
2024 Molby internally handles all atomic positions as cartesian coordinates. However, the fractional coordinates can be calculated "on-the-fly." In the property table, you can choose to display the fractional coordinates (together with the site occupancies and isotropic temperature factors) as below.
2025 </p>
2026 <p><img src="../etc/xtal_04.png" /><img src="../etc/xtal_05.png" /></p>
2027
2028 <h2>2. Examining the Crystal Structure</h2>
2029 <p>
2030 Commands for examining the crystal structure are available in the "Xtal" menu.
2031 </p>
2032 <p><img src="../etc/xtal_06.png" /></p>
2033 <h3>2-1. Unit Cell</h3>
2034 <p>
2035 The "Unit Cell" command is used to set the unit cell parameters. It is also possible to set the origin and the unit cell axes directly.
2036 </p>
2037 <p><img src="../etc/xtal_07.png" /></p>
2038 <h3>2-2. Symmetry Operation</h3>
2039 <p>
2040 The "Symmetry Operation" command is used to add/remove the symmetry operation, or change the space group.
2041 </p>
2042 <p><img src="../etc/xtal_08.png" /></p>
2043 <p>
2044 Hitting the "Select..." button causes another dialog to open, where you can choose one of the predefined space groups. All 230 space groups are included with various origin and axis settings (not all possible choices are covered though).
2045 </p>
2046 <p><img src="../etc/xtal_09.png" /></p>
2047 <h3>2-3. Symmetry Expansion</h3>
2048 <p>
2049 The "Complete by Symmetry" command is used to expand the molecular fragment in the asymmetric unit. It is supposed to work similarly as the "expand fragments" option in loading CIFs, but the result may be different. (This is because, in the "Complete by Symmetry" command, the bonds between different asymmetric units are "guessed" based on interatomic distances instead of being read from the CIF file.)
2050 </p>
2051 <p><img src="../etc/xtal_10.png" /></p>
2052 <p>
2053 The "Create Packing Diagram" command generates symmetry-related atoms within the given range of the fractional coordinates.
2054 </p>
2055 <p><img src="../etc/xtal_11.png" /><img src="../etc/xtal_12.png" /></p>
2056 <p>
2057 The "Show Periodic Image" command does <i>not</i> generate new atoms, but shows the periodic images of the present unit cell.
2058 </p>
2059 <p><img src="../etc/xtal_13.png" /><img src="../etc/xtal_14.png" /></p>
2060 <p>
2061 The "Remove Expanded Atoms" command removes the atoms generated by symmetry expansion. There are two options; one is to remove all expanded atoms, and the other is to remove only those atoms that are included in completely expanded fragments (i.e. the fragments containing at least one non-expanded atoms will be kept unchanged).
2062 </p>
2063 <p><img src="../etc/xtal_15.png" /></p>
2064 <p>
2065 The result looks like below. Note that the periodic images are still shown, because they are not expanded atoms but just images shown on the screen.
2066 </p>
2067 <p><img src="../etc/xtal_16.png" /></p>
2068
2069 <h3>2-4. Bonds, Angles, and Planes</h3>
2070 <p>
2071 The "Bonds and Angles with Sigma..." command is used to calculate the interatomic distances and angles with the standard deviations.
2072 </p>
2073 <p><img src="../etc/xtal_17.png" /></p>
2074 <p>
2075 Hit "Add Bond" or "Add Angle" button to create a new entry, then select the atoms one by one in the main window. After adding one "bond" and one "angle", the window looks like below. Note that you can choose atoms that are not connected via chemical bonds.
2076 </p>
2077 <p><img src="../etc/xtal_18.png" /></p>
2078 <p>
2079 To use the calculated information in other applications (like pasting into a word processor), select the table rows and hit "Export to Clipboard." The information is copied as a plain text (one line per row) that can be pasted into other applications.
2080 </p>
2081 <p><img src="../etc/xtal_19.png" /><img src="../etc/xtal_20.png" /></p>
2082 <p>
2083 The "Best-Fit Planes" command is used for calculating mean planes, angles between the planes, and distances of atoms from the plane. After the dialog is opened, the set of atoms can be assigned by selecting the atoms in the main window and hit one of the "Set Current Selection" buttons.
2084 </p>
2085 <p><img src="../etc/xtal_21.png" /></p>
2086
2087 <h3>2-5. ORTEP Drawing</h3>
2088 <p>
2089 The "Show ORTEP" command open the dialog like below.
2090 </p>
2091 <p><img src="../etc/xtal_22.png" /></p>
2092 <p>
2093 The ORTEP drawing is created by the bundled ORTEP-III program. The following citation should be made when using the output.
2094 </p>
2095 <ul>
2096 <li>
2097 Burnett, M. N.; Johnson, C. K. <i>ORTEP-III: Oak Ridge Thermal Ellipsoid Plot Program for Crystal Structure Illustrations,</i> Oak Ridge National Laboratory Report ORNL-6895, 1996.
2098 </li>
2099 </ul>
2100 <p>
2101 On this dialog, you can choose the appearance of the atoms and bonds. The orientation of the drawing is similar (although not completely the same) as in the main window. The drawing can be exported as an ORTEP input file or a graphic file (either as an encapsulated PostScript file, a PNG file or a TIFF file). When exporting to a bitmap file, the drawing is done at resolution of 360 dpi.
2102 </p>
2103 <p><img src="../etc/xtal_23.png" /></p>
2104 </div>
2105 <div class="contents" lang="ja">
2106 <h1>第十段階:結晶構造を取り扱う</h1>
2107 <p>
2108 単結晶X線構造解析は、分子構造の重要な情報源です。Molby は、結晶情報ファイル (CIF) を読み込み、構造データを取り扱うことができます。回折データから構造解析を行うことはできませんが、結晶構造を表示したり調べたりするのに便利な機能を持っています。
2109 </p>
2110 <h2>1. CIFデータの読み込み</h2>
2111 <p>
2112 "File" メニューから "Open..." コマンドを選び、ファイルタイプとして "Crystallographic Information File (CIF)" を選択します。
2113 </p>
2114 <p><img src="../etc/xtal_01.png" /></p>
2115 <p>
2116 CIF を選んで "Open" を押します。CIF の中の分子は、対称操作で関連づけられた原子との間に結合を持っていることがあります。このような場合は、下のダイアログが表示されます。
2117 </p>
2118 <p><img src="../etc/xtal_02.png" /></p>
2119 <p>
2120 分子が無限鎖でなく、自分自身の中に結晶学的な対称性を持っている場合は、2番目の選択肢(これが標準です)でうまくいきます。分子が無限鎖の場合は、1番目の選択肢の方が合理的です。また、対称操作で分子を拡大する機能は後でも使うことができますので、この段階では「外との結合」を無視する(3番目の選択肢)ことにしても構いません。
2121 </p>
2122 <p>
2123 対称操作によって拡大すると、分子は下のようになります。暗い色で表示されているのは、対称操作によって作られた原子です。
2124 </p>
2125 <p><img src="../etc/xtal_03.png" /></p>
2126 <p>
2127 Molby の内部では、すべての原子座標は直交座標で扱われています。しかし、単位格子内の部分座標も計算することができます。属性テーブルで "xtal coords" を選ぶと、部分座標と占有数・温度因子を表示できます。
2128 </p>
2129 <p><img src="../etc/xtal_04.png" /><img src="../etc/xtal_05.png" /></p>
2130
2131 <h2>2. 結晶構造を調べる</h2>
2132 <p>
2133 結晶構造を調べるためのコマンドは "Xtal" メニューにあります。
2134 </p>
2135 <p><img src="../etc/xtal_06.png" /></p>
2136 <h3>2-1. 単位格子</h3>
2137 <p>
2138 "Unit Cell" コマンドは、単位格子のパラメータを設定するのに使います。原点と単位格子の軸ベクトルを直接設定することもできます。
2139 </p>
2140 <p><img src="../etc/xtal_07.png" /></p>
2141 <h3>2-2. 対称操作</h3>
2142 <p>
2143 "Symmetry Operation" コマンドでは、対称操作を追加・削除したり、空間群を設定したりできます。
2144 </p>
2145 <p><img src="../etc/xtal_08.png" /></p>
2146 <p>
2147 "Select..." ボタンを押すと、もう一つ別のダイアログが開きます。ここでは、あらかじめ定義された空間群を選択することができます。230 の空間群すべてがいろいろな原点・軸の設定で登録されています(すべての選択肢が網羅されている訳ではありませんが)。
2148 </p>
2149 <p><img src="../etc/xtal_09.png" /></p>
2150 <h3>2-3. 対称操作による拡大</h3>
2151 <p>
2152 "Complete by Symmetry" コマンドは、非対称単位内の分子の部分を対称操作によって拡大するために使います。これは、CIF を読み込む時のオプションと同様に機能しますが、結果は少し違うこともあります。(その理由は、"Complete by Symmetry" コマンドでは、異なる非対称単位中の原子間の結合の有無を、結合距離から推測するためです。CIF 読み込みの場合は、CIF に書かれた結合の情報を使います。)
2153 </p>
2154 <p><img src="../etc/xtal_10.png" /></p>
2155 <p>
2156 "Create Packing Diagram" コマンドは、指定した部分座標の範囲(標準は単位格子全体)に存在する原子を対称操作によって生成します。
2157 </p>
2158 <p><img src="../etc/xtal_11.png" /><img src="../etc/xtal_12.png" /></p>
2159 <p>
2160 "Show Periodic Image" コマンドは、新しく原子を作るのではなく、単位格子の繰り返しイメージを画面上で表示するためのものです。
2161 </p>
2162 <p><img src="../etc/xtal_13.png" /><img src="../etc/xtal_14.png" /></p>
2163 <p>
2164 "Remove Expanded Atoms" コマンドは、対称操作によって生成された原子を削除します。2つのオプションがあります。1つは、すべての生成原子を削除するものです。もう1つは、拡張原子のみから成る部分分子を削除するものです(この場合、元の原子と同じ分子に属する拡張原子はそのまま残されます)。
2165 </p>
2166 <p><img src="../etc/xtal_15.png" /></p>
2167 <p>
2168 結果は下のようになります。"Show Periodic Image" で表示している繰り返しイメージはまだ表示されていることに注意してください。これは拡張原子ではないため、削除はされません。(このイメージを消すには、"Show Periodic Image" コマンドで表示を無効にしてください。)
2169 </p>
2170 <p><img src="../etc/xtal_16.png" /></p>
2171
2172 <h3>2-4. 結合・角度・最適平面</h3>
2173 <p>
2174 "Bonds and Angles with Sigma..." コマンドは、原子間の距離・角度を標準偏差付きで計算するものです。
2175 </p>
2176 <p><img src="../etc/xtal_17.png" /></p>
2177 <p>
2178 "Add Bond" または "Add Angle" ボタンを押して新しいエントリーを作り、それからメインウィンドウで原子を1つずつクリックして指定します。例えば、"Bond" を1つ、"Angle" を1つ作ると、下のようになります。直接結合されていない原子を指定することもできます。
2179 </p>
2180 <p><img src="../etc/xtal_18.png" /></p>
2181 <p>
2182 計算結果を他のソフトウェアで使うためには(例えばワードプロセッサにペーストする場合)、表の行を選択して "Export to Clipboard" ボタンを押してください。計算結果はプレーンテキストでコピーされ、他のアプリケーションにペーストできるようになります。
2183 </p>
2184 <p><img src="../etc/xtal_19.png" /><img src="../etc/xtal_20.png" /></p>
2185 <p>
2186 "Best-Fit Planes" コマンドは、最適平面を計算し、二面角や原子・平面間距離を計算するのに使います。ダイアログが開いたら、指定したい原子をメインウィンドウで選択して "Set Current Selection" ボタンを押してください。
2187 </p>
2188 <p><img src="../etc/xtal_21.png" /></p>
2189
2190 <h3>2-5. ORTEP 描画</h3>
2191 <p>
2192 "Show ORTEP" コマンドは、下のようなウィンドウを開きます。
2193 </p>
2194 <p><img src="../etc/xtal_22.png" /></p>
2195 <p>
2196 ORTEP 描画は、ORTEP-III プログラムで作成しています。この結果を使う時には、下のように引用してください。
2197 </p>
2198 <ul>
2199 <li>
2200 Burnett, M. N.; Johnson, C. K. <i>ORTEP-III: Oak Ridge Thermal Ellipsoid Plot Program for Crystal Structure Illustrations,</i> Oak Ridge National Laboratory Report ORNL-6895, 1996.
2201 </li>
2202 </ul>
2203 <p>
2204 このウィンドウで、原子や結合の表示方法を指定することができます。分子の向きは、メインウィンドウでの向きとだいたい同じです(完全に同じとは言えませんが)。描画結果は、ORTEP 入力ファイルで書き出すことができます。また、グラフィックファイル(EPS, PNG, TIFF)で書き出すこともできます。ビットマップ型 (PNG, TIFF) で書き出す時には、解像度は 360 dpi になります。
2205 </p>
2206 <p><img src="../etc/xtal_23.png" /></p>
2207 </div>
2208 <link id="#navigation" />
2209 </div>
2210
2211 <div file="ruby.html">
2212 <link rel="Up" href="tutorials.html" />
2213 <link rel="Prev" href="xtal.html" />
2214 <link id="#header" />
2215 <div class="contents" lang="en">
2216 <h1>Step Eleven: Using Embedded Ruby Interpreter</h1>
2217 <p>
2218 One of the most useful features of Molby is the embedded Ruby interpreter. When working on molecular modeling, it is often necessary to modify the model according to some mathematical relations. It is also convenient if we can extract some molecular information by automated "scripts" (i.e. computer programs), and export as a text file that can be processed by graphing software. The embedded Ruby interpreter is very useful under these circumstances. Actually, many functions of Molby itself are implemented by Ruby scripts.
2219 </p>
2220 <p>
2221 To use the embedded Ruby interpreter in Molby, you need to be familiar with the Ruby programming language. You can find several good on-line tutorials in the Internet. However, you can also get the idea by going through the following sections.
2222 </p>
2223 <h2>1. Using the Ruby Console</h2>
2224 <p>
2225 The Ruby <i>console window</i> is open when Molby starts up.
2226 </p>
2227 <p><img src="../etc/ruby_01.png" /></p>
2228 <p>
2229 On this window, you can execute Ruby scripts in an interactive manner. Let us try something on it now. Make the console window active by clicking on it, and type "1+2" followed by hitting the Return key. You will find this:
2230 </p>
2231 <p class="code">% <span class="blue">1+2</span>
2232 <span class="red">--&gt; 3</span>
2233 %
2234 </p>
2235 <p>
2236 The Ruby interpreter calculated "1+2", and displayed the answer (3) in the following line.
2237 </p>
2238 <p>
2239 You can give a longer expression including parenthesis.
2240 </p>
2241 <p class="code">% <span class="blue">(13.0*13.0+7.0*7.0)/1.365</span>
2242 <span class="red">--&gt;159.70695970696</span>
2243 %
2244 </p>
2245 <p>
2246 Or use common mathematical functions.
2247 </p>
2248 <p class="code">% <span class="blue">exp(-2.0) * (sin(0.25) + cos(0.25))</span>
2249 <span class="red">--&gt;0.1646105219232536</span>
2250 %
2251 </p>
2252 <p class="note">Usually in Ruby, you need to say <code>Math.exp</code> or <code>Math.sin</code> when using these mathematical functions. In Molby, the prefix <code>Math</code> is not necessary, because Molby automatically "includes" the <code>Math</code> module on startup.</p>
2253 <p>
2254 You can also use <i>Strings</i>, which is a series of characters.
2255 </p>
2256 <p class="code">% <span class="blue">"C" + "32"</span>
2257 <span class="red">--&gt;"C32"</span>
2258 %
2259 </p>
2260 <p>
2261 The "32" here is not a number but a string, because it is surrounded by quotation marks. If you omit these quotation marks, what happens?
2262 </p>
2263 <p class="code">% <span class="blue">"C" + 32</span>
2264 </p>
2265 <p><img src="../etc/ruby_02.png" /></p>
2266 <p>
2267 Molby complains with this error dialog. It says "no implicit conversion of Fixnum into String," which means the integer 32 cannot be added to a string "C". Such kind of "type mismatch" error occurs very often, so please get used to it and learn how to fix it.
2268 </p>
2269 <p>
2270 Another useful feature of Ruby is an <i>Array</i>, which is an ordered collection of other Ruby objects. An array is expressed by comma-separated values surrounded by a pair of brackets.
2271 </p>
2272 <p class="code">% <span class="blue">[1, 2, 3]</span>
2273 <span class="red">--&gt;[1, 2, 3]</span>
2274 %
2275 </p>
2276 <p>
2277 Any Ruby object can be stored in a <i>variable</i>. The name of variables should begin with a lowercase alphabet and should consist of alphabets, number characters and underline "_".
2278 </p>
2279 <p class="code">% <span class="blue">a = ["apple", "orange", "grape"]</span>
2280 <span class="red">--&gt;["apple", "orange", "grape"]</span>
2281 % <span class="blue">a[0]</span>     <span class="comment"># This shows how to access the array elements</span>
2282 <span class="red">--&gt;"apple"</span>
2283 </p>
2284
2285 <h2>2. How to Handle Molecules in Molby Scripts</h2>
2286 <p>
2287 The examples so far used only built-in types (<code>Integer</code>, <code>String</code>, <code>Array</code>) in Ruby, but you will definitely need to handle <i>Molecules</i> from your Molby scripts. Suppose we have a benzene molecule (again).
2288 </p>
2289 <p><img src="../etc/ruby_03.png" /></p>
2290 <p>
2291 What if you want to convert it to chlorobenzene? There are two GUI ways; double-click on the H1 atom, and enter "Cl" into the dialog box, or double-click on the "H" text in the "element" column of the property table and change it to "Cl". But there is also a "Ruby" way, as follows:
2292 </p>
2293 <p class="code">% <span class="blue">atoms[1].element = "Cl"</span>
2294 <span class="red">--&gt;"Cl"</span>
2295 %
2296 </p>
2297 <p><img src="../etc/ruby_04.png" /></p>
2298 <p>
2299 This short piece of code implies some important concepts for coding in Molby. First, <code>atoms</code> denotes the atoms in the <i>current molecule</i>, which is the molecule in the frontmost window (except for the console window). <code>atoms</code> is not really an Array (as in the Ruby terminology), but can be used in a similar way as Array in many aspects. Specifically, it can be "indexed" to extract a specific atom.
2300 </p>
2301 <p class="code">atoms[i]   <span class="comment">#  Gives the i-th atom in the current molecule</span>
2302 </p>
2303 <p>
2304 Please make sure to say <code>atoms[i]</code>, not <code>atom[i]</code>. This may be confusing, but it is because <code>atoms</code> is a collection of atoms and <code>[]</code> denotes "extraction of the i-th element."
2305 </p>
2306 <p>
2307 The second point in the above example is <code>.element = "Cl"</code>. In Ruby, a period (<code>.</code>) followed by a word (<code>element</code>) indicates a "method call." <i>Method</i> is a technical term in Ruby programming language; it is a function that is specific to an object. In this case, <code>atoms[1]</code> is an object, and it has a method named <code>element=</code> (including the last equal sign) whose meaning is "to change the element as indicated by the string value in the right side." In this way, the script <code>atoms[1].element = "Cl"</code> causes the element of the atom 1 changed to chlorine.
2308 </p>
2309 <p>
2310 What if you want to change all hydrogen atoms to chlorine? Here is the code:
2311 </p>
2312 <p class="code">% <span class="blue">natoms.times { |i| if atoms[i].element == "H"; atoms[i].element = "Cl"; end }</span>
2313 <span class="red">--&gt;12</span>
2314 %
2315 </p>
2316 <p>
2317 This is far more complicated than the previous example. A step-by-step explanation follows.
2318 </p>
2319 <p>
2320 <code>natoms</code> gives the number of atoms in the current molecule as an integer number. This is actually a method call (<code>natoms</code> is a method of a <code>Molecule</code> object). Why a method is called even though no period is preceding the word? It is because Ruby has a feature called "implicit method call." This will be explained in more detail later.
2321 </p>
2322 <p class="code">natoms   <span class="comment"># Gives 12</span>
2323 </p>
2324 <p>
2325 <code>times</code> is a method of <code>Integer</code> (which is a built-in class of Ruby), which causes the following code surrounded by a pair of braces to be repeated the given number of times.
2326 </p>
2327 <p class="code">natoms.times { ... }   <span class="comment"># { ... } is executed 12 times</span>
2328 </p>
2329 <p class="note">The code within the braces is called <i>"block"</i> in Ruby terminology.</p>
2330 <p>
2331 In the repeated code (or <i>"block"</i>), it is very likely that you want to know "how many times have I repeated?" This is achieved by declaring a variable name at the top of the block, surrounded by two vertical bars.
2332 </p>
2333 <p class="code">natoms.times { |i| ... }   <span class="comment"># In { ... }, the variable i indicates the number of repeats</span>
2334 </p>
2335 <p>
2336 The following piece of codes is often used for testing. (<code>puts</code> prints the arguments to the console.)
2337 </p>
2338 <p class="code">% <span class="blue">natoms.times { |i| puts i }</span>
2339 0
2340 1
2341 2
2342 3
2343 4
2344 5
2345 6
2346 7
2347 8
2348 9
2349 10
2350 11
2351 <span class="red">--&gt;12</span>
2352 </p>
2353 <p>
2354 The "12" in the last line is the "result value" of the method <code>times</code>, and the numbers 0 to 11 are the outputs from the <code>puts</code> method. Now you can see the block was executed 12 times with changing the variable <code>i</code> from 0 to 11.
2355 </p>
2356 <p>
2357 In the block, there is an <code>if</code> statement:
2358 </p>
2359 <p class="code">if atoms[i].element == "H"; atoms[i].element = "Cl"; end
2360 </p>
2361 <p>
2362 The <code>if</code> statement has the following general form:
2363 </p>
2364 <p class="code">if <i>&lt;condition&gt;</i>; <i>&lt;statements&gt;</i>; end
2365 </p>
2366 <p>
2367 The <i>&lt;condition&gt;</i> is evaluated first, and if it is "true", the <i>&lt;statements&gt;</i> are executed; otherwise the <i>&lt;statements&gt;</i> are skipped.
2368 </p>
2369 <p>
2370 <i>Note:</i> Ruby interprets only <code>false</code> and <code>nil</code> as non-true values. Other values are all "true". Specifically, the number <code>0</code> (zero) and an empty string (<code>""</code>) are evaluated to "true" (this is unlike other programming language such as Perl). Many Ruby methods returns <code>nil</code> in case of failure; such methods are suitable for the condition part.
2371 </p>
2372 <p>
2373 Finally, the <code>element</code> method in the following code is different from the <code>element=</code> method that we previously used:
2374 </p>
2375 <p class="code">atoms[i].element == "H"
2376 </p>
2377 <p>
2378 In this case, the following symbol is "<code>==</code>", which means "are these equal?". This is distinct from the symbol "<code>=</code>", which means "the right side is assigned to the left side." The <code>element</code> symbol is interpreted as the <code>element=</code> method only when it is followed by the assignment symbol "<code>=</code>". The above code is not the case, so that it is interpreted as the <code>element</code> method, which returns the present element symbol as a <code>String</code>.
2379 </p>
2380 <p>
2381 After execution of the script, the molecule should look like this:
2382 </p>
2383 <p><img src="../etc/ruby_05.png" /></p>
2384
2385 <h2>3. About the "Implicit" Method Call</h2>
2386 <p>
2387 In the preceding section, we saw that <code>natoms</code> was a method of a <code>Molecule</code> object.
2388 </p>
2389 <p class="code">natoms     <span class="comment"># 12, in case of benzene</span>
2390 </p>
2391 <p>
2392 Why this symbol <code>natoms</code> is regarded as a method call? Actually, when the Ruby interpreter finds a symbol beginning with a lowercase alphabet, it looks for a (local) variable first, and if none is found, then it assumes that the symbol is a method belonging to the <i>"current object"</i>. Since Ruby is an object-oriented language, there is always a "current object", which is denoted as <code>self</code>. We can see it on our console:
2393 </p>
2394 <p class="code">% <span class="blue">self</span>
2395 <span class="red">--&gt;Molecule["unnamed1"]</span>
2396 %
2397 </p>
2398 <p>
2399 This piece of code indicates that the "current object" is a <code>Molecule</code> object. In fact, the <code>Molecule</code> object corresponding to the frontmost window becomes the "current object" when a script is executed on the Molby console. 
2400 </p>
2401 <p class="note">When no molecule is open, the "current object" is "main", which is the standard toplevel object in Ruby.</p>
2402 <p>
2403 Sometimes you happen to define a variable with the same name as a method of <code>Molecule</code>. In that case, access to the variable is preferred and the method is no longer called.
2404 </p>
2405 <p class="code">% <span class="blue">natoms = 2</span>    <span class="comment"># Define a variable</span>
2406 <span class="red">--&gt;2</span>
2407 % <span class="blue">natoms</span>    <span class="comment"># Now this is an access to the variable, not a method call</span>
2408 <span class="red">--&gt;2</span>
2409 %
2410 </p>
2411 <p>
2412 In this situation, you can explicitly request a method call by specifying <code>self</code>.
2413 </p>
2414 <p class="code">% <span class="blue">self.natoms</span>    <span class="comment"># This is a method call</span>
2415 <span class="red">--&gt;12</span>
2416 %
2417 </p>
2418 <p>
2419 A special case is the methods with the assignment symbol ("<code>=</code>"). For example, a method <code>show_hydrogens=</code> can control whether the hydrogen atoms are shown or not. However, without specifying <code>self</code>, the expression is always regarded as the assignment to a local variable. Therefore, <code>self</code> should be always explicitly given.
2420 </p>
2421 <p class="code">% <span class="blue">show_hydrogens = false</span>    <span class="comment"># This does not change the Molecule's state, just changes a local variable</span>
2422 <span class="red">--&gt;false</span>
2423 % <span class="blue">self.show_hydrogens = false</span>    <span class="comment"># This changes the Molecule's state</span>
2424 <span class="red">--&gt;false</span>
2425 %
2426 </p>
2427 <h2>4. Executing a Ruby Script on a File</h2>
2428 <p>
2429 From the Ruby console, you can only execute a one-line script. For more complex scripts, or if you want to use the script many times over, it will be more convenient to store the script in a file and execute it. The "Execute Script..." command in the "Script" menu does this job.
2430 </p>
2431 <p><img src="../etc/ruby_06.png" /></p>
2432 <p>
2433 There are endless possibilities for the script; here are presented only a few examples. The first script is to create a table of bond lengths including metal atoms (Fe):
2434 </p>
2435 <p class="code"><span class="comment">#  Create a bond table including Fe
2436 #  Requires Molby</span>
2437 fp = open("bond_table.txt", "w") <span class="comment">#  Create an output file</span>
2438 atoms.each { |ap|  <span class="comment">#  This is another way to repeat over all atoms;
2439                    #  ap points to the atom on each iteration</span>
2440   if ap.element == "Fe"
2441     r1 = ap.r               <span class="comment"># The cartesian coordinate of Fe</span>
2442     ap.connects.each { |n|  <span class="comment"># ap.connects is an array of atom indices connected to this atom</span>
2443       ap2 = atoms[n]        <span class="comment"># The atom connected to Fe</span>
2444       r2 = ap2.r            <span class="comment"># The cartesian coordinate of the atom</span>
2445       d = (r - r2).length   <span class="comment"># The bond length</span>
2446       fp.printf "%s-%s %.3f\n", ap.name, ap2.name, d <span class="comment"># Write a table entry to the file</span>
2447     }                       <span class="comment"># End loop (ap.connects)</span>
2448   end                       <span class="comment"># End if</span>
2449 }                           <span class="comment"># End loop (atoms.each)</span>
2450 fp.close                    <span class="comment"># We are done with this file</span>
2451 </p>
2452 <p>
2453 Save this text to a file, select "Execute Script..." command (be sure that the target molecule is on the front), and choose the script file. After execution, a file named "bond_table.txt" will be generated in the same directory as the script file.
2454 </p>
2455 <p>
2456 Here is another example, which works on a MD trajectory. For each frame, the molecule is reoriented so that the atom 0 is at the origin and atoms 1 and 2 are on the xy plane (with the atom 1 on the x-axis), and calculate the center of mass of the atoms 6 to 11. Such processing is useful to visualize how a particular part of the molecule moves around throughout the MD run.
2457 </p>
2458 <p class="code"><span class="comment">#  Reorient the molecule and extract center of some group
2459 #  Requires Molby</span>
2460 fp = open("extract_group.txt", "w") <span class="comment">#  Create an output file</span>
2461 each_frame { |n|  <span class="comment">#  This is an idiom to iterate over all frames</span>
2462   rotate_with_axis(1, 2, 0)  <span class="comment">#  Reorientation of the molecule is so frequently used
2463                              #  that the Molecule class has a method to do it</span>
2464   r = center_of_mass(6..11)  <span class="comment">#  Also has a method to calculate the center of mass</span>
2465   fp.printf "%d %.6f %.6f %.6f\n", n, r.x, r.y, r.z  <span class="comment">#  Write the coordinates</span>
2466 }
2467 fp.close                     <span class="comment">#  We are done with this file</span>
2468 </p>
2469 <p>
2470 The last example generates a model of carbon nanotube with any chirality and length as you like.
2471 </p>
2472 <p class="code"><span class="comment">#  Create a model of carbon nanotube
2473 #  Requires Molby</span>
2474 r = 1.42     <span class="comment">#  The C-C bond length</span>
2475 n = 10       <span class="comment">#  The default chirality index</span>
2476 m = 5        <span class="comment">#  (ibid)</span>
2477 aspect = 5.0 <span class="comment">#  The default aspect ratio (length / diameter)</span>
2478
2479 #  Dialog to ask the chirality index and the aspect ratio
2480 h = Dialog.run("Create Carbon Nanotube") {
2481   layout(3,
2482     item(:text, :title=&gt;"Chirality Index"),
2483     item(:textfield, :width=&gt;80, :tag=&gt;"n", :value=&gt;n.to_s),
2484     item(:textfield, :width=&gt;80, :tag=&gt;"m", :value=&gt;m.to_s),
2485     item(:text, :title=&gt;"Aspect Ratio"),
2486     item(:textfield, :width=&gt;160, :tag=&gt;"aspect", :value=&gt;sprintf("%.1f", aspect)),
2487     -1)
2488 }
2489
2490 exit if h[:status] != 0
2491 aspect = h["aspect"].to_f
2492 n = h["n"].to_i
2493 m = h["m"].to_i
2494
2495 k = aspect / (PI * sqrt(3.0))
2496 points = []
2497 <span class="comment">#  The limiting points are (0, 0), (n, m), (k(n+2m), -k(2n+m)), (k(n+2m)+n, -k(2n+m)+n)
2498 #  Search for the lattice points that are within the parallelogram
2499 #  surrounded by the above points
2500 #  det is the determinant of the matrix that converts the unit cell to the above parallelogram </span>
2501 delta = 2 * k * (n * n + m * m + n * m)
2502 (0..(k * (n + 2 * m) + n).ceil).each { |s|
2503   ((-k * (2 * n + m)).floor..m).each { |t|
2504     [0, 2.0/3.0].each { |d|   <span class="comment">#  For two lattice points within the unit cell</span>
2505       ss = (k * (2 * n + m) * (s + d) + k * (n + 2 * m) * (t + d)) / delta
2506       tt = (m * (s + d) - n * (t + d)) / delta
2507       if ss &gt;= 0.0 &amp;&amp; ss &lt; 1.0 &amp;&amp; tt &gt;= 0.0 &amp;&amp; tt &lt;= 1.0
2508         points.push([ss, tt, s, t])   <span class="comment">#  This point is within the parallelogram</span>
2509       end
2510     }
2511   }
2512 }
2513 <span class="comment">#  Create nanotube: line up [ss, tt] into cylindric shape</span>
2514 rad = sqrt(3.0) * r * sqrt(n * n + m * m + n * m) / (2 * PI)
2515 len = rad * 2 * aspect
2516 mol = Molecule.new
2517 points.each { |p|
2518   ap = mol.create_atom
2519   ap.element = "C"
2520   ap.atom_type = "ca"
2521   ap.r = [rad * cos(2 * PI * p[0]), rad * sin(2 * PI * p[0]), len * p[1]]
2522 }
2523 mol.guess_bonds
2524 <span class="comment">#  Show the result in a new window</span>
2525 mol2 = Molecule.open
2526 mol2.add(mol)
2527 </p>
2528 <p><img style="vertical-align: top;" src="../etc/ruby_07.png" /><img src="../etc/ruby_08.png" /></p>
2529
2530 <h2>5. Where to Go from Here</h2>
2531 <p>
2532 The embedded Ruby capability is very strong, and cannot be fully explained in this short tutorial. If you are interested, read carefully the <a href="ruby_ref.html">reference of the Ruby extension</a>. There are also many scripts in the Molby application, which you can examine by opening the "Scripts" folder (which is within the Application package in Mac OS X, and in the same folder as the Molby application in Windows).
2533 </p>
2534 </div>
2535 <div class="contents" lang="ja">
2536 <h1>第十一段階:組み込み Ruby インタプリタを使う</h1>
2537 <p>
2538 Molby の最も有用な機能の1つは、内蔵の Ruby インタプリタです。分子モデリングを行うとき、ある数学的な規則に従ってモデルを変更したいことがしばしばあります。また、分子のある種の情報を自動化された「スクリプト」(コンピュータプログラム)で抽出してテキストとして書き出し、グラフ描画ソフトウェアで処理することも有用です。内蔵 Ruby インタプリタは、このような場合に威力を発揮します。実は、Molby の機能の多くの部分は Ruby スクリプトで実装されているのです。
2539 </p>
2540 <p>
2541 Molby の内蔵 Ruby インタプリタを使うためには、プログラミング言語 Ruby の知識が必要です。インターネット上で良いオンラインチュートリアルを見つけてください。もっとも、以下の解説を読めば、ある程度のイメージはつかめるでしょう。
2542 </p>
2543 <h2>1. Ruby コンソールを使う</h2>
2544 <p>
2545 Molby が起動すると、Ruby の「コンソールウィンドウ」が開きます。
2546 </p>
2547 <p><img src="../etc/ruby_01.png" /></p>
2548 <p>
2549 このウィンドウ上で、Ruby スクリプトを対話的に実行することができます。いくつか試してみましょう。コンソールウィンドウをクリックしてアクティブにして、"1+2"、続いてリターンキーをタイプしてください。次のようになります。
2550 </p>
2551 <p class="code">% <span class="blue">1+2</span>
2552 <span class="red">--&gt; 3</span>
2553 %
2554 </p>
2555 <p>
2556 Ruby インタプリタが "1+2" を計算し、答え (3) を次の行に表示したところです。
2557 </p>
2558 <p>
2559 カッコを含む長い式も計算できます。
2560 </p>
2561 <p class="code">% <span class="blue">(13.0*13.0+7.0*7.0)/1.365</span>
2562 <span class="red">--&gt;159.70695970696</span>
2563 %
2564 </p>
2565 <p>
2566 数学関数も使うことができます。
2567 </p>
2568 <p class="code">% <span class="blue">exp(-2.0) * (sin(0.25) + cos(0.25))</span>
2569 <span class="red">--&gt;0.1646105219232536</span>
2570 %
2571 </p>
2572 <p class="note">通常 Ruby では、これらの数学関数を使うときには <code>Math.exp</code>, <code>Math.sin</code> のように書かなくてはなりません。Molby では、<code>Math</code> という接頭辞は必要ありません。これは Molby が起動時に <code>Math</code> モジュールを "include" するためです。</p>
2573 <p>
2574 文字列 <i>(Strings)</i> を使うこともできます。
2575 </p>
2576 <p class="code">% <span class="blue">"C" + "32"</span>
2577 <span class="red">--&gt;"C32"</span>
2578 %
2579 </p>
2580 <p>
2581 ここの "32" は数ではなく文字列です。引用符で囲まれているからです。引用符を省略するとどうなるでしょう?
2582 </p>
2583 <p class="code">% <span class="blue">"C" + 32</span>
2584 </p>
2585 <p><img src="../etc/ruby_02.png" /></p>
2586 <p>
2587 Molby はエラーメッセージ "no implicit conversion of Fixnum into String" を表示します。これは、「整数」32 を「文字列」"C" に足すことはできないことを意味しています。このような「型が違う」エラーはとてもよく起きるので、どのように直せばいいかをよく理解しておいてください。
2588 </p>
2589 <p>
2590 Ruby のもう1つの便利な機能は「配列」<i>(Array)</i> です。これは、他の Ruby オブジェクトを順番に並べたものです。配列は、値をコンマで区切って角括弧 [] で囲むことで表します。
2591 </p>
2592 <p class="code">% <span class="blue">[1, 2, 3]</span>
2593 <span class="red">--&gt;[1, 2, 3]</span>
2594 %
2595 </p>
2596 <p>
2597 Ruby のオブジェクトは「変数」に格納することができます。変数の名前は、小文字のアルファベットで始まり、数字またはアルファベット ("_" を含む) の並びでなくてはなりません。
2598 </p>
2599 <p class="code">% <span class="blue">a = ["apple", "orange", "grape"]</span>
2600 <span class="red">--&gt;["apple", "orange", "grape"]</span>
2601 % <span class="blue">a[0]</span>     <span class="comment"># 配列の要素を指定する</span>
2602 <span class="red">--&gt;"apple"</span>
2603 </p>
2604
2605 <h2>2. Molby スクリプトで分子を扱う</h2>
2606 <p>
2607 ここまでの例では、Ruby の組み込み型 <code>Integer</code>, <code>String</code>, <code>Array</code> を使ってきましたが、Molby スクリプトでは「分子」を扱うことが必要になります。ベンゼン分子があるとしましょう。
2608 </p>
2609 <p><img src="../etc/ruby_03.png" /></p>
2610 <p>
2611 これをクロロベンゼンに変えたいとします。グラフィックインターフェイスでは2つのやり方があります。H1原子をダブルクリックしてダイアログボックスに "Cl" と入力するか、属性テーブルの "element" のセルで "H" を "Cl" に変えます。これを Ruby スクリプトで行うには、次のようにします。
2612 </p>
2613 <p class="code">% <span class="blue">atoms[1].element = "Cl"</span>
2614 <span class="red">--&gt;"Cl"</span>
2615 %
2616 </p>
2617 <p><img src="../etc/ruby_04.png" /></p>
2618 <p>
2619 この短いコードに、Molby でのコーディングの重要な技法が含まれています。まず、<code>atoms</code> は「現在の分子」(コンソールウィンドウを除いて最も手前側にあるウィンドウの分子)に含まれる原子の並びを表します。<code>atoms</code> は Ruby の配列 (<code>Array</code>) ではありませんが、多くの点で配列と同じように使うことができます。特に、「添字」をつけて特定の原子を指定することができます。
2620 </p>
2621 <p class="code">atoms[i]   <span class="comment">#  現在の分子の i 番目の原子</span>
2622 </p>
2623 <p>
2624 <code>atom[i]</code> ではなく <code>atoms[i]</code> であることに注意してください。混乱しますが、これは <code>atoms</code> が原子の並びで <code>[]</code> が「…番目の要素を取り出す」という機能を表すためです。
2625 </p>
2626 <p>
2627 次は <code>.element = "Cl"</code> です。Ruby では、ピリオド (<code>.</code>) に続けて単語 (<code>element</code>) を書くと、「メソッド呼び出し」になります。「メソッド」とはプログラミング言語 Ruby の用語で、ある対象(オブジェクト)に固有の動作を指します。この場合は、<code>atoms[1]</code> がオブジェクトで、<code>element=</code> という名前のメソッドを持っています(最後の '=' を含みます)。このメソッドは、「その原子の元素記号を右辺の文字列で表されたものに変える」という働きをします。このようにして、スクリプト <code>atoms[1].element = "Cl"</code> は、原子1の元素記号を Cl に変えます。
2628 </p>
2629 <p>
2630 もし、全部の水素原子を塩素に変えたいとしたらどうでしょう? 次のようにします。
2631 </p>
2632 <p class="code">% <span class="blue">natoms.times { |i| if atoms[i].element == "H"; atoms[i].element = "Cl"; end }</span>
2633 <span class="red">--&gt;12</span>
2634 %
2635 </p>
2636 <p>
2637 これは前の例よりずっと複雑です。ステップごとに説明していきます。
2638 </p>
2639 <p>
2640 <code>natoms</code> は、現在の分子の原子数を整数で返します。これは実はメソッド呼び出しで、<code>Molecule</code> 型オブジェクトのメソッド <code>natoms</code> を呼んでいます。ピリオドがないのにメソッドが呼び出されているのはなぜでしょう? これは Ruby 言語の仕様に、「暗黙のメソッド呼び出し」があるためです。あとでもう少し詳しく説明します。
2641 </p>
2642 <p class="code">natoms   <span class="comment"># 12 となる</span>
2643 </p>
2644 <p>
2645 <code>times</code> は、<code>Integer</code> (これは Ruby の組み込み型です)のメソッドです。その後ろの中括弧 {} で囲まれたコードを、指定した回数実行します。
2646 </p>
2647 <p class="code">natoms.times { ... }   <span class="comment"># { ... } が 12 回実行される</span>
2648 </p>
2649 <p class="note">中括弧で囲んだコードを Ruby の用語で「ブロック」と呼びます。</p>
2650 <p>
2651 繰り返すコード(ブロック)の中で、「今実行しているのは何回目?」かを知りたいことがあります。このためには、ブロックの先頭で、2本の縦棒 "|" で囲んで変数を指定します。
2652 </p>
2653 <p class="code">natoms.times { |i| ... }   <span class="comment"># { ... } の中で、変数 i は繰り返し回数を表す</span>
2654 </p>
2655 <p>
2656 次のようなコードがテストのためによく使われます。(<code>puts</code> は与えられたオブジェクトをコンソールに出力します。)
2657 </p>
2658 <p class="code">% <span class="blue">natoms.times { |i| puts i }</span>
2659 0
2660 1
2661 2
2662 3
2663 4
2664 5
2665 6
2666 7
2667 8
2668 9
2669 10
2670 11
2671 <span class="red">--&gt;12</span>
2672 </p>
2673 <p>
2674 最後の行の "12" は、<code>times</code> メソッドの「戻り値」です。その上の 0 から 11 の数は、<code>puts</code> メソッドからの出力です。ブロックが 12 回実行され、変数 <code>i</code> が 0 から 11 まで変化したことがわかりますね。
2675 </p>
2676 <p>
2677 ブロックの中には、<code>if</code> 文があります。
2678 </p>
2679 <p class="code">if atoms[i].element == "H"; atoms[i].element = "Cl"; end
2680 </p>
2681 <p>
2682 <code>if</code> 文の一般形は次の通りです。
2683 </p>
2684 <p class="code">if <i>&lt;条件&gt;</i>; <i>&lt;実行文&gt;</i>; end
2685 </p>
2686 <p>
2687 まず <i>&lt;条件&gt;</i> が評価されます。それが「真」ならば、<i>&lt;実行文&gt;</i> が実行されます。条件が「真」でなければ、<i>&lt;実行文&gt;</i> はスキップされます。
2688 </p>
2689 <p>
2690 <i>注:</i> Ruby は <code>false</code> と <code>nil</code> だけを「真でない」値とします。その他の値はすべて「真」です。特に、数値の <code>0</code>(ゼロ)と空の文字列 (<code>""</code>) も「真」となります(これは Perl などの他のプログラミング言語とは異なります)。多くの Ruby メソッドは、失敗したときに nil を返します。これらのメソッドは条件部分にそのまま使えます。
2691 </p>
2692 <p>
2693 最後に出てくる <code>element</code> メソッドは、先に出て来た <code>element=</code> メソッドとは違います。
2694 </p>
2695 <p class="code">atoms[i].element == "H"
2696 </p>
2697 <p>
2698 この場合は、<code>element</code> の次に来る記号は "<code>==</code>" で、これは「2つの値は等しいか?」という意味です。この記号は "<code>=</code>" とは違います。後者は「右辺を左辺に代入する」という意味です。<code>element</code> という記号は、その次に "<code>=</code>" 記号が来るときに限って、"<code>element=</code>" メソッドとして解釈されます。この場合はそうではないので、<code>element</code> メソッドが呼び出されます。このメソッドは、現在の元素記号を <code>String</code> (文字列)として返します。
2699 </p>
2700 <p>
2701 スクリプトを実行したら、分子は次のようになるはずです。
2702 </p>
2703 <p><img src="../etc/ruby_05.png" /></p>
2704
2705 <h2>3. 暗黙のメソッド呼び出し</h2>
2706 <p>
2707 前の節で、<code>natoms</code> は <code>Molecule</code> オブジェクトのメソッドであることを学びました。
2708 </p>
2709 <p class="code">natoms     <span class="comment"># 12 (ベンゼンの場合)</span>
2710 </p>
2711 <p>
2712 なぜこの <code>natoms</code> はメソッド呼び出しと見なされるのでしょう? 実は、Ruby インタプリタ(Ruby スクリプトを実行するプログラム)は小文字のアルファベットで始まる単語を見つけると、まず変数(ローカル変数)を探し、それが見つからなければ「現在のオブジェクト」に属するメソッドであると見なすのです。Ruby は「オブジェクト指向言語」なので、Ruby スクリプトの実行中は必ず「現在のオブジェクト」が存在しています。これを <code>self</code> と呼びます。コンソールで試してみましょう:
2713 </p>
2714 <p class="code">% <span class="blue">self</span>
2715 <span class="red">--&gt;Molecule["unnamed1"]</span>
2716 %
2717 </p>
2718 <p>
2719 この結果は、「現在のオブジェクト」が "unnamed1" という分子を表す <code>Molecule</code> オブジェクトであることを示しています。Molby コンソールでスクリプトを実行する時は、最前面にあるウィンドウの分子に対応する <code>Molecule</code> オブジェクトが「現在のオブジェクト」になります。
2720 </p>
2721 <p class="note">分子のウィンドウが1つも開いていない時は、現在のオブジェクトは <code>main</code> になります。これは Ruby 起動時の「現在のオブジェクト」と同じものです。</p>
2722 <p>
2723 ときどき、<code>Molecule</code> が持つメソッド名と同じ名前の変数を作ってしまうことがあります。この場合、変数へのアクセスが優先されますので、メソッドを呼び出すことはできなくなります。
2724 </p>
2725 <p class="code">% <span class="blue">natoms = 2</span>    <span class="comment"># 変数 natoms を定義</span>
2726 <span class="red">--&gt;2</span>
2727 % <span class="blue">natoms</span>    <span class="comment"># これは変数へのアクセスになり、メソッド呼び出しではない</span>
2728 <span class="red">--&gt;2</span>
2729 %
2730 </p>
2731 <p>
2732 この場合でも、<code>self</code> を指定すればメソッドを呼び出すことができます。
2733 </p>
2734 <p class="code">% <span class="blue">self.natoms</span>    <span class="comment"># これはメソッド呼び出し</span>
2735 <span class="red">--&gt;12</span>
2736 %
2737 </p>
2738 <p>
2739 特に注意が必要なのは、代入記号 ("<code>=</code>") を持つメソッドです。例えば、<code>show_hydrogens=</code> というメソッドは、水素原子を表示するかどうかを指定するものです。しかし、<code>self</code> を使わないと、ローカル変数への代入になってしまいます。従って、この場合は常に <code>self</code> を指定する必要があります。
2740 </p>
2741 <p class="code">% <span class="blue">show_hydrogens = false</span>    <span class="comment"># これはローカル変数への代入で、分子の状態は変わらない</span>
2742 <span class="red">--&gt;false</span>
2743 % <span class="blue">self.show_hydrogens = false</span>    <span class="comment"># これはメソッド呼び出しで、分子の状態を変える</span>
2744 <span class="red">--&gt;false</span>
2745 %
2746 </p>
2747 <h2>4. ファイル上の Ruby スクリプトを実行する</h2>
2748 <p>
2749 Ruby コンソール上では、1行のスクリプトしか実行できません。もっと複雑なスクリプトを実行したい時や、同じスクリプトを何度も実行したい時は、ファイルにスクリプトを格納して実行する方が便利です。"Script" メニューの "Execute Script..." コマンドでこれが実現できます。
2750 </p>
2751 <p><img src="../etc/ruby_06.png" /></p>
2752 <p>
2753 スクリプトには無限の可能性があります。いくつかの例をここに示します。最初のものは、「鉄原子を含む結合長のテーブルを作る」スクリプトです。
2754 </p>
2755 <p class="code"><span class="comment">#  Create a bond table including Fe
2756 #  Requires Molby</span>
2757 fp = open("bond_table.txt", "w") <span class="comment">#  Create an output file</span>
2758 atoms.each { |ap|  <span class="comment">#  This is another way to repeat over all atoms;
2759                    #  ap points to the atom on each iteration</span>
2760   if ap.element == "Fe"
2761     r1 = ap.r               <span class="comment"># The cartesian coordinate of Fe</span>
2762     ap.connects.each { |n|  <span class="comment"># ap.connects is an array of atom indices connected to this atom</span>
2763       ap2 = atoms[n]        <span class="comment"># The atom connected to Fe</span>
2764       r2 = ap2.r            <span class="comment"># The cartesian coordinate of the atom</span>
2765       d = (r - r2).length   <span class="comment"># The bond length</span>
2766       fp.printf "%s-%s %.3f\n", ap.name, ap2.name, d <span class="comment"># Write a table entry to the file</span>
2767     }                       <span class="comment"># End loop (ap.connects)</span>
2768   end                       <span class="comment"># End if</span>
2769 }                           <span class="comment"># End loop (atoms.each)</span>
2770 fp.close                    <span class="comment"># We are done with this file</span>
2771 </p>
2772 <p>
2773 このテキストをファイルに保存し、"Execute Script..." コマンドを実行し(目的の分子が一番前のウィンドウに表示されていることを確かめて)、スクリプトファイルを選びます。実行後、"bond_table.txt" というファイルが、スクリプトファイルと同じディレクトリに作成されています。
2774 </p>
2775 <p>
2776 次の例は、MD トラジェクトリを処理するものです。各フレームに対して、原子 0 が原点、原子 1, 2 が xy 平面上(原子 1 が x 軸上)に来るように分子を再配向して、原子 6 から 11 の重心を計算します。このような処理は、MD の結果分子のある部分がどのように動くかを可視化するのに便利です。
2777 </p>
2778 <p class="code"><span class="comment">#  Reorient the molecule and extract center of some group
2779 #  Requires Molby</span>
2780 fp = open("extract_group.txt", "w") <span class="comment">#  Create an output file</span>
2781 each_frame { |n|  <span class="comment">#  This is an idiom to iterate over all frames</span>
2782   rotate_with_axis(1, 2, 0)  <span class="comment">#  Reorientation of the molecule is so frequently used
2783                              #  that the Molecule class has a method to do it</span>
2784   r = center_of_mass(6..11)  <span class="comment">#  Also has a method to calculate the center of mass</span>
2785   fp.printf "%d %.6f %.6f %.6f\n", n, r.x, r.y, r.z  <span class="comment">#  Write the coordinates</span>
2786 }
2787 fp.close                     <span class="comment">#  We are done with this file</span>
2788 </p>
2789 <p>
2790 最後の例は、任意のキラリティ・長さのカーボンナノチューブのモデルを作成するスクリプトです。
2791 </p>
2792 <p class="code"><span class="comment">#  Create a model of carbon nanotube
2793 #  Requires Molby</span>
2794 r = 1.42     <span class="comment">#  The C-C bond length</span>
2795 n = 10       <span class="comment">#  The default chirality index</span>
2796 m = 5        <span class="comment">#  (ibid)</span>
2797 aspect = 5.0 <span class="comment">#  The default aspect ratio (length / diameter)</span>
2798
2799 #  Dialog to ask the chirality index and the aspect ratio
2800 h = Dialog.run("Create Carbon Nanotube") {
2801   layout(3,
2802     item(:text, :title=&gt;"Chirality Index"),
2803     item(:textfield, :width=&gt;80, :tag=&gt;"n", :value=&gt;n.to_s),
2804     item(:textfield, :width=&gt;80, :tag=&gt;"m", :value=&gt;m.to_s),
2805     item(:text, :title=&gt;"Aspect Ratio"),
2806     item(:textfield, :width=&gt;160, :tag=&gt;"aspect", :value=&gt;sprintf("%.1f", aspect)),
2807     -1)
2808 }
2809
2810 exit if h[:status] != 0
2811 aspect = h["aspect"].to_f
2812 n = h["n"].to_i
2813 m = h["m"].to_i
2814
2815 k = aspect / (PI * sqrt(3.0))
2816 points = []
2817 <span class="comment">#  The limiting points are (0, 0), (n, m), (k(n+2m), -k(2n+m)), (k(n+2m)+n, -k(2n+m)+n)
2818 #  Search for the lattice points that are within the parallelogram
2819 #  surrounded by the above points
2820 #  det is the determinant of the matrix that converts the unit cell to the above parallelogram </span>
2821 delta = 2 * k * (n * n + m * m + n * m)
2822 (0..(k * (n + 2 * m) + n).ceil).each { |s|
2823   ((-k * (2 * n + m)).floor..m).each { |t|
2824     [0, 2.0/3.0].each { |d|   <span class="comment">#  For two lattice points within the unit cell</span>
2825       ss = (k * (2 * n + m) * (s + d) + k * (n + 2 * m) * (t + d)) / delta
2826       tt = (m * (s + d) - n * (t + d)) / delta
2827       if ss &gt;= 0.0 &amp;&amp; ss &lt; 1.0 &amp;&amp; tt &gt;= 0.0 &amp;&amp; tt &lt;= 1.0
2828         points.push([ss, tt, s, t])   <span class="comment">#  This point is within the parallelogram</span>
2829       end
2830     }
2831   }
2832 }
2833 <span class="comment">#  Create nanotube: line up [ss, tt] into cylindric shape</span>
2834 rad = sqrt(3.0) * r * sqrt(n * n + m * m + n * m) / (2 * PI)
2835 len = rad * 2 * aspect
2836 mol = Molecule.new
2837 points.each { |p|
2838   ap = mol.create_atom
2839   ap.element = "C"
2840   ap.atom_type = "ca"
2841   ap.r = [rad * cos(2 * PI * p[0]), rad * sin(2 * PI * p[0]), len * p[1]]
2842 }
2843 mol.guess_bonds
2844 <span class="comment">#  Show the result in a new window</span>
2845 mol2 = Molecule.open
2846 mol2.add(mol)
2847 </p>
2848 <p><img style="vertical-align: top;" src="../etc/ruby_07.png" /><img src="../etc/ruby_08.png" /></p>
2849
2850 <h2>5. 次に学ぶべきこと</h2>
2851 <p>
2852 組み込み Ruby インタプリタは非常に強力であるため、この短いチュートリアルでは説明しきれません。興味があるなら、<a href="ruby_ref.html">Ruby 拡張のリファレンス</a> に目を通してください。また、Molby アプリケーション本体にはたくさんの Ruby スクリプトが内蔵されています。"Scripts" フォルダを参照してください(Mac OS X では Molby アプリケーションパッケージの中、Windows では Molby アプリケーションと同じフォルダにあります)。
2853 </p>
2854 </div>
2855 <link id="#navigation" />
2856 </div>
2857
2858 <div file="appendix.html">
2859 <link rel="Up" href="index.html" />
2860 <link rel="Prev" href="tutorials.html" />
2861 <link id="#header" />
2862 <div class="contents" lang="en">
2863 <h1>Appendix</h1>
2864 <link id="#toc" />
2865 </div>
2866 <div class="contents" lang="ja">
2867 <h1>付録</h1>
2868 <link id="#toc" />
2869 </div>
2870 <link id="#navigation" />
2871 </div>
2872
2873 <div file="ruby_ref.html">
2874 <link rel="Up" href="appendix.html" />
2875 <link id="#header" />
2876 <div class="contents" lang="en">
2877 <h1>Ruby Extension Reference</h1>
2878 <p>
2879 The following classes/module/exception are defined in the embedded Ruby interpreter in Molby. The methods defined in the module <code>Kernel</code> can be used as if they are builtin functions, like in the standard Ruby interpreter. All other classes and <code>MolbyError</code> exception are defined under the a module <code>Molby</code>. However, <code>Molby::</code> prefix is not necessary because <code>include Molby</code> is invoked on startup.
2880 </p>
2881 <p class="note">
2882 On startup, <code>include Math</code> is also invoked, so that the methods and constants in the <code>Math</code> module can also be used without prefix.
2883 </p>
2884 <p>
2885 It is recommended for you to read the document of the most important class <a href="molby_rb/Molecule.html">Molecule</a>. Follow the links as necessary, and you will understand how other classes are defined and used.
2886 </p>
2887 <h3 class="section-bar">Classes</h3>
2888 <ul>
2889 <li><a href="molby_rb/AtomRef.html">AtomRef</a></li>
2890 <li><a href="molby_rb/Dialog.html">Dialog</a></li>
2891 <li><a href="molby_rb/DialogItem.html">DialogItem</a></li>
2892 <li><a href="molby_rb/IntGroup.html">IntGroup</a></li>
2893 <li><a href="molby_rb/LAMatrix.html">LAMatrix</a></li>
2894 <li><a href="molby_rb/MDArena.html">MDArena</a></li>
2895 <li><a href="molby_rb/MolEnumerable.html">MolEnumerable</a></li>
2896 <li><a href="molby_rb/Molecule.html">Molecule</a></li>
2897 <li><a href="molby_rb/Parameter.html">Parameter</a></li>
2898 <li><a href="molby_rb/ParameterRef.html">ParameterRef</a></li>
2899 <li><a href="molby_rb/ParEnumerable.html">ParEnumerable</a></li>
2900 <li><a href="molby_rb/Transform.html">Transform</a></li>
2901 <li><a href="molby_rb/Vector3D.html">Vector3D</a></li>
2902 </ul>
2903 <h3 class="section-bar">Module</h3>
2904 <ul>
2905 <li><a href="molby_rb/Kernel.html">Kernel</a></li>
2906 <li><a href="molby_rb/MolbyModule.html">Molby</a></li>
2907 </ul>
2908 <h3 class="section-bar">Exception</h3>
2909 <ul>
2910 <li><a href="molby_rb/MolbyError.html">MolbyError</a></li>
2911 </ul>
2912 </div>
2913 <div class="contents" lang="ja">
2914 <h1>Ruby 拡張リファレンス</h1>
2915 <p>
2916 以下のクラス/モジュール/例外が Molby 内蔵の Ruby インタプリタに組み込まれています。<code>Kernel</code> モジュールのメソッドは、通常の Ruby インタプリタと同様に組み込み関数のように使うことができます。その他のクラスと <code>MolbyError</code> 例外は <code>Molby</code> モジュールの下に定義されています。ただし、起動時に <code>include Molby</code> が呼び出されるため、<code>Molby::</code> 接頭辞は必要ありません。
2917 </p>
2918 <p class="note">
2919 起動時には <code>include Math</code> も呼び出されるため、<code>Math</code> モジュールのメソッドや定数も接頭辞なしで使うことができます。
2920 </p>
2921 <p>
2922 最も重要なクラスは <a href="molby_rb/Molecule.html">Molecule</a> なので、このドキュメントを最初に読むことをお勧めします。ここから必要に応じてリンクをたどっていけば、他のクラスがどのように定義され使われるかが理解しやすくなります。
2923 </p>
2924 <h3 class="section-bar">Classes</h3>
2925 <ul>
2926 <li><a href="molby_rb/AtomRef.html">AtomRef</a></li>
2927 <li><a href="molby_rb/Dialog.html">Dialog</a></li>
2928 <li><a href="molby_rb/DialogItem.html">DialogItem</a></li>
2929 <li><a href="molby_rb/IntGroup.html">IntGroup</a></li>
2930 <li><a href="molby_rb/LAMatrix.html">LAMatrix</a></li>
2931 <li><a href="molby_rb/MDArena.html">MDArena</a></li>
2932 <li><a href="molby_rb/MolEnumerable.html">MolEnumerable</a></li>
2933 <li><a href="molby_rb/Molecule.html">Molecule</a></li>
2934 <li><a href="molby_rb/Parameter.html">Parameter</a></li>
2935 <li><a href="molby_rb/ParameterRef.html">ParameterRef</a></li>
2936 <li><a href="molby_rb/ParEnumerable.html">ParEnumerable</a></li>
2937 <li><a href="molby_rb/Transform.html">Transform</a></li>
2938 <li><a href="molby_rb/Vector3D.html">Vector3D</a></li>
2939 </ul>
2940 <h3 class="section-bar">Module</h3>
2941 <ul>
2942 <li><a href="molby_rb/Kernel.html">Kernel</a></li>
2943 <li><a href="molby_rb/MolbyModule.html">Molby</a></li>
2944 </ul>
2945 <h3 class="section-bar">Exception</h3>
2946 <ul>
2947 <li><a href="molby_rb/MolbyError.html">MolbyError</a></li>
2948 </ul>
2949 </div>
2950 <link id="#navigation" />
2951 </div>
2952
2953 <div file="filter_kit_howto.html">
2954 <link rel="Up" href="appendix.html" />
2955 <link rel="Prev" href="ruby_ref.html" />
2956 <link id="#header" />
2957 <div class="contents" lang="en">
2958 <h1>Filter Kit How-to</h1>
2959 <p>
2960 In the research of chemistry, we sometimes a simple processing of text files. Ruby is particularly suitable for such purposes. To make the use of Ruby easier, Molby provides a special capability called "filter kit" (version 0.6.4 and later). The name originates from the "UNIX" culture, where small programs for text processing are called "filters".
2961 </p>
2962 <p>
2963 Here is a description of making a filter script. As a demonstration, the filter here is a very simple function; it appends a sequential line number on each line.
2964 </p>
2965 <p><img src="../etc/filter_01.png" />&nbsp;&nbsp;&nbsp;<img src="../etc/filter_02.png" /></p>
2966 <p>
2967 To write a filter, we create a new text file, with extention ".rb" or ".mrb". Former is conventional as a Ruby script, but latter may be useful to specify Ruby scripts for Molby.
2968 </p>
2969 <p>
2970 We start from the following line:
2971 </p>
2972 <p class="code">Dialog.filter_kit("Filter Sample", "This is a sample filter.") { |args|
2973 </p>
2974 <p>
2975 The method <code>Dialog.filter_kit</code> takes two arguments, the window title and the message. It also requires a block, which actually contains the main program.
2976 </p>
2977 <p>
2978 When the user presses the "Select Files" button and choose files (which can be multiple), the block is executed with the array of the chosen file names as the argument. The block body is written as follows:
2979 </p>
2980 <p class="code"><span class="linenumber">  1 </span> Dialog.filter_kit("Filter Sample", "This is a sample filter.") { |args|
2981 <span class="linenumber">  2 </span>   args.each { |fname|
2982 <span class="linenumber">  3 </span>    fp = open(fname, "r")
2983 <span class="linenumber">  4 </span>    if fp == nil
2984 <span class="linenumber">  5 </span>      error_message_box("Cannot open file: #{arg}")
2985 <span class="linenumber">  6 </span>      next
2986 <span class="linenumber">  7 </span>    end
2987 <span class="linenumber">  8 </span>    puts fname
2988 <span class="linenumber">  9 </span>    a = fp.readlines
2989 <span class="linenumber"> 10 </span>    fp.close
2990 <span class="linenumber"> 11 </span>    File.rename(fname, fname + "~")
2991 <span class="linenumber"> 12 </span>    fp2 = open(fname, "w")
2992 <span class="linenumber"> 13 </span>    a.each_with_index { |ln, n|
2993 <span class="linenumber"> 14 </span>      ln = (n + 1).to_s + "  " + ln
2994 <span class="linenumber"> 15 </span>      fp2.print ln
2995 <span class="linenumber"> 16 </span>    }
2996 <span class="linenumber"> 17 </span>    fp2.close
2997 <span class="linenumber"> 18 </span>  }
2998 </p>
2999 <ul>
3000 <li>Line 2: The code in the following braces (<code>{}</code>) is repeated over all files.</li>
3001 <li>Line 3: Open the file for reading.</li>
3002 <li>Lines 4-7: If the file cannot be opened, then show the error message and continue to the next file.</li>
3003 <li>Line 8: Display the filename as information. The output will be displayed in the text box within the filter dialog.</li>
3004 <li>Line 9: Read all lines from the file and store in an array.</li>
3005 <li>Line 10: Now we are done with this file, so close the file.</li>
3006 <li>Line 11: Rename the file name with a tilda (~) at the end. (It is also possible to change the extension, for example; however, you need to learn about "regular expression" to write the code.)</li>
3007 <li>Line 12: Open the file with the same name, this time for writing. We also need error handling for this operation as in line 4-7, which is omitted here for clarity.</li>
3008 <li>Line 13: Repeat the following block (the code in the braces) for all elements in the array. The element and its index are given to the block as <code>ln</code> and <code>n</code>, respectively.</li>
3009 <li>Line 14: Append the line number. <code>(n + 1)</code> denotes the line number (because the array index begins with zero), and <code>to_s</code> generates a String object from an Integer.</li>
3010 <li>Line 15: Write the line to the file.</li>
3011 <li>Line 17: Close the file.</li>
3012 </ul>
3013 <p>
3014 The above text is saved as "filter_sample.rb" (the filename can be arbitrary except for the extension). Open it with Molby, and you will get the filter running.
3015 </p>
3016 </div>
3017 <div class="contents" lang="ja">
3018 <h1>Filter Kit の使い方</h1>
3019 <p>
3020 化学の研究では、テキストファイルに簡単な処理を加えたいことがときどきあります。Ruby はこの目的に特に適しています。Ruby を簡単に使えるようにするため、Molby は "filter kit" という特別な機能を持っています(バージョン 0.6.4 以降)。Filter という名前は "UNIX" の文化から来ており、テキストを処理する小さなプログラムのことを指します。
3021 </p>
3022 <p>
3023 以下にフィルタスクリプトの作り方を解説します。説明のため、ごく単純な機能を持ったものを作ります。ファイルの各行に行番号をつけるものです。
3024 </p>
3025 <p><img src="../etc/filter_01.png" />&nbsp;&nbsp;&nbsp;<img src="../etc/filter_02.png" /></p>
3026 <p>
3027 フィルタを書くためには、新しいテキストファイルを作って、拡張子を ".rb" か ".mrb" とします。前者が Ruby スクリプトとして一般的なものですが、後者は Molby 専用のスクリプトを示すために使うことができます。
3028 </p>
3029 <p>
3030 まず次の行から始めます。
3031 </p>
3032 <p class="code">Dialog.filter_kit("Filter Sample", "This is a sample filter.") { |args|
3033 </p>
3034 <p>
3035 <code>Dialog.filter_kit</code> というメソッドは2つの引数をとります。ウィンドウのタイトルと、メッセージです。この他にブロックが必要で、その中にメインプログラムを置きます。
3036 </p>
3037 <p>
3038 フィルタのユーザーが "Select Files" ボタンでファイルを選ぶと(複数のファイルを選択できます)、ブロックが実行され、選択されたファイル名の配列 (Array) が引数として渡されます。ブロックの本体は次のように書きます。
3039 </p>
3040 <p class="code"><span class="linenumber">  1 </span> Dialog.filter_kit("Filter Sample", "This is a sample filter.") { |args|
3041 <span class="linenumber">  2 </span>   args.each { |fname|
3042 <span class="linenumber">  3 </span>    fp = open(fname, "r")
3043 <span class="linenumber">  4 </span>    if fp == nil
3044 <span class="linenumber">  5 </span>      error_message_box("Cannot open file: #{arg}")
3045 <span class="linenumber">  6 </span>      next
3046 <span class="linenumber">  7 </span>    end
3047 <span class="linenumber">  8 </span>    puts fname
3048 <span class="linenumber">  9 </span>    a = fp.readlines
3049 <span class="linenumber"> 10 </span>    fp.close
3050 <span class="linenumber"> 11 </span>    File.rename(fname, fname + "~")
3051 <span class="linenumber"> 12 </span>    fp2 = open(fname, "w")
3052 <span class="linenumber"> 13 </span>    a.each_with_index { |ln, n|
3053 <span class="linenumber"> 14 </span>      ln = (n + 1).to_s + "  " + ln
3054 <span class="linenumber"> 15 </span>      fp2.print ln
3055 <span class="linenumber"> 16 </span>    }
3056 <span class="linenumber"> 17 </span>    fp2.close
3057 <span class="linenumber"> 18 </span>  }
3058 </p>
3059 <ul>
3060 <li>2行: 以下のブレース (<code>{}</code>) 内のコードを各ファイルに対して繰り返します。</li>
3061 <li>3行: ファイルを読み取り用にオープンします。</li>
3062 <li>4-7行: ファイルがオープンできなければ、エラーメッセージを表示して、次のファイルに進みます。</li>
3063 <li>8行: ファイル名を表示します。出力は、ダイアログの中のテキストボックスに表示されます。</li>
3064 <li>9行: ファイルのすべての行を読み込んで配列に格納します。</li>
3065 <li>10行: 読み込みが終わったので、ファイルを閉じます。</li>
3066 <li>11行: ファイル名の後ろにチルダ (~) をつけます。(たとえば拡張子を変更する、などの処理も可能ですが、コードを書くには「正規表現」を学ぶ必要があります。)</li>
3067 <li>12行: ファイルを同じ名前で、今度は書き込み用にオープンします。本当は 4-7 行と同じようにエラー処理が必要ですが、ここでは簡単のため省略してあります。</li>
3068 <li>13行: 以下のブロック(ブレース内のコード)を配列内のすべての要素(つまりすべての行)について繰り返します。配列要素(つまりそれぞれの行)とそのインデックスがそれぞれ <code>ln</code> and <code>n</code> としてブロックに渡されます。</li>
3069 <li>14行: 行番号をつけます。<code>(n + 1)</code> が行番号になります(インデックスは0から始まるため)。<code>to_s</code> は整数を文字列に変換します。</li>
3070 <li>15行: 行をファイルに書き出します。</li>
3071 <li>17行: ファイルを閉じて書き込みを完結します。</li>
3072 </ul>
3073 <p>
3074 上のテキストを "filter_sample.rb" として保存します(拡張子が正しければ、ファイル名は何でも構いません)。このファイルを Molby で開けば、フィルタとして使うことができます。
3075 </p>
3076 </div>
3077 <link id="#navigation" />
3078 </div>
3079
3080 </body>
3081 </html>