[Molby Document Home] [Contents]

Class: | AtomRef
Parent: | Object

### Description

#### Overview

The class AtomRef points to an atom at a particular index in a Molecule. AtomRef does not implement initialize nor new methods; i.e. an AtomRef object cannot be created explicitly by calling a constructor method. Instead, an AtomRef object is implicitly created as a return value from such methods like Molecule#add_atom, Molecule#create_atom, Molecule#duplicate_atom and MolEnumerable#[], or given as a block argument in some iterator methods such as Molecule#each_atom and MolEnumerable#each.

#### Atom Attributes

An atom has many attributes, such as name, position, atom type, and so on. All atom attributes have the corresponding accessor (setter/getter) methods. Some attributes are read only, in which case the setter functions cause exception.

#### AtomRef and Editing Molecule

An AtomRef object contains the parent Molecule and the index (non-negative integer). The index is not automatically updated when the parent Molecule is edited; in such case, the AtomRef object may point to a different atom, or even cause out-of-range exception.

    % m = Molecule.from_formula("CH4")
    -->#<Molecule:0x16400bf8>
    % m.dump
       0 RES.1   C1   ""   C    0.000   0.000   0.000  0.000 [1,2,3,4]
       1 RES.1   H1   ""   H   -0.355   0.000  -1.020  0.000 [0]
       2 RES.1   H2   ""   H   -0.355  -0.883   0.510  0.000 [0]
       3 RES.1   H3   ""   H   -0.355   0.883   0.510  0.000 [0]
       4 RES.1   H4   ""   H    1.080   0.000   0.000  0.000 [0]
    -->
    % a = m.atoms[3]  #  Points to "H3"
    -->#<AtomRef:0x164449e8>
    % a.name
    -->"H3"
    % m.remove([0])   #  Remove atom 0: now "a" points to "H4"
    -->
    % a.name
    -->"H4"
    % m.remove([0])   #  Remove atom 0 again: "a" becomes out of range
    -->
    % a.name
    ("atom index out of range" exception)

### Public Instance methods

aniso → [f1, f2, f3, f4, f5, f6]
self.aniso = [f1, f2, f3, f4, f5, f6]

Get/set the anisotropic thermal factors. If no anisotropic thermal factors are defined for this atom, the getter returns nil. The setter can accept nil as the right-hand value, which clears anisotropic thermal factors for this atom.

The anisotropic thermal parameters are defined as in ORTEP type 0, with the following formula:

exp(-(f1*h2 + f2*k2 + f3*l2 + 2*f4*h*k + 2*f5*h*l + 2*f6*k*l))

