class Chem::Atom

Included Modules

Defined in:

chem/core/atom.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(residue : Residue, serial : Int32, element : Element, name : String, coords : Spatial::Vec3, 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) #

[View source]

Instance Method Detail

def <=>(other : self) : Int32 #

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 serial.

atoms = Structure.read("peptide.pdb").atoms

atoms[0] <=> atoms[1] # => -1
atoms[1] <=> atoms[1] # => 0
atoms[2] <=> atoms[1] # => 1

[View source]
def ===(atom_t : Templates::Atom) : Bool #

Case equality. This is equivalent to #matches?.

structure = Structure.read "peptide.pdb"
desc = case structure.dig('A', 5, "CA")
       when Templates::Atom("C")  then "carbonyl carbon"
       when Templates::Atom("CA") then "alpha carbon"
       when Templates::Atom("CB") then "beta carbon"
       when Templates::Atom("CG") then "gamma carbon"
       when Templates::Atom("CD") then "delta carbon"
       when PeriodicTable::C         then "carbon"
       else                               "non-carbon"
       end
desc # => "alpha carbon"

[View source]
def ===(element : Element) : Bool #

Case equality. Returns true if atom's element is element, otherwise false.

structure = Structure.read "peptide.pdb"
desc = case structure.dig('A', 5, "CK")
       when Templates::Atom("C")  then "carbonyl carbon"
       when Templates::Atom("CA") then "alpha carbon"
       when Templates::Atom("CB") then "beta carbon"
       when Templates::Atom("CG") then "gamma carbon"
       when Templates::Atom("CD") then "delta carbon"
       when PeriodicTable::C         then "carbon"
       else                               "non-carbon"
       end
desc # => "non-carbon"

[View source]
def actinium? #

Returns true if the atom's element is "Actinium", else false.


[View source]
def aluminum? #

Returns true if the atom's element is "Aluminum", else false.


[View source]
def americium? #

Returns true if the atom's element is "Americium", else false.


[View source]
def antimony? #

Returns true if the atom's element is "Antimony", else false.


[View source]
def argon? #

Returns true if the atom's element is "Argon", else false.


[View source]
def arsenic? #

Returns true if the atom's element is "Arsenic", else false.


[View source]
def astatine? #

Returns true if the atom's element is "Astatine", else false.


[View source]
def atomic_number(*args, **options) #

[View source]
def atomic_number(*args, **options, &) #

[View source]
def barium? #

Returns true if the atom's element is "Barium", else false.


[View source]
def berkelium? #

Returns true if the atom's element is "Berkelium", else false.


[View source]
def beryllium? #

Returns true if the atom's element is "Beryllium", else false.


[View source]
def bismuth? #

Returns true if the atom's element is "Bismuth", else false.


[View source]
def bohrium? #

Returns true if the atom's element is "Bohrium", else false.


[View source]
def bonded?(to other : self) : Bool #

[View source]
def bonded_atoms : Array(Atom) #

[View source]
def bonds : BondArray #

[View source]
def boron? #

Returns true if the atom's element is "Boron", else false.


[View source]
def bromine? #

Returns true if the atom's element is "Bromine", else false.


[View source]
def cadmium? #

Returns true if the atom's element is "Cadmium", else false.


[View source]
def calcium? #

Returns true if the atom's element is "Calcium", else false.


[View source]
def californium? #

Returns true if the atom's element is "Californium", else false.


[View source]
def carbon? #

Returns true if the atom's element is "Carbon", else false.


[View source]
def cerium? #

Returns true if the atom's element is "Cerium", else false.


[View source]
def cesium? #

Returns true if the atom's element is "Cesium", else false.


[View source]
def chain(*args, **options) #

[View source]
def chain(*args, **options, &) #

[View source]
def chlorine? #

Returns true if the atom's element is "Chlorine", else false.


[View source]
def chromium? #

Returns true if the atom's element is "Chromium", else false.


[View source]
def cobalt? #

Returns true if the atom's element is "Cobalt", else false.


