Skip to content

Commit

Permalink
in process
Browse files Browse the repository at this point in the history
  • Loading branch information
dprada committed Aug 13, 2024
1 parent 44c81e9 commit b4175d9
Show file tree
Hide file tree
Showing 8 changed files with 375 additions and 12 deletions.
198 changes: 198 additions & 0 deletions docs/contents/user/tools/build/add_bonds.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "3908cf62-3a4c-4c82-a061-e78f6f2f7097",
"metadata": {
"tags": [
"remove-input"
]
},
"outputs": [],
"source": [
"# This cell is removed with the tag: \"remove-input\"\n",
"# As such, it will not be shown in documentation\n",
"\n",
"#import warnings\n",
"#warnings.filterwarnings('ignore')"
]
},
{
"cell_type": "markdown",
"id": "034d6a12-81b5-40fe-89a7-59046d378078",
"metadata": {},
"source": [
"(Tutorial_Add_bonds)=\n",
"# Add bonds\n",
"\n",
"To be written..."
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "19c12010-9573-490a-89fa-f899756609d7",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "804fe4f2f91b418fbaecbfd991719a56",
"version_major": 2,
"version_minor": 0
},
"text/plain": []
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"import molsysmt as msm"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "7ebdbcb9-f241-472a-9a5e-63066fbb064b",
"metadata": {},
"outputs": [],
"source": [
"molsys = msm.systems['alanine dipeptide']['alanine_dipeptide.h5msm']"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "623d0cf1-e54f-438e-a7f5-fdab6e56d8af",
"metadata": {},
"outputs": [],
"source": [
"molsys = msm.convert(molsys)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "ec89fe3d-b83c-495b-bc29-c1c1b3f58408",
"metadata": {},
"outputs": [],
"source": [
"msm.build.remove_bonds(molsys)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "5357ae81-d988-48a5-9e5e-d61ce63a0dba",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"msm.get(molsys, n_bonds=True)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "4ed0846f-048c-4184-96a1-07b649dcd9cf",
"metadata": {},
"outputs": [],
"source": [
"msm.build.add_bonds(molsys, bonded_atom_pairs=[[0,1], [0,2], [1,4]])"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "03abc0cd-29aa-45ac-9da3-bf470bd2d37f",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"3"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"msm.get(molsys, n_bonds=True)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "1aa4d0b4-7985-43c1-a41b-d87870271e17",
"metadata": {},
"outputs": [],
"source": [
"bonded_atom_pairs = msm.get(molsys, bonded_atom_pairs=True)"
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "1fa3f835-6ebc-4a17-b021-e1f4ed392785",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"bonded_atom_pairs == [[0,1], [0,2], [1,4]]"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ec17414f-e734-49a7-84e0-3fcde8284f4c",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.9"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
114 changes: 113 additions & 1 deletion docs/contents/user/tools/build/add_missing_bonds.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,118 @@
"\n",
"To be written..."
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "298105c1-444e-4e94-bf44-e16ce0e5e171",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "56cb802dd5d94eff8a202610839ed1db",
"version_major": 2,
"version_minor": 0
},
"text/plain": []
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"import molsysmt as msm"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "cb9faa83-9dba-4e6e-8e89-ad0ae6604c80",
"metadata": {},
"outputs": [],
"source": [
"molsys = msm.systems['alanine dipeptide']['alanine_dipeptide.h5msm']"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "e0970914-34f1-4ae6-8104-76ea7394046b",
"metadata": {},
"outputs": [],
"source": [
"molsys = msm.convert(molsys)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "fc7a3b4a-c6c8-4690-884d-ff054daddd44",
"metadata": {},
"outputs": [],
"source": [
"bonded_atom_pairs = msm.get(molsys, bonded_atom_pairs=True)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "5218d00e-a83b-4cb8-a01f-5b0c28686bdc",
"metadata": {},
"outputs": [],
"source": [
"msm.build.remove_bonds(molsys)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "88abb2cb-2778-4d1f-9ab5-df84d879a7ec",
"metadata": {},
"outputs": [],
"source": [
"msm.build.add_missing_bonds(molsys)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "7c3129c2-c4c3-403b-8053-9f361371f9a2",
"metadata": {},
"outputs": [],
"source": [
"new_bonded_atom_pairs = msm.get(molsys, bonded_atom_pairs=True)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "aa10a14e-f3bf-4edb-ae1a-c648d68a7bbf",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"new_bonded_atom_pairs == bonded_atom_pairs"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "00813f47-1589-43d7-8bb1-2716dda3a387",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -46,7 +158,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.14"
"version": "3.11.9"
}
},
"nbformat": 4,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.14"
"version": "3.11.9"
}
},
"nbformat": 4,
Expand Down
10 changes: 0 additions & 10 deletions molsysmt/build/add_missing_bonds.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,7 @@ def add_missing_bonds(molecular_system, threshold='2 angstroms', selection='all'

return add_bonds(molecular_system, bonds, in_place=in_place, skip_digestion=True)

elif engine=="ParmEd":

raise NotImplementedError

elif engine=="pytraj":

raise NotImplementedError

else:

raise NotImplementedError

raise NotImplementedError

22 changes: 22 additions & 0 deletions tests/build/add_bonds/test_add_bonds.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"""
Unit and regression test for the is solvate module of the molsysmt package on molsysmt MolSys molecular
systems.
"""

# Import package, test suite, and other packages as needed
import pytest
import molsysmt as msm
from molsysmt import systems
import numpy as np


def test_add_bonds_molsysmt_MolSys_1():

molsys = msm.systems['alanine dipeptide']['alanine_dipeptide.h5msm']
molsys = msm.convert(molsys)
msm.build.remove_bonds(molsys)
msm.build.add_bonds(molsys, bonded_atom_pairs=[[0,1], [0,2], [1,4]])
n_bonds, bonded_atom_pairs = msm.get(molsys, n_bonds=True, bonded_atom_pairs=True)

assert n_bonds==3
assert bonded_atom_pairs==[[0,1], [0,2], [1,4]]
10 changes: 10 additions & 0 deletions tests/build/add_missing_bonds/test_add_missing_bonds.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,13 @@ def test_add_missing_bonds_molsysmt_MolSys_1():

assert n_bonds_before==n_bonds_after

def test_add_missing_bonds_molsysmt_MolSys_2():

molsys = msm.systems['alanine dipeptide']['alanine_dipeptide.h5msm']
molsys = msm.convert(molsys)
bonded_atom_pairs = msm.get(molsys, bonded_atom_pairs=True)
msm.build.remove_bonds(molsys)
msm.build.add_missing_bonds(molsys)
new_bonded_atom_pairs = msm.get(molsys, bonded_atom_pairs=True)

assert new_bonded_atom_pairs == bonded_atom_pairs
Loading

0 comments on commit b4175d9

Please sign in to comment.