class Chem::Chain

Defined in:

chem/core/chain.cr
chem/register_format.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(structure : Structure, id : Char) #

[View source]

Instance Method Detail

def <=>(rhs : self) : Int32 #

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 identifier.

chains = Structure.read("peptide.pdb").chains

chains[0] <=> chains[1] # => -1
chains[1] <=> chains[1] # => 0
chains[2] <=> chains[1] # => 1

[View source]
def [](number : Int32, insertion_code : Char | Nil = nil) : Residue #

[View source]
def []?(number : Int32, insertion_code : Char | Nil = nil) : Residue | Nil #

[View source]
def atoms : AtomView #

[View source]
def clear : self #

[View source]
def delete(residue : Residue) : Residue | Nil #

[View source]
def dig(number : Int32, insertion_code : Char | Nil) : Residue #

[View source]
def dig(number : Int32, insertion_code : Char | Nil, *subindexes) #

[View source]
def dig(number : Int32) : Residue #

[View source]
def dig(number : Int32, *subindexes) #

[View source]
def dig?(number : Int32, insertion_code : Char | Nil) : Residue | Nil #

[View source]
def dig?(number : Int32, insertion_code : Char | Nil, *subindexes) #

[View source]
def dig?(number : Int32) : Residue | Nil #

[View source]
def dig?(number : Int32, *subindexes) #

[View source]
def id : Char #

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

Appends a String representation of this object which includes its class name, its object address and the values of all instance variables.

class Person
  def initialize(@name : String, @age : Int32)
  end
end

Person.new("John", 32).inspect # => #<Person:0x10fd31f20 @name="John", @age=32>

[View source]
def matches?(id : Char) : Bool #

Returns true if the chain id equals the given character, else false.


[View source]
def matches?(ids : Enumerable(Char)) : Bool #

Returns true if the chain id is included in the given characters, else false.


[View source]
def polymer? : Bool #

[View source]
def renumber_residues_by(& : Residue -> _) : Nil #

Renumber residues based on the order by the output value of the block.


[View source]
def renumber_residues_by_connectivity : Nil #

Renumber residues based on bond information. Residue ordering is computed based on the link bond if available.


[View source]
def reset_cache : Nil #

[View source]
def residues : ResidueView #

[View source]
def spec(io : IO) : Nil #

Writes the chain specification to the given IO.

Chain specification is a short string representation encoding chain information including the id.


[View source]
def spec : String #

Returns the chain specification.

Chain specification is a short string representation encoding chain information including the id.


[View source]
def structure : Structure #

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

TODO remove this nonsensical line


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

TODO remove this nonsensical line


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

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


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

Writes the chain to output using the Chem::Gen file format. Arguments are forwarded to Chem::Gen::Writer.open.


[View source]
def to_mol(variant : Chem::Mol::Variant = :v2000) : String #

Returns a string representation of the chain using the Chem::Mol file format. Arguments are forwarded to Chem::Mol::Writer.open.


[View source]
def to_mol(output : IO | Path | String, variant : Chem::Mol::Variant = :v2000) : Nil #

Writes the chain to output using the Chem::Mol file format. Arguments are forwarded to Chem::Mol::Writer.open.


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

Writes the chain to output using the Chem::Mol2 file format. Arguments are forwarded to Chem::Mol2::Writer.open.


[View source]
def to_mol2 : String #

Returns a string representation of the chain using the Chem::Mol2 file format. Arguments are forwarded 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 chain using the Chem::PDB file format. Arguments are forwarded 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 chain to output using the Chem::PDB file format. Arguments are forwarded to Chem::PDB::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_xyz(extended : Bool = false, fields : Array(String) = [] of String) : String #

Returns a string representation of the chain using the Chem::XYZ file format. Arguments are forwarded 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 chain to output using the Chem::XYZ file format. Arguments are forwarded to Chem::XYZ::Writer.open.


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

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

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.


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

Writes the chain 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]