[View source]
def constraint : Constraint | Nil #

[View source]
def constraint=(constraint : Constraint | Nil) #

[View source]
def coords : Spatial::Vec3 #

[View source]
def coords=(coords : Spatial::Vec3) #

[View source]
def copernicium? #

Returns true if the atom's element is "Copernicium", else false.


[View source]
def copper? #

Returns true if the atom's element is "Copper", else false.


[View source]
def covalent_radius(*args, **options) #

[View source]
def covalent_radius(*args, **options, &) #

[View source]
def curium? #

Returns true if the atom's element is "Curium", else false.


[View source]
def darmstadtium? #

Returns true if the atom's element is "Darmstadtium", else false.


[View source]
def degree : Int32 #

Returns the number of bonds.


[View source]
def dna? : Bool #

Returns true if the atom belongs to a dna residue, else false.


[View source]
def dubnium? #

Returns true if the atom's element is "Dubnium", else false.


[View source]
def dysprosium? #

Returns true if the atom's element is "Dysprosium", else false.


[View source]
def each_bonded_atom : Iterator(Atom) #

[View source]
def each_bonded_atom(& : self -> ) : Nil #

[View source]
def einsteinium? #

Returns true if the atom's element is "Einsteinium", else false.


[View source]
def element : Element #

[View source]
def element=(element : Element) #

[View source]
def erbium? #

Returns true if the atom's element is "Erbium", else false.


[View source]
def europium? #

Returns true if the atom's element is "Europium", else false.


[View source]
def fermium? #

Returns true if the atom's element is "Fermium", else false.


[View source]
def flerovium? #

Returns true if the atom's element is "Flerovium", else false.


[View source]
def fluorine? #

Returns true if the atom's element is "Fluorine", else false.


[View source]
def formal_charge : Int32 #

[View source]
def formal_charge=(formal_charge : Int32) #

[View source]
def francium? #

Returns true if the atom's element is "Francium", else false.


[View source]
def gadolinium? #

Returns true if the atom's element is "Gadolinium", else false.


[View source]
def gallium? #

Returns true if the atom's element is "Gallium", else false.


[View source]
def germanium? #

Returns true if the atom's element is "Germanium", else false.


[View source]
def gold? #

Returns true if the atom's element is "Gold", else false.


[View source]
def hafnium? #

Returns true if the atom's element is "Hafnium", else false.


[View source]
def hassium? #

Returns true if the atom's element is "Hassium", else false.


[View source]
def heavy?(*args, **options) #

[View source]
def heavy?(*args, **options, &) #

[View source]
def helium? #

Returns true if the atom's element is "Helium", else false.


[View source]
def het? : Bool #

Returns true if the atom belongs to a non-standard (HET) residue, else false.


[View source]
def holmium? #

Returns true if the atom's element is "Holmium", else false.


[View source]
def hydrogen? #

Returns true if the atom's element is "Hydrogen", else false.


[View source]
def indium? #

Returns true if the atom's element is "Indium", else false.


[View source]
def iodine? #

Returns true if the atom's element is "Iodine", else false.


[View source]
def ion? : Bool #

Returns true if the atom belongs to a ion residue, else false.


[View source]
def iridium? #

Returns true if the atom's element is "Iridium", else false.


[View source]
def iron? #

Returns true if the atom's element is "Iron", else false.


[View source]
def krypton? #

Returns true if the atom's element is "Krypton", else false.


[View source]
def lanthanum? #

Returns true if the atom's element is "Lanthanum", else false.


[View source]
def lawrencium? #

Returns true if the atom's element is "Lawrencium", else false.


[View source]
def lead? #

Returns true if the atom's element is "Lead", else false.


[View source]
def lithium? #

Returns true if the atom's element is "Lithium", else false.


[View source]
def livermorium? #

Returns true if the atom's element is "Livermorium", else false.


[View source]
def lutetium? #

Returns true if the atom's element is "Lutetium", else false.


[View source]
def magnesium? #

Returns true if the atom's element is "Magnesium", else false.


