struct Chem::ResidueView
- Chem::ResidueView
- Struct
- Value
- Object
Included Modules
- Array::Wrapper(Chem::Residue)
Defined in:
chem/core/residue_view.crchem/register_format.cr
Instance Method Summary
- #atoms : AtomView
- #chains : ChainView
-
#each_residue_fragment(& : ResidueView -> ) : Nil
Iterates over residue-wise fragments.
-
#each_secondary_structure(reuse : Bool | Array(Residue) = false, strict : Bool = true, handedness : Bool = true) : Iterator(ResidueView)
Returns an iterator over secondary structure elements (SSEs).
-
#each_secondary_structure(reuse : Bool | Array(Residue) = false, strict : Bool = true, handedness : Bool = true, & : ResidueView, Protein::SecondaryStructure -> ) : Nil
Iterates over secondary structure elements (SSEs), yielding both the residues and secondary structure.
- #link_bond : Templates::Bond | Nil
-
#reset_secondary_structure : self
Sets secondary structure of every residue to none.
-
#residue_fragments : Array(ResidueView)
Returns residue-wise fragments.
- #sec=(seclist : Array(Protein::SecondaryStructure)) : Array(Protein::SecondaryStructure)
- #sec=(sec : Protein::SecondaryStructure) : Protein::SecondaryStructure
-
#secondary_structures(strict : Bool = true, handedness : Bool = true) : Array(ResidueView)
TODO rename to
#chunks_by_sec
or#sec_chunks
-
#to_gen(fractional : Bool = false) : String
Returns a string representation of the residue view using the
Chem::Gen
file format. -
#to_gen(output : IO | Path | String, fractional : Bool = false) : Nil
Writes the residue view to output using the
Chem::Gen
file format. -
#to_mol(variant : Chem::Mol::Variant = :v2000) : String
Returns a string representation of the residue view using the
Chem::Mol
file format. -
#to_mol(output : IO | Path | String, variant : Chem::Mol::Variant = :v2000) : Nil
Writes the residue view to output using the
Chem::Mol
file format. -
#to_mol2(output : IO | Path | String) : Nil
Writes the residue view to output using the
Chem::Mol2
file format. -
#to_mol2 : String
Returns a string representation of the residue view using the
Chem::Mol2
file format. -
#to_pdb(bonds : Chem::PDB::Writer::BondOptions = Chem::PDB::Writer::BondOptions.flags(Het, Disulfide), renumber : Bool = true, ter_on_fragment : Bool = false) : String
Returns a string representation of the residue view using the
Chem::PDB
file format. -
#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
Writes the residue view to output using the
Chem::PDB
file format. -
#to_xyz(extended : Bool = false, fields : Array(String) = [] of String) : String
Returns a string representation of the residue view using the
Chem::XYZ
file format. -
#to_xyz(output : IO | Path | String, extended : Bool = false, fields : Array(String) = [] of String) : Nil
Writes the residue view to output using the
Chem::XYZ
file format. -
#write(output : IO | Path | String, format : Chem::Format | String) : Nil
Writes the residue view to output using format.
-
#write(path : Path | String) : Nil
Writes the residue view to the specified file.
Instance methods inherited from module Indexable(Chem::Residue)
[](idxs : Tuple) : Tuple[](idxs : Enumerable(Int)) : Array(T)
[](*idxs : Int) : Tuple [], sentence(io : IO, separator : String = ", ", *, pair_separator : String = " and ", tail_separator : String = ", and ", & : T, IO -> ) : Nil
sentence(io : IO, separator : String = ", ", *, pair_separator : String = " and ", tail_separator : String = ", and ") : Nil
sentence(separator : String = ", ", *, pair_separator : String = " and ", tail_separator : String = ", and ", & : T -> ) : String
sentence(separator : String = ", ", *, pair_separator : String = " and ", tail_separator : String = ", and ") : String sentence
Instance methods inherited from module Enumerable(Chem::Residue)
===(atom : Chem::Atom) : Bool===(chain : Chem::Chain) : Bool
===(residue : Chem::Residue) : Bool ===, average(weights : Indexable(Number))
average(weights : Indexable(Number), & : T -> _) average, find(pattern, if_none default = nil) find, find!(pattern) find!, mean
mean(& : T -> _) mean
Instance Method Detail
Iterates over residue-wise fragments.
A fragment is an array of inter-connected residues. Fragments are
dynamically computed by iterating over Residue#bonded_residues
of the selected residues.
NOTE fragments are scoped to the current list of residues such that bonded residues not contained in the list are omitted, e.g., given the list of residues [1, 2, 3, 4, 7, 8] belonging to the sequence 1-2-3-4-5-6 7-8-9, this method will return [[1, 2, 3, 4], [7, 8]], not [[1, 2, 3, 4, 5, 6], [7, 8, 9]].
TODO Rename to #each_fragment
.
Returns an iterator over secondary structure elements (SSEs).
SSEs are defined as segments of consecutive, bonded residues that
have the same secondary structure. If strict
is false
,
residues are grouped by their secondary structure type. If
handedness
is false
, handedness is not taken into account when
strict
is false
. See Protein::SecondaryStructure#equals?
.
Let's say a structure
has 25 residues with two beta strands
spanning residues 3-12 and 18-23, then:
iter = structure.each_secondary_structure
iter.next.map &.number # => [1, 2]
iter.next.map &.number # => [3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
iter.next.map &.number # => [13, 14, 15, 16, 17]
iter.next.map &.number # => [18, 19, 20, 21, 22, 23]
iter.next.map &.number # => [24, 25]
iter.next # => Iterator::Stop::INSTANCE
Note that non-protein residues are skipped over.
By default, a new array is created and yielded for each slice when
invoking next
.
- If reuse is
false
, a new array is created for each chunk. - If reuse is
true
, an array is created once and reused. - If reuse is an
Array
, it will be reused instead.
The latter can be used to prevent many memory allocations when each slice of interest is to be used in a read-only fashion.
TODO Rename to chunk_by_sec
Iterates over secondary structure elements (SSEs), yielding both the residues and secondary structure.
SSEs are defined as segments of consecutive, bonded residues that
have the same secondary structure. If strict
is false
,
residues are grouped by their secondary structure type. If
handedness
is false
, handedness is not taken into account when
strict
is false
. See Protein::SecondaryStructure#equals?
.
Let's say a structure
has 25 residues with two beta strands
spanning residues 3-12 and 18-23, then:
structure.each_secondary_structure do |sec, ary|
puts "#{sec.to_s} at #{ary[0].number}..#{ary[-1].number}"
end
Prints:
None at 1..2
BetaStrand at 3..12
None at 13..17
BetaStrand at 18..23
None at 24..25
Note that non-protein residues are skipped over.
By default, a new array is created and yielded for each slice when
invoking next
.
- If reuse is
false
, a new array is created for each chunk. - If reuse is
true
, an array is created once and reused. - If reuse is an
Array
, it will be reused instead.
The latter can be used to prevent many memory allocations when each slice of interest is to be used in a read-only fashion.
TODO Rename to each_chunk_by_sec
TODO yield the sec first (similar to #chunks)
Sets secondary structure of every residue to none.
TODO remove this (residues.sec = :none is clear and shorter)
Returns residue-wise fragments. See #each_residue_fragment.
TODO rename to #fragments
TODO rename to #chunks_by_sec
or #sec_chunks
Returns a string representation of the residue view using
the Chem::Gen
file format. Arguments are forwarded to
Chem::Gen::Writer.open
.
Writes the residue view to output using the Chem::Gen
file format. Arguments are forwarded to Chem::Gen::Writer.open
.
Returns a string representation of the residue view using
the Chem::Mol
file format. Arguments are forwarded to
Chem::Mol::Writer.open
.
Writes the residue view to output using the Chem::Mol
file format. Arguments are forwarded to Chem::Mol::Writer.open
.
Writes the residue view to output using the Chem::Mol2
file format. Arguments are forwarded to Chem::Mol2::Writer.open
.
Returns a string representation of the residue view using
the Chem::Mol2
file format. Arguments are forwarded to
Chem::Mol2::Writer.open
.
Returns a string representation of the residue view using
the Chem::PDB
file format. Arguments are forwarded to
Chem::PDB::Writer.open
.
Writes the residue view to output using the Chem::PDB
file format. Arguments are forwarded to Chem::PDB::Writer.open
.
Returns a string representation of the residue view using
the Chem::XYZ
file format. Arguments are forwarded to
Chem::XYZ::Writer.open
.
Writes the residue view to output using the Chem::XYZ
file format. Arguments are forwarded to Chem::XYZ::Writer.open
.
Writes the residue view to output using format. Raises
ArgumentError
if format has required arguments or cannot
write Chem::ResidueView
.
The supported file formats are Chem::Gen
, Chem::Mol2
, Chem::Mol
, Chem::PDB
, Chem::XYZ
. Use the
#to_*
methods to customize how the object is written in the
corresponding file format if possible.
Writes the residue view to the specified file. The file
format is chosen based on the filename (see
Chem::Format#from_filename
). Raises ArgumentError
if the
file format cannot be determined.
The supported file formats are the following:
Chem::Gen
(.gen)Chem::Mol
(.mol)Chem::Mol2
(.mol2)Chem::PDB
(.ent, .pdb)Chem::XYZ
(.xyz)
Use the #to_*
methods to customize how the object is written
in the corresponding file format if possible.