class Chem::Structure

Included Modules

Defined in:

chem/core/structure.cr
chem/register_format.cr

Constructors

Instance Method Summary

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

Constructor Detail

def self.build(*args, **options, &) : self #

[View source]
def self.from_chgcar(input : IO | Path | String) : self #

Returns the structure encoded in input using the Chem::VASP::Chgcar file format. Arguments are forwarded to Chem::VASP::Chgcar::Reader.open.


[View source]
def self.from_cube(input : IO | Path | String) : self #

Returns the structure encoded in input using the Chem::Cube file format. Arguments are forwarded to Chem::Cube::Reader.open.


[View source]
def self.from_gen(input : IO | Path | String, guess_bonds : Bool = false, guess_names : Bool = false) : self #

Returns the structure encoded in input using the Chem::Gen file format. Arguments are forwarded to Chem::Gen::Reader.open.


[View source]
def self.from_locpot(input : IO | Path | String) : self #

Returns the structure encoded in input using the Chem::VASP::Locpot file format. Arguments are forwarded to Chem::VASP::Locpot::Reader.open.


[View source]
def self.from_mol(input : IO | Path | String) : self #

Returns the structure encoded in input using the Chem::Mol file format. Arguments are forwarded to Chem::Mol::Reader.open.


[View source]
def self.from_mol2(input : IO | Path | String) : self #

Returns the structure encoded in input using the Chem::Mol2 file format. Arguments are forwarded to Chem::Mol2::Reader.open.

If input contains multiple entries, this method returns the first one only. Use Array#from_mol2 or Chem::Mol2::Reader#each to get multiple entries instead.


[View source]
def self.from_pdb(input : IO | Path | String, alt_loc : Char | Nil = nil, chains : Enumerable(Char) | String | Nil = nil, guess_bonds : Bool = false, het : Bool = true) : self #

Returns the structure encoded in input using the Chem::PDB file format. Arguments are forwarded to Chem::PDB::Reader.open.

If input contains multiple entries, this method returns the first one only. Use Array#from_pdb or Chem::PDB::Reader#each to get multiple entries instead.


[View source]
def self.from_poscar(input : IO | Path | String, guess_bonds : Bool = false, guess_names : Bool = false) : self #

Returns the structure encoded in input using the Chem::VASP::Poscar file format. Arguments are forwarded to Chem::VASP::Poscar::Reader.open.


[View source]
def self.from_psf(input : IO | Path | String) : self #

Returns the structure encoded in input using the Chem::PSF file format. Arguments are forwarded to Chem::PSF::Reader.open.


[View source]
def self.from_sdf(input : IO | Path | String) : self #

Returns the structure encoded in input using the Chem::SDF file format. Arguments are forwarded to Chem::SDF::Reader.open.

If input contains multiple entries, this method returns the first one only. Use Array#from_sdf or Chem::SDF::Reader#each to get multiple entries instead.


[View source]
def self.from_xyz(input : IO | Path | String, guess_bonds : Bool = false, guess_names : Bool = false) : self #

Returns the structure encoded in input using the Chem::XYZ file format. Arguments are forwarded to Chem::XYZ::Reader.open.

If input contains multiple entries, this method returns the first one only. Use Array#from_xyz or Chem::XYZ::Reader#each to get multiple entries instead.


[View source]
def self.new(topology : Topology = Topology.new, source_file : Path | String | Nil = nil) #

[View source]
def self.read(input : IO | Path | String, format : Chem::Format | String) : self #

Returns the structure encoded in the specified file using format. Raises ArgumentError if format has required arguments or cannot read Chem::Structure.

If input contains multiple entries, this method returns the first one only. Use Array.read or Chem::FormatReader::MultiEntry#each (reader can be obtained via Chem::Format.reader) to get multiple entries instead.

The supported file formats are Chem::Cube, Chem::Gen, Chem::Mol2, Chem::Mol, Chem::PDB, Chem::PSF, Chem::SDF, Chem::VASP::Chgcar, Chem::VASP::Locpot, Chem::VASP::Poscar, Chem::XYZ. Use the .from_* methods to customize how the object is decoded in the corresponding file format if possible.