[View source]
def manganese? #

Returns true if the atom's element is "Manganese", else false.


[View source]
def mass : Float64 #

[View source]
def mass=(mass : Float64) #

[View source]
def matches?(atom_t : Templates::Atom) : Bool #

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


[View source]
def max_valence(*args, **options) #

[View source]
def max_valence(*args, **options, &) #

[View source]
def meitnerium? #

Returns true if the atom's element is "Meitnerium", else false.


[View source]
def membrane? : Bool #

Returns true if the atom belongs to a membrane residue, else false.


[View source]
def mendelevium? #

Returns true if the atom's element is "Mendelevium", else false.


[View source]
def mercury? #

Returns true if the atom's element is "Mercury", else false.


[View source]
def metadata : Metadata #

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

[View source]
def missing_valence : Int32 #

[View source]
def molybdenum? #

Returns true if the atom's element is "Molybdenum", else false.


[View source]
def moscovium? #

Returns true if the atom's element is "Moscovium", else false.


[View source]
def name : String #

[View source]
def name=(name : String) #

[View source]
def neodymium? #

Returns true if the atom's element is "Neodymium", else false.


[View source]
def neon? #

Returns true if the atom's element is "Neon", else false.


[View source]
def neptunium? #

Returns true if the atom's element is "Neptunium", else false.


[View source]
def nickel? #

Returns true if the atom's element is "Nickel", else false.


[View source]
def nihonium? #

Returns true if the atom's element is "Nihonium", else false.


[View source]
def niobium? #

Returns true if the atom's element is "Niobium", else false.


[View source]
def nitrogen? #

Returns true if the atom's element is "Nitrogen", else false.


[View source]
def nobelium? #

Returns true if the atom's element is "Nobelium", else false.


[View source]
def occupancy : Float64 #

[View source]
def occupancy=(occupancy : Float64) #

[View source]
def oganesson? #

Returns true if the atom's element is "Oganesson", else false.


[View source]
def osmium? #

Returns true if the atom's element is "Osmium", else false.


[View source]
def other? : Bool #

Returns true if the atom belongs to a other residue, else false.


[View source]
def oxygen? #

Returns true if the atom's element is "Oxygen", else false.


[View source]
def palladium? #

Returns true if the atom's element is "Palladium", else false.


[View source]
def partial_charge : Float64 #

[View source]
def partial_charge=(partial_charge : Float64) #

[View source]
def phosphorus? #

Returns true if the atom's element is "Phosphorus", else false.


[View source]
def platinum? #

Returns true if the atom's element is "Platinum", else false.


[View source]
def plutonium? #

Returns true if the atom's element is "Plutonium", else false.


[View source]
def polonium? #

Returns true if the atom's element is "Polonium", else false.


[View source]
def potassium? #

Returns true if the atom's element is "Potassium", else false.


[View source]
def praseodymium? #

Returns true if the atom's element is "Praseodymium", else false.


[View source]
def proactinium? #

Returns true if the atom's element is "Proactinium", else false.


[View source]
def promethium? #

Returns true if the atom's element is "Promethium", else false.


[View source]
def protein? : Bool #

Returns true if the atom belongs to a protein residue, else false.


[View source]
def radium? #

Returns true if the atom's element is "Radium", else false.


[View source]
def radon? #

Returns true if the atom's element is "Radon", else false.


[View source]
def residue : Residue #

[View source]
def residue=(new_res : Residue) : Residue #

[View source]
def rhenium? #

Returns true if the atom's element is "Rhenium", else false.


[View source]
def rhodium? #

Returns true if the atom's element is "Rhodium", else false.


[View source]
def roentgenium? #

Returns true if the atom's element is "Roentgenium", else false.


[View source]
def rubidium? #

Returns true if the atom's element is "Rubidium", else false.


[View source]
def ruthenium? #

Returns true if the atom's element is "Ruthenium", else false.


[View source]
def rutherfordium? #

Returns true if the atom's element is "Rutherfordium", else false.


[View source]
def samarium? #

