• R/O
  • SSH
  • HTTPS

molby: Commit


Commit MetaInfo

Revision66 (tree)
Time2011-07-03 00:24:26
Authortoshinagata1964

Log Message

Gaff and parm99 parameters: the equilibrium bond lengths have now three significant digits after the decimal point. Ruby: AtomRef#exclusion method is implemented. MM/MD: minimization sometimes caused crash. Hopefully fixed.

Change Summary

Incremental Difference

--- trunk/Scripts/md.rb (revision 65)
+++ trunk/Scripts/md.rb (revision 66)
@@ -583,6 +583,88 @@
583583 }
584584 end
585585
586+ def export_ac(acfile)
587+ open(acfile, "w") { |fp|
588+ charge = 0.0
589+ each_atom { |ap|
590+ charge += ap.charge
591+ }
592+ fp.printf "CHARGE %6.3f\n", charge
593+ form = []
594+ each_atom { |ap|
595+ form[ap.atomic_number] = (form[ap.atomic_number] || 0) + 1
596+ }
597+ fp.print "Formula: "
598+ form.each_with_index { |n, i|
599+ if n != nil
600+ fp.print Parameter.builtin.elements[i].name + n.to_s
601+ end
602+ }
603+ fp.print "\n"
604+ each_atom { |ap|
605+ fp.printf "ATOM %6d %-4s%3.3s 1 %8.3f%8.3f%8.3f%10.5f %-4s %s\n", ap.index + 1, ap.name, ap.res_name, ap.x, ap.y, ap.z, ap.charge, ap.atom_type, ap.name
606+ }
607+ bonds.each_with_index { |bd, i|
608+ n1, n2 = bd
609+ fp.printf "BOND%5d%5d%5d%5d %4s%4s\n", i + 1, n1 + 1, n2 + 1, 0, atoms[n1].name, atoms[n2].name
610+ }
611+ }
612+ end
613+
614+ def export_frcmod(frcfile)
615+ p = self.parameter
616+ open(frcfile, "w") { |fp|
617+ fp.print "remark goes here\n"
618+ fp.print "MASS\n"
619+ p.vdws.each { |np|
620+ if np.source != "gaff" && np.source != "parm99"
621+ fp.printf "%s %10.5f %s\n", np.atom_type, np.weight, np.comment
622+ end
623+ }
624+ fp.print "\n"
625+ fp.print "BOND\n"
626+ p.bonds.each { |bp|
627+ if bp.source != "gaff" && bp.source != "parm99"
628+ types = sprintf("%-2s-%-2s", bp.atom_types[0], bp.atom_types[1])
629+ fp.printf "%s %6.3f %7.3f %s\n", types, bp.k, bp.r0, bp.comment
630+ end
631+ }
632+ fp.print "\n"
633+ fp.print "ANGLE\n"
634+ p.angles.each { |ap|
635+ if ap.source != "gaff" && ap.source != "parm99"
636+ types = sprintf("%-2s-%-2s-%-2s", ap.atom_types[0], ap.atom_types[1], ap.atom_types[2])
637+ fp.printf "%s %7.3f %7.3f %s\n", types, ap.k, ap.a0, ap.comment
638+ end
639+ }
640+ fp.print "\n"
641+ fp.print "DIHE\n"
642+ p.dihedrals.each { |dp|
643+ if dp.source != "gaff" && dp.source != "parm99"
644+ types = sprintf("%-2s-%-2s-%-2s-%-2s", dp.atom_types[0], dp.atom_types[1], dp.atom_types[2], dp.atom_types[3])
645+ fp.printf "%s %d %6.3f %7.3f %6.3f %s\n", types, dp.mult, dp.k, dp.phi0, dp.period, dp.comment
646+ end
647+ }
648+ fp.print "\n"
649+ fp.print "IMPROPER\n"
650+ p.impropers.each { |dp|
651+ if dp.source != "gaff" && dp.source != "parm99"
652+ types = sprintf("%-2s-%-2s-%-2s-%-2s", dp.atom_types[0], dp.atom_types[1], dp.atom_types[2], dp.atom_types[3])
653+ fp.printf "%s %6.2f %7.3f %6.2f %s\n", types, dp.k, dp.phi0, dp.period, dp.comment
654+ end
655+ }
656+ fp.print "\n"
657+ fp.print "NONBON\n"
658+ p.vdws.each { |np|
659+ if np.source != "gaff" && np.source != "parm99"
660+ types = sprintf("%2s", np.atom_types[0])
661+ fp.printf "%s %10.5f %10.5f %s\n", np.atom_type, np.r_eq, np.eps, np.comment
662+ end
663+ }
664+ fp.print "\n"
665+ }
666+ end
667+
586668 def count_elements
587669 elements = []
588670 each_atom { |ap|
--- trunk/README (revision 65)
+++ trunk/README (revision 66)
@@ -5,7 +5,7 @@
55 An Interactive Molecular Modeling Software
66 with Integrated Ruby Interpreter
77
8- Version 0.5.5 build 20110426
8+ Version 0.5.5 build 20110702
99
1010 Toshi Nagata
1111
--- trunk/xcode-build/Info.plist (revision 65)
+++ trunk/xcode-build/Info.plist (revision 66)
@@ -36,6 +36,6 @@
3636 <key>CFBundleSignature</key>
3737 <string>????</string>
3838 <key>CFBundleVersion</key>
39- <string>v0.5.5 build 20110426</string>
39+ <string>v0.5.5 build 20110702</string>
4040 </dict>
4141 </plist>
--- trunk/Documents/src/molby_rb/AtomRef.html (revision 65)
+++ trunk/Documents/src/molby_rb/AtomRef.html (revision 66)
@@ -186,6 +186,26 @@
186186 </div>
187187
188188 <div id="method-atom_type" class="method-detail">
189+<a name="exclusion"></a>
190+<div class="method-heading">
191+<span class="method-name">
192+exclusion &rarr; [[i1, i2, ...], [j1, j2, ...], [k1, k2, ...]]<br />
193+</span>
194+</div>
195+<div class="method-description">
196+<p>
197+Get the exclusion table, which is used to "exclude" the pair of atoms from the calculation of the non-bonding interaction. [i1, i2, ...] are the atoms which are directly connected to this atom (1-2 exclusion). [j1, j2, ...] are the atoms (other than self) that are connected to [i1, i2, ...] and not in the 1-2 exclusion list (1-3 exclusion). [k1, k2, ...] are the atoms (other than self) that are connected to [j1, j2, ...] and not in the 1-2 nor 1-3 exclusion list.
198+</p>
199+<p>
200+This is a read-only attribute.
201+</p>
202+<p>
203+This method requires that the <a href="MDArena.html">MDArena</a> object for the parent molecule is already established and <a href="MDArena.html#M000046">prepare</a>'d.
204+</p>
205+</div>
206+</div>
207+
208+<div id="method-atom_type" class="method-detail">
189209 <a name="f"></a>
190210 <div class="method-heading">
191211 <span class="method-name">
--- trunk/Documents/src/doc_source.html (revision 65)
+++ trunk/Documents/src/doc_source.html (revision 66)
@@ -13,13 +13,13 @@
1313 <div class="centered" lang="en">
1414 <h1>Molby</h1>
1515 <h2>An Interactive Molecular Modeling Software<br />with Integrated Ruby Interpreter</h2>
16-<h3>Version 0.5.5 build 20110426</h3> <!-- version -->
16+<h3>Version 0.5.5 build 20110702</h3> <!-- version -->
1717 <h3>Toshi Nagata</h3>
1818 </div>
1919 <div class="centered" lang="ja">
2020 <h1>Molby</h1>
2121 <h2>対話型分子モデリングソフトウェア<br />(Ruby インタプリタ内蔵)</h2>
22-<h3>Version 0.5.5 build 20110426</h3> <!-- version -->
22+<h3>Version 0.5.5 build 20110702</h3> <!-- version -->
2323 <h3>永田 央</h3>
2424 </div>
2525 <hr />
--- trunk/wxSources/MyDocument.cpp (revision 65)
+++ trunk/wxSources/MyDocument.cpp (revision 66)
@@ -713,8 +713,10 @@
713713 md_copy_coordinates_from_internal(mol->arena);
714714 MoleculeUnlock(mol); */
715715
716- if (minimize && mol->arena->minimize_complete)
716+ if (minimize && mol->arena->minimize_complete) {
717+ r = -2; /* Minimization complete */
717718 break;
719+ }
718720 wxPostEvent(doc, insertFrameEvent);
719721 }
720722 }
--- trunk/wxSources/MyVersion.c (revision 65)
+++ trunk/wxSources/MyVersion.c (revision 66)
@@ -15,5 +15,5 @@
1515 GNU General Public License for more details.
1616 */
1717
18-const char *gVersionString = "v0.5.5 build 20110426";
18+const char *gVersionString = "v0.5.5 build 20110702";
1919 const char *gCopyrightString = "Copyright (c) 2008-2011 Toshi Nagata";
--- trunk/amberparm2molby.pl (revision 65)
+++ trunk/amberparm2molby.pl (revision 66)
@@ -4,6 +4,7 @@
44 # output (stdout): a Molby parm file
55 # Written as amberparm2namd.pl by Toshi Nagata, Dec 2 2004
66 # Updated for Molby, Nov 13 2009
7+# Revised Jul 2 2011
78
89 $title = <>;
910 print "! ", $title;
@@ -39,7 +40,7 @@
3940 chomp;
4041 last if /^\s*$/;
4142 ($a1, $a2, $fc, $len, $com) = unpack("A2 x1 A2 A10 A10 A75", $_ . $blanks);
42- printf "bond %-2s %-2s %7.1f %5.2f%s\n", $a1, $a2, $fc, $len, format_com($com);
43+ printf "bond %-2s %-2s %7.1f %5.3f%s\n", $a1, $a2, $fc, $len, format_com($com);
4344 }
4445 print "\n";
4546
--- trunk/MolLib/Ruby_bind/ruby_bind.c (revision 65)
+++ trunk/MolLib/Ruby_bind/ruby_bind.c (revision 66)
@@ -58,7 +58,8 @@
5858 s_RSym, s_XSym, s_YSym, s_ZSym,
5959 s_FractRSym, s_FractXSym, s_FractYSym, s_FractZSym,
6060 s_VSym, s_FSym, s_OccupancySym, s_TempFactorSym,
61- s_AnisoSym, s_IntChargeSym, s_FixForceSym, s_FixPosSym;
61+ s_AnisoSym, s_IntChargeSym, s_FixForceSym, s_FixPosSym,
62+ s_ExclusionSym;
6263
6364 /* Symbols for parameter attributes */
6465 static VALUE
@@ -3293,6 +3294,34 @@
32933294 return ValueFromVector(&(s_AtomFromValue(self)->fix_pos));
32943295 }
32953296
3297+static VALUE s_AtomRef_GetExclusion(VALUE self) {
3298+ Molecule *mol;
3299+ Atom *ap;
3300+ int idx, i;
3301+ MDExclusion *exinfo;
3302+ Int *exlist;
3303+ VALUE retval, aval;
3304+ idx = s_AtomIndexFromValue(self, &ap, &mol);
3305+ if (mol->arena == NULL || mol->arena->is_initialized == 0 || mol->needsMDRebuild)
3306+ rb_raise(rb_eMolbyError, "Molecular dynamics is not ready. Please consider doing 'minimize' by hand or 'mol.md_arena.prepare' from script.");
3307+ exinfo = mol->arena->exinfo + idx;
3308+ exlist = mol->arena->exlist;
3309+ retval = rb_ary_new();
3310+ aval = rb_ary_new();
3311+ for (i = exinfo->index1; i < exinfo->index2; i++) /* 1-2 exclusion */
3312+ rb_ary_push(aval, INT2NUM(exlist[i]));
3313+ rb_ary_push(retval, aval);
3314+ aval = rb_ary_new();
3315+ for (i = exinfo->index2; i < exinfo->index3; i++) /* 1-3 exclusion */
3316+ rb_ary_push(aval, INT2NUM(exlist[i]));
3317+ rb_ary_push(retval, aval);
3318+ aval = rb_ary_new();
3319+ for (i = exinfo->index3; i < (exinfo + 1)->index0; i++) /* 1-4 exclusion */
3320+ rb_ary_push(aval, INT2NUM(exlist[i]));
3321+ rb_ary_push(retval, aval);
3322+ return retval;
3323+}
3324+
32963325 static VALUE s_AtomRef_SetIndex(VALUE self, VALUE val) {
32973326 rb_raise(rb_eMolbyError, "index cannot be directly set");
32983327 return Qnil;
@@ -3608,6 +3637,11 @@
36083637 return val;
36093638 }
36103639
3640+static VALUE s_AtomRef_SetExclusion(VALUE self, VALUE val) {
3641+ rb_raise(rb_eMolbyError, "exclusion table is read-only.");
3642+ return val; /* Not reached */
3643+}
3644+
36113645 static struct s_AtomAttrDef {
36123646 char *name;
36133647 VALUE *symref; /* Address of s_IndexSymbol etc. */
@@ -3643,6 +3677,7 @@
36433677 {"int_charge", &s_IntChargeSym, 0, s_AtomRef_GetIntCharge, s_AtomRef_SetIntCharge},
36443678 {"fix_force", &s_FixForceSym, 0, s_AtomRef_GetFixForce, s_AtomRef_SetFixForce},
36453679 {"fix_pos", &s_FixPosSym, 0, s_AtomRef_GetFixPos, s_AtomRef_SetFixPos},
3680+ {"exclusion", &s_ExclusionSym, 0, s_AtomRef_GetExclusion, s_AtomRef_SetExclusion},
36463681 {NULL} /* Sentinel */
36473682 };
36483683
Show on old repository browser