The thermal parameters are described in crystallographic coordinates, so that it is only meaningful when a crystallographic unit cell is defined (see also: Molecule#cell, Molecule#cell=). Nevertheless, setting anisotropic parameters without defining a unit cell does not cause exception, in which case a trivial unit cell ([1, 0, 0], [0, 1, 0], [0, 0, 1]) is implicitly assumed.

atom_type → String
self.atom_type = String

Get/set the atom type for molecular mechanics calculations. The atom type is a string consisting of up to 4 printable ASCII characters (case sensitive), with an optional "variant" part consisting of a period followed by one case-insensitive alphanumeric character. Thus, the following strings are all valid atom types: "ca", "C*", "Zn" ("zn" or "ZN" are different atom types), "CAHN.1".

The atom type with a variant part behaves similarly as the same atom type without the variant, except when a parameter is explicitly defined for the variant-containing atom type. For example, suppose there is an atom with type "cp.1" bound to an atom with type "ca"; when a bond parameter "ca-cp.1" is defined, this parameter is used for this bond; otherwise, a bond parameter "ca-cp" is looked for, and if one is found it is used for this bond.

The atom type "X" and "x" are reserved as wildcards. When parameters are looked for, these atom types match any atom types. Note that these are only wildcard atom types defined in Molby; atom types such as "C*" or "C?" are just individual atom types, with no "matching" behavior.

atomic_number → Integer
self.atomic_number = Integer

Get/set the atomic number. Setting an atomic number also causes change of the element and weight attributes.

See Also: AtomRef#element, AtomRef#weight.

charge → Float
self.charge = Float

Get/set the partial charge. The partial charge is a value used in molecular mechanics calculations for evaluation of electrostatic interactions, and is different from an integer charge as defined in PDB format. For the latter attribute, use AtomRef#int_charge and AtomRef#int_charge= methods.

connects → Array of Integers

Get the connection table. A connection table is a list of atoms that are connected to this atom, represented by an array of atom indices (0-based). This is a read-only attribute; if new bonds are to be created or removed, Molecule#create_bond or Molecule#remove_bond should be used.

element → String
self.element = String

Get/set the chemical element. The chemical element is represented by a two-character string, the first uppercase character and the second (optional) lowercase character, although the right-hand argument for the setter is case-insensitive. It follows that the three-character element symbols for newly discovered elements cannot be used; they are hardly useful for molecular modeling anyway.

Setting the chemical element also causes change of the atomic_number and weight attributes.

See Also: AtomRef#atomic_number, AtomRef#weight.

f → Vector3D
self.f = Vector3D

Get the force value from the last MM/MD calculation. The value is in internal force unit, amu Å fs-2 (amu is the atomic mass unit, fs is femtosecond). The setter method is also implemented, however it is seldom useful.

fix_force → Float
self.fix_force = Float

Get/set the force constant to fix the atom at the particular position during MM/MD calculations. The value is in kcal/mol. If the force constant is positive, an auxiliary harmonic potential is applied for this atom. If the force constant is negative, the forces are calculated as usual but the velocity of the atom is set to zero in every step. The latter is physically problematic, so use of negative force is not recommended.

See Also: AtomRef#fix_pos

fix_pos → Vector3D
self.fix_pos = Vector3D

Get/set the position to fix the atom during MM/MD calculations. The fix_force should also be set.

See Also: AtomRef#fix_force

fract_r → Vector3D
self.fract_r = Vector3D

Get/set the fractional coordinates as a Vector3D. If the crystallographic unit cell is not defined, these methods are equivalent to AtomRef#r and AtomRef#r=, respectively.

fract_x → Float
self.fract_x = Float

Get/set the fractional coordinate x. If the crystallographic unit cell is not defined, these methods are equivalent to AtomRef#x and AtomRef#x=, respectively.

fract_y → Float
self.fract_y = Float

Get/set the fractional coordinate y. If the crystallographic unit cell is not defined, these methods are equivalent to AtomRef#y and AtomRef#y=, respectively.

fract_z → Float
self.fract_z = Float

Get/set the fractional coordinate z. If the crystallographic unit cell is not defined, these methods are equivalent to AtomRef#z and AtomRef#z=, respectively.

index → Integer

Get the atom index as an integer. This is a read-only attribute; if you want to change the order of the atoms, you should use Molecule#renumber_atoms.

int_charge → Integer
self.int_charge = Integer

Get/set the integer charge. This is the integer charge of the atom as defined in PDB format, and different from the partial (fractional) charge used in MM/MD calculations. For the latter attribute, use AtomRef#charge and AtomRef#charge= methods.

name → String
self.name = String

Get/set the atom name. An atom name consists of up to 4 printable ASCII characters.

occupancy → Float
self.occupancy = Float

Get/set the occupancy.

r → Vector3D
self.r = Vector3D

Get/set the atom position as a Vector3D. The atom positions are always in cartesian coordinates, even when the crystallographic unit cell is defined. To handle crystallographic fractional coordinates, use AtomRef#fract_r and AtomRef#fract_r=.

res_name → String

Get the residue name. A residue name consists of up to 4 printable ASCII characters. This is a read-only attribute; if a residue name is to be changed, use Molecule#assign_residue.

res_seq → Integer

Get the residue number. Residue numbers are 1-based, and the number 0 means "no residue assigned". This is a read-only attribute; if a residue number is to be changed, use Molecule#assign_residue.

seg_name → String
self.seg_name = String

Get/set the segment name. A segment name consists of up to 4 printable ASCII characters.

seg_seq → Integer
self.seg_seq = Integer

Get/set the segment number.

temp_factor → Float
self.temp_factor = Float

Get/set the (isotropic) temperature factor. For anisotropic temperature factors, see AtomRef#aniso.

v → Vector3D
self.v = Vector3D

Get/set the velocity value from the last MM/MD calculation. The value is in Å fs-1 (fs is femtosecond).

weight → Float
self.weight = Float

Get/set the atomic weight. This attribute is automatically updated when atomic_number or element is modified, whereas changing the weight attribute does not cause automatic update of either atomic_number or element attribute.

x → Float
self.x = Float

Get/set the cartesian coordinate x. To handle crystallographic fractional coordinates, use AtomRef#fract_x and AtomRef#fract_x=.

y → Float
self.y = Float

Get/set the cartesian coordinate y. To handle crystallographic fractional coordinates, use AtomRef#fract_y and AtomRef#fract_y=.

z → Float
self.z = Float

Get/set the cartesian coordinate z. To handle crystallographic fractional coordinates, use AtomRef#fract_z and AtomRef#fract_z=.