Returns true if the atom's element is "Samarium", else false.


[View source]
def scandium? #

Returns true if the atom's element is "Scandium", else false.


[View source]
def seaborgium? #

Returns true if the atom's element is "Seaborgium", else false.


[View source]
def selenium? #

Returns true if the atom's element is "Selenium", else false.


[View source]
def serial : Int32 #

[View source]
def serial=(serial : Int32) #

[View source]
def silicon? #

Returns true if the atom's element is "Silicon", else false.


[View source]
def silver? #

Returns true if the atom's element is "Silver", else false.


[View source]
def sodium? #

Returns true if the atom's element is "Sodium", else false.


[View source]
def solvent? : Bool #

Returns true if the atom belongs to a solvent residue, else false.


[View source]
def spec(io : IO) : Nil #

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.


[View source]
def spec : String #

Returns the atom specification.

Atom specification is a short string representation encoding atom information including chain, residue, atom name, and atom number.


[View source]
def strontium? #

Returns true if the atom's element is "Strontium", else false.


[View source]
def sulfur? #

Returns true if the atom's element is "Sulfur", else false.


[View source]
def tantalum? #

Returns true if the atom's element is "Tantalum", else false.


[View source]
def target_valence : Int32 #

Returns the target valence based on the effective valence. This is useful for multi-valent elements (e.g., sulfur, phosphorus).


[View source]
def technetium? #

Returns true if the atom's element is "Technetium", else false.


[View source]
def tellurium? #

Returns true if the atom's element is "Tellurium", else false.


[View source]
def temperature_factor : Float64 #

[View source]
def temperature_factor=(temperature_factor : Float64) #

[View source]
def tennessine? #

Returns true if the atom's element is "Tennessine", else false.


[View source]
def terbium? #

Returns true if the atom's element is "Terbium", else false.


[View source]
def thallium? #

Returns true if the atom's element is "Thallium", else false.


[View source]
def thorium? #

Returns true if the atom's element is "Thorium", else false.


[View source]
def thulium? #

Returns true if the atom's element is "Thulium", else false.


[View source]
def tin? #

Returns true if the atom's element is "Tin", else false.


[View source]
def titanium? #

Returns true if the atom's element is "Titanium", else false.


[View source]
def to_s(io : IO) #
Description copied from class Reference

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>

[View source]
def tungsten? #

Returns true if the atom's element is "Tungsten", else false.


[View source]
def typename : String | Nil #

Atom typename. Usually specifies the atomic parameter set assigned to this atom within a given force field.


[View source]
def typename=(typename : String | Nil) #

Atom typename. Usually specifies the atomic parameter set assigned to this atom within a given force field.


[View source]
def uranium? #

Returns true if the atom's element is "Uranium", else false.


[View source]
def valence : Int32 #

Returns the effective valence. This is equivalent to the sum of the bond orders.


[View source]
def valence_electrons(*args, **options) #

[View source]
def valence_electrons(*args, **options, &) #

[View source]
def vanadium? #

Returns true if the atom's element is "Vanadium", else false.


[View source]
def vdw_radius : Float64 #

[View source]
def vdw_radius=(vdw_radius : Float64) #

[View source]
def water? : Bool #

Returns true if the atom belongs to a water residue, else false.


[View source]
def within_covalent_distance?(rhs : self) : Bool #

[View source]
def x(*args, **options) #

[View source]
def x(*args, **options, &) #

[View source]
def xenon? #

Returns true if the atom's element is "Xenon", else false.


[View source]
def y(*args, **options) #

[View source]
def y(*args, **options, &) #

[View source]
def ytterbium? #

Returns true if the atom's element is "Ytterbium", else false.


[View source]
def yttrium? #

Returns true if the atom's element is "Yttrium", else false.


[View source]
def z(*args, **options) #

[View source]
def z(*args, **options, &) #

[View source]
def zinc? #

Returns true if the atom's element is "Zinc", else false.


[View source]
def zirconium? #

Returns true if the atom's element is "Zirconium", else false.


[View source]