class Chem::Residue
- Chem::Residue
- Reference
- Object
Included Modules
- Chem::AtomCollection
- Comparable(Chem::Residue)
Defined in:
chem/core/residue.crConstructors
- .new(chain : Chain, number : Int32, insertion_code : Char | Nil, name : String)
- .new(chain : Chain, number : Int32, name : String) : self
Instance Method Summary
-
#<=>(other : self) : Int32
The comparison operator.
-
#==(rhs : self) : Bool
Returns
true
if this residue is the same as rhs, elsefalse
. -
#[](atom_t : Templates::Atom) : Atom
Returns the atom that matches atom_t.
- #[](*args, **options)
- #[](*args, **options, &)
-
#[]?(atom_t : Templates::Atom) : Atom | Nil
Returns the atom that matches atom_t.
- #[]?(*args, **options)
- #[]?(*args, **options, &)
-
#bonded?(other : self, bond_t : Templates::Bond, strict : Bool = true) : Bool
Returns true if
self
is bonded to other through bond_t, otherwise false. -
#bonded?(other : self, lhs : Templates::Atom | String, rhs : Templates::Atom | String, order : BondOrder | Nil = nil) : Bool
Returns true if
self
is bonded to other through a bond between lhs and rhs, otherwise false. -
#bonded?(other : self, lhs : Templates::Atom | String, rhs : Element, order : BondOrder | 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 : Templates::Atom | String, order : BondOrder | 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 : Element, order : BondOrder | 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 : Templates::Bond, 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
-
#code(default : Char = 'X') : Char
Returns a single-letter code associated with the residue's template.
- #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
Returns
true
if the residue is a DNA residue, elsefalse
. - #each_atom : Iterator(Atom)
- #each_atom(&block : Atom -> )
-
#each_bonded_residue(bond_t : Templates::Bond, forward_only : Bool = true, strict : Bool = true, & : Residue -> ) : Nil
Yields each residue bonded through bond_t.
-
#each_bonded_residue(& : Residue -> ) : Nil
Yields each bonded residue.
- #has_backbone? : Bool
-
#het? : Bool
Returns
true
if the residue is a non-standard (HET) residue, elsefalse
. - #hlxparams : Protein::HlxParams | Nil
-
#includes?(atom : Atom) : Bool
Returns
true
if the residue contains atom, elsefalse
. - #insertion_code : Char | Nil
- #insertion_code=(insertion_code : Char | Nil) : Char | Nil
-
#ion? : Bool
Returns
true
if the residue is a ion residue, elsefalse
. -
#levo? : Bool
Returns
true
is residue is levorotatory, otherwisefalse
. -
#membrane? : Bool
Returns
true
if the residue is a membrane residue, elsefalse
. - #n_atoms : Int32
- #name : String
- #name=(str : String) : String
- #number : Int32
- #number=(number : Int32) : Int32
- #omega : Float64
- #omega? : Float64 | Nil
-
#other? : Bool
Returns
true
if the residue is an unknown residue, elsefalse
. - #phi : Float64
- #phi? : Float64 | Nil
- #polymer? : Bool
-
#pred(strict : Bool = true, use_numbering : Bool = true) : Residue
Returns the preceding residue if exists, else raises
Error
. -
#pred?(strict : Bool = true, use_numbering : Bool = true) : Residue | Nil
Returns the preceding residue if exists, otherwise
nil
. -
#protein? : Bool
Returns
true
if the residue is a protein residue, elsefalse
. - #psi : Float64
- #psi? : Float64 | Nil
- #ramachandran_angles : Tuple(Float64, Float64)
- #sec : Protein::SecondaryStructure
- #sec=(sec : Protein::SecondaryStructure)
-
#solvent? : Bool
Returns
true
if the residue is a solvent residue, elsefalse
. -
#spec(io : IO) : Nil
Writes the residue specification to the given IO.
-
#spec : String
Returns the residue specification.
- #structure(*args, **options)
- #structure(*args, **options, &)
-
#succ(strict : Bool = true, use_numbering : Bool = true) : Residue
Returns the following residue if exists, else raises
Error
. -
#succ?(strict : Bool = true, use_numbering : Bool = true) : Residue | Nil
Returns the following residue if exists, otherwise
nil
. -
#template : Templates::Residue | Nil
Returns associated residue template if registered, otherwise nil.
-
#to_s(io : IO)
Appends a short String representation of this object which includes its class name and its object address.
- #trans? : Bool
- #type : ResidueType
- #type=(type : ResidueType)
-
#water? : Bool
Returns
true
if the residue is a water residue, elsefalse
.
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
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 template's name and element, otherwise
it raises IndexError
.
residue = Structure.read("peptide.pdb").residues[0]
residue[Templates::Atom("CA")] # => <Atom A:TRP1:CA(2)
residue[Templates::Atom("CA", element: "N")] # raises IndexError
residue[Templates::Atom("CX")] # raises IndexError
Returns the atom that matches atom_t.
Atom must match both atom template's name and element, otherwise
it returns nil
.
residue = Structure.read("peptide.pdb").residues[0]
residue[Templates::Atom("CA")] # => <Atom A:TRP1:CA(2)
residue[Templates::Atom("CA", element: "N")] # => nil
residue[Templates::Atom("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 = Templates::Bond.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 = Templates::Bond.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 = Templates::Bond.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 template, or elements:
a, b = Templates::Atom.new("C"), Templates::Atom.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 template are specified, this method returns false if missing:
missing_atom_t = Templates::Atom.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 template, or elements:
a, b = Templates::Atom.new("C"), Templates::Atom.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 template are specified, this method returns false if missing:
missing_atom_t = Templates::Atom.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 template, or elements:
a, b = Templates::Atom.new("C"), Templates::Atom.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 template are specified, this method returns false if missing:
missing_atom_t = Templates::Atom.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 template, or elements:
a, b = Templates::Atom.new("C"), Templates::Atom.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 template are specified, this method returns false if missing:
missing_atom_t = Templates::Atom.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. 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 = Templates::Bond.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: false).map(&.name) # => ["CYS"]
residues[1].bonded_residues(bond_t, forward_only: false).map(&.name) # => ["ALA", "THR"]
residues[2].bonded_residues(bond_t, forward_only: false).map(&.name) # => ["CYS"]
residues[3].bonded_residues(bond_t, forward_only: false).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 = Templates::Bond.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. 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 a single-letter code associated with the residue's template. If the residue has no associated template or it doesn't have a code, the method returns default.
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?
.
Yields each residue bonded through bond_t.
If forward_only is false
, then bond directionality is ignored.
If strict is false
, bond search checks elements only, and bond
order is ignored (fuzzy search).
See #bonded_residues(bond_t, forward_only, strict)
for examples.
Yields each bonded residue. Residues may be bonded through any atom.
See #bonded_residues
for examples.
Returns true
if the residue contains atom, else false
.
The check is done by name first, and then by atom equality.
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 preceding residue if exists, otherwise nil
.
It uses the link bond type of the associated residue template, 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.
Writes the residue specification to the given IO.
Residue specification is a short string representation encoding residue information including chain, name, number, and insertion code.
Returns the residue specification.
Residue specification is a short string representation encoding residue information including chain, name, number, and insertion code.
Returns the following residue if exists, otherwise nil
.
It uses the link bond type of the associated residue template, 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 associated residue template if registered, otherwise nil.
The template is fetched by the residue name.
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>
Returns true
if the residue is a water residue, else false
.
This is done by checking if the associated residue template (if
any) correspond to the water template.