From bccc30a06f281f1021d2046b9b7053de8bbf9576 Mon Sep 17 00:00:00 2001 From: Diego Prada-Gracia Date: Mon, 29 Apr 2024 23:46:32 -0600 Subject: [PATCH] In process --- .../digestion/argument/bond_indices.py | 41 ++++ molsysmt/build/__init__.py | 1 + molsysmt/build/remove_bonds.py | 22 +++ molsysmt/element/entity/get_entity_index.py | 15 +- molsysmt/form/molsysmt_MolSys/__init__.py | 4 +- molsysmt/form/molsysmt_MolSys/remove_bonds.py | 8 + .../to_molsysmt_Topology.py | 80 +++++--- molsysmt/form/molsysmt_Topology/__init__.py | 3 + molsysmt/form/molsysmt_Topology/add_bonds.py | 10 + .../form/molsysmt_Topology/remove_bonds.py | 8 + molsysmt/form/openmm_Modeller/__init__.py | 6 +- molsysmt/native/topology.py | 42 +++++ .../test_compare_with_molsysmt_MolSys.py | 8 +- .../test_remove_bonds_molsysmt_MolSys.py | 22 +++ sandbox/Tests.ipynb | 176 +++++++++++++----- 15 files changed, 359 insertions(+), 87 deletions(-) create mode 100644 molsysmt/_private/digestion/argument/bond_indices.py create mode 100644 molsysmt/build/remove_bonds.py create mode 100644 molsysmt/form/molsysmt_MolSys/remove_bonds.py create mode 100644 molsysmt/form/molsysmt_Topology/add_bonds.py create mode 100644 molsysmt/form/molsysmt_Topology/remove_bonds.py create mode 100644 molsysmt/tests/build/remove_bonds/test_remove_bonds_molsysmt_MolSys.py diff --git a/molsysmt/_private/digestion/argument/bond_indices.py b/molsysmt/_private/digestion/argument/bond_indices.py new file mode 100644 index 000000000..4e06423e5 --- /dev/null +++ b/molsysmt/_private/digestion/argument/bond_indices.py @@ -0,0 +1,41 @@ +from ...exceptions import ArgumentError +from ...variables import is_all +import numpy as np + +def digest_bond_indices(bond_indices, caller=None): + """ Checks if bond_indices has the expected type and value. + + Parameters + ---------- + indices : str or int or list or tuple or range. + The indices + + caller: str, optional + Name of the function or method that is being digested. + For debugging purposes. + + Returns + ------- + str or ndarray or None + Either None, 'all' or an numpy array of integers with the indices. + + Raises + ------- + ArgumentError + If the given indices are not of the correct type. + """ + + if bond_indices is None: + return None + elif is_all(bond_indices): + return 'all' + elif isinstance(bond_indices, (int, np.int64, np.int32)): + return np.array([bond_indices], dtype='int64') + elif isinstance(bond_indices, (np.ndarray, list, tuple, range)): + if all(isinstance(ii, (int, np.int64, np.int32)) for ii in bond_indices): + return np.array(bond_indices, dtype='int64') + else: + return [digest_bond_indices(ii) for ii in bond_indices] + + raise ArgumentError('bond_indices', caller=caller, message=None) + diff --git a/molsysmt/build/__init__.py b/molsysmt/build/__init__.py index 109cfc8d7..6149db3d1 100644 --- a/molsysmt/build/__init__.py +++ b/molsysmt/build/__init__.py @@ -19,4 +19,5 @@ from .define_new_chain import define_new_chain from .make_water_box import make_water_box from .remove_overlapping_molecules import remove_overlapping_molecules +from .remove_bonds import remove_bonds diff --git a/molsysmt/build/remove_bonds.py b/molsysmt/build/remove_bonds.py new file mode 100644 index 000000000..c98191561 --- /dev/null +++ b/molsysmt/build/remove_bonds.py @@ -0,0 +1,22 @@ +from molsysmt._private.exceptions import NotImplementedMethodError +from molsysmt._private.digestion import digest +from molsysmt._private.variables import is_all + +@digest() +def remove_bonds(molecular_system, bond_indices='all', in_place=True, skip_digestion=False): + + from molsysmt.basic import where_is_attribute + from molsysmt.form import _dict_modules + + if in_place: + + item, form = where_is_attribute(molecular_system, 'bond_index', check_if_None=False, + skip_digestion=True) + + add_bonds_function = getattr(_dict_modules[form], f'remove_bonds') + add_bonds_function(item, bond_indices, skip_digestion=True) + + else: + + raise NotImplementedMethodError + diff --git a/molsysmt/element/entity/get_entity_index.py b/molsysmt/element/entity/get_entity_index.py index c2dc668e6..767c924ce 100644 --- a/molsysmt/element/entity/get_entity_index.py +++ b/molsysmt/element/entity/get_entity_index.py @@ -3,7 +3,8 @@ @digest() def get_entity_index(molecular_system, element='atom', selection='all', - redefine_molecules=False, redefine_indices=False, syntax='MolSysMT'): + redefine_molecules=False, redefine_indices=False, syntax='MolSysMT', + skip_digestion=False): if redefine_molecules or redefine_indices: @@ -12,18 +13,20 @@ def get_entity_index(molecular_system, element='atom', selection='all', if redefine_molecules: molecule_name_from_molecules = get_molecule_name(molecular_system, element='molecule', - selection=selection, redefine_molecules=True, syntax=syntax) + selection=selection, redefine_molecules=True, syntax=syntax, skip_digestion=True) molecule_type_from_molecules = get_molecule_type(molecular_system, element='molecule', - selection=selection, redefine_molecules=True, syntax=syntax) + selection=selection, redefine_molecules=True, syntax=syntax, skip_digestion=True) else: molecule_name_from_molecules = get_molecule_name(molecular_system, element='molecule', - selection=selection, redefine_molecules=False, redefine_names=False, syntax=syntax) + selection=selection, redefine_molecules=False, redefine_names=False, syntax=syntax, + skip_digestion=True) molecule_type_from_molecules = get_molecule_type(molecular_system, element='molecule', - selection=selection, redefine_molecules=False, redefine_types=False, syntax=syntax) + selection=selection, redefine_molecules=False, redefine_types=False, syntax=syntax, + skip_digestion=True) count = 0 output = [] @@ -87,7 +90,7 @@ def get_entity_index(molecular_system, element='atom', selection='all', from molsysmt import get output = get(molecular_system, element=element, selection=selection, syntax=syntax, - entity_index=True) + entity_index=True, skip_digestion=True) return output diff --git a/molsysmt/form/molsysmt_MolSys/__init__.py b/molsysmt/form/molsysmt_MolSys/__init__.py index ea4143cc1..d6f95d6ee 100644 --- a/molsysmt/form/molsysmt_MolSys/__init__.py +++ b/molsysmt/form/molsysmt_MolSys/__init__.py @@ -15,7 +15,6 @@ from .copy import copy from .add import add from .merge import merge -from .add_bonds import add_bonds from .append_structures import append_structures from .get_topological_attributes import * from .get_structural_attributes import * @@ -23,6 +22,9 @@ from .set import * from .iterators import StructuresIterator, TopologyIterator +from .add_bonds import add_bonds +from .remove_bonds import remove_bonds + from .to_mdtraj_Topology import to_mdtraj_Topology from .to_mdtraj_Trajectory import to_mdtraj_Trajectory from .to_molsysmt_Topology import to_molsysmt_Topology diff --git a/molsysmt/form/molsysmt_MolSys/remove_bonds.py b/molsysmt/form/molsysmt_MolSys/remove_bonds.py new file mode 100644 index 000000000..2518e2eff --- /dev/null +++ b/molsysmt/form/molsysmt_MolSys/remove_bonds.py @@ -0,0 +1,8 @@ +from molsysmt._private.exceptions import NotImplementedMethodError +from molsysmt._private.digestion import digest +from molsysmt._private.variables import is_all + +@digest(form='molsysmt.MolSys') +def remove_bonds(item, bond_indices='all', skip_digestion=False): + + return item.topology.remove_bonds(bond_indices=bond_indices, skip_digestion=True) diff --git a/molsysmt/form/molsysmt_PDBFileHandler/to_molsysmt_Topology.py b/molsysmt/form/molsysmt_PDBFileHandler/to_molsysmt_Topology.py index de2698c53..30c22f1a8 100644 --- a/molsysmt/form/molsysmt_PDBFileHandler/to_molsysmt_Topology.py +++ b/molsysmt/form/molsysmt_PDBFileHandler/to_molsysmt_Topology.py @@ -1,5 +1,6 @@ from molsysmt._private.digestion import digest from molsysmt._private.variables import is_all +from molsysmt import pyunitwizard as puw import pandas as pd import numpy as np @@ -7,10 +8,9 @@ def to_molsysmt_Topology(item, atom_indices='all', structure_indices=0, get_missing_bonds=True, skip_digestion=False): - from molsysmt.native import Topology - from molsysmt.build import get_missing_bonds as _get_missing_bonds + from molsysmt.native import MolSys - tmp_item = Topology() + tmp_item = MolSys() atom_id_array = [] atom_name_array = [] @@ -22,6 +22,7 @@ def to_molsysmt_Topology(item, atom_indices='all', structure_indices=0, get_miss occupancy_array = [] alternate_location_array = [] + coordinates_array = [] group_index = -1 former_group_id = None @@ -30,8 +31,6 @@ def to_molsysmt_Topology(item, atom_indices='all', structure_indices=0, get_miss former_chain_name = None aux_dict_chain = {} - - for atom_record in item.entry.coordinate.model[0].record: atom_id_array.append(atom_record.serial) @@ -58,6 +57,8 @@ def to_molsysmt_Topology(item, atom_indices='all', structure_indices=0, get_miss chain_index_array.append(chain_index) + coordinates_array.append([atom_record.x, atom_record.y, atom_record.z]) + atom_id_array = np.array(atom_id_array, dtype=int) atom_name_array = np.array(atom_name_array, dtype=str) group_index_array = np.array(group_index_array, dtype=int) @@ -69,6 +70,8 @@ def to_molsysmt_Topology(item, atom_indices='all', structure_indices=0, get_miss occupancy_array = np.array(occupancy_array, dtype=float) alternate_location_array = np.array(alternate_location_array, dtype=str) + coordinates_array = np.array(coordinates_array, dtype=float) + alt_atom_indices = np.where(alternate_location_array!=' ')[0] aux_dict = {} @@ -96,51 +99,72 @@ def to_molsysmt_Topology(item, atom_indices='all', structure_indices=0, get_miss chosen = np.argmax(alt_occupancy) chosen = same_atoms.pop(chosen) atoms_to_be_removed_with_alt_loc += same_atoms - + atom_id_array = np.delete(atom_id_array, atoms_to_be_removed_with_alt_loc) atom_name_array = np.delete(atom_name_array, atoms_to_be_removed_with_alt_loc) group_index_array = np.delete(group_index_array, atoms_to_be_removed_with_alt_loc) chain_index_array = np.delete(chain_index_array, atoms_to_be_removed_with_alt_loc) + if len(atoms_to_be_removed_with_alt_loc): + coordinates_array = np.delete(coordinates_array, atoms_to_be_removed_with_alt_loc) + n_atoms = atom_id_array.shape[0] n_groups = group_name_array.shape[0] n_chains = chain_name_array.shape[0] - tmp_item.reset_atoms(n_atoms=n_atoms) - tmp_item.reset_groups(n_groups=n_groups) - tmp_item.reset_chains(n_chains=n_chains) + tmp_item.topology.reset_atoms(n_atoms=n_atoms) + tmp_item.topology.reset_groups(n_groups=n_groups) + tmp_item.topology.reset_chains(n_chains=n_chains) - tmp_item.atoms.atom_id = atom_id_array - tmp_item.atoms.atom_name = atom_name_array - tmp_item.atoms.group_index = group_index_array - tmp_item.atoms.chain_index = chain_index_array + tmp_item.topology.atoms.atom_id = atom_id_array + tmp_item.topology.atoms.atom_name = atom_name_array + tmp_item.topology.atoms.group_index = group_index_array + tmp_item.topology.atoms.chain_index = chain_index_array - tmp_item.rebuild_atoms(redefine_ids=False, redefine_types=True) + tmp_item.topology.rebuild_atoms(redefine_ids=False, redefine_types=True) - tmp_item.groups.group_id = group_id_array - tmp_item.groups.group_name = group_name_array + tmp_item.topology.groups.group_id = group_id_array + tmp_item.topology.groups.group_name = group_name_array - tmp_item.rebuild_groups(redefine_ids=False, redefine_types=True) + tmp_item.topology.rebuild_groups(redefine_ids=False, redefine_types=True) - tmp_item.chains.chain_name = chain_name_array + tmp_item.topology.chains.chain_name = chain_name_array - tmp_item.rebuild_chains(redefine_ids=True, redefine_types=False ) + tmp_item.topology.rebuild_chains(redefine_ids=True, redefine_types=False ) + + del(atom_id_array, atom_name_array, + group_index_array, group_id_array, group_name_array, + chain_index_array, chain_name_array, + occupancy_array, alternate_location_array, alt_atom_indices, aux_dict) if get_missing_bonds: + from molsysmt.build import get_missing_bonds as _get_missing_bonds + from molsysmt.pbc import get_box_from_lengths_and_angles + + cryst1 = item.entry.crystallographic_and_coordinate_transformation.cryst1 + box_lengths = puw.quantity([[cryst1.a, cryst1.b, cryst1.c]], 'angstroms') + box_angles = puw.quantity([[cryst1.alpha, cryst1.beta, cryst1.gamma]], 'degrees') + box = get_box_from_lengths_and_angles(box_lengths, box_angles, skip_digestion=True) + + coordinates = puw.quantity(coordinates_array, 'angstroms') + tmp_item.structures.append(coordinates=coordinates, box=box) + + del(coordinates_array, box, box_lengths, box_angles) + bonds = _get_missing_bonds(tmp_item, skip_digestion=True) bonds = np.array(bonds) - tmp_item.reset_bonds(n_bonds=bonds.shape[0]) - tmp_item.bonds.drop(['order', 'type'], axis=1, inplace=True) - tmp_item.bonds.atom1_index=bonds[:,0] - tmp_item.bonds.atom2_index=bonds[:,1] + tmp_item.topology,reset_bonds(n_bonds=bonds.shape[0]) + tmp_item.topology.bonds.drop(['order', 'type'], axis=1, inplace=True) + tmp_item.topology.bonds.atom1_index=bonds[:,0] + tmp_item.topology.bonds.atom2_index=bonds[:,1] - tmp_item.rebuild_components() - tmp_item.rebuild_molecules() - tmp_item.rebuild_chains(redefine_ids=False, redefine_types=True) - tmp_item.rebuild_entities() + tmp_item.topology.rebuild_components() + tmp_item.topology.rebuild_molecules() + tmp_item.topology.rebuild_chains(redefine_ids=False, redefine_types=True) + tmp_item.topology.rebuild_entities() - tmp_item = tmp_item.extract(atom_indices=atom_indices, copy_if_all=False, skip_digestion=True) + tmp_item = tmp_item.topology.extract(atom_indices=atom_indices, copy_if_all=False, skip_digestion=True) return tmp_item diff --git a/molsysmt/form/molsysmt_Topology/__init__.py b/molsysmt/form/molsysmt_Topology/__init__.py index 62a949001..e51a38fcb 100644 --- a/molsysmt/form/molsysmt_Topology/__init__.py +++ b/molsysmt/form/molsysmt_Topology/__init__.py @@ -20,6 +20,9 @@ from .set import * from .iterators import TopologyIterator +from .add_bonds import add_bonds +from .remove_bonds import remove_bonds + from .to_string_amino_acids_3 import to_string_amino_acids_3 from .to_string_amino_acids_1 import to_string_amino_acids_1 from .to_string_pdb_text import to_string_pdb_text diff --git a/molsysmt/form/molsysmt_Topology/add_bonds.py b/molsysmt/form/molsysmt_Topology/add_bonds.py new file mode 100644 index 000000000..49938b25e --- /dev/null +++ b/molsysmt/form/molsysmt_Topology/add_bonds.py @@ -0,0 +1,10 @@ +from molsysmt._private.exceptions import NotImplementedMethodError +from molsysmt._private.digestion import digest +from molsysmt import pyunitwizard as puw +import numpy as np + +@digest(form='molsysmt.Topology') +def add_bonds(item, bonded_atom_pairs, skip_digestion=False): + + item.add_bonds(bonded_atom_pairs, skip_digestion=True) + diff --git a/molsysmt/form/molsysmt_Topology/remove_bonds.py b/molsysmt/form/molsysmt_Topology/remove_bonds.py new file mode 100644 index 000000000..2c32fd42c --- /dev/null +++ b/molsysmt/form/molsysmt_Topology/remove_bonds.py @@ -0,0 +1,8 @@ +from molsysmt._private.exceptions import NotImplementedMethodError +from molsysmt._private.digestion import digest +from molsysmt._private.variables import is_all + +@digest(form='molsysmt.Topology') +def remove_bonds(item, bond_indices='all', skip_digestion=False): + + return item.remove_bonds(bond_indices=bond_indices, skip_digestion=True) diff --git a/molsysmt/form/openmm_Modeller/__init__.py b/molsysmt/form/openmm_Modeller/__init__.py index 4c4f1bbe5..c6171de36 100644 --- a/molsysmt/form/openmm_Modeller/__init__.py +++ b/molsysmt/form/openmm_Modeller/__init__.py @@ -2,9 +2,9 @@ form_type = 'class' form_info = ["", ""] -piped_topological_attribute = None -piped_structural_attribute = None -piped_any_attribute = None +piped_topological_attribute = 'molsysmt.Topology' +piped_structural_attribute = 'molsysmt.Structures' +piped_any_attribute = 'molsysmt.MolSys' from .is_form import is_form diff --git a/molsysmt/native/topology.py b/molsysmt/native/topology.py index df44d88f0..3b73ef109 100644 --- a/molsysmt/native/topology.py +++ b/molsysmt/native/topology.py @@ -334,8 +334,46 @@ def add_bonds(self, bonded_atom_pairs, skip_digestion=False): self.bonds._sort_bonds() self.bonds._remove_empty_columns() + self.rebuild_components() + self.rebuild_molecules() + self.rebuild_entities() + del(df_concatenado, aux_bonds_dataframe) + def remove_bonds(self, bond_indices='all', skip_digestion=False): + + if is_all(bond_indices): + + self.bonds = Bonds_DataFrame(n_bonds=0) + + else: + + tmp_dataframe = self.bonds.drop(bond_indices) + + n_bonds = bonded_atom_pairs.shape[0] + + self.bonds = Bonds_DataFrame(n_bonds=n_bonds) + self.bonds.atom1_index=tmp_dataframe.atom1_index + self.bonds.atom2_index=tmp_dataframe.atom2_index + + if 'order' in tmp_dataframe: + self.bonds['order'] = tmp_dataframe['order'] + else: + del self.bonds['order'] + + if 'type' in tmp_dataframe: + self.bonds['type'] = tmp_dataframe['type'] + else: + del self.bonds['type'] + + self.bonds._sort_bonds() + + del(tmp_dataframe) + + self.rebuild_components() + self.rebuild_molecules() + self.rebuild_entities() + def add_missing_bonds(self, selection='all', syntax='MolSysMT', skip_digestion=False): @@ -347,6 +385,10 @@ def add_missing_bonds(self, selection='all', syntax='MolSysMT', skip_digestion=F self.add_bonds(bonds, skip_digestion=True) + self.rebuild_components() + self.rebuild_molecules() + self.rebuild_entities() + def rebuild_atoms(self, redefine_ids=True, redefine_types=True): if redefine_ids: diff --git a/molsysmt/tests/basic/compare/test_compare_with_molsysmt_MolSys.py b/molsysmt/tests/basic/compare/test_compare_with_molsysmt_MolSys.py index 34864c6f8..4c2ab222d 100644 --- a/molsysmt/tests/basic/compare/test_compare_with_molsysmt_MolSys.py +++ b/molsysmt/tests/basic/compare/test_compare_with_molsysmt_MolSys.py @@ -51,17 +51,17 @@ def test_compare_all_eq_3(): if comparison['chain_index']!=True: output = False - if comparison['chain_name']!=False: + if comparison['chain_name']!=True: output = False - if comparison['chain_id']!=False: + if comparison['chain_id']!=True: output = False - if comparison['chain_type']!=False: + if comparison['chain_type']!=True: output = False if comparison['molecule_index']!=True: output = False if comparison['molecule_type']!=True: - output = False + output = True if comparison['bonded_atoms']!=True: output = False diff --git a/molsysmt/tests/build/remove_bonds/test_remove_bonds_molsysmt_MolSys.py b/molsysmt/tests/build/remove_bonds/test_remove_bonds_molsysmt_MolSys.py new file mode 100644 index 000000000..928716064 --- /dev/null +++ b/molsysmt/tests/build/remove_bonds/test_remove_bonds_molsysmt_MolSys.py @@ -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_remove_bonds_molsysmt_MolSys_1(): + + molsys = msm.convert(systems['T4 lysozyme L99A']['t4_lysozyme_L99A.h5msm']) + n_bonds_before = msm.get(molsys, n_bonds=True) + msm.build.remove_bonds(molsys) + n_bonds_after = msm.get(molsys, n_bonds=True) + + assert n_bonds_before==2645 + assert n_bonds_after==0 + diff --git a/sandbox/Tests.ipynb b/sandbox/Tests.ipynb index f0f62f83b..a0d10c277 100644 --- a/sandbox/Tests.ipynb +++ b/sandbox/Tests.ipynb @@ -28,7 +28,7 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "99da1f04440343a7af688013598d9547", + "model_id": "49a21aadf38949e584dcb9e5c69ba80e", "version_major": 2, "version_minor": 0 }, @@ -56,77 +56,163 @@ { "cell_type": "code", "execution_count": 4, - "id": "020376b7-c10e-4ef8-8b2a-fd04c900e938", + "id": "effbea99-d147-4c87-96bd-894cd565a116", "metadata": {}, "outputs": [], "source": [ - "molsys = msm.convert(systems['TcTIM']['1tcd.h5msm'], to_form='molsysmt.MolSys')" + "molsys = systems['T4 lysozyme L99A']['t4_lysozyme_L99A.h5msm']" ] }, { "cell_type": "code", "execution_count": 5, - "id": "1fc79724-d236-45f6-a2e7-838a87c522c1", + "id": "aa0a59f4-725f-4d2e-b6d8-4f0a32e32726", "metadata": {}, "outputs": [], "source": [ - "view = msm.convert(molsys, to_form='nglview.NGLWidget')" + "molsys_ref = msm.convert(molsys, to_form='molsysmt.MolSys')" ] }, { "cell_type": "code", "execution_count": 6, - "id": "cd4610ac-0e3b-455f-b0d1-1c809edbaca6", + "id": "f83375bd-b82c-47c0-8afa-e424960b39d2", "metadata": {}, "outputs": [ { - "ename": "NotImplementedFormError", - "evalue": "None", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)", - "File \u001b[0;32m/conda/miniconda3/envs/MolSysMT@uibcdf_3.10/lib/python3.10/site-packages/pyunitwizard/main.py:27\u001b[0m, in \u001b[0;36mget_form\u001b[0;34m(quantity_or_unit)\u001b[0m\n\u001b[1;32m 26\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m---> 27\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mdict_is_form\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;28;43mtype\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43mquantity_or_unit\u001b[49m\u001b[43m)\u001b[49m\u001b[43m]\u001b[49m\n\u001b[1;32m 28\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mKeyError\u001b[39;00m:\n", - "\u001b[0;31mKeyError\u001b[0m: ", - "\nDuring handling of the above exception, another exception occurred:\n", - "\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)", - "File \u001b[0;32m/conda/miniconda3/envs/MolSysMT@uibcdf_3.10/lib/python3.10/site-packages/pyunitwizard/main.py:30\u001b[0m, in \u001b[0;36mget_form\u001b[0;34m(quantity_or_unit)\u001b[0m\n\u001b[1;32m 29\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m---> 30\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mdict_is_form\u001b[49m\u001b[43m[\u001b[49m\u001b[43mquantity_or_unit\u001b[49m\u001b[43m]\u001b[49m\n\u001b[1;32m 31\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mKeyError\u001b[39;00m:\n", - "\u001b[0;31mKeyError\u001b[0m: None", - "\nDuring handling of the above exception, another exception occurred:\n", - "\u001b[0;31mNotImplementedFormError\u001b[0m Traceback (most recent call last)", - "Cell \u001b[0;32mIn[6], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mmsm\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget\u001b[49m\u001b[43m(\u001b[49m\u001b[43mview\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43melement\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43msystem\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mn_components\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m)\u001b[49m\n", - "File \u001b[0;32m~/repos@uibcdf/MolSysMT/molsysmt/_private/digestion/digest.py:122\u001b[0m, in \u001b[0;36mdigest..digestor..wrapper\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 120\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m func(all_args[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mself\u001b[39m\u001b[38;5;124m'\u001b[39m], \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mfinal_args)\n\u001b[1;32m 121\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m--> 122\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mfunc\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mfinal_args\u001b[49m\u001b[43m)\u001b[49m\n", - "File \u001b[0;32m~/repos@uibcdf/MolSysMT/molsysmt/basic/get.py:282\u001b[0m, in \u001b[0;36mget\u001b[0;34m(molecular_system, element, selection, structure_indices, mask, syntax, get_missing_bonds, output_type, skip_digestion, **kwargs)\u001b[0m\n\u001b[1;32m 280\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 281\u001b[0m aux_get \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mgetattr\u001b[39m(_dict_modules[aux_form], \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mget_\u001b[39m\u001b[38;5;132;01m{\u001b[39;00min_attribute\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m_from_\u001b[39m\u001b[38;5;132;01m{\u001b[39;00melement\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m'\u001b[39m)\n\u001b[0;32m--> 282\u001b[0m result \u001b[38;5;241m=\u001b[39m \u001b[43maux_get\u001b[49m\u001b[43m(\u001b[49m\u001b[43maux_item\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mdict_indices\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 284\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 286\u001b[0m result \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m\n", - "File \u001b[0;32m~/repos@uibcdf/MolSysMT/molsysmt/_private/digestion/digest.py:122\u001b[0m, in \u001b[0;36mdigest..digestor..wrapper\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 120\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m func(all_args[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mself\u001b[39m\u001b[38;5;124m'\u001b[39m], \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mfinal_args)\n\u001b[1;32m 121\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m--> 122\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mfunc\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mfinal_args\u001b[49m\u001b[43m)\u001b[49m\n", - "File \u001b[0;32m~/repos@uibcdf/MolSysMT/molsysmt/form/nglview_NGLWidget/get_topological_attributes.py:4183\u001b[0m, in \u001b[0;36mget_n_components_from_system\u001b[0;34m(item, skip_digestion)\u001b[0m\n\u001b[1;32m 4180\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mmolsysmt_Topology\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m get_n_components_from_system \u001b[38;5;28;01mas\u001b[39;00m aux_get\n\u001b[1;32m 4182\u001b[0m bonds_required \u001b[38;5;241m=\u001b[39m bonds_are_required_to_get_attribute(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mn_components\u001b[39m\u001b[38;5;124m'\u001b[39m, \u001b[38;5;124m'\u001b[39m\u001b[38;5;124msystem\u001b[39m\u001b[38;5;124m'\u001b[39m)\n\u001b[0;32m-> 4183\u001b[0m tmp_item \u001b[38;5;241m=\u001b[39m \u001b[43mto_molsysmt_Topology\u001b[49m\u001b[43m(\u001b[49m\u001b[43mitem\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mget_missing_bonds\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mbonds_required\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mskip_digestion\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m)\u001b[49m\n\u001b[1;32m 4184\u001b[0m output \u001b[38;5;241m=\u001b[39m aux_get(tmp_item, skip_digestion\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m)\n\u001b[1;32m 4186\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m output\n", - "File \u001b[0;32m~/repos@uibcdf/MolSysMT/molsysmt/_private/digestion/digest.py:52\u001b[0m, in \u001b[0;36mdigest..digestor..wrapper\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 48\u001b[0m \u001b[38;5;129m@functools\u001b[39m\u001b[38;5;241m.\u001b[39mwraps(func)\n\u001b[1;32m 49\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mwrapper\u001b[39m(\u001b[38;5;241m*\u001b[39margs, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs):\n\u001b[1;32m 51\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m kwargs\u001b[38;5;241m.\u001b[39mget(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mskip_digestion\u001b[39m\u001b[38;5;124m'\u001b[39m, \u001b[38;5;28;01mFalse\u001b[39;00m):\n\u001b[0;32m---> 52\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mfunc\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 54\u001b[0m \u001b[38;5;66;03m# Define caller\u001b[39;00m\n\u001b[1;32m 56\u001b[0m caller \u001b[38;5;241m=\u001b[39m func\u001b[38;5;241m.\u001b[39m\u001b[38;5;18m__module__\u001b[39m\u001b[38;5;241m+\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m.\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;241m+\u001b[39mfunc\u001b[38;5;241m.\u001b[39m\u001b[38;5;18m__name__\u001b[39m\n", - "File \u001b[0;32m~/repos@uibcdf/MolSysMT/molsysmt/form/nglview_NGLWidget/to_molsysmt_Topology.py:10\u001b[0m, in \u001b[0;36mto_molsysmt_Topology\u001b[0;34m(item, atom_indices, get_missing_bonds, skip_digestion)\u001b[0m\n\u001b[1;32m 7\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mstring_pdb_text\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m to_molsysmt_Topology \u001b[38;5;28;01mas\u001b[39;00m string_pdb_text_to_molsysmt_Topology\n\u001b[1;32m 9\u001b[0m tmp_item \u001b[38;5;241m=\u001b[39m to_string_pdb_text(item, skip_digestion\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m)\n\u001b[0;32m---> 10\u001b[0m tmp_item \u001b[38;5;241m=\u001b[39m \u001b[43mstring_pdb_text_to_molsysmt_Topology\u001b[49m\u001b[43m(\u001b[49m\u001b[43mtmp_item\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43matom_indices\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43matom_indices\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 11\u001b[0m \u001b[43m \u001b[49m\u001b[43mget_missing_bonds\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mget_missing_bonds\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mskip_digestion\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m)\u001b[49m\n\u001b[1;32m 13\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m tmp_item\n", - "File \u001b[0;32m~/repos@uibcdf/MolSysMT/molsysmt/_private/digestion/digest.py:52\u001b[0m, in \u001b[0;36mdigest..digestor..wrapper\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 48\u001b[0m \u001b[38;5;129m@functools\u001b[39m\u001b[38;5;241m.\u001b[39mwraps(func)\n\u001b[1;32m 49\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mwrapper\u001b[39m(\u001b[38;5;241m*\u001b[39margs, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs):\n\u001b[1;32m 51\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m kwargs\u001b[38;5;241m.\u001b[39mget(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mskip_digestion\u001b[39m\u001b[38;5;124m'\u001b[39m, \u001b[38;5;28;01mFalse\u001b[39;00m):\n\u001b[0;32m---> 52\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mfunc\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 54\u001b[0m \u001b[38;5;66;03m# Define caller\u001b[39;00m\n\u001b[1;32m 56\u001b[0m caller \u001b[38;5;241m=\u001b[39m func\u001b[38;5;241m.\u001b[39m\u001b[38;5;18m__module__\u001b[39m\u001b[38;5;241m+\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m.\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;241m+\u001b[39mfunc\u001b[38;5;241m.\u001b[39m\u001b[38;5;18m__name__\u001b[39m\n", - "File \u001b[0;32m~/repos@uibcdf/MolSysMT/molsysmt/form/string_pdb_text/to_molsysmt_Topology.py:10\u001b[0m, in \u001b[0;36mto_molsysmt_Topology\u001b[0;34m(item, atom_indices, get_missing_bonds, skip_digestion)\u001b[0m\n\u001b[1;32m 7\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mmolsysmt_PDBFileHandler\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m to_molsysmt_Topology \u001b[38;5;28;01mas\u001b[39;00m molsysmt_PDBFileHandler_to_molsysmt_Topology\n\u001b[1;32m 9\u001b[0m tmp_item \u001b[38;5;241m=\u001b[39m to_molsysmt_PDBFileHandler(item, skip_digestion\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m)\n\u001b[0;32m---> 10\u001b[0m tmp_item \u001b[38;5;241m=\u001b[39m \u001b[43mmolsysmt_PDBFileHandler_to_molsysmt_Topology\u001b[49m\u001b[43m(\u001b[49m\u001b[43mtmp_item\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43matom_indices\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43matom_indices\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 11\u001b[0m \u001b[43m \u001b[49m\u001b[43mget_missing_bonds\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mget_missing_bonds\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 12\u001b[0m \u001b[43m \u001b[49m\u001b[43mskip_digestion\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m)\u001b[49m\n\u001b[1;32m 14\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m tmp_item\n", - "File \u001b[0;32m~/repos@uibcdf/MolSysMT/molsysmt/_private/digestion/digest.py:52\u001b[0m, in \u001b[0;36mdigest..digestor..wrapper\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 48\u001b[0m \u001b[38;5;129m@functools\u001b[39m\u001b[38;5;241m.\u001b[39mwraps(func)\n\u001b[1;32m 49\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mwrapper\u001b[39m(\u001b[38;5;241m*\u001b[39margs, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs):\n\u001b[1;32m 51\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m kwargs\u001b[38;5;241m.\u001b[39mget(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mskip_digestion\u001b[39m\u001b[38;5;124m'\u001b[39m, \u001b[38;5;28;01mFalse\u001b[39;00m):\n\u001b[0;32m---> 52\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mfunc\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 54\u001b[0m \u001b[38;5;66;03m# Define caller\u001b[39;00m\n\u001b[1;32m 56\u001b[0m caller \u001b[38;5;241m=\u001b[39m func\u001b[38;5;241m.\u001b[39m\u001b[38;5;18m__module__\u001b[39m\u001b[38;5;241m+\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m.\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;241m+\u001b[39mfunc\u001b[38;5;241m.\u001b[39m\u001b[38;5;18m__name__\u001b[39m\n", - "File \u001b[0;32m~/repos@uibcdf/MolSysMT/molsysmt/form/molsysmt_PDBFileHandler/to_molsysmt_Topology.py:131\u001b[0m, in \u001b[0;36mto_molsysmt_Topology\u001b[0;34m(item, atom_indices, structure_indices, get_missing_bonds, skip_digestion)\u001b[0m\n\u001b[1;32m 127\u001b[0m tmp_item\u001b[38;5;241m.\u001b[39mrebuild_chains(redefine_ids\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m, redefine_types\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mFalse\u001b[39;00m )\n\u001b[1;32m 129\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m get_missing_bonds:\n\u001b[0;32m--> 131\u001b[0m bonds \u001b[38;5;241m=\u001b[39m \u001b[43m_get_missing_bonds\u001b[49m\u001b[43m(\u001b[49m\u001b[43mtmp_item\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mskip_digestion\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m)\u001b[49m\n\u001b[1;32m 132\u001b[0m bonds \u001b[38;5;241m=\u001b[39m np\u001b[38;5;241m.\u001b[39marray(bonds)\n\u001b[1;32m 133\u001b[0m tmp_item\u001b[38;5;241m.\u001b[39mreset_bonds(n_bonds\u001b[38;5;241m=\u001b[39mbonds\u001b[38;5;241m.\u001b[39mshape[\u001b[38;5;241m0\u001b[39m])\n", - "File \u001b[0;32m~/repos@uibcdf/MolSysMT/molsysmt/_private/digestion/digest.py:52\u001b[0m, in \u001b[0;36mdigest..digestor..wrapper\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 48\u001b[0m \u001b[38;5;129m@functools\u001b[39m\u001b[38;5;241m.\u001b[39mwraps(func)\n\u001b[1;32m 49\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mwrapper\u001b[39m(\u001b[38;5;241m*\u001b[39margs, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs):\n\u001b[1;32m 51\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m kwargs\u001b[38;5;241m.\u001b[39mget(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mskip_digestion\u001b[39m\u001b[38;5;124m'\u001b[39m, \u001b[38;5;28;01mFalse\u001b[39;00m):\n\u001b[0;32m---> 52\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mfunc\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 54\u001b[0m \u001b[38;5;66;03m# Define caller\u001b[39;00m\n\u001b[1;32m 56\u001b[0m caller \u001b[38;5;241m=\u001b[39m func\u001b[38;5;241m.\u001b[39m\u001b[38;5;18m__module__\u001b[39m\u001b[38;5;241m+\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m.\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;241m+\u001b[39mfunc\u001b[38;5;241m.\u001b[39m\u001b[38;5;18m__name__\u001b[39m\n", - "File \u001b[0;32m~/repos@uibcdf/MolSysMT/molsysmt/build/get_missing_bonds.py:68\u001b[0m, in \u001b[0;36mget_missing_bonds\u001b[0;34m(molecular_system, threshold, selection, structure_indices, syntax, engine, with_templates, with_distances, sorted, skip_digestion)\u001b[0m\n\u001b[1;32m 48\u001b[0m \u001b[38;5;28;01mpass\u001b[39;00m\n\u001b[1;32m 50\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m with_distances:\n\u001b[1;32m 51\u001b[0m \n\u001b[1;32m 52\u001b[0m \u001b[38;5;66;03m# Protein:\u001b[39;00m\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 65\u001b[0m \u001b[38;5;66;03m# Enlace C-C: aproximadamente 1.54 Å\u001b[39;00m\n\u001b[1;32m 66\u001b[0m \u001b[38;5;66;03m# Enlace P-O: aproximadamente 1.61 Å\u001b[39;00m\n\u001b[0;32m---> 68\u001b[0m contacts_heavy_atoms \u001b[38;5;241m=\u001b[39m \u001b[43mget_contacts\u001b[49m\u001b[43m(\u001b[49m\u001b[43mmolecular_system\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mselection\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mheavy_atoms_not_water\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 69\u001b[0m \u001b[43m \u001b[49m\u001b[43mthreshold\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mthreshold\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43moutput_type\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mpairs\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 70\u001b[0m \u001b[43m \u001b[49m\u001b[43moutput_indices\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43matom\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mpbc\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mskip_digestion\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m)\u001b[49m\n\u001b[1;32m 72\u001b[0m bonds_distances \u001b[38;5;241m+\u001b[39m\u001b[38;5;241m=\u001b[39m contacts_heavy_atoms[\u001b[38;5;241m0\u001b[39m]\n\u001b[1;32m 74\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mlen\u001b[39m(h_atoms_not_water):\n", - "File \u001b[0;32m~/repos@uibcdf/MolSysMT/molsysmt/_private/digestion/digest.py:52\u001b[0m, in \u001b[0;36mdigest..digestor..wrapper\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 48\u001b[0m \u001b[38;5;129m@functools\u001b[39m\u001b[38;5;241m.\u001b[39mwraps(func)\n\u001b[1;32m 49\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mwrapper\u001b[39m(\u001b[38;5;241m*\u001b[39margs, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs):\n\u001b[1;32m 51\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m kwargs\u001b[38;5;241m.\u001b[39mget(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mskip_digestion\u001b[39m\u001b[38;5;124m'\u001b[39m, \u001b[38;5;28;01mFalse\u001b[39;00m):\n\u001b[0;32m---> 52\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mfunc\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 54\u001b[0m \u001b[38;5;66;03m# Define caller\u001b[39;00m\n\u001b[1;32m 56\u001b[0m caller \u001b[38;5;241m=\u001b[39m func\u001b[38;5;241m.\u001b[39m\u001b[38;5;18m__module__\u001b[39m\u001b[38;5;241m+\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m.\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;241m+\u001b[39mfunc\u001b[38;5;241m.\u001b[39m\u001b[38;5;18m__name__\u001b[39m\n", - "File \u001b[0;32m~/repos@uibcdf/MolSysMT/molsysmt/structure/get_contacts.py:31\u001b[0m, in \u001b[0;36mget_contacts\u001b[0;34m(molecular_system, selection, center_of_atoms, weights, structure_indices, selection_2, center_of_atoms_2, weights_2, structure_indices_2, threshold, pbc, syntax, output_type, output_indices, skip_digestion)\u001b[0m\n\u001b[1;32m 28\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 29\u001b[0m atom_indices_2 \u001b[38;5;241m=\u001b[39m select(molecular_system, selection\u001b[38;5;241m=\u001b[39mselection_2, syntax\u001b[38;5;241m=\u001b[39msyntax)\n\u001b[0;32m---> 31\u001b[0m all_dists \u001b[38;5;241m=\u001b[39m \u001b[43mget_distances\u001b[49m\u001b[43m(\u001b[49m\u001b[43mmolecular_system\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mmolecular_system\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mselection\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43matom_indices\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 32\u001b[0m \u001b[43m \u001b[49m\u001b[43mcenter_of_atoms\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mcenter_of_atoms\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mweights\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mweights\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mstructure_indices\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mstructure_indices\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 33\u001b[0m \u001b[43m \u001b[49m\u001b[43mselection_2\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43matom_indices_2\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mcenter_of_atoms_2\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mcenter_of_atoms_2\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mweights_2\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mweights_2\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 34\u001b[0m \u001b[43m \u001b[49m\u001b[43mstructure_indices_2\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mstructure_indices_2\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mpbc\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mpbc\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 36\u001b[0m length_units \u001b[38;5;241m=\u001b[39m puw\u001b[38;5;241m.\u001b[39mget_unit(all_dists)\n\u001b[1;32m 37\u001b[0m threshold \u001b[38;5;241m=\u001b[39m puw\u001b[38;5;241m.\u001b[39mget_value(threshold, to_unit\u001b[38;5;241m=\u001b[39mlength_units)\n", - "File \u001b[0;32m~/repos@uibcdf/MolSysMT/molsysmt/_private/digestion/digest.py:122\u001b[0m, in \u001b[0;36mdigest..digestor..wrapper\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 120\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m func(all_args[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mself\u001b[39m\u001b[38;5;124m'\u001b[39m], \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mfinal_args)\n\u001b[1;32m 121\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m--> 122\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mfunc\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mfinal_args\u001b[49m\u001b[43m)\u001b[49m\n", - "File \u001b[0;32m~/repos@uibcdf/MolSysMT/molsysmt/structure/get_distances.py:84\u001b[0m, in \u001b[0;36mget_distances\u001b[0;34m(molecular_system, selection, structure_indices, center_of_atoms, weights, molecular_system_2, selection_2, structure_indices_2, center_of_atoms_2, weights_2, pairs, pbc, engine, syntax)\u001b[0m\n\u001b[1;32m 80\u001b[0m in_memory \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mFalse\u001b[39;00m\n\u001b[1;32m 82\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m in_memory:\n\u001b[0;32m---> 84\u001b[0m output \u001b[38;5;241m=\u001b[39m \u001b[43m_get_distances_in_memory\u001b[49m\u001b[43m(\u001b[49m\u001b[43mmolecular_system\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 85\u001b[0m \u001b[43m \u001b[49m\u001b[43mselection\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43matom_indices\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mstructure_indices\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mstructure_indices\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mcenter_of_atoms\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mcenter_of_atoms\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mweights\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mweights\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 86\u001b[0m \u001b[43m \u001b[49m\u001b[43mmolecular_system_2\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mmolecular_system_2\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mselection_2\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43matom_indices_2\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mstructure_indices_2\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mstructure_indices_2\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 87\u001b[0m \u001b[43m \u001b[49m\u001b[43mcenter_of_atoms_2\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mcenter_of_atoms_2\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mweights_2\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mweights_2\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mpairs\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mpairs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mpbc\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mpbc\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43msyntax\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43msyntax\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 89\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 91\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m NotImplementedMethodError\n", - "File \u001b[0;32m~/repos@uibcdf/MolSysMT/molsysmt/structure/get_distances.py:171\u001b[0m, in \u001b[0;36m_get_distances_in_memory\u001b[0;34m(molecular_system, selection, structure_indices, center_of_atoms, weights, molecular_system_2, selection_2, structure_indices_2, center_of_atoms_2, weights_2, pairs, pbc, aux_dict, syntax)\u001b[0m\n\u001b[1;32m 167\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m pairs:\n\u001b[1;32m 169\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m coordinates_2 \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[0;32m--> 171\u001b[0m coordinates, length_unit \u001b[38;5;241m=\u001b[39m \u001b[43mpuw\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget_value_and_unit\u001b[49m\u001b[43m(\u001b[49m\u001b[43mcoordinates\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 173\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m pbc:\n\u001b[1;32m 174\u001b[0m box \u001b[38;5;241m=\u001b[39m get(molecular_system, element\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124msystem\u001b[39m\u001b[38;5;124m'\u001b[39m, structure_indices\u001b[38;5;241m=\u001b[39mstructure_indices, box\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m)\n", - "File \u001b[0;32m/conda/miniconda3/envs/MolSysMT@uibcdf_3.10/lib/python3.10/site-packages/pyunitwizard/main.py:180\u001b[0m, in \u001b[0;36mget_value_and_unit\u001b[0;34m(quantity, to_unit, to_form, parser, standardized)\u001b[0m\n\u001b[1;32m 177\u001b[0m quantity \u001b[38;5;241m=\u001b[39m standardize(quantity)\n\u001b[1;32m 178\u001b[0m to_unit \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[0;32m--> 180\u001b[0m value \u001b[38;5;241m=\u001b[39m \u001b[43mconvert\u001b[49m\u001b[43m(\u001b[49m\u001b[43mquantity\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mto_unit\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mto_unit\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mparser\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mparser\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mto_type\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mvalue\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m)\u001b[49m\n\u001b[1;32m 181\u001b[0m unit \u001b[38;5;241m=\u001b[39m convert(quantity, to_unit\u001b[38;5;241m=\u001b[39mto_unit, to_form\u001b[38;5;241m=\u001b[39mto_form, parser\u001b[38;5;241m=\u001b[39mparser, to_type\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124munit\u001b[39m\u001b[38;5;124m'\u001b[39m)\n\u001b[1;32m 183\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m value, unit\n", - "File \u001b[0;32m/conda/miniconda3/envs/MolSysMT@uibcdf_3.10/lib/python3.10/site-packages/pyunitwizard/main.py:547\u001b[0m, in \u001b[0;36mconvert\u001b[0;34m(quantity_or_unit, to_unit, to_form, parser, to_type)\u001b[0m\n\u001b[1;32m 522\u001b[0m \u001b[38;5;250m\u001b[39m\u001b[38;5;124;03m\"\"\" Converts a quantity or unit to a different unit and/or to a different\u001b[39;00m\n\u001b[1;32m 523\u001b[0m \u001b[38;5;124;03m form and/or type. \u001b[39;00m\n\u001b[1;32m 524\u001b[0m \n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 543\u001b[0m \u001b[38;5;124;03m be a float or a numpy array.\u001b[39;00m\n\u001b[1;32m 544\u001b[0m \u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[1;32m 545\u001b[0m output \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[0;32m--> 547\u001b[0m form_in \u001b[38;5;241m=\u001b[39m \u001b[43mget_form\u001b[49m\u001b[43m(\u001b[49m\u001b[43mquantity_or_unit\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 548\u001b[0m to_form \u001b[38;5;241m=\u001b[39m digest_to_form(to_form, form_in)\n\u001b[1;32m 549\u001b[0m parser \u001b[38;5;241m=\u001b[39m digest_parser(parser)\n", - "File \u001b[0;32m/conda/miniconda3/envs/MolSysMT@uibcdf_3.10/lib/python3.10/site-packages/pyunitwizard/main.py:32\u001b[0m, in \u001b[0;36mget_form\u001b[0;34m(quantity_or_unit)\u001b[0m\n\u001b[1;32m 30\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m dict_is_form[quantity_or_unit]\n\u001b[1;32m 31\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mKeyError\u001b[39;00m:\n\u001b[0;32m---> 32\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m NotImplementedFormError(\u001b[38;5;28mtype\u001b[39m(quantity_or_unit))\n", - "\u001b[0;31mNotImplementedFormError\u001b[0m: None" - ] + "data": { + "text/plain": [ + "2645" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "msm.get(molsys_ref, n_bonds=True)" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "9dc3125c-8c88-458a-839d-8e1fb5f08a94", + "metadata": {}, + "outputs": [], + "source": [ + "msm.build.remove_bonds(molsys_ref)" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "0f2e011a-e04a-4eab-98f1-df632c2cc111", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "0" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" } ], "source": [ - "msm.get(view, element='system', n_components=True)" + "msm.get(molsys_ref, n_bonds=True)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "2bfbe476-e055-4ba0-aaf4-7acefa3af748", + "metadata": {}, + "outputs": [], + "source": [ + "msm.build.get_missing_bonds(molsys_ref)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "a03e5920-0979-4447-b51e-0bd06c02a49b", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "85eb504d-6b8c-49dd-b907-2badaffb61a9", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "947878fd-4868-4ead-8e87-6b416c1803be", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "60db1fdc-7ed5-4f3a-9da5-984952bb8a65", + "metadata": {}, + "outputs": [], + "source": [ + "molsys = msm.convert(molsys, to_form='nglview.NGLWidget')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "0a5d8789-a163-444d-a08c-7f04cc82e44e", + "metadata": {}, + "outputs": [], + "source": [ + "n_molecules_ref, n_structures_ref = msm.get(molsys_ref, element='system', n_molecules=True, n_structures=True)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "cdc1cceb-f9d2-4826-a80d-677a799eb0be", + "metadata": {}, + "outputs": [], + "source": [ + "msm.convert(molsys, to_form='molsysmt.Topology', get_missing_bonds=True)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "6db05926-2da0-408e-a18e-3a7c9a24cf6a", + "metadata": {}, + "outputs": [], + "source": [ + "msm.get(molsys, element='system', n_molecules=True)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "6edaa896-669c-4926-adaf-804cc59518da", + "metadata": {}, + "outputs": [], + "source": [ + "n_molecules, n_structures = msm.get(molsys, element='system', n_molecules=True, n_structures=True)" ] }, { "cell_type": "code", "execution_count": null, - "id": "59e18040-4290-4bed-8bf3-1021d2a4234a", + "id": "0a294fc7-05e2-4a73-b6e7-b4cfd181a4bb", "metadata": {}, "outputs": [], "source": []