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:
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
Molby の著作権は永田 央が保持しています。
</p>
<p>
-Copyright (C) 2008-2013 Toshi Nagata <!-- copyright -->
+Copyright (C) 2008-2014 Toshi Nagata <!-- copyright -->
</p>
<p>
Molby は以下のソフトウェアを含んでいます。それぞれの著作権表示は下の通りです。
Molby: 対話型分子モデルソフトウェア(Ruby インタプリタ内蔵)
</p>
<p>
-Copyright (C) 2008-2013 Toshi Nagata <!-- copyright -->
+Copyright (C) 2008-2014 Toshi Nagata <!-- copyright -->
</p>
<p>
このプログラムはフリーソフトウェアです。あなたはこれを、フリーソフトウェア財団によって発行された GNU 一般公衆利用許諾契約書(バージョン2か、希望によってはそれ以降のバージョンのうちどれか)の定める条件の下で再頒布または改変することができます。
<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) → Array<br />
+<span class="method-name">expand_by_symmetry(group, sym, dx=0, dy=0, dz=0, allow_overlap = false) → 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>
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";
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);
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);
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);
}
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;
/*
* 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) {
* 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