Tools

These tools may call external programs to perform each task. Please verify the installation of the necessary tool for each case.

Add hydrogens with OpenBabel

PDBTools.add_hydrogens!Function
add_hydrogens!(atoms::AbstractVector{<:Atom}; pH=7.0, obabel="obabel", debug=false)

Add hydrogens to a PDB file using Open Babel.

Arguments

  • atoms::AbstractVector{<:Atom}: structure (usually PDB file of a protein) to add hydrogens to.
  • pH: the pH of the solution. Default is 7.0.
  • obabel: path to the obabel executable. Default is "obabel".
  • debug: if true, print the output message from obabel. Default is false.
Note

This function requires the installation of OpenBabel. Please cite the corresponding reference if using it.

Example

julia> using PDBTools

julia> atoms = read_pdb(PDBTools.TESTPDB, "protein and not element H");

julia> add_hydrogens!(atoms)
   Vector{Atom{Nothing}} with 1459 atoms with fields:
   index name resname chain   resnum  residue        x        y        z occup  beta model segname index_pdb
       1    N     ALA     A        1        1   -9.229  -14.861   -5.481  1.00  0.00     1       -         1
       2   CA     ALA     A        1        1   -8.483  -14.912   -6.726  1.00  0.00     1       -         2
       3   CB     ALA     A        1        1   -9.383  -14.465   -7.880  1.00  0.00     1       -         3
                                                       ⋮ 
    1457    H     THR     A      104      208    5.886  -10.722   -7.797  1.00  0.00     1       -      1457
    1458    H     THR     A      104      208    5.871  -10.612   -9.541  1.00  0.00     1       -      1458
    1459    H     THR     A      104      208    6.423  -12.076   -8.762  1.00  0.00     1       -      1459
source

Custom protein residue types

It is possible to add to the list of protein residues, custom residue types. This can be done by simply adding to the PDBTools.protein_residues dictionary of residues a new PDBTools.ProteinResidue entry.

PDBTools.add_protein_residue!Function
add_protein_residue!(resname::String, reference_residue::PDBTools.ProteinResidue)

Function to add a custom protein residue to the list of protein residues. The function will return the ProteinResidue object that was added. To remove all custom protein residues use remove_custom_protein_residues!().

Example

julia> using PDBTools

julia> remove_custom_protein_residues!();

julia> add_protein_residue!("sA", PDBTools.protein_residues["ALA"])
PDBTools.ProteinResidue("sA", "ALA", "A", "Aliphatic", false, true, 71.037114, 71.0779, 0, true)

julia> isprotein(Atom(resname="sA"))
true

julia> remove_custom_protein_residues!(); # clean up

Here we repeatedly call remove_custom_residues!() to guarantee the proper execution of the test codes, without any custom residues in the list of protein residues.

source
PDBTools.remove_custom_protein_residues!Function
remove_custom_protein_residues!()

Function to remove all custom protein residues from the list of protein residues.

Example

julia> using PDBTools

julia> remove_custom_protein_residues!(); # clean up

julia> add_protein_residue!("sA", PDBTools.protein_residues["ALA"])
PDBTools.ProteinResidue("sA", "ALA", "A", "Aliphatic", false, true, 71.037114, 71.0779, 0, true)

julia> isprotein(Atom(resname="sA"))
true

julia> remove_custom_protein_residues!();

julia> isprotein(Atom(resname="sA"))
false

Here we repeatedly call remove_custom_residues!() to guarantee the proper execution of the test codes, without any custom residues in the list of protein residues.

source

For example, here we create a new resiude type NEW with the same properties of an ALA residue. To remove all custom protein residues, use remove_custom_protein_residues!().

using PDBTools
add_protein_residue!("NEW", PDBTools.protein_residues["ALA"])
PDBTools.ProteinResidue("NEW", "ALA", "A", "Aliphatic", false, true, 71.037114, 71.0779, 0, true)

Then, an atom of residue name NEW will be recognized as a protein residue:

atom = Atom(resname="NEW")
isprotein(atom)
true

To remove the elements added, do:

remove_custom_protein_residues!()
OrderedCollections.OrderedDict{String, PDBTools.ProteinResidue} with 28 entries:
  "ALA" => ProteinResidue("Alanine", "ALA", "A", "Aliphatic", false, true, 71.0371, 71.0779, 0, false)
  "ARG" => ProteinResidue("Arginine", "ARG", "R", "Basic", true, false, 156.101, 156.186, 1, false)
  "ASN" => ProteinResidue("Asparagine", "ASN", "N", "Amide", true, false, 114.043, 114.103, 0, false)
  "ASP" => ProteinResidue("Aspartic acid", "ASP", "D", "Acidic", true, false, 115.027, 115.087, -1, false)
  "CYS" => ProteinResidue("Cysteine", "CYS", "C", "Sulfuric", true, false, 103.009, 103.143, 0, false)
  ⋮     => ⋮

