diff --git a/.gitignore b/.gitignore index 85703c0ca..7ac111863 100644 --- a/.gitignore +++ b/.gitignore @@ -112,7 +112,8 @@ record.txt *.mod *.swp -# JetBrains +# VSCode +.vscode .idea # In This Library @@ -123,5 +124,3 @@ devtools/playground/* !molsysmt/lib molsysmt/_version.py -# pycharm -.idea/ diff --git a/molsysmt/_private/digestion/argument/element.py b/molsysmt/_private/digestion/argument/element.py index 7f350ad7b..fd691cd04 100644 --- a/molsysmt/_private/digestion/argument/element.py +++ b/molsysmt/_private/digestion/argument/element.py @@ -17,12 +17,12 @@ def digest_element(element, caller=None): """ - from molsysmt.element import _elements, _element_plural_to_singular + from molsysmt.element import _elements, _plural_elements_to_singular if isinstance(element, str): element_name_lower = element.lower() - if element_name_lower in _element_plural_to_singular: - return _element_plural_to_singular[element_name_lower] + if element_name_lower in _plural_elements_to_singular: + return _plural_elements_to_singular[element_name_lower] if element_name_lower in _elements: return element_name_lower elif element is None: diff --git a/molsysmt/_private/get.py b/molsysmt/_private/get.py new file mode 100644 index 000000000..84db797d0 --- /dev/null +++ b/molsysmt/_private/get.py @@ -0,0 +1,442 @@ +from molsysmt._private.variables import is_all +from molsysmt.element import is_composed_of, is_element +from molsysmt.element import _plural_elements_to_singular, _singular_element_to_plural +from molsysmt.element.group import _plural_group_types_to_singular +from molsysmt.element.group import is_group_type +from molsysmt.element.molecule import _plural_molecule_types_to_singular +from molsysmt.element.molecule import is_molecule_type +import numpy as np +import pandas as pd +from networkx import Graph +from importlib import import_module + +def _auxiliary_getter(function, item, indices='all'): + + module = import_module(function.__module__) + function_name = function.__name__ + + words = function_name.split('_') + + if 'n' == words[1]: + + aux_word = function_name.split('get_n_')[-1].split('_from_')[0].replace('_', ' ') + + if is_element(aux_word): + + involved_element = _plural_elements_to_singular[words[2]] + base_element = words[-1] + + if involved_element == base_element: + + return _get_n_elements(module, base_element, item, indices) + + else: + + if is_composed_of(base_element, involved_element): + + return _get_n_inf_from_element(module, involved_element, base_element, item, indices) + + else: + + return _get_n_sup_from_element(module, involved_element, base_element, item, indices) + + elif is_group_type(aux_word): + + base_element = words[-1] + if aux_word in _plural_group_types_to_singular: + aux_word = _plural_group_types_to_singular[aux_word] + + if base_element == 'system': + + return _get_n_group_type_from_system(module, aux_word, item) + + else: + + return _get_n_group_type_from_element(module, aux_word, base_element, item, indices) + + elif is_molecule_type(aux_word): + + base_element = words[-1] + if aux_word in _plural_molecule_types_to_singular: + aux_word = _plural_molecule_types_to_singular[aux_word] + + if base_element == 'system': + + return _get_n_molecule_type_from_system(module, aux_word, item) + + else: + + return _get_n_molecule_type_from_element(module, aux_word, base_element, item, indices) + + else: + + raise NotImplementedError + + elif 'index' == words[2]: + + involved_element = words[1] + base_element = words[-1] + + if involved_element == base_element: + + return _get_index_from_element(module, base_element, item, indices) + + else: + + if is_composed_of(base_element, involved_element): + + return _get_inf_index_from_element(module, involved_element, base_element, item, indices) + + else: + + return _get_sup_index_from_element(module, involved_element, base_element, item, indices) + + elif is_element(words[1]): + + involved_element = words[1] + attribute = words[2] + base_element = words[-1] + + if involved_element == base_element: + + raise NotImplementedError + + else: + + if is_composed_of(base_element, involved_element): + + return _get_inf_attr_from_element(module, involved_element, attribute, base_element, item, + indices) + + else: + + return _get_sup_attr_from_element(module, involved_element, attribute, base_element, item, + indices) + + elif function_name == 'get_bond_index_from_atom': + + return _get_bond_index_from_atom(module, item, indices) + + elif function_name == 'get_bonded_atoms_from_atom': + + return _get_bonded_atoms_from_atom(module, item, indices) + + elif function_name == 'get_inner_bond_index_from_atom': + + return _get_inner_bond_index_from_atom(module, item, indices) + + elif function_name == 'get_inner_bonded_atoms_from_atom': + + return _get_inner_bonded_atoms_from_atom(module, item, indices) + + elif function_name == 'get_n_bonds_from_atom': + + return _get_n_bonds_from_atom(module, item, indices) + + elif function_name == 'get_n_inner_bonds_from_atom': + + return _get_n_inner_bonds_from_atom(module, item, indices) + + else: + + raise NotImplementedError + + +# n elements + + +def _get_n_elements(module, element, item, indices): + + if is_all(indices): + aux_get = getattr(module, f'get_n_{_singular_element_to_plural[element]}_from_system') + output = aux_get(item) + else: + output = indices.shape[0] + + return output + + +def _get_n_inf_from_element(module, involved_element, base_element, item, indices): + + aux_get = getattr(module, f'get_{involved_element}_index_from_{base_element}') + output = aux_get(item, indices) + output = [ii.shape[0] for ii in output] + + return output + + +def _get_n_sup_from_element(module, involved_element, base_element, item, indices): + + if is_all(indices): + aux_get = getattr(module, f'get_n_{_singular_element_to_plural[involved_element]}_from_system') + output = aux_get(item) + else: + aux_get = getattr(module, f'get_{involved_element}_index_from_{base_element}') + output = aux_get(item, indices=indices) + output = np.unique(output).shape[0] + + return output + + +# n index + +def _get_index_from_element(module, element, item, indices): + + if is_all(indices): + aux_get = getattr(module, f'get_n_{_singular_element_to_plural[element]}_from_system') + n_aux = aux_get(item) + output = np.arange(n_aux, dtype=int) + else: + output = np.array(indices, dtype=int) + + return output.tolist() + + +def _get_inf_index_from_element(module, involved_element, base_element, item, indices): + + from molsysmt.config import large_list_length + + aux_get = getattr(module, f'get_{base_element}_index_from_{involved_element}') + target_index = aux_get(item) + + if len(target_index) > large_list_length: + + serie = pd.Series(target_index) + groups_serie = serie.groupby(serie).apply(lambda x: x.index.tolist()) + if is_all(indices): + output = [ii for ii in groups_serie] + else: + output = [groups_serie[ii] for ii in indices] + + else: + + indice_dict = {} + + for idx, num in enumerate(target_index): + try: + indice_dict[num].append(idx) + except KeyError: + indice_dict[num] = [idx] + + if is_all(indices): + output = [indice_dict[ii] for ii in indice_dict.keys()] + else: + output = [indice_dict[ii] for ii in indices] + + return output + + +def _get_sup_index_from_element(module, involved_element, base_element, item, indices): + + get_1 = getattr(module, f'get_atom_index_from_{base_element}') + get_2 = getattr(module, f'get_{involved_element}_index_from_atom') + + atom_index_from_target = get_1(item, indices=indices) + first_atom_index_from_target = np.array([ii[0] for ii in atom_index_from_target]) + output = get_2(item, indices=first_atom_index_from_target) + + del atom_index_from_target, first_atom_index_from_target + + return output + + +# attrs + + +def _get_inf_attr_from_element(module, involved_element, attribute, base_element, item, indices): + + get_1 = getattr(module, f'get_{involved_element}_index_from_{base_element}') + target_indices = get_1(item, indices=indices) + get_2 = getattr(module, f'get_{involved_element}_{attribute}_from_{involved_element}') + + aux_unique_indices, aux_indices = np.unique(np.concatenate(target_indices), return_inverse=True) + aux_vals = get_2(item, indices=aux_unique_indices) + aux_output = np.array(aux_vals)[aux_indices] + output = [] + ii = 0 + for aux in target_indices: + jj = ii+len(aux) + output.append(aux_output[ii:jj].tolist()) + ii = jj + + del aux_unique_indices, aux_vals, aux_output, target_indices + + return output + + +def _get_sup_attr_from_element(module, involved_element, attribute, base_element, item, indices): + + get_1 = getattr(module, f'get_{involved_element}_index_from_{base_element}') + get_2 = getattr(module, f'get_{involved_element}_{attribute}_from_{involved_element}') + + aux_indices = get_1(item, indices=indices) + aux_unique_indices, aux_new_indices = np.unique(aux_indices, return_inverse=True) + aux_vals = get_2(item, indices=aux_unique_indices) + output = np.array(aux_vals)[aux_new_indices] + + del aux_indices, aux_unique_indices, aux_vals, aux_new_indices + + return output.tolist() + + +# n group or molecule types + + +def _get_n_group_type_from_element(module, group_type, element, item, indices): + + get_1 = getattr(module, f'get_group_index_from_{element}') + get_2 = getattr(module, 'get_group_type_from_group') + + group_indices = get_1(item, indices=indices) + group_indices = np.unique(group_indices) + group_types = get_2(item, indices=group_indices) + output = (np.array(group_types) == group_type).sum() + + return output + + +def _get_n_group_type_from_system(module, group_type, item): + + get_1 = getattr(module, 'get_group_type_from_group') + + group_types = get_1(item) + output = (np.array(group_types) == group_type).sum() + + return output + + +def _get_n_molecule_type_from_element(module, molecule_type, element, item, indices): + + get_1 = getattr(module, f'get_molecule_index_from_{element}') + get_2 = getattr(module, 'get_molecule_type_from_molecule') + + molecule_indices = get_1(item, indices=indices) + molecule_indices = np.unique(molecule_indices) + molecule_types = get_2(item, indices=molecule_indices) + output = (np.array(molecule_types) == molecule_type).sum() + + return output + + +def _get_n_molecule_type_from_system(module, molecule_type, item): + + get_1 = getattr(module, 'get_molecule_type_from_molecule') + + molecule_types = get_1(item) + output = (np.array(molecule_types) == molecule_type).sum() + + return output + + +# bonds + +def _get_bond_index_from_atom(module, item, indices): + + aux_get = getattr(module, 'get_bonded_atoms_from_bond') + + output = None + + G = Graph() + edges = aux_get(item) + n_bonds = edges.shape[0] + edge_indices = np.array([{'index': ii} for ii in range(n_bonds)]).reshape([n_bonds, 1]) + G.add_edges_from(np.hstack([edges, edge_indices])) + + if is_all(indices): + + aux_get = getattr(module, 'get_atom_index_from_atom') + indices = aux_get(item) + + output = [] + + for ii in indices: + if ii in G: + output.append(np.array([n['index'] for n in G[ii].values()])) + else: + output.append(np.array([])) + + output = np.array(output, dtype=object) + + del G, edges, edge_indices + + return output + + +def _get_bonded_atoms_from_atom(module, item, indices): + + output = None + + aux_get_1 = getattr(module, 'get_bonded_atoms_from_bond') + aux_get_2 = getattr(module, 'get_atom_index_from_atom') + + G = Graph() + edges = aux_get_1(item) + G.add_edges_from(edges) + + if is_all(indices): + + indices = aux_get_2(item) + + output = [] + + for ii in indices: + if ii in G: + output.append(np.array([n for n in G[ii]])) + else: + output.append(np.array([])) + + output = np.array(output, dtype=object) + + for ii in range(output.shape[0]): + output[ii] = np.sort(output[ii]) + + del G, edges + + return output + + +def _get_inner_bond_index_from_atom(module, item, indices): + + raise NotImplementedError + + +def _get_inner_bonded_atoms_from_atom(module, item, indices): + + aux_get_1 = getattr(module, 'get_bonded_atoms_from_bond') + aux_get_2 = getattr(module, 'get_inner_bond_index_from_atom') + + if is_all(indices): + + output = aux_get_1(item) + + else: + + bond_indices = aux_get_2(item, indices=indices) + output = aux_get_1(item, indices=bond_indices) + del bond_indices + + output = output[np.lexsort((output[:, 1], output[:, 0]))] + + return output + + +def _get_n_bonds_from_atom(module, item, indices): + + aux_get = getattr(module, 'get_bonded_atoms_from_bond') + + bond_indices = aux_get(item, indices) + output = len(bond_indices) + del bond_indices + + return output + + +def _get_n_inner_bonds_from_atom(module, item, indices): + + aux_get = getattr(module, 'get_inner_bonded_atoms_from_bond') + + bond_indices = aux_get(item, indices) + output = len(bond_indices) + del bond_indices + + return output diff --git a/molsysmt/basic/select.py b/molsysmt/basic/select.py index 6a48c5517..a7880d481 100644 --- a/molsysmt/basic/select.py +++ b/molsysmt/basic/select.py @@ -2,13 +2,13 @@ from molsysmt._private.digestion import digest import numpy as np from molsysmt._private.variables import is_all, is_iterable_of_iterables -from molsysmt.element import _element_singular_to_plural +from molsysmt.element import _singular_element_to_plural from .selector import _dict_select, _dict_indices_to_selection @digest() def select(molecular_system, selection='all', structure_indices='all', element='atom', - mask=None, syntax='MolSysMT', to_syntax=None): + mask=None, syntax='MolSysMT', to_syntax=None): """ Selecting elements in a molecular system @@ -112,20 +112,20 @@ def select(molecular_system, selection='all', structure_indices='all', element=' """ - from molsysmt.basic import get, where_is_attribute + from molsysmt.basic import where_is_attribute from molsysmt.form import _dict_modules if is_all(selection): - attribute = 'n_'+_element_singular_to_plural[element] + attribute = 'n_'+_singular_element_to_plural[element] aux_item, aux_form = where_is_attribute(molecular_system, attribute) n_elements = getattr(_dict_modules[aux_form], f'get_{attribute}_from_system')(aux_item) - return np.arange(n_elements, dtype='int64') + return np.arange(n_elements, dtype='int64').tolist() elif isinstance(selection, (int, np.int64, np.int32)): - return np.array([selection]) + return [selection] elif selection is None: @@ -135,7 +135,7 @@ def select(molecular_system, selection='all', structure_indices='all', element=' if all([isinstance(ii, (int, np.int32, np.int64)) for ii in selection]): - return np.array(selection) + return list(selection) else: @@ -144,7 +144,7 @@ def select(molecular_system, selection='all', structure_indices='all', element=' for tmp_selection in selection: tmp_indices = select(molecular_system, selection=tmp_selection, - structure_indices=structure_indices, element=element, syntax=syntax) + structure_indices=structure_indices, element=element, syntax=syntax) output.append(tmp_indices) @@ -160,7 +160,7 @@ def select(molecular_system, selection='all', structure_indices='all', element=' raise NotSupportedSyntaxError() - if element=='atom': + if element == 'atom': output_indices = atom_indices @@ -172,17 +172,18 @@ def select(molecular_system, selection='all', structure_indices='all', element=' aux_item, aux_form = where_is_attribute(molecular_system, element+'_index') for aux_atom_indices in atom_indices: - temp_output_indices = getattr(_dict_modules[aux_form], f'get_{element}_index_from_atom')(aux_item, indices=aux_atom_indices) + temp_output_indices = getattr(_dict_modules[aux_form], + f'get_{element}_index_from_atom')(aux_item, indices=aux_atom_indices) output_indices.append(np.unique(temp_output_indices)) - else: - aux_item, aux_form = where_is_attribute(molecular_system, element+'_index') - output_indices = getattr(_dict_modules[aux_form], f'get_{element}_index_from_atom')(aux_item, indices=atom_indices) - output_indices = np.unique(output_indices) + aux_item, aux_form = where_is_attribute(molecular_system, element+'_index') + output_indices = getattr(_dict_modules[aux_form], f'get_{element}_index_from_atom')(aux_item, + indices=atom_indices) + output_indices = np.unique(output_indices) - elif element=='bond': + elif element == 'bond': aux_item, aux_form = where_is_attribute(molecular_system, 'inner_bond_index') output_indices = _dict_modules[aux_form].get_inner_bond_index_from_atom(aux_item, indices=atom_indices) @@ -192,7 +193,7 @@ def select(molecular_system, selection='all', structure_indices='all', element=' raise NotImplementedMethodError() if is_all(mask): - mask=None + mask = None if mask is not None: if isinstance(mask, str): @@ -210,6 +211,4 @@ def select(molecular_system, selection='all', structure_indices='all', element=' else: raise NotSupportedSyntaxError() - return output - diff --git a/molsysmt/basic/selector/__init__.py b/molsysmt/basic/selector/__init__.py index 3ef2b48e1..832a5cbb6 100644 --- a/molsysmt/basic/selector/__init__.py +++ b/molsysmt/basic/selector/__init__.py @@ -1,12 +1,14 @@ -from . import native +from . import molsysmt +from . import molsysmt_new from . import mdtraj from . import amber from . import nglview from . import mdanalysis - +## Selection Syntaxes _dict_select = { - 'MolSysMT': native.select, + 'MolSysMT': molsysmt.select, + 'MolSysMT_NEW': molsysmt_new.select, 'MDTraj': mdtraj.select, 'Amber': amber.select, 'NGLView': nglview.select, diff --git a/molsysmt/basic/selector/native.py b/molsysmt/basic/selector/molsysmt.py similarity index 95% rename from molsysmt/basic/selector/native.py rename to molsysmt/basic/selector/molsysmt.py index 702a8fd5a..38603ce69 100644 --- a/molsysmt/basic/selector/native.py +++ b/molsysmt/basic/selector/molsysmt.py @@ -1,9 +1,7 @@ -from molsysmt._private.exceptions import NotImplementedMethodError, NotSupportedSyntaxError -from molsysmt._private.digestion import digest import numpy as np -from molsysmt._private.variables import is_all, is_iterable_of_iterables +from molsysmt._private.variables import is_all from molsysmt._private.strings import get_parenthesis -from molsysmt.element import _element_plural_to_singular, _element_index +from molsysmt.element import _plural_elements_to_singular, _element_index from re import findall from inspect import stack, getargvalues @@ -205,8 +203,8 @@ def select_in_elements_of(molecular_system, selection): if 'in '+elements_2 in after: - element_1 = _element_plural_to_singular[elements_1] - element_2 = _element_plural_to_singular[elements_2] + element_1 = _plural_elements_to_singular[elements_1] + element_2 = _plural_elements_to_singular[elements_2] bbefore, aafter = after.split('in '+elements_2) @@ -246,7 +244,7 @@ def select_in_elements_of(molecular_system, selection): else: - element_1 = _element_plural_to_singular[elements_1] + element_1 = _plural_elements_to_singular[elements_1] after = after.replace('of ', '') diff --git a/molsysmt/basic/selector/molsysmt_new.py b/molsysmt/basic/selector/molsysmt_new.py new file mode 100644 index 000000000..80fd7e49a --- /dev/null +++ b/molsysmt/basic/selector/molsysmt_new.py @@ -0,0 +1,442 @@ +import numpy as np +import pandas as pd +from molsysmt._private.variables import is_all +from molsysmt._private.strings import get_parenthesis +from molsysmt.element import _plural_elements_to_singular, _element_index +from re import findall +from inspect import stack, getargvalues + + +def select(molecular_system, selection='all', structure_indices='all'): + + if isinstance(selection, str): + + while selection_with_special_subsentences(selection): + + sub_selection = selection_with_special_subsentences(selection) + sub_atom_indices = select(molecular_system, sub_selection, structure_indices) + selection = selection.replace(sub_selection, 'atom_index==@sub_atom_indices') + + if _in_elements_of(selection): + + atom_indices = select_in_elements_of(molecular_system, selection) + + elif 'within' in selection: + atom_indices = select_within(molecular_system, selection, structure_indices) + + elif 'bonded to' in selection: + atom_indices = select_bonded_to(molecular_system, selection) + + else: + atom_indices = select_standard(molecular_system, selection) + + return atom_indices + + +def select_standard(item, selection): + + from molsysmt.basic import convert, get_form + from molsysmt.config import selection_shortcuts + + form_in = get_form(item) + + if form_in == 'molsysmt.TopologyNEW': + tmp_item = item + else: + tmp_item = convert(item, to_form='molsysmt.TopologyNEW') + + tmp_selection = selection + + if '@' in selection: + + var_names = _var_names_in_selection(selection) + + all_stack_frames = stack() + + counter = -1 + n_frames = len(all_stack_frames) + + no_wrapper_stack_frames = [ii for ii in all_stack_frames if ii[3] != 'wrapper'] + + for aux_stack in no_wrapper_stack_frames: + args, args_paramname, kwargs_paramname, values = getargvalues(aux_stack.frame) + if 'selection' in args: + selection_input = values['selection'] + aux_var_names = _var_names_in_selection(selection_input) + if all([ii in aux_var_names for ii in var_names]): + counter += 1 + else: + break + else: + break + + # print(counter) + # for ii in range(len(no_wrapper_stack_frames)): + # aaa = no_wrapper_stack_frames[ii] + # print(ii, aaa[3]) + # if 'selection' in getargvalues(aaa.frame)[3]: + # print('#####', getargvalues(aaa.frame)[3]['selection']) + # print('>>>', var_names[0] in aaa[0].f_locals) + # print('>>>', var_names[0] in aaa[0].f_globals) + + for var_name in var_names: + if var_name in no_wrapper_stack_frames[counter][0].f_locals: + var_value = no_wrapper_stack_frames[counter][0].f_locals[var_name] + elif var_name in no_wrapper_stack_frames[counter][0].f_globals: + var_value = no_wrapper_stack_frames[counter][0].f_globals[var_name] + elif var_name in no_wrapper_stack_frames[counter+1][0].f_locals: + var_value = no_wrapper_stack_frames[counter+1][0].f_locals[var_name] + elif var_name in no_wrapper_stack_frames[counter+1][0].f_globals: + var_value = no_wrapper_stack_frames[counter+1][0].f_globals[var_name] + else: + raise ValueError("The variable", var_name, "was not found by the selection tool.") + tmp_selection = tmp_selection.replace('@'+var_name, '@auxiliar_variable_'+var_name) + if type(var_value) in [np.ndarray]: + var_value = list(var_value) + locals()['auxiliar_variable_'+var_name]=var_value + + shortcuts = selection_shortcuts['MolSysMT'] + + for key in shortcuts: + if key in selection: + tmp_selection = tmp_selection.replace(key, shortcuts[key]) + + if is_all(tmp_selection): + + output = np.array(np.arange(tmp_item.atoms.shape[0])) + + else: + + atom_columns = [] + group_columns = [] + component_columns = [] + molecule_columns = [] + entity_columns = [] + chain_columns = [] + + for column in tmp_item.atoms.keys(): + if column in tmp_selection: + atom_columns.append(column) + + for column in tmp_item.groups.keys(): + if column in tmp_selection: + group_columns.append(column) + + for column in tmp_item.components.keys(): + if column in tmp_selection: + component_columns.append(column) + + for column in tmp_item.molecules.keys(): + if column in tmp_selection: + molecule_columns.append(column) + + for column in tmp_item.entities.keys(): + if column in tmp_selection: + entity_columns.append(column) + + for column in tmp_item.chains.keys(): + if column in tmp_selection: + chain_columns.append(column) + + if len(entity_columns): + if 'entity_index' not in molecule_columns: + molecule_columns.append('entity_index') + + if len(molecule_columns): + if 'molecule_index' not in component_columns: + component_columns.append('molecule_index') + + if len(component_columns): + if 'component_index' not in group_columns: + group_columns.append('component_index') + + if len(group_columns): + if 'group_index' not in atom_columns: + atom_columns.append('group_index') + + if len(chain_columns): + if 'chain_index' not in atom_columns: + atom_columns.append('chain_index') + + aux_df = None + + if len(entity_columns): + + aux_df = pd.merge(item.molecules[molecule_columns], item.entities[entity_columns], + left_on='entity_index', right_index=True) + + if len(molecule_columns): + + if aux_df is None: + + aux_df = pd.merge(item.components[component_columns], item.molecules[molecule_columns], + left_on='molecule_index', right_index=True) + + else: + + aux_df = pd.merge(item.components[component_columns], aux_df, + left_on='molecule_index', right_index=True) + + if len(component_columns): + + if aux_df is None: + + aux_df = pd.merge(item.groups[group_columns], item.components[component_columns], + left_on='component_index', right_index=True) + + else: + + aux_df = pd.merge(item.groups[group_columns], aux_df, + left_on='component_index', right_index=True) + + if len(group_columns): + + if aux_df is None: + + aux_df = pd.merge(item.atoms[atom_columns], item.groups[group_columns], + left_on='group_index', right_index=True) + + else: + + aux_df = pd.merge(item.atoms[atom_columns], aux_df, + left_on='group_index', right_index=True) + + else: + + aux_df = item.atoms[atom_columns] + + if len(chain_columns): + + aux_df = pd.merge(aux_df, item.chains[chain_columns], + left_on='chain_index', right_index=True) + + output = aux_df.query(tmp_selection).index.to_list() + + del aux_df + + return output + + +def select_within(molecular_system, selection, structure_indices): + + from molsysmt.structure.get_contacts import get_contacts + + not_within = False + + if "not within " in selection: + selection_1, tmp_selection = selection.split(" not within ") + not_within = True + else: + selection_1, tmp_selection = selection.split(" within ") + + pbc = False + + if "with pbc " in tmp_selection: + pbc = True + tmp_selection = tmp_selection.replace("with pbc ", "") + elif "without pbc " in tmp_selection: + tmp_selection = tmp_selection.replace("without pbc ", "") + + threshold, selection_2 = tmp_selection.split(" of ") + + atom_indices_1 = select(molecular_system, selection_1) + atom_indices_2 = select(molecular_system, selection_2) + cmap = get_contacts(molecular_system, selection=atom_indices_1, selection_2=atom_indices_2, + structure_indices=structure_indices, threshold=threshold, pbc=pbc) + + if not_within: + output = atom_indices_1[np.where(cmap.all(axis=2)[0] == False)[0]] + else: + output = atom_indices_1[np.where(cmap.any(axis=2)[0] == True)[0]] + + return output + + +def select_bonded_to(molecular_system, selection): + + from molsysmt.basic import get + + not_bonded = False + + if "not bonded to" in selection: + selection_1, selection_2 = selection.split(" not bonded to") + not_bonded = True + else: + selection_1, selection_2 = selection.split(" bonded to") + + atom_indices_1 = select(molecular_system, selection=selection_1) + atom_indices_2 = get(molecular_system, element='atom', selection=selection_2, bonded_atoms=True) + atom_indices_2 = np.unique(np.concatenate(atom_indices_2).ravel()) + + if not_bonded: + output = np.setdiff1d(atom_indices_1, atom_indices_2, assume_unique=True) + else: + output = np.intersect1d(atom_indices_1, atom_indices_2, assume_unique=True) + + return output + + +_aux_dict_in_elements_in = { + 'groups': ['components', + 'molecules', + 'chains', + 'entities'], + 'components': ['molecules', + 'chains', + 'entities'], + 'molecules': ['chains', + 'entities'], + 'chains': ['molecules', + 'entities'], + 'entities': [], + } + + +def select_in_elements_of(molecular_system, selection): + + from molsysmt.basic import get + + for elements_1, list_elements_2 in _aux_dict_in_elements_in.items(): + + if 'in '+elements_1 in selection: + + before, after = selection.split('in '+elements_1) + + before = before.strip() + after = after.strip() + + if _in_elements_of(after): + + for elements_2 in list_elements_2: + + if 'in '+elements_2 in after: + + element_1 = _plural_elements_to_singular[elements_1] + element_2 = _plural_elements_to_singular[elements_2] + + bbefore, aafter = after.split('in '+elements_2) + + bbefore = bbefore.strip() + aafter = aafter.strip() + + bbefore = bbefore.replace('of ', '') + aafter = aafter.replace('of ', '') + + if bbefore == '': + bbefore = 'all' + + if aafter == '': + aafter = 'all' + + kwarg = {_element_index[element_1]: True} + pre_output = get(molecular_system, element=element_2, selection=aafter, **kwarg) + mask = get(molecular_system, element=element_1, selection=bbefore, index=True) + output_2 = [np.intersect1d(ii, mask) for ii in pre_output] + output_2 = [ii for ii in output_2 if ii.shape[0] > 0] + + if before == '': + before = 'all' + + mask = select(molecular_system, selection=before) + + output = [] + + for aux_after in output_2: + + pre_output = get(molecular_system, element=element_1, selection=aux_after, atom_index=True) + aux_output = [np.intersect1d(ii, mask) for ii in pre_output] + aux_output = [ii for ii in aux_output if ii.shape[0] > 0] + output.append(aux_output) + + return output + + else: + + element_1 = _plural_elements_to_singular[elements_1] + + after = after.replace('of ', '') + + if before == '': + before = 'all' + + if after == '': + after = 'all' + + pre_output = get(molecular_system, element=element_1, selection=after, atom_index=True) + mask = select(molecular_system, selection=before) + output = [np.intersect1d(ii, mask) for ii in pre_output] + output = [ii for ii in output if ii.shape[0] > 0] + + return output + + raise NotImplementedError + + +def select_in_groups_of(molecular_system, selection): + + from molsysmt.basic import get + + before, after = selection.split('in groups of') + before = before.strip() + after = after.strip() + + if before == '' or is_all(before): + + output = get(molecular_system, element='group', selection=after, atom_index=True) + output = [ii for ii in output] + + else: + + pre_output = get(molecular_system, element='group', selection=after, atom_index=True) + mask = select(molecular_system, selection=before) + output = [np.intersect1d(ii, mask) for ii in pre_output] + output = [ii for ii in output if ii.shape[0] > 0] + + return output + + +def selection_with_special_subsentences(selection): + + output = None + parenthesis = get_parenthesis(selection) + for subselection in parenthesis: + if ('within ' in subselection) or ('bonded to ' in subselection): + output = subselection + break + + return output + + +def _var_names_in_selection(selection): + + var_names = [] + + if isinstance(selection, str): + + var_names = [ii[1:] for ii in findall(r"@[\w']+", selection)] + + elif isinstance(selection, (tuple, list)): + + for ii in selection: + + var_names += _var_names_in_selection(ii) + + return var_names + + +def _in_elements_of(selection): + + output = False + + if "in groups" in selection: + output = True + elif "in components" in selection: + output = True + elif "in chains" in selection: + output = True + elif "in molecules" in selection: + output = True + elif "in entities" in selection: + output = True + + return output diff --git a/molsysmt/config.py b/molsysmt/config.py index 9824f5ebe..105d93ed7 100644 --- a/molsysmt/config.py +++ b/molsysmt/config.py @@ -74,3 +74,6 @@ def set_default_standard_units(standards=['nm', 'ps', 'K', 'mole', 'amu', 'e', if _sphinx_is_working: _view_from_htmlfiles=True +# Optimization +large_list_length = 10000 + diff --git a/molsysmt/element/__init__.py b/molsysmt/element/__init__.py index 7bfc64450..fb10c14c5 100644 --- a/molsysmt/element/__init__.py +++ b/molsysmt/element/__init__.py @@ -1,3 +1,13 @@ +from . import atom as atom +from . import group as group +from . import component as component +from . import molecule as molecule +from . import chain as chain +from . import entity as entity + +from .is_element import is_element +from .is_composed_of import is_composed_of + _elements = [ 'atom', 'group', @@ -29,7 +39,7 @@ 'bond': 'bond_index' } -_element_plural_to_singular = { +_plural_elements_to_singular = { 'atoms': 'atom', 'groups': 'group', 'residue': 'group', @@ -41,7 +51,7 @@ 'bonds': 'bond', } -_element_singular_to_plural = { +_singular_element_to_plural = { 'atom': 'atoms', 'group': 'groups', 'component': 'components', @@ -51,11 +61,3 @@ 'bond': 'bonds', } - -from . import atom as atom -from . import group as group -from . import component as component -from . import molecule as molecule -from . import chain as chain -from . import entity as entity - diff --git a/molsysmt/element/component/__init__.py b/molsysmt/element/component/__init__.py index 9564b7420..ad4e8bd07 100644 --- a/molsysmt/element/component/__init__.py +++ b/molsysmt/element/component/__init__.py @@ -15,3 +15,38 @@ from .get_component_type_from_group_names import get_component_type_from_group_names from .get_component_type_from_component import get_component_type_from_component from .get_n_components_from_system import get_n_components_from_system + +from .is_component_type import is_component_type + +_component_types = [ + 'water', + 'ion', + 'small molecule', + 'peptide', + 'protein', + 'dna', + 'rna', + 'lipid', + 'oligosaccharide' + ] + +_singular_component_type_to_plural = { + 'water': 'waters', + 'ion': 'ions', + 'small molecule': 'small molecules', + 'peptide': 'peptides', + 'protein': 'proteins', + 'lipid': 'lipids', + 'oligosaccharide': 'oligosaccharides', +} + +_plural_component_types_to_singular = { + 'waters': 'water', + 'ions': 'ion', + 'small molecules': 'small molecule', + 'peptides': 'peptide', + 'proteins': 'protein', + 'lipids': 'lipid', + 'oligosaccharides': 'oligosaccharide', +} + diff --git a/molsysmt/element/component/is_component_type.py b/molsysmt/element/component/is_component_type.py new file mode 100644 index 000000000..9bbd9a199 --- /dev/null +++ b/molsysmt/element/component/is_component_type.py @@ -0,0 +1,15 @@ +def is_component_type(component_type): + + from molsysmt.element.component import _component_types + from molsysmt.element.component import _plural_component_types_to_singular + + output = False + + if component_type in _component_types: + output = True + + elif component_type in _plural_component_types_to_singular: + output = True + + return output + diff --git a/molsysmt/element/group/__init__.py b/molsysmt/element/group/__init__.py index d85cfe2b7..4eb85f0df 100644 --- a/molsysmt/element/group/__init__.py +++ b/molsysmt/element/group/__init__.py @@ -6,5 +6,43 @@ from . import nucleotide from . import lipid from . import saccharide +from . import oligosaccharide +from .is_group_type import is_group_type from .get_group_type_from_group_name import get_group_type_from_group_name + +_group_types = [ + 'water', + 'ion', + 'small molecule', + 'amino acid', + 'terminal capping', + 'nucleotide', + 'lipid', + 'saccharide', + 'oligosaccharide' + ] + +_singular_group_type_to_plural = { + 'water': 'waters', + 'ion': 'ions', + 'small molecule': 'small molecules', + 'amino acid': 'amino acids', + 'terminal capping': 'terminal cappings', + 'nucleotide': 'nucleotides', + 'lipid': 'lipids', + 'saccharide': 'saccharides', + 'oligosaccharide': 'oligosaccharides', +} + +_plural_group_types_to_singular = { + 'waters': 'water', + 'ions': 'ion', + 'small molecules': 'small molecule', + 'amino acids': 'amino acid', + 'terminal cappings': 'terminal capping', + 'nucleotides': 'nucleotide', + 'lipids': 'lipid', + 'saccharides': 'saccharide', + 'oligosaccharides': 'oligosaccharide', +} diff --git a/molsysmt/element/group/is_group_type.py b/molsysmt/element/group/is_group_type.py new file mode 100644 index 000000000..09555f6ae --- /dev/null +++ b/molsysmt/element/group/is_group_type.py @@ -0,0 +1,15 @@ +def is_group_type(group_type): + + from molsysmt.element.group import _group_types + from molsysmt.element.group import _plural_group_types_to_singular + + output = False + + if group_type in _group_types: + output = True + + elif group_type in _plural_group_types_to_singular: + output = True + + return output + diff --git a/molsysmt/element/group/oligosaccharide/__init__.py b/molsysmt/element/group/oligosaccharide/__init__.py new file mode 100644 index 000000000..dd098ff53 --- /dev/null +++ b/molsysmt/element/group/oligosaccharide/__init__.py @@ -0,0 +1,2 @@ +from .oligosaccharide_names import oligosaccharide_names +from .is_oligosaccharide import is_oligosaccharide diff --git a/molsysmt/element/group/oligosaccharide/is_oligosaccharide.py b/molsysmt/element/group/oligosaccharide/is_oligosaccharide.py new file mode 100644 index 000000000..796011aef --- /dev/null +++ b/molsysmt/element/group/oligosaccharide/is_oligosaccharide.py @@ -0,0 +1,6 @@ +from .oligosaccharide_names import oligosaccharide_names + +def is_oligosaccharide(name): + + return (name in oligosaccharide_names) + diff --git a/molsysmt/element/group/oligosaccharide/oligosaccharide_names.py b/molsysmt/element/group/oligosaccharide/oligosaccharide_names.py new file mode 100644 index 000000000..164679033 --- /dev/null +++ b/molsysmt/element/group/oligosaccharide/oligosaccharide_names.py @@ -0,0 +1,3 @@ +oligosaccharide_names = [ +] + diff --git a/molsysmt/element/is_composed_of.py b/molsysmt/element/is_composed_of.py new file mode 100644 index 000000000..d829b5f75 --- /dev/null +++ b/molsysmt/element/is_composed_of.py @@ -0,0 +1,36 @@ +def is_composed_of(element_1, element_2): + + from molsysmt.element import _plural_elements_to_singular + + if element_1 in _plural_elements_to_singular: + element_1 = _plural_elements_to_singular[element_1] + + if element_2 in _plural_elements_to_singular: + element_2 = _plural_elements_to_singular[element_2] + + if element_1 == 'system': + if element_2 in ['atom', 'group', 'component', 'molecule', 'entity', 'bond', 'chain']: + return True + + elif element_1 == 'chain': + if element_2 in ['atom', 'group', 'component', 'molecule', 'entity']: + return True + + elif element_1 == 'entity': + if element_2 in ['atom', 'group', 'component', 'molecule']: + return True + + elif element_1 == 'molecule': + if element_2 in ['atom', 'group', 'component']: + return True + + elif element_1 == 'component': + if element_2 in ['atom', 'group']: + return True + + elif element_1 == 'group': + if element_2 == 'atom': + return True + + return False + diff --git a/molsysmt/element/is_element.py b/molsysmt/element/is_element.py new file mode 100644 index 000000000..2a8c35761 --- /dev/null +++ b/molsysmt/element/is_element.py @@ -0,0 +1,14 @@ +def is_element(element): + + from molsysmt.element import _elements, _plural_elements_to_singular + + output = False + + if element in _plural_elements_to_singular: + output = True + + elif element in _elements: + output = True + + return output + diff --git a/molsysmt/element/molecule/__init__.py b/molsysmt/element/molecule/__init__.py index 35211088f..0e3af33f3 100644 --- a/molsysmt/element/molecule/__init__.py +++ b/molsysmt/element/molecule/__init__.py @@ -16,3 +16,42 @@ from .get_molecule_type_from_sequence import get_molecule_type_from_sequence from .get_n_molecules_from_system import get_n_molecules_from_system +from .is_molecule_type import is_molecule_type + +_molecule_types = [ + 'water', + 'ion', + 'small molecule', + 'peptide', + 'protein', + 'dna', + 'rna', + 'lipid', + 'oligosaccharide' + ] + +_singular_molecule_type_to_plural = { + 'water': 'waters', + 'ion': 'ions', + 'small molecule': 'small molecules', + 'peptide': 'peptides', + 'protein': 'protein', + 'dna': 'dnas', + 'rna': 'rnas', + 'lipid': 'lipids', + 'oligosaccharide': 'oligosaccharides', +} + +_plural_molecule_types_to_singular = { + 'waters': 'water', + 'ions': 'ion', + 'small molecules': 'small molecule', + 'peptides': 'peptide', + 'proteins': 'protein', + 'dnas': 'dna', + 'rnas': 'rna', + 'lipids': 'lipid', + 'oligosaccharides': 'oligosaccharide', +} + + diff --git a/molsysmt/element/molecule/is_molecule_type.py b/molsysmt/element/molecule/is_molecule_type.py new file mode 100644 index 000000000..f5afddf87 --- /dev/null +++ b/molsysmt/element/molecule/is_molecule_type.py @@ -0,0 +1,15 @@ +def is_molecule_type(molecule_type): + + from molsysmt.element.molecule import _molecule_types + from molsysmt.element.molecule import _plural_molecule_types_to_singular + + output = False + + if molecule_type in _molecule_types: + output = True + + elif molecule_type in _plural_molecule_types_to_singular: + output = True + + return output + diff --git a/molsysmt/form/molsysmt_H5MSMFileHandler/get.py b/molsysmt/form/molsysmt_H5MSMFileHandler/get.py index e561c8f42..be4b9134d 100644 --- a/molsysmt/form/molsysmt_H5MSMFileHandler/get.py +++ b/molsysmt/form/molsysmt_H5MSMFileHandler/get.py @@ -86,30 +86,12 @@ def get_entity_index_from_atom(item, indices='all'): return output -@digest(form=form) -def get_inner_bonded_atoms_from_atom(item, indices='all'): - - if is_all(indices): - - output = get_bonded_atoms_from_bond(item, indices='all') - - else: - - bond_indices = get_inner_bond_index_from_atom (item, indices=indices) - output = get_bonded_atoms_from_bond(item, indices=bond_indices) - del(bond_indices) - - output = output[np.lexsort((output[:, 1], output[:, 0]))] - return(output) @digest(form=form) -def get_n_inner_bonds_from_atom(item, indices='all'): +def get_inner_bond_index_from_atom(item, indices='all'): - bond_indices = get_inner_bond_index_from_atom(item, indices=indices) - output = bond_indices.shape[0] - del(bond_indices) - return(output) + raise NotImplementedError @digest(form=form) def get_coordinates_from_atom(item, indices='all', structure_indices='all'): @@ -516,7 +498,7 @@ def get_bonded_atoms_from_bond(item, indices='all'): else: atom1_index = item.file['topology']['bonds']['atom1_index'][indices].astype('int64') - atom2_index = item.file['topology']['bonds']['atomw_index'][indices].astype('int64') + atom2_index = item.file['topology']['bonds']['atom2_index'][indices].astype('int64') tmp_out = np.array([atom1_index, atom2_index]) tmp_out = np.sort(tmp_out) diff --git a/molsysmt/form/molsysmt_H5MSMFileHandler/to_molsysmt_TopologyNEW.py b/molsysmt/form/molsysmt_H5MSMFileHandler/to_molsysmt_TopologyNEW.py index 632679be4..871b87029 100644 --- a/molsysmt/form/molsysmt_H5MSMFileHandler/to_molsysmt_TopologyNEW.py +++ b/molsysmt/form/molsysmt_H5MSMFileHandler/to_molsysmt_TopologyNEW.py @@ -1,4 +1,5 @@ from molsysmt._private.digestion import digest +from molsysmt._private.variables import is_all import pandas as pd import numpy as np @@ -11,55 +12,131 @@ def to_molsysmt_TopologyNEW(item, atom_indices='all'): tmp_item = TopologyNEW() - # Atoms + if is_all(atom_indices): - n_atoms = topology_ds['atoms'].attrs['n_atoms'] + # Atoms - tmp_item.atoms['atom_id']=topology_ds['atoms']['id'][:] - tmp_item.atoms['atom_type']=topology_ds['atoms']['type'].asstr()[:] - tmp_item.atoms['atom_name']=topology_ds['atoms']['name'].asstr()[:] - tmp_item.atoms['group_index']=topology_ds['atoms']['group_index'][:] - tmp_item.atoms['chain_index']=topology_ds['atoms']['chain_index'][:] + tmp_item.atoms['atom_id']=topology_ds['atoms']['id'][:].astype('int64') + tmp_item.atoms['atom_type']=topology_ds['atoms']['type'].asstr()[:] + tmp_item.atoms['atom_name']=topology_ds['atoms']['name'].asstr()[:] + tmp_item.atoms['group_index']=topology_ds['atoms']['group_index'][:].astype('int64') + tmp_item.atoms['chain_index']=topology_ds['atoms']['chain_index'][:].astype('int64') - # Groups + # Groups - tmp_item.groups['group_id']=topology_ds['groups']['id'][:] - tmp_item.groups['group_name']=topology_ds['groups']['name'].asstr()[:] - tmp_item.groups['group_type']=topology_ds['groups']['type'].asstr()[:] - tmp_item.groups['component_index']=topology_ds['groups']['component_index'][:] + tmp_item.groups['group_id']=topology_ds['groups']['id'][:].astype('int64') + tmp_item.groups['group_name']=topology_ds['groups']['name'].asstr()[:] + tmp_item.groups['group_type']=topology_ds['groups']['type'].asstr()[:] + tmp_item.groups['component_index']=topology_ds['groups']['component_index'][:].astype('int64') - # Components + # Components - tmp_item.components['component_id']=topology_ds['components']['id'][:] - tmp_item.components['component_name']=topology_ds['components']['name'].asstr()[:] - tmp_item.components['component_type']=topology_ds['components']['type'].asstr()[:] - tmp_item.components['molecule_index']=topology_ds['components']['molecule_index'][:] + tmp_item.components['component_id']=topology_ds['components']['id'][:].astype('int64') + tmp_item.components['component_name']=topology_ds['components']['name'].asstr()[:] + tmp_item.components['component_type']=topology_ds['components']['type'].asstr()[:] + tmp_item.components['molecule_index']=topology_ds['components']['molecule_index'][:].astype('int64') - # Molecules + # Molecules - tmp_item.molecules['molecule_id']=topology_ds['molecules']['id'][:] - tmp_item.molecules['molecule_name']=topology_ds['molecules']['name'].asstr()[:] - tmp_item.molecules['molecule_type']=topology_ds['molecules']['type'].asstr()[:] - tmp_item.molecules['entity_index']=topology_ds['molecules']['entity_index'][:] + tmp_item.molecules['molecule_id']=topology_ds['molecules']['id'][:].astype('int64') + tmp_item.molecules['molecule_name']=topology_ds['molecules']['name'].asstr()[:] + tmp_item.molecules['molecule_type']=topology_ds['molecules']['type'].asstr()[:] + tmp_item.molecules['entity_index']=topology_ds['molecules']['entity_index'][:].astype('int64') - # Entities + # Entities - tmp_item.entities['entity_id']=topology_ds['entities']['id'][:] - tmp_item.entities['entity_name']=topology_ds['entities']['name'].asstr()[:] - tmp_item.entities['entity_type']=topology_ds['entities']['type'].asstr()[:] + tmp_item.entities['entity_id']=topology_ds['entities']['id'][:].astype('int64') + tmp_item.entities['entity_name']=topology_ds['entities']['name'].asstr()[:] + tmp_item.entities['entity_type']=topology_ds['entities']['type'].asstr()[:] - # Entities + # Chains - tmp_item.chains['chain_id']=topology_ds['chains']['id'][:] - tmp_item.chains['chain_name']=topology_ds['chains']['name'].asstr()[:] - tmp_item.chains['chain_type']=topology_ds['chains']['type'].asstr()[:] + tmp_item.chains['chain_id']=topology_ds['chains']['id'][:].astype('int64') + tmp_item.chains['chain_name']=topology_ds['chains']['name'].asstr()[:] + tmp_item.chains['chain_type']=topology_ds['chains']['type'].asstr()[:] - # Bonds + # Bonds - tmp_item.bonds['atom1_index']=topology_ds['bonds']['atom1_index'][:] - tmp_item.bonds['atom2_index']=topology_ds['bonds']['atom2_index'][:] - tmp_item.bonds['type']=topology_ds['bonds']['type'].asstr()[:] - tmp_item.bonds['order']=topology_ds['bonds']['order'].asstr()[:] + tmp_item.bonds['atom1_index']=topology_ds['bonds']['atom1_index'][:].astype('int64') + tmp_item.bonds['atom2_index']=topology_ds['bonds']['atom2_index'][:].astype('int64') + tmp_item.bonds['type']=topology_ds['bonds']['type'].asstr()[:] + tmp_item.bonds['order']=topology_ds['bonds']['order'].asstr()[:] + + else: + + # Atoms + + tmp_item.atoms['atom_id'] = topology_ds['atoms']['id'][atom_indices].astype('int64') + tmp_item.atoms['atom_type'] = topology_ds['atoms']['type'].asstr()[atom_indices] + tmp_item.atoms['atom_name'] = topology_ds['atoms']['name'].asstr()[atom_indices] + + group_indices, aux = np.unique(topology_ds['atoms']['group_index'][atom_indices].astype('int64'), + return_inverse=True) + tmp_item.atoms['group_index'] = aux + + chain_indices, aux = np.unique(topology_ds['atoms']['chain_index'][atom_indices].astype('int64'), + return_inverse=True) + tmp_item.atoms['chain_index']=aux + + + # Groups + + tmp_item.groups['group_id']=topology_ds['groups']['id'][group_indices].astype('int64') + tmp_item.groups['group_name']=topology_ds['groups']['name'].asstr()[group_indices] + tmp_item.groups['group_type']=topology_ds['groups']['type'].asstr()[group_indices] + + component_indices, aux = np.unique(topology_ds['groups']['component_index'][group_indices].astype('int64'), + return_inverse=True) + tmp_item.atoms['component_index']=aux + + # Components + + tmp_item.components['component_id']=topology_ds['components']['id'][component_indices].astype('int64') + tmp_item.components['component_name']=topology_ds['components']['name'].asstr()[component_indices] + tmp_item.components['component_type']=topology_ds['components']['type'].asstr()[component_indices] + + molecule_indices, aux = np.unique(topology_ds['components']['molecule_index'][component_indices].astype('int64'), + return_inverse=True) + tmp_item.components['molecule_index']=aux + + # Molecules + + tmp_item.molecules['molecule_id']=topology_ds['molecules']['id'][molecule_indices].astype('int64') + tmp_item.molecules['molecule_name']=topology_ds['molecules']['name'].asstr()[molecule_indices] + tmp_item.molecules['molecule_type']=topology_ds['molecules']['type'].asstr()[molecule_indices] + + entity_indices, aux = np.unique(topology_ds['molecules']['entity_index'][molecule_indices].astype('int64'), + return_inverse=True) + tmp_item.molecules['entity_index']=aux + + # Entities + + tmp_item.entities['entity_id']=topology_ds['entities']['id'][entity_indices].astype('int64') + tmp_item.entities['entity_name']=topology_ds['entities']['name'].asstr()[entity_indices] + tmp_item.entities['entity_type']=topology_ds['entities']['type'].asstr()[entity_indices] + + # Entities + + tmp_item.chains['chain_id']=topology_ds['chains']['id'][chain_indices].astype('int64') + tmp_item.chains['chain_name']=topology_ds['chains']['name'].asstr()[chain_indices] + tmp_item.chains['chain_type']=topology_ds['chains']['type'].asstr()[chain_indices] + + # Bonds + + mask1 = np.in1d(topology_ds['bonds']['atom1_index'][:], atom_indices) + mask2 = np.in1d(topology_ds['bonds']['atom2_index'][:], atom_indices) + mask = mask1*mask2 + + tmp_item.bonds['atom1_index']=np.searchsorted(atom_indices, + topology_ds['bonds']['atom1_index'][mask].astype('int64'), + side='left') + tmp_item.bonds['atom2_index']=np.searchsorted(atom_indices, + topology_ds['bonds']['atom2_index'][mask].astype('int64'), + side='left') + tmp_item.bonds['type']=topology_ds['bonds']['type'].asstr()[mask] + tmp_item.bonds['order']=topology_ds['bonds']['order'].asstr()[mask] + + del(aux, mask1, mask2, mask) return tmp_item diff --git a/molsysmt/form/molsysmt_TopologyNEW/get.py b/molsysmt/form/molsysmt_TopologyNEW/get.py index e8f7c0fad..ec7b6d88f 100644 --- a/molsysmt/form/molsysmt_TopologyNEW/get.py +++ b/molsysmt/form/molsysmt_TopologyNEW/get.py @@ -1,1528 +1,2192 @@ -from molsysmt._private.exceptions import NotImplementedMethodError, NotWithThisFormError from molsysmt._private.digestion import digest from molsysmt._private.variables import is_all from molsysmt import pyunitwizard as puw import numpy as np -from networkx import Graph +from molsysmt._private.get import _auxiliary_getter +import types -form='molsysmt.TopologyNEW' +form = 'molsysmt.TopologyNEW' -## From atom -@digest(form=form) -def get_atom_index_from_atom(item, indices='all'): +####################################################################### +# To be customized for each form # +####################################################################### + +# From atom - raise NotImplementedError @digest(form=form) def get_atom_id_from_atom(item, indices='all'): - raise NotImplementedError + if is_all(indices): + output = item.atoms['atom_id'].to_list() + else: + output = item.atoms['atom_id'][indices].to_list() + + return output + @digest(form=form) def get_atom_name_from_atom(item, indices='all'): - raise NotImplementedError + if is_all(indices): + output = item.atoms['atom_name'].to_list() + else: + output = item.atoms['atom_name'][indices].to_list() + + return output + @digest(form=form) def get_atom_type_from_atom(item, indices='all'): - raise NotImplementedError + if is_all(indices): + output = item.atoms['atom_type'].to_list() + else: + output = item.atoms['atom_type'][indices].to_list() + + return output + @digest(form=form) def get_group_index_from_atom(item, indices='all'): - raise NotImplementedError + if is_all(indices): + output = item.atoms['group_index'].to_list() + else: + output = item.atoms['group_index'][indices].to_list() + + return output + @digest(form=form) -def get_group_id_from_atom(item, indices='all'): +def get_component_index_from_atom(item, indices='all'): + + group_indices = get_group_index_from_atom(item, indices=indices) + output = item.groups['component_index'][group_indices].to_list() + del group_indices + + return output - raise NotImplementedError @digest(form=form) -def get_group_name_from_atom(item, indices='all'): +def get_molecule_index_from_atom(item, indices='all'): + + component_indices = get_component_index_from_atom(item, indices=indices) + output = item.components['molecule_index'][component_indices].to_list() + del component_indices + + return output - raise NotImplementedError @digest(form=form) -def get_group_type_from_atom(item, indices='all'): +def get_entity_index_from_atom(item, indices='all'): + + molecule_indices = get_molecule_index_from_atom(item, indices=indices) + output = item.molecules['entity_index'][molecule_indices].to_list() + del molecule_indices + + return output - raise NotImplementedError @digest(form=form) -def get_component_index_from_atom(item, indices='all'): +def get_chain_index_from_atom(item, indices='all'): + + if is_all(indices): + output = item.atoms['chain_index'][:].to_numpy() + else: + output = item.atoms['chain_index'][indices].to_list() + + return output - raise NotImplementedError @digest(form=form) -def get_component_id_from_atom(item, indices='all'): +def get_occupancy_from_atom(item, indices='all'): + + tmp_indices = get_atom_index_from_atom(item, indices=indices) + output = item.atoms['occupancy'][tmp_indices].to_list() + return output - raise NotImplementedError @digest(form=form) -def get_component_name_from_atom(item, indices='all'): +def get_alternate_location_from_atom(item, indices='all'): + + tmp_indices = get_atom_index_from_atom(item, indices=indices) + output = item.atoms['alternate_location'][tmp_indices].to_list() + return output - raise NotImplementedError @digest(form=form) -def get_component_type_from_atom(item, indices='all'): +def get_b_factor_from_atom(item, indices='all'): + + tmp_indices = get_atom_index_from_atom(item, indices=indices) + output = item.atoms['b_factor'][tmp_indices].to_list() + unit = puw.get_standard_units(dimensionality={'[L]': 2}) + output = puw.quantity(output, unit, standardized=True) + return output - raise NotImplementedError @digest(form=form) -def get_chain_index_from_atom(item, indices='all'): +def get_formal_charge_from_atom(item, indices='all'): + + tmp_indices = get_atom_index_from_atom(item, indices=indices) + output = item.atoms['formal_charge'][tmp_indices].to_list() + unit = puw.get_standard_units(dimensionality={'[T]': 1, '[A]': 1}) + output = puw.quantity(output, unit, standardized=True) + return output - raise NotImplementedError @digest(form=form) -def get_chain_id_from_atom(item, indices='all'): +def get_partial_charge_from_atom(item, indices='all'): + + tmp_indices = get_atom_index_from_atom(item, indices=indices) + output = item.atoms['partial_charge'][tmp_indices].to_list() + unit = puw.get_standard_units(dimensionality={'[T]': 1, '[A]': 1}) + output = puw.quantity(output, unit, standardized=True) + return output + + +# From group - raise NotImplementedError @digest(form=form) -def get_chain_name_from_atom(item, indices='all'): +def get_group_id_from_group(item, indices='all'): + + if is_all(indices): + output = item.groups['group_id'].to_list() + else: + output = item.groups['group_id'][indices].to_list() + + return output - raise NotImplementedError @digest(form=form) -def get_chain_type_from_atom(item, indices='all'): +def get_group_name_from_group(item, indices='all'): + + if is_all(indices): + output = item.groups['group_name'].to_list() + else: + output = item.groups['group_name'][indices].to_list() + + return output - raise NotImplementedError @digest(form=form) -def get_molecule_index_from_atom(item, indices='all'): +def get_group_type_from_group(item, indices='all'): + + if is_all(indices): + output = item.groups['group_type'].to_list() + else: + output = item.groups['group_type'][indices].to_list() + + return output + + +# From component + + +@digest(form=form) +def get_component_id_from_component(item, indices='all'): + + if is_all(indices): + output = item.components['component_id'].to_list() + else: + output = item.components['component_id'][indices].to_list() + + return output + + +@digest(form=form) +def get_component_name_from_component(item, indices='all'): + + if is_all(indices): + output = item.components['component_name'].to_list() + else: + output = item.components['component_name'][indices].to_list() + + return output + + +@digest(form=form) +def get_component_type_from_component(item, indices='all'): + + if is_all(indices): + output = item.components['component_type'].to_list() + else: + output = item.components['component_type'][indices].to_list() + + return output + + +# From molecule + + +@digest(form=form) +def get_molecule_id_from_molecule(item, indices='all'): + + if is_all(indices): + output = item.molecules['molecule_id'].to_list() + else: + output = item.molecules['molecule_id'][indices].to_list() + + return output + + +@digest(form=form) +def get_molecule_name_from_molecule(item, indices='all'): + + if is_all(indices): + output = item.molecules['molecule_name'].to_list() + else: + output = item.molecules['molecule_name'][indices].to_list() + + return output + + +@digest(form=form) +def get_molecule_type_from_molecule(item, indices='all'): + + if is_all(indices): + output = item.molecules['molecule_type'].to_list() + else: + output = item.molecules['molecule_type'][indices].to_list() + + return output + + +# From entity + + +@digest(form=form) +def get_entity_id_from_entity(item, indices='all'): + + if is_all(indices): + output = item.entities['entity_id'].to_list() + else: + output = item.entities['entity_id'][indices].to_list() + + return output + + +@digest(form=form) +def get_entity_name_from_entity(item, indices='all'): + + if is_all(indices): + output = item.entities['entity_name'].to_list() + else: + output = item.entities['entity_name'][indices].to_list() + + return output + + +@digest(form=form) +def get_entity_type_from_entity(item, indices='all'): + + if is_all(indices): + output = item.entities['entity_name'].to_list() + else: + output = item.entities['entity_name'][indices].to_list() + + return output + + +# From chain + + +@digest(form=form) +def get_chain_id_from_chain(item, indices='all'): + + if is_all(indices): + output = item.chains['chain_id'].to_list() + else: + output = item.chains['chain_id'][indices].to_list() + + return output + + +@digest(form=form) +def get_chain_name_from_chain(item, indices='all'): + + if is_all(indices): + output = item.chains['chain_name'].to_list() + else: + output = item.chains['chain_name'][indices].to_list() + + return output + + +@digest(form=form) +def get_chain_type_from_chain(item, indices='all'): + + if is_all(indices): + output = item.chains['chain_type'].to_list() + else: + output = item.chains['chain_type'][indices].to_list() + + return output + + +# From bond + + +@digest(form=form) +def get_bond_order_from_bond(item, indices='all'): + + if is_all(indices): + output = item.bonds['order'].to_list() + else: + output = item.bonds['order'][indices].to_list() + + return output + + +@digest(form=form) +def get_bond_type_from_bond(item, indices='all'): + + if is_all(indices): + output = item.bonds['order'].to_list() + else: + output = item.bonds['order'][indices].to_list() + + return output + + +@digest(form=form) +def get_bonded_atoms_from_bond(item, indices='all'): + + if is_all(indices): + + atom1_index = item.bonds['atom1_index'].to_numpy() + atom2_index = item.bonds['atom2_index'].to_numpy() + + else: + + atom1_index = item.bonds['atom1_index'][indices].to_numpy() + atom2_index = item.bonds['atom2_index'][indices].to_numpy() + + tmp_out = np.array([atom1_index, atom2_index]) + tmp_out = np.sort(tmp_out) + + return tmp_out + + +# From system + + +@digest(form=form) +def get_n_atoms_from_system(item): + + return item.atoms.shape[0] + + +@digest(form=form) +def get_n_groups_from_system(item): + + return item.groups.shape[0] + + +@digest(form=form) +def get_n_components_from_system(item): + + return item.components.shape[0] + + +@digest(form=form) +def get_n_chains_from_system(item): + + return item.chains.shape[0] + + +@digest(form=form) +def get_n_molecules_from_system(item): + + return item.molecules.shape[0] + + +@digest(form=form) +def get_n_entities_from_system(item): + + return item.entities.shape[0] + + +@digest(form=form) +def get_n_bonds_from_system(item): + + return item.bonds.shape[0] + + +####################################################################### +# Assisted by the auxiliary getter function # +####################################################################### + + +# From atom + +@digest(form=form) +def get_atom_index_from_atom(item, indices='all'): + + return _auxiliary_getter(get_atom_index_from_atom, item, indices) + + +@digest(form=form) +def get_group_id_from_atom(item, indices='all'): + + return _auxiliary_getter(get_group_id_from_atom, item, indices) + + +@digest(form=form) +def get_group_name_from_atom(item, indices='all'): + + return _auxiliary_getter(get_group_name_from_atom, item, indices) + + +@digest(form=form) +def get_group_type_from_atom(item, indices='all'): + + return _auxiliary_getter(get_group_type_from_atom, item, indices) + + +@digest(form=form) +def get_component_id_from_atom(item, indices='all'): + + return _auxiliary_getter(get_component_id_from_atom, item, indices) + + +@digest(form=form) +def get_component_name_from_atom(item, indices='all'): + + return _auxiliary_getter(get_component_name_from_atom, item, indices) + + +@digest(form=form) +def get_component_type_from_atom(item, indices='all'): + + return _auxiliary_getter(get_component_type_from_atom, item, indices) - raise NotImplementedError @digest(form=form) def get_molecule_id_from_atom(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_molecule_id_from_atom, item, indices) + @digest(form=form) def get_molecule_name_from_atom(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_molecule_name_from_atom, item, indices) + @digest(form=form) def get_molecule_type_from_atom(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_molecule_type_from_atom, item, indices) -@digest(form=form) -def get_entity_index_from_atom(item, indices='all'): - - raise NotImplementedError @digest(form=form) def get_entity_id_from_atom(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_entity_id_from_atom, item, indices) + @digest(form=form) def get_entity_name_from_atom(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_entity_name_from_atom, item, indices) + @digest(form=form) def get_entity_type_from_atom(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_entity_type_from_atom, item, indices) + @digest(form=form) -def get_n_atoms_from_atom(item, indices='all'): +def get_chain_id_from_atom(item, indices='all'): + + return _auxiliary_getter(get_chain_id_from_atom, item, indices) - raise NotImplementedError @digest(form=form) -def get_n_groups_from_atom(item, indices='all'): +def get_chain_name_from_atom(item, indices='all'): + + return _auxiliary_getter(get_chain_name_from_atom, item, indices) - raise NotImplementedError @digest(form=form) -def get_n_components_from_atom(item, indices='all'): +def get_chain_type_from_atom(item, indices='all'): + + return _auxiliary_getter(get_chain_type_from_atom, item, indices) - raise NotImplementedError @digest(form=form) -def get_n_molecules_from_atom(item, indices='all'): +def get_bond_index_from_atom(item, indices='all'): + + return _auxiliary_getter(get_bond_index_from_atom, item, indices) - raise NotImplementedError @digest(form=form) -def get_n_chains_from_atom(item, indices='all'): +def get_bond_type_from_atom(item, indices='all'): raise NotImplementedError + @digest(form=form) -def get_n_entities_from_atom(item, indices='all'): +def get_bond_order_from_atom(item, indices='all'): raise NotImplementedError + @digest(form=form) def get_bonded_atoms_from_atom(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_bonded_atoms_from_atom, item, indices) + @digest(form=form) -def get_bond_index_from_atom(item, indices='all'): +def get_inner_bond_index_from_atom(item, indices='all'): + + output = None + + if is_all(indices): + output = get_bond_index_from_bond(item) + else: + output = item.bonds.query('atom1_index==@indices and atom2_index==@indices').index.to_numpy(dtype=int, + copy=True) + output = output.to_list() + + return output - raise NotImplementedError @digest(form=form) -def get_n_bonds_from_atom(item, indices='all'): +def get_inner_bonded_atoms_from_atom(item, indices='all'): + + return _auxiliary_getter(get_inner_bonded_atoms_from_atom, item, indices) - raise NotImplementedError @digest(form=form) -def get_inner_bond_index_from_atom(item, indices='all'): +def get_n_atoms_from_atom(item, indices='all'): + + return _auxiliary_getter(get_n_atoms_from_atom, item, indices) - raise NotImplementedError @digest(form=form) -def get_inner_bonded_atoms_from_atom(item, indices='all'): +def get_n_groups_from_atom(item, indices='all'): + + return _auxiliary_getter(get_n_groups_from_atom, item, indices) - raise NotImplementedError @digest(form=form) -def get_n_inner_bonds_from_atom(item, indices='all'): +def get_n_components_from_atom(item, indices='all'): + + return _auxiliary_getter(get_n_components_from_atom, item, indices) - raise NotImplementedError @digest(form=form) -def get_occupancy_from_atom(item, indices='all'): +def get_n_molecules_from_atom(item, indices='all'): + + return _auxiliary_getter(get_n_molecules_from_atom, item, indices) - raise NotImplementedError @digest(form=form) -def get_alternate_location_from_atom(item, indices='all'): +def get_n_chains_from_atom(item, indices='all'): + + return _auxiliary_getter(get_n_chains_from_atom, item, indices) - raise NotImplementedError @digest(form=form) -def get_b_factor_from_atom(item, indices='all'): +def get_n_entities_from_atom(item, indices='all'): + + return _auxiliary_getter(get_n_entities_from_atom, item, indices) - raise NotImplementedError @digest(form=form) -def get_formal_charge_from_atom(item, indices='all'): +def get_n_bonds_from_atom(item, indices='all'): + + return _auxiliary_getter(get_n_bonds_from_atom, item, indices) - raise NotImplementedError @digest(form=form) -def get_partial_charge_from_atom(item, indices='all'): +def get_n_inner_bonds_from_atom(item, indices='all'): + + return _auxiliary_getter(get_n_inner_bonds_from_atom, item, indices) - raise NotImplementedError @digest(form=form) def get_n_aminoacids_from_atom(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_n_aminoacids_from_atom, item, indices) + @digest(form=form) def get_n_nucleotides_from_atom(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_n_nucleotides_from_atom, item, indices) + @digest(form=form) def get_n_ions_from_atom(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_n_ions_from_atom, item, indices) + @digest(form=form) def get_n_waters_from_atom(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_n_waters_from_atom, item, indices) + @digest(form=form) def get_n_small_molecules_from_atom(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_n_small_molecules_from_atom, item, indices) + @digest(form=form) def get_n_peptides_from_atom(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_n_peptides_from_atom, item, indices) + @digest(form=form) def get_n_proteins_from_atom(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_n_proteins_from_atom, item, indices) + @digest(form=form) def get_n_dnas_from_atom(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_n_dnas_from_atom, item, indices) + @digest(form=form) def get_n_rnas_from_atom(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_n_rnas_from_atom, item, indices) + @digest(form=form) def get_n_lipids_from_atom(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_n_lipids_from_atom, item, indices) + @digest(form=form) def get_n_oligosaccharides_from_atom(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_n_oligosaccharides_from_atom, item, indices) + @digest(form=form) def get_n_saccharides_from_atom(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_n_saccharides_from_atom, item, indices) + +# From group -## group @digest(form=form) def get_atom_index_from_group(item, indices='all'): - raise NotImplementedError + aux = item.atoms.groupby('group_index') + + if is_all(indices): + output = [jj.tolist() for ii, jj in aux.groups.items()] + else: + output = [aux.groups[ii].tolist() for ii in indices] + + del aux + + return output + @digest(form=form) def get_atom_id_from_group(item, indices='all'): - raise NotImplementedError + aux = item.atoms.groupby('group_index')['atom_id'] + + if is_all(indices): + output = [jj.tolist() for ii, jj in aux] + else: + output = [aux.get_group(ii).tolist() for ii in indices] + + del aux + + return output + @digest(form=form) def get_atom_name_from_group(item, indices='all'): - raise NotImplementedError + aux = item.atoms.groupby('group_index')['atom_name'] -@digest(form=form) -def get_atom_type_from_group(item, indices='all'): + if is_all(indices): + output = [jj.tolist() for ii, jj in aux] + else: + output = [aux.get_group(ii).tolist() for ii in indices] - raise NotImplementedError + del aux -@digest(form=form) -def get_group_index_from_group(item, indices='all'): + return output - raise NotImplementedError @digest(form=form) -def get_group_id_from_group(item, indices='all'): +def get_atom_type_from_group(item, indices='all'): - raise NotImplementedError + aux = item.atoms.groupby('group_index')['atom_type'] -@digest(form=form) -def get_group_name_from_group(item, indices='all'): + if is_all(indices): + output = [jj.tolist() for ii, jj in aux] + else: + output = [aux.get_group(ii).tolist() for ii in indices] + + del aux + + return output - raise NotImplementedError @digest(form=form) -def get_group_type_from_group(item, indices='all'): +def get_group_index_from_group(item, indices='all'): + + return _auxiliary_getter(get_group_index_from_group, item, indices) - raise NotImplementedError @digest(form=form) def get_component_index_from_group(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_component_index_from_group, item, indices) + @digest(form=form) def get_component_id_from_group(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_component_id_from_group, item, indices) + @digest(form=form) def get_component_name_from_group(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_component_name_from_group, item, indices) + @digest(form=form) def get_component_type_from_group(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_component_type_from_group, item, indices) + @digest(form=form) def get_chain_index_from_group(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_chain_index_from_group, item, indices) + @digest(form=form) def get_chain_id_from_group(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_chain_id_from_group, item, indices) + @digest(form=form) def get_chain_name_from_group(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_chain_name_from_group, item, indices) + @digest(form=form) def get_chain_type_from_group(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_chain_type_from_group, item, indices) + @digest(form=form) def get_molecule_index_from_group(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_molecule_index_from_group, item, indices) + @digest(form=form) def get_molecule_id_from_group(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_molecule_id_from_group, item, indices) + @digest(form=form) def get_molecule_name_from_group(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_molecule_name_from_group, item, indices) + @digest(form=form) def get_molecule_type_from_group(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_molecule_type_from_group, item, indices) + @digest(form=form) def get_entity_index_from_group(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_entity_index_from_group, item, indices) + @digest(form=form) def get_entity_id_from_group(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_entity_id_from_group, item, indices) + @digest(form=form) def get_entity_name_from_group(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_entity_name_from_group, item, indices) + @digest(form=form) def get_entity_type_from_group(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_entity_type_from_group, item, indices) + @digest(form=form) def get_n_atoms_from_group(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_n_atoms_from_group, item, indices) + @digest(form=form) def get_n_groups_from_group(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_n_groups_from_group, item, indices) + @digest(form=form) def get_n_components_from_group(item, indices='all'): - raise NotImplementedError - -@digest(form=form) -def get_n_molecules_from_group(item, indices='all'): + return _auxiliary_getter(get_n_components_from_group, item, indices) - raise NotImplementedError @digest(form=form) -def get_n_chains_from_group(item, indices='all'): - - raise NotImplementedError +def get_n_molecules_from_group(item, indices='all'): -@digest(form=form) -def get_n_entities_from_group(item, indices='all'): + return _auxiliary_getter(get_n_molecules_from_group, item, indices) - raise NotImplementedError @digest(form=form) -def get_n_bonds_from_group(item, indices='all'): - - raise NotImplementedError +def get_n_chains_from_group(item, indices='all'): -@digest(form=form) -def get_n_inner_bonds_from_group(item, indices='all'): + return _auxiliary_getter(get_n_chains_from_group, item, indices) - raise NotImplementedError @digest(form=form) -def get_n_aminoacids_from_group(item, indices='all'): - - raise NotImplementedError +def get_n_entities_from_group(item, indices='all'): -@digest(form=form) -def get_n_nucleotides_from_group(item, indices='all'): + return _auxiliary_getter(get_n_entities_from_group, item, indices) - raise NotImplementedError -@digest(form=form) -def get_n_ions_from_group(item, indices='all'): +# From component - raise NotImplementedError @digest(form=form) -def get_n_waters_from_group(item, indices='all'): - - raise NotImplementedError +def get_atom_index_from_component(item, indices='all'): -@digest(form=form) -def get_n_small_molecules_from_group(item, indices='all'): + return _auxiliary_getter(get_atom_index_from_component, item, indices) - raise NotImplementedError @digest(form=form) -def get_n_peptides_from_group(item, indices='all'): - - raise NotImplementedError +def get_atom_id_from_component(item, indices='all'): -@digest(form=form) -def get_n_proteins_from_group(item, indices='all'): + return _auxiliary_getter(get_atom_id_from_component, item, indices) - raise NotImplementedError @digest(form=form) -def get_n_dnas_from_group(item, indices='all'): - - raise NotImplementedError +def get_atom_name_from_component(item, indices='all'): -@digest(form=form) -def get_n_rnas_from_group(item, indices='all'): + return _auxiliary_getter(get_atom_name_from_component, item, indices) - raise NotImplementedError @digest(form=form) -def get_n_lipids_from_group(item, indices='all'): - - raise NotImplementedError +def get_atom_type_from_component(item, indices='all'): -@digest(form=form) -def get_n_oligosaccharides_from_group(item, indices='all'): + return _auxiliary_getter(get_atom_type_from_component, item, indices) - raise NotImplementedError @digest(form=form) -def get_n_saccharides_from_group(item, indices='all'): - - raise NotImplementedError +def get_group_index_from_component(item, indices='all'): + aux = item.groups.groupby('component_index') + if is_all(indices): + output = [jj.tolist() for ii, jj in aux.groups.items()] + else: + output = [aux.groups[ii].tolist() for ii in indices] -## component + del aux -@digest(form=form) -def get_atom_index_from_component(item, indices='all'): + return output - raise NotImplementedError @digest(form=form) -def get_atom_id_from_component(item, indices='all'): +def get_group_id_from_component(item, indices='all'): - raise NotImplementedError + aux = item.groups.groupby('component_index')['group_id'] -@digest(form=form) -def get_atom_name_from_component(item, indices='all'): + if is_all(indices): + output = [jj.tolist() for ii, jj in aux] + else: + output = [aux.get_group(ii).tolist() for ii in indices] - raise NotImplementedError + del aux -@digest(form=form) -def get_atom_type_from_component(item, indices='all'): + return output - raise NotImplementedError @digest(form=form) -def get_group_index_from_component(item, indices='all'): +def get_group_name_from_component(item, indices='all'): - raise NotImplementedError + aux = item.groups.groupby('component_index')['group_name'] -@digest(form=form) -def get_group_id_from_component(item, indices='all'): + if is_all(indices): + output = [jj.tolist() for ii, jj in aux] + else: + output = [aux.get_group(ii).tolist() for ii in indices] - raise NotImplementedError + del aux -@digest(form=form) -def get_group_name_from_component(item, indices='all'): + return output - raise NotImplementedError @digest(form=form) def get_group_type_from_component(item, indices='all'): - raise NotImplementedError + aux = item.groups.groupby('component_index')['group_type'] -@digest(form=form) -def get_component_index_from_component(item, indices='all'): + if is_all(indices): + output = [jj.tolist() for ii, jj in aux] + else: + output = [aux.get_group(ii).tolist() for ii in indices] - raise NotImplementedError + del aux -@digest(form=form) -def get_component_id_from_component(item, indices='all'): + return output - raise NotImplementedError @digest(form=form) -def get_component_name_from_component(item, indices='all'): - - raise NotImplementedError +def get_component_index_from_component(item, indices='all'): -@digest(form=form) -def get_component_type_from_component(item, indices='all'): + return _auxiliary_getter(get_component_index_from_component, item, indices) - raise NotImplementedError @digest(form=form) def get_chain_index_from_component(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_chain_index_from_component, item, indices) + @digest(form=form) def get_chain_id_from_component(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_chain_id_from_component, item, indices) + @digest(form=form) def get_chain_name_from_component(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_chain_name_from_component, item, indices) + @digest(form=form) def get_chain_type_from_component(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_chain_type_from_component, item, indices) + @digest(form=form) def get_molecule_index_from_component(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_molecule_index_from_component, item, indices) + @digest(form=form) def get_molecule_id_from_component(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_molecule_id_from_component, item, indices) + @digest(form=form) def get_molecule_name_from_component(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_molecule_name_from_component, item, indices) + @digest(form=form) def get_molecule_type_from_component(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_molecule_type_from_component, item, indices) + @digest(form=form) def get_entity_index_from_component(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_entity_index_from_component, item, indices) + @digest(form=form) def get_entity_id_from_component(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_entity_id_from_component, item, indices) + @digest(form=form) def get_entity_name_from_component(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_entity_name_from_component, item, indices) + @digest(form=form) def get_entity_type_from_component(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_entity_type_from_component, item, indices) + @digest(form=form) def get_n_atoms_from_component(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_n_atoms_from_component, item, indices) + @digest(form=form) def get_n_groups_from_component(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_n_groups_from_component, item, indices) + @digest(form=form) def get_n_components_from_component(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_n_components_from_component, item, indices) + @digest(form=form) def get_n_molecules_from_component(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_n_molecules_from_component, item, indices) + @digest(form=form) def get_n_chains_from_component(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_n_chains_from_component, item, indices) + @digest(form=form) def get_n_entities_from_component(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_n_entities_from_component, item, indices) + @digest(form=form) def get_n_bonds_from_component(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_n_bonds_from_component, item, indices) + @digest(form=form) def get_n_inner_bonds_from_component(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_n_inner_bonds_from_component, item, indices) + + +@digest(form=form) +def get_formal_charge_from_component(item, indices='all'): + + return _auxiliary_getter(get_formal_charge_from_component, item, indices) + + +@digest(form=form) +def get_partial_charge_from_group(item, indices='all'): + + return _auxiliary_getter(get_partial_charge_from_group, item, indices) + @digest(form=form) def get_n_aminoacids_from_component(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_n_aminoacids_from_component, item, indices) + @digest(form=form) def get_n_nucleotides_from_component(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_n_nucleotides_from_component, item, indices) + @digest(form=form) def get_n_ions_from_component(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_n_ions_from_component, item, indices) + @digest(form=form) def get_n_waters_from_component(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_n_waters_from_component, item, indices) + @digest(form=form) def get_n_small_molecules_from_component(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_n_small_molecules_from_component, item, indices) + @digest(form=form) def get_n_peptides_from_component(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_n_peptides_from_component, item, indices) + @digest(form=form) def get_n_proteins_from_component(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_n_proteins_from_component, item, indices) + @digest(form=form) def get_n_dnas_from_component(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_n_dnas_from_component, item, indices) + @digest(form=form) def get_n_rnas_from_component(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_n_rnas_from_component, item, indices) + @digest(form=form) def get_n_lipids_from_component(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_n_lipids_from_component, item, indices) + @digest(form=form) def get_n_oligosaccharides_from_component(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_n_oligosaccharides_from_component, item, indices) + @digest(form=form) def get_n_saccharides_from_component(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_n_saccharides_from_component, item, indices) -## molecule +# From molecule + @digest(form=form) def get_atom_index_from_molecule(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_atom_index_from_molecule, item, indices) + @digest(form=form) def get_atom_id_from_molecule(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_atom_id_from_molecule, item, indices) + @digest(form=form) def get_atom_name_from_molecule(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_atom_name_from_molecule, item, indices) + @digest(form=form) def get_atom_type_from_molecule(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_atom_type_from_molecule, item, indices) + @digest(form=form) def get_group_index_from_molecule(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_group_index_from_molecule, item, indices) + @digest(form=form) def get_group_id_from_molecule(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_group_id_from_molecule, item, indices) + @digest(form=form) def get_group_name_from_molecule(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_group_name_from_molecule, item, indices) + @digest(form=form) def get_group_type_from_molecule(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_group_type_from_molecule, item, indices) + @digest(form=form) def get_component_index_from_molecule(item, indices='all'): - raise NotImplementedError + aux = item.components.groupby('molecule_index') + + if is_all(indices): + output = [jj.tolist() for ii, jj in aux.groups.items()] + else: + output = [aux.groups[ii].tolist() for ii in indices] + + del aux + + return output + @digest(form=form) def get_component_id_from_molecule(item, indices='all'): - raise NotImplementedError + aux = item.components.groupby('molecule_index')['component_id'] + + if is_all(indices): + output = [jj.tolist() for ii, jj in aux] + else: + output = [aux.get_group(ii).tolist() for ii in indices] + + del aux + + return output + @digest(form=form) def get_component_name_from_molecule(item, indices='all'): - raise NotImplementedError + aux = item.components.groupby('molecule_index')['component_name'] + + if is_all(indices): + output = [jj.tolist() for ii, jj in aux] + else: + output = [aux.get_group(ii).tolist() for ii in indices] + + del aux + + return output + @digest(form=form) def get_component_type_from_molecule(item, indices='all'): - raise NotImplementedError + aux = item.components.groupby('molecule_index')['component_type'] + + if is_all(indices): + output = [jj.tolist() for ii, jj in aux] + else: + output = [aux.get_group(ii).tolist() for ii in indices] + + del aux + + return output + @digest(form=form) def get_chain_index_from_molecule(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_chain_index_from_molecule, item, indices) + @digest(form=form) def get_chain_id_from_molecule(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_chain_id_from_molecule, item, indices) + @digest(form=form) def get_chain_name_from_molecule(item, indices='all'): - raise NotImplementedError - -@digest(form=form) -def get_chain_type_from_molecule(item, indices='all'): + return _auxiliary_getter(get_chain_name_from_molecule, item, indices) - raise NotImplementedError @digest(form=form) -def get_molecule_index_from_molecule(item, indices='all'): - - raise NotImplementedError +def get_chain_type_from_molecule(item, indices='all'): -@digest(form=form) -def get_molecule_id_from_molecule(item, indices='all'): + return _auxiliary_getter(get_chain_type_from_molecule, item, indices) - raise NotImplementedError @digest(form=form) -def get_molecule_name_from_molecule(item, indices='all'): - - raise NotImplementedError +def get_molecule_index_from_molecule(item, indices='all'): -@digest(form=form) -def get_molecule_type_from_molecule(item, indices='all'): + return _auxiliary_getter(get_molecule_index_from_molecule, item, indices) - raise NotImplementedError @digest(form=form) def get_entity_index_from_molecule(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_entity_index_from_molecule, item, indices) + @digest(form=form) def get_entity_id_from_molecule(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_entity_id_from_molecule, item, indices) + @digest(form=form) def get_entity_name_from_molecule(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_entity_name_from_molecule, item, indices) + @digest(form=form) def get_entity_type_from_molecule(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_entity_type_from_molecule, item, indices) + @digest(form=form) def get_n_atoms_from_molecule(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_n_atoms_from_molecule, item, indices) + @digest(form=form) def get_n_groups_from_molecule(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_n_groups_from_molecule, item, indices) + @digest(form=form) def get_n_components_from_molecule(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_n_components_from_molecule, item, indices) + @digest(form=form) def get_n_molecules_from_molecule(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_n_molecules_from_molecule, item, indices) + @digest(form=form) def get_n_chains_from_molecule(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_n_chains_from_molecule, item, indices) + @digest(form=form) def get_n_entities_from_molecule(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_n_entities_from_molecule, item, indices) + @digest(form=form) def get_n_bonds_from_molecule(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_n_bonds_from_molecule, item, indices) + @digest(form=form) def get_n_inner_bonds_from_molecule(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_n_inner_bonds_from_molecule, item, indices) + + +@digest(form=form) +def get_formal_charge_from_molecule(item, indices='all'): + + return _auxiliary_getter(get_formal_charge_from_molecule, item, indices) + + +@digest(form=form) +def get_partial_charge_from_molecule(item, indices='all'): + + return _auxiliary_getter(get_partial_charge_from_molecule, item, indices) + @digest(form=form) def get_n_aminoacids_from_molecule(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_n_aminoacids_from_molecule, item, indices) + @digest(form=form) def get_n_nucleotides_from_molecule(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_n_nucleotides_from_molecule, item, indices) + @digest(form=form) def get_n_ions_from_molecule(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_n_ions_from_molecule, item, indices) + @digest(form=form) def get_n_waters_from_molecule(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_n_waters_from_molecule, item, indices) + @digest(form=form) def get_n_small_molecules_from_molecule(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_n_small_molecules_from_molecule, item, indices) + @digest(form=form) def get_n_peptides_from_molecule(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_n_peptides_from_molecule, item, indices) + @digest(form=form) def get_n_proteins_from_molecule(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_n_proteins_from_molecule, item, indices) + @digest(form=form) def get_n_dnas_from_molecule(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_n_dnas_from_molecule, item, indices) + @digest(form=form) def get_n_rnas_from_molecule(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_n_rnas_from_molecule, item, indices) + @digest(form=form) def get_n_lipids_from_molecule(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_n_lipids_from_molecule, item, indices) + @digest(form=form) def get_n_oligosaccharides_from_molecule(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_n_oligosaccharides_from_molecule, item, indices) + @digest(form=form) def get_n_saccharides_from_molecule(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_n_saccharides_from_molecule, item, indices) + +# Entity -## chain @digest(form=form) -def get_atom_index_from_chain(item, indices='all'): +def get_atom_index_from_entity(item, indices='all'): + + return _auxiliary_getter(get_atom_index_from_entity, item, indices) - raise NotImplementedError @digest(form=form) -def get_atom_id_from_chain(item, indices='all'): +def get_atom_id_from_entity(item, indices='all'): + + return _auxiliary_getter(get_atom_id_from_entity, item, indices) - raise NotImplementedError @digest(form=form) -def get_atom_name_from_chain(item, indices='all'): +def get_atom_name_from_entity(item, indices='all'): + + return _auxiliary_getter(get_atom_name_from_entity, item, indices) - raise NotImplementedError @digest(form=form) -def get_atom_type_from_chain(item, indices='all'): +def get_atom_type_from_entity(item, indices='all'): + + return _auxiliary_getter(get_atom_type_from_entity, item, indices) - raise NotImplementedError @digest(form=form) -def get_group_index_from_chain(item, indices='all'): +def get_group_index_from_entity(item, indices='all'): + + return _auxiliary_getter(get_group_index_from_entity, item, indices) - raise NotImplementedError @digest(form=form) -def get_group_id_from_chain(item, indices='all'): +def get_group_id_from_entity(item, indices='all'): + + return _auxiliary_getter(get_group_id_from_entity, item, indices) - raise NotImplementedError @digest(form=form) -def get_group_name_from_chain(item, indices='all'): +def get_group_name_from_entity(item, indices='all'): + + return _auxiliary_getter(get_group_name_from_entity, item, indices) - raise NotImplementedError @digest(form=form) -def get_group_type_from_chain(item, indices='all'): +def get_group_type_from_entity(item, indices='all'): + + return _auxiliary_getter(get_group_type_from_entity, item, indices) - raise NotImplementedError @digest(form=form) -def get_component_index_from_chain(item, indices='all'): +def get_component_index_from_entity(item, indices='all'): + + return _auxiliary_getter(get_component_index_from_entity, item, indices) - raise NotImplementedError @digest(form=form) -def get_component_id_from_chain(item, indices='all'): +def get_component_id_from_entity(item, indices='all'): + + return _auxiliary_getter(get_component_id_from_entity, item, indices) - raise NotImplementedError @digest(form=form) -def get_component_name_from_chain(item, indices='all'): +def get_component_name_from_entity(item, indices='all'): + + return _auxiliary_getter(get_component_name_from_entity, item, indices) - raise NotImplementedError @digest(form=form) -def get_component_type_from_chain(item, indices='all'): +def get_component_type_from_entity(item, indices='all'): + + return _auxiliary_getter(get_component_type_from_entity, item, indices) - raise NotImplementedError @digest(form=form) -def get_chain_index_from_chain(item, indices='all'): +def get_chain_index_from_entity(item, indices='all'): + + return _auxiliary_getter(get_chain_index_from_entity, item, indices) - raise NotImplementedError @digest(form=form) -def get_chain_id_from_chain(item, indices='all'): +def get_chain_id_from_entity(item, indices='all'): + + return _auxiliary_getter(get_chain_id_from_entity, item, indices) - raise NotImplementedError @digest(form=form) -def get_chain_name_from_chain(item, indices='all'): +def get_chain_name_from_entity(item, indices='all'): + + return _auxiliary_getter(get_chain_name_from_entity, item, indices) - raise NotImplementedError @digest(form=form) -def get_chain_type_from_chain(item, indices='all'): +def get_chain_type_from_entity(item, indices='all'): + + return _auxiliary_getter(get_chain_type_from_entity, item, indices) - raise NotImplementedError @digest(form=form) -def get_molecule_index_from_chain(item, indices='all'): +def get_molecule_index_from_entity(item, indices='all'): + + aux = item.molecules.groupby('entity_index') + + if is_all(indices): + output = [jj.tolist() for ii, jj in aux.groups.items()] + else: + output = [aux.groups[ii].tolist() for ii in indices] + + del aux + + return output - raise NotImplementedError @digest(form=form) -def get_molecule_id_from_chain(item, indices='all'): +def get_molecule_id_from_entity(item, indices='all'): + + aux = item.molecules.groupby('entity_index')['molecule_id'] + + if is_all(indices): + output = [jj.tolist() for ii, jj in aux] + else: + output = [aux.get_group(ii).tolist() for ii in indices] + + del aux + + return output - raise NotImplementedError @digest(form=form) -def get_molecule_name_from_chain(item, indices='all'): +def get_molecule_name_from_entity(item, indices='all'): + + aux = item.molecules.groupby('entity_index')['molecule_name'] + + if is_all(indices): + output = [jj.tolist() for ii, jj in aux] + else: + output = [aux.get_group(ii).tolist() for ii in indices] + + del aux + + return output - raise NotImplementedError @digest(form=form) -def get_molecule_type_from_chain(item, indices='all'): +def get_molecule_type_from_entity(item, indices='all'): + + aux = item.molecules.groupby('entity_index')['molecule_type'] + + if is_all(indices): + output = [jj.tolist() for ii, jj in aux] + else: + output = [aux.get_group(ii).tolist() for ii in indices] + + del aux + + return output - raise NotImplementedError @digest(form=form) -def get_entity_index_from_chain(item, indices='all'): +def get_entity_index_from_entity(item, indices='all'): + + return _auxiliary_getter(get_entity_index_from_entity, item, indices) - raise NotImplementedError @digest(form=form) -def get_entity_id_from_chain(item, indices='all'): +def get_n_atoms_from_entity(item, indices='all'): + + return _auxiliary_getter(get_n_atoms_from_entity, item, indices) - raise NotImplementedError @digest(form=form) -def get_entity_name_from_chain(item, indices='all'): +def get_n_groups_from_entity(item, indices='all'): + + return _auxiliary_getter(get_n_groups_from_entity, item, indices) - raise NotImplementedError @digest(form=form) -def get_entity_type_from_chain(item, indices='all'): +def get_n_components_from_entity(item, indices='all'): + + return _auxiliary_getter(get_n_components_from_entity, item, indices) - raise NotImplementedError @digest(form=form) -def get_n_atoms_from_chain(item, indices='all'): +def get_n_molecules_from_entity(item, indices='all'): + + return _auxiliary_getter(get_n_molecules_from_entity, item, indices) - raise NotImplementedError @digest(form=form) -def get_n_groups_from_chain(item, indices='all'): +def get_n_chains_from_entity(item, indices='all'): + + return _auxiliary_getter(get_n_chains_from_entity, item, indices) - raise NotImplementedError @digest(form=form) -def get_n_components_from_chain(item, indices='all'): +def get_n_entities_from_entity(item, indices='all'): + + return _auxiliary_getter(get_n_entities_from_entity, item, indices) - raise NotImplementedError @digest(form=form) -def get_n_molecules_from_chain(item, indices='all'): +def get_n_bonds_from_entity(item, indices='all'): + + return _auxiliary_getter(get_n_bonds_from_entity, item, indices) - raise NotImplementedError @digest(form=form) -def get_n_chains_from_chain(item, indices='all'): +def get_n_inner_bonds_from_entity(item, indices='all'): + + return _auxiliary_getter(get_n_inner_bonds_from_entity, item, indices) - raise NotImplementedError @digest(form=form) -def get_n_entities_from_chain(item, indices='all'): +def get_formal_charge_from_entity(item, indices='all'): + + return _auxiliary_getter(get_formal_charge_from_entity, item, indices) - raise NotImplementedError @digest(form=form) -def get_n_bonds_from_chain(item, indices='all'): +def get_partial_charge_from_entity(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_partial_charge_from_entity, item, indices) @digest(form=form) -def get_n_inner_bonds_from_chain(item, indices='all'): +def get_n_aminoacids_from_entity(item, indices='all'): + + return _auxiliary_getter(get_n_aminoacids_from_entity, item, indices) - raise NotImplementedError @digest(form=form) -def get_n_aminoacids_from_chain(item, indices='all'): +def get_n_nucleotides_from_entity(item, indices='all'): + + return _auxiliary_getter(get_n_nucleotides_from_entity, item, indices) - raise NotImplementedError @digest(form=form) -def get_n_nucleotides_from_chain(item, indices='all'): +def get_n_ions_from_entity(item, indices='all'): + + return _auxiliary_getter(get_n_ions_from_entity, item, indices) - raise NotImplementedError @digest(form=form) -def get_n_ions_from_chain(item, indices='all'): +def get_n_waters_from_entity(item, indices='all'): + + return _auxiliary_getter(get_n_waters_from_entity, item, indices) - raise NotImplementedError @digest(form=form) -def get_n_waters_from_chain(item, indices='all'): +def get_n_small_molecules_from_entity(item, indices='all'): + + return _auxiliary_getter(get_n_small_molecules_from_entity, item, indices) - raise NotImplementedError @digest(form=form) -def get_n_small_molecules_from_chain(item, indices='all'): +def get_n_peptides_from_entity(item, indices='all'): + + return _auxiliary_getter(get_n_peptides_from_entity, item, indices) - raise NotImplementedError @digest(form=form) -def get_n_peptides_from_chain(item, indices='all'): +def get_n_proteins_from_entity(item, indices='all'): + + return _auxiliary_getter(get_n_proteins_from_entity, item, indices) + + +@digest(form=form) +def get_n_dnas_from_entity(item, indices='all'): + + return _auxiliary_getter(get_n_dnas_from_entity, item, indices) + + +@digest(form=form) +def get_n_rnas_from_entity(item, indices='all'): + + return _auxiliary_getter(get_n_rnas_from_entity, item, indices) - raise NotImplementedError @digest(form=form) -def get_n_proteins_from_chain(item, indices='all'): +def get_n_lipids_from_entity(item, indices='all'): + + return _auxiliary_getter(get_n_lipids_from_entity, item, indices) - raise NotImplementedError @digest(form=form) -def get_n_dnas_from_chain(item, indices='all'): +def get_n_oligosaccharides_from_entity(item, indices='all'): + + return _auxiliary_getter(get_n_oligosaccharides_from_entity, item, indices) - raise NotImplementedError @digest(form=form) -def get_n_rnas_from_chain(item, indices='all'): +def get_n_saccharides_from_entity(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_n_saccharides_from_entity, item, indices) -@digest(form=form) -def get_n_lipids_from_chain(item, indices='all'): - raise NotImplementedError +# Chain + @digest(form=form) -def get_n_oligosaccharides_from_chain(item, indices='all'): +def get_atom_index_from_chain(item, indices='all'): - raise NotImplementedError + aux = item.atoms.groupby('chain_index') -@digest(form=form) -def get_n_saccharides_from_chain(item, indices='all'): + if is_all(indices): + output = [jj.tolist() for ii, jj in aux.groups.items()] + else: + output = [aux.groups[ii].tolist() for ii in indices] - raise NotImplementedError + del aux + return output -## entity @digest(form=form) -def get_atom_index_from_entity(item, indices='all'): +def get_atom_id_from_chain(item, indices='all'): - raise NotImplementedError + aux = item.atoms.groupby('chain_index')['atom_id'] -@digest(form=form) -def get_atom_id_from_entity(item, indices='all'): + if is_all(indices): + output = [jj.tolist() for ii, jj in aux] + else: + output = [aux.get_group(ii).tolist() for ii in indices] - raise NotImplementedError + del aux -@digest(form=form) -def get_atom_name_from_entity(item, indices='all'): + return output - raise NotImplementedError @digest(form=form) -def get_atom_type_from_entity(item, indices='all'): +def get_atom_name_from_chain(item, indices='all'): - raise NotImplementedError + aux = item.atoms.groupby('chain_index')['atom_name'] -@digest(form=form) -def get_group_index_from_entity(item, indices='all'): + if is_all(indices): + output = [jj.tolist() for ii, jj in aux] + else: + output = [aux.get_group(ii).tolist() for ii in indices] - raise NotImplementedError + del aux -@digest(form=form) -def get_group_id_from_entity(item, indices='all'): + return output - raise NotImplementedError @digest(form=form) -def get_group_name_from_entity(item, indices='all'): +def get_atom_type_from_chain(item, indices='all'): - raise NotImplementedError + aux = item.atoms.groupby('chain_index')['atom_type'] -@digest(form=form) -def get_group_type_from_entity(item, indices='all'): + if is_all(indices): + output = [jj.tolist() for ii, jj in aux] + else: + output = [aux.get_group(ii).tolist() for ii in indices] - raise NotImplementedError + del aux -@digest(form=form) -def get_component_index_from_entity(item, indices='all'): + return output - raise NotImplementedError @digest(form=form) -def get_component_id_from_entity(item, indices='all'): +def get_group_index_from_chain(item, indices='all'): + + return _auxiliary_getter(get_group_index_from_chain, item, indices) - raise NotImplementedError @digest(form=form) -def get_component_name_from_entity(item, indices='all'): +def get_group_id_from_chain(item, indices='all'): + + return _auxiliary_getter(get_group_id_from_chain, item, indices) - raise NotImplementedError @digest(form=form) -def get_component_type_from_entity(item, indices='all'): +def get_group_name_from_chain(item, indices='all'): + + return _auxiliary_getter(get_group_name_from_chain, item, indices) - raise NotImplementedError @digest(form=form) -def get_chain_index_from_entity(item, indices='all'): +def get_group_type_from_chain(item, indices='all'): + + return _auxiliary_getter(get_group_type_from_chain, item, indices) - raise NotImplementedError @digest(form=form) -def get_chain_id_from_entity(item, indices='all'): +def get_component_index_from_chain(item, indices='all'): + + return _auxiliary_getter(get_component_index_from_chain, item, indices) - raise NotImplementedError @digest(form=form) -def get_chain_name_from_entity(item, indices='all'): +def get_component_id_from_chain(item, indices='all'): + + return _auxiliary_getter(get_component_id_from_chain, item, indices) - raise NotImplementedError @digest(form=form) -def get_chain_type_from_entity(item, indices='all'): +def get_component_name_from_chain(item, indices='all'): + + return _auxiliary_getter(get_component_name_from_chain, item, indices) - raise NotImplementedError @digest(form=form) -def get_molecule_index_from_entity(item, indices='all'): +def get_component_type_from_chain(item, indices='all'): + + return _auxiliary_getter(get_component_type_from_chain, item, indices) - raise NotImplementedError @digest(form=form) -def get_molecule_id_from_entity(item, indices='all'): +def get_chain_index_from_chain(item, indices='all'): + + return _auxiliary_getter(get_chain_index_from_chain, item, indices) - raise NotImplementedError @digest(form=form) -def get_molecule_name_from_entity(item, indices='all'): +def get_molecule_index_from_chain(item, indices='all'): + + return _auxiliary_getter(get_molecule_index_from_chain, item, indices) - raise NotImplementedError @digest(form=form) -def get_molecule_type_from_entity(item, indices='all'): +def get_molecule_id_from_chain(item, indices='all'): + + return _auxiliary_getter(get_molecule_id_from_chain, item, indices) - raise NotImplementedError @digest(form=form) -def get_entity_index_from_entity(item, indices='all'): +def get_molecule_name_from_chain(item, indices='all'): + + return _auxiliary_getter(get_molecule_name_from_chain, item, indices) - raise NotImplementedError @digest(form=form) -def get_entity_id_from_entity(item, indices='all'): +def get_molecule_type_from_chain(item, indices='all'): + + return _auxiliary_getter(get_molecule_type_from_chain, item, indices) - raise NotImplementedError @digest(form=form) -def get_entity_name_from_entity(item, indices='all'): +def get_entity_index_from_chain(item, indices='all'): + + return _auxiliary_getter(get_entity_index_from_chain, item, indices) - raise NotImplementedError @digest(form=form) -def get_entity_type_from_entity(item, indices='all'): +def get_entity_id_from_chain(item, indices='all'): + + return _auxiliary_getter(get_entity_id_from_chain, item, indices) - raise NotImplementedError @digest(form=form) -def get_n_atoms_from_entity(item, indices='all'): +def get_entity_name_from_chain(item, indices='all'): + + return _auxiliary_getter(get_entity_name_from_chain, item, indices) - raise NotImplementedError @digest(form=form) -def get_n_groups_from_entity(item, indices='all'): +def get_entity_type_from_chain(item, indices='all'): + + return _auxiliary_getter(get_entity_type_from_chain, item, indices) - raise NotImplementedError @digest(form=form) -def get_n_components_from_entity(item, indices='all'): +def get_n_atoms_from_chain(item, indices='all'): + + return _auxiliary_getter(get_n_atoms_from_chain, item, indices) - raise NotImplementedError @digest(form=form) -def get_n_molecules_from_entity(item, indices='all'): +def get_n_groups_from_chain(item, indices='all'): + + return _auxiliary_getter(get_n_groups_from_chain, item, indices) - raise NotImplementedError @digest(form=form) -def get_n_chains_from_entity(item, indices='all'): +def get_n_components_from_chain(item, indices='all'): + + return _auxiliary_getter(get_n_components_from_chain, item, indices) - raise NotImplementedError @digest(form=form) -def get_n_entities_from_entity(item, indices='all'): +def get_n_molecules_from_chain(item, indices='all'): + + return _auxiliary_getter(get_n_molecules_from_chain, item, indices) - raise NotImplementedError @digest(form=form) -def get_n_bonds_from_entity(item, indices='all'): +def get_n_chains_from_chain(item, indices='all'): + + return _auxiliary_getter(get_n_chains_from_chain, item, indices) - raise NotImplementedError @digest(form=form) -def get_n_inner_bonds_from_entity(item, indices='all'): +def get_n_entities_from_chain(item, indices='all'): + + return _auxiliary_getter(get_n_entities_from_chain, item, indices) - raise NotImplementedError @digest(form=form) -def get_n_aminoacids_from_entity(item, indices='all'): +def get_n_bonds_from_chain(item, indices='all'): + + return _auxiliary_getter(get_n_bonds_from_chain, item, indices) - raise NotImplementedError @digest(form=form) -def get_n_nucleotides_from_entity(item, indices='all'): +def get_n_inner_bonds_from_chain(item, indices='all'): + + return _auxiliary_getter(get_n_inner_bonds_from_chain, item, indices) - raise NotImplementedError @digest(form=form) -def get_n_ions_from_entity(item, indices='all'): +def get_formal_charge_from_chain(item, indices='all'): + + return _auxiliary_getter(get_formal_charge_from_chain, item, indices) - raise NotImplementedError @digest(form=form) -def get_n_waters_from_entity(item, indices='all'): +def get_partial_charge_from_chain(item, indices='all'): + + return _auxiliary_getter(get_partial_charge_from_chain, item, indices) - raise NotImplementedError @digest(form=form) -def get_n_small_molecules_from_entity(item, indices='all'): +def get_n_aminoacids_from_chain(item, indices='all'): + + return _auxiliary_getter(get_n_aminoacids_from_chain, item, indices) - raise NotImplementedError @digest(form=form) -def get_n_peptides_from_entity(item, indices='all'): +def get_n_nucleotides_from_chain(item, indices='all'): + + return _auxiliary_getter(get_n_nucleotides_from_chain, item, indices) - raise NotImplementedError @digest(form=form) -def get_n_proteins_from_entity(item, indices='all'): +def get_n_ions_from_chain(item, indices='all'): + + return _auxiliary_getter(get_n_ions_from_chain, item, indices) - raise NotImplementedError @digest(form=form) -def get_n_dnas_from_entity(item, indices='all'): +def get_n_waters_from_chain(item, indices='all'): + + return _auxiliary_getter(get_n_waters_from_chain, item, indices) - raise NotImplementedError @digest(form=form) -def get_n_rnas_from_entity(item, indices='all'): +def get_n_small_molecules_from_chain(item, indices='all'): + + return _auxiliary_getter(get_n_small_molecules_from_chain, item, indices) - raise NotImplementedError @digest(form=form) -def get_n_lipids_from_entity(item, indices='all'): +def get_n_peptides_from_chain(item, indices='all'): + + return _auxiliary_getter(get_n_peptides_from_chain, item, indices) - raise NotImplementedError @digest(form=form) -def get_n_oligosaccharides_from_entity(item, indices='all'): +def get_n_proteins_from_chain(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_n_proteins_from_chain, item, indices) -@digest(form=form) -def get_n_saccharides_from_entity(item, indices='all'): - raise NotImplementedError +@digest(form=form) +def get_n_dnas_from_chain(item, indices='all'): + return _auxiliary_getter(get_n_dnas_from_chain, item, indices) -## system @digest(form=form) -def get_n_atoms_from_system(item): +def get_n_rnas_from_chain(item, indices='all'): + + return _auxiliary_getter(get_n_rnas_from_chain, item, indices) - raise NotImplementedError @digest(form=form) -def get_n_groups_from_system(item): +def get_n_lipids_from_chain(item, indices='all'): + + return _auxiliary_getter(get_n_lipids_from_chain, item, indices) - raise NotImplementedError @digest(form=form) -def get_n_components_from_system(item): +def get_n_oligosaccharides_from_chain(item, indices='all'): + + return _auxiliary_getter(get_n_oligosaccharides_from_chain, item, indices) - raise NotImplementedError @digest(form=form) -def get_n_chains_from_system(item): +def get_n_saccharides_from_chain(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_n_saccharides_from_chain, item, indices) -@digest(form=form) -def get_n_molecules_from_system(item): - raise NotImplementedError +# Bond + @digest(form=form) -def get_n_entities_from_system(item): +def get_bond_index_from_bond(item, indices='all'): + + return _auxiliary_getter(get_bond_index_from_bond, item, indices) - raise NotImplementedError @digest(form=form) -def get_n_bonds_from_system(item): +def get_n_bonds_from_bond(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_n_bonds_from_bond, item, indices) -@digest(form=form) -def get_n_inner_bonds_from_system(item): - raise NotImplementedError +# System + @digest(form=form) def get_n_aminoacids_from_system(item): - raise NotImplementedError + return _auxiliary_getter(get_n_aminoacids_from_system, item) + @digest(form=form) def get_n_nucleotides_from_system(item): - raise NotImplementedError + return _auxiliary_getter(get_n_nucleotides_from_system, item) + @digest(form=form) def get_n_ions_from_system(item): - raise NotImplementedError + return _auxiliary_getter(get_n_ions_from_system, item) + @digest(form=form) def get_n_waters_from_system(item): - raise NotImplementedError + return _auxiliary_getter(get_n_waters_from_system, item) + @digest(form=form) def get_n_small_molecules_from_system(item): - raise NotImplementedError + return _auxiliary_getter(get_n_small_molecules_from_system, item) + @digest(form=form) def get_n_peptides_from_system(item): - raise NotImplementedError + return _auxiliary_getter(get_n_peptides_from_system, item) + @digest(form=form) def get_n_proteins_from_system(item): - raise NotImplementedError + return _auxiliary_getter(get_n_proteins_from_system, item) + @digest(form=form) def get_n_dnas_from_system(item): - raise NotImplementedError + return _auxiliary_getter(get_n_dnas_from_system, item) + @digest(form=form) def get_n_rnas_from_system(item): - raise NotImplementedError + return _auxiliary_getter(get_n_rnas_from_system, item) + @digest(form=form) def get_n_lipids_from_system(item): - raise NotImplementedError + return _auxiliary_getter(get_n_lipids_from_system, item) + @digest(form=form) def get_n_oligosaccharides_from_system(item): - raise NotImplementedError + return _auxiliary_getter(get_n_oligosaccharides_from_system, item) + @digest(form=form) def get_n_saccharides_from_system(item): - raise NotImplementedError + return _auxiliary_getter(get_n_saccharides_from_system, item) + @digest(form=form) -def get_n_structures_from_system(item, structure_indices='all'): +def get_formal_charge_from_system(item, indices='all'): - raise NotImplementedError + return _auxiliary_getter(get_formal_charge_from_system, item, indices) -## bond @digest(form=form) -def get_bond_index_from_bond(item, indices='all'): - - raise NotImplementedError +def get_partial_charge_from_system(item, indices='all'): -@digest(form=form) -def get_bond_order_from_bond(item, indices='all'): + return _auxiliary_getter(get_partial_charge_from_system, item, indices) - raise NotImplementedError @digest(form=form) -def get_bond_type_from_bond(item, indices='all'): +def get_bonded_atoms_from_system(item): + + return _auxiliary_getter(get_bonded_atoms_from_system, item) - raise NotImplementedError @digest(form=form) -def get_bonded_atoms_from_bond(item, indices='all'): +def get_bond_index_from_system(item): - raise NotImplementedError + return _auxiliary_getter(get_bond_index_from_system, item) -@digest(form=form) -def get_n_bonds_from_bond(item, indices='all'): - raise NotImplementedError +# List of functions to be imported + +__all__ = [name for name, obj in globals().items() if isinstance(obj, types.FunctionType) and name.startswith('get_')] diff --git a/molsysmt/form/molsysmt_TopologyNEW/has_attribute.py b/molsysmt/form/molsysmt_TopologyNEW/has_attribute.py index 829a99b28..87fde303c 100644 --- a/molsysmt/form/molsysmt_TopologyNEW/has_attribute.py +++ b/molsysmt/form/molsysmt_TopologyNEW/has_attribute.py @@ -7,5 +7,4 @@ def has_attribute(molecular_system, attribute): output = attributes[attribute] - raise NotImplementedError - + return output diff --git a/molsysmt/supported/syntaxes.py b/molsysmt/supported/syntaxes.py index 50e2b792f..635eecf7b 100644 --- a/molsysmt/supported/syntaxes.py +++ b/molsysmt/supported/syntaxes.py @@ -1,5 +1,6 @@ syntaxes = [ 'MolSysMT', + 'MolSysMT_NEW', 'Amber', 'MDAnalysis', 'MDTraj', diff --git a/sandbox/Test_new_selection.ipynb b/sandbox/Test_new_selection.ipynb index 8ed6e66b8..198f86081 100644 --- a/sandbox/Test_new_selection.ipynb +++ b/sandbox/Test_new_selection.ipynb @@ -17,7 +17,7 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "793e0952677a420da7a05c582f608656", + "model_id": "0b5abb42ea34464a9c78263b4564ca5f", "version_major": 2, "version_minor": 0 }, @@ -36,29 +36,1083 @@ "execution_count": 2, "id": "659a8693-aa1b-48b8-b2cc-1d63ae0596b3", "metadata": {}, + "outputs": [], + "source": [ + "molsys = msm.convert('traj.h5msm', to_form='molsysmt.TopologyNEW')" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "de4706b3-0a79-4eef-8838-84048bcf5557", + "metadata": {}, "outputs": [ { - "ename": "NotImplementedConversionError", - "evalue": "Error in conversion from file:msmh5 to molsysmt.MolSysNEW", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mNotImplementedConversionError\u001b[0m Traceback (most recent call last)", - "Cell \u001b[0;32mIn[2], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m molsys \u001b[38;5;241m=\u001b[39m \u001b[43mmsm\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mconvert\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mtraj.msmh5\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mto_form\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mmolsysmt.MolSysNEW\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m)\u001b[49m\n", - "File \u001b[0;32m~/repos@uibcdf/MolSysMT/molsysmt/_private/digestion/digest.py:119\u001b[0m, in \u001b[0;36mdigest..digestor..wrapper\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 117\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 118\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m--> 119\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/convert.py:541\u001b[0m, in \u001b[0;36mconvert\u001b[0;34m(molecular_system, to_form, selection, structure_indices, syntax, verbose, **kwargs)\u001b[0m\n\u001b[1;32m 539\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mlen\u001b[39m(from_form)\u001b[38;5;241m==\u001b[39m\u001b[38;5;241m1\u001b[39m:\n\u001b[1;32m 540\u001b[0m from_form\u001b[38;5;241m=\u001b[39mfrom_form[\u001b[38;5;241m0\u001b[39m]\n\u001b[0;32m--> 541\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m NotImplementedConversionError(from_form, to_form)\n\u001b[1;32m 543\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(output, (\u001b[38;5;28mlist\u001b[39m, \u001b[38;5;28mtuple\u001b[39m)):\n\u001b[1;32m 544\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mlen\u001b[39m(output) \u001b[38;5;241m==\u001b[39m \u001b[38;5;241m1\u001b[39m:\n", - "\u001b[0;31mNotImplementedConversionError\u001b[0m: Error in conversion from file:msmh5 to molsysmt.MolSysNEW" + "name": "stdout", + "output_type": "stream", + "text": [ + "chain_id==1\n" ] + }, + { + "data": { + "text/plain": [ + "[3727,\n", + " 3728,\n", + " 3729,\n", + " 3730,\n", + " 3731,\n", + " 3732,\n", + " 3733,\n", + " 3734,\n", + " 3735,\n", + " 3736,\n", + " 3737,\n", + " 3738,\n", + " 3739,\n", + " 3740,\n", + " 3741,\n", + " 3742,\n", + " 3743,\n", + " 3744,\n", + " 3745,\n", + " 3746,\n", + " 3747,\n", + " 3748,\n", + " 3749,\n", + " 3750,\n", + " 3751,\n", + " 3752,\n", + " 3753,\n", + " 3754,\n", + " 3755,\n", + " 3756,\n", + " 3757,\n", + " 3758,\n", + " 3759,\n", + " 3760,\n", + " 3761,\n", + " 3762,\n", + " 3763,\n", + " 3764,\n", + " 3765,\n", + " 3766,\n", + " 3767,\n", + " 3768,\n", + " 3769,\n", + " 3770,\n", + " 3771,\n", + " 3772,\n", + " 3773,\n", + " 3774,\n", + " 3775,\n", + " 3776,\n", + " 3777,\n", + " 3778,\n", + " 3779,\n", + " 3780,\n", + " 3781,\n", + " 3782,\n", + " 3783,\n", + " 3784,\n", + " 3785,\n", + " 3786,\n", + " 3787,\n", + " 3788,\n", + " 3789,\n", + " 3790,\n", + " 3791,\n", + " 3792,\n", + " 3793,\n", + " 3794,\n", + " 3795,\n", + " 3796,\n", + " 3797,\n", + " 3798,\n", + " 3799,\n", + " 3800,\n", + " 3801,\n", + " 3802,\n", + " 3803,\n", + " 3804,\n", + " 3805,\n", + " 3806,\n", + " 3807,\n", + " 3808,\n", + " 3809,\n", + " 3810,\n", + " 3811,\n", + " 3812,\n", + " 3813,\n", + " 3814,\n", + " 3815,\n", + " 3816,\n", + " 3817,\n", + " 3818,\n", + " 3819,\n", + " 3820,\n", + " 3821,\n", + " 3822,\n", + " 3823,\n", + " 3824,\n", + " 3825,\n", + " 3826,\n", + " 3827,\n", + " 3828,\n", + " 3829,\n", + " 3830,\n", + " 3831,\n", + " 3832,\n", + " 3833,\n", + " 3834,\n", + " 3835,\n", + " 3836,\n", + " 3837,\n", + " 3838,\n", + " 3839,\n", + " 3840,\n", + " 3841,\n", + " 3842,\n", + " 3843,\n", + " 3844,\n", + " 3845,\n", + " 3846,\n", + " 3847,\n", + " 3848,\n", + " 3849,\n", + " 3850,\n", + " 3851,\n", + " 3852,\n", + " 3853,\n", + " 3854,\n", + " 3855,\n", + " 3856,\n", + " 3857,\n", + " 3858,\n", + " 3859,\n", + " 3860,\n", + " 3861,\n", + " 3862,\n", + " 3863,\n", + " 3864,\n", + " 3865,\n", + " 3866,\n", + " 3867,\n", + " 3868,\n", + " 3869,\n", + " 3870,\n", + " 3871,\n", + " 3872,\n", + " 3873,\n", + " 3874,\n", + " 3875,\n", + " 3876,\n", + " 3877,\n", + " 3878,\n", + " 3879,\n", + " 3880,\n", + " 3881,\n", + " 3882,\n", + " 3883,\n", + " 3884,\n", + " 3885,\n", + " 3886,\n", + " 3887,\n", + " 3888,\n", + " 3889,\n", + " 3890,\n", + " 3891,\n", + " 3892,\n", + " 3893,\n", + " 3894,\n", + " 3895,\n", + " 3896,\n", + " 3897,\n", + " 3898,\n", + " 3899,\n", + " 3900,\n", + " 3901,\n", + " 3902,\n", + " 3903,\n", + " 3904,\n", + " 3905,\n", + " 3906,\n", + " 3907,\n", + " 3908,\n", + " 3909,\n", + " 3910,\n", + " 3911,\n", + " 3912,\n", + " 3913,\n", + " 3914,\n", + " 3915,\n", + " 3916,\n", + " 3917,\n", + " 3918,\n", + " 3919,\n", + " 3920,\n", + " 3921,\n", + " 3922,\n", + " 3923,\n", + " 3924,\n", + " 3925,\n", + " 3926,\n", + " 3927,\n", + " 3928,\n", + " 3929,\n", + " 3930,\n", + " 3931,\n", + " 3932,\n", + " 3933,\n", + " 3934,\n", + " 3935,\n", + " 3936,\n", + " 3937,\n", + " 3938,\n", + " 3939,\n", + " 3940,\n", + " 3941,\n", + " 3942,\n", + " 3943,\n", + " 3944,\n", + " 3945,\n", + " 3946,\n", + " 3947,\n", + " 3948,\n", + " 3949,\n", + " 3950,\n", + " 3951,\n", + " 3952,\n", + " 3953,\n", + " 3954,\n", + " 3955,\n", + " 3956,\n", + " 3957,\n", + " 3958,\n", + " 3959,\n", + " 3960,\n", + " 3961,\n", + " 3962,\n", + " 3963,\n", + " 3964,\n", + " 3965,\n", + " 3966,\n", + " 3967,\n", + " 3968,\n", + " 3969,\n", + " 3970,\n", + " 3971,\n", + " 3972,\n", + " 3973,\n", + " 3974,\n", + " 3975,\n", + " 3976,\n", + " 3977,\n", + " 3978,\n", + " 3979,\n", + " 3980,\n", + " 3981,\n", + " 3982,\n", + " 3983,\n", + " 3984,\n", + " 3985,\n", + " 3986,\n", + " 3987,\n", + " 3988,\n", + " 3989,\n", + " 3990,\n", + " 3991,\n", + " 3992,\n", + " 3993,\n", + " 3994,\n", + " 3995,\n", + " 3996,\n", + " 3997,\n", + " 3998,\n", + " 3999,\n", + " 4000,\n", + " 4001,\n", + " 4002,\n", + " 4003,\n", + " 4004,\n", + " 4005,\n", + " 4006,\n", + " 4007,\n", + " 4008,\n", + " 4009,\n", + " 4010,\n", + " 4011,\n", + " 4012,\n", + " 4013,\n", + " 4014,\n", + " 4015,\n", + " 4016,\n", + " 4017,\n", + " 4018,\n", + " 4019,\n", + " 4020,\n", + " 4021,\n", + " 4022,\n", + " 4023,\n", + " 4024,\n", + " 4025,\n", + " 4026,\n", + " 4027,\n", + " 4028,\n", + " 4029,\n", + " 4030,\n", + " 4031,\n", + " 4032,\n", + " 4033,\n", + " 4034,\n", + " 4035,\n", + " 4036,\n", + " 4037,\n", + " 4038,\n", + " 4039,\n", + " 4040,\n", + " 4041,\n", + " 4042,\n", + " 4043,\n", + " 4044,\n", + " 4045,\n", + " 4046,\n", + " 4047,\n", + " 4048,\n", + " 4049,\n", + " 4050,\n", + " 4051,\n", + " 4052,\n", + " 4053,\n", + " 4054,\n", + " 4055,\n", + " 4056,\n", + " 4057,\n", + " 4058,\n", + " 4059,\n", + " 4060,\n", + " 4061,\n", + " 4062,\n", + " 4063,\n", + " 4064,\n", + " 4065,\n", + " 4066,\n", + " 4067,\n", + " 4068,\n", + " 4069,\n", + " 4070,\n", + " 4071,\n", + " 4072,\n", + " 4073,\n", + " 4074,\n", + " 4075,\n", + " 4076,\n", + " 4077,\n", + " 4078,\n", + " 4079,\n", + " 4080,\n", + " 4081,\n", + " 4082,\n", + " 4083,\n", + " 4084,\n", + " 4085,\n", + " 4086,\n", + " 4087,\n", + " 4088,\n", + " 4089,\n", + " 4090,\n", + " 4091,\n", + " 4092,\n", + " 4093,\n", + " 4094,\n", + " 4095,\n", + " 4096,\n", + " 4097,\n", + " 4098,\n", + " 4099,\n", + " 4100,\n", + " 4101,\n", + " 4102,\n", + " 4103,\n", + " 4104,\n", + " 4105,\n", + " 4106,\n", + " 4107,\n", + " 4108,\n", + " 4109,\n", + " 4110,\n", + " 4111,\n", + " 4112,\n", + " 4113,\n", + " 4114,\n", + " 4115,\n", + " 4116,\n", + " 4117,\n", + " 4118,\n", + " 4119,\n", + " 4120,\n", + " 4121,\n", + " 4122,\n", + " 4123,\n", + " 4124,\n", + " 4125,\n", + " 4126,\n", + " 4127,\n", + " 4128,\n", + " 4129,\n", + " 4130,\n", + " 4131,\n", + " 4132,\n", + " 4133,\n", + " 4134,\n", + " 4135,\n", + " 4136,\n", + " 4137,\n", + " 4138,\n", + " 4139,\n", + " 4140,\n", + " 4141,\n", + " 4142,\n", + " 4143,\n", + " 4144,\n", + " 4145,\n", + " 4146,\n", + " 4147,\n", + " 4148,\n", + " 4149,\n", + " 4150,\n", + " 4151,\n", + " 4152,\n", + " 4153,\n", + " 4154,\n", + " 4155,\n", + " 4156,\n", + " 4157,\n", + " 4158,\n", + " 4159,\n", + " 4160,\n", + " 4161,\n", + " 4162,\n", + " 4163,\n", + " 4164,\n", + " 4165,\n", + " 4166,\n", + " 4167,\n", + " 4168,\n", + " 4169,\n", + " 4170,\n", + " 4171,\n", + " 4172,\n", + " 4173,\n", + " 4174,\n", + " 4175,\n", + " 4176,\n", + " 4177,\n", + " 4178,\n", + " 4179,\n", + " 4180,\n", + " 4181,\n", + " 4182,\n", + " 4183,\n", + " 4184,\n", + " 4185,\n", + " 4186,\n", + " 4187,\n", + " 4188,\n", + " 4189,\n", + " 4190,\n", + " 4191,\n", + " 4192,\n", + " 4193,\n", + " 4194,\n", + " 4195,\n", + " 4196,\n", + " 4197,\n", + " 4198,\n", + " 4199,\n", + " 4200,\n", + " 4201,\n", + " 4202,\n", + " 4203,\n", + " 4204,\n", + " 4205,\n", + " 4206,\n", + " 4207,\n", + " 4208,\n", + " 4209,\n", + " 4210,\n", + " 4211,\n", + " 4212,\n", + " 4213,\n", + " 4214,\n", + " 4215,\n", + " 4216,\n", + " 4217,\n", + " 4218,\n", + " 4219,\n", + " 4220,\n", + " 4221,\n", + " 4222,\n", + " 4223,\n", + " 4224,\n", + " 4225,\n", + " 4226,\n", + " 4227,\n", + " 4228,\n", + " 4229,\n", + " 4230,\n", + " 4231,\n", + " 4232,\n", + " 4233,\n", + " 4234,\n", + " 4235,\n", + " 4236,\n", + " 4237,\n", + " 4238,\n", + " 4239,\n", + " 4240,\n", + " 4241,\n", + " 4242,\n", + " 4243,\n", + " 4244,\n", + " 4245,\n", + " 4246,\n", + " 4247,\n", + " 4248,\n", + " 4249,\n", + " 4250,\n", + " 4251,\n", + " 4252,\n", + " 4253,\n", + " 4254,\n", + " 4255,\n", + " 4256,\n", + " 4257,\n", + " 4258,\n", + " 4259,\n", + " 4260,\n", + " 4261,\n", + " 4262,\n", + " 4263,\n", + " 4264,\n", + " 4265,\n", + " 4266,\n", + " 4267,\n", + " 4268,\n", + " 4269,\n", + " 4270,\n", + " 4271,\n", + " 4272,\n", + " 4273,\n", + " 4274,\n", + " 4275,\n", + " 4276,\n", + " 4277,\n", + " 4278,\n", + " 4279,\n", + " 4280,\n", + " 4281,\n", + " 4282,\n", + " 4283,\n", + " 4284,\n", + " 4285,\n", + " 4286,\n", + " 4287,\n", + " 4288,\n", + " 4289,\n", + " 4290,\n", + " 4291,\n", + " 4292,\n", + " 4293,\n", + " 4294,\n", + " 4295,\n", + " 4296,\n", + " 4297,\n", + " 4298,\n", + " 4299,\n", + " 4300,\n", + " 4301,\n", + " 4302,\n", + " 4303,\n", + " 4304,\n", + " 4305,\n", + " 4306,\n", + " 4307,\n", + " 4308,\n", + " 4309,\n", + " 4310,\n", + " 4311,\n", + " 4312,\n", + " 4313,\n", + " 4314,\n", + " 4315,\n", + " 4316,\n", + " 4317,\n", + " 4318,\n", + " 4319,\n", + " 4320,\n", + " 4321,\n", + " 4322,\n", + " 4323,\n", + " 4324,\n", + " 4325,\n", + " 4326,\n", + " 4327,\n", + " 4328,\n", + " 4329,\n", + " 4330,\n", + " 4331,\n", + " 4332,\n", + " 4333,\n", + " 4334,\n", + " 4335,\n", + " 4336,\n", + " 4337,\n", + " 4338,\n", + " 4339,\n", + " 4340,\n", + " 4341,\n", + " 4342,\n", + " 4343,\n", + " 4344,\n", + " 4345,\n", + " 4346,\n", + " 4347,\n", + " 4348,\n", + " 4349,\n", + " 4350,\n", + " 4351,\n", + " 4352,\n", + " 4353,\n", + " 4354,\n", + " 4355,\n", + " 4356,\n", + " 4357,\n", + " 4358,\n", + " 4359,\n", + " 4360,\n", + " 4361,\n", + " 4362,\n", + " 4363,\n", + " 4364,\n", + " 4365,\n", + " 4366,\n", + " 4367,\n", + " 4368,\n", + " 4369,\n", + " 4370,\n", + " 4371,\n", + " 4372,\n", + " 4373,\n", + " 4374,\n", + " 4375,\n", + " 4376,\n", + " 4377,\n", + " 4378,\n", + " 4379,\n", + " 4380,\n", + " 4381,\n", + " 4382,\n", + " 4383,\n", + " 4384,\n", + " 4385,\n", + " 4386,\n", + " 4387,\n", + " 4388,\n", + " 4389,\n", + " 4390,\n", + " 4391,\n", + " 4392,\n", + " 4393,\n", + " 4394,\n", + " 4395,\n", + " 4396,\n", + " 4397,\n", + " 4398,\n", + " 4399,\n", + " 4400,\n", + " 4401,\n", + " 4402,\n", + " 4403,\n", + " 4404,\n", + " 4405,\n", + " 4406,\n", + " 4407,\n", + " 4408,\n", + " 4409,\n", + " 4410,\n", + " 4411,\n", + " 4412,\n", + " 4413,\n", + " 4414,\n", + " 4415,\n", + " 4416,\n", + " 4417,\n", + " 4418,\n", + " 4419,\n", + " 4420,\n", + " 4421,\n", + " 4422,\n", + " 4423,\n", + " 4424,\n", + " 4425,\n", + " 4426,\n", + " 4427,\n", + " 4428,\n", + " 4429,\n", + " 4430,\n", + " 4431,\n", + " 4432,\n", + " 4433,\n", + " 4434,\n", + " 4435,\n", + " 4436,\n", + " 4437,\n", + " 4438,\n", + " 4439,\n", + " 4440,\n", + " 4441,\n", + " 4442,\n", + " 4443,\n", + " 4444,\n", + " 4445,\n", + " 4446,\n", + " 4447,\n", + " 4448,\n", + " 4449,\n", + " 4450,\n", + " 4451,\n", + " 4452,\n", + " 4453,\n", + " 4454,\n", + " 4455,\n", + " 4456,\n", + " 4457,\n", + " 4458,\n", + " 4459,\n", + " 4460,\n", + " 4461,\n", + " 4462,\n", + " 4463,\n", + " 4464,\n", + " 4465,\n", + " 4466,\n", + " 4467,\n", + " 4468,\n", + " 4469,\n", + " 4470,\n", + " 4471,\n", + " 4472,\n", + " 4473,\n", + " 4474,\n", + " 4475,\n", + " 4476,\n", + " 4477,\n", + " 4478,\n", + " 4479,\n", + " 4480,\n", + " 4481,\n", + " 4482,\n", + " 4483,\n", + " 4484,\n", + " 4485,\n", + " 4486,\n", + " 4487,\n", + " 4488,\n", + " 4489,\n", + " 4490,\n", + " 4491,\n", + " 4492,\n", + " 4493,\n", + " 4494,\n", + " 4495,\n", + " 4496,\n", + " 4497,\n", + " 4498,\n", + " 4499,\n", + " 4500,\n", + " 4501,\n", + " 4502,\n", + " 4503,\n", + " 4504,\n", + " 4505,\n", + " 4506,\n", + " 4507,\n", + " 4508,\n", + " 4509,\n", + " 4510,\n", + " 4511,\n", + " 4512,\n", + " 4513,\n", + " 4514,\n", + " 4515,\n", + " 4516,\n", + " 4517,\n", + " 4518,\n", + " 4519,\n", + " 4520,\n", + " 4521,\n", + " 4522,\n", + " 4523,\n", + " 4524,\n", + " 4525,\n", + " 4526,\n", + " 4527,\n", + " 4528,\n", + " 4529,\n", + " 4530,\n", + " 4531,\n", + " 4532,\n", + " 4533,\n", + " 4534,\n", + " 4535,\n", + " 4536,\n", + " 4537,\n", + " 4538,\n", + " 4539,\n", + " 4540,\n", + " 4541,\n", + " 4542,\n", + " 4543,\n", + " 4544,\n", + " 4545,\n", + " 4546,\n", + " 4547,\n", + " 4548,\n", + " 4549,\n", + " 4550,\n", + " 4551,\n", + " 4552,\n", + " 4553,\n", + " 4554,\n", + " 4555,\n", + " 4556,\n", + " 4557,\n", + " 4558,\n", + " 4559,\n", + " 4560,\n", + " 4561,\n", + " 4562,\n", + " 4563,\n", + " 4564,\n", + " 4565,\n", + " 4566,\n", + " 4567,\n", + " 4568,\n", + " 4569,\n", + " 4570,\n", + " 4571,\n", + " 4572,\n", + " 4573,\n", + " 4574,\n", + " 4575,\n", + " 4576,\n", + " 4577,\n", + " 4578,\n", + " 4579,\n", + " 4580,\n", + " 4581,\n", + " 4582,\n", + " 4583,\n", + " 4584,\n", + " 4585,\n", + " 4586,\n", + " 4587,\n", + " 4588,\n", + " 4589,\n", + " 4590,\n", + " 4591,\n", + " 4592,\n", + " 4593,\n", + " 4594,\n", + " 4595,\n", + " 4596,\n", + " 4597,\n", + " 4598,\n", + " 4599,\n", + " 4600,\n", + " 4601,\n", + " 4602,\n", + " 4603,\n", + " 4604,\n", + " 4605,\n", + " 4606,\n", + " 4607,\n", + " 4608,\n", + " 4609,\n", + " 4610,\n", + " 4611,\n", + " 4612,\n", + " 4613,\n", + " 4614,\n", + " 4615,\n", + " 4616,\n", + " 4617,\n", + " 4618,\n", + " 4619,\n", + " 4620,\n", + " 4621,\n", + " 4622,\n", + " 4623,\n", + " 4624,\n", + " 4625,\n", + " 4626,\n", + " 4627,\n", + " 4628,\n", + " 4629,\n", + " 4630,\n", + " 4631,\n", + " 4632,\n", + " 4633,\n", + " 4634,\n", + " 4635,\n", + " 4636,\n", + " 4637,\n", + " 4638,\n", + " 4639,\n", + " 4640,\n", + " 4641,\n", + " 4642,\n", + " 4643,\n", + " 4644,\n", + " 4645,\n", + " 4646,\n", + " 4647,\n", + " 4648,\n", + " 4649,\n", + " 4650,\n", + " 4651,\n", + " 4652,\n", + " 4653,\n", + " 4654,\n", + " 4655,\n", + " 4656,\n", + " 4657,\n", + " 4658,\n", + " 4659,\n", + " 4660,\n", + " 4661,\n", + " 4662,\n", + " 4663,\n", + " 4664,\n", + " 4665,\n", + " 4666,\n", + " 4667,\n", + " 4668,\n", + " 4669,\n", + " 4670,\n", + " 4671,\n", + " 4672,\n", + " 4673,\n", + " 4674,\n", + " 4675,\n", + " 4676,\n", + " 4677,\n", + " 4678,\n", + " 4679,\n", + " 4680,\n", + " 4681,\n", + " 4682,\n", + " 4683,\n", + " 4684,\n", + " 4685,\n", + " 4686,\n", + " 4687,\n", + " 4688,\n", + " 4689,\n", + " 4690,\n", + " 4691,\n", + " 4692,\n", + " 4693,\n", + " 4694,\n", + " 4695,\n", + " 4696,\n", + " 4697,\n", + " 4698,\n", + " 4699,\n", + " 4700,\n", + " 4701,\n", + " 4702,\n", + " 4703,\n", + " 4704,\n", + " 4705,\n", + " 4706,\n", + " 4707,\n", + " 4708,\n", + " 4709,\n", + " 4710,\n", + " 4711,\n", + " 4712,\n", + " 4713,\n", + " 4714,\n", + " 4715,\n", + " 4716,\n", + " 4717,\n", + " 4718,\n", + " 4719,\n", + " 4720,\n", + " 4721,\n", + " 4722,\n", + " 4723,\n", + " 4724,\n", + " 4725,\n", + " 4726,\n", + " ...]" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" } ], "source": [ - "molsys = msm.convert('traj.msmh5', to_form='molsysmt.MolSysNEW')" + "msm.select(molsys, 'chain_id==1', syntax='MolSysMT_NEW')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "6b43791f-3f3d-407b-b75a-3703e7462338", + "metadata": {}, + "outputs": [], + "source": [ + "msm.info(molsys)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "baf85aab-a8d8-43c3-b069-de8c5d4d576d", + "metadata": {}, + "outputs": [], + "source": [ + "import pandas as pd" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "da82aaeb-dc12-451f-b15e-b9ff08ed7759", + "metadata": {}, + "outputs": [], + "source": [ + "pd.merge(molsys.atoms, molsys.groups, left_on='group_index', right_index=True)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "44de835a-ce44-49db-a2f0-182950f43f82", + "metadata": {}, + "outputs": [], + "source": [ + "molsys.atoms.merge(molsys.groups, left_index=True)" ] }, { "cell_type": "code", "execution_count": null, - "id": "01a50298-338c-4bb8-9f77-a9658141dcba", + "id": "59fcc257-3374-47a8-9dc0-54adde4179f9", "metadata": {}, "outputs": [], "source": [] @@ -80,7 +1134,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.12" + "version": "3.10.13" } }, "nbformat": 4, diff --git a/sandbox/Test_remove_overlapping_molecules.ipynb b/sandbox/Test_remove_overlapping_molecules.ipynb index f14b2ee02..75459ef8f 100644 --- a/sandbox/Test_remove_overlapping_molecules.ipynb +++ b/sandbox/Test_remove_overlapping_molecules.ipynb @@ -315,7 +315,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.12" + "version": "3.10.13" } }, "nbformat": 4, diff --git a/sandbox/Test_selection.ipynb b/sandbox/Test_selection.ipynb index f323c1b42..0de4759f3 100644 --- a/sandbox/Test_selection.ipynb +++ b/sandbox/Test_selection.ipynb @@ -116,7 +116,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.12" + "version": "3.10.13" } }, "nbformat": 4,