Add cylinders#

import molsysmt as msm
from molsysmt import pyunitwizard as puw
import nglview as nv
import numpy as np
view = nv.NGLWidget()

bottom = puw.quantity([[0,0,0], [0,5,0]], 'angstroms')
top = puw.quantity([[10,0,0], [0,10,0]], 'angstroms')

msm.thirds.nglview.add_cylinders(view, bottom=bottom, top=top, color='#ff0000', color_2='#0000ff', radius='0.2 angstroms')

view
molsys = msm.convert(msm.systems['chicken villin HP35']['chicken_villin_HP35.h5msm'])
view = msm.view(molsys, standard=True)
view
contacts = msm.structure.get_contacts(molsys, selection='atom_name=="CA"', threshold='9 angstroms',
                                     output_type='pairs', output_indices='atom')
start = msm.get(molsys, element='atom', selection=np.array(contacts[0])[:,0], coordinates=True)
end = msm.get(molsys, element='atom', selection=np.array(contacts[0])[:,1], coordinates=True)
view = msm.view(molsys, standard=True)
msm.thirds.nglview.add_cylinders(view, bottom=start, top=end)
view
start, groups_start = msm.get(molsys, element='atom', selection=np.array(contacts[0])[:,0], coordinates=True, group_index=True)
end, groups_end = msm.get(molsys, element='atom', selection=np.array(contacts[0])[:,1], coordinates=True, group_index=True)
view = msm.view(molsys, standard=True)
msm.thirds.nglview.add_cylinders(view, start[0], end[0], color_values=groups_start, color_values_2=groups_end,
                                 colormap='viridis')
view