class
Chem::Atom
- Chem::Atom
- Reference
- Object
Included Modules
- Comparable(Chem::Atom)
Defined in:
chem/core/atom.crConstructors
-
.new(structure : Structure, element : Element, pos : Spatial::Vec3, *, name : String | Nil = nil, number : Int32 | Nil = nil, residue : Residue | Nil = nil, typename : String | Nil = nil, formal_charge : Int32 = 0, mass : Float64 = element.mass, occupancy : Float64 = 1, partial_charge : Float64 = 0.0, temperature_factor : Float64 = 0, vdw_radius : Float64 = element.vdw_radius)
Creates an atom in structure with the given element and coordinates.
-
.new(residue : Residue, name : String, pos : Spatial::Vec3, element : Element | Nil = nil, **options) : self
Creates an atom in residue (and its parent structure).
Instance Method Summary
-
#<=>(other : self) : Int32
The comparison operator.
-
#==(rhs : self) : Bool
Returns
trueifselfand rhs are the same atom, elsefalse. -
#actinium?
Returns
trueif the atom's element is "Actinium", elsefalse. -
#aluminum?
Returns
trueif the atom's element is "Aluminum", elsefalse. -
#americium?
Returns
trueif the atom's element is "Americium", elsefalse. -
#antimony?
Returns
trueif the atom's element is "Antimony", elsefalse. -
#argon?
Returns
trueif the atom's element is "Argon", elsefalse. -
#arsenic?
Returns
trueif the atom's element is "Arsenic", elsefalse. -
#astatine?
Returns
trueif the atom's element is "Astatine", elsefalse. - #atomic_number(*args, **options)
- #atomic_number(*args, **options, &)
-
#barium?
Returns
trueif the atom's element is "Barium", elsefalse. -
#berkelium?
Returns
trueif the atom's element is "Berkelium", elsefalse. -
#beryllium?
Returns
trueif the atom's element is "Beryllium", elsefalse. -
#bismuth?
Returns
trueif the atom's element is "Bismuth", elsefalse. -
#bohrium?
Returns
trueif the atom's element is "Bohrium", elsefalse. - #bonded?(to other : self) : Bool
- #bonded_atoms : Array(Atom)
- #bonds : BondArray
-
#boron?
Returns
trueif the atom's element is "Boron", elsefalse. -
#bromine?
Returns
trueif the atom's element is "Bromine", elsefalse. -
#cadmium?
Returns
trueif the atom's element is "Cadmium", elsefalse. -
#calcium?
Returns
trueif the atom's element is "Calcium", elsefalse. -
#californium?
Returns
trueif the atom's element is "Californium", elsefalse. -
#carbon?
Returns
trueif the atom's element is "Carbon", elsefalse. -
#cerium?
Returns
trueif the atom's element is "Cerium", elsefalse. -
#cesium?
Returns
trueif the atom's element is "Cesium", elsefalse. -
#chain : Chain
Returns the parent chain.
-
#chain? : Chain | Nil
Returns the parent chain, or
nilif the atom has no residue. -
#chlorine?
Returns
trueif the atom's element is "Chlorine", elsefalse. -
#chromium?
Returns
trueif the atom's element is "Chromium", elsefalse. -
#cobalt?
Returns
trueif the atom's element is "Cobalt", elsefalse. - #constraint : Spatial::Direction | Nil
- #constraint=(constraint : Spatial::Direction | Nil)
-
#copernicium?
Returns
trueif the atom's element is "Copernicium", elsefalse. -
#copper?
Returns
trueif the atom's element is "Copper", elsefalse. - #covalent_radius(*args, **options)
- #covalent_radius(*args, **options, &)
-
#curium?
Returns
trueif the atom's element is "Curium", elsefalse. -
#darmstadtium?
Returns
trueif the atom's element is "Darmstadtium", elsefalse. -
#degree : Int32
Returns the number of bonds.
-
#delete : Nil
Removes the atom from its parent structure and residue, and deletes its bonds.
-
#dna? : Bool
Returns
trueif the atom belongs to a dna residue, elsefalse. -
#dubnium?
Returns
trueif the atom's element is "Dubnium", elsefalse. -
#dysprosium?
Returns
trueif the atom's element is "Dysprosium", elsefalse. - #each_bonded_atom : Iterator(Atom)
- #each_bonded_atom(& : self -> ) : Nil
-
#einsteinium?
Returns
trueif the atom's element is "Einsteinium", elsefalse. - #element : Element
- #element=(element : Element)
-
#erbium?
Returns
trueif the atom's element is "Erbium", elsefalse. -
#europium?
Returns
trueif the atom's element is "Europium", elsefalse. -
#fermium?
Returns
trueif the atom's element is "Fermium", elsefalse. -
#flerovium?
Returns
trueif the atom's element is "Flerovium", elsefalse. -
#fluorine?
Returns
trueif the atom's element is "Fluorine", elsefalse. - #formal_charge : Int32
- #formal_charge=(formal_charge : Int32)
-
#francium?
Returns
trueif the atom's element is "Francium", elsefalse. -
#gadolinium?
Returns
trueif the atom's element is "Gadolinium", elsefalse. -
#gallium?
Returns
trueif the atom's element is "Gallium", elsefalse. -
#germanium?
Returns
trueif the atom's element is "Germanium", elsefalse. -
#gold?
Returns
trueif the atom's element is "Gold", elsefalse. -
#hafnium?
Returns
trueif the atom's element is "Hafnium", elsefalse. -
#hassium?
Returns
trueif the atom's element is "Hassium", elsefalse. - #heavy?(*args, **options)
- #heavy?(*args, **options, &)
-
#helium?
Returns
trueif the atom's element is "Helium", elsefalse. -
#het? : Bool
Returns
trueif the atom belongs to a non-standard (HET) residue, elsefalse. -
#holmium?
Returns
trueif the atom's element is "Holmium", elsefalse. -
#hydrogen?
Returns
trueif the atom's element is "Hydrogen", elsefalse. -
#indium?
Returns
trueif the atom's element is "Indium", elsefalse. -
#inspect(io : IO) : Nil
Appends a String representation of this object which includes its class name, its object address and the values of all instance variables.
-
#iodine?
Returns
trueif the atom's element is "Iodine", elsefalse. -
#ion? : Bool
Returns
trueif the atom belongs to a ion residue, elsefalse. -
#iridium?
Returns
trueif the atom's element is "Iridium", elsefalse. -
#iron?
Returns
trueif the atom's element is "Iron", elsefalse. -
#krypton?
Returns
trueif the atom's element is "Krypton", elsefalse. -
#lanthanum?
Returns
trueif the atom's element is "Lanthanum", elsefalse. -
#lawrencium?
Returns
trueif the atom's element is "Lawrencium", elsefalse. -
#lead?
Returns
trueif the atom's element is "Lead", elsefalse. -
#lithium?
Returns
trueif the atom's element is "Lithium", elsefalse. -
#livermorium?
Returns
trueif the atom's element is "Livermorium", elsefalse. -
#lutetium?
Returns
trueif the atom's element is "Lutetium", elsefalse. -
#magnesium?
Returns
trueif the atom's element is "Magnesium", elsefalse. -
#manganese?
Returns
trueif the atom's element is "Manganese", elsefalse. - #mass : Float64
- #mass=(mass : Float64)
-
#matches?(number : Int) : Bool
Returns
trueif the atom number equals the given number, elsefalse. -
#matches?(str : String) : Bool
Returns
trueif the atom name equals the given name, elsefalse. -
#matches?(pattern : Regex) : Bool
Returns
trueif the atom name matches the given pattern, elsefalse. -
#matches?(numbers : Range(Int, Int) | Range(Nil, Int) | Range(Int, Nil) | Range(Nil, Nil)) : Bool
Returns
trueif the atom number is included in the given range, elsefalse. -
#matches?(numbers : Enumerable(Int)) : Bool
Returns
trueif the atom number is included in the given numbers, elsefalse. -
#matches?(names : Enumerable(String)) : Bool
Returns
trueif the atom name is included in the given names, elsefalse. -
#matches?(element : Element) : Bool
Returns
trueif the atom's element equals the given element, elsefalse. -
#matches?(atom_t : Templates::Atom) : Bool
Returns
trueif the atom matches the given template, elsefalse. - #max_valence(*args, **options)
- #max_valence(*args, **options, &)
-
#meitnerium?
Returns
trueif the atom's element is "Meitnerium", elsefalse. -
#membrane? : Bool
Returns
trueif the atom belongs to a membrane residue, elsefalse. -
#mendelevium?
Returns
trueif the atom's element is "Mendelevium", elsefalse. -
#mercury?
Returns
trueif the atom's element is "Mercury", elsefalse. -
#metadata : Metadata
Hash-like container that stores the atom's additional properties as key (string)-value pairs.
- #missing_valence : Int32
-
#molybdenum?
Returns
trueif the atom's element is "Molybdenum", elsefalse. -
#moscovium?
Returns
trueif the atom's element is "Moscovium", elsefalse. -
#name : String
Atom name.
-
#name=(name : String | Nil) : String | Nil
Assigns the atom name.
-
#name? : String | Nil
Atom name.
-
#neodymium?
Returns
trueif the atom's element is "Neodymium", elsefalse. -
#neon?
Returns
trueif the atom's element is "Neon", elsefalse. -
#neptunium?
Returns
trueif the atom's element is "Neptunium", elsefalse. -
#nickel?
Returns
trueif the atom's element is "Nickel", elsefalse. -
#nihonium?
Returns
trueif the atom's element is "Nihonium", elsefalse. -
#niobium?
Returns
trueif the atom's element is "Niobium", elsefalse. -
#nitrogen?
Returns
trueif the atom's element is "Nitrogen", elsefalse. -
#nobelium?
Returns
trueif the atom's element is "Nobelium", elsefalse. -
#number : Int32
Serial number (PDB-style id).
-
#number=(number : Int32)
Serial number (PDB-style id).
- #occupancy : Float64
- #occupancy=(occupancy : Float64)
-
#oganesson?
Returns
trueif the atom's element is "Oganesson", elsefalse. -
#osmium?
Returns
trueif the atom's element is "Osmium", elsefalse. -
#other? : Bool
Returns
trueif the atom belongs to a other residue, elsefalse. -
#oxygen?
Returns
trueif the atom's element is "Oxygen", elsefalse. -
#palladium?
Returns
trueif the atom's element is "Palladium", elsefalse. - #partial_charge : Float64
- #partial_charge=(partial_charge : Float64)
-
#phosphorus?
Returns
trueif the atom's element is "Phosphorus", elsefalse. -
#platinum?
Returns
trueif the atom's element is "Platinum", elsefalse. -
#plutonium?
Returns
trueif the atom's element is "Plutonium", elsefalse. -
#polonium?
Returns
trueif the atom's element is "Polonium", elsefalse. - #pos : Spatial::Vec3
- #pos=(pos : Spatial::Vec3)
-
#potassium?
Returns
trueif the atom's element is "Potassium", elsefalse. -
#praseodymium?
Returns
trueif the atom's element is "Praseodymium", elsefalse. -
#proactinium?
Returns
trueif the atom's element is "Proactinium", elsefalse. -
#promethium?
Returns
trueif the atom's element is "Promethium", elsefalse. -
#protein? : Bool
Returns
trueif the atom belongs to a protein residue, elsefalse. -
#radium?
Returns
trueif the atom's element is "Radium", elsefalse. -
#radon?
Returns
trueif the atom's element is "Radon", elsefalse. -
#residue : Residue
Parent residue.
-
#residue=(new_res : Residue) : Residue
Assigns the parent residue.
-
#residue? : Residue | Nil
Parent residue.
-
#rhenium?
Returns
trueif the atom's element is "Rhenium", elsefalse. -
#rhodium?
Returns
trueif the atom's element is "Rhodium", elsefalse. -
#roentgenium?
Returns
trueif the atom's element is "Roentgenium", elsefalse. -
#rubidium?
Returns
trueif the atom's element is "Rubidium", elsefalse. -
#ruthenium?
Returns
trueif the atom's element is "Ruthenium", elsefalse. -
#rutherfordium?
Returns
trueif the atom's element is "Rutherfordium", elsefalse. -
#samarium?
Returns
trueif the atom's element is "Samarium", elsefalse. -
#scandium?
Returns
trueif the atom's element is "Scandium", elsefalse. -
#seaborgium?
Returns
trueif the atom's element is "Seaborgium", elsefalse. -
#selenium?
Returns
trueif the atom's element is "Selenium", elsefalse. -
#silicon?
Returns
trueif the atom's element is "Silicon", elsefalse. -
#silver?
Returns
trueif the atom's element is "Silver", elsefalse. -
#sodium?
Returns
trueif the atom's element is "Sodium", elsefalse. -
#solvent? : Bool
Returns
trueif the atom belongs to a solvent residue, elsefalse. -
#spec(io : IO) : Nil
Writes the atom specification to the given IO.
-
#spec : String
Returns the atom specification.
-
#strontium?
Returns
trueif the atom's element is "Strontium", elsefalse. -
#structure : Structure
Parent structure.
-
#sulfur?
Returns
trueif the atom's element is "Sulfur", elsefalse. -
#tantalum?
Returns
trueif the atom's element is "Tantalum", elsefalse. -
#target_valence : Int32
Returns the target valence based on the effective valence.
-
#technetium?
Returns
trueif the atom's element is "Technetium", elsefalse. -
#tellurium?
Returns
trueif the atom's element is "Tellurium", elsefalse. - #temperature_factor : Float64
- #temperature_factor=(temperature_factor : Float64)
-
#tennessine?
Returns
trueif the atom's element is "Tennessine", elsefalse. -
#terbium?
Returns
trueif the atom's element is "Terbium", elsefalse. -
#terminal? : Bool
Returns
trueif the atom is connected to one heavy atom (hydrogens are ignored), elsefalse. -
#thallium?
Returns
trueif the atom's element is "Thallium", elsefalse. -
#thorium?
Returns
trueif the atom's element is "Thorium", elsefalse. -
#thulium?
Returns
trueif the atom's element is "Thulium", elsefalse. -
#tin?
Returns
trueif the atom's element is "Tin", elsefalse. -
#titanium?
Returns
trueif the atom's element is "Titanium", elsefalse. -
#to_s(io : IO)
Appends a short String representation of this object which includes its class name and its object address.
-
#tungsten?
Returns
trueif the atom's element is "Tungsten", elsefalse. -
#typename : String | Nil
Atom typename.
-
#typename=(typename : String | Nil)
Atom typename.
-
#uranium?
Returns
trueif the atom's element is "Uranium", elsefalse. -
#valence : Int32
Returns the effective valence.
- #valence_electrons(*args, **options)
- #valence_electrons(*args, **options, &)
-
#vanadium?
Returns
trueif the atom's element is "Vanadium", elsefalse. - #vdw_radius : Float64
- #vdw_radius=(vdw_radius : Float64)
-
#water? : Bool
Returns
trueif the atom belongs to a water residue, elsefalse. - #within_covalent_distance?(rhs : self) : Bool
- #x(*args, **options)
- #x(*args, **options, &)
-
#xenon?
Returns
trueif the atom's element is "Xenon", elsefalse. - #y(*args, **options)
- #y(*args, **options, &)
-
#ytterbium?
Returns
trueif the atom's element is "Ytterbium", elsefalse. -
#yttrium?
Returns
trueif the atom's element is "Yttrium", elsefalse. - #z(*args, **options)
- #z(*args, **options, &)
-
#zinc?
Returns
trueif the atom's element is "Zinc", elsefalse. -
#zirconium?
Returns
trueif the atom's element is "Zirconium", elsefalse.
Constructor Detail
Creates an atom in structure with the given element and coordinates.
name belongs with topology: pass it together with residue. number defaults to the next 1-based insertion index.
Creates an atom in residue (and its parent structure). The element is guessed from name unless element is given.
Instance Method Detail
The comparison operator.
Returns -1, 0 or 1 depending on whether self precedes
rhs, equals to rhs or comes after rhs. The comparison is
done based on atom number.
atoms = Structure.read("peptide.pdb").atoms
atoms[0] <=> atoms[1] # => -1
atoms[1] <=> atoms[1] # => 0
atoms[2] <=> atoms[1] # => 1
Returns true if self and rhs are the same atom, else
false.
NOTE overrides the equality operator included by Comparable,
which uses the <=> operator thus returning true for two
different atoms that have the same number.
Returns the parent chain, or nil if the atom has no residue.
Appends a String representation of this object which includes its class name, its object address and the values of all instance variables.
class Person
def initialize(@name : String, @age : Int32)
end
end
Person.new("John", 32).inspect # => #<Person:0x10fd31f20 @name="John", @age=32>
Returns true if the atom number equals the given number, else
false.
Returns true if the atom name equals the given name, else
false.
Returns true if the atom name matches the given pattern, else
false.
Returns true if the atom number is included in the given range,
else false.
Returns true if the atom number is included in the given
numbers, else false.
Returns true if the atom name is included in the given
names, else false.
Returns true if the atom's element equals the given element,
else false.
Returns true if the atom matches the given template, else
false.
Checking for a match considers both atom name and element.
atom = Structure.read("peptide.pdb").dig 'A', 1, "CA"
atom.match?(Templates::Atom.new("CA")) # => true
atom.match?(Templates::Atom.new("CA", element: "N")) # => false
atom.match?(Templates::Atom.new("ND2")) # => false
TODO compare topology via Templates::Atom#top_spec
Hash-like container that stores the atom's additional properties
as key (string)-value pairs. A property's value can be any of the
primitive types (string, integer, float, or bool), and so it's
internally stored as Metadata::Any. Use the cast methods
(#as_*) to convert to the desired type.
atom.metadata["foo"] = 123
atom.metadata["foo"] # => Metadata::Any(123)
atom.metadata["foo"].as_i # => 123
atom.metadata["foo"].as_f # => 123.0
atom.metadata["foo"].as_s # raises TypeCastError
Atom name. Raises if unset. Use #name? when the atom may have
been created without a name (no topology).
Assigns the atom name. Raises if name is nil and the atom
belongs to a residue.
Atom name. Raises if unset. Use #name? when the atom may have
been created without a name (no topology).
Serial number (PDB-style id). Independent of the atom's index in
Structure#atoms. Assigned as 1-based insertion order when
omitted.
Serial number (PDB-style id). Independent of the atom's index in
Structure#atoms. Assigned as 1-based insertion order when
omitted.
Parent residue. Raises if the atom is not in a residue. Use
#residue? when hierarchy may be absent.
Assigns the parent residue. To remove the atom from the structure,
use #delete.
Parent residue. Raises if the atom is not in a residue. Use
#residue? when hierarchy may be absent.
Writes the atom specification to the given IO.
Atom specification is a short string representation encoding atom information including chain, residue, atom name, and atom number.
Returns the atom specification.
Atom specification is a short string representation encoding atom information including chain, residue, atom name, and atom number.
Returns the target valence based on the effective valence. This is useful for multi-valent elements (e.g., sulfur, phosphorus).
Returns true if the atom is connected to one heavy atom
(hydrogens are ignored), else false. This is useful to detect
terminal functional groups such as -CH₃, -NH₂, etc.
Appends a short String representation of this object which includes its class name and its object address.
class Person
def initialize(@name : String, @age : Int32)
end
end
Person.new("John", 32).to_s # => #<Person:0x10a199f20>
Atom typename. Usually specifies the atomic parameter set assigned to this atom within a given force field.
Atom typename. Usually specifies the atomic parameter set assigned to this atom within a given force field.
Returns the effective valence. This is equivalent to the sum of the bond orders.