class Chem::Structure::Builder

Defined in:

chem/core/structure/builder.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(guess_bonds : Bool = false, guess_names : Bool = false, use_templates : Bool = false, **options) #

[View source]

Instance Method Detail

def atom(name : String, serial : Int32, coords : Spatial::Vec3, element : Element, **options) : Atom #

[View source]
def atom(name : String, serial : Int32, coords : Spatial::Vec3, **options) : Atom #

[View source]
def atom(element : Element | Symbol, coords : Spatial::Vec3, **options) : Atom #

Creates an Atom of element at the given coordinates. Extra named arguments are forwarded to the Atom constructor.

The atom name will set to the element's symbol followed by the number of atoms with the same element within the current residue.

structure = Chem::Structure.build do |builder|
  builder.residue
  builder.atom Chem::PeriodicTable::H, Chem::Spatial::Vec3.zero
  builder.atom Chem::PeriodicTable::C, Chem::Spatial::Vec3.zero
  builder.atom Chem::PeriodicTable::H, Chem::Spatial::Vec3.zero
  builder.atom Chem::PeriodicTable::H, Chem::Spatial::Vec3.zero
  builder.atom Chem::PeriodicTable::C, Chem::Spatial::Vec3.zero
  builder.residue
  builder.atom Chem::PeriodicTable::H, Chem::Spatial::Vec3.zero
  builder.atom Chem::PeriodicTable::C, Chem::Spatial::Vec3.zero
  builder.atom Chem::PeriodicTable::N, Chem::Spatial::Vec3.zero
end
structure.atoms.map(&.name) # => ["H1", "C1", "H2", "H3", "C2", "H1", "C1", "N1"]

Note that the atom names resets on a new residue.

WARNING This method assumes that residues are created in sequence, so calling #residue will always create a new residue, not retrieving a preceding one. Otherwise, the order of the atom names will be reset.


[View source]
def atom(name : String, coords : Spatial::Vec3, **options) : Atom #

[View source]
def atom(index : Int) : Atom #

[View source]
def atom(coords : Spatial::Vec3, **options) : Atom #

[View source]
def atom?(index : Int) : Atom | Nil #

[View source]
def bond(name : String, other : String, order : BondOrder = :single) : Bond #

[View source]
def bond(i : Int, j : Int, order : BondOrder = :single, aromatic : Bool = false) : Bond #

[View source]
def bonds(bond_table : Hash(Tuple(Int32, Int32), BondOrder)) : Nil #

[View source]
def build : Structure #

[View source]

[View source]
def cell(a : Float64, b : Float64, c : Float64) : Spatial::Parallelepiped #

[View source]
def cell(cell : Spatial::Parallelepiped | Nil) #

[View source]
def cell : Spatial::Parallelepiped | Nil #

[View source]

[View source]
def chain(id : Char) : Chain #

[View source]
def chain : Chain #

[View source]
def chain(id : Char, & : self -> ) : Nil #

[View source]
def chain(& : self -> ) : Nil #

[View source]
def current_chain : Chain | Nil #

[View source]
def current_residue : Residue | Nil #

[View source]
def expt(expt : Structure::Experiment | Nil) #

[View source]
def residue(name : String, number : Int32, inscode : Char | Nil = nil) : Residue #

[View source]
def residue(name : String) : Residue #

[View source]
def residue : Residue #

[View source]
def residue(name : String, number : Int32, inscode : Char | Nil = nil, & : self -> ) : Nil #

[View source]
def residue(name : String, & : self -> ) : Nil #

[View source]
def secondary_structure(i : Tuple(Char, Int32, Char | Nil), j : Tuple(Char, Int32, Char | Nil), type : Protein::SecondaryStructure) : Nil #

[View source]
def secondary_structure(ri : Residue, rj : Residue, type : Protein::SecondaryStructure) #

[View source]
def title(title : String) #

[View source]