TrjArray type
MDToolbox.jl introduces a unique type, called TrjArray
, for storing and processing MD trajectory data. When you load MD data with mdload()
, mdload()
always generates a new variable with TrjArray
type. Alternatively, a TrjArray
-type variable can be manually generated by calling its constructor.
using MDToolbox
ENV["COLUMNS"] = 130; # if you are using Jupyter, the column width should be set for the message width from MDToolbox.jl.
# A TrjArray variable generated by loading MD data
t = mdload("examples/data/md_alad/3_prod/run.nc");
# Generate a TrjArray by calling its constructor. Here, single atom and its nine-frame coordinates are given.
t = TrjArray(xyz=rand(10, 3));
TrjArray
displays the information of its topology and trajectory on the standard ouput for users. For example, the following are the outputs from TrjArray
just after loading a pdb file.
t = mdload("examples/data/3gb1.pdb")
32x855 TrjArray{Float64, Int64}
| A | A | … A |
| 1MET | 1MET | … 56GLU |
| 1N | 2CA | … 855HG3 |
| -13.15 -1.71 5.51 | -12.20 -2.85 5.70 | … 10.24 2.24 -4.53 |
| -13.16 -2.75 4.19 | -12.38 -3.43 5.26 | 10.29 1.79 -3.20 |
| -13.26 -2.20 5.12 | -12.23 -3.26 5.29 | 11.09 3.24 -6.13 |
| -12.45 -4.30 6.28 | -12.25 -3.22 5.28 | 11.75 2.57 -3.31 |
| -13.05 -1.52 5.31 | -12.15 -2.68 5.56 | 10.46 1.51 -3.50 |
| -12.98 -3.74 6.65 | -12.43 -3.31 5.34 | … 11.26 3.06 -3.59 |
| -13.03 -2.10 3.64 | -12.47 -2.79 4.83 | 10.38 1.53 -3.30 |
| -13.00 -2.17 5.21 | -12.09 -3.19 5.78 | 11.32 3.37 -5.78 |
| -12.57 -2.96 3.87 | -12.12 -3.42 5.21 | 10.36 1.38 -3.53 |
| -12.60 -2.85 4.27 | -12.16 -3.02 5.68 | 10.44 1.40 -3.37 |
| -13.12 -1.61 4.72 | -12.34 -2.60 5.52 | … 10.96 3.58 -5.68 |
| ⋮ | ⋮ | ⋱ ⋮ |
| -13.46 -2.54 6.05 | -12.41 -3.14 5.18 | 10.33 1.63 -3.72 |
| -12.61 -4.31 6.34 | -12.22 -3.51 5.15 | 10.26 1.56 -3.59 |
| -13.24 -2.72 6.28 | -12.16 -3.34 5.45 | 11.30 2.91 -3.41 |
| -13.21 -2.29 5.61 | -12.13 -3.31 5.53 | 11.76 2.84 -5.65 |
| -12.75 -2.42 4.33 | -12.22 -2.96 5.61 | … 11.53 3.05 -5.67 |
| -13.32 -2.12 5.10 | -12.27 -3.17 5.25 | 10.38 1.88 -3.32 |
| -13.07 -2.31 4.32 | -12.27 -3.22 5.19 | 11.65 3.11 -5.90 |
| -12.76 -3.69 6.68 | -12.11 -3.33 5.38 | 11.51 2.97 -5.63 |
| -13.21 -2.55 5.53 | -12.06 -3.41 5.11 | 10.26 1.60 -3.20 |
| -13.13 -2.12 4.11 | -12.34 -3.00 5.02 | … 12.68 3.28 -4.88 |
| -12.81 -2.86 4.32 | -12.23 -3.33 5.62 | 9.98 2.33 -5.34 |
Here, the first three rows display the topology information contained in the TrjArray
-type variable t
. The 1st row shows chain IDs and names. The 2nd row shows residue IDs and names. The 3rd row shows atom IDs and names.
The rest of the rows are the XYZ coordinates of atoms. The rows represent frames of the trajectory. So, the coordinates of each structure are contained in the respective row.
Users can directly access the topology and trajectory data contained in a TrjArray
-type variable. For example, atom names can be accessed from t.atomname
t.atomname
855-element Vector{String}:
"N"
"CA"
"C"
"O"
⋮
"HB2"
"HB3"
"HG2"
"HG3"
Likewise, residue names can be accessed from t.resname
t.resid
855-element Vector{Int64}:
1
1
1
1
⋮
56
56
56
56
XYZ coordinates of atoms at every frames are stored in t.xyz
as a Matrix (2-dimensional Array).
t.xyz
32×2565 Array{Float64,2}:
-13.148 -1.712 5.506 -12.204 -2.845 5.703 -10.787 … -5.015 11.4 2.981 -5.635 10.243 2.242 -4.528
-13.157 -2.751 4.188 -12.383 -3.431 5.265 -11.062 -4.948 10.403 2.845 -4.607 10.289 1.786 -3.203
-13.263 -2.198 5.124 -12.234 -3.262 5.291 -10.878 -3.987 12.803 2.829 -6.066 11.088 3.244 -6.129
-12.447 -4.303 6.284 -12.247 -3.222 5.278 -10.903 -5.088 10.448 1.461 -3.727 11.753 2.573 -3.312
-13.048 -1.516 5.314 -12.149 -2.68 5.56 -10.728 -5.194 10.528 2.313 -5.067 10.462 1.511 -3.498
⋮ ⋮ ⋱ ⋮
-12.758 -3.689 6.677 -12.112 -3.327 5.385 -10.767 -3.783 13.174 2.414 -5.77 11.507 2.972 -5.631
-13.206 -2.549 5.527 -12.063 -3.411 5.11 -10.744 -5.049 10.311 2.8 -4.493 10.257 1.6 -3.201
-13.127 -2.119 4.107 -12.343 -3.001 5.019 -10.998 … -4.007 11.853 2.636 -6.3 12.676 3.277 -4.88
-12.809 -2.858 4.322 -12.235 -3.325 5.615 -10.889 -5.346 10.808 2.939 -3.91 9.983 2.325 -5.343
Here, a row vector are the XYZ coordinates of atoms in order
x(1) y(1) z(1) x(2) y(2) z(2) .. x(natom) y(natom) z(natom)
The rows represent frames in the trajectory. For typical MD simulation data, frames are time steps of recorded atomic coordinates.
For example, the translation of the X coordinates of the system at the 3rd frame can be accessed as follows,
t.xyz[3, 1:3:end]
855-element Array{Float64,1}:
-13.263
-12.234
-10.878
-10.574
-12.144
⋮
10.754
12.452
12.803
11.088
TrjArray
containes the following variables:
variable name | type | content |
---|---|---|
natom | Int | The number of atoms |
nframe | Int | The number of frames or structures |
xyz | nframe x (natom*3) Matrix{Float} | XYZ coordinates of atoms |
boxsize | nframe x 3 Matrix{Float} | XYZ size of simulation box |
chainname | natom Vector{String} | Chain names |
chainid | natom Vector{Int} | Chain IDs |
resname | natom Vector{String} | Resisude names |
resid | natom Vector{Int} | Residue IDs |
atomname | natom Vector{String} | Atom names |
atomid | natom Vector{Int} | Atom IDs |
mass | natom Vector{Float} | Masses |
radius | natom Vector{Float} | VDW radii of atoms |
charge | natom Vector{Float} | Partial chages of atoms |
sasa | natom Vector{Float} | Solvent accessible surface areas |
list_bond | nbond x 2 Matrix{Int} | Atom ID pairs for bonds |
list_angle | nangle x 2 Matrix{Int} | Atom ID triples for angles |
list_dihedral | ndihedral x 2 Matrix{Int} | Atom ID quadruplets for dihedrals |
list_improper | nimproper x 2 Matrix{Int} | Atom ID quadruplets for impropers |
list_cmap | ncmap x 2 Matrix{Int} | Atom ID quadruplets for cmaps |