struct

Chem::Spatial::CoordinatesProxy

Inherits Iterable / Enumerable / Struct / Value / Object

Constructors

new(atoms : AtomCollection, cell : Parallelepiped | Nil = nil)
Source

Instance methods

==(rhs : Enumerable(Vec3)) : Bool
Source
align_to(other : self) : self

Superimposes the coordinates onto other. Raises ArgumentError if the two coordinate sets are of different size.

conformers = Array(Structure).read "E20_conformers.mol2"
ref_pos = conformers[0].coords
pos = conformers[1].coords
Spatial.rmsd(pos, ref_pos)   # => 7.933736
pos.center == ref_pos.center # => false
pos.align_to(res_pos)
Spatial.rmsd(pos, ref_pos)   # => 3.463298
pos.center == ref_pos.center # => true

The transformation is obtained via the Transform.aligning(pos, ref_pos) method, which computes the optimal rotation matrix by minimizing the root mean square deviation (RMSD) using the QCP method (refer to Spatial.qcp for details).

Source
bounds
Source
center
Source
center_along(vec : Vec3) : self

Translates coordinates so that the center is at the middle of vec.

structure = Structure.read "path/to/file"
structure.coords.center # => [1.5 2.0 3.2]
structure.coords.center_along Vec3[0, 10, 0]
structure.coords.center # => [1.5 5.0 3.2]
Source
center_at(vec : Vec3) : self

Translates coordinates so that the center is at vec.

structure = Structure.read "path/to/file"
structure.coords.center # => [1.0 2.0 3.0]
structure.coords.center_at Vec3[10, 20, 30]
structure.coords.center # => [10 20 30]
Source
center_at_cell

Translates coordinates so that they are centered at the primary unit cell.

Raises NotPeriodicError if coordinates are not periodic.

structure = Structure.read "path/to/file"
structure.cell          # => [[1.0 0.0 0.0] [0.0 25.0 0.0] [0.0 0.0 213]]
structure.coords.center # => [1.0 2.0 3.0]
structure.coords.center_at_cell
structure.coords.center # => [0.5 12.5 106.5]

structure = Structure.read "path/to/non_periodic_file"
structure.coords.center_at_cell # raises NotPeriodicError
Source
center_at_origin

Translates coordinates so that the center is at the origin.

structure = Structure.read "path/to/file"
structure.coords.center # => [1.0 2.0 3.0]
structure.coords.center_at_origin
structure.coords.center # => [0.0 0.0 0.0]
Source
com

Returns the center of mass.

structure = Chem::Structure.build do
  atom :O, Vec3[1, 2, 3]
  atom :H, Vec3[4, 5, 6]
  atom :H, Vec3[7, 8, 9]
end
structure.coords.center # => [4.0 5.0 6.0]
structure.coords.com    # => [1.5035248 2.5035248 3.5035248]
Source
each(fractional : Bool = false) : Iterator(Vec3)

Must return an Iterator over the elements in this collection.

Source
each(fractional : Bool = false, &block : Vec3 -> )

Must yield this collection's elements to the block.

Source
each_with_atom(fractional : Bool = false, &block : Vec3, Atom -> )
Source
map!(fractional : Bool = false, &block : Vec3 -> Vec3) : self
Source
map_with_atom!(fractional : Bool = false, &block : Vec3, Atom -> Vec3) : self
Source
rmsd(other : self, weights : Indexable(Float64), minimize : Bool = false) : Float64

Returns the weighted root mean square deviation (RMSD) in Å between the coordinates and other.

The RMSD is defined as the weighted average Euclidean distance between the two coordinates sets A and B. The weights (e.g., atom masses) determine the relative weights of each coordinate when calculating the RMSD.

If the minimum RMSD is desired (minimize is true), the RMSD will be computed using the quaternion-based characteristic polynomial (QCP) method (refer to .qcp). This method superimpose the coordinates onto other by computing the optimal rotation between the two coordinate sets before calculating the RMSD.

Source
rmsd(other : CoordinatesProxy, minimize : Bool = false) : Float64

Returns the root mean square deviation (RMSD) in Å between the coordinates and other.

The RMSD is defined as the average Euclidean distance between the two coordinates sets A and B.

If the minimum RMSD is desired (minimize is true), the RMSD will be computed using the quaternion-based characteristic polynomial (QCP) method (refer to .qcp). This method superimpose the coordinates onto other by computing the optimal rotation between the two coordinate sets before calculating the RMSD.

Source
rotate(x : Number, y : Number, z : Number, pivot : Vec3 = center) : self

Rotates the coordinates by the given Euler angles in degrees. The rotation will be centered at pivot, which defaults to the coordinates' center.

Delegates to Quat.rotation for computing the rotation.

Source
rotate(about rotaxis : Vec3, by angle : Number, pivot : Vec3 = center) : self

Rotates the coordinates about rotaxis by angle degrees. The rotation will be centered at pivot, which defaults to the coordinates' center.

Delegates to Quat.rotation for computing the rotation.

Source
rotate(quat : Quat, pivot : Vec3 = center) : self

Rotates the coordinates by the given quaternion. The rotation will be centered at pivot, which defaults to the coordinates' center.

Source
to_a(fractional : Bool = false) : Array(Vec3)

Returns an Array with all the elements in the collection.

(1..5).to_a # => [1, 2, 3, 4, 5]
Source
to_cart!
Source
to_fract!
Source
transform(transform : Transform) : self

Transforms the coordinates by the given transformation.

Source
translate(by offset : Vec3) : self

Translates the coordinates by the given offset.

Source
unwrap
Source
wrap(around center : Vec3 | Nil = nil) : self
Source
wrap(cell : Parallelepiped, around center : Vec3 | Nil = nil) : self
Source