struct Chem::Spatial::CoordinatesProxy

Included Modules

Defined in:

chem/spatial/coordinates_proxy.cr

Constructors

Instance Method Summary

Instance methods inherited from module Enumerable(Chem::Spatial::Vec3)

average(weights : Indexable(Number))
average(weights : Indexable(Number), & : T -> _)
average
, mean
mean(& : T -> _)
mean

Constructor Detail

def self.new(atoms : AtomCollection, cell : Parallelepiped | Nil = nil) #

[View source]

Instance Method Detail

def ==(rhs : Enumerable(Vec3)) : Bool #

[View source]
def 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).


[View source]
def bounds : Parallelepiped #

[View source]
def center : Vec3 #

[View source]
def 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]

[View source]
def 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]

[View source]
def center_at_cell : self #

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

[View source]
def center_at_origin : self #

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]

[View source]
def com : Vec3 #

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]

[View source]
def each(fractional : Bool = false) : Iterator(Vec3) #
Description copied from module Iterable(Chem::Spatial::Vec3)

Must return an Iterator over the elements in this collection.


[View source]
def each(fractional : Bool = false, &block : Vec3 -> ) #
Description copied from module Enumerable(Chem::Spatial::Vec3)

Must yield this collection's elements to the block.


[View source]
def each_with_atom(fractional : Bool = false, &block : Vec3, Atom -> ) #

[View source]
def map!(fractional : Bool = false, &block : Vec3 -> Vec3) : self #

[View source]
def map_with_atom!(fractional : Bool = false, &block : Vec3, Atom -> Vec3) : self #

[View source]
def 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.


[View source]
def 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.


[View source]
def 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.


[View source]
def 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.


[View source]
def 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.


[View source]
def to_a(fractional : Bool = false) : Array(Vec3) #
Description copied from module Enumerable(Chem::Spatial::Vec3)

Returns an Array with all the elements in the collection.

(1..5).to_a # => [1, 2, 3, 4, 5]

[View source]
def to_cart! : self #

[View source]
def to_fract! : self #

[View source]
def transform(transform : Transform) : self #

Transforms the coordinates by the given transformation.


[View source]
def translate(by offset : Vec3) : self #

Translates the coordinates by the given offset.


[View source]
def unwrap : self #

[View source]
def wrap(around center : Vec3 | Nil = nil) : self #

[View source]
def wrap(cell : Parallelepiped, around center : Vec3 | Nil = nil) : self #

[View source]