[View source]
def self.read(path : Path | String) : self #

Returns the structure encoded in 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.

If the file contains multiple entries, this method returns the first one only. Use Array.read to get multiple entries instead.

The supported file formats are the following:

Use the .from_* methods to customize how the object is decoded in the corresponding file format if possible.


[View source]

Instance Method Detail

def [](*args, **options) #

TODO remove this delegates... directly use the topology class


[View source]
def [](*args, **options, &) #

TODO remove this delegates... directly use the topology class


[View source]
def []?(*args, **options) #

TODO remove this delegates... directly use the topology class


[View source]
def []?(*args, **options, &) #

TODO remove this delegates... directly use the topology class


[View source]
def atoms(*args, **options) #

TODO remove this delegates... directly use the topology class


[View source]
def atoms(*args, **options, &) #

TODO remove this delegates... directly use the topology class


[View source]
def biases : Array(Chem::Bias) #

[View source]

Returns the unit cell. Raises Spatial::NotPeriodicError if cell is nil.


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

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

def chains(*args, **options) #

TODO remove this delegates... directly use the topology class


[View source]
def chains(*args, **options, &) #

TODO remove this delegates... directly use the topology class


[View source]
def clear : self #

[View source]
def clone : self #

Returns a deep copy of self, that is, every chain/residue/atom is copied.

Unlike array-like classes in the language, #dup (shallow copy) is not possible.

structure = Structure.new "/path/to/file.pdb"
other = structure.clone
other == structure     # => true
other.same?(structure) # => false

structure.dig('A', 23, "OG").partial_charge         # => 0.0
other.dig('A', 23, "OG").partial_charge             # => 0.0
structure.dig('A', 23, "OG").partial_charge = 0.635 # => 0.635
other.dig('A', 23, "OG").partial_charge             # => 0.0

[View source]

[View source]
def delete(*args, **options) #

TODO remove this delegates... directly use the topology class


[View source]
def delete(*args, **options, &) #

TODO remove this delegates... directly use the topology class


[View source]
def dig(*args, **options) #

TODO remove this delegates... directly use the topology class


[View source]
def dig(*args, **options, &) #

TODO remove this delegates... directly use the topology class


[View source]
def dig?(*args, **options) #

TODO remove this delegates... directly use the topology class


[View source]
def dig?(*args, **options, &) #

TODO remove this delegates... directly use the topology class


[View source]
def each_atom : Iterator(Atom) #

[View source]
def each_atom(& : Atom -> ) #

[View source]
def each_chain : Iterator(Chain) #

[View source]
def each_chain(& : Chain -> ) #

[View source]
def each_residue : Iterator(Residue) #

[View source]
def each_residue(& : Residue -> ) #

[View source]
def experiment : Structure::Experiment | Nil #

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

[View source]
def extract(copy_properties : Bool = true, & : Atom -> Bool) : self #

Returns a new structure containing the selected atoms by the given block.

Structure properties such as biases, unit cell, title, etc. are copied only if copy_properties is true.


[View source]
def metadata : Chem::Metadata #

Hash-like container that stores the structure's properties as key (string)-value pairs. A property's value can be any of the primitive types (string, integer, float, or bool), and so it's internally stored as Metadata::Any. Use the cast methods (#as_*) to convert to the desired type.

structure.metadata["foo"] = 123
structure.metadata["foo"]      # => Metadata::Any(123)
structure.metadata["foo"].as_i # => 123
structure.metadata["foo"].as_f # => 123.0
structure.metadata["foo"].as_s # raises TypeCastError

[View source]
def n_atoms : Int32 #

[View source]
def n_chains : Int32 #

[View source]
def n_residues : Int32 #

[View source]
def periodic? : Bool #

[View source]
def residues(*args, **options) #

TODO remove this delegates... directly use the topology class


[View source]
def residues(*args, **options, &) #

TODO remove this delegates... directly use the topology class


