%load_ext autoreload
%autoreload 2
#%matplotlib widget
import molsysmt as msm
import nglview as nv
#import warnings
#warnings.filterwarnings('ignore')
Working with NGLView#
molecular_system = msm.convert([nv.datafiles.GRO, nv.datafiles.XTC], to_form='molsysmt.MolSys')
nv.show_molsysmt(molecular_system)
view = msm.view(molecular_system, standard=True)
view
contact_map = msm.structure.get_contacts(view, selection='molecule_type=="protein" and atom_name=="CA"', threshold='12 angstroms')
CA_labels = msm.get_label(view, selection='molecule_type=="protein" and atom_name=="CA"', string='{group_name}-{group_id}')
print(CA_labels[100])
GLY-101
import plotly.express as px
fig = px.imshow(~contact_map, animation_frame=0, binary_string=True, height=600, origin='lower')
fig.update_layout(
xaxis = dict(
tickmode = 'array',
tickvals = list(range(0,contact_map.shape[1],25)),
ticktext = CA_labels[::25],
tickangle = 45
),
yaxis = dict(
tickmode = 'array',
tickvals = list(range(0,contact_map.shape[1],25)),
ticktext = CA_labels[::25],
tickangle = 45
)
)
fig.show()
msm.convert(view, to_form='string:aminoacids3')
'AceMetAsnGlyThrGluGlyProAsnPheTyrValProPheSerAsnLysThrGlyValValArgSerProPheGluAlaProGlnTyrTyrLeuAlaGluProTrpGlnPheSerMetLeuAlaAlaTyrMetPheLeuLeuIleMetLeuGlyPheProIleAsnPheLeuThrLeuTyrValThrValGlnHisLysLysLeuArgThrProLeuAsnTyrIleLeuLeuAsnLeuAlaValAlaAspLeuPheMetValPheGlyGlyPheThrThrThrLeuTyrThrSerLeuHisGlyTyrPheValPheGlyProThrGlyCysAsnLeuGluGlyPhePheAlaThrLeuGlyGlyGluIleAlaLeuTrpSerLeuValValLeuAlaIleGluArgTyrValValValCysLysProMetSerAsnPheArgPheGlyGluAsnHisAlaIleMetGlyValAlaPheThrTrpValMetAlaLeuAlaCysAlaAlaProProLeuValGlyTrpSerArgTyrIleProGluGlyMetGlnCysSerCysGlyIleAspTyrTyrThrProHisGluGluThrAsnAsnGluSerPheValIleTyrMetPheValValHisPheIleIleProLeuIleValIlePhePheCysTyrGlyGlnLeuValPheThrValLysGluAlaAlaAlaGlnGlnGlnGluSerAlaThrThrGlnLysAlaGluLysGluValThrArgMetValIleIleMetValIleAlaPheLeuIleCysTrpLeuProTyrAlaGlyValAlaPheTyrIlePheThrHisGlnGlySerAspPheGlyProIlePheMetThrIleProAlaPhePheAlaLrtThrSerAlaValTyrAsnProValIleTyrIleMetMetAsnLysGlnPheArgAsnCysMetValThrThrLeuYplYplGlyLysAsnProLeuGlyAspAspGluAlaSerThrThrValSerLysThrGluThrSerGlnValAlaProAla'
molsys_A = msm.build.build_peptide('AceAlaNME')
molsys_B = msm.structure.translate(molsys_A, translation='[0.5, 0.0, 0.0] nm')
view1 = msm.convert(molsys_A, to_form='nglview.NGLWidget')
view2 = msm.view(molsys_B)
view = msm.merge([view1, view2])
msm.info(view)
form | n_atoms | n_groups | n_components | n_chains | n_molecules | n_entities | n_peptides | n_structures |
---|---|---|---|---|---|---|---|---|
nglview.NGLWidget | 44 | 6 | 2 | 2 | 2 | 1 | 2 | 1 |
msm.structure.get_geometric_center(view, selection='molecule_index==0')
Magnitude | [[[0.44929119636363635 0.485347455 -0.022366771363636358]]] |
---|---|
Units | nanometer |
msm.structure.get_geometric_center(view, selection='molecule_index==1')
Magnitude | [[[0.9492911963636362 0.485347455 -0.022366771363636358]]] |
---|---|
Units | nanometer |
msm.structure.get_distances(view, selection='molecule_index==0', selection_2='molecule_index==1',
group_behavior='geometric center', group_behavior_2='geometric center')
Magnitude | [[[0.4999999999999999]]] |
---|---|
Units | nanometer |