Atomic and molecular properties

Some simple atom properties can be retrieved using special functions, which operate on atoms of the type Atom. For example:

julia> atoms = readPDB("./file.pdb");

julia> printatom(atoms[1])
   index name resname chain   resnum  residue        x        y        z  beta occup model segname index_pdb
       1   OW     SOL     X        1        1   54.370   45.310   33.970  0.00  0.00     1       -         1

julia> mass(atoms[1])
14.0067

julia> atomic_number(atoms[1])
7

julia> element(atoms[1])
"N"

julia> element_name(atoms[1])
"Nitrogen"

The formula or stoichiometry of a selection can also be retrieved:

julia> atoms = wget("1LBD","protein and residue 1");

julia> f = formula(atoms)
C₃N₁O₂

julia> stoichiometry(select(atoms,"water"))
H₂O₁

AtomsBase compatibility

Compat

This interface requires at least PDBTools version 0.14.2.

The following functions are supported as part of the API, to conform the AtomsBase interface:

FunctionExampleOutput
atomic_number(::PDBTools.Atom)atomic_number(Atom(name="NE2"))7
atomic_symbol(::PDBTools.Atom)atomic_symbol(Atom(name="NE2")):N
atomic_mass(::PDBTools.Atom)atomic_mass(Atom(name="NE2"))14.0067
position(::PDBTools.Atom)position(Atom(name="NE2"))SVector{3,Float64}(0,0,0)

Custom Atom fields

Compat

Custom field support was introduced on PDBTools version 0.14.3.

Custom atom fields can be added to an Atom object by defining the custom dictionary. The fields can be accessed by the standard dot syntax if the field name does not clash with an existing Atom field, or by the custom_field getter function.

For example:

julia> atom = Atom(index = 0; custom=Dict(:c => "c", :index => 1))
       0    X     XXX     X        0        0    0.000    0.000    0.000  0.00  0.00     0    XXXX         0

julia> atom.c
"c"

julia> atom.index
0

julia> custom_field(atom, :index)
1

Setting new custom fields follow the standard Julia dictionary syntax:

julia> atom.custom[:new] = "NEW"
"NEW"

julia> atom.new
"NEW"

julia> custom_field(atom, :new)
"NEW"