import warnings
warnings.filterwarnings('ignore')
import parmed as pmd

x = pmd.load_file('tz2.pdb')
[res.name for res in x.residues]

[atom.name for atom in x.residues[0]]

"""
Explanation: Using Jupyter notebook for interactive development
url: http://jupyter.org/

Install
bash
conda install parmed -c ambermd # Python package for topology editing and force field development
conda install pytraj-dev -c ambermd # Python interface for cpptraj (MD trajectory data analysis)
conda install pysander -c ambermd # Python interface for SANDER
ParmEd: Cross-program parameter and topology file editor and molecular mechanical simulator engine.
url: https://github.com/ParmEd/ParmEd (AMBER16)
End of explanation
"""


import pytraj as pt

traj = pt.load('tz2.nc', 'tz2.parm7')
distances = pt.distances(traj, ':1 :12', dtype='dataframe')
distances.head()

%matplotlib inline 

distances.hist()

energies = pt.energy_decomposition(traj, prmtop='tz2.parm7', dtype='dataframe')
energies[['bond', 'angle', 'dihedral', 'gb']].head() # kcal/mol

# gb: implicit solvation energy

help(pt.energy_decomposition)

dihedrals = pt.multidihedral(traj, resrange='1-3', dtype='dataframe')
dihedrals.head(3)

%matplotlib inline

from matplotlib import pyplot as plt

plt.plot(dihedrals['phi_2'], dihedrals['psi_2'], '-bo', linewidth=0)
plt.xlim([-180, 180])
plt.ylim([-180, 180])

"""
Explanation: PYTRAJ: Interactive data analysis for molecular dynamics simulations
url: https://github.com/Amber-MD/pytraj (AMBER 16)
End of explanation
"""


import warnings
warnings.filterwarnings('ignore')

import nglview as nv
view = nv.show_pytraj(traj)
view

view.representations = []
view.add_representation('cartoon', color='residueindex')
view.add_representation('licorice')

t0 = pt.fetch_pdb('3pqr')
view0 = pt.view.to_nglview(t0)
view0

view0.representations = []
view0.add_representation('cartoon', selection='protein', color='residueindex')
view0.add_representation('licorice', selection='not protein')

"""
Explanation: Protein/DNA/RNA viewer in notebook
End of explanation
"""


