struct Chem::Spatial::Positions3Proxy

Included Modules

Defined in:

chem/spatial/positions3_proxy.cr

Constructors

Instance Method Summary

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

[](idxs : Tuple) : Tuple
[](idxs : Enumerable(Int)) : Array(T)
[](*idxs : Int) : Tuple
[]
, sentence(io : IO, separator : String = ", ", *, pair_separator : String = " and ", tail_separator : String = ", and ", & : T, IO -> ) : Nil
sentence(io : IO, separator : String = ", ", *, pair_separator : String = " and ", tail_separator : String = ", and ") : Nil
sentence(separator : String = ", ", *, pair_separator : String = " and ", tail_separator : String = ", and ", & : T -> ) : String
sentence(separator : String = ", ", *, pair_separator : String = " and ", tail_separator : String = ", and ") : String
sentence
, to_dcd(io : IO, title : String | Nil = nil) : Nil
to_dcd(title : String | Nil = nil) : String
to_dcd(path : Path | String, title : String | Nil = nil) : Nil
to_dcd

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

===(atom : Chem::Atom) : Bool
===(chain : Chem::Chain) : Bool
===(residue : Chem::Residue) : Bool
===
, average(weights : Indexable(Number))
average(weights : Indexable(Number), & : T -> _)
average
, find(pattern, if_none default = nil) find, find!(pattern) find!, mean
mean(& : T -> _)
mean
, to_dcd(io : IO, title : String | Nil = nil) : Nil
to_dcd(title : String | Nil = nil) : String
to_dcd(path : Path | String, title : String | Nil = nil) : Nil
to_dcd
, to_maestro(io : IO) : Nil
to_maestro(path : Path | String) : Nil
to_maestro : String
to_maestro
, to_mol2(io : IO) : Nil
to_mol2(path : Path | String) : Nil
to_mol2 : String
to_mol2
, to_pdb(io : IO, conect conect_options : PDB::ConectOptions = PDB::ConectOptions.flags(Het, Disulfide), renumber : Bool = true, ter_on_fragment : Bool = false) : Nil
to_pdb(conect conect_options : PDB::ConectOptions = PDB::ConectOptions.flags(Het, Disulfide), renumber : Bool = true, ter_on_fragment : Bool = false) : String
to_pdb(path : Path | String, conect conect_options : PDB::ConectOptions = PDB::ConectOptions.flags(Het, Disulfide), renumber : Bool = true, ter_on_fragment : Bool = false) : Nil
to_pdb
, to_sdf(io : IO, variant : Mol::Variant = :v2000) : Nil
to_sdf(path : Path | String, variant : Mol::Variant = :v2000) : Nil
to_sdf(variant : Mol::Variant = :v2000) : String
to_sdf
, to_xyz(io : IO, extended : Bool = false, fields : Array(String) = [] of String) : Nil
to_xyz(extended : Bool = false, fields : Array(String) = [] of String) : String
to_xyz(path : Path | String, extended : Bool = false, fields : Array(String) = [] of String) : Nil
to_xyz

Constructor Detail

def self.new(atoms : AtomView, 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].pos
pos = conformers[1].pos
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 atoms : AtomView #

Atoms whose coordinates are wrapped by this proxy.


[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.pos.center # => [1.5 2.0 3.2]
structure.pos.center_along Vec3[0, 10, 0]
structure.pos.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.pos.center # => [1.0 2.0 3.0]
structure.pos.center_at Vec3[10, 20, 30]
structure.pos.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.pos.center # => [1.0 2.0 3.0]
structure.pos.center_at_cell
structure.pos.center # => [0.5 12.5 106.5]

structure = Structure.read "path/to/non_periodic_file"
structure.pos.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.pos.center # => [1.0 2.0 3.0]
structure.pos.center_at_origin
structure.pos.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.pos.center # => [4.0 5.0 6.0]
structure.pos.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 Indexable(Chem::Spatial::Vec3)

Calls the given block once for each element in self, passing that element as a parameter.

a = ["a", "b", "c"]
a.each { |x| print x, " -- " }

produces:

a -- b -- c --

[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 rdgyr : Float64 #

Returns the radius of gyration in Å.

The radius of gyration is a measure of the distribution of the atoms around the center of mass of a molecule. The radius of gyration is defined as the root-mean-square distance of the atoms from the axis of rotation:

RDGYR = √ 1 / N * Σ(r - c)²

where N is the number of atoms in the molecule, r is the coordinates of each atom, and c is the center of mass of the molecule.


[View source]
def rmsd(other : AtomView | Residue | ResidueView | Chain | ChainView | Structure | self, *, weights : Indexable(Float64) | Nil = nil, minimize : Bool = false, use_symmetry : Bool = false) : Float64 #

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

Delegates to AtomView#rmsd. If use_symmetry is true, atoms in self that belong to a residue template's symmetric_atom_groups are permuted so that they best match other before the RMSD is computed. The reference (other) is left unchanged. This is opt-in and defaults to false. See AtomView#sort_by_symmetry.


[View source]
def rmsd(other : Indexable(Vec3), *, weights : Indexable(Float64) | Nil = nil, minimize : Bool = false) : Float64 #

Returns the root mean square deviation (RMSD) in Å between the coordinates and other. Delegates to Spatial.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 size : Int32 #
Description copied from module Indexable(Chem::Spatial::Vec3)

Returns the number of elements in this container.


[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 unsafe_fetch(index : Int) : Vec3 #
Description copied from module Indexable(Chem::Spatial::Vec3)

Returns the element at the given index, without doing any bounds check.

Indexable makes sure to invoke this method with index in 0...size, so converting negative indices to positive ones is not needed here.

Clients never invoke this method directly. Instead, they access elements with #[](index) and #[]?(index).

This method should only be directly invoked if you are absolutely sure the index is in bounds, to avoid a bounds check for a small boost of performance.


[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]