class Chem::Topology
- Chem::Topology
- Reference
- Object
Included Modules
Defined in:
chem/topology.crConstant Summary
-
MAX_CHAINS =
62
Class Method Summary
-
.guess_element(atom_name : String) : Element
Returns the element of an atom based on its name.
-
.guess_element?(atom_name : String) : Element | Nil
Returns the element of an atom based on its name if possible, else
nil
.
Instance Method Summary
- #[](chain_id : Char) : Chain
- #[]?(chain_id : Char) : Chain | Nil
-
#angles : Array::View(Angle)
Returns the angles in the topology.
-
#angles=(angles : Array(Chem::Angle))
Angles in the topology.
-
#apply_templates : Nil
Assign bonds, formal charges, and residue's type from known residue types.
-
#bonds : Array(Bond)
Returns the bonds between all atoms.
- #clear : self
- #clone : self
- #delete(ch : Chain) : Chain | Nil
- #dig(id : Char) : Chain
- #dig(id : Char, *subindexes)
- #dig?(id : Char) : Chain | Nil
- #dig?(id : Char, *subindexes)
-
#dihedrals : Array::View(Dihedral)
Returns the dihedral angles in the topology.
-
#dihedrals=(dihedrals : Array(Chem::Dihedral))
Dihedral angles in the topology.
- #each_atom : Iterator(Atom)
- #each_atom(&block : Atom -> )
- #each_chain : Iterator(Chain)
- #each_chain(&block : Chain -> )
- #each_residue : Iterator(Residue)
- #each_residue(&block : Residue -> )
-
#guess_angles : Nil
Determines the angles based on connectivity.
-
#guess_bonds(perceive_order : Bool = true) : Nil
Determines the bonds from connectivity and geometry.
-
#guess_dihedrals : Nil
Determines the dihedral angles based on connectivity.
-
#guess_formal_charges : Nil
Sets the formal charges based on the existing bonds.
-
#guess_impropers : Nil
Determines the improper dihedral angles based on connectivity.
-
#guess_names : Nil
Detects and assigns topology names from known residue templates based on bond information.
-
#guess_unknown_residue_types : Nil
Determines the type of unknown residues based on their neighbors.
-
#impropers : Array::View(Improper)
Returns the improper dihedral angles in the topology.
-
#impropers=(impropers : Array(Chem::Improper))
Improper dihedral angles in the topology.
- #n_atoms : Int32
- #n_chains : Int32
- #n_residues : Int32
-
#renumber_residues_by(& : Residue -> _) : Nil
Renumber residues per chain based on the order by the output value of the block.
-
#renumber_residues_by_connectivity(split_chains : Bool = true) : Nil
Renumber chain and residues based on bond information.
- #structure : Structure
- #structure=(structure : Structure)
Instance methods inherited from module Chem::ResidueCollection
each_residue : Iterator(Residue)each_residue(&block : Residue -> ) each_residue, each_residue_fragment(& : ResidueView -> ) : Nil each_residue_fragment, each_secondary_structure(reuse : Bool | Array(Residue) = false, strict : Bool = true, handedness : Bool = true) : Iterator(ResidueView)
each_secondary_structure(reuse : Bool | Array(Residue) = false, strict : Bool = true, handedness : Bool = true, & : ResidueView, Protein::SecondaryStructure -> ) : Nil each_secondary_structure, link_bond : Templates::Bond | Nil link_bond, n_residues : Int32 n_residues, reset_secondary_structure : self reset_secondary_structure, residue_fragments : Array(ResidueView) residue_fragments, residues : ResidueView residues, sec=(seclist : Array(Protein::SecondaryStructure)) : Array(Protein::SecondaryStructure)
sec=(sec : Protein::SecondaryStructure) : Protein::SecondaryStructure sec=, secondary_structures(strict : Bool = true, handedness : Bool = true) : Array(ResidueView) secondary_structures
Instance methods inherited from module Chem::ChainCollection
chains : ChainView
chains,
each_chain : Iterator(Chain)each_chain(&block : Chain -> ) each_chain, n_chains : Int32 n_chains
Instance methods inherited from module Chem::AtomCollection
atoms : AtomView
atoms,
bonds : Array(Bond)
bonds,
coords : Spatial::CoordinatesProxy
coords,
coords=(coords : Enumerable(Spatial::Vec3)) : Enumerable(Spatial::Vec3)
coords=,
each_atom : Iterator(Atom)each_atom(&block : Atom -> ) each_atom, each_fragment(& : AtomView -> ) : Nil each_fragment, formal_charge : Int32 formal_charge, formal_charges : Array(Int32) formal_charges, fragments : Array(AtomView) fragments, has_hydrogens? : Bool has_hydrogens?, n_atoms : Int32 n_atoms, to_gen(fractional : Bool = false) : String
to_gen(output : IO | Path | String, fractional : Bool = false) : Nil to_gen, to_mol2(output : IO | Path | String) : Nil
to_mol2 : String to_mol2, to_pdb(bonds : Chem::PDB::Writer::BondOptions = Chem::PDB::Writer::BondOptions.flags(Het, Disulfide), renumber : Bool = true, ter_on_fragment : Bool = false) : String
to_pdb(output : IO | Path | String, bonds : Chem::PDB::Writer::BondOptions = Chem::PDB::Writer::BondOptions.flags(Het, Disulfide), renumber : Bool = true, ter_on_fragment : Bool = false) : Nil to_pdb, to_xyz(extended : Bool = false, fields : Array(String) = [] of String) : String
to_xyz(output : IO | Path | String, extended : Bool = false, fields : Array(String) = [] of String) : Nil to_xyz, write(output : IO | Path | String, format : Chem::Format | String) : Nil
write(path : Path | String) : Nil write
Class Method Detail
Returns the element of an atom based on its name. Raises Error
if
the element could not be determined. Refer to .guess_element?
for
details.
Returns the element of an atom based on its name if possible, else
nil
.
This is a naive approach, where the first letter of atom_name is tested first to get the element, then the name with trailing digits stripped.
Instance Method Detail
Returns the angles in the topology. See Angle
for definition.
Angles in the topology. See Angle
for definition.
Assign bonds, formal charges, and residue's type from known residue types.
Returns the dihedral angles in the topology. See Dihedral
for
definition.
Dihedral angles in the topology. See Dihedral
for definition.
Determines the angles based on connectivity. See Angle
for
definition.
NOTE It deletes existing angles.
Determines the bonds from connectivity and geometry.
Bonds are added when the pairwise distances are within the
corresponding covalent distances (see
PeriodicTable.covalent_distance
). Bonds are added until the atoms'
valences are fulfilled. If extraneous bonds are found (beyond the
maximum number of bonds, see Element#max_bonds
), the longest ones
will be removed.
Bonds to atoms that could potential be as cations (K, Na, etc.) are disfavored such that they won't be added if the neighbor is over-valence or the bond can be substituted by increasing the bond order of another bond of the neighbor (e.g., C-O + K is preferred over C-O-K since C-O can be converted to C=O).
Bond orders are assigned based on the following procedure. First,
atom hybridization is guessed from the geometry. Then, the bond
orders are determined such that both atoms must have the same
hybridization to assign a double (sp2) or triple (sp) bond. Bond
order is only changed if the bonded atoms have missing valence. If
multiple bonded atoms fulfill the requirements for increasing the
bond order, the atom with the most missing valence or that is
closest to the current atom is selected first. This procedure is
loosely based on OpenBabel's PerceiveBondOrders
function.
Determines the dihedral angles based on connectivity. See Dihedral
for definition.
NOTE It deletes existing dihedral angles.
Sets the formal charges based on the existing bonds.
For most cases, the formal charge is calculated as
Nele - Tele + V
where Nele is the number of valence electrons, Tele is the
number of electrons in the full valence shell, and V is the
effective valence, which is equivalent to the sum of the bond
orders. Tele is usually 8 following the octet rule, but there are
some exceptions (see Element#target_electrons
).
If an atom has no bonds, it is considered as a monoatomic ion, where
the formal charge is set according to the following rule: if the
valence electrons < 4 (cation, e.g., Na+, Mg2+), the formal charge
is equal to the number of valence electrons, else (anions, e.g.,
Cl-) it is equal to Nele - Tele
.
WARNING Elements that have no valence determined such as transition metals are ignored.
Determines the improper dihedral angles based on connectivity. See
Improper
for definition.
Improper dihedral angles are often used to constraint the planarity of certain functional groups of molecules in molecular mechanics simulations, and so not every possible improper dihedral angle is required. This method lists every possible improper dihedral angle following the formal definition, which will probably generate extraneous angles.
NOTE It deletes existing improper dihedral angles.
Detects and assigns topology names from known residue templates based on bond information.
The method creates chains and residues according to the detected fragments and residue matches. The procedure is as follows. First, atoms are split into fragments, where each fragment is scanned for matches to known residue templates. Then, fragments are divided into polymer (e.g., peptide) and non-polymer (e.g., water) fragments based on the number of residues per fragment. Non-polymer residues are grouped together by their type (i.e., ion, solvent, etc.). Finally, every polymer fragment and group of non-polymer fragments are assigned to a unique chain and residues are created for each match.
NOTE Fragments are assigned to a unique chain unless the chain limit (62) is reached, otherwise all residues are assigned to the same chain.
WARNING Existing chains and residues are invalid after calling this method so do not cache them.
Determines the type of unknown residues based on their neighbors.
Returns the improper dihedral angles in the topology. See Improper
for definition.
Improper dihedral angles in the topology. See Improper
for
definition.
Renumber residues per chain based on the order by the output value of the block.
NOTE This won't change the order of the existing chains.
Renumber chain and residues based on bond information.
Residue fragments are assigned to unique chains unless
split_chains is false
, which keeps existing chains intact.
Residue ordering is computed based on the link bond if available.
NOTE existing chains are reused to re-arrang the residues among them, so avoid caching them before calling this.