class Chem::Residue
- Chem::Residue
- Reference
- Object
Included Modules
- Chem::AtomCollection
- Comparable(Chem::Residue)
Defined in:
chem/core/residue.crConstructors
- .new(name : String, number : Int32, insertion_code : Char | Nil, chain : Chain)
- .new(name : String, number : Int32, chain : Chain)
Instance Method Summary
-
#<=>(rhs : self) : Int32
The comparison operator.
-
#==(rhs : self) : Bool
Returns
true
if this residue is the same as rhs, elsefalse
. -
#[](atom_t : Topology::AtomType) : Atom
Returns the atom that matches atom_t.
- #[](*args, **options)
- #[](*args, **options, &)
-
#[]?(atom_t : Topology::AtomType) : Atom | Nil
Returns the atom that matches atom_t.
- #[]?(*args, **options)
- #[]?(*args, **options, &)
-
#bonded?(other : self, bond_t : Topology::BondType, strict : Bool = true) : Bool
Returns true if
self
is bonded to other through bond_t, otherwise false. -
#bonded?(other : self, lhs : Element, rhs : Element, order : Int | Nil = nil) : Bool
Returns true if
self
is bonded to other through a bond between lhs and rhs, otherwise false. -
#bonded?(other : self, lhs : Topology::AtomType | String, rhs : Element, order : Int | Nil = nil) : Bool
Returns true if
self
is bonded to other through a bond between lhs and rhs, otherwise false. -
#bonded?(other : self, lhs : Element, rhs : Topology::AtomType | String, order : Int | Nil = nil) : Bool
Returns true if
self
is bonded to other through a bond between lhs and rhs, otherwise false. -
#bonded?(other : self, lhs : Topology::AtomType | String, rhs : Topology::AtomType | String, order : Int | Nil = nil) : Bool
Returns true if
self
is bonded to other through a bond between lhs and rhs, otherwise false. -
#bonded?(other : self) : Bool
Returns true if
self
is bonded to other, otherwise false. -
#bonded_residues(bond_t : Topology::BondType, forward_only : Bool = true, strict : Bool = true) : Array(Residue)
Returns residues bonded through bond_t.
-
#bonded_residues : Array(Residue)
Returns bonded residues.
- #chain : Chain
- #chain=(new_chain : Chain) : Chain
- #cis? : Bool
- #clear : self
- #delete(atom : Atom) : Atom | Nil
-
#dextro? : Bool
Returns
true
is residue is dextrorotatory, otherwisefalse
. - #dig(name : String) : Atom
- #dig?(name : String) : Atom | Nil
- #dna? : Bool
- #dssp : Char
- #each_atom : Iterator(Atom)
- #each_atom(&block : Atom -> )
- #has_backbone? : Bool
- #hlxparams : Spatial::HlxParams | Nil
- #insertion_code : Char | Nil
- #insertion_code=(insertion_code : Char | Nil)
- #inspect(io : ::IO) : Nil
- #ion? : Bool
- #kind : Kind
- #kind=(kind : Kind)
-
#levo? : Bool
Returns
true
is residue is levorotatory, otherwisefalse
. - #n_atoms : Int32
- #name : String
- #name=(str : String) : String
-
#next(strict : Bool = true, use_numbering : Bool = true) : Residue | Nil
Returns the following residue if exists, otherwise
nil
. - #number : Int32
- #number=(number : Int32)
- #omega : Float64
- #omega? : Float64 | Nil
- #other? : Bool
- #phi : Float64
- #phi? : Float64 | Nil
- #polymer? : Bool
-
#previous(strict : Bool = true, use_numbering : Bool = true) : Residue | Nil
Returns the preceding residue if exists, otherwise
nil
. - #protein? : Bool
- #psi : Float64
- #psi? : Float64 | Nil
- #ramachandran_angles : Tuple(Float64, Float64)
- #sec : Protein::SecondaryStructure
- #sec=(sec : Protein::SecondaryStructure)
- #solvent? : Bool
- #structure(*args, **options)
- #structure(*args, **options, &)
- #to_s(io : ::IO)
- #trans? : Bool
-
#type : Topology::ResidueType | Nil
Returns associated residue type if registered, otherwise nil.
Instance methods inherited from module Chem::AtomCollection
atoms : AtomView
atoms,
bonds : Array(Bond)
bonds,
coords : Spatial::CoordinatesProxy
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(output : ::IO | Path | String, *args, **options) : Nil
to_gen(*args, **options) : String to_gen, to_mol2(output : ::IO | Path | String, *args, **options) : Nil
to_mol2(*args, **options) : String to_mol2, to_pdb(output : ::IO | Path | String, *args, **options) : Nil
to_pdb(*args, **options) : String to_pdb, to_poscar(output : ::IO | Path | String, *args, **options) : Nil
to_poscar(*args, **options) : String to_poscar, to_xyz(output : ::IO | Path | String, *args, **options) : Nil
to_xyz(*args, **options) : String to_xyz
Constructor Detail
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 chain id, residue number, and insertion code if
present.
residues = Structure.read "peptide.pdb"
residues[0] # => <Residue A:TRP1>
residues[1] # => <Residue A:GLY1A>
residues[2] # => <Residue A:SER1B>
residues[3] # => <Residue A:ASN1C>
residues[4] # => <Residue A:VAL2>
residues[5] # => <Residue B:THR1>
residues[6] # => <Residue B:ASN2>
residues[0] <=> residues[1] # => -1
residues[1] <=> residues[1] # => 0
residues[2] <=> residues[1] # => 1
residues[0] <=> residues[5] # => -1
residues[5] <=> residues[6] # => -1
Returns true
if this residue is the same as rhs, else false
.
NOTE overrides the equality operator included by Comparable
,
which uses the <=>
operator thus returning true for two
different residues that have the same chain id, number and
insertion code.
Returns the atom that matches atom_t.
Atom must match both atom type's name and element, otherwise it
raises IndexError
.
residue = Structure.read("peptide.pdb").residues[0]
residue[Topology::AtomType("CA")] # => <Atom A:TRP1:CA(2)
residue[Topology::AtomType("CA", element: "N")] # raises IndexError
residue[Topology::AtomType("CX")] # raises IndexError
Returns the atom that matches atom_t.
Atom must match both atom type's name and element, otherwise it
returns nil
.
residue = Structure.read("peptide.pdb").residues[0]
residue[Topology::AtomType("CA")] # => <Atom A:TRP1:CA(2)
residue[Topology::AtomType("CA", element: "N")] # => nil
residue[Topology::AtomType("CX")] # => nil
Returns true if self
is bonded to other through bond_t,
otherwise false.
# Covalent ligand (JG7) is bonded to CYS sidechain
residues = Structure.read("ala-cys-thr-jg7.pdb").residues
bond_t = Topology::BondType.new "C", "N"
residues[0].bonded?(residues[1], bond_t) # => true
residues[1].bonded?(residues[2], bond_t) # => true
residues[2].bonded?(residues[3], bond_t) # => false
residues[1].bonded?(residues[3], bond_t) # => false
Bond check follows the directionality of bond_t, that is, the
left and right atoms are looked up in self
and other,
respectively:
residues[0].bonded?(residues[1], bond_t) # => true
residues[1].bonded?(residues[0], bond_t) # => false
Note that bond order is taken into account, e.g.:
bond_t = Topology::BondType.new "C", "N", order: 2
residues[0].bonded?(residues[1], bond_t) # => false
If strict is false, it uses elements only instead to look for bonded atoms, and bond order is ignored.
bond_t = Topology::BondType.new "C", "NX", order: 2
residues[0].bonded?(residues[1], bond_t) # => false
residues[0].bonded?(residues[1], bond_t, strict: false) # => true
Returns true if self
is bonded to other through a bond between
lhs and rhs, otherwise false.
# Covalent ligand (JG7) is bonded to CYS sidechain
residues = Structure.read("ala-cys-thr-jg7.pdb").residues
One can use atom names, atom types or elements:
a, b = Topology::AtomType.new("C"), Topology::AtomType.new("N")
residues[0].bonded? residues[1], "C", "N" # => true
residues[0].bonded? residues[1], a, b # => true
residues[0].bonded? residues[1], a, PeriodicTable::N # => true
residues[0].bonded? residues[1], PeriodicTable::C, b # => true
residues[1].bonded? residues[2], a, b # => true
residues[1].bonded? residues[3], a, b # => false
residues[2].bonded? residues[3], a, b # => false
Note that lhs and rhs are looked up in self
and other,
respectively, i.e., the arguments are not interchangeable:
residues[0].bonded? residues[1], "C", "N" # => true
residues[0].bonded? residues[1], "N", "C" # => false
When atom names or atom types are specified, this method returns false if missing:
missing_atom_t = Topology::AtomType.new("OZ5")
residues[0].bonded? residues[1], "CX1", "N" # => false
residues[0].bonded? residues[1], missing_atom_t, "N" # => false
residues[0].bonded? residues[1], "C", PeriodicTable::Mg # => false
When elements are specified, all atoms of that element are tested:
residues[1].bonded? residues[2], "C", PeriodicTable::N # => true
residues[1].bonded? residues[2], "SG", PeriodicTable::C # => true
If order is specified, it also check for bond order, otherwise it is ignored:
residues[0].bonded? residues[1], "C", "N" # => true
residues[0].bonded? residues[1], "C", "N", 1 # => true
residues[0].bonded? residues[1], "C", "N", 2 # => false
Returns true if self
is bonded to other through a bond between
lhs and rhs, otherwise false.
# Covalent ligand (JG7) is bonded to CYS sidechain
residues = Structure.read("ala-cys-thr-jg7.pdb").residues
One can use atom names, atom types or elements:
a, b = Topology::AtomType.new("C"), Topology::AtomType.new("N")
residues[0].bonded? residues[1], "C", "N" # => true
residues[0].bonded? residues[1], a, b # => true
residues[0].bonded? residues[1], a, PeriodicTable::N # => true
residues[0].bonded? residues[1], PeriodicTable::C, b # => true
residues[1].bonded? residues[2], a, b # => true
residues[1].bonded? residues[3], a, b # => false
residues[2].bonded? residues[3], a, b # => false
Note that lhs and rhs are looked up in self
and other,
respectively, i.e., the arguments are not interchangeable:
residues[0].bonded? residues[1], "C", "N" # => true
residues[0].bonded? residues[1], "N", "C" # => false
When atom names or atom types are specified, this method returns false if missing:
missing_atom_t = Topology::AtomType.new("OZ5")
residues[0].bonded? residues[1], "CX1", "N" # => false
residues[0].bonded? residues[1], missing_atom_t, "N" # => false
residues[0].bonded? residues[1], "C", PeriodicTable::Mg # => false
When elements are specified, all atoms of that element are tested:
residues[1].bonded? residues[2], "C", PeriodicTable::N # => true
residues[1].bonded? residues[2], "SG", PeriodicTable::C # => true
If order is specified, it also check for bond order, otherwise it is ignored:
residues[0].bonded? residues[1], "C", "N" # => true
residues[0].bonded? residues[1], "C", "N", 1 # => true
residues[0].bonded? residues[1], "C", "N", 2 # => false
Returns true if self
is bonded to other through a bond between
lhs and rhs, otherwise false.
# Covalent ligand (JG7) is bonded to CYS sidechain
residues = Structure.read("ala-cys-thr-jg7.pdb").residues
One can use atom names, atom types or elements:
a, b = Topology::AtomType.new("C"), Topology::AtomType.new("N")
residues[0].bonded? residues[1], "C", "N" # => true
residues[0].bonded? residues[1], a, b # => true
residues[0].bonded? residues[1], a, PeriodicTable::N # => true
residues[0].bonded? residues[1], PeriodicTable::C, b # => true
residues[1].bonded? residues[2], a, b # => true
residues[1].bonded? residues[3], a, b # => false
residues[2].bonded? residues[3], a, b # => false
Note that lhs and rhs are looked up in self
and other,
respectively, i.e., the arguments are not interchangeable:
residues[0].bonded? residues[1], "C", "N" # => true
residues[0].bonded? residues[1], "N", "C" # => false
When atom names or atom types are specified, this method returns false if missing:
missing_atom_t = Topology::AtomType.new("OZ5")
residues[0].bonded? residues[1], "CX1", "N" # => false
residues[0].bonded? residues[1], missing_atom_t, "N" # => false
residues[0].bonded? residues[1], "C", PeriodicTable::Mg # => false
When elements are specified, all atoms of that element are tested:
residues[1].bonded? residues[2], "C", PeriodicTable::N # => true
residues[1].bonded? residues[2], "SG", PeriodicTable::C # => true
If order is specified, it also check for bond order, otherwise it is ignored:
residues[0].bonded? residues[1], "C", "N" # => true
residues[0].bonded? residues[1], "C", "N", 1 # => true
residues[0].bonded? residues[1], "C", "N", 2 # => false
Returns true if self
is bonded to other through a bond between
lhs and rhs, otherwise false.
# Covalent ligand (JG7) is bonded to CYS sidechain
residues = Structure.read("ala-cys-thr-jg7.pdb").residues
One can use atom names, atom types or elements:
a, b = Topology::AtomType.new("C"), Topology::AtomType.new("N")
residues[0].bonded? residues[1], "C", "N" # => true
residues[0].bonded? residues[1], a, b # => true
residues[0].bonded? residues[1], a, PeriodicTable::N # => true
residues[0].bonded? residues[1], PeriodicTable::C, b # => true
residues[1].bonded? residues[2], a, b # => true
residues[1].bonded? residues[3], a, b # => false
residues[2].bonded? residues[3], a, b # => false
Note that lhs and rhs are looked up in self
and other,
respectively, i.e., the arguments are not interchangeable:
residues[0].bonded? residues[1], "C", "N" # => true
residues[0].bonded? residues[1], "N", "C" # => false
When atom names or atom types are specified, this method returns false if missing:
missing_atom_t = Topology::AtomType.new("OZ5")
residues[0].bonded? residues[1], "CX1", "N" # => false
residues[0].bonded? residues[1], missing_atom_t, "N" # => false
residues[0].bonded? residues[1], "C", PeriodicTable::Mg # => false
When elements are specified, all atoms of that element are tested:
residues[1].bonded? residues[2], "C", PeriodicTable::N # => true
residues[1].bonded? residues[2], "SG", PeriodicTable::C # => true
If order is specified, it also check for bond order, otherwise it is ignored:
residues[0].bonded? residues[1], "C", "N" # => true
residues[0].bonded? residues[1], "C", "N", 1 # => true
residues[0].bonded? residues[1], "C", "N", 2 # => false
Returns true if self
is bonded to other, otherwise false.
Residues may be bonded by any two atoms.
# Covalent ligand (JG7) is bonded to CYS sidechain
residues = Structure.read("ala-cys-thr-jg7.pdb").residues
residues[0].bonded?(residues[1]) # => true
residues[1].bonded?(residues[2]) # => true
residues[2].bonded?(residues[3]) # => false
residues[1].bonded?(residues[3]) # => true
Returns residues bonded through bond_t.
Returned residues are ordered by their chain id, residue number and insertion code if present (refer to #<=>).
# Covalent ligand (JG7) is bonded to CYS sidechain
residues = Structure.read("ala-cys-thr-jg7.pdb").residues
bond_t = Topology::BondType.new("C", "N")
residues[0].bonded_residues(bond_t).map(&.name) # => ["CYS"]
residues[1].bonded_residues(bond_t).map(&.name) # => ["THR"]
residues[2].bonded_residues(bond_t).map(&.name) # => []
residues[3].bonded_residues(bond_t).map(&.name) # => []
If forward_only is false, then bond directionality is ignored:
residues[0].bonded_residues(bond_t, forward_only: true).map(&.name) # => ["CYS"]
residues[1].bonded_residues(bond_t, forward_only: true).map(&.name) # => ["ALA", "THR"]
residues[2].bonded_residues(bond_t, forward_only: true).map(&.name) # => ["CYS"]
residues[3].bonded_residues(bond_t, forward_only: true).map(&.name) # => []
If strict is false, bond search checks elements only, and bond
order is ignored (fuzzy search). In the following example, using
strict: false
makes that any C-N bond is accepted regardless of
atom names or bond order:
bond_t = Topology::BondType.new "C", "NX", order: 2
residues[0].bonded_residues(bond_t, strict: false).map(&.name) # => ["CYS"]
residues[1].bonded_residues(bond_t, strict: false).map(&.name) # => ["THR"]
residues[2].bonded_residues(bond_t, strict: false).map(&.name) # => []
residues[3].bonded_residues(bond_t, strict: false).map(&.name) # => []
Returns bonded residues. Residues may be bonded through any atom.
Returned residues are ordered by their chain id, residue number and insertion code if present (refer to #<=>).
# Covalent ligand (JG7) is bonded to CYS sidechain
residues = Structure.read("ala-cys-thr-jg7.pdb").residues
residues[0].bonded_residues.map(&.name) # => ["CYS"]
residues[1].bonded_residues.map(&.name) # => ["ALA", "THR", "JG7"]
residues[2].bonded_residues.map(&.name) # => ["CYS"]
residues[3].bonded_residues.map(&.name) # => ["CYS"]
Returns true
is residue is dextrorotatory, otherwise false
.
A residue is considered to be dextrorotatory if the improper angle C-CA-C-CB is negative.
Note that this method returns false
if the residue doesn't have
any of such atoms, therefore it's not always equal to the inverse
of #levo?
.
Returns true
is residue is levorotatory, otherwise false
.
A residue is considered to be levorotatory if the improper angle C-CA-C-CB is positive.
Note that this method returns false
if the residue doesn't have
any of such atoms, therefore it's not always equal to the inverse
of #dextro?
.
Returns the following residue if exists, otherwise nil
.
It uses the link bond type of the associated residue type, if
present, to search for the next residue. Thus, link bond
determines the direction, e.g., C(i)-N(i+1). Be aware that atom
types must match exactly to find a residue unless strict is
false
.
Otherwise, it returns a bonded residue whose number and insertion
code come just after those of self
. This fallback can be
disabled by setting use_numbering to false
.
Note that when multiple residues can be connected to the same residue (e.g., branched polymers), it returns the first residue among them.
Returns the preceding residue if exists, otherwise nil
.
It uses the link bond type of the associated residue type, if
present, to search for the previous residue. Thus, link bond
determines the direction, e.g., C(i-1)-N(i). Be aware that atom
types must match exactly to find a residue unless strict is
false
.
Otherwise, it returns a bonded residue whose number and insertion
code come just before those of self
. This fallback can be
disabled by setting use_numbering to false
.
Note that when multiple residues can be connected to the same residue (e.g., branched polymers), it returns the last residue among them.
Returns associated residue type if registered, otherwise nil.
The type of a residue is fetched by its name.