OSDN Git Service

Ruby: Molecule#expand_by_symmetry is modified so that it accepts an optional argument...
authortoshinagata1964 <toshinagata1964@a2be9bc6-48de-4e38-9406-05402d4bc13c>
Sat, 15 Feb 2014 14:51:37 +0000 (14:51 +0000)
committertoshinagata1964 <toshinagata1964@a2be9bc6-48de-4e38-9406-05402d4bc13c>
Sat, 15 Feb 2014 14:51:37 +0000 (14:51 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/molby/trunk@432 a2be9bc6-48de-4e38-9406-05402d4bc13c

Documents/src/doc_source.html
Documents/src/molby_rb/Molecule.html
MolLib/MolAction.c
MolLib/Ruby_bind/ruby_bind.c
wxSources/MyVersion.c

index 5b052c6..ae4dd61 100644 (file)
@@ -203,7 +203,7 @@ Molbyフォルダの中にアンインストーラがあります。「スター
 Molby is a copyrighted product of Toshi Nagata.
 </p>
 <p>
-Copyright (C) 2008-2013 Toshi Nagata <!-- copyright -->
+Copyright (C) 2008-2014 Toshi Nagata <!-- copyright -->
 </p>
 <p>
 Molby includes the following softwares, which are copyrighted products as described below:
@@ -235,7 +235,7 @@ Molby is distributed under the GNU General Public License (version 2).
 Molby: An Interactive Molecular Modeling Software with Integrated Ruby Interpreter
 </p>
 <p>
-Copyright (C) 2008-2013 Toshi Nagata <!-- copyright -->
+Copyright (C) 2008-2014 Toshi Nagata <!-- copyright -->
 </p>
 <p>
 This program is free software; you can redistribute it and/or modify
@@ -258,7 +258,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 Molby の著作権は永田 央が保持しています。
 </p>
 <p>
-Copyright (C) 2008-2013 Toshi Nagata <!-- copyright -->
+Copyright (C) 2008-2014 Toshi Nagata <!-- copyright -->
 </p>
 <p>
 Molby は以下のソフトウェアを含んでいます。それぞれの著作権表示は下の通りです。
@@ -290,7 +290,7 @@ Molby は <a href="../etc/gpl.txt">GNU General Public License (GNU 一般公衆
 Molby: 対話型分子モデルソフトウェア(Ruby インタプリタ内蔵)
 </p>
 <p>
-Copyright (C) 2008-2013 Toshi Nagata <!-- copyright -->
+Copyright (C) 2008-2014 Toshi Nagata <!-- copyright -->
 </p>
 <p>
 このプログラムはフリーソフトウェアです。あなたはこれを、フリーソフトウェア財団によって発行された GNU 一般公衆利用許諾契約書(バージョン2か、希望によってはそれ以降のバージョンのうちどれか)の定める条件の下で再頒布または改変することができます。
index 9616f47..d24a7ae 100644 (file)
@@ -1362,12 +1362,18 @@ present, then returns nil.
 <div id="method-M000292" class="method-detail">
 <a name="expand_by_symmetry"></a>
 <div class="method-heading">
-<span class="method-name">expand_by_symmetry(group, sym, dx=0, dy=0, dz=0) &rarr; Array<br />
+<span class="method-name">expand_by_symmetry(group, sym, dx=0, dy=0, dz=0, allow_overlap = false) &rarr; Array<br />
 </span>
 </div>
 <div class="method-description">
 <p>
-Expand the specified part of the molecule by the given symmetry operation. Sym is the index to the <a href="Molecule.html#M000331">symmetries</a> array, and dx/dy/dz are the integers representing the translational operations along the unit cell axes. Returns an array of indices of the expanded atoms (corresponding the atoms in group).  This operation is undoable.
+Expand the specified part of the molecule by the given symmetry operation. Sym is the index to the <a href="Molecule.html#M000331">symmetries</a> array, and dx/dy/dz are the integers representing the translational operations along the unit cell axes. Returns an array of indices of the expanded atoms (corresponding the atoms in group).
+</p>
+<p>
+If allow_overlap is true, then new atoms are created even when the coordinates coincide with the some other atom (special position) of the same element; otherwise, such atom will not be created and the index of the existing atom is given in the returned array.
+</p>
+<p>
+This operation is undoable.
 </p>
 </div>
 </div>
index d913b2c..b8b6c68 100644 (file)
@@ -57,7 +57,7 @@ const char *gMolActionChangeResidueNames = "changeResNames:IC";
 const char *gMolActionOffsetResidueNumbers = "offsetResSeq:Gii";
 const char *gMolActionChangeNumberOfResidues = "changeNres:i";
 const char *gMolActionRenumberAtoms    = "renumberAtoms:I";
-const char *gMolActionExpandBySymmetry = "expandSym:Giiii;I";
+const char *gMolActionExpandBySymmetry = "expandSym:Giiiii;I";
 const char *gMolActionDeleteSymmetryOperation = "deleteSymop";
 const char *gMolActionAddSymmetryOperation = "addSymop:t";
 const char *gMolActionSetCell         = "setCell:Di";
@@ -1419,7 +1419,7 @@ s_MolActionChangeNumberOfResidues(Molecule *mol, MolAction *action, MolAction **
 static int
 s_MolActionExpandBySymmetry(Molecule *mol, MolAction *action, MolAction **actp)
 {
-       Int n1, *ip, count;
+       Int n1, *ip, count, allow_overlap;
        Symop symop;
        IntGroup *ig = action->args[0].u.igval;
        count = IntGroupGetCount(ig);
@@ -1430,11 +1430,12 @@ s_MolActionExpandBySymmetry(Molecule *mol, MolAction *action, MolAction **actp)
        symop.dz = action->args[3].u.ival;
        symop.sym = action->args[4].u.ival;
        symop.alive = (symop.dx != 0 || symop.dy != 0 || symop.dz != 0 || symop.sym != 0);
-       if (action->args[5].u.retval.ptr != NULL) {
+       allow_overlap = action->args[5].u.ival;
+       if (action->args[6].u.retval.ptr != NULL) {
                /*  Request the indices of the atoms  */
                ip = (Int *)calloc(sizeof(Int), count);
        } else ip = NULL;
-       n1 = MoleculeAddExpandedAtoms(mol, symop, ig, ip, 0);
+       n1 = MoleculeAddExpandedAtoms(mol, symop, ig, ip, allow_overlap);
        if (n1 > 0) {
                ig = IntGroupNew();
                IntGroupAdd(ig, mol->natoms - n1, n1);
@@ -1447,8 +1448,8 @@ s_MolActionExpandBySymmetry(Molecule *mol, MolAction *action, MolAction **actp)
                        ip = NULL;
                        count = 0;
                }
-               *((Int **)(action->args[5].u.retval.ptr)) = ip;
-               *(action->args[5].u.retval.nptr) = count;
+               *((Int **)(action->args[6].u.retval.ptr)) = ip;
+               *(action->args[6].u.retval.nptr) = count;
        }
        return (n1 >= 0 ? 0 : n1);
 }
index ba665b7..38e9dbd 100644 (file)
@@ -7115,7 +7115,7 @@ s_Molecule_FindCloseAtoms(int argc, VALUE *argv, VALUE self)
                        radius = gElementParameters[6].radius;
                else
                        radius = NUM2DBL(rb_Float(radval));
-               n1 = 0;
+               n1 = mol->natoms;
        } else {
                n1 = s_Molecule_AtomIndexFromValue(mol, aval);
                v = ATOM_AT_INDEX(mol->atoms, n1)->r;
@@ -8235,33 +8235,38 @@ s_Molecule_MeasureDihedral(VALUE self, VALUE nval1, VALUE nval2, VALUE nval3, VA
 
 /*
  *  call-seq:
- *     expand_by_symmetry(group, sym, dx=0, dy=0, dz=0) -> Array
+ *     expand_by_symmetry(group, sym, dx=0, dy=0, dz=0, allow_overlap = false) -> Array
  *
  *  Expand the specified part of the molecule by the given symmetry operation.
  *  Returns the array of atom indices corresponding to the expanded atoms.
+ *  If allow_overlap is true, then new atoms are created even when the
+ *  coordinates coincide with the some other atom (special position) of the
+ *  same element; otherwise, such atom will not be created and the index of the
+ *  existing atom is given in the returned array.
  */
 static VALUE
 s_Molecule_ExpandBySymmetry(int argc, VALUE *argv, VALUE self)
 {
     Molecule *mol;
-       VALUE gval, sval, xval, yval, zval, rval;
+       VALUE gval, sval, xval, yval, zval, rval, oval;
        IntGroup *ig;
-       Int n[4];
+       Int n[4], allow_overlap;
        Int natoms;
        Int nidx, *idx;
 
     Data_Get_Struct(self, Molecule, mol);
-       rb_scan_args(argc, argv, "23", &gval, &sval, &xval, &yval, &zval);
+       rb_scan_args(argc, argv, "24", &gval, &sval, &xval, &yval, &zval, &oval);
        n[0] = NUM2INT(rb_Integer(sval));
        n[1] = (xval == Qnil ? 0 : NUM2INT(rb_Integer(xval)));
        n[2] = (yval == Qnil ? 0 : NUM2INT(rb_Integer(yval)));
        n[3] = (zval == Qnil ? 0 : NUM2INT(rb_Integer(zval)));
+       allow_overlap = (RTEST(oval) ? 1 : 0);
        ig = s_Molecule_AtomGroupFromValue(self, gval);
        if (n[0] < 0 || (n[0] > 0 && n[0] >= mol->nsyms))
                rb_raise(rb_eMolbyError, "symmetry index is out of bounds");
        natoms = mol->natoms;
        
-       MolActionCreateAndPerform(mol, gMolActionExpandBySymmetry, ig, n[1], n[2], n[3], n[0], &nidx, &idx);
+       MolActionCreateAndPerform(mol, gMolActionExpandBySymmetry, ig, n[1], n[2], n[3], n[0], allow_overlap, &nidx, &idx);
 
        rval = rb_ary_new2(nidx);
        while (--nidx >= 0) {
index bf5030b..42b9e7a 100644 (file)
@@ -3,7 +3,7 @@
  *  Molby
  *
  *  Created by Toshi Nagata on 09/10/16.
- *  Copyright 2008-2013 Toshi Nagata. All rights reserved.
+ *  Copyright 2008-2014 Toshi Nagata. All rights reserved.
  *
  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by