The SIRAH force-field residues and element types

Conveniencie functions can be created to add sets of new types of residues and atom types to the list of residues and elements. This is illustrated in the custom_types.jl file of the source code, in this case for the residues and atom types of the SIRAH force field for Coarse-Grained protein simulations.

Note
  • Masses of the SIRAH beads are not useful in general, and do not have a spcific physical meaning.
  • Residue sX is interpreted as a bridged Cysteine.
  • To compute SASAs of SIRAH models, be careful in adding the SIRAH custom elements first, and use the sasa_particles(SIRAH, ...) method.

Defining atom and residue types

Here we repeteadly call remove_custom_residues!() and remove_custom_elements!() to guarantee the proper execution of the test codes, this is not necessary in a regular use of these functions.

With those definitions, adding all SIRAH protein residue types and element names can be done with:

using PDBTools
custom_protein_residues!(SIRAH)
custom_elements!(SIRAH)

With that, SIRAH structures have a special support. Let us start reading a CG model:

sirah_pdb = read_pdb(PDBTools.SIRAHPDB)
resname.(eachresidue(sirah_pdb))
5-element Vector{InlineStrings.String15}:
 "sI"
 "sR"
 "sX"
 "sI"
 "sG"

Note that the residue names of the SIRAH force-field are non-standard (sI, sR, etc.), but the sequence is properly retrieved with standard one-letter codes:

getseq(sirah_pdb)
5-element Vector{String}:
 "I"
 "R"
 "C"
 "I"
 "G"

And all protein atoms are recognized:

all(isprotein.(sirah_pdb))
true

Computing SIRAH solvent accessible area

To compute the solvent accessible surface area of SIRAH models, call the sasa_particles(SIRAH, ...) method:

s_sirah = sasa_particles(SIRAH, sirah_pdb)
PDBTools.SASA{3, Vector{Atom{Nothing}}}
    Number of particles: 22
    Total SASA: 1535.7573
    Output of dots: false 

which can be decomposed as usual:

sasa(s_sirah, "sidechain")
812.94617f0

Removing the custom types

To remove the custom element types and residues, do:

remove_custom_protein_residues!()
remove_custom_elements!()
Dict{String, PDBTools.Element} with 267 entries:
  "Pd"       => Element(:Pd, String15("Pd"), "Palladium", 46, 106.4, false, 1.63)
  "Ag"       => Element(:Ag, String15("Ag"), "Silver", 47, 107.868, false, 1.72)
  "Gd"       => Element(:Gd, String15("Gd"), "Gadolinium", 64, 157.25, false, NaN)
  "Actinium" => Element(:Ac, String15("Ac"), "Actinium", 89, 227.028, false, NaN)
  "Europium" => Element(:Eu, String15("Eu"), "Europium", 63, 151.96, false, NaN)
  ⋮          => ⋮

Move atoms and center of mass

The center_of_mass function can be used to compute the center of mass of set of atoms, and the moveto! function can be used to move the center of mass of the atoms to the origin (by default) or to a specified position:

MolSimToolkitShared.center_of_massFunction
center_of_mass(atoms::AbstractVector{<:Atom})

Calculate the center of mass of the atoms.

Example

julia> using PDBTools

julia> atoms = read_pdb(PDBTools.SMALLPDB);

julia> center_of_mass(atoms)
3-element StaticArraysCore.SVector{3, Float32} with indices SOneTo(3):
  -5.5844226
 -13.1104145
  -7.1399713
source
PDBTools.moveto!Function
moveto!(atoms::AbstractVector{<:Atom}; center::AbstractVector{<:Real}=SVector(0.0, 0.0, 0.0))

Move the center of mass of the atoms to the specified center position, which defaults to the origin.

Example

julia> using PDBTools

julia> atoms = read_pdb(PDBTools.SMALLPDB);

julia> center_of_mass(atoms)
3-element StaticArraysCore.SVector{3, Float32} with indices SOneTo(3):
  -5.5844226
 -13.1104145
  -7.1399713

julia> moveto!(atoms; center = [1.0, 2.0, 3.0]);

julia> center_of_mass(atoms)
3-element StaticArraysCore.SVector{3, Float32} with indices SOneTo(3):
 1.0
 2.0000014
 3.0
source