[View source]
def source_file : Path | Nil #

[View source]
def title : String #

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

[View source]
def to_gen(fractional : Bool = false) : String #

Returns a string representation of the structure using the Chem::Gen file format. Arguments are fowarded to Chem::Gen::Writer.open.


[View source]
def to_gen(output : IO | Path | String, fractional : Bool = false) : Nil #

Writes the structure to output using the Chem::Gen file format. Arguments are fowarded to Chem::Gen::Writer.open.


[View source]
def to_mol2(output : IO | Path | String) : Nil #

Writes the structure to output using the Chem::Mol2 file format. Arguments are fowarded to Chem::Mol2::Writer.open.


[View source]
def to_mol2 : String #

Returns a string representation of the structure using the Chem::Mol2 file format. Arguments are fowarded to Chem::Mol2::Writer.open.


[View source]
def 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 structure using the Chem::PDB file format. Arguments are fowarded to Chem::PDB::Writer.open.


[View source]
def 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 structure to output using the Chem::PDB file format. Arguments are fowarded to Chem::PDB::Writer.open.


[View source]
def to_poscar(order : Array(Element) | Array(String) | Nil = nil, fractional : Bool = false, wrap : Bool = false) : String #

Returns a string representation of the structure using the Chem::VASP::Poscar file format. Arguments are fowarded to Chem::VASP::Poscar::Writer.open.


[View source]
def to_poscar(output : IO | Path | String, order : Array(Element) | Array(String) | Nil = nil, fractional : Bool = false, wrap : Bool = false) : Nil #

Writes the structure to output using the Chem::VASP::Poscar file format. Arguments are fowarded to Chem::VASP::Poscar::Writer.open.


[View source]
def to_pymol(output : IO | Path | String) : Nil #

Writes the structure to output using the Chem::PyMOL file format. Arguments are fowarded to Chem::PyMOL::Writer.open.


[View source]
def to_pymol : String #

Returns a string representation of the structure using the Chem::PyMOL file format. Arguments are fowarded to Chem::PyMOL::Writer.open.


[View source]
def to_s(io : IO) #
Description copied from class Reference

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>

[View source]
def to_stride(output : IO | Path | String) : Nil #

Writes the structure to output using the Chem::Protein::Stride file format. Arguments are fowarded to Chem::Protein::Stride::Writer.open.


[View source]
def to_stride : String #

Returns a string representation of the structure using the Chem::Protein::Stride file format. Arguments are fowarded to Chem::Protein::Stride::Writer.open.


[View source]
def to_vmd(output : IO | Path | String) : Nil #

Writes the structure to output using the Chem::VMD file format. Arguments are fowarded to Chem::VMD::Writer.open.


[View source]
def to_vmd : String #

Returns a string representation of the structure using the Chem::VMD file format. Arguments are fowarded to Chem::VMD::Writer.open.


[View source]
def to_xyz(extended : Bool = false, fields : Array(String) = [] of String) : String #

Returns a string representation of the structure using the Chem::XYZ file format. Arguments are fowarded to Chem::XYZ::Writer.open.


[View source]
def to_xyz(output : IO | Path | String, extended : Bool = false, fields : Array(String) = [] of String) : Nil #

Writes the structure to output using the Chem::XYZ file format. Arguments are fowarded to Chem::XYZ::Writer.open.


[View source]
def topology : Topology #

[View source]
def write(output : IO | Path | String, format : Chem::Format | String) : Nil #

Writes the structure to output using format. Raises ArgumentError if format has required arguments or cannot write Chem::Structure.

The supported file formats are Chem::Gen, Chem::Mol2, Chem::PDB, Chem::Protein::Stride, Chem::PyMOL, Chem::VASP::Poscar, Chem::VMD, Chem::XYZ. Use the #to_* methods to customize how the object is written in the corresponding file format if possible.


[View source]
def write(path : Path | String) : Nil #

Writes the structure 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:

Use the #to_* methods to customize how the object is written in the corresponding file format if possible.


[View source]