diff --git a/.gitignore b/.gitignore index faacb393c..dacb509d6 100644 --- a/.gitignore +++ b/.gitignore @@ -120,4 +120,7 @@ devtools/playground/* !devtools/playground/README.md !molsysmt/build/* !molsysmt/docs/contents/build/* +todo.txt +# pycharm +.idea/ diff --git a/Untitled.ipynb b/Untitled.ipynb index 363fcab7e..b6f163519 100644 --- a/Untitled.ipynb +++ b/Untitled.ipynb @@ -1,6 +1,17 @@ { - "cells": [], + "cells": [ + { + "cell_type": "raw", + "source": [], + "metadata": { + "collapsed": false, + "pycharm": { + "name": "" + } + } + } + ], "metadata": {}, "nbformat": 4, "nbformat_minor": 5 -} +} \ No newline at end of file diff --git a/molsysmt/_private/atom_indices.py b/molsysmt/_private/atom_indices.py index 6fba59b97..eca60a75c 100644 --- a/molsysmt/_private/atom_indices.py +++ b/molsysmt/_private/atom_indices.py @@ -1,25 +1,22 @@ import numpy as np + def complementary_atom_indices(molecular_system, atom_indices): from molsysmt.basic import get n_atoms = get(molecular_system, element='system', n_atoms=True) - mask = np.ones(n_atoms,dtype=bool) - mask[atom_indices]=False + mask = np.ones(n_atoms, dtype=bool) + mask[atom_indices] = False return list(np.where(mask)[0]) + def atom_indices_to_AmberMask(molecular_system, atom_indices): from molsysmt.basic import get n_atoms = get(molecular_system, element='system', n_atoms=True) - mask = np.zeros(n_atoms,dtype=int) - mask[atom_indices]=1 + mask = np.zeros(n_atoms, dtype=int) + mask[atom_indices] = 1 return list(mask) - -def atom_indices_to_csv(atom_indices): - - return ",".join([str(ii) for ii in atom_indices]) - diff --git a/molsysmt/_private/digestion/__init__.py b/molsysmt/_private/digestion/__init__.py index 57fa38b67..60f8413af 100644 --- a/molsysmt/_private/digestion/__init__.py +++ b/molsysmt/_private/digestion/__init__.py @@ -1,20 +1,18 @@ -from .atom_indices import digest_atom_indices +from .argument import digest_argument from .box import digest_box -from .box import digest_box_lengths, digest_box_lengths_value -from .box import digest_box_angles, digest_box_angles_value +from .box import digest_box_vectors from .coordinates import digest_coordinates from .comparison import digest_comparison from .element import digest_element from .engine import digest_engine from .form import digest_form, digest_to_form -from .group_indices import digest_group_indices -from .indices import digest_indices +from .indices import digest_indices, digest_structure_indices, digest_multiple_structure_indices +from .indices import digest_atom_indices, digest_group_indices from .item import digest_item from .molecular_system import digest_single_molecular_system, digest_multiple_molecular_systems from .output import digest_output from .selection import digest_selection, digest_multiple_selections from .step import digest_step -from .structure_indices import digest_structure_indices, digest_multiple_structure_indices from .syntaxis import digest_syntaxis, digest_to_syntaxis from .element import digest_element from .time import digest_time diff --git a/molsysmt/_private/digestion/argument.py b/molsysmt/_private/digestion/argument.py new file mode 100644 index 000000000..ee0d99963 --- /dev/null +++ b/molsysmt/_private/digestion/argument.py @@ -0,0 +1,16 @@ +from molsysmt.attribute.attributes import attribute_synonyms, attributes +from ..exceptions import WrongGetArgumentError + + +def digest_argument(argument, element): + """ Helper function to check keyword arguments passed to get function. + """ + output_argument = argument.lower() + if output_argument in ['index', 'indices', 'name', 'names', 'id', 'ids', 'type', 'types', 'order']: + output_argument = '_'.join([element, output_argument]) + if output_argument in attribute_synonyms: + output_argument = attribute_synonyms[output_argument] + if output_argument in attributes: + return output_argument + else: + raise WrongGetArgumentError(argument) diff --git a/molsysmt/_private/digestion/atom_indices.py b/molsysmt/_private/digestion/atom_indices.py deleted file mode 100644 index fbe38890b..000000000 --- a/molsysmt/_private/digestion/atom_indices.py +++ /dev/null @@ -1,16 +0,0 @@ -import numpy as np - -def digest_atom_indices(atom_indices): - - if type(atom_indices)==str: - if atom_indices in ['all', 'All', 'ALL']: - atom_indices = 'all' - else: - raise ValueError() - elif type(atom_indices) in [int, np.int64, np.int32]: - atom_indices = np.array([atom_indices], dtype='int64') - elif hasattr(atom_indices, '__iter__'): - atom_indices = np.array(atom_indices, dtype='int64') - - return atom_indices - diff --git a/molsysmt/_private/digestion/box.py b/molsysmt/_private/digestion/box.py index a11f73469..8d1ccdebe 100644 --- a/molsysmt/_private/digestion/box.py +++ b/molsysmt/_private/digestion/box.py @@ -1,76 +1,72 @@ import numpy as np from molsysmt import puw -from ..exceptions import * +from ..exceptions import IncorrectShapeError -def digest_box(box): +def digest_box(box): + # TODO: Function doesn't do anything. return box -def digest_box_lengths_value(box_lengths): - - output = None - - if type(box_lengths) is not np.ndarray: - box_lengths = np.array(box_lengths) - - shape = box_lengths.shape - - if len(shape)==1: - if shape[0]==3: - output = np.expand_dims(box_lengths, axis=0) - else: - raise ValueError('box_lengths array with has not the correct shape.') - elif len(shape)==2: - if shape[1]==3: - output = box_lengths - else: - raise ValueError('box_lengths array with has not the correct shape.') - else: - raise ValueError('box_lengths array with has not the correct shape.') - - return output - -def digest_box_lengths(box_lengths): - - output = None - unit = puw.get_unit(box_lengths) - box_lengths_value = puw.get_value(box_lengths) - box_lengths_value = digest_box_lengths_value(box_lengths_value) - output = box_lengths_value*unit - return output +def digest_box_vectors_value(box_vectors): + """ Checks if box_vectors has the correct shape. -def digest_box_angles_value(box_angles): + The array should have shape (n, 3) where n is any integer. + However, if a list, tuple is passed it will be converted + to an array with the desired shape. Also, if an array of + shape (3, ) is passed its dimensions will be expanded to + (1, 3). If an array with rank > 2 is passed and exception + is raised. - output = None + Parameters + ---------- + box_vectors : np.ndarray, list or tuple + A quantity with the box lengths. - if type(box_angles) is not np.ndarray: - box_angles = np.array(box_angles) + Raises + ------ + IncorrectShapeError + If box_vectors doesn't have the correct shape. + """ + if not(isinstance(box_vectors, np.ndarray)): + box_vectors = np.array(box_vectors) - shape = box_angles.shape + shape = box_vectors.shape - if len(shape)==1: - if shape[0]==3: - output = np.expand_dims(box_angles, axis=0) + if len(shape) == 1: + if shape[0] == 3: + box_vectors = np.expand_dims(box_vectors, axis=0) else: - raise ValueError('box_angles array with has not the correct shape.') - elif len(shape)==2: - if shape[1]==3: - output = box_angles - else: - raise ValueError('box_angles array with has not the correct shape.') + raise IncorrectShapeError(expected_shape="(1, 3)", actual_shape=str(shape)) + elif len(shape) == 2: + if shape[1] != 3: + raise IncorrectShapeError(expected_shape="(n, 3)", actual_shape=str(shape)) else: - raise ValueError('box_angles array with has not the correct shape.') - - return output - -def digest_box_angles(box_angles): - - output = None - unit = puw.get_unit(box_angles) - box_angles_value = puw.get_value(box_angles) - box_angles_value = digest_box_angles_value(box_angles_value) - output = box_angles_value*unit - - return output - + raise IncorrectShapeError(expected_shape="(n, 3)", actual_shape=str(shape)) + + return box_vectors + + +def digest_box_vectors(box_vectors): + """ Checks if box vectors have the correct shape. Can be used + to check box_lengths and box_angles. + + Parameters + ---------- + box_vectors : puw.Quantity + A quantity with the box vectors. + + Returns + ------- + puw.Quantity + The box vectors with the shape corrected. + + Raises + ------ + IncorrectShapeError + If box_vectors doesn't have the correct shape. + """ + unit = puw.get_unit(box_vectors) + box_vectors = puw.get_value(box_vectors) + box_vectors = digest_box_vectors_value(box_vectors) + return box_vectors * unit diff --git a/molsysmt/_private/digestion/comparison.py b/molsysmt/_private/digestion/comparison.py index 6f041adb6..23b99ba93 100644 --- a/molsysmt/_private/digestion/comparison.py +++ b/molsysmt/_private/digestion/comparison.py @@ -2,7 +2,8 @@ from molsysmt import puw from ..exceptions import * -def digest_comparison(comparison): +def digest_comparison(comparison): + # TODO: function doesn't do anything return comparison diff --git a/molsysmt/_private/digestion/coordinates.py b/molsysmt/_private/digestion/coordinates.py index 900656527..e5df18c4d 100644 --- a/molsysmt/_private/digestion/coordinates.py +++ b/molsysmt/_private/digestion/coordinates.py @@ -1,6 +1,7 @@ from ..exceptions import * -def digest_coordinates(coordinates): +def digest_coordinates(coordinates): + # TODO: function doesn't do anything return coordinates diff --git a/molsysmt/_private/digestion/element.py b/molsysmt/_private/digestion/element.py index 1bc5ae218..19516a84f 100644 --- a/molsysmt/_private/digestion/element.py +++ b/molsysmt/_private/digestion/element.py @@ -1,4 +1,4 @@ -from ..exceptions import * +from ..exceptions import WrongElementError elements = [ 'atom', @@ -11,28 +11,40 @@ 'bond', ] -elements_from_plural={ - 'atoms' : 'atom', - 'groups' : 'group', - 'residue' : 'group', - 'residues' : 'group', - 'components' : 'component', - 'chains' : 'chain', - 'molecules' : 'molecule', - 'entities' : 'entity', - 'systems' : 'system', - 'bonds' : 'bond', +elements_from_plural = { + 'atoms': 'atom', + 'groups': 'group', + 'residue': 'group', + 'residues': 'group', + 'components': 'component', + 'chains': 'chain', + 'molecules': 'molecule', + 'entities': 'entity', + 'systems': 'system', + 'bonds': 'bond', } + def digest_element(element): + """ Helper function to check an element type. Raises a BadCallError + if the element type is not supported by MolSysMT. + + Parameters + ---------- + element : str + The name of the element. - try: - tmp_element = element.lower() - if tmp_element in elements_from_plural: - tmp_element = elements_from_plural[tmp_element] - elif tmp_element not in elements: - raise BadCallError() - return tmp_element - except: - raise BadCallError() + Raises + ------ + BadCallError + If the element is not a string or its name is not valid. + """ + if isinstance(element, str): + element_name_lower = element.lower() + if element_name_lower in elements_from_plural: + return elements_from_plural[element_name_lower] + if element_name_lower not in elements: + raise WrongElementError("wrong element name") + return element_name_lower + raise WrongElementError("element is not a string") diff --git a/molsysmt/_private/digestion/engine.py b/molsysmt/_private/digestion/engine.py index 229ea747e..eb115851f 100644 --- a/molsysmt/_private/digestion/engine.py +++ b/molsysmt/_private/digestion/engine.py @@ -1,4 +1,4 @@ -from ..exceptions import * +from ..exceptions import WrongEngineError engines = [ 'Amber', @@ -13,12 +13,26 @@ 'NGLView', ] -engines_from_lowercase={ ii.lower() : ii for ii in engines } +engines_from_lowercase = {ii.lower(): ii for ii in engines} + def digest_engine(engine): + """ Check the name of the engine. - try: - return engines_from_lowercase[engine.lower()] - except: - raise BadCallError() + Parameters + --------- + engine : str + The name of the engine + Raises + ------ + BadCallError + If the engine name is not valid. + """ + if isinstance(engine, str): + try: + return engines_from_lowercase[engine.lower()] + except KeyError: + # TODO: create a wrong engine error + raise WrongEngineError + raise WrongEngineError diff --git a/molsysmt/_private/digestion/form.py b/molsysmt/_private/digestion/form.py index db0b431e3..4ae12c080 100644 --- a/molsysmt/_private/digestion/form.py +++ b/molsysmt/_private/digestion/form.py @@ -1,25 +1,40 @@ from ..lists_and_tuples import is_list_or_tuple -from ..exceptions import * +from ..exceptions import WrongFormError + def digest_form(form): + """ Checks that the name of the form is correct and + returns its name capitalized. For example, if + form is mdanalysis.universe it returns mdanalysis.Universe. + + Parameters + ---------- + form: str or list[str] + The name or names of the forms + + Returns + ------- + str or list[str] + The name or names of the forms. + """ from molsysmt.api_forms import _dict_forms_lowercase from molsysmt.item import is_file if is_list_or_tuple(form): - output = [digest_form(ii) for ii in form] + return [digest_form(ii) for ii in form] else: if is_file(form): - output = form + return form else: - output = _dict_forms_lowercase[form.lower()] + try: + return _dict_forms_lowercase[form.lower()] + except KeyError: + raise WrongFormError(form) - return output def digest_to_form(to_form): if to_form is None: return None - else: - return digest_form(to_form) - + return digest_form(to_form) diff --git a/molsysmt/_private/digestion/group_indices.py b/molsysmt/_private/digestion/group_indices.py deleted file mode 100644 index e294111ef..000000000 --- a/molsysmt/_private/digestion/group_indices.py +++ /dev/null @@ -1,16 +0,0 @@ -import numpy as np - -def digest_group_indices(group_indices): - - if type(group_indices)==str: - if group_indices in ['all', 'All', 'ALL']: - group_indices = 'all' - else: - raise ValueError() - elif type(group_indices) in [int, np.int64, np.int32]: - group_indices = np.array([group_indices], dtype='int64') - elif hasattr(group_indices, '__iter__'): - group_indices = np.array(group_indices, dtype='int64') - - return group_indices - diff --git a/molsysmt/_private/digestion/indices.py b/molsysmt/_private/digestion/indices.py index eb379ca2d..029bd6eff 100644 --- a/molsysmt/_private/digestion/indices.py +++ b/molsysmt/_private/digestion/indices.py @@ -1,16 +1,62 @@ import numpy as np +from ..exceptions import WrongIndicesError +from ..lists_and_tuples import is_list_or_tuple + def digest_indices(indices): + """ Checks if indices are of the expected type and value. + + Parameters + ---------- + indices : str or int or list or tuple or range. + The indices + + Returns + ------- + str or np.ndarray + Either 'all' or an array with the indices. - if type(indices)==str: - if indices in ['all', 'All', 'ALL']: - indices = 'all' + Raises + ------- + WrongIndicesError + If the given indices are not of the correct type. + """ + if indices is None: + return + + if isinstance(indices, str): + if indices.lower() == 'all': + return 'all' else: - raise ValueError() - elif type(indices) in [int, np.int64, np.int32]: + raise WrongIndicesError + elif isinstance(indices, (int, np.int64, np.int32)): indices = np.array([indices], dtype='int64') - elif hasattr(indices, '__iter__'): + elif isinstance(indices, (np.ndarray, list, tuple, range)): indices = np.array(indices, dtype='int64') + else: + raise WrongIndicesError return indices + +def digest_atom_indices(atom_indices): + """ Checks if atom indices are of the expected type and value. """ + return digest_indices(atom_indices) + + +def digest_group_indices(group_indices): + """ Checks if group indices are of the expected type and value. """ + return digest_indices(group_indices) + + +def digest_structure_indices(structure_indices): + """ Checks if structure indices are of the expected type and value. """ + return digest_indices(structure_indices) + + +def digest_multiple_structure_indices(structure_indices): + """ Checks multiple structure indices. """ + if is_list_or_tuple(structure_indices): + return [digest_structure_indices(ii) for ii in structure_indices] + else: + return digest_structure_indices(structure_indices) diff --git a/molsysmt/_private/digestion/item.py b/molsysmt/_private/digestion/item.py index 846bd9f8c..cf6ea72de 100644 --- a/molsysmt/_private/digestion/item.py +++ b/molsysmt/_private/digestion/item.py @@ -1,13 +1,32 @@ from ..exceptions import WrongFormError + def digest_item(item, form): + """ Check if an item hsa the expected form. + + Examples + -------- + >>> from Bio.Seq import Seq + >>> sequence = Seq("ATA") + >>> digest_item(item=sequence, form="biopython.Seq") + + Parameters + ---------- + item : obj + An instance of one of the forms supported by MolSysMT. + + form : str + Name of the form + Raises + ------ + WrongFormError + If the item form is not the given form. + + """ from molsysmt.api_forms import dict_is_form try: dict_is_form[form](item) - except: + except KeyError: raise WrongFormError(form) - - pass - diff --git a/molsysmt/_private/digestion/output.py b/molsysmt/_private/digestion/output.py index 71841548a..2f94d234a 100644 --- a/molsysmt/_private/digestion/output.py +++ b/molsysmt/_private/digestion/output.py @@ -1,10 +1,12 @@ from ..lists_and_tuples import is_list_or_tuple -def digest_output(output): +def digest_output(output): + """ If 'output is a list or tuple with a single element, it returns that + element. If not it returns the original 'output'. + """ if is_list_or_tuple(output): - if len(output)==1: + if len(output) == 1: output = output[0] return output - diff --git a/molsysmt/_private/digestion/selection.py b/molsysmt/_private/digestion/selection.py index 46b40a7ae..dc639a700 100644 --- a/molsysmt/_private/digestion/selection.py +++ b/molsysmt/_private/digestion/selection.py @@ -1,38 +1,21 @@ +from ..exceptions import WrongSelectionError +from ..lists_and_tuples import is_list_or_tuple -def digest_selection(selection, syntaxis="MolSysMT"): - - from ..exceptions import WrongSelectionError - - try: - - if type(selection) is str: - - from .syntaxis import digest_syntaxis - syntaxis = digest_syntaxis(syntaxis) - if syntaxis=='MolSysMT': - - selection=selection.replace('backbone', '(atom_name==["CA", "N", "C", "O"])') - - return selection - - except: +def digest_selection(selection, syntaxis="MolSysMT"): + """ Checks if a given selection is of the expected type. + """ + # TODO: this function may not check for all selection types. + if isinstance(selection, str): + from .syntaxis import digest_syntaxis + syntaxis = digest_syntaxis(syntaxis) + if syntaxis == 'MolSysMT': + selection = selection.replace('backbone', '(atom_name==["CA", "N", "C", "O"])') + return selection - raise WrongSelectionError() def digest_multiple_selections(selections, syntaxis="MolSysMT"): - - from ..lists_and_tuples import is_list_or_tuple - - output = None - if is_list_or_tuple(selections): - - output = [digest_selection(ii) for ii in selections] - + return [digest_selection(ii, syntaxis) for ii in selections] else: - - output = digest_selection(selections) - - return output - + return digest_selection(selections, syntaxis) diff --git a/molsysmt/_private/digestion/structure_indices.py b/molsysmt/_private/digestion/structure_indices.py deleted file mode 100644 index cc2b5b7bc..000000000 --- a/molsysmt/_private/digestion/structure_indices.py +++ /dev/null @@ -1,33 +0,0 @@ -import numpy as np - -def digest_structure_indices(structure_indices): - - if type(structure_indices)==str: - if structure_indices in ['all', 'All', 'ALL']: - structure_indices = 'all' - else: - raise ValueError() - elif type(structure_indices) in [int, np.int64, np.int32]: - structure_indices = np.array([structure_indices], dtype='int64') - elif hasattr(structure_indices, '__iter__'): - structure_indices = np.array(structure_indices, dtype='int64') - else: - raise ValueError() - return structure_indices - -def digest_multiple_structure_indices(structure_indices): - - from ..lists_and_tuples import is_list_or_tuple - - output = None - - if is_list_or_tuple(structure_indices): - - output = [digest_structure_indices(ii) for ii in structure_indices] - - else: - - output = digest_structure_indices(structure_indices) - - return output - diff --git a/molsysmt/_private/digestion/syntaxis.py b/molsysmt/_private/digestion/syntaxis.py index aa3bdbec9..5fdf2f24c 100644 --- a/molsysmt/_private/digestion/syntaxis.py +++ b/molsysmt/_private/digestion/syntaxis.py @@ -8,17 +8,24 @@ 'NGLView', ] -syntaxis_from_lower = { ii.lower():ii for ii in syntaxis } +syntaxis_from_lower = {ii.lower(): ii for ii in syntaxis} -def digest_syntaxis(syntaxis): +def digest_syntaxis(syntaxis): + """ Helper function to check if the given syntaxis is supported by + MolSysMt. + """ from ..exceptions import WrongSyntaxisError + if not isinstance(syntaxis, str): + raise WrongSyntaxisError("syntaxis must be a string.") + try: syntaxis = syntaxis_from_lower[syntaxis.lower()] return syntaxis - except: - raise WrongSyntaxisError() + except KeyError: + raise WrongSyntaxisError(f"{syntaxis} is not a valid syntaxis.") + def digest_to_syntaxis(to_syntaxis): diff --git a/molsysmt/_private/exceptions/__init__.py b/molsysmt/_private/exceptions/__init__.py index 22f9082c9..17c9caa6a 100644 --- a/molsysmt/_private/exceptions/__init__.py +++ b/molsysmt/_private/exceptions/__init__.py @@ -1,29 +1,25 @@ from .bad_call_error import BadCallError -from .library_not_found_error import LibraryNotFoundError -from .not_implemented_engine_error import NotImplementedEngineError -from .not_with_this_molecular_system_error import NotWithThisMolecularSystemError -from .not_implemented_form_error import NotImplementedFormError -from .not_implemented_method_error import NotImplementedMethodError -from .not_implemented_syntaxis_error import NotImplementedSyntaxisError -from .not_implemented_class_error import NotImplementedClassError -from .not_supported_form_error import NotSupportedFormError -from .not_implemented_conversion_error import NotImplementedConversionError -from .not_with_this_form_error import NotWithThisFormError -from .molecular_system_needed_error import MolecularSystemNeededError -from .multiple_molecular_system_needed_error import MultipleMolecularSystemsNeededError -from .wrong_get_argument_error import WrongGetArgumentError -from .wrong_syntaxis_error import WrongSyntaxisError -from .wrong_atom_indices_error import WrongAtomIndicesError -from .wrong_indices_error import WrongIndicesError -from .wrong_element_error import WrongElementError -from .wrong_box_error import WrongBoxError -from .wrong_output_filename_error import WrongOutputFilenameError -from .wrong_time_error import WrongTimeError -from .wrong_comparison_error import WrongComparisonError -from .wrong_selection_error import WrongSelectionError -from .wrong_to_form_error import WrongToFormError -from .wrong_coordinates_error import WrongCoordinatesError -from .wrong_step_error import WrongStepError -from .wrong_form_error import WrongFormError -from .wrong_structure_indices_error import WrongStructureIndicesError - +from .not_implemented_errors import LibraryNotFoundError +from .not_implemented_errors import NotImplementedMethodError +from .not_implemented_errors import NotImplementedSyntaxisError +from .not_implemented_errors import NotImplementedConversionError +from .value_errors import IncorrectShapeError +from .value_errors import NotSupportedFormError +from .value_errors import NotWithThisFormError +from .value_errors import MolecularSystemNeededError +from .value_errors import MultipleMolecularSystemsNeededError +from .value_errors import NotWithThisMolecularSystemError +from .value_errors import WrongElementError +from .value_errors import WrongEngineError +from .value_errors import WrongGetArgumentError +from .value_errors import WrongSyntaxisError +from .value_errors import WrongAtomIndicesError +from .value_errors import WrongIndicesError +from .value_errors import WrongOutputFilenameError +from .value_errors import WrongTimeError +from .value_errors import WrongComparisonError +from .value_errors import WrongSelectionError +from .value_errors import WrongToFormError +from .value_errors import WrongStepError +from .value_errors import WrongFormError +from .value_errors import WrongStructureIndicesError diff --git a/molsysmt/_private/exceptions/library_not_found_error.py b/molsysmt/_private/exceptions/library_not_found_error.py deleted file mode 100644 index 02a7787e1..000000000 --- a/molsysmt/_private/exceptions/library_not_found_error.py +++ /dev/null @@ -1,59 +0,0 @@ -class LibraryNotFoundError(NotImplementedError): - """Exception raised when a library required by the user is not found. - - Some libraries are not considered as dependencies by Sabueso. These libraries are required if - the user choose to execute a method with a not default engine. In this case, the user hat to - install it previousy. It that's not the case, the method will raise this exceptions suggesting - the manual installation. - - Parameters - ---------- - argument : str - The name of the not found library. - - Raises - ------ - LibraryNotFoundError - A message is printed out with the name of the class or the method raising the exception, - the name of the not found library, the link to the API documentation, and the link to the - issues board of Sabueso's GitHub repository. - - Examples - -------- - >>> from molsysmt._private.exceptions import LibraryNotFoundError - >>> def method_name(item, engine='MolSysMT'): - ... if engine == 'OpenMM': - ... try: - ... import openmm - ... except: - ... raise LibraryNotFoundError('OpenMM') - ... pass - - .. admonition:: See Also - :class: attention - - :ref:`Developer Guide \> Exceptions \> LibraryNotFoundError ` - - """ - - def __init__(self, library): - - from molsysmt import __github_issues_web__ - from inspect import stack - - all_stack_frames = stack() - caller_stack_frame = all_stack_frames[1] - caller_name = caller_stack_frame[3] - - api_doc = '' - - message = ( - f"The python library {library} was not found. " - f"Although {library} is not considered a dependency, it needs " - f"to be installed to execute the {caller_name} method the way you require. " - f"If you still need help, open a new issue in {__github_issues_web__}." - ) - - super().__init__(message) - - diff --git a/molsysmt/_private/exceptions/molecular_system_needed_error.py b/molsysmt/_private/exceptions/molecular_system_needed_error.py deleted file mode 100644 index 5dcadba23..000000000 --- a/molsysmt/_private/exceptions/molecular_system_needed_error.py +++ /dev/null @@ -1,13 +0,0 @@ -class MolecularSystemNeededError(ValueError): - def __init__(self, message=None): - if message is None: - message = ( - f"The method \"{caller_name}\" works over a molecular system. " - f"Either no molecular system or multiple systems were provided." - f"Check {api_doc} for more information. " - f"Write a new issue in {__github_issues_web__} asking for its implementation." - ) - - super().__init__(message) - - diff --git a/molsysmt/_private/exceptions/multiple_molecular_system_needed_error.py b/molsysmt/_private/exceptions/multiple_molecular_system_needed_error.py deleted file mode 100644 index 3386f9fa1..000000000 --- a/molsysmt/_private/exceptions/multiple_molecular_system_needed_error.py +++ /dev/null @@ -1,7 +0,0 @@ -class MultipleMolecularSystemsNeededError(ValueError): - def __init__(self, message=None): - if message is None: - message = 'This method works only over a single molecular system. But multiple molecular systems are provided.' - super().__init__(message) - - diff --git a/molsysmt/_private/exceptions/not_implemented_class_error.py b/molsysmt/_private/exceptions/not_implemented_class_error.py deleted file mode 100644 index 5e64c77e3..000000000 --- a/molsysmt/_private/exceptions/not_implemented_class_error.py +++ /dev/null @@ -1,54 +0,0 @@ -class NotImplementedClassError(NotImplementedError): - """Exception raised when a class has not been fully implemented yet. - - This exception is raised when a class has being already defined but its code was not fully - implemented yet. Maybe the class was just included in a developing version to be coded in the - future. Or maybe the class can be instantated already for certain values of the input - arguments, but not for others yet. - - Note - ---- - This exception does not require input arguments. - - Raises - ------ - NotImplementedClassError - A message is printed out with the name of the class raising the exception, the link to - the API documentation, and the link to the issues board of Sabueso's GitHub repository. - - Examples - -------- - >>> from molsysmt._private.exceptions import NotImplementedClassError - >>> class ClassName(): - ... def __init__(self): - ... raise NotImplementedClassError - ... pass - - .. admonition:: See Also - :class: attention - - :ref:`Developer Guide \> Exceptions \> NotImplementedClassError ` - - """ - - def __init__(self): - - from molsysmt import __github_issues_web__ - from inspect import stack - - all_stack_frames = stack() - caller_stack_frame = all_stack_frames[1] - caller_name = caller_stack_frame[3] - - api_doc = '' - - message = ( - f"The \"{caller_name}\" class has not been implemented yet in the way you are using it. " - f"Check {api_doc} for more information. " - f"If you still want to suggest its implementation, open a new issue in {__github_issues_web__}." - ) - - super().__init__(message) - - - diff --git a/molsysmt/_private/exceptions/not_implemented_conversion_error.py b/molsysmt/_private/exceptions/not_implemented_conversion_error.py deleted file mode 100644 index d107ce0eb..000000000 --- a/molsysmt/_private/exceptions/not_implemented_conversion_error.py +++ /dev/null @@ -1,60 +0,0 @@ -class NotImplementedConversionError(NotImplementedError): - - """Exception raised when the conversion between two forms was not implemented yet. - - This exception is raised when the conversion of a molecular system between two forms has not - been implemented yet. - - Parameters - ---------- - from_form : str - The form of the molecular system to be converted. - to_form : str - The target form to which the molecular system needs to be converted. - - Raises - ------ - NotImplementedFormError - A message is printed out with the name of the two forms defining the not supported conversion, the name of the class or - the method raising the exception, the link to the API documentation, and the link to the - issues board of Sabueso's GitHub repository. - - Examples - -------- - >>> from molsysmt._private.exceptions import NotImplementedConversionError - >>> def method_name(molecular_system, to_form): - ... from molsysmt.basic import get_form - ... from_form = get_form(molecular_system) - ... if from_form in ['string_pdb']: - ... if to_form in ['file_pdb']: - ... raise NotImplementedConversionError(from_form, to_form) - ... pass - - .. admonition:: See Also - :class: attention - - :ref:`Developer Guide \> Exceptions \> NotImplementedConversionError ` - - """ - - def __init__(self, from_form, to_form): - - from molsysmt import __github_issues_web__ - from inspect import stack - - all_stack_frames = stack() - caller_stack_frame = all_stack_frames[1] - caller_name = caller_stack_frame[3] - - api_doc = '' - - message = ( - f"The conversion from {from_form} to {to_form} in \"{caller_name}\" has not been implemented yet. " - f"Check {api_doc} for more information. " - f"Write a new issue in {__github_issues_web__} asking for its implementation." - ) - - super().__init__(message) - - - diff --git a/molsysmt/_private/exceptions/not_implemented_engine_error.py b/molsysmt/_private/exceptions/not_implemented_engine_error.py deleted file mode 100644 index 7f96ffe28..000000000 --- a/molsysmt/_private/exceptions/not_implemented_engine_error.py +++ /dev/null @@ -1,53 +0,0 @@ -class NotImplementedEngineError(NotImplementedError): - - """Exception raised when executing a method with a specific engine is not supported yet. - - This exception is raised when a method can not be executed with the selected engine by the user. - - Parameters - ---------- - engine : str - The engine not supported yet. - - Raises - ------ - NotImplementedFormError - A message is printed out with the name of the engine not supported, the name of the class or - the method raising the exception, the link to the API documentation, and the link to the - issues board of Sabueso's GitHub repository. - - Examples - -------- - >>> from molsysmt._private.exceptions import NotImplementedEngineError - >>> def method_name(engine): - ... if engine not in ['MolSysMT', 'MDTraj']: - ... raise NotImplementedEngineError(engine) - ... pass - - .. admonition:: See Also - :class: attention - - :ref:`Developer Guide \> Exceptions \> NotImplementedEngineError ` - - """ - - def __init__(self, syntaxis): - - from molsysmt import __github_issues_web__ - from inspect import stack - - all_stack_frames = stack() - caller_stack_frame = all_stack_frames[1] - caller_name = caller_stack_frame[3] - - api_doc = '' - - message = ( - f"The \"{engine}\" engine in \"{caller_name}\" has not been implemented yet. " - f"Check {api_doc} for more information. " - f"Write a new issue in {__github_issues_web__} asking for its implementation." - ) - - super().__init__(message) - - diff --git a/molsysmt/_private/exceptions/not_implemented_errors.py b/molsysmt/_private/exceptions/not_implemented_errors.py new file mode 100644 index 000000000..c8a36b8f5 --- /dev/null +++ b/molsysmt/_private/exceptions/not_implemented_errors.py @@ -0,0 +1,54 @@ + +__github_web__ = 'https://github.com/uibcdf/MolSysMT' +__github_issues_web__ = __github_web__ + '/issues' +api_doc = '' + + +class MolSysNotImplementedError(ValueError): + """ Base class for not implemented errors. """ + + def __init__(self, message=None): + if message is None: + message = "" + + message += ( + "The method has not been implemented yet. " + f" Check {api_doc} for more information. " + f"Write a new issue in {__github_issues_web__} asking for its implementation." + ) + super().__init__(message) + + +class NotImplementedConversionError(MolSysNotImplementedError): + pass + + +class NotImplementedMethodError(MolSysNotImplementedError): + pass + + +class NotImplementedSyntaxisError(MolSysNotImplementedError): + pass + + +class NotImplementedConversionError(MolSysNotImplementedError): + pass + + +class LibraryNotFoundError(MolSysNotImplementedError): + """ Exception raised when a library required by the user is not found. + + Some libraries are not considered as dependencies by Sabueso. These libraries are required if + the user choose to execute a method with a not default engine. In this case, the user hat to + install it previous. It that's not the case, the method will raise these exceptions suggesting + the manual installation. + """ + + def __init__(self, library): + + message = ( + f"The python library {library} was not found. " + f"If you still need help, open a new issue in {__github_issues_web__}." + ) + + super().__init__(message) diff --git a/molsysmt/_private/exceptions/not_implemented_form_error.py b/molsysmt/_private/exceptions/not_implemented_form_error.py deleted file mode 100644 index 9b0bae6a5..000000000 --- a/molsysmt/_private/exceptions/not_implemented_form_error.py +++ /dev/null @@ -1,57 +0,0 @@ -class NotImplementedFormError(NotImplementedError): - """Exception raised when a method or a class does not support a specific item's form yet. - - This exception is raised when a method or a class should be able to work with an item's form, - but it has not been implemented yet. For instance, a method gets the number of atoms of a - molecular system, but the current version works over a pdb file but not yet over a mol file. In - this case this exception should be rised when the input argument is a mol file. - - Parameters - ---------- - form : str - The item's form not supported yet by the class or method raising the exception. - - Raises - ------ - NotImplementedFormError - A message is printed out with the name of the not supported form, the name of the class or - the method raising the exception, the link to the API documentation, and the link to the - issues board of Sabueso's GitHub repository. - - Examples - -------- - >>> from molsysmt._private.exceptions import NotImplementedFormError - >>> from molsysmt import get_form - >>> def method_name(item): - ... input_form = get_form(item) - ... if input_form not in ['file:pdb', 'string:pdb_id', 'string:pdb_text']: - ... raise NotImplementedFormError(input_form) - ... pass - - .. admonition:: See Also - :class: attention - - :ref:`Developer Guide \> Exceptions \> NotImplementedFormError ` - - """ - - def __init__(self, form): - - from molsysmt import __github_issues_web__ - from inspect import stack - - all_stack_frames = stack() - caller_stack_frame = all_stack_frames[1] - caller_name = caller_stack_frame[3] - - api_doc = '' - - message = ( - f"The \"{form}\" form has not been implemeted yet in \"{caller_name}\". " - f"Check {api_doc} for more information. " - f"Write a new issue in {__github_issues_web__} asking for its implementation." - ) - - super().__init__(message) - - diff --git a/molsysmt/_private/exceptions/not_implemented_method_error.py b/molsysmt/_private/exceptions/not_implemented_method_error.py deleted file mode 100644 index 89c8f007b..000000000 --- a/molsysmt/_private/exceptions/not_implemented_method_error.py +++ /dev/null @@ -1,51 +0,0 @@ -class NotImplementedMethodError(NotImplementedError): - """Exception raised when a method has not been fully implemented yet. - - This exception is raised when a method has been already defined but its code was not fully - implemented yet. Maybe the method was just included in a developing version to be coded in the - future. Or maybe the method works already for certain values of the input arguments, but not - for others yet. - - Note - ---- - This exception does not require input arguments. - - Raises - ------ - NotImplementedMethodError - A message is printed out with the name of the method raising the exception, the link to - the API documentation, and the link to the issues board of Sabueso's GitHub repository. - - Examples - -------- - >>> from molsysmt._private.exceptions import NotImplementedMethodError - >>> def method_name(a, b=True): - ... raise NotImplementedMethodError - ... pass - - .. admonition:: See Also - :class: attention - - :ref:`Developer Guide \> Exceptions \> NotImplementedMethodError ` - - """ - - def __init__(self): - - from molsysmt import __github_issues_web__ - from inspect import stack - - all_stack_frames = stack() - caller_stack_frame = all_stack_frames[1] - caller_name = caller_stack_frame[3] - - api_doc = '' - - message = ( - f"The \"{caller_name}\" method has not been implemented yet in the way you are using it. " - f"Check {api_doc} for more information. " - f"If you still want to suggest its implementation, open a new issue in {__github_issues_web__}" - ) - - super().__init__(message) - diff --git a/molsysmt/_private/exceptions/not_implemented_syntaxis_error.py b/molsysmt/_private/exceptions/not_implemented_syntaxis_error.py deleted file mode 100644 index 31a4afd79..000000000 --- a/molsysmt/_private/exceptions/not_implemented_syntaxis_error.py +++ /dev/null @@ -1,53 +0,0 @@ -class NotImplementedSyntaxisError(NotImplementedError): - - """Exception raised when a syntaxis is not supported yet. - - This exception is raised when a syntaxis not supported yet has been selected by the user. - - Parameters - ---------- - syntaxis : str - The syntaxis not supported yet. - - Raises - ------ - NotImplementedFormError - A message is printed out with the name of the syntaxis not supported, the name of the class or - the method raising the exception, the link to the API documentation, and the link to the - issues board of Sabueso's GitHub repository. - - Examples - -------- - >>> from molsysmt._private.exceptions import NotImplementedSyntaxisError - >>> def method_name(syntaxis): - ... if syntaxis not in ['MolSysMT', 'MDTraj']: - ... raise NotImplementedSyntaxisError(syntaxis) - ... pass - - .. admonition:: See Also - :class: attention - - :ref:`Developer Guide \> Exceptions \> NotImplementedSyntaxisError ` - - """ - - def __init__(self, syntaxis): - - from molsysmt import __github_issues_web__ - from inspect import stack - - all_stack_frames = stack() - caller_stack_frame = all_stack_frames[1] - caller_name = caller_stack_frame[3] - - api_doc = '' - - message = ( - f"The \"{syntaxis}\" syntaxis in \"{caller_name}\" has not been implemented yet. " - f"Check {api_doc} for more information. " - f"Write a new issue in {__github_issues_web__} asking for its implementation." - ) - - super().__init__(message) - - diff --git a/molsysmt/_private/exceptions/not_supported_form_error.py b/molsysmt/_private/exceptions/not_supported_form_error.py deleted file mode 100644 index 5dd60e474..000000000 --- a/molsysmt/_private/exceptions/not_supported_form_error.py +++ /dev/null @@ -1,51 +0,0 @@ -class NotSupportedFormError(ValueError): - """Exception raised when the item's form is unknown and thereby not supported. - - This exception is raised when Sabueso does not recognize the item as a supported form. - - Note - ---- - This exception does not require input arguments. - - Raises - ------ - NotSupportedFormError - A message is printed out with the name of the class or the method raising the exception, - the link to the API documentation with the list of supported forms, and the link to the - issues board of Sabueso's GitHub repository. - - Examples - -------- - >>> from molsysmt._private.exceptions import NotSupportedFormError - >>> from molsysmt import get_form - >>> try: - ... _ = get_form(item) - ... except: - ... raise NotSupportedFormError - - .. admonition:: See Also - :class: attention - - :ref:`Developer Guide \> Exceptions \> NotSupportedFormError ` - - """ - - def __init__(self, form_type): - - from molsysmt import __github_issues_web__ - from inspect import stack - - all_stack_frames = stack() - caller_stack_frame = all_stack_frames[1] - caller_name = caller_stack_frame[3] - - api_doc = '' - - message = ( - f"The input molecular system or item in \"{caller_name}\" has a not supported form: {form_type} " - f"Check {api_doc} for more information. " - f"If you still need help, open a new issue in {__github_issues_web__}." - ) - - super().__init__(message) - diff --git a/molsysmt/_private/exceptions/not_with_this_form_error.py b/molsysmt/_private/exceptions/not_with_this_form_error.py deleted file mode 100644 index ae86423f1..000000000 --- a/molsysmt/_private/exceptions/not_with_this_form_error.py +++ /dev/null @@ -1,57 +0,0 @@ -class NotWithThisFormError(ValueError): - """Exception raised when a method or a class can not accept a specific item's form -by no means-. - - This exception is raised when a method or a class should be able to work with an item's form, - but it has not been implemented yet. For instance, the method used to get the value of the - dihedral angle defined by four atoms can not work over a GROMACS topology file (.top). In this - case the method will raise a 'NotWithTisFormError' exception. - - Parameters - ---------- - form : str - The item's form not accepted by the method or class raising the exception. - - Raises - ------ - NotWithThisFormError - A message is printed out with the name of the not supported form, the name of the class or - the method raising the exception, the link to the API documentation, and the link to the - issues board of Sabueso's GitHub repository. - - Examples - -------- - >>> from molsysmt._private.exceptions import NotWithThisFormError - >>> from molsysmt import get_form - >>> def method_name(item): - ... input_form = get_form(item) - ... if input_form not in ['file:top', 'file:prmtop']: - ... raise NotWithThisFormError(input_form) - ... pass - - .. admonition:: See Also - :class: attention - - :ref:`Developer Guide \> Exceptions \> NotWithThisFormError ` - - """ - - def __init__(self, form): - - from molsysmt import __github_issues_web__ - from inspect import stack - - all_stack_frames = stack() - caller_stack_frame = all_stack_frames[1] - caller_name = caller_stack_frame[3] - - api_doc = '' - - message = ( - f"\"{caller_name}\" does not work with {form} items. " - f"Check {api_doc} for more information. " - f"If you still need help, open a new issue in {__github_issues_web__}." - ) - - super().__init__(message) - - diff --git a/molsysmt/_private/exceptions/not_with_this_molecular_system_error.py b/molsysmt/_private/exceptions/not_with_this_molecular_system_error.py deleted file mode 100644 index 75f384088..000000000 --- a/molsysmt/_private/exceptions/not_with_this_molecular_system_error.py +++ /dev/null @@ -1,7 +0,0 @@ -class NotWithThisMolecularSystemError(ValueError): - def __init__(self, message=None): - if message is None: - message = 'This method can not be applied over this molecular system.' - super().__init__(message) - - diff --git a/molsysmt/_private/exceptions/value_errors.py b/molsysmt/_private/exceptions/value_errors.py new file mode 100644 index 000000000..4b08adabf --- /dev/null +++ b/molsysmt/_private/exceptions/value_errors.py @@ -0,0 +1,147 @@ + +__github_web__ = 'https://github.com/uibcdf/MolSysMT' +__github_issues_web__ = __github_web__ + '/issues' +api_doc = '' + + +class MolSysValueError(ValueError): + """ Base class for value errors. """ + + def __init__(self, message=None): + if message is None: + message = "" + + message += ( + f" Check {api_doc} for more information. " + f"If you still need help, open a new issue in {__github_issues_web__}." + ) + super().__init__(message) + + +class NotWithThisMolecularSystemError(MolSysValueError): + """ Error raised when trying to call a function that does not accept + the given type of molecular system. + """ + + def __init__(self, message=None): + if message is None: + message = 'This method can not be applied over this molecular system. ' + super().__init__(message) + + +class MolecularSystemNeededError(MolSysValueError): + def __init__(self, message=None): + if message is None: + message = ( f"The method works over a molecular system. " + f"Either no molecular system or multiple systems were provided.") + super().__init__(message) + + +class MultipleMolecularSystemsNeededError(MolSysValueError): + def __init__(self, message=None): + if message is None: + message = ('This method works only over a single molecular system. ' + 'But multiple molecular systems are provided. ') + super().__init__(message) + + +class NotSupportedFormError(MolSysValueError): + """ Exception raised when the item's form is unknown and thereby not supported. + + This exception is raised when Sabueso does not recognize the item as a supported form. + """ + def __init__(self, form_type): + message = f"The input molecular system or item has a not supported form: {form_type} " + super().__init__(message) + + +class NotWithThisFormError(MolSysValueError): + """ Exception raised when a method or a class can not accept a specific item's form -by no means-. + + This exception is raised when a method or a class should be able to work with an item's form, + but it has not been implemented yet. For instance, the method used to get the value of the + dihedral angle defined by four atoms can not work over a GROMACS topology file (.top). In this + case the method will raise a 'NotWithTisFormError' exception. + """ + def __init__(self, form): + message = f"Invalid form: {form} " + super().__init__(message) + + +class WrongGetArgumentError(MolSysValueError): + """ Exception raised when the get method is called with a not valid input argument. + """ + def __init__(self, argument=None): + message = f"The get method was invoked with not valid input argument: \"{argument}\"" + super().__init__(message) + +# TODO: WrongFormError and NotWithThisFormError are redundant. + + +class WrongFormError(MolSysValueError): + """Exception raised when the item has not the correct form expected by a method or a class. + """ + def __init__(self, form): + message = f"The input item's should be {form} and is not. " + super().__init__(message) + + +class WrongAtomIndicesError(MolSysValueError): + pass + + +class WrongSelectionError(MolSysValueError): + pass + + +class WrongIndicesError(MolSysValueError): + pass + + +class WrongOutputFilenameError(MolSysValueError): + pass + + +class WrongComparisonError(MolSysValueError): + pass + + +class WrongStepError(MolSysValueError): + pass + + +class WrongStructureIndicesError(MolSysValueError): + pass + + +class WrongSyntaxisError(MolSysValueError): + pass + + +class WrongTimeError(MolSysValueError): + pass + + +class WrongToFormError(MolSysValueError): + pass + + +class WrongElementError(MolSysValueError): + pass + + +class WrongEngineError(MolSysValueError): + pass + + +class IncorrectShapeError(MolSysValueError): + """Exception raised when a quantity or array doesn't have the correct shape. + """ + + def __init__(self, expected_shape=None, actual_shape=None): + message = "" + if expected_shape: + message = f"Expected shape {expected_shape}. " + if actual_shape: + message += f"Actual shape {actual_shape}. " + super().__init__(message) diff --git a/molsysmt/_private/exceptions/wrong_atom_indices_error.py b/molsysmt/_private/exceptions/wrong_atom_indices_error.py deleted file mode 100644 index 7926c9eea..000000000 --- a/molsysmt/_private/exceptions/wrong_atom_indices_error.py +++ /dev/null @@ -1,7 +0,0 @@ -class WrongAtomIndicesError(ValueError): - def __init__(self, message=None): - if message is None: - message = '' - super().__init__(message) - - diff --git a/molsysmt/_private/exceptions/wrong_box_error.py b/molsysmt/_private/exceptions/wrong_box_error.py deleted file mode 100644 index c9bc13a0c..000000000 --- a/molsysmt/_private/exceptions/wrong_box_error.py +++ /dev/null @@ -1,6 +0,0 @@ -class WrongBoxError(ValueError): - def __init__(self, message=None): - if message is None: - message = '' - super().__init__(message) - diff --git a/molsysmt/_private/exceptions/wrong_comparison_error.py b/molsysmt/_private/exceptions/wrong_comparison_error.py deleted file mode 100644 index 2f924a32e..000000000 --- a/molsysmt/_private/exceptions/wrong_comparison_error.py +++ /dev/null @@ -1,7 +0,0 @@ -class WrongComparisonError(ValueError): - def __init__(self, message=None): - if message is None: - message = '' - super().__init__(message) - - diff --git a/molsysmt/_private/exceptions/wrong_coordinates_error.py b/molsysmt/_private/exceptions/wrong_coordinates_error.py deleted file mode 100644 index 09b5d07d2..000000000 --- a/molsysmt/_private/exceptions/wrong_coordinates_error.py +++ /dev/null @@ -1,7 +0,0 @@ -class WrongCoordinatesError(ValueError): - def __init__(self, message=None): - if message is None: - message = '' - super().__init__(message) - - diff --git a/molsysmt/_private/exceptions/wrong_element_error.py b/molsysmt/_private/exceptions/wrong_element_error.py deleted file mode 100644 index 86410aaa5..000000000 --- a/molsysmt/_private/exceptions/wrong_element_error.py +++ /dev/null @@ -1,7 +0,0 @@ -class WrongElementError(ValueError): - def __init__(self, message=None): - if message is None: - message = '' - super().__init__(message) - - diff --git a/molsysmt/_private/exceptions/wrong_form_error.py b/molsysmt/_private/exceptions/wrong_form_error.py deleted file mode 100644 index 6cdf26cfe..000000000 --- a/molsysmt/_private/exceptions/wrong_form_error.py +++ /dev/null @@ -1,54 +0,0 @@ -class WrongFormError(ValueError): - """Exception raised when the item has not the correct form expected by a method or a class. - - This exception is raised when an item has not the correct form for the method to work or the - class to be instantiated. - - Parameters - ---------- - form : str - The form accepted by the method or the class. - - Raises - ------ - WrongFormError - A message is printed out with the name of the right form, the name of the class or - the method raising the exception, the link to the API documentation, and the link to the - issues board of Sabueso's GitHub repository. - - Examples - -------- - >>> from molsysmt._private.exceptions import WrongFormError - >>> from molsysmt import get_form - >>> input_form = get_form('1VII.pdb') - ... if input_form != 'file:top': - ... raise WrongFormError('file:top') - - .. admonition:: See Also - :class: attention - - :ref:`Developer Guide \> Exceptions \> WrongFormError ` - - """ - - def __init__(self, form): - - from molsysmt import __github_issues_web__ - from inspect import stack - - all_stack_frames = stack() - caller_stack_frame = all_stack_frames[1] - caller_name = caller_stack_frame[3] - - api_doc = '' - - message = ( - f"The input item's form of \"{caller_name}\" should be {form} and is not. " - f"Check {api_doc} for more information. " - f"If you still need help, open a new issue in {__github_issues_web__}." - ) - - super().__init__(message) - - - diff --git a/molsysmt/_private/exceptions/wrong_get_argument_error.py b/molsysmt/_private/exceptions/wrong_get_argument_error.py deleted file mode 100644 index d5585a1c5..000000000 --- a/molsysmt/_private/exceptions/wrong_get_argument_error.py +++ /dev/null @@ -1,53 +0,0 @@ -class WrongGetArgumentError(ValueError): - """Exception raised when the get method is called with a not valid input argument. - - This exception is raise when the get method is called with an input argument not recognized by - MolSySMT - - Parameters - ---------- - argument : str, optional - The name of the possible wrong input argument. - - Raises - ------ - BadCallError - A message is printed out with the name of the class or the method raising the exception, - the possible wrong argument, the link to the API documentation, and the link to the - issues board of Sabueso's GitHub repository. - - Examples - -------- - >>> from molsysmt._private.exceptions import WrongGetArgumentError - >>> from molsysmt.basic.get.arguments import arguments - >>> argument = 'atom_color' - >>> if atom_color not in arguments: - ... raise WrongGetArgumentError(argument) - - .. admonition:: See Also - :class: attention - - :ref:`Developer Guide \> Exceptions \> WrongGetArgumentError ` - - """ - - def __init__(self, argument=None): - - from molsysmt import __github_issues_web__ - from inspect import stack - - all_stack_frames = stack() - caller_stack_frame = all_stack_frames[1] - caller_name = caller_stack_frame[3] - - api_doc = '' - - message = f"The get method was invoked with not valid input argument:\"{argument}\"" - message += ( - f". Check {api_doc} for more information. " - f"If you still need help, open a new issue in {__github_issues_web__}." - ) - - super().__init__(message) - - diff --git a/molsysmt/_private/exceptions/wrong_indices_error.py b/molsysmt/_private/exceptions/wrong_indices_error.py deleted file mode 100644 index a73a88033..000000000 --- a/molsysmt/_private/exceptions/wrong_indices_error.py +++ /dev/null @@ -1,6 +0,0 @@ -class WrongIndicesError(ValueError): - def __init__(self, message=None): - if message is None: - message = '' - super().__init__(message) - diff --git a/molsysmt/_private/exceptions/wrong_output_filename_error.py b/molsysmt/_private/exceptions/wrong_output_filename_error.py deleted file mode 100644 index 96838f181..000000000 --- a/molsysmt/_private/exceptions/wrong_output_filename_error.py +++ /dev/null @@ -1,7 +0,0 @@ -class WrongOutputFilenameError(ValueError): - def __init__(self, message=None): - if message is None: - message = '' - super().__init__(message) - - diff --git a/molsysmt/_private/exceptions/wrong_selection_error.py b/molsysmt/_private/exceptions/wrong_selection_error.py deleted file mode 100644 index 97f655971..000000000 --- a/molsysmt/_private/exceptions/wrong_selection_error.py +++ /dev/null @@ -1,7 +0,0 @@ -class WrongSelectionError(ValueError): - def __init__(self, message=None): - if message is None: - message = '' - super().__init__(message) - - diff --git a/molsysmt/_private/exceptions/wrong_step_error.py b/molsysmt/_private/exceptions/wrong_step_error.py deleted file mode 100644 index b3626c5b5..000000000 --- a/molsysmt/_private/exceptions/wrong_step_error.py +++ /dev/null @@ -1,7 +0,0 @@ -class WrongStepError(ValueError): - def __init__(self, message=None): - if message is None: - message = '' - super().__init__(message) - - diff --git a/molsysmt/_private/exceptions/wrong_structure_indices_error.py b/molsysmt/_private/exceptions/wrong_structure_indices_error.py deleted file mode 100644 index 595797990..000000000 --- a/molsysmt/_private/exceptions/wrong_structure_indices_error.py +++ /dev/null @@ -1,7 +0,0 @@ -class WrongStructureIndicesError(ValueError): - def __init__(self, message=None): - if message is None: - message = '' - super().__init__(message) - - diff --git a/molsysmt/_private/exceptions/wrong_syntaxis_error.py b/molsysmt/_private/exceptions/wrong_syntaxis_error.py deleted file mode 100644 index c33c5a413..000000000 --- a/molsysmt/_private/exceptions/wrong_syntaxis_error.py +++ /dev/null @@ -1,7 +0,0 @@ -class WrongSyntaxisError(ValueError): - def __init__(self, message=None): - if message is None: - message = '' - super().__init__(message) - - diff --git a/molsysmt/_private/exceptions/wrong_time_error.py b/molsysmt/_private/exceptions/wrong_time_error.py deleted file mode 100644 index ec2212a55..000000000 --- a/molsysmt/_private/exceptions/wrong_time_error.py +++ /dev/null @@ -1,7 +0,0 @@ -class WrongTimeError(ValueError): - def __init__(self, message=None): - if message is None: - message = '' - super().__init__(message) - - diff --git a/molsysmt/_private/exceptions/wrong_to_form_error.py b/molsysmt/_private/exceptions/wrong_to_form_error.py deleted file mode 100644 index 6cde22756..000000000 --- a/molsysmt/_private/exceptions/wrong_to_form_error.py +++ /dev/null @@ -1,6 +0,0 @@ -class WrongToFormError(ValueError): - def __init__(self, message=None): - if message is None: - message = '' - super().__init__(message) - diff --git a/molsysmt/_private/files_and_directories.py b/molsysmt/_private/files_and_directories.py index cb056dd2f..c8ed4e121 100644 --- a/molsysmt/_private/files_and_directories.py +++ b/molsysmt/_private/files_and_directories.py @@ -1,19 +1,12 @@ import tempfile -def temp_file(dir=None, extension=None): - - if not extension.startswith("."): - extension="."+extension - - return tempfile.NamedTemporaryFile(suffix=extension, dir=dir, delete=False) - def temp_filename(dir=None, extension=None): if not extension.startswith("."): - extension="."+extension + extension = "."+extension - file=tempfile.NamedTemporaryFile(suffix=extension, dir=dir, delete=True) + file = tempfile.NamedTemporaryFile(suffix=extension, dir=dir, delete=True) filename = file.name file.close() return filename @@ -22,4 +15,3 @@ def temp_filename(dir=None, extension=None): def temp_directory(): return tempfile.mkdtemp() - diff --git a/molsysmt/_private/lists_and_tuples.py b/molsysmt/_private/lists_and_tuples.py index 82a19eaec..7cfcce269 100644 --- a/molsysmt/_private/lists_and_tuples.py +++ b/molsysmt/_private/lists_and_tuples.py @@ -1,28 +1,4 @@ def is_list_or_tuple(obj): - - if type(obj) in [list, tuple]: - return True - else: - return False - -def list_to_csv_string(obj): - - return ",".join([str(ii) for ii in obj]) - -def list_to_ssv_string(obj): - - return " ".join([str(ii) for ii in obj]) - -def are_equal_sets(objects1, objects2): - - if not is_list_or_tuple(objects1): - objects1=[objects1] - if not is_list_or_tuple(objects2): - objects2=[objects2] - - output = False - if set(objects1)==set(objects2): - output = True - - return output - + """ Returns true if the given object is a list or a tuple. + """ + return isinstance(obj, (list, tuple)) diff --git a/molsysmt/api_forms/__init__.py b/molsysmt/api_forms/__init__.py index ee5b65207..7438f8ed7 100644 --- a/molsysmt/api_forms/__init__.py +++ b/molsysmt/api_forms/__init__.py @@ -17,9 +17,6 @@ file_forms = [] string_forms = [] -apis = [] -file_apis = [] -string_apis = [] current_dir = os.path.dirname(os.path.abspath(__file__)) apis = [filename.split('.')[0] for filename in os.listdir(current_dir) if filename.startswith('api_')] @@ -28,7 +25,7 @@ for api_name in apis: - mod = import_module('molsysmt.api_forms.'+api_name) + mod = import_module('molsysmt.api_forms.' + api_name) forms.append(mod.form_name) @@ -37,20 +34,36 @@ if api_name in string_apis: string_forms.append(mod.form_name) - dict_type[mod.form_name]=mod.form_type - dict_info[mod.form_name]=mod.form_info - dict_attributes[mod.form_name]=mod.form_attributes - - dict_is_form[mod.form_name]=mod.is_form - dict_add[mod.form_name]=mod.add - dict_append_structures[mod.form_name]=mod.append_structures - dict_extract[mod.form_name]=mod.extract - - dict_convert[mod.form_name]= {} - dict_get[mod.form_name]= {'atom':{}, 'group':{}, 'component':{}, 'molecule':{}, 'chain':{}, - 'entity':{}, 'system':{}, 'bond':{}} - dict_set[mod.form_name]= {'atom':{}, 'group':{}, 'component':{}, 'molecule':{}, 'chain':{}, - 'entity':{}, 'system':{}, 'bond':{}} + dict_type[mod.form_name] = mod.form_type + dict_info[mod.form_name] = mod.form_info + dict_attributes[mod.form_name] = mod.form_attributes + + dict_is_form[mod.form_name] = mod.is_form + dict_add[mod.form_name] = mod.add + dict_append_structures[mod.form_name] = mod.append_structures + dict_extract[mod.form_name] = mod.extract + + dict_convert[mod.form_name] = {} + dict_get[mod.form_name] = { + 'atom': {}, + 'group': {}, + 'component': {}, + 'molecule': {}, + 'chain': {}, + 'entity': {}, + 'system': {}, + 'bond': {}, + } + dict_set[mod.form_name] = { + 'atom': {}, + 'group': {}, + 'component': {}, + 'molecule': {}, + 'chain': {}, + 'entity': {}, + 'system': {}, + 'bond': {}, + } for method in mod.__dict__.keys(): if method.startswith('to_'): @@ -71,5 +84,4 @@ del(mod, method, out_form_name) del(current_dir, import_module) -_dict_forms_lowercase = {ii.lower():ii for ii in forms} - +_dict_forms_lowercase = {ii.lower(): ii for ii in forms} diff --git a/molsysmt/api_forms/api_XYZ.py b/molsysmt/api_forms/api_XYZ.py index c244b5d7c..17e3e0b69 100644 --- a/molsysmt/api_forms/api_XYZ.py +++ b/molsysmt/api_forms/api_XYZ.py @@ -1,81 +1,27 @@ from molsysmt._private.exceptions import * - from molsysmt.item.XYZ.is_XYZ import is_XYZ as is_form from molsysmt.item.XYZ.extract import extract from molsysmt.item.XYZ.add import add from molsysmt.item.XYZ.append_structures import append_structures from molsysmt.item.XYZ.get import * from molsysmt.item.XYZ.set import * +from .form_attributes import form_attributes -form_name='XYZ' -form_type='class' -form_info = ["",""] - -form_attributes = { - - 'atom_index' : False, - 'atom_id' : False, - 'atom_name' : False, - 'atom_type' : False, - - 'bond_index' : False, - 'bond_id' : False, - 'bond_name' : False, - 'bond_type' : False, - 'bond_order' : False, - - 'group_index' : False, - 'group_id' : False, - 'group_name' : False, - 'group_type' : False, - - 'component_index' : False, - 'component_id' : False, - 'component_name' : False, - 'component_type' : False, - - 'molecule_index' : False, - 'molecule_id' : False, - 'molecule_name' : False, - 'molecule_type' : False, +form_name = 'XYZ' +form_type = 'class' +form_info = ["", ""] - 'chain_index' : False, - 'chain_id' : False, - 'chain_name' : False, - 'chain_type' : False, +form_attributes = form_attributes() +form_attributes['coordinates'] = True - 'entity_index' : False, - 'entity_id' : False, - 'entity_name' : False, - 'entity_type' : False, - - 'coordinates' : True, - 'velocities' : False, - 'box' : False, - 'time' : False, - 'step' : False, - - 'forcefield' : False, - 'temperature' : False, - 'pressure' : False, - 'integrator' : False, - 'damping' : False, -} def to_molsysmt_Structures(item, molecular_system=None, atom_indices='all', structure_indices='all'): - from molsysmt.item.XYZ import to_molsysmt_Structures as XYZ_to_molsysmt_Structures - tmp_item = XYZ_to_molsysmt_Structures(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return XYZ_to_molsysmt_Structures(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) - return tmp_item def to_file_xyznpy(item, molecular_system=None, atom_indices='all', structure_indices='all', output_filename=None): - from molsysmt.item.XYZ import to_file_xyznpy as XYZ_to_file_xyznpy - tmp_item = XYZ_to_file_xyznpy(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) - - return tmp_item - - + return XYZ_to_file_xyznpy(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) diff --git a/molsysmt/api_forms/api_biopython_Seq.py b/molsysmt/api_forms/api_biopython_Seq.py index f09d0bd76..144140d15 100644 --- a/molsysmt/api_forms/api_biopython_Seq.py +++ b/molsysmt/api_forms/api_biopython_Seq.py @@ -6,61 +6,15 @@ from molsysmt.item.biopython_Seq.append_structures import append_structures from molsysmt.item.biopython_Seq.get import * from molsysmt.item.biopython_Seq.set import * +from .form_attributes import form_attributes -form_name='biopython.Seq' -form_type='class' -form_info=["",""] +form_name = 'biopython.Seq' +form_type = 'class' +form_info = ["", ""] -form_attributes = { - - 'atom_index' : False, - 'atom_id' : False, - 'atom_name' : False, - 'atom_type' : False, - - 'bond_index' : False, - 'bond_id' : False, - 'bond_name' : False, - 'bond_type' : False, - 'bond_order' : False, - - 'group_index' : True, - 'group_id' : False, - 'group_name' : True, - 'group_type' : False, - - 'component_index' : False, - 'component_id' : False, - 'component_name' : False, - 'component_type' : False, - - 'molecule_index' : False, - 'molecule_id' : False, - 'molecule_name' : False, - 'molecule_type' : False, - - 'chain_index' : False, - 'chain_id' : False, - 'chain_name' : False, - 'chain_type' : False, - - 'entity_index' : False, - 'entity_id' : False, - 'entity_name' : False, - 'entity_type' : False, - - 'coordinates' : False, - 'velocities' : False, - 'box' : False, - 'time' : False, - 'step' : False, - - 'forcefield' : False, - 'temperature' : False, - 'pressure' : False, - 'integrator' : False, - 'damping' : False, -} +form_attributes = form_attributes() +form_attributes['group_index'] = True +form_attributes['group_name'] = True def to_biopython_SeqRecord(item, molecular_system, atom_indices='all', structure_indices='all', @@ -68,17 +22,13 @@ def to_biopython_SeqRecord(item, molecular_system, atom_indices='all', structure from molsysmt.item.biopython_Seq import to_biopython_SeqRecord as biopython_Seq_to_biopython_SeqRecord - tmp_item = biopython_Seq_to_biopython_SeqRecord(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return biopython_Seq_to_biopython_SeqRecord(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) - return tmp_item def to_file_fasta(item, molecular_system, atom_indices='all', structure_indices='all', output_filename=None): from molsysmt.item.biopython_Seq import to_file_fasta as biopython_Seq_to_file_fasta - tmp_item = biopython_Seq_to_file_fasta(item, atom_indices=atom_indices, + return biopython_Seq_to_file_fasta(item, atom_indices=atom_indices, structure_indices=structure_indices, output_filename=output_filename, check=False) - - return tmp_item - diff --git a/molsysmt/api_forms/api_biopython_SeqRecord.py b/molsysmt/api_forms/api_biopython_SeqRecord.py index 7f34bcb38..4c65970f6 100644 --- a/molsysmt/api_forms/api_biopython_SeqRecord.py +++ b/molsysmt/api_forms/api_biopython_SeqRecord.py @@ -6,61 +6,12 @@ from molsysmt.item.biopython_SeqRecord.append_structures import append_structures from molsysmt.item.biopython_SeqRecord.get import * from molsysmt.item.biopython_SeqRecord.set import * +from .form_attributes import form_attributes -form_name='biopython.SeqRecord' -form_type='class' -form_info=["",""] - -form_attributes = { - - 'atom_index' : False, - 'atom_id' : False, - 'atom_name' : False, - 'atom_type' : False, - - 'bond_index' : False, - 'bond_id' : False, - 'bond_name' : False, - 'bond_type' : False, - 'bond_order' : False, - - 'group_index' : True, - 'group_id' : False, - 'group_name' : True, - 'group_type' : False, - - 'component_index' : False, - 'component_id' : False, - 'component_name' : False, - 'component_type' : False, - - 'molecule_index' : False, - 'molecule_id' : False, - 'molecule_name' : False, - 'molecule_type' : False, - - 'chain_index' : False, - 'chain_id' : False, - 'chain_name' : False, - 'chain_type' : False, - - 'entity_index' : False, - 'entity_id' : False, - 'entity_name' : False, - 'entity_type' : False, - - 'coordinates' : False, - 'velocities' : False, - 'box' : False, - 'time' : False, - 'step' : False, - - 'forcefield' : False, - 'temperature' : False, - 'pressure' : False, - 'integrator' : False, - 'damping' : False, - -} - +form_name = 'biopython.SeqRecord' +form_type = 'class' +form_info = ["", ""] +form_attributes = form_attributes() +form_attributes['group_index'] = True +form_attributes['group_name'] = True diff --git a/molsysmt/api_forms/api_file_gro.py b/molsysmt/api_forms/api_file_gro.py index b786b16e4..e229f0358 100644 --- a/molsysmt/api_forms/api_file_gro.py +++ b/molsysmt/api_forms/api_file_gro.py @@ -6,98 +6,67 @@ from molsysmt.item.file_gro.append_structures import append_structures from molsysmt.item.file_gro.get import * from molsysmt.item.file_gro.set import * +from .form_attributes import form_attributes + +form_name = 'file:gro' +form_type = 'file' +form_info = ["Gromacs gro file format", + "http://manual.gromacs.org/documentation/2018/user-guide/file-formats.html#gro"] + + +form_attributes = form_attributes() +form_attributes['atom_index'] = True +form_attributes['atom_id'] = True +form_attributes['atom_name'] = True +form_attributes['atom_type'] = True +form_attributes['bond_index'] = True +form_attributes['bond_id'] = True +form_attributes['bond_name'] = True +form_attributes['bond_type'] = True +form_attributes['bond_order'] = True +form_attributes['group_index'] = True +form_attributes['group_id'] = True +form_attributes['group_name'] = True +form_attributes['group_type'] = True +form_attributes['chain_index'] = True +form_attributes['chain_id'] = True +form_attributes['chain_name'] = True +form_attributes['chain_type'] = True +form_attributes['coordinates'] = True +form_attributes['velocities'] = True +form_attributes['box'] = True -form_name='file:gro' -form_type='file' -form_info=["Gromacs gro file format","http://manual.gromacs.org/documentation/2018/user-guide/file-formats.html#gro"] - -form_attributes = { - - 'atom_index' : True, - 'atom_id' : True, - 'atom_name' : True, - 'atom_type' : True, - - 'bond_index' : True, - 'bond_id' : True, - 'bond_name' : True, - 'bond_type' : True, - 'bond_order' : True, - - 'group_index' : True, - 'group_id' : True, - 'group_name' : True, - 'group_type' : True, - - 'component_index' : False, - 'component_id' : False, - 'component_name' : False, - 'component_type' : False, - - 'molecule_index' : False, - 'molecule_id' : False, - 'molecule_name' : False, - 'molecule_type' : False, - - 'chain_index' : True, - 'chain_id' : True, - 'chain_name' : True, - 'chain_type' : True, - - 'entity_index' : False, - 'entity_id' : False, - 'entity_name' : False, - 'entity_type' : False, - - 'coordinates' : True, - 'velocities' : True, - 'box' : True, - 'time' : False, - 'step' : False, - - 'forcefield_parameters' : False, - - 'forcefield' : False, - 'temperature' : False, - 'pressure' : False, - 'integrator' : False, - 'damping' : False, -} def to_molsysmt_MolSys(item, molecular_system, atom_indices='all', structure_indices='all'): from molsysmt.item.file_gro import to_molsysmt_MolSys as file_gro_to_molsysmt_MolSys - tmp_item = file_gro_to_molsysmt_MolSys(item, atom_indices=atom_indices, + return file_gro_to_molsysmt_MolSys(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) - return tmp_item def to_molsysmt_Topology(item, molecular_system, atom_indices='all', structure_indices='all'): from molsysmt.item.file_gro import to_molsysmt_Topology as file_gro_to_molsysmt_Topology - tmp_item = file_gro_to_molsysmt_Topology(item, atom_indices=atom_indices, check=False) + return file_gro_to_molsysmt_Topology(item, atom_indices=atom_indices, check=False) - return tmp_item def to_molsysmt_Structures(item, molecular_system, atom_indices='all', structure_indices='all'): from molsysmt.item.file_gro import to_molsysmt_Structures as file_gro_to_molsysmt_Structures - tmp_item = file_gro_to_molsysmt_Structures(item, atom_indices=atom_indices, + return file_gro_to_molsysmt_Structures(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) - return tmp_item def to_mdtraj_Trajectory(item, molecular_system, atom_indices='all', structure_indices='all'): from molsysmt.item.file_gro import to_mdtraj_Trajectory as file_gro_to_mdtraj_Trajectory - tmp_item = file_gro_to_mdtraj_Trajectory(item, atom_indices=atom_indices, + return file_gro_to_mdtraj_Trajectory(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) - return tmp_item def to_mdtraj_Topology(item, molecular_system, atom_indices='all', structure_indices='all'): @@ -107,44 +76,41 @@ def to_mdtraj_Topology(item, molecular_system, atom_indices='all', structure_ind return tmp_item + def to_mdtraj_GroTrajectoryFile(item, molecular_system, atom_indices='all', structure_indices='all'): from molsysmt.item.file_gro import to_mdtraj_GroTrajectoryFile as file_gro_to_mdtraj_GroTrajectoryFile - tmp_item = file_gro_to_mdtraj_GroTrajectoryFile(item, atom_indices=atom_indices, + return file_gro_to_mdtraj_GroTrajectoryFile(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) - return tmp_item def to_openmm_Topology(item, molecular_system, atom_indices='all', structure_indices='all'): from molsysmt.item.file_gro import to_openmm_Topology as file_gro_to_openmm_Topology - tmp_item = file_gro_to_openmm_Topology(item, atom_indices=atom_indices, check=False) + return file_gro_to_openmm_Topology(item, atom_indices=atom_indices, check=False) - return tmp_item def to_openmm_Modeller(item, molecular_system, atom_indices='all', structure_indices='all'): from molsysmt.item.file_gro import to_openmm_Modeller as file_gro_to_openmm_Modeller - tmp_item = file_gro_to_openmm_Modeller(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return file_gro_to_openmm_Modeller(item, atom_indices=atom_indices, + structure_indices=structure_indices, check=False) - return tmp_item def to_openmm_GromacsGroFile(item, molecular_system, atom_indices='all', structure_indices='all'): from molsysmt.item.file_gro import to_openmm_GromacsGroFile as file_gro_to_openmm_GromacsGroFile - tmp_item = file_gro_to_openmm_GromacsGroFile(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return file_gro_to_openmm_GromacsGroFile(item, atom_indices=atom_indices, + structure_indices=structure_indices, check=False) - return tmp_item def to_nglview_NGLWidget(item, molecular_system, atom_indices='all', structure_indices='all'): from molsysmt.item.file_gro import to_nglview_NGLWidget as file_gro_to_nglview_NGLWidget - tmp_item = file_gro_to_nglview_NGLWidget(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) - - return tmp_item - + return file_gro_to_nglview_NGLWidget(item, atom_indices=atom_indices, + structure_indices=structure_indices, check=False) diff --git a/molsysmt/api_forms/api_file_h5.py b/molsysmt/api_forms/api_file_h5.py index ae04e1b50..301179fb0 100644 --- a/molsysmt/api_forms/api_file_h5.py +++ b/molsysmt/api_forms/api_file_h5.py @@ -6,63 +6,41 @@ from molsysmt.item.file_h5.append_structures import append_structures from molsysmt.item.file_h5.get import * from molsysmt.item.file_h5.set import * - -form_name='file:h5' -form_type='file' -form_info=["",""] - -form_attributes = { - - 'atom_index' : True, - 'atom_id' : True, - 'atom_name' : True, - 'atom_type' : True, - - 'bond_index' : True, - 'bond_id' : True, - 'bond_name' : True, - 'bond_type' : True, - 'bond_order' : True, - - 'group_index' : True, - 'group_id' : True, - 'group_name' : True, - 'group_type' : True, - - 'component_index' : True, - 'component_id' : False, - 'component_name' : False, - 'component_type' : False, - - 'molecule_index' : True, - 'molecule_id' : True, - 'molecule_name' : True, - 'molecule_type' : True, - - 'chain_index' : True, - 'chain_id' : True, - 'chain_name' : True, - 'chain_type' : True, - - 'entity_index' : False, - 'entity_id' : False, - 'entity_name' : False, - 'entity_type' : False, - - 'coordinates' : True, - 'velocities' : True, - 'box' : True, - 'time' : True, - 'step' : True, - - 'forcefield_parameters' : True, - - 'forcefield' : False, - 'temperature' : False, - 'pressure' : False, - 'integrator' : False, - 'damping' : False, -} +from .form_attributes import form_attributes + +form_name = 'file:h5' +form_type = 'file' +form_info = ["", ""] + +form_attributes = form_attributes() +form_attributes['atom_index'] = True +form_attributes['atom_id'] = True +form_attributes['atom_name'] = True +form_attributes['atom_type'] = True +form_attributes['bond_index'] = True +form_attributes['bond_id'] = True +form_attributes['bond_name'] = True +form_attributes['bond_type'] = True +form_attributes['bond_order'] = True +form_attributes['group_index'] = True +form_attributes['group_id'] = True +form_attributes['group_name'] = True +form_attributes['group_type'] = True +form_attributes['component_index'] = True +form_attributes['molecule_index'] = True +form_attributes['molecule_id'] = True +form_attributes['molecule_name'] = True +form_attributes['molecule_type'] = True +form_attributes['chain_index'] = True +form_attributes['chain_id'] = True +form_attributes['chain_name'] = True +form_attributes['chain_type'] = True +form_attributes['coordinates'] = True +form_attributes['velocities'] = True +form_attributes['box'] = True +form_attributes['time'] = True +form_attributes['step'] = True +form_attributes['forcefield_parameters'] = True def to_mdtraj_Trajectory(item, molecular_system, atom_indices='all', structure_indices='all'): diff --git a/molsysmt/api_forms/api_file_inpcrd.py b/molsysmt/api_forms/api_file_inpcrd.py index cc4f5de0d..c30e6cb18 100644 --- a/molsysmt/api_forms/api_file_inpcrd.py +++ b/molsysmt/api_forms/api_file_inpcrd.py @@ -6,85 +6,34 @@ from molsysmt.item.file_inpcrd.append_structures import append_structures from molsysmt.item.file_inpcrd.get import * from molsysmt.item.file_inpcrd.set import * +from .form_attributes import form_attributes -form_name='file:inpcrd' -form_type='file' -form_info = ["AMBER ASCII restart/inpcrd file format","https://ambermd.org/FileFormats.php#trajectory"] +form_name = 'file:inpcrd' +form_type = 'file' +form_info = ["AMBER ASCII restart/inpcrd file format", + "https://ambermd.org/FileFormats.php#trajectory"] -form_attributes = { - - 'atom_index' : False, - 'atom_id' : False, - 'atom_name' : False, - 'atom_type' : False, - - 'bond_index' : False, - 'bond_id' : False, - 'bond_name' : False, - 'bond_type' : False, - 'bond_order' : False, - - 'group_index' : False, - 'group_id' : False, - 'group_name' : False, - 'group_type' : False, - - 'component_index' : False, - 'component_id' : False, - 'component_name' : False, - 'component_type' : False, - - 'molecule_index' : False, - 'molecule_id' : False, - 'molecule_name' : False, - 'molecule_type' : False, - - 'chain_index' : False, - 'chain_id' : False, - 'chain_name' : False, - 'chain_type' : False, - - 'entity_index' : False, - 'entity_id' : False, - 'entity_name' : False, - 'entity_type' : False, - - 'coordinates' : True, - 'velocities' : False, - 'box' : True, - 'time' : False, - 'step' : False, - - 'forcefield' : False, - 'temperature' : False, - 'pressure' : False, - 'integrator' : False, - 'damping' : False, -} +form_attributes = form_attributes() +form_attributes['coordinates'] = True +form_attributes['box'] = True def to_molsysmt_Structures(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.file_inpcrd import to_molsysmt_Structures as file_inpcrd_to_molsysmt_Structures - tmp_item = file_inpcrd_to_molsysmt_Structures(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return file_inpcrd_to_molsysmt_Structures(item, atom_indices=atom_indices, + structure_indices=structure_indices, check=False) - return tmp_item def to_mdtraj_AmberRestartFile(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.file_inpcrd import to_mdtraj_AmberRestartFile as file_inpcrd_to_mdtraj_AmberRestartFile - tmp_item = file_inpcrd_to_mdtraj_AmberRestartFile(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return file_inpcrd_to_mdtraj_AmberRestartFile(item, atom_indices=atom_indices, + structure_indices=structure_indices, check=False) - return tmp_item def to_openmm_AmberInpcrdFile(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.file_inpcrd import to_openmm_AmberInpcrdFile as file_inpcrd_to_openmm_AmberInpcrdFile - tmp_item = file_inpcrd_to_openmm_AmberInpcrdFile(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) - - return tmp_item - - + return file_inpcrd_to_openmm_AmberInpcrdFile(item, atom_indices=atom_indices, + structure_indices=structure_indices, check=False) diff --git a/molsysmt/api_forms/api_file_mmtf.py b/molsysmt/api_forms/api_file_mmtf.py index aa291a1b5..80ec78a89 100644 --- a/molsysmt/api_forms/api_file_mmtf.py +++ b/molsysmt/api_forms/api_file_mmtf.py @@ -6,97 +6,68 @@ from molsysmt.item.file_mmtf.append_structures import append_structures from molsysmt.item.file_mmtf.get import * from molsysmt.item.file_mmtf.set import * +from .form_attributes import form_attributes import numpy as np -form_name='file:mmtf' -form_type='file' -form_info=["",""] - -form_attributes = { - - 'atom_index' : True, - 'atom_id' : True, - 'atom_name' : True, - 'atom_type' : True, - - 'bond_index' : True, - 'bond_id' : True, - 'bond_name' : True, - 'bond_type' : True, - 'bond_order' : True, - - 'group_index' : True, - 'group_id' : True, - 'group_name' : True, - 'group_type' : True, - - 'component_index' : True, - 'component_id' : False, - 'component_name' : False, - 'component_type' : False, - - 'molecule_index' : True, - 'molecule_id' : True, - 'molecule_name' : True, - 'molecule_type' : True, - - 'chain_index' : True, - 'chain_id' : True, - 'chain_name' : True, - 'chain_type' : True, - - 'entity_index' : False, - 'entity_id' : False, - 'entity_name' : False, - 'entity_type' : False, - - 'coordinates' : False, - 'velocities' : False, - 'box' : True, - 'time' : False, - 'step' : False, - - 'forcefield_parameters' : True, - - 'forcefield' : False, - 'temperature' : False, - 'pressure' : False, - 'integrator' : False, - 'damping' : False, -} +form_name = 'file:mmtf' +form_type = 'file' +form_info = ["", ""] + +form_attributes = form_attributes() +form_attributes['atom_index'] = True +form_attributes['atom_id'] = True +form_attributes['atom_name'] = True +form_attributes['atom_type'] = True +form_attributes['bond_index'] = True +form_attributes['bond_id'] = True +form_attributes['bond_name'] = True +form_attributes['bond_type'] = True +form_attributes['bond_order'] = True +form_attributes['group_index'] = True +form_attributes['group_id'] = True +form_attributes['group_name'] = True +form_attributes['group_type'] = True +form_attributes['component_index'] = True +form_attributes['molecule_index'] = True +form_attributes['molecule_id'] = True +form_attributes['molecule_name'] = True +form_attributes['molecule_type'] = True +form_attributes['chain_index'] = True +form_attributes['chain_id'] = True +form_attributes['chain_name'] = True +form_attributes['chain_type'] = True +form_attributes['box'] = True +form_attributes['forcefield_parameters'] = True + def to_mmtf_MMTFDecoder(item, molecular_system, atom_indices='all', structure_indices='all'): from molsysmt.item.file_mmtf import to_mmtf_MMTFDecoder as file_mmtf_to_mmtf_MMTFDecoder - tmp_item = file_mmtf_to_mmtf_MMTFDecoder(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return file_mmtf_to_mmtf_MMTFDecoder(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) - return tmp_item def to_molsysmt_MolSys(item, molecular_system, atom_indices='all', structure_indices='all'): from molsysmt.item.file_mmtf import to_molsysmt_MolSys as file_mmtf_to_molsysmt_MolSys - tmp_item = file_mmtf_to_molsysmt_MolSys(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return file_mmtf_to_molsysmt_MolSys(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) - return tmp_item def to_molsysmt_Topology(item, molecular_system, atom_indices='all', structure_indices='all'): from molsysmt.item.file_mmtf import to_molsysmt_Topology as file_mmtf_to_molsysmt_Topology - tmp_item = file_mmtf_to_molsysmt_Topology(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return file_mmtf_to_molsysmt_Topology(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) - return tmp_item def to_molsysmt_Structures(item, molecular_system, atom_indices='all', structure_indices='all'): from molsysmt.item.file_mmtf import to_molsysmt_Structures as file_mmtf_to_molsysmt_Structures - tmp_item = file_mmtf_to_molsysmt_Structures(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return file_mmtf_to_molsysmt_Structures(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) - return tmp_item def to_string_aminoacids1(item, molecular_system, atom_indices='all', structure_indices='all'): @@ -106,9 +77,8 @@ def to_string_aminoacids1(item, molecular_system, atom_indices='all', structure_ group_indices = get_group_index_from_atom(item, indices=atom_indices) group_indices = np.unique(group_indices) - tmp_item = file_mmtf_to_string_aminoacids1(item, group_indices=group_indices, check=False) + return file_mmtf_to_string_aminoacids1(item, group_indices=group_indices, check=False) - return tmp_item def to_string_aminoacids3(item, molecular_system, atom_indices='all', structure_indices='all'): @@ -118,25 +88,21 @@ def to_string_aminoacids3(item, molecular_system, atom_indices='all', structure_ group_indices = get_group_index_from_atom(item, indices=atom_indices) group_indices = np.unique(group_indices) - tmp_item = file_mmtf_to_string_aminoacids3(item, group_indices=group_indices, check=False) + return file_mmtf_to_string_aminoacids3(item, group_indices=group_indices, check=False) - return tmp_item def to_mdanalysis_Universe(item, molecular_system, atom_indices='all', structure_indices='all'): from molsysmt.item.file_mmtf import to_mdanalysis_Universe as file_mmtf_to_mdanalysis_Universe - tmp_item = file_mmtf_to_mdanalysis_Universe(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return file_mmtf_to_mdanalysis_Universe(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) - return tmp_item def to_file_pdb(item, molecular_system=None, atom_indices='all', structure_indices='all', output_filename=None): from molsysmt.item.file_mmtf import to_file_pdb as file_mmtf_to_file_pdb - tmp_item = file_mmtf_to_file_pdb(item, atom_indices=atom_indices, + return file_mmtf_to_file_pdb(item, atom_indices=atom_indices, structure_indices=structure_indices, output_filename=output_filename, check=False) - return tmp_item - diff --git a/molsysmt/api_forms/api_file_mol2.py b/molsysmt/api_forms/api_file_mol2.py index 2ad3173a2..c963bd600 100644 --- a/molsysmt/api_forms/api_file_mol2.py +++ b/molsysmt/api_forms/api_file_mol2.py @@ -1,150 +1,106 @@ from molsysmt._private.exceptions import * - from molsysmt.item.file_mol2.is_file_mol2 import is_file_mol2 as is_form from molsysmt.item.file_mol2.extract import extract from molsysmt.item.file_mol2.add import add from molsysmt.item.file_mol2.append_structures import append_structures from molsysmt.item.file_mol2.get import * from molsysmt.item.file_mol2.set import * - -form_name='file:mol2' -form_type='file' -form_info=["", ""] - -form_attributes = { - - 'atom_index' : True, - 'atom_id' : True, - 'atom_name' : True, - 'atom_type' : True, - - 'bond_index' : True, - 'bond_id' : True, - 'bond_name' : True, - 'bond_type' : True, - 'bond_order' : True, - - 'group_index' : True, - 'group_id' : True, - 'group_name' : True, - 'group_type' : True, - - 'component_index' : True, - 'component_id' : False, - 'component_name' : False, - 'component_type' : False, - - 'molecule_index' : True, - 'molecule_id' : True, - 'molecule_name' : True, - 'molecule_type' : True, - - 'chain_index' : True, - 'chain_id' : True, - 'chain_name' : True, - 'chain_type' : True, - - 'entity_index' : False, - 'entity_id' : False, - 'entity_name' : False, - 'entity_type' : False, - - 'coordinates' : False, - 'velocities' : False, - 'box' : True, - 'time' : False, - 'step' : False, - - 'forcefield_parameters' : True, - - 'forcefield' : False, - 'temperature' : False, - 'pressure' : False, - 'integrator' : False, - 'damping' : False, -} +from .form_attributes import form_attributes + +form_name = 'file:mol2' +form_type = 'file' +form_info = ["", ""] + +form_attributes = form_attributes() +form_attributes['atom_index'] = True +form_attributes['atom_id'] = True +form_attributes['atom_name'] = True +form_attributes['atom_type'] = True +form_attributes['bond_index'] = True +form_attributes['bond_id'] = True +form_attributes['bond_name'] = True +form_attributes['bond_type'] = True +form_attributes['bond_order'] = True +form_attributes['group_index'] = True +form_attributes['group_id'] = True +form_attributes['group_name'] = True +form_attributes['group_type'] = True +form_attributes['component_index'] = True +form_attributes['molecule_index'] = True +form_attributes['molecule_id'] = True +form_attributes['molecule_name'] = True +form_attributes['molecule_type'] = True +form_attributes['chain_index'] = True +form_attributes['chain_id'] = True +form_attributes['chain_name'] = True +form_attributes['chain_type'] = True +form_attributes['box'] = True +form_attributes['forcefield_parameters'] = True def to_molsysmt_MolSys(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.file_mol2 import to_molsysmt_MolSys as file_mol2_to_molsysmt_MolSys - tmp_item = file_mol2_to_molsysmt_MolSys(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return file_mol2_to_molsysmt_MolSys(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_molsysmt_Topology(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.file_mol2 import to_molsysmt_Topology as file_mol2_to_molsysmt_Topology - tmp_item = file_mol2_to_molsysmt_Topology(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return file_mol2_to_molsysmt_Topology(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_molsysmt_Structures(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.file_mol2 import to_molsysmt_Structures as file_mol2_to_molsysmt_Structures - tmp_item = file_mol2_to_molsysmt_Structures(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return file_mol2_to_molsysmt_Structures(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_parmed_Structure(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.file_mol2 import to_parmed_Structure as file_mol2_to_parmed_Structure - tmp_item = file_mol2_to_parmed_Structure(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return file_mol2_to_parmed_Structure(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_mdtraj_Trajectory(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.file_mol2 import to_mdtraj_Trajectory as file_mol2_to_mdtraj_Trajectory - tmp_item = file_mol2_to_mdtraj_Trajectory(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return file_mol2_to_mdtraj_Trajectory(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_mdtraj_Topology(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.file_mol2 import to_mdtraj_Topology as file_mol2_to_mdtraj_Topology - tmp_item = file_mol2_to_mdtraj_Topology(item, atom_indices=atom_indices, check=False) + return file_mol2_to_mdtraj_Topology(item, atom_indices=atom_indices, check=False) - return tmp_item def to_openmm_Topology(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.file_mol2 import to_openmm_Topology as file_mol2_to_openmm_Topology - tmp_item = file_mol2_to_openmm_Topology(item, atom_indices=atom_indices, check=False) + return file_mol2_to_openmm_Topology(item, atom_indices=atom_indices, check=False) - return tmp_item def to_openmm_Modeller(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.file_mol2 import to_openmm_Modeller as file_mol2_to_openmm_Modeller - tmp_item = file_mol2_to_openmm_Modeller(item, atom_indices=atom_indices, - structure_indices=structure_indices, check=False) + return file_mol2_to_openmm_Modeller(item, atom_indices=atom_indices, + structure_indices=structure_indices, check=False) - return tmp_item def to_file_pdb(item, molecular_system, atom_indices='all', structure_indices='all', output_filename=None): - from molsysmt.item.file_mol2 import to_file_pdb as file_mol2_to_file_pdb - tmp_item = file_mol2_to_file_pdb(item, atom_indices=atom_indices, - structure_indices=structure_indices, output_filename=output_filename, check=False) + return file_mol2_to_file_pdb(item, atom_indices=atom_indices, + structure_indices=structure_indices, output_filename=output_filename, check=False) - return tmp_item def to_nglview_NGLWidget(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.file_mol2 import to_nglview_NGLWidget as file_mol2_to_nglview_NGLWidget - tmp_item = file_mol2_to_nglview_NGLWidget(item, atom_indices=atom_indices, - structure_indices=structure_indices, check=False) - - return tmp_item - + return file_mol2_to_nglview_NGLWidget(item, atom_indices=atom_indices, + structure_indices=structure_indices, check=False) diff --git a/molsysmt/api_forms/api_file_msmpk.py b/molsysmt/api_forms/api_file_msmpk.py index 8abd5c86d..b3a91d050 100644 --- a/molsysmt/api_forms/api_file_msmpk.py +++ b/molsysmt/api_forms/api_file_msmpk.py @@ -1,100 +1,74 @@ from molsysmt._private.exceptions import * - from molsysmt.item.file_msmpk.is_file_msmpk import is_file_msmpk as is_form from molsysmt.item.file_msmpk.extract import extract from molsysmt.item.file_msmpk.add import add from molsysmt.item.file_msmpk.append_structures import append_structures from molsysmt.item.file_msmpk.get import * from molsysmt.item.file_msmpk.set import * - -form_name='file:msmpk' -form_type='file' -form_info=["",""] - -form_attributes = { - - 'atom_index' : True, - 'atom_id' : True, - 'atom_name' : True, - 'atom_type' : True, - - 'bond_index' : True, - 'bond_id' : True, - 'bond_name' : True, - 'bond_type' : True, - 'bond_order' : True, - - 'group_index' : True, - 'group_id' : True, - 'group_name' : True, - 'group_type' : True, - - 'component_index' : True, - 'component_id' : True, - 'component_name' : True, - 'component_type' : True, - - 'molecule_index' : True, - 'molecule_id' : True, - 'molecule_name' : True, - 'molecule_type' : True, - - 'chain_index' : True, - 'chain_id' : True, - 'chain_name' : True, - 'chain_type' : True, - - 'entity_index' : True, - 'entity_id' : True, - 'entity_name' : True, - 'entity_type' : True, - - 'coordinates' : True, - 'velocities' : True, - 'box' : True, - 'time' : True, - 'step' : True, - - 'forcefield_parameters' : False, - - 'forcefield' : False, - 'temperature' : False, - 'pressure' : False, - 'integrator' : False, - 'damping' : False, -} +from .form_attributes import form_attributes + +form_name = 'file:msmpk' +form_type = 'file' +form_info = ["", ""] + +form_attributes = form_attributes() +form_attributes['atom_index'] = True +form_attributes['atom_id'] = True +form_attributes['atom_name'] = True +form_attributes['atom_type'] = True +form_attributes['bond_index'] = True +form_attributes['bond_id'] = True +form_attributes['bond_name'] = True +form_attributes['bond_type'] = True +form_attributes['bond_order'] = True +form_attributes['group_index'] = True +form_attributes['group_id'] = True +form_attributes['group_name'] = True +form_attributes['group_type'] = True +form_attributes['component_index'] = True +form_attributes['component_id'] = True +form_attributes['component_name'] = True +form_attributes['component_type'] = True +form_attributes['molecule_index'] = True +form_attributes['molecule_id'] = True +form_attributes['molecule_name'] = True +form_attributes['molecule_type'] = True +form_attributes['chain_index'] = True +form_attributes['chain_id'] = True +form_attributes['chain_name'] = True +form_attributes['chain_type'] = True +form_attributes['entity_index'] = True +form_attributes['entity_id'] = True +form_attributes['entity_name'] = True +form_attributes['entity_type'] = True +form_attributes['coordinates'] = True +form_attributes['velocities'] = True +form_attributes['box'] = True +form_attributes['time'] = True +form_attributes['step'] = True def to_molsysmt_MolSys(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.file_msmpk import to_molsysmt_MolSys as file_msmpk_to_molsysmt_MolSys - tmp_item = file_msmpk_to_molsysmt_MolSys(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return file_msmpk_to_molsysmt_MolSys(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_molsysmt_Topology(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.file_msmpk import to_molsysmt_Topology as file_msmpk_to_molsysmt_Topology - tmp_item = file_msmpk_to_molsysmt_Topology(item, atom_indices=atom_indices, check=False) + return file_msmpk_to_molsysmt_Topology(item, atom_indices=atom_indices, check=False) - return tmp_item def to_molsysmt_Structures(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.file_msmpk import to_molsysmt_Structures as file_msmpk_to_molsysmt_Structures - tmp_item = file_msmpk_to_molsysmt_Structures(item, atom_indices=atom_indices, check=False) + return file_msmpk_to_molsysmt_Structures(item, atom_indices=atom_indices, check=False) - return tmp_item def to_nglview_NGLWidget(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.file_msmpk import to_nglview_NGLWidget as file_msmpk_to_nglview_NGLWidget - tmp_item = file_msmpk_to_nglview_NGLWidget(item, atom_indices=atom_indices, - structure_indices=structure_indices, check=False) - - return tmp_item - + return file_msmpk_to_nglview_NGLWidget(item, atom_indices=atom_indices, + structure_indices=structure_indices, check=False) diff --git a/molsysmt/api_forms/api_file_pdb.py b/molsysmt/api_forms/api_file_pdb.py index af8099450..b7d7879cd 100644 --- a/molsysmt/api_forms/api_file_pdb.py +++ b/molsysmt/api_forms/api_file_pdb.py @@ -1,191 +1,141 @@ from molsysmt._private.exceptions import * - from molsysmt.item.file_pdb.is_file_pdb import is_file_pdb as is_form from molsysmt.item.file_pdb.extract import extract from molsysmt.item.file_pdb.add import add from molsysmt.item.file_pdb.append_structures import append_structures from molsysmt.item.file_pdb.get import * from molsysmt.item.file_pdb.set import * +from .form_attributes import form_attributes + +form_name = 'file:pdb' +form_type = 'file' +form_info = ["Protein Data Bank file format", "https://www.rcsb.org/pdb/static.do?p=file_formats/pdb/index.html"] + +form_attributes = form_attributes() +form_attributes['atom_index'] = True +form_attributes['atom_id'] = True +form_attributes['atom_name'] = True +form_attributes['atom_type'] = True +form_attributes['bond_index'] = True +form_attributes['bond_id'] = True +form_attributes['bond_name'] = True +form_attributes['bond_type'] = True +form_attributes['bond_order'] = True +form_attributes['group_index'] = True +form_attributes['group_id'] = True +form_attributes['group_name'] = True +form_attributes['group_type'] = True +form_attributes['component_index'] = True +form_attributes['molecule_index'] = True +form_attributes['molecule_id'] = True +form_attributes['molecule_name'] = True +form_attributes['molecule_type'] = True +form_attributes['chain_index'] = True +form_attributes['chain_id'] = True +form_attributes['chain_name'] = True +form_attributes['chain_type'] = True +form_attributes['box'] = True +form_attributes['forcefield_parameters'] = True -form_name='file:pdb' -form_type='file' -form_info=["Protein Data Bank file format","https://www.rcsb.org/pdb/static.do?p=file_formats/pdb/index.html"] - -form_attributes = { - - 'atom_index' : True, - 'atom_id' : True, - 'atom_name' : True, - 'atom_type' : True, - - 'bond_index' : True, - 'bond_id' : True, - 'bond_name' : True, - 'bond_type' : True, - 'bond_order' : True, - - 'group_index' : True, - 'group_id' : True, - 'group_name' : True, - 'group_type' : True, - - 'component_index' : True, - 'component_id' : False, - 'component_name' : False, - 'component_type' : False, - - 'molecule_index' : True, - 'molecule_id' : True, - 'molecule_name' : True, - 'molecule_type' : True, - - 'chain_index' : True, - 'chain_id' : True, - 'chain_name' : True, - 'chain_type' : True, - - 'entity_index' : False, - 'entity_id' : False, - 'entity_name' : False, - 'entity_type' : False, - - 'coordinates' : False, - 'velocities' : False, - 'box' : True, - 'time' : False, - 'step' : False, - - 'forcefield_parameters' : True, - - 'forcefield' : False, - 'temperature' : False, - 'pressure' : False, - 'integrator' : False, - 'damping' : False, -} def to_molsysmt_MolSys(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.file_pdb import to_molsysmt_MolSys as file_pdb_to_molsysmt_MolSys - tmp_item = file_pdb_to_molsysmt_MolSys(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return file_pdb_to_molsysmt_MolSys(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_molsysmt_Topology(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.file_pdb import to_molsysmt_Topology as file_pdb_to_molsysmt_Topology - tmp_item = file_pdb_to_molsysmt_Topology(item, atom_indices=atom_indices, check=False) + return file_pdb_to_molsysmt_Topology(item, atom_indices=atom_indices, check=False) - return tmp_item def to_molsysmt_Structures(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.file_pdb import to_molsysmt_Structures as file_pdb_to_molsysmt_Structures - tmp_item = file_pdb_to_molsysmt_Structures(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return file_pdb_to_molsysmt_Structures(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_parmed_Structure(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.file_pdb import to_parmed_Structure as file_pdb_to_parmed_Structure - tmp_item = file_pdb_to_parmed_Structure(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return file_pdb_to_parmed_Structure(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_mdanalysis_Universe(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.file_pdb import to_mdanalysis_Universe as file_pdb_to_mdanalysis_Universe - tmp_item = file_pdb_to_mdanalysis_Universe(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return file_pdb_to_mdanalysis_Universe(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item, tmp_molecular_system def to_mdanalysis_Topology(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.file_pdb import to_mdanalysis_Topology as file_pdb_to_mdanalysis_Topology - tmp_item = file_pdb_to_mdanalysis_Topology(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return file_pdb_to_mdanalysis_Topology(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_mdanalysis_topology_PDBParser(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.file_pdb import to_mdanalysis_topology_PDBParser as file_pdb_to_mdanalysis_topology_PDBParser - tmp_item = file_pdb_to_mdanalysis_topology_PDBParser(item, atom_indices=atom_indices, check=False) + return file_pdb_to_mdanalysis_topology_PDBParser(item, atom_indices=atom_indices, check=False) - return tmp_item def to_mdtraj_Topology(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.file_pdb import to_mdtraj_Topology as file_pdb_to_mdtraj_Topology - tmp_item = file_pdb_to_mdtraj_Topology(item, atom_indices=atom_indices, check=False) + return file_pdb_to_mdtraj_Topology(item, atom_indices=atom_indices, check=False) - return tmp_item def to_mdtraj_Trajectory(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.file_pdb import to_mdtraj_Trajectory as file_pdb_to_mdtraj_Trajectory - tmp_item = file_pdb_to_mdtraj_Trajectory(item, atom_indices=atom_indices, - structure_indices=structure_indices, check=False) + return file_pdb_to_mdtraj_Trajectory(item, atom_indices=atom_indices, + structure_indices=structure_indices, check=False) - return tmp_item def to_mdtraj_PDBTrajectoryFile(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.file_pdb import to_mdtraj_PDBTrajectoryFile as file_pdb_to_mdtraj_PDBTrajectoryFile - tmp_item = file_pdb_to_mdtraj_PDBTrajectoryFile(item, atom_indices=atom_indices, check=False) + return file_pdb_to_mdtraj_PDBTrajectoryFile(item, atom_indices=atom_indices, check=False) - return tmp_item def to_file_mol2(item, molecular_system, atom_indices='all', structure_indices='all', output_filename=None): - from molsysmt.item.file_pdb import to_file_mol2 as file_pdb_to_file_mol2 - tmp_item = file_pdb_to_file_mol2(item, atom_indices=atom_indices, - structure_indices=structure_indices, output_filename=output_filename, check=False) + return file_pdb_to_file_mol2(item, atom_indices=atom_indices, + structure_indices=structure_indices, output_filename=output_filename, check=False) - return tmp_item def to_openmm_Topology(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.file_pdb import to_openmm_Topology as file_pdb_to_openmm_Topology - tmp_item = file_pdb_to_openmm_Topology(item, atom_indices=atom_indices, check=False) + return file_pdb_to_openmm_Topology(item, atom_indices=atom_indices, check=False) - return tmp_item def to_openmm_Modeller(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.file_pdb import to_openmm_Modeller as file_pdb_to_openmm_Modeller - tmp_item = file_pdb_to_openmm_Modeller(item, atom_indices=atom_indices, - structure_indices=structure_indices, check=False) + return file_pdb_to_openmm_Modeller(item, atom_indices=atom_indices, + structure_indices=structure_indices, check=False) - return tmp_item def to_openmm_System(item, molecular_system, atom_indices='all', structure_indices='all', forcefield=None, non_bonded_method='no_cutoff', non_bonded_cutoff='1.0 nm', constraints=None, rigid_water=True, remove_cm_motion=True, hydrogen_mass=None, switch_distance=None, flexible_constraints=False): - from molsysmt.item.file_pdb import to_openmm_System as file_pdb_to_openmm_System - tmp_item = file_pdb_to_openmm_System(item, atom_indices=atom_indices, structure_indices=structure_indices, - forcefield=forcefield, non_bonded_method=non_bonded_method, - non_bonded_cutoff=non_bonded_cutoff, constraints=constraints, - rigid_water=rigid_water, remove_cm_motion=remove_cm_motion, - hydrogen_mass=hydrogen_mass, switch_distance=switch_distance, - flexible_constraints=flexible_constraints, check=False) - - return tmp_item + return file_pdb_to_openmm_System(item, atom_indices=atom_indices, structure_indices=structure_indices, + forcefield=forcefield, non_bonded_method=non_bonded_method, + non_bonded_cutoff=non_bonded_cutoff, constraints=constraints, + rigid_water=rigid_water, remove_cm_motion=remove_cm_motion, + hydrogen_mass=hydrogen_mass, switch_distance=switch_distance, + flexible_constraints=flexible_constraints, check=False) def to_openmm_Simulation(item, molecular_system, atom_indices='all', structure_indices='all', @@ -193,66 +143,54 @@ def to_openmm_Simulation(item, molecular_system, atom_indices='all', structure_i rigid_water=True, remove_cm_motion=True, hydrogen_mass=None, switch_distance=None, flexible_constraints=False, integrator='Langevin', temperature='300.0 K', collisions_rate='1.0 1/ps', integration_timestep='2.0 fs', platform='CUDA'): - from molsysmt.item.file_pdb import to_openmm_Simulation as file_pdb_to_openmm_Simulation - tmp_item = file_pdb_to_openmm_Simulation(item, atom_indices=atom_indices, structure_indices=structure_indices, - forcefield=forcefield, non_bonded_method=non_bonded_method, - non_bonded_cutoff=non_bonded_cutoff, constraints=constraints, - rigid_water=rigid_water, remove_cm_motion=remove_cm_motion, - hydrogen_mass=hydrogen_mass, switch_distance=switch_distance, - flexible_constraints=flexible_constraints, integrator=integrator, - temperature=temperature, collisions_rate=collisions_rate, - integration_timestep=integration_timestep, platform=platform, check=False) + return file_pdb_to_openmm_Simulation(item, atom_indices=atom_indices, structure_indices=structure_indices, + forcefield=forcefield, non_bonded_method=non_bonded_method, + non_bonded_cutoff=non_bonded_cutoff, constraints=constraints, + rigid_water=rigid_water, remove_cm_motion=remove_cm_motion, + hydrogen_mass=hydrogen_mass, switch_distance=switch_distance, + flexible_constraints=flexible_constraints, integrator=integrator, + temperature=temperature, collisions_rate=collisions_rate, + integration_timestep=integration_timestep, platform=platform, check=False) - return tmp_item def to_openmm_PDBFile(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.file_pdb import to_openmm_PDBFile as file_pdb_to_openmm_PDBFile - tmp_item = file_pdb_to_openmm_PDBFile(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return file_pdb_to_openmm_PDBFile(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) - return tmp_item def to_pdbfixer_PDBFixer(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.file_pdb import to_pdbfixer_PDBFixer as file_pdb_to_pdbfixer_PDBFixer - tmp_item = file_pdb_to_pdbfixer_PDBFixer(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return file_pdb_to_pdbfixer_PDBFixer(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_pytraj_Trajectory(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.file_pdb import to_pytraj_Trajectory as file_pdb_to_pytraj_Trajectory - tmp_item = file_pdb_to_pytraj_Trajectory(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return file_pdb_to_pytraj_Trajectory(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_pytraj_Topology(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.file_pdb import to_pytraj_Topology as file_pdb_to_pytraj_Topology - tmp_item = file_pdb_to_pytraj_Topology(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return file_pdb_to_pytraj_Topology(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_nglview_NGLWidget(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.file_pdb import to_nglview_NGLWidget as file_pdb_to_nglview_NGLWidget - tmp_item = file_pdb_to_nglview_NGLWidget(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return file_pdb_to_nglview_NGLWidget(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_string_pdb_text(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.file_pdb import to_string_pdb_text as file_pdb_to_string_pdb_text - tmp_item = file_pdb_to_string_pdb_text(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) - - return tmp_item - - + return file_pdb_to_string_pdb_text(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) diff --git a/molsysmt/api_forms/api_file_prmtop.py b/molsysmt/api_forms/api_file_prmtop.py index 8b14949db..d316ef6e4 100644 --- a/molsysmt/api_forms/api_file_prmtop.py +++ b/molsysmt/api_forms/api_file_prmtop.py @@ -1,138 +1,105 @@ from molsysmt._private.exceptions import * - from molsysmt.item.file_prmtop.is_file_prmtop import is_file_prmtop as is_form from molsysmt.item.file_prmtop.extract import extract from molsysmt.item.file_prmtop.add import add from molsysmt.item.file_prmtop.append_structures import append_structures from molsysmt.item.file_prmtop.get import * from molsysmt.item.file_prmtop.set import * +from .form_attributes import form_attributes + +form_name = 'file:prmtop' +form_type = 'file' +form_info = ["AMBER parameter/topology file format", + "https://ambermd.org/FileFormats.php#topology"] + +form_attributes = form_attributes() +form_attributes['atom_index'] = True +form_attributes['atom_id'] = True +form_attributes['atom_name'] = True +form_attributes['atom_type'] = True +form_attributes['bond_index'] = True +form_attributes['bond_id'] = True +form_attributes['bond_name'] = True +form_attributes['bond_type'] = True +form_attributes['bond_order'] = True +form_attributes['group_index'] = True +form_attributes['group_id'] = True +form_attributes['group_name'] = True +form_attributes['group_type'] = True +form_attributes['component_index'] = True +form_attributes['molecule_index'] = True +form_attributes['molecule_id'] = True +form_attributes['molecule_name'] = True +form_attributes['molecule_type'] = True +form_attributes['chain_index'] = True +form_attributes['chain_id'] = True +form_attributes['chain_name'] = True +form_attributes['chain_type'] = True +form_attributes['box'] = True +form_attributes['forcefield_parameters'] = True -form_name='file:prmtop' -form_type='file' -form_info = ["AMBER parameter/topology file format","https://ambermd.org/FileFormats.php#topology"] - -form_attributes = { - - 'atom_index' : True, - 'atom_id' : True, - 'atom_name' : True, - 'atom_type' : True, - - 'bond_index' : True, - 'bond_id' : True, - 'bond_name' : True, - 'bond_type' : True, - 'bond_order' : True, - - 'group_index' : True, - 'group_id' : True, - 'group_name' : True, - 'group_type' : True, - - 'component_index' : True, - 'component_id' : False, - 'component_name' : False, - 'component_type' : False, - - 'molecule_index' : True, - 'molecule_id' : True, - 'molecule_name' : True, - 'molecule_type' : True, - - 'chain_index' : True, - 'chain_id' : True, - 'chain_name' : True, - 'chain_type' : True, - - 'entity_index' : False, - 'entity_id' : False, - 'entity_name' : False, - 'entity_type' : False, - - 'coordinates' : False, - 'velocities' : False, - 'box' : True, - 'time' : False, - 'step' : False, - - 'forcefield_parameters' : True, - - 'forcefield' : False, - 'temperature' : False, - 'pressure' : False, - 'integrator' : False, - 'damping' : False, -} def to_file_pdb(item, molecular_system, atom_indices='all', structure_indices='all', output_filename=None): - from molsysmt.item.file_prmtop import to_file_pdb as file_prmtop_to_file_pdb + from molsysmt.basic import get - coordinates = get(molecular_system, element='atom', indices=atom_indices, structure_indices=structure_indices, coordinates=True, check=False) - tmp_item = file_prmtop_to_file_pdb(item, atom_indices=atom_indices, coordinates=coordinates, output_filename=output_filename, check=False) + coordinates = get(molecular_system, element='atom', indices=atom_indices, structure_indices=structure_indices, + coordinates=True, check=False) + return file_prmtop_to_file_pdb(item, atom_indices=atom_indices, coordinates=coordinates, + output_filename=output_filename, check=False) - return tmp_item def to_mdtraj_Topology(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.file_prmtop import to_mdtraj_Topology as file_prmtop_to_mdtraj_Topology - tmp_item = file_prmtop_to_mdtraj_Topology(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return file_prmtop_to_mdtraj_Topology(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_molsysmt_MolSys(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.file_prmtop import to_molsysmt_MolSys as file_prmtop_to_molsysmt_MolSys + from molsysmt.basic import get - coordinates = get(molecular_system, element='atom', indices=atom_indices, structure_indices=structure_indices, coordinates=True, check=False) - tmp_item = file_prmtop_to_molsysmt_MolSys(item, atom_indices=atom_indices, coordinates=coordinates, check=False) + coordinates = get(molecular_system, element='atom', indices=atom_indices, structure_indices=structure_indices, + coordinates=True, check=False) + return file_prmtop_to_molsysmt_MolSys(item, atom_indices=atom_indices, coordinates=coordinates, check=False) - return tmp_item def to_molsysmt_Topology(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.file_prmtop import to_molsysmt_Topology as file_prmtop_to_molsysmt_Topology - tmp_item = file_prmtop_to_molsysmt_Topology(item, atom_indices=atom_indices, check=False) + return file_prmtop_to_molsysmt_Topology(item, atom_indices=atom_indices, check=False) - return tmp_item def to_nglview_NGLWidget(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.file_prmtop import to_nglview_NGLWidget as file_prmtop_to_nglview_NGLWidget + from molsysmt.basic import get - coordinates = get(molecular_system, atom_indices=atom_indices, structure_indices=structure_indices, coordinates=True, check=False) - tmp_item = file_prmtop_to_nglview_NGLWidget(item, atom_indices=atom_indices, coordinates=coordinates, check=False) + coordinates = get(molecular_system, atom_indices=atom_indices, structure_indices=structure_indices, + coordinates=True, check=False) + return file_prmtop_to_nglview_NGLWidget(item, atom_indices=atom_indices, coordinates=coordinates, check=False) - return tmp_item def to_openmm_AmberPrmtopFile(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.file_prmtop import to_openmm_AmberPrmtopFile as file_prmtop_to_openmm_AmberPrmtopFile - tmp_item = file_prmtop_to_nglview_NGLWidget(item, atom_indices=atom_indices, check=False) + return file_prmtop_to_nglview_NGLWidget(item, atom_indices=atom_indices, check=False) - return tmp_item def to_openmm_Topology(item, molecular_system=None, atom_indices='all', structure_indices='all'): - from molsysmt.item.file_prmtop import to_openmm_Topology as file_prmtop_to_openmm_Topology - tmp_item = file_prmtop_to_openmm_Topology(item, atom_indices=atom_indices, check=False) + return file_prmtop_to_openmm_Topology(item, atom_indices=atom_indices, check=False) - return tmp_item def to_openmm_Modeller(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.file_prmtop import to_openmm_Modeller as file_prmtop_to_openmm_Modeller - from molsysmt.basic import get - - coordinates = get(molecular_system, atom_indices=atom_indices, structure_indices=structure_indices, coordinates=True, check=False) - tmp_item = file_prmtop_to_openmm_Modeller(item, atom_indices=atom_indices, coordinates=coordinates, check=False) - return tmp_item + from molsysmt.basic import get + coordinates = get(molecular_system, atom_indices=atom_indices, structure_indices=structure_indices, + coordinates=True, check=False) + return file_prmtop_to_openmm_Modeller(item, atom_indices=atom_indices, coordinates=coordinates, check=False) diff --git a/molsysmt/api_forms/api_file_xtc.py b/molsysmt/api_forms/api_file_xtc.py index 5e9d270ec..944efc538 100644 --- a/molsysmt/api_forms/api_file_xtc.py +++ b/molsysmt/api_forms/api_file_xtc.py @@ -1,90 +1,39 @@ from molsysmt._private.exceptions import * - from molsysmt.item.file_xtc.is_file_xtc import is_file_xtc as is_form from molsysmt.item.file_xtc.extract import extract from molsysmt.item.file_xtc.add import add from molsysmt.item.file_xtc.append_structures import append_structures from molsysmt.item.file_xtc.get import * from molsysmt.item.file_xtc.set import * +from .form_attributes import form_attributes -form_name='file:xtc' -form_type='file' -form_info=["",""] - -form_attributes = { - - 'atom_index' : False, - 'atom_id' : False, - 'atom_name' : False, - 'atom_type' : False, - - 'bond_index' : False, - 'bond_id' : False, - 'bond_name' : False, - 'bond_type' : False, - 'bond_order' : False, - - 'group_index' : False, - 'group_id' : False, - 'group_name' : False, - 'group_type' : False, - - 'component_index' : False, - 'component_id' : False, - 'component_name' : False, - 'component_type' : False, - - 'molecule_index' : False, - 'molecule_id' : False, - 'molecule_name' : False, - 'molecule_type' : False, - - 'chain_index' : False, - 'chain_id' : False, - 'chain_name' : False, - 'chain_type' : False, +form_name = 'file:xtc' +form_type = 'file' +form_info = ["", ""] - 'entity_index' : False, - 'entity_id' : False, - 'entity_name' : False, - 'entity_type' : False, +form_attributes = form_attributes() +form_attributes['coordinates'] = True +form_attributes['box'] = True +form_attributes['time'] = True +form_attributes['step'] = True - 'coordinates' : True, - 'velocities' : False, - 'box' : True, - 'time' : True, - 'step' : True, - - 'forcefield_parameters' : False, - - 'forcefield' : False, - 'temperature' : False, - 'pressure' : False, - 'integrator' : False, - 'damping' : False, -} def to_molsysmt_Structures(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.file_xtc import to_molsysmt_Structures as file_xtc_to_molsysmt_Structures - tmp_item = file_xtc_to_molsysmt_Structures(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return file_xtc_to_molsysmt_Structures(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_mdtraj_XTCTrajectoryFile(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.file_xtc import to_mdtraj_XTCTrajectoryFile as file_xtc_to_mdtraj_XTCTrajectoryFile - tmp_item = file_xtc_to_mdtraj_XTCTrajectoryFile(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return file_xtc_to_mdtraj_XTCTrajectoryFile(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_mdtraj_Trajectory(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.file_xtc import to_mdtraj_Trajectory as file_xtc_to_mdtraj_Trajectory - tmp_item = file_xtc_to_mdtraj_Trajectory(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) - - return tmp_item - + return file_xtc_to_mdtraj_Trajectory(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) diff --git a/molsysmt/api_forms/api_file_xyznpy.py b/molsysmt/api_forms/api_file_xyznpy.py index e21e46e0a..90014973e 100644 --- a/molsysmt/api_forms/api_file_xyznpy.py +++ b/molsysmt/api_forms/api_file_xyznpy.py @@ -1,75 +1,21 @@ from molsysmt._private.exceptions import * - from molsysmt.item.file_xyznpy.is_file_xyznpy import is_file_xyznpy as is_form from molsysmt.item.file_xyznpy.extract import extract from molsysmt.item.file_xyznpy.add import add from molsysmt.item.file_xyznpy.append_structures import append_structures from molsysmt.item.file_xyznpy.get import * from molsysmt.item.file_xyznpy.set import * +from .form_attributes import form_attributes -form_name='file:xyznpy' -form_type='file' -form_info = ["XYZ file format like saved with Numpy",""] - - -form_attributes = { - - 'atom_index' : False, - 'atom_id' : False, - 'atom_name' : False, - 'atom_type' : False, - - 'bond_index' : False, - 'bond_id' : False, - 'bond_name' : False, - 'bond_type' : False, - 'bond_order' : False, - - 'group_index' : False, - 'group_id' : False, - 'group_name' : False, - 'group_type' : False, - - 'component_index' : False, - 'component_id' : False, - 'component_name' : False, - 'component_type' : False, - - 'molecule_index' : False, - 'molecule_id' : False, - 'molecule_name' : False, - 'molecule_type' : False, +form_name = 'file:xyznpy' +form_type = 'file' +form_info = ["XYZ file format like saved with Numpy", ""] - 'chain_index' : False, - 'chain_id' : False, - 'chain_name' : False, - 'chain_type' : False, - - 'entity_index' : False, - 'entity_id' : False, - 'entity_name' : False, - 'entity_type' : False, - - 'coordinates' : True, - 'velocities' : False, - 'box' : False, - 'time' : False, - 'step' : False, - - 'forcefield' : False, - 'temperature' : False, - 'pressure' : False, - 'integrator' : False, - 'damping' : False, -} +form_attributes = form_attributes() +form_attributes['coordinates'] = True def to_XYZ(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.file_xyznpy import to_XYZ as file_xyznpy_to_XYZ - tmp_item = file_xyznpy_to_XYZ(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) - - return tmp_item - - + return file_xyznpy_to_XYZ(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) diff --git a/molsysmt/api_forms/api_mdanalysis_Topology.py b/molsysmt/api_forms/api_mdanalysis_Topology.py index 893f7d894..c0f075ff7 100644 --- a/molsysmt/api_forms/api_mdanalysis_Topology.py +++ b/molsysmt/api_forms/api_mdanalysis_Topology.py @@ -1,65 +1,37 @@ from molsysmt._private.exceptions import * import numpy as np - from molsysmt.item.mdanalysis_Topology.is_mdanalysis_Topology import is_mdanalysis_Topology as is_form from molsysmt.item.mdanalysis_Topology.extract import extract from molsysmt.item.mdanalysis_Topology.add import add from molsysmt.item.mdanalysis_Topology.append_structures import append_structures from molsysmt.item.mdanalysis_Topology.get import * from molsysmt.item.mdanalysis_Topology.set import * - -form_name='mdanalysis.Topology' -form_type='class' -form_info=["",""] - -form_attributes = { - - 'atom_index' : True, - 'atom_id' : True, - 'atom_name' : True, - 'atom_type' : True, - - 'bond_index' : True, - 'bond_id' : True, - 'bond_name' : True, - 'bond_type' : True, - 'bond_order' : True, - - 'group_index' : True, - 'group_id' : True, - 'group_name' : True, - 'group_type' : True, - - 'component_index' : True, - 'component_id' : False, - 'component_name' : False, - 'component_type' : False, - - 'molecule_index' : True, - 'molecule_id' : True, - 'molecule_name' : True, - 'molecule_type' : True, - - 'chain_index' : True, - 'chain_id' : True, - 'chain_name' : True, - 'chain_type' : True, - - 'entity_index' : False, - 'entity_id' : False, - 'entity_name' : False, - 'entity_type' : False, - - 'coordinates' : False, - 'velocities' : False, - 'box' : False, - 'time' : False, - 'step' : False, - - 'forcefield' : False, - 'temperature' : False, - 'pressure' : False, - 'integrator' : False, - 'damping' : False, -} - +from .form_attributes import form_attributes + +form_name = 'mdanalysis.Topology' +form_type = 'class' +form_info = ["", ""] + +form_attributes = form_attributes() +form_attributes['atom_index'] = True +form_attributes['atom_id'] = True +form_attributes['atom_name'] = True +form_attributes['atom_type'] = True +form_attributes['bond_index'] = True +form_attributes['bond_id'] = True +form_attributes['bond_name'] = True +form_attributes['bond_type'] = True +form_attributes['bond_order'] = True +form_attributes['group_index'] = True +form_attributes['group_id'] = True +form_attributes['group_name'] = True +form_attributes['group_type'] = True +form_attributes['component_index'] = True +form_attributes['molecule_index'] = True +form_attributes['molecule_id'] = True +form_attributes['molecule_name'] = True +form_attributes['molecule_type'] = True +form_attributes['chain_index'] = True +form_attributes['chain_id'] = True +form_attributes['chain_name'] = True +form_attributes['chain_type'] = True diff --git a/molsysmt/api_forms/api_mdanalysis_Universe.py b/molsysmt/api_forms/api_mdanalysis_Universe.py index 463b4f888..7bb42ff49 100644 --- a/molsysmt/api_forms/api_mdanalysis_Universe.py +++ b/molsysmt/api_forms/api_mdanalysis_Universe.py @@ -1,118 +1,81 @@ from molsysmt._private.exceptions import * import numpy as np - from molsysmt.item.mdanalysis_Universe.is_mdanalysis_Universe import is_mdanalysis_Universe as is_form from molsysmt.item.mdanalysis_Universe.extract import extract from molsysmt.item.mdanalysis_Universe.add import add from molsysmt.item.mdanalysis_Universe.append_structures import append_structures from molsysmt.item.mdanalysis_Universe.get import * from molsysmt.item.mdanalysis_Universe.set import * +from .form_attributes import form_attributes + +form_name = 'mdanalysis.Universe' +form_type = 'class' +form_info = ["", ""] + +form_attributes = form_attributes() +form_attributes['atom_index'] = True +form_attributes['atom_id'] = True +form_attributes['atom_name'] = True +form_attributes['atom_type'] = True +form_attributes['bond_index'] = True +form_attributes['bond_id'] = True +form_attributes['bond_name'] = True +form_attributes['bond_type'] = True +form_attributes['bond_order'] = True +form_attributes['group_index'] = True +form_attributes['group_id'] = True +form_attributes['group_name'] = True +form_attributes['group_type'] = True +form_attributes['component_index'] = True +form_attributes['molecule_index'] = True +form_attributes['molecule_id'] = True +form_attributes['molecule_name'] = True +form_attributes['molecule_type'] = True +form_attributes['chain_index'] = True +form_attributes['chain_id'] = True +form_attributes['chain_name'] = True +form_attributes['chain_type'] = True +form_attributes['coordinates'] = True +form_attributes['box'] = True -form_name='mdanalysis.Universe' -form_type='class' -form_info=["",""] - -form_attributes = { - - 'atom_index' : True, - 'atom_id' : True, - 'atom_name' : True, - 'atom_type' : True, - - 'bond_index' : True, - 'bond_id' : True, - 'bond_name' : True, - 'bond_type' : True, - 'bond_order' : True, - - 'group_index' : True, - 'group_id' : True, - 'group_name' : True, - 'group_type' : True, - - 'component_index' : True, - 'component_id' : False, - 'component_name' : False, - 'component_type' : False, - - 'molecule_index' : True, - 'molecule_id' : True, - 'molecule_name' : True, - 'molecule_type' : True, - - 'chain_index' : True, - 'chain_id' : True, - 'chain_name' : True, - 'chain_type' : True, - - 'entity_index' : False, - 'entity_id' : False, - 'entity_name' : False, - 'entity_type' : False, - - 'coordinates' : True, - 'velocities' : False, - 'box' : True, - 'time' : False, - 'step' : False, - - 'forcefield' : False, - 'temperature' : False, - 'pressure' : False, - 'integrator' : False, - 'damping' : False, -} def to_nglview_NGLWidget(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.mdanalysis_Universe import to_nglview_NGLWidget as mdanalysis_Universe_to_nglview_NGLWidget - tmp_item = mdanalysis_Universe_to_nglview_NGLWidget(item, atom_indices=atom_indices, - structure_indices=structure_indices, check=False) + return mdanalysis_Universe_to_nglview_NGLWidget(item, atom_indices=atom_indices, + structure_indices=structure_indices, check=False) - return tmp_item def to_file_pdb(item, molecular_system, atom_indices='all', structure_indices='all', output_filename=None): - from molsysmt.item.mdanalysis_Universe import to_file_pdb as mdanalysis_Universe_to_file_pdb - tmp_item = mdanalysis_Universe_to_file_pdb(item, atom_indices=atom_indices, - structure_indices=structure_indices, output_filename=output_filename, check=False) + return mdanalysis_Universe_to_file_pdb(item, atom_indices=atom_indices, + structure_indices=structure_indices, output_filename=output_filename, + check=False) - return tmp_item - -def to_mdtraj_Trajectory (item, molecular_system, atom_indices='all', structure_indices='all'): +def to_mdtraj_Trajectory(item, molecular_system, atom_indices='all', structure_indices='all'): from molsysmt.item.mdanalysis_Universe import to_mdtraj_Trajectory as mdanalysis_Universe_to_mdtraj_Trajectory - tmp_item = mdanalysis_Universe_to_mdtraj_Trajectory(item, atom_indices=atom_indices, - structure_indices=structure_indices, check=False) - - return tmp_item + return mdanalysis_Universe_to_mdtraj_Trajectory(item, atom_indices=atom_indices, + structure_indices=structure_indices, check=False) -def to_molsysmt_MolSys (item, molecular_system, atom_indices='all', structure_indices='all'): +def to_molsysmt_MolSys(item, molecular_system, atom_indices='all', structure_indices='all'): from molsysmt.item.mdanalysis_Universe import to_molsysmt_MolSys as mdanalysis_Universe_to_molsysmt_MolSys - tmp_item = mdanalysis_Universe_to_molsysmt_MolSys(item, atom_indices=atom_indices, - structure_indices=structure_indices, check=False) + return mdanalysis_Universe_to_molsysmt_MolSys(item, atom_indices=atom_indices, + structure_indices=structure_indices, check=False) - return tmp_item - -def to_molsysmt_Structures (item, molecular_system, atom_indices='all', structure_indices='all'): +def to_molsysmt_Structures(item, molecular_system, atom_indices='all', structure_indices='all'): from molsysmt.item.mdanalysis_Universe import to_molsysmt_MolSys as mdanalysis_Universe_to_molsysmt_Structures - tmp_item = mdanalysis_Universe_to_molsysmt_Structures(item, atom_indices=atom_indices, - structure_indices=structure_indices, check=False) - - return tmp_item + return mdanalysis_Universe_to_molsysmt_Structures(item, atom_indices=atom_indices, + structure_indices=structure_indices, check=False) -def to_molsysmt_Topology (item, molecular_system, atom_indices='all', structure_indices='all'): +def to_molsysmt_Topology(item, molecular_system, atom_indices='all', structure_indices='all'): from molsysmt.item.mdanalysis_Universe import to_molsysmt_Topology as mdanalysis_Universe_to_molsysmt_Topology - tmp_item = mdanalysis_Universe_to_molsysmt_Topology(item, atom_indices=atom_indices, check=False) - - return tmp_item - + return mdanalysis_Universe_to_molsysmt_Topology(item, atom_indices=atom_indices, check=False) diff --git a/molsysmt/api_forms/api_mdtraj_HDF5TrajectoryFile.py b/molsysmt/api_forms/api_mdtraj_HDF5TrajectoryFile.py index cff691510..0bc19dfe5 100644 --- a/molsysmt/api_forms/api_mdtraj_HDF5TrajectoryFile.py +++ b/molsysmt/api_forms/api_mdtraj_HDF5TrajectoryFile.py @@ -1,106 +1,80 @@ from molsysmt._private.exceptions import * - from molsysmt.item.mdtraj_HDF5TrajectoryFile.is_mdtraj_HDF5TrajectoryFile import is_mdtraj_HDF5TrajectoryFile as is_form from molsysmt.item.mdtraj_HDF5TrajectoryFile.extract import extract from molsysmt.item.mdtraj_HDF5TrajectoryFile.add import add from molsysmt.item.mdtraj_HDF5TrajectoryFile.append_structures import append_structures from molsysmt.item.mdtraj_HDF5TrajectoryFile.get import * from molsysmt.item.mdtraj_HDF5TrajectoryFile.set import * +from .form_attributes import form_attributes + +form_name = 'mdtraj.HDF5TrajectoryFile' +form_type = 'class' +form_info = ["", ""] + +form_attributes = form_attributes() +form_attributes['atom_index'] = True +form_attributes['atom_id'] = True +form_attributes['atom_name'] = True +form_attributes['atom_type'] = True +form_attributes['bond_index'] = True +form_attributes['bond_id'] = True +form_attributes['bond_name'] = True +form_attributes['bond_type'] = True +form_attributes['bond_order'] = True +form_attributes['group_index'] = True +form_attributes['group_id'] = True +form_attributes['group_name'] = True +form_attributes['group_type'] = True +form_attributes['component_index'] = True +form_attributes['molecule_index'] = True +form_attributes['molecule_id'] = True +form_attributes['molecule_name'] = True +form_attributes['molecule_type'] = True +form_attributes['chain_index'] = True +form_attributes['chain_id'] = True +form_attributes['chain_name'] = True +form_attributes['chain_type'] = True +form_attributes['coordinates'] = True +form_attributes['velocities'] = True +form_attributes['box'] = True +form_attributes['time'] = True +form_attributes['step'] = True +form_attributes['forcefield_parameters'] = True -form_name='mdtraj.HDF5TrajectoryFile' -form_type='class' -form_info=["",""] - -form_attributes = { - - 'atom_index' : True, - 'atom_id' : True, - 'atom_name' : True, - 'atom_type' : True, - - 'bond_index' : True, - 'bond_id' : True, - 'bond_name' : True, - 'bond_type' : True, - 'bond_order' : True, - - 'group_index' : True, - 'group_id' : True, - 'group_name' : True, - 'group_type' : True, - - 'component_index' : True, - 'component_id' : False, - 'component_name' : False, - 'component_type' : False, - - 'molecule_index' : True, - 'molecule_id' : True, - 'molecule_name' : True, - 'molecule_type' : True, - - 'chain_index' : True, - 'chain_id' : True, - 'chain_name' : True, - 'chain_type' : True, - - 'entity_index' : False, - 'entity_id' : False, - 'entity_name' : False, - 'entity_type' : False, - - 'coordinates' : True, - 'velocities' : True, - 'box' : True, - 'time' : True, - 'step' : True, - - 'forcefield_parameters' : True, - - 'forcefield' : False, - 'temperature' : False, - 'pressure' : False, - 'integrator' : False, - 'damping' : False, -} def to_mdtraj_Topology(item, molecular_system, atom_indices='all', structure_indices='all'): + from molsysmt.item.mdtraj_HDF5TrajectoryFile import \ + to_mdtraj_Topology as mdtraj_HDF5TrajectoryFile_to_mdtraj_Topology - from molsysmt.item.mdtraj_HDF5TrajectoryFile import to_mdtraj_Topology as mdtraj_HDF5TrajectoryFile_to_mdtraj_Topology - - tmp_item = mdtraj_HDF5TrajectoryFile_to_mdtraj_Topology(item, atom_indices=atom_indices, check=False) + return mdtraj_HDF5TrajectoryFile_to_mdtraj_Topology(item, atom_indices=atom_indices, check=False) - return tmp_item def to_openmm_Topology(item, molecular_system, atom_indices='all', structure_indices='all'): + from molsysmt.item.mdtraj_HDF5TrajectoryFile import \ + to_openmm_Topology as mdtraj_HDF5TrajectoryFile_to_openmm_Topology - from molsysmt.item.mdtraj_HDF5TrajectoryFile import to_openmm_Topology as mdtraj_HDF5TrajectoryFile_to_openmm_Topology + return mdtraj_HDF5TrajectoryFile_to_openmm_Topology(item, atom_indices=atom_indices, check=False) - tmp_item = mdtraj_HDF5TrajectoryFile_to_openmm_Topology(item, atom_indices=atom_indices, check=False) - - return tmp_item def to_molsysmt_MolSys(item, molecular_system, atom_indices='all', structure_indices='all'): + from molsysmt.item.mdtraj_HDF5TrajectoryFile import \ + to_molsysmt_MolSys as mdtraj_HDF5TrajectoryFile_to_molsysmt_MolSys - from molsysmt.item.mdtraj_HDF5TrajectoryFile import to_molsysmt_MolSys as mdtraj_HDF5TrajectoryFile_to_molsysmt_MolSys - - tmp_item = mdtraj_HDF5TrajectoryFile_to_molsysmt_MolSys(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return mdtraj_HDF5TrajectoryFile_to_molsysmt_MolSys(item, atom_indices=atom_indices, + structure_indices=structure_indices, check=False) - return tmp_item def to_molsysmt_Topology(item, molecular_system, atom_indices='all', structure_indices='all'): + from molsysmt.item.mdtraj_HDF5TrajectoryFile import \ + to_molsysmt_Topology as mdtraj_HDF5TrajectoryFile_to_molsysmt_Topology - from molsysmt.item.mdtraj_HDF5TrajectoryFile import to_molsysmt_Topology as mdtraj_HDF5TrajectoryFile_to_molsysmt_Topology + return mdtraj_HDF5TrajectoryFile_to_molsysmt_Topology(item, atom_indices=atom_indices, + structure_indices=structure_indices, check=False) - tmp_item = mdtraj_HDF5TrajectoryFile_to_molsysmt_Topology(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) - - return tmp_item def to_molsysmt_Structures(item, molecular_system, atom_indices='all', structure_indices='all'): + from molsysmt.item.mdtraj_HDF5TrajectoryFile import \ + to_molsysmt_Structures as mdtraj_HDF5TrajectoryFile_to_molsysmt_Structures - from molsysmt.item.mdtraj_HDF5TrajectoryFile import to_molsysmt_Structures as mdtraj_HDF5TrajectoryFile_to_molsysmt_Structures - - tmp_item = mdtraj_HDF5TrajectoryFile_to_molsysmt_Structures(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) - - return tmp_item - + return mdtraj_HDF5TrajectoryFile_to_molsysmt_Structures(item, atom_indices=atom_indices, + structure_indices=structure_indices, check=False) diff --git a/molsysmt/api_forms/api_mdtraj_Topology.py b/molsysmt/api_forms/api_mdtraj_Topology.py index 45b6b70e2..9bd45f1f4 100644 --- a/molsysmt/api_forms/api_mdtraj_Topology.py +++ b/molsysmt/api_forms/api_mdtraj_Topology.py @@ -1,143 +1,99 @@ from molsysmt._private.exceptions import * - from molsysmt.item.mdtraj_Topology.is_mdtraj_Topology import is_mdtraj_Topology as is_form from molsysmt.item.mdtraj_Topology.extract import extract from molsysmt.item.mdtraj_Topology.add import add from molsysmt.item.mdtraj_Topology.append_structures import append_structures from molsysmt.item.mdtraj_Topology.get import * from molsysmt.item.mdtraj_Topology.set import * - -form_name='mdtraj.Topology' -form_type='class' -form_info=["",""] - -form_attributes = { - - 'atom_index' : True, - 'atom_id' : True, - 'atom_name' : True, - 'atom_type' : True, - - 'bond_index' : True, - 'bond_id' : True, - 'bond_name' : True, - 'bond_type' : True, - 'bond_order' : True, - - 'group_index' : True, - 'group_id' : True, - 'group_name' : True, - 'group_type' : True, - - 'component_index' : True, - 'component_id' : False, - 'component_name' : False, - 'component_type' : False, - - 'molecule_index' : True, - 'molecule_id' : True, - 'molecule_name' : True, - 'molecule_type' : True, - - 'chain_index' : True, - 'chain_id' : True, - 'chain_name' : True, - 'chain_type' : True, - - 'entity_index' : False, - 'entity_id' : False, - 'entity_name' : False, - 'entity_type' : False, - - 'coordinates' : False, - 'velocities' : False, - 'box' : False, - 'time' : False, - 'step' : False, - - 'forcefield' : False, - 'temperature' : False, - 'pressure' : False, - 'integrator' : False, - 'damping' : False, -} +from .form_attributes import form_attributes + +form_name = 'mdtraj.Topology' +form_type = 'class' +form_info = ["", ""] + +form_attributes = form_attributes() +form_attributes['atom_index'] = True +form_attributes['atom_id'] = True +form_attributes['atom_name'] = True +form_attributes['atom_type'] = True +form_attributes['bond_index'] = True +form_attributes['bond_id'] = True +form_attributes['bond_name'] = True +form_attributes['bond_type'] = True +form_attributes['bond_order'] = True +form_attributes['group_index'] = True +form_attributes['group_id'] = True +form_attributes['group_name'] = True +form_attributes['group_type'] = True +form_attributes['component_index'] = True +form_attributes['molecule_index'] = True +form_attributes['molecule_id'] = True +form_attributes['molecule_name'] = True +form_attributes['molecule_type'] = True +form_attributes['chain_index'] = True +form_attributes['chain_id'] = True +form_attributes['chain_name'] = True +form_attributes['chain_type'] = True ## To other form - def to_string_aminoacids3(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.mdtraj_Topology import to_string_aminoacids3 as mdtraj_Topology_to_string_aminoacids3 + from molsysmt.item.mdtraj_Topology import get_group_index_from_atom group_indices = get_group_index_from_atom(item, indices=atom_indices, check=False) - tmp_item = mdtraj_Topology_to_string_aminoacids3(item, group_indices=group_indices, check=False) + return mdtraj_Topology_to_string_aminoacids3(item, group_indices=group_indices, check=False) - return tmp_item def to_string_aminoacids1(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.mdtraj_Topology import to_string_aminoacids1 as mdtraj_Topology_to_string_aminoacids1 + from molsysmt.item.mdtraj_Topology import get_group_index_from_atom group_indices = get_group_index_from_atom(item, indices=atom_indices, check=False) - tmp_item = mdtraj_Topology_to_string_aminoacids1(item, group_indices=group_indices, check=False) + return mdtraj_Topology_to_string_aminoacids1(item, group_indices=group_indices, check=False) - return tmp_item def to_molsysmt_Topology(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.mdtraj_Topology import to_molsysmt_Topology as mdtraj_Topology_to_molsysmt_Topology - tmp_item = mdtraj_Topology_to_molsysmt_Topology(item, atom_indices=atom_indices, check=False) + return mdtraj_Topology_to_molsysmt_Topology(item, atom_indices=atom_indices, check=False) - return tmp_item def to_openmm_Topology(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.mdtraj_Topology import to_openmm_Topology as mdtraj_Topology_to_openmm_Topology - tmp_item = mdtraj_Topology_to_openmm_Topology(item, atom_indices=atom_indices, check=False) + return mdtraj_Topology_to_openmm_Topology(item, atom_indices=atom_indices, check=False) - return tmp_item def to_parmed_Structure(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.mdtraj_Topology import to_parmed_Structure as mdtraj_Topology_to_parmed_Structure - tmp_item = mdtraj_Topology_to_parmed_Structure(item, atom_indices=atom_indices, check=False) + return mdtraj_Topology_to_parmed_Structure(item, atom_indices=atom_indices, check=False) - return tmp_item def to_parmed_GromacsTopologyFile(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.mdtraj_Topology import to_parmed_Structure as mdtraj_Topology_to_parmed_Structure - tmp_item = mdtraj_Topology_to_parmed_Structure(item, atom_indices=atom_indices, check=False) + return mdtraj_Topology_to_parmed_Structure(item, atom_indices=atom_indices, check=False) - return tmp_item def to_file_top(item, molecular_system, atom_indices='all', structure_indices='all', output_filename=None): - from molsysmt.item.mdtraj_Topology import to_file_top as mdtraj_Topology_to_file_top - tmp_item = mdtraj_Topology_to_parmed_Structure(item, atom_indices=atom_indices, output_filename=output_filename, check=False) + return mdtraj_Topology_to_parmed_Structure(item, atom_indices=atom_indices, output_filename=output_filename, + check=False) - return tmp_item def to_mdtraj_Trajectory(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.mdtraj_Topology import to_mdtraj_Trajectory as mdtraj_Topology_to_mdtraj_Trajectory + from molsysmt.basic import get coordinates = get(molecular_system, element='atom', selection=atom_indices, - structure_indices=structure_indices, coordinates=True, check=False) + structure_indices=structure_indices, coordinates=True, check=False) box = get(molecular_system, element='system', structure_indices=structure_indices, box=True, - check=False) - - tmp_item = mdtraj_Topology_to_mdtraj_Trajectory(item, atom_indices=atom_indices, - coordinates=coordinates, box=box, check=False) - - return tmp_item - - + check=False) + return mdtraj_Topology_to_mdtraj_Trajectory(item, atom_indices=atom_indices, + coordinates=coordinates, box=box, check=False) diff --git a/molsysmt/api_forms/api_mdtraj_Trajectory.py b/molsysmt/api_forms/api_mdtraj_Trajectory.py index a453a562b..c7d6e289f 100644 --- a/molsysmt/api_forms/api_mdtraj_Trajectory.py +++ b/molsysmt/api_forms/api_mdtraj_Trajectory.py @@ -1,199 +1,149 @@ from molsysmt._private.exceptions import * import numpy as np - from molsysmt.item.mdtraj_Trajectory.is_mdtraj_Trajectory import is_mdtraj_Trajectory as is_form from molsysmt.item.mdtraj_Trajectory.extract import extract from molsysmt.item.mdtraj_Trajectory.add import add from molsysmt.item.mdtraj_Trajectory.append_structures import append_structures from molsysmt.item.mdtraj_Trajectory.get import * from molsysmt.item.mdtraj_Trajectory.set import * +from .form_attributes import form_attributes + +form_name = 'mdtraj.Trajectory' +form_type = 'class' +form_info = ["", ""] + +form_attributes = form_attributes() +form_attributes['atom_index'] = True +form_attributes['atom_id'] = True +form_attributes['atom_name'] = True +form_attributes['atom_type'] = True +form_attributes['bond_index'] = True +form_attributes['bond_id'] = True +form_attributes['bond_name'] = True +form_attributes['bond_type'] = True +form_attributes['bond_order'] = True +form_attributes['group_index'] = True +form_attributes['group_id'] = True +form_attributes['group_name'] = True +form_attributes['group_type'] = True +form_attributes['component_index'] = True +form_attributes['molecule_index'] = True +form_attributes['molecule_id'] = True +form_attributes['molecule_name'] = True +form_attributes['molecule_type'] = True +form_attributes['chain_index'] = True +form_attributes['chain_id'] = True +form_attributes['chain_name'] = True +form_attributes['chain_type'] = True +form_attributes['coordinates'] = True +form_attributes['box'] = True -form_name='mdtraj.Trajectory' -form_type='class' -form_info=["",""] - -form_attributes = { - - 'atom_index' : True, - 'atom_id' : True, - 'atom_name' : True, - 'atom_type' : True, - - 'bond_index' : True, - 'bond_id' : True, - 'bond_name' : True, - 'bond_type' : True, - 'bond_order' : True, - - 'group_index' : True, - 'group_id' : True, - 'group_name' : True, - 'group_type' : True, - - 'component_index' : True, - 'component_id' : False, - 'component_name' : False, - 'component_type' : False, - - 'molecule_index' : True, - 'molecule_id' : True, - 'molecule_name' : True, - 'molecule_type' : True, - - 'chain_index' : True, - 'chain_id' : True, - 'chain_name' : True, - 'chain_type' : True, - - 'entity_index' : False, - 'entity_id' : False, - 'entity_name' : False, - 'entity_type' : False, - - 'coordinates' : True, - 'velocities' : False, - 'box' : True, - 'time' : False, - 'step' : False, - - 'forcefield' : False, - 'temperature' : False, - 'pressure' : False, - 'integrator' : False, - 'damping' : False, -} def to_string_aminoacids3(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.mdtraj_Trajectory import to_string_aminoacids3 as mdtraj_Trajectory_to_string_aminoacids3 + from molsysmt.item.mdtraj_Trajectory import get_group_index_from_atom group_indices = get_group_index_from_atom(item, indices=atom_indices, check=False) group_indices = np.unique(group_indices) - tmp_item = mdtraj_Trajectory_to_string_aminoacids3(item, group_indices=group_indices, check=False) + return mdtraj_Trajectory_to_string_aminoacids3(item, group_indices=group_indices, check=False) - return tmp_item def to_string_aminoacids1(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.mdtraj_Trajectory import to_string_aminoacids1 as mdtraj_Trajectory_to_string_aminoacids1 group_indices = get_group_index_from_atom(item, indices=atom_indices, check=False) group_indices = np.unique(group_indices) - tmp_item = mdtraj_Trajectory_to_string_aminoacids1(item, group_indices=group_indices, check=False) + return mdtraj_Trajectory_to_string_aminoacids1(item, group_indices=group_indices, check=False) - return tmp_item def to_biopython_Seq(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.mdtraj_Trajectory import to_biopython_Seq as mdtraj_Trajectory_to_biopython_Seq group_indices = get_group_index_from_atom(item, indices=atom_indices, check=False) group_indices = np.unique(group_indices) - tmp_item = mdtraj_Trajectory_to_biopython_Seq(item, group_indices=group_indices, check=False) + return mdtraj_Trajectory_to_biopython_Seq(item, group_indices=group_indices, check=False) - return tmp_item def to_biopython_SeqRecord(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.mdtraj_Trajectory import to_biopython_Seq as mdtraj_Trajectory_to_biopython_SeqRecord group_indices = get_group_index_from_atom(item, indices=atom_indices, check=False) group_indices = np.unique(group_indices) - tmp_item = mdtraj_Trajectory_to_biopython_SeqRecord(item, group_indices=group_indices, check=False) + return mdtraj_Trajectory_to_biopython_SeqRecord(item, group_indices=group_indices, check=False) - return tmp_item def to_molsysmt_MolSys(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.mdtraj_Trajectory import to_molsysmt_MolSys as mdtraj_Trajectory_to_molsysmt_MolSys - tmp_item = mdtraj_Trajectory_to_molsysmt_MolSys(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return mdtraj_Trajectory_to_molsysmt_MolSys(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_molsysmt_Topology(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.mdtraj_Trajectory import to_molsysmt_Topology as mdtraj_Trajectory_to_molsysmt_Topology - tmp_item = mdtraj_Trajectory_to_molsysmt_Topology(item, atom_indices=atom_indices, check=False) + return mdtraj_Trajectory_to_molsysmt_Topology(item, atom_indices=atom_indices, check=False) - return tmp_item def to_molsysmt_Structures(item, molecular_system=None, atom_indices='all', structure_indices='all'): - from molsysmt.item.mdtraj_Trajectory import to_molsysmt_Structures as mdtraj_Trajectory_to_molsysmt_Structures - tmp_item = mdtraj_Trajectory_to_molsysmt_Structures(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return mdtraj_Trajectory_to_molsysmt_Structures(item, atom_indices=atom_indices, + structure_indices=structure_indices, check=False) - return tmp_item def to_mdtraj_Topology(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.mdtraj_Trajectory import to_mdtraj_Topology as mdtraj_Trajectory_to_mdtraj_Topology - tmp_item = mdtraj_Trajectory_to_mdtraj_Topology(item, atom_indices=atom_indices, check=False) + return mdtraj_Trajectory_to_mdtraj_Topology(item, atom_indices=atom_indices, check=False) - return tmp_item def to_openmm_Topology(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.mdtraj_Trajectory import to_openmm_Topology as mdtraj_Trajectory_to_openmm_Topology - tmp_item = mdtraj_Trajectory_to_openmm_Topology(item, atom_indices=atom_indices, check=False) + return mdtraj_Trajectory_to_openmm_Topology(item, atom_indices=atom_indices, check=False) - return tmp_item def to_openmm_Modeller(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.mdtraj_Trajectory import to_openmm_Modeller as mdtraj_Trajectory_to_openmm_Modeller - tmp_item = mdtraj_Trajectory_to_openmm_Modeller(item, atom_indices=atom_indices, - structure_indices=structure_indices, check=False) + return mdtraj_Trajectory_to_openmm_Modeller(item, atom_indices=atom_indices, + structure_indices=structure_indices, check=False) - return tmp_item def to_parmed_Structure(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.mdtraj_Trajectory import to_parmed_Structures as mdtraj_Trajectory_to_parmed_Structures - tmp_item = mdtraj_Trajectory_to_parmed_Structures(item, atom_indices=atom_indices, - structure_indices=structure_indices, check=False) + return mdtraj_Trajectory_to_parmed_Structures(item, atom_indices=atom_indices, + structure_indices=structure_indices, check=False) - return tmp_item def to_pdbfixer_PDBFixer(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.mdtraj_Trajectory import to_pdbfixer_PDBFixer as mdtraj_Trajectory_to_pdbfixer_PDBFixer - tmp_item = mdtraj_Trajectory_to_pdbfixer_PDBFixer(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return mdtraj_Trajectory_to_pdbfixer_PDBFixer(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_file_pdb(item, molecular_system, atom_indices='all', structure_indices='all', output_filename=None): - from molsysmt.item.mdtraj_Trajectory import to_file_pdb as mdtraj_Trajectory_to_file_pdb - tmp_item = mdtraj_Trajectory_to_file_pdb(item, atom_indices=atom_indices, - structure_indices=structure_indices, output_filename=output_filename, check=False) + return mdtraj_Trajectory_to_file_pdb(item, atom_indices=atom_indices, + structure_indices=structure_indices, output_filename=output_filename, + check=False) - return tmp_item def to_file_xtc(item, molecular_system, atom_indices='all', structure_indices='all', output_filename=None): - from molsysmt.item.mdtraj_Trajectory import to_file_xtc as mdtraj_Trajectory_to_file_xtc - tmp_item = mdtraj_Trajectory_to_file_xtc(item, atom_indices=atom_indices, - structure_indices=structure_indices, output_filename=output_filename, check=False) + return mdtraj_Trajectory_to_file_xtc(item, atom_indices=atom_indices, + structure_indices=structure_indices, output_filename=output_filename, + check=False) - return tmp_item def to_nglview_NGLWidget(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.mdtraj_Trajectory import to_nglview_NGLWidget as mdtraj_Trajectory_to_nglview_NGLWidget - tmp_item = mdtraj_Trajectory_to_nglview_NGLWidget(item, atom_indices=atom_indices, - structure_indices=structure_indices, check=False) - - return tmp_item - + return mdtraj_Trajectory_to_nglview_NGLWidget(item, atom_indices=atom_indices, + structure_indices=structure_indices, check=False) diff --git a/molsysmt/api_forms/api_mdtraj_XTCTrajectoryFile.py b/molsysmt/api_forms/api_mdtraj_XTCTrajectoryFile.py index 34522fdfb..2c0b96780 100644 --- a/molsysmt/api_forms/api_mdtraj_XTCTrajectoryFile.py +++ b/molsysmt/api_forms/api_mdtraj_XTCTrajectoryFile.py @@ -1,74 +1,26 @@ from molsysmt._private.exceptions import * - from molsysmt.item.mdtraj_XTCTrajectoryFile.is_mdtraj_XTCTrajectoryFile import is_mdtraj_XTCTrajectoryFile as is_form from molsysmt.item.mdtraj_XTCTrajectoryFile.extract import extract from molsysmt.item.mdtraj_XTCTrajectoryFile.add import add from molsysmt.item.mdtraj_XTCTrajectoryFile.append_structures import append_structures from molsysmt.item.mdtraj_XTCTrajectoryFile.get import * from molsysmt.item.mdtraj_XTCTrajectoryFile.set import * +from .form_attributes import form_attributes -form_name='mdtraj.XTCTrajectoryFile' -form_type='class' -form_info=["",""] - -form_attributes = { - - 'atom_index' : False, - 'atom_id' : False, - 'atom_name' : False, - 'atom_type' : False, - - 'bond_index' : False, - 'bond_id' : False, - 'bond_name' : False, - 'bond_type' : False, - 'bond_order' : False, - - 'group_index' : False, - 'group_id' : False, - 'group_name' : False, - 'group_type' : False, - - 'component_index' : False, - 'component_id' : False, - 'component_name' : False, - 'component_type' : False, - - 'molecule_index' : False, - 'molecule_id' : False, - 'molecule_name' : False, - 'molecule_type' : False, +form_name = 'mdtraj.XTCTrajectoryFile' +form_type = 'class' +form_info = ["", ""] - 'chain_index' : False, - 'chain_id' : False, - 'chain_name' : False, - 'chain_type' : False, +form_attributes = form_attributes() +form_attributes['coordinates'] = True +form_attributes['box'] = True +form_attributes['time'] = True +form_attributes['step'] = True - 'entity_index' : False, - 'entity_id' : False, - 'entity_name' : False, - 'entity_type' : False, - - 'coordinates' : True, - 'velocities' : False, - 'box' : True, - 'time' : True, - 'step' : True, - - 'forcefield_parameters' : False, - - 'forcefield' : False, - 'temperature' : False, - 'pressure' : False, - 'integrator' : False, - 'damping' : False, -} def to_molsysmt_Structures(item, molecular_system, atom_indices='all', structure_indices='all'): + from molsysmt.item.mdtraj_XTCTrajectoryFile import \ + to_molsysmt_Structures as mdtraj_XTCTrajectoryFile_to_molsysmt_Structures - from molsysmt.item.mdtraj_XTCTrajectoryFile import to_molsysmt_Structures as mdtraj_XTCTrajectoryFile_to_molsysmt_Structures - - tmp_item = mdtraj_XTCTrajectoryFile_to_molsysmt_Structures(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) - - return tmp_item - + return mdtraj_XTCTrajectoryFile_to_molsysmt_Structures(item, atom_indices=atom_indices, + structure_indices=structure_indices, check=False) diff --git a/molsysmt/api_forms/api_mmtf_MMTFDecoder.py b/molsysmt/api_forms/api_mmtf_MMTFDecoder.py index 6a84c42be..54f0a304b 100644 --- a/molsysmt/api_forms/api_mmtf_MMTFDecoder.py +++ b/molsysmt/api_forms/api_mmtf_MMTFDecoder.py @@ -1,137 +1,104 @@ from molsysmt._private.exceptions import * - from molsysmt.item.mmtf_MMTFDecoder.is_mmtf_MMTFDecoder import is_mmtf_MMTFDecoder as is_form from molsysmt.item.mmtf_MMTFDecoder.extract import extract from molsysmt.item.mmtf_MMTFDecoder.add import add from molsysmt.item.mmtf_MMTFDecoder.append_structures import append_structures from molsysmt.item.mmtf_MMTFDecoder.get import * from molsysmt.item.mmtf_MMTFDecoder.set import * - -form_name='mmtf.MMTFDecoder' -form_type='class' -form_info=["",""] - -form_attributes = { - - 'atom_index' : True, - 'atom_id' : True, - 'atom_name' : True, - 'atom_type' : True, - - 'bond_index' : True, - 'bond_id' : True, - 'bond_name' : True, - 'bond_type' : True, - 'bond_order' : True, - - 'group_index' : True, - 'group_id' : True, - 'group_name' : True, - 'group_type' : True, - - 'component_index' : True, - 'component_id' : False, - 'component_name' : False, - 'component_type' : False, - - 'molecule_index' : True, - 'molecule_id' : True, - 'molecule_name' : True, - 'molecule_type' : True, - - 'chain_index' : True, - 'chain_id' : True, - 'chain_name' : True, - 'chain_type' : True, - - 'entity_index' : True, - 'entity_id' : True, - 'entity_name' : True, - 'entity_type' : True, - - 'coordinates' : True, - 'velocities' : False, - 'box' : True, - 'time' : False, - 'step' : False, - - 'forcefield' : False, - 'temperature' : False, - 'pressure' : False, - 'integrator' : False, - 'damping' : False, -} +from .form_attributes import form_attributes + +form_name = 'mmtf.MMTFDecoder' +form_type = 'class' +form_info = ["", ""] + +form_attributes = form_attributes() +form_attributes['atom_index'] = True +form_attributes['atom_id'] = True +form_attributes['atom_name'] = True +form_attributes['atom_type'] = True +form_attributes['bond_index'] = True +form_attributes['bond_id'] = True +form_attributes['bond_name'] = True +form_attributes['bond_type'] = True +form_attributes['bond_order'] = True +form_attributes['group_index'] = True +form_attributes['group_id'] = True +form_attributes['group_name'] = True +form_attributes['group_type'] = True +form_attributes['component_index'] = True +form_attributes['molecule_index'] = True +form_attributes['molecule_id'] = True +form_attributes['molecule_name'] = True +form_attributes['molecule_type'] = True +form_attributes['chain_index'] = True +form_attributes['chain_id'] = True +form_attributes['chain_name'] = True +form_attributes['chain_type'] = True +form_attributes['entity_index'] = True +form_attributes['entity_id'] = True +form_attributes['entity_name'] = True +form_attributes['entity_type'] = True +form_attributes['coordinates'] = True +form_attributes['box'] = True def to_file_mmtf(item, molecular_system, atom_indices='all', structure_indices='all', output_filename=None): - from molsysmt.item.mmtf_MMTFDecoder import to_file_mmtf as mmtf_MMTFDecoder_to_file_mmtf - tmp_item = mmtf_MMTFDecoder_to_file_mmtf(item, atom_indices=atom_indices, structure_indices=structure_indices, output_filename=output_filename, check=False) + return mmtf_MMTFDecoder_to_file_mmtf(item, atom_indices=atom_indices, structure_indices=structure_indices, + output_filename=output_filename, check=False) - return tmp_item def to_file_pdb(item, molecular_system, atom_indices='all', structure_indices='all', output_filename=None): - from molsysmt.item.mmtf_MMTFDecoder import to_file_pdb as mmtf_MMTFDecoder_to_file_pdb - tmp_item = mmtf_MMTFDecoder_to_file_pdb(item, atom_indices=atom_indices, structure_indices=structure_indices, output_filename=output_filename, check=False) + return mmtf_MMTFDecoder_to_file_pdb(item, atom_indices=atom_indices, structure_indices=structure_indices, + output_filename=output_filename, check=False) - return tmp_item def to_molsysmt_MolSys(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.mmtf_MMTFDecoder import to_molsysmt_MolSys as mmtf_MMTFDecoder_to_molsysmt_MolSys - tmp_item = mmtf_MMTFDecoder_to_molsysmt_MolSys(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return mmtf_MMTFDecoder_to_molsysmt_MolSys(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_molsysmt_Topology(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.mmtf_MMTFDecoder import to_molsysmt_Topology as mmtf_MMTFDecoder_to_molsysmt_Topology - tmp_item = mmtf_MMTFDecoder_to_molsysmt_Topology(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return mmtf_MMTFDecoder_to_molsysmt_Topology(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_molsysmt_Structures(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.mmtf_MMTFDecoder import to_molsysmt_Structures as mmtf_MMTFDecoder_to_molsysmt_Structures - tmp_item = mmtf_MMTFDecoder_to_molsysmt_Structures(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return mmtf_MMTFDecoder_to_molsysmt_Structures(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_mdtraj_Trajectory(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.mmtf_MMTFDecoder import to_mdtraj_Trajectory as mmtf_MMTFDecoder_to_mdtraj_Trajectory - tmp_item = mmtf_MMTFDecoder_to_molsysmt_Structures(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return mmtf_MMTFDecoder_to_molsysmt_Structures(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_string_aminoacids1(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.mmtf_MMTFDecoder import to_string_aminoacids1 as mmtf_MMTFDecoder_to_string_aminoacids1 + from molsysmt.item.mmtf_MMTFDecoder import get_group_index_from_atom group_indices = get_group_index_from_atom(item, indices=atom_indices) group_indices = np.unique(group_indices) + return mmtf_MMTFDecoder_to_string_aminoacids1(item, group_indices=group_indices, check=False) - tmp_item = mmtf_MMTFDecoder_to_string_aminoacids1(item, group_indices=group_indices, check=False) - - return tmp_item def to_string_aminoacids3(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.mmtf_MMTFDecoder import to_string_aminoacids3 as mmtf_MMTFDecoder_to_string_aminoacids3 + from molsysmt.item.mmtf_MMTFDecoder import get_group_index_from_atom group_indices = get_group_index_from_atom(item, indices=atom_indices) group_indices = np.unique(group_indices) - - tmp_item = mmtf_MMTFDecoder_to_string_aminoacids3(item, group_indices=group_indices, check=False) - - return tmp_item - + return mmtf_MMTFDecoder_to_string_aminoacids3(item, group_indices=group_indices, check=False) diff --git a/molsysmt/api_forms/api_molsysmt_MolSys.py b/molsysmt/api_forms/api_molsysmt_MolSys.py index b4a4cb767..a17a9b610 100644 --- a/molsysmt/api_forms/api_molsysmt_MolSys.py +++ b/molsysmt/api_forms/api_molsysmt_MolSys.py @@ -1,244 +1,196 @@ from molsysmt._private.exceptions import * - from molsysmt.item.molsysmt_MolSys.is_molsysmt_MolSys import is_molsysmt_MolSys as is_form from molsysmt.item.molsysmt_MolSys.extract import extract from molsysmt.item.molsysmt_MolSys.add import add from molsysmt.item.molsysmt_MolSys.append_structures import append_structures from molsysmt.item.molsysmt_MolSys.get import * from molsysmt.item.molsysmt_MolSys.set import * - import numpy as np - -form_name='molsysmt.MolSys' -form_type='class' -form_info=["",""] - -form_attributes = { - - 'atom_index' : True, - 'atom_id' : True, - 'atom_name' : True, - 'atom_type' : True, - - 'bond_index' : True, - 'bond_id' : True, - 'bond_name' : True, - 'bond_type' : True, - 'bond_order' : True, - 'bonded_atoms' : True, - - 'group_index' : True, - 'group_id' : True, - 'group_name' : True, - 'group_type' : True, - - 'component_index' : True, - 'component_id' : True, - 'component_name' : True, - 'component_type' : True, - - 'molecule_index' : True, - 'molecule_id' : True, - 'molecule_name' : True, - 'molecule_type' : True, - - 'chain_index' : True, - 'chain_id' : True, - 'chain_name' : True, - 'chain_type' : True, - - 'entity_index' : True, - 'entity_id' : True, - 'entity_name' : True, - 'entity_type' : True, - - 'coordinates' : True, - 'velocities' : False, - 'box' : True, - 'time' : True, - 'step' : True, - - 'forcefield' : False, - 'temperature' : False, - 'pressure' : False, - 'integrator' : False, - 'damping' : False, -} +from .form_attributes import form_attributes + +form_name = 'molsysmt.MolSys' +form_type = 'class' +form_info = ["", ""] + +form_attributes = form_attributes() +form_attributes['atom_index'] = True +form_attributes['atom_id'] = True +form_attributes['atom_name'] = True +form_attributes['atom_type'] = True +form_attributes['bond_index'] = True +form_attributes['bond_id'] = True +form_attributes['bond_name'] = True +form_attributes['bond_type'] = True +form_attributes['bond_order'] = True +form_attributes['bonded_atoms'] = True +form_attributes['group_index'] = True +form_attributes['group_id'] = True +form_attributes['group_name'] = True +form_attributes['group_type'] = True +form_attributes['component_index'] = True +form_attributes['component_id'] = True +form_attributes['component_name'] = True +form_attributes['component_type'] = True +form_attributes['molecule_index'] = True +form_attributes['molecule_id'] = True +form_attributes['molecule_name'] = True +form_attributes['molecule_type'] = True +form_attributes['chain_index'] = True +form_attributes['chain_id'] = True +form_attributes['chain_name'] = True +form_attributes['chain_type'] = True +form_attributes['entity_index'] = True +form_attributes['entity_id'] = True +form_attributes['entity_name'] = True +form_attributes['entity_type'] = True +form_attributes['coordinates'] = True +form_attributes['box'] = True +form_attributes['time'] = True +form_attributes['step'] = True def to_molsysmt_Topology(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.molsysmt_MolSys import to_molsysmt_Topology as molsysmt_MolSys_to_molsysmt_Topology - tmp_item = molsysmt_MolSys_to_molsysmt_Topology(item, atom_indices=atom_indices, check=False) + return molsysmt_MolSys_to_molsysmt_Topology(item, atom_indices=atom_indices, check=False) - return tmp_item def to_molsysmt_Structures(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.molsysmt_MolSys import to_molsysmt_Structures as molsysmt_MolSys_to_molsysmt_Structures - tmp_item = molsysmt_MolSys_to_molsysmt_Structures(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return molsysmt_MolSys_to_molsysmt_Structures(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_XYZ(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.molsysmt_MolSys import to_XYZ as molsysmt_MolSys_to_XYZ - tmp_item = molsysmt_MolSys_to_XYZ(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return molsysmt_MolSys_to_XYZ(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) - return tmp_item def to_string_aminoacids3(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.molsysmt_MolSys import to_string_aminoacids3 as molsysmt_MolSys_to_string_aminoacids3 + from molsysmt.item.molsysmt_MolSys import get_group_index_from_atom as get_group_index_from_atom_molsysmt_MolSys group_indices = get_group_index_from_atom_molsysmt_MolSys(item, indices=atom_indices, check=False) group_indices = np.unique(group_indices) + return molsysmt_MolSys_to_string_aminoacids3(item, group_indices=group_indices, check=False) - tmp_item = molsysmt_MolSys_to_string_aminoacids3(item, group_indices=group_indices, check=False) - - return tmp_item def to_string_aminoacids1(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.molsysmt_MolSys import to_string_aminoacids1 as molsysmt_MolSys_to_string_aminoacids1 + from molsysmt.item.molsysmt_MolSys import get_group_index_from_atom as get_group_index_from_atom_molsysmt_MolSys group_indices = get_group_index_from_atom_molsysmt_MolSys(item, indices=atom_indices, check=False) group_indices = np.unique(group_indices) + return molsysmt_MolSys_to_string_aminoacids1(item, group_indices=group_indices, check=False) - tmp_item = molsysmt_MolSys_to_string_aminoacids1(item, group_indices=group_indices, check=False) - - return tmp_item def to_biopython_Seq(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.molsysmt_MolSys import to_biopython_Seq as molsysmt_MolSys_to_biopython_Seq + from molsysmt.item.molsysmt_MolSys import get_group_index_from_atom as get_group_index_from_atom_molsysmt_MolSys group_indices = get_group_index_from_atom_molsysmt_MolSys(item, indices=atom_indices, check=False) group_indices = np.unique(group_indices) + return molsysmt_MolSys_to_biopython_Seq(item, group_indices=group_indices, check=False) - tmp_item = molsysmt_MolSys_to_biopython_Seq(item, group_indices=group_indices, check=False) - - return tmp_item def to_biopython_SeqRecord(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.molsysmt_MolSys import to_biopython_SeqRecord as molsysmt_MolSys_to_biopython_SeqRecord + from molsysmt.item.molsysmt_MolSys import get_group_index_from_atom as get_group_index_from_atom_molsysmt_MolSys group_indices = get_group_index_from_atom_molsysmt_MolSys(item, indices=atom_indices, check=False) group_indices = np.unique(group_indices) + return molsysmt_MolSys_to_biopython_SeqRecord(item, group_indices=group_indices, check=False) - tmp_item = molsysmt_MolSys_to_biopython_SeqRecord(item, group_indices=group_indices, check=False) - - return tmp_item def to_mdtraj_Trajectory(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.molsysmt_MolSys import to_mdtraj_Trajectory as molsysmt_MolSys_to_mdtraj_Trajectory - tmp_item = molsysmt_MolSys_to_mdtraj_Trajectory(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return molsysmt_MolSys_to_mdtraj_Trajectory(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_mdtraj_Topology(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.molsysmt_MolSys import to_mdtraj_Topology as molsysmt_MolSys_to_mdtraj_Topology - tmp_item = molsysmt_MolSys_to_mdtraj_Topology(item, atom_indices=atom_indices, check=False) + return molsysmt_MolSys_to_mdtraj_Topology(item, atom_indices=atom_indices, check=False) - return tmp_item def to_openmm_Topology(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.molsysmt_MolSys import to_openmm_Topology as molsysmt_MolSys_to_openmm_Topology - tmp_item = molsysmt_MolSys_to_openmm_Topology(item, atom_indices=atom_indices, check=False) + return molsysmt_MolSys_to_openmm_Topology(item, atom_indices=atom_indices, check=False) - return tmp_item def to_openmm_Modeller(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.molsysmt_MolSys import to_openmm_Modeller as molsysmt_MolSys_to_openmm_Modeller - tmp_item = molsysmt_MolSys_to_openmm_Modeller(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return molsysmt_MolSys_to_openmm_Modeller(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_openmm_System(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.molsysmt_MolSys import to_openmm_System as molsysmt_MolSys_to_openmm_System - tmp_item = molsysmt_MolSys_to_openmm_System(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return molsysmt_MolSys_to_openmm_System(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_openmm_Context(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.molsysmt_MolSys import to_openmm_Context as molsysmt_MolSys_to_openmm_Context - tmp_item = molsysmt_MolSys_to_openmm_Context(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return molsysmt_MolSys_to_openmm_Context(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_openmm_Simulation(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.molsysmt_MolSys import to_openmm_Simulation as molsysmt_MolSys_to_openmm_Simulation - tmp_item = molsysmt_MolSys_to_openmm_Simulation(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return molsysmt_MolSys_to_openmm_Simulation(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_file_pdb(item, molecular_system, atom_indices='all', structure_indices='all', output_filename=None): - from molsysmt.item.molsysmt_MolSys import to_file_pdb as molsysmt_MolSys_to_file_pdb - tmp_item = molsysmt_MolSys_to_file_pdb(item, atom_indices=atom_indices, structure_indices=structure_indices, output_filename=output_filename, check=False) + return molsysmt_MolSys_to_file_pdb(item, atom_indices=atom_indices, structure_indices=structure_indices, + output_filename=output_filename, check=False) - return tmp_item def to_file_msmpk(item, molecular_system, atom_indices='all', structure_indices='all', output_filename=None): - from molsysmt.item.molsysmt_MolSys import to_file_msmpk as molsysmt_MolSys_to_file_msmpk - tmp_item = molsysmt_MolSys_to_file_msmpk(item, atom_indices=atom_indices, structure_indices=structure_indices, output_filename=output_filename, check=False) + return molsysmt_MolSys_to_file_msmpk(item, atom_indices=atom_indices, structure_indices=structure_indices, + output_filename=output_filename, check=False) - return tmp_item def to_string_pdb_text(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.molsysmt_MolSys import to_string_pdb_text as molsysmt_MolSys_to_string_pdb_text - tmp_item = molsysmt_MolSys_to_string_pdb_text(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return molsysmt_MolSys_to_string_pdb_text(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_pdbfixer_PDBFixer(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.molsysmt_MolSys import to_pdbfixer_PDBFixer as molsysmt_MolSys_to_pdbfixer_PDBFixer - tmp_item = molsysmt_MolSys_to_pdbfixer_PDBFixer(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return molsysmt_MolSys_to_pdbfixer_PDBFixer(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_pytraj_Topology(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.molsysmt_MolSys import to_pytraj_Topology as molsysmt_MolSys_to_pytraj_Topology - tmp_item = molsysmt_MolSys_to_pytraj_Topology(item, atom_indices=atom_indices, check=False) + return molsysmt_MolSys_to_pytraj_Topology(item, atom_indices=atom_indices, check=False) - return tmp_item def to_nglview_NGLWidget(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.molsysmt_MolSys import to_nglview_NGLWidget as molsysmt_MolSys_to_nglview_NGLWidget - tmp_item = molsysmt_MolSys_to_nglview_NGLWidget(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) - - return tmp_item - + return molsysmt_MolSys_to_nglview_NGLWidget(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) diff --git a/molsysmt/api_forms/api_molsysmt_MolecularMechanics.py b/molsysmt/api_forms/api_molsysmt_MolecularMechanics.py index b29f076a2..1457cbe16 100644 --- a/molsysmt/api_forms/api_molsysmt_MolecularMechanics.py +++ b/molsysmt/api_forms/api_molsysmt_MolecularMechanics.py @@ -1,92 +1,41 @@ from molsysmt._private.exceptions import * - -from molsysmt.item.molsysmt_MolecularMechanics.is_molsysmt_MolecularMechanics import is_molsysmt_MolecularMechanics as is_form +from molsysmt.item.molsysmt_MolecularMechanics.is_molsysmt_MolecularMechanics import \ + is_molsysmt_MolecularMechanics as is_form from molsysmt.item.molsysmt_MolecularMechanics.extract import extract from molsysmt.item.molsysmt_MolecularMechanics.add import add from molsysmt.item.molsysmt_MolecularMechanics.append_structures import append_structures from molsysmt.item.molsysmt_MolecularMechanics.get import * from molsysmt.item.molsysmt_MolecularMechanics.set import * - -form_name='molsysmt.MolecularMechanics' -form_type='class' -form_info=["",""] - -form_attributes = { - - 'atom_index' : False, - 'atom_id' : False, - 'atom_name' : False, - 'atom_type' : False, - - 'bond_index' : False, - 'bond_id' : False, - 'bond_name' : False, - 'bond_type' : False, - 'bond_order' : False, - - 'group_index' : False, - 'group_id' : False, - 'group_name' : False, - 'group_type' : False, - - 'component_index' : False, - 'component_id' : False, - 'component_name' : False, - 'component_type' : False, - - 'molecule_index' : False, - 'molecule_id' : False, - 'molecule_name' : False, - 'molecule_type' : False, - - 'chain_index' : False, - 'chain_id' : False, - 'chain_name' : False, - 'chain_type' : False, - - 'entity_index' : False, - 'entity_id' : False, - 'entity_name' : False, - 'entity_type' : False, - - 'coordinates' : False, - 'velocities' : False, - 'box' : False, - 'time' : False, - 'step' : False, - - 'forcefield' : True, - 'non_bonded_method' : True, - 'non_bonded_cutoff' : True, - 'switch_distance' : True, - 'use_dispersion_correction' : True, - 'ewald_error_tolerance' : True, - 'hydrogen_mass' : True, - 'constraints' : True, - 'flexible_constraints' : True, - 'water_model' : True, - 'rigid_water' : True, - 'residue_templates' : True, - 'ignore_external_bonds' : True, - 'implicit_solvent' : True, - 'implicit_solvent' : True, - 'solute_dielectric' : True, - 'solvent_dielectric' : True, - 'implicit_solvent_salt_conc' : True, - 'implicit_solvent_kappa' : True, - - 'temperature' : False, - 'pressure' : False, - 'integrator' : False, - 'damping' : False, -} +from .form_attributes import form_attributes + +form_name = 'molsysmt.MolecularMechanics' +form_type = 'class' +form_info = ["", ""] + +form_attributes = form_attributes() +form_attributes['forcefield'] = True +form_attributes['non_bonded_method'] = True +form_attributes['non_bonded_cutoff'] = True +form_attributes['switch_distance'] = True +form_attributes['use_dispersion_correction'] = True +form_attributes['ewald_error_tolerance'] = True +form_attributes['hydrogen_mass'] = True +form_attributes['constraints'] = True +form_attributes['flexible_constraints'] = True +form_attributes['water_model'] = True +form_attributes['rigid_water'] = True +form_attributes['residue_templates'] = True +form_attributes['ignore_external_bonds'] = True +form_attributes['implicit_solvent'] = True +form_attributes['implicit_solvent'] = True +form_attributes['solute_dielectric'] = True +form_attributes['solvent_dielectric'] = True +form_attributes['implicit_solvent_salt_conc'] = True +form_attributes['implicit_solvent_kappa'] = True def to_MolecularMechanicsDict(item, molecular_system, atom_indices='all', structure_indices='all'): + from molsysmt.item.molsysmt_MolecularMechanics import \ + to_molsysmt_MolecularMechanicsDict as molsysmt_MolecularMechanics_to_molsysmt_MolecularMechanicsDict - from molsysmt.item.molsysmt_MolecularMechanics import to_molsysmt_MolecularMechanicsDict as molsysmt_MolecularMechanics_to_molsysmt_MolecularMechanicsDict - - tmp_item = molsysmt_MolecularMechanics_to_molsysmt_MolecularMechanicsDict(item, check=False) - - return tmp_item - + return molsysmt_MolecularMechanics_to_molsysmt_MolecularMechanicsDict(item, check=False) diff --git a/molsysmt/api_forms/api_molsysmt_MolecularMechanicsDict.py b/molsysmt/api_forms/api_molsysmt_MolecularMechanicsDict.py index b617e7a3a..1fef29ec9 100644 --- a/molsysmt/api_forms/api_molsysmt_MolecularMechanicsDict.py +++ b/molsysmt/api_forms/api_molsysmt_MolecularMechanicsDict.py @@ -1,93 +1,41 @@ from molsysmt._private.exceptions import * - -from molsysmt.item.molsysmt_MolecularMechanicsDict.is_molsysmt_MolecularMechanicsDict import is_molsysmt_MolecularMechanicsDict as is_form +from molsysmt.item.molsysmt_MolecularMechanicsDict.is_molsysmt_MolecularMechanicsDict import \ + is_molsysmt_MolecularMechanicsDict as is_form from molsysmt.item.molsysmt_MolecularMechanicsDict.extract import extract from molsysmt.item.molsysmt_MolecularMechanicsDict.add import add from molsysmt.item.molsysmt_MolecularMechanicsDict.append_structures import append_structures from molsysmt.item.molsysmt_MolecularMechanicsDict.get import * from molsysmt.item.molsysmt_MolecularMechanicsDict.set import * - -form_name='molsysmt.MolecularMechanicsDict' -form_type='class' -form_info=["",""] - - -form_attributes = { - - 'atom_index' : False, - 'atom_id' : False, - 'atom_name' : False, - 'atom_type' : False, - - 'bond_index' : False, - 'bond_id' : False, - 'bond_name' : False, - 'bond_type' : False, - 'bond_order' : False, - - 'group_index' : False, - 'group_id' : False, - 'group_name' : False, - 'group_type' : False, - - 'component_index' : False, - 'component_id' : False, - 'component_name' : False, - 'component_type' : False, - - 'molecule_index' : False, - 'molecule_id' : False, - 'molecule_name' : False, - 'molecule_type' : False, - - 'chain_index' : False, - 'chain_id' : False, - 'chain_name' : False, - 'chain_type' : False, - - 'entity_index' : False, - 'entity_id' : False, - 'entity_name' : False, - 'entity_type' : False, - - 'coordinates' : False, - 'velocities' : False, - 'box' : False, - 'time' : False, - 'step' : False, - - 'forcefield' : True, - 'non_bonded_method' : True, - 'non_bonded_cutoff' : True, - 'switch_distance' : True, - 'use_dispersion_correction' : True, - 'ewald_error_tolerance' : True, - 'hydrogen_mass' : True, - 'constraints' : True, - 'flexible_constraints' : True, - 'water_model' : True, - 'rigid_water' : True, - 'residue_templates' : True, - 'ignore_external_bonds' : True, - 'implicit_solvent' : True, - 'implicit_solvent' : True, - 'solute_dielectric' : True, - 'solvent_dielectric' : True, - 'implicit_solvent_salt_conc' : True, - 'implicit_solvent_kappa' : True, - - 'temperature' : False, - 'pressure' : False, - 'integrator' : False, - 'damping' : False, -} +from .form_attributes import form_attributes + +form_name = 'molsysmt.MolecularMechanicsDict' +form_type = 'class' +form_info = ["", ""] + +form_attributes = form_attributes() +form_attributes['forcefield'] = True +form_attributes['non_bonded_method'] = True +form_attributes['non_bonded_cutoff'] = True +form_attributes['switch_distance'] = True +form_attributes['use_dispersion_correction'] = True +form_attributes['ewald_error_tolerance'] = True +form_attributes['hydrogen_mass'] = True +form_attributes['constraints'] = True +form_attributes['flexible_constraints'] = True +form_attributes['water_model'] = True +form_attributes['rigid_water'] = True +form_attributes['residue_templates'] = True +form_attributes['ignore_external_bonds'] = True +form_attributes['implicit_solvent'] = True +form_attributes['implicit_solvent'] = True +form_attributes['solute_dielectric'] = True +form_attributes['solvent_dielectric'] = True +form_attributes['implicit_solvent_salt_conc'] = True +form_attributes['implicit_solvent_kappa'] = True def to_molsysmt_MolecularMechanics(item, molecular_system, atom_indices='all', structure_indices='all'): + from molsysmt.item.molsysmt_MolecularMechanicsDict import \ + to_molsysmt_MolecularMechanics as molsysmt_MolecularMechanicsDict_to_molsysmt_MolecularMechanics - from molsysmt.item.molsysmt_MolecularMechanicsDict import to_molsysmt_MolecularMechanics as molsysmt_MolecularMechanicsDict_to_molsysmt_MolecularMechanics - - tmp_item = molsysmt_MolecularMechanicsDict_to_molsysmt_MolecularMechanics(item, check=False) - - return tmp_item - + return molsysmt_MolecularMechanicsDict_to_molsysmt_MolecularMechanics(item, check=False) diff --git a/molsysmt/api_forms/api_molsysmt_Structures.py b/molsysmt/api_forms/api_molsysmt_Structures.py index 9b22d9ef8..00f6ecd95 100644 --- a/molsysmt/api_forms/api_molsysmt_Structures.py +++ b/molsysmt/api_forms/api_molsysmt_Structures.py @@ -1,84 +1,33 @@ from molsysmt._private.exceptions import * - from molsysmt.item.molsysmt_Structures.is_molsysmt_Structures import is_molsysmt_Structures as is_form from molsysmt.item.molsysmt_Structures.extract import extract from molsysmt.item.molsysmt_Structures.add import add from molsysmt.item.molsysmt_Structures.append_structures import append_structures from molsysmt.item.molsysmt_Structures.get import * from molsysmt.item.molsysmt_Structures.set import * +from .form_attributes import form_attributes -form_name='molsysmt.Structures' -form_type='class' -form_info=["",""] - -form_attributes = { - - 'atom_index' : False, - 'atom_id' : False, - 'atom_name' : False, - 'atom_type' : False, - - 'bond_index' : False, - 'bond_id' : False, - 'bond_name' : False, - 'bond_type' : False, - 'bond_order' : False, - - 'group_index' : False, - 'group_id' : False, - 'group_name' : False, - 'group_type' : False, - - 'component_index' : False, - 'component_id' : False, - 'component_name' : False, - 'component_type' : False, - - 'molecule_index' : False, - 'molecule_id' : False, - 'molecule_name' : False, - 'molecule_type' : False, - - 'chain_index' : False, - 'chain_id' : False, - 'chain_name' : False, - 'chain_type' : False, +form_name = 'molsysmt.Structures' +form_type = 'class' +form_info = ["", ""] - 'entity_index' : False, - 'entity_id' : False, - 'entity_name' : False, - 'entity_type' : False, - - 'coordinates' : True, - 'velocities' : False, - 'box' : True, - 'time' : True, - 'step' : True, - - 'forcefield' : False, - 'temperature' : False, - 'pressure' : False, - 'integrator' : False, - 'damping' : False, -} +form_attributes = form_attributes() +form_attributes['coordinates'] = True +form_attributes['box'] = True +form_attributes['time'] = True +form_attributes['step'] = True # Methods - def to_molsysmt_TrajectoryDict(item, molecular_system, atom_indices='all', structure_indices='all'): + from molsysmt.item.molsysmt_Structures import \ + to_molsysmt_TrajectoryDict as molsysmt_Structures_to_molsysmt_TrajectoryDict - from molsysmt.item.molsysmt_Structures import to_molsysmt_TrajectoryDict as molsysmt_Structures_to_molsysmt_TrajectoryDict - - tmp_item = molsysmt_Structures_to_molsysmt_TrajectoryDict(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return molsysmt_Structures_to_molsysmt_TrajectoryDict(item, atom_indices=atom_indices, + structure_indices=structure_indices, check=False) - return tmp_item def to_XYZ(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.molsysmt_Structures import to_XYZ as molsysmt_Structures_to_XYZ - tmp_item = molsysmt_Structures_to_XYZ(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) - - return tmp_item - - + return molsysmt_Structures_to_XYZ(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) diff --git a/molsysmt/api_forms/api_molsysmt_Topology.py b/molsysmt/api_forms/api_molsysmt_Topology.py index dcdf9b352..fb080c3bb 100644 --- a/molsysmt/api_forms/api_molsysmt_Topology.py +++ b/molsysmt/api_forms/api_molsysmt_Topology.py @@ -1,137 +1,109 @@ from molsysmt._private.exceptions import * - from molsysmt.item.molsysmt_Topology.is_molsysmt_Topology import is_molsysmt_Topology as is_form from molsysmt.item.molsysmt_Topology.extract import extract from molsysmt.item.molsysmt_Topology.add import add from molsysmt.item.molsysmt_Topology.append_structures import append_structures from molsysmt.item.molsysmt_Topology.get import * from molsysmt.item.molsysmt_Topology.set import * +from .form_attributes import form_attributes + +form_name = 'molsysmt.Topology' +form_type = 'class' +form_info = ["", ""] + +form_attributes = form_attributes() +form_attributes['atom_index'] = True +form_attributes['atom_id'] = True +form_attributes['atom_name'] = True +form_attributes['atom_type'] = True +form_attributes['bond_index'] = True +form_attributes['bond_id'] = True +form_attributes['bond_name'] = True +form_attributes['bond_type'] = True +form_attributes['bond_order'] = True +form_attributes['bonded_atoms'] = True +form_attributes['group_index'] = True +form_attributes['group_id'] = True +form_attributes['group_name'] = True +form_attributes['group_type'] = True +form_attributes['component_index'] = True +form_attributes['component_id'] = True +form_attributes['component_name'] = True +form_attributes['component_type'] = True +form_attributes['molecule_index'] = True +form_attributes['molecule_id'] = True +form_attributes['molecule_name'] = True +form_attributes['molecule_type'] = True +form_attributes['chain_index'] = True +form_attributes['chain_id'] = True +form_attributes['chain_name'] = True +form_attributes['chain_type'] = True +form_attributes['entity_index'] = True +form_attributes['entity_id'] = True +form_attributes['entity_name'] = True +form_attributes['entity_type'] = True -form_name='molsysmt.Topology' -form_type='class' -form_info=["",""] - -form_attributes = { - - 'atom_index' : True, - 'atom_id' : True, - 'atom_name' : True, - 'atom_type' : True, - - 'bond_index' : True, - 'bond_id' : True, - 'bond_name' : True, - 'bond_type' : True, - 'bond_order' : True, - 'bonded_atoms' : True, - - 'group_index' : True, - 'group_id' : True, - 'group_name' : True, - 'group_type' : True, - - 'component_index' : True, - 'component_id' : True, - 'component_name' : True, - 'component_type' : True, - - 'molecule_index' : True, - 'molecule_id' : True, - 'molecule_name' : True, - 'molecule_type' : True, - - 'chain_index' : True, - 'chain_id' : True, - 'chain_name' : True, - 'chain_type' : True, - - 'entity_index' : True, - 'entity_id' : True, - 'entity_name' : True, - 'entity_type' : True, - - 'coordinates' : False, - 'velocities' : False, - 'box' : False, - 'time' : False, - 'step' : False, - - 'forcefield' : False, - 'temperature' : False, - 'pressure' : False, - 'integrator' : False, - 'damping' : False, -} def to_string_aminoacids3(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.molsysmt_Topology import to_string_aminoacids3 as molsysmt_Topology_to_string_aminoacids3 + from molsysmt.item.molsysmt_Topology import get_group_index_from_atom as get_group_index_from_atom_molsysmt_Topology group_indices = get_group_index_from_atom_molsysmt_Topology(item, indices=atom_indices, check=False) group_indices = np.unique(group_indices) - tmp_item = molsysmt_Topology_to_string_aminoacids3(item, group_indices=group_indices, check=False) + return molsysmt_Topology_to_string_aminoacids3(item, group_indices=group_indices, check=False) - return tmp_item def to_string_aminoacids1(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.molsysmt_Topology import to_string_aminoacids1 as molsysmt_Topology_to_string_aminoacids1 + from molsysmt.item.molsysmt_Topology import get_group_index_from_atom as get_group_index_from_atom_molsysmt_Topology group_indices = get_group_index_from_atom_molsysmt_Topology(item, indices=atom_indices, check=False) group_indices = np.unique(group_indices) - tmp_item = molsysmt_Topology_to_string_aminoacids1(item, group_indices=group_indices, check=False) + return molsysmt_Topology_to_string_aminoacids1(item, group_indices=group_indices, check=False) - return tmp_item def to_openmm_Topology(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.molsysmt_Topology import to_openmm_Topology as molsysmt_Topology_to_openmm_Topology + from molsysmt.basic import get box = get(molecular_system, element='system', structure_indices=structure_indices, box=True) + return molsysmt_Topology_to_openmm_Topology(item, box, atom_indices=atom_indices, check=False) - tmp_item = molsysmt_Topology_to_openmm_Topology(item, box, atom_indices=atom_indices, check=False) - - return tmp_item def to_mdtraj_Topology(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.molsysmt_Topology import to_mdtraj_Topology as molsysmt_Topology_to_mdtraj_Topology - tmp_item = molsysmt_Topology_to_mdtraj_Topology(item, atom_indices=atom_indices, check=False) + return molsysmt_Topology_to_mdtraj_Topology(item, atom_indices=atom_indices, check=False) - return tmp_item def to_pytraj_Topology(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.molsysmt_Topology import to_pytraj_Topology as molsysmt_Topology_to_pytraj_Topology - tmp_item = molsysmt_Topology_to_pytraj_Topology(item, atom_indices=atom_indices, check=False) + return molsysmt_Topology_to_pytraj_Topology(item, atom_indices=atom_indices, check=False) - return tmp_item def to_file_pdb(item, molecular_system, atom_indices='all', structure_indices='all', output_filename=None): - from molsysmt.item.molsysmt_Topology import to_file_pdb as molsysmt_Topology_to_file_pdb + from molsysmt.basic import get - coordinates = get(molecular_system, element='atom', selection=atom_indices, structure_indices=structure_indices, coordinates=True) + coordinates = get(molecular_system, element='atom', selection=atom_indices, structure_indices=structure_indices, + coordinates=True) box = get(molecular_system, element='system', structure_indices=structure_indices, box=True) + return molsysmt_Topology_to_file_pdb(item, coordinates, box, atom_indices=atom_indices, + output_filename=output_filename, check=False) - tmp_item = molsysmt_Topology_to_file_pdb(item, coordinates, box, atom_indices=atom_indices, output_filename=output_filename, check=False) - - return tmp_item def to_string_pdb_text(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.molsysmt_Topology import to_string_pdb_text as molsysmt_Topology_to_string_pdb_text + from molsysmt.basic import get - coordinates = get(molecular_system, element='atom', selection=atom_indices, structure_indices=structure_indices, coordinates=True) + coordinates = get(molecular_system, element='atom', selection=atom_indices, structure_indices=structure_indices, + coordinates=True) box = get(molecular_system, element='system', structure_indices=structure_indices, box=True) - tmp_item = molsysmt_Topology_to_string_pdb_text(item, coordinates=coordinates, box=box, atom_indices=atom_indices, check=False) - - return tmp_item - + return molsysmt_Topology_to_string_pdb_text(item, coordinates=coordinates, box=box, atom_indices=atom_indices, + check=False) diff --git a/molsysmt/api_forms/api_networkx_Graph.py b/molsysmt/api_forms/api_networkx_Graph.py index cfe0d7b29..b7792c76f 100644 --- a/molsysmt/api_forms/api_networkx_Graph.py +++ b/molsysmt/api_forms/api_networkx_Graph.py @@ -1,68 +1,18 @@ from molsysmt._private.exceptions import * - from molsysmt.item.networkx_Graph.is_networkx_Graph import is_networkx_Graph as is_form from molsysmt.item.networkx_Graph.extract import extract from molsysmt.item.networkx_Graph.add import add from molsysmt.item.networkx_Graph.append_structures import append_structures from molsysmt.item.networkx_Graph.get import * from molsysmt.item.networkx_Graph.set import * - import numpy as np +from .form_attributes import form_attributes -form_name='networkx.Graph' -form_type='class' -form_info=["",""] - -form_attributes = { - - 'atom_index' : True, - 'atom_id' : False, - 'atom_name' : False, - 'atom_type' : False, - - 'bond_index' : True, - 'bond_id' : False, - 'bond_name' : False, - 'bond_type' : False, - 'bond_order' : False, - 'bonded_atoms' : True, - - 'group_index' : False, - 'group_id' : False, - 'group_name' : False, - 'group_type' : False, - - 'component_index' : False, - 'component_id' : False, - 'component_name' : False, - 'component_type' : False, - - 'molecule_index' : False, - 'molecule_id' : False, - 'molecule_name' : False, - 'molecule_type' : False, - - 'chain_index' : False, - 'chain_id' : False, - 'chain_name' : False, - 'chain_type' : False, - - 'entity_index' : False, - 'entity_id' : False, - 'entity_name' : False, - 'entity_type' : False, - - 'coordinates' : False, - 'velocities' : False, - 'box' : False, - 'time' : False, - 'step' : False, - - 'forcefield' : False, - 'temperature' : False, - 'pressure' : False, - 'integrator' : False, - 'damping' : False, - -} +form_name = 'networkx.Graph' +form_type = 'class' +form_info = ["", ""] +form_attributes = form_attributes() +form_attributes['atom_index'] = True +form_attributes['bond_index'] = True +form_attributes['bonded_atoms'] = True diff --git a/molsysmt/api_forms/api_nglview_NGLWidget.py b/molsysmt/api_forms/api_nglview_NGLWidget.py index 6f56e16c7..1ba8f62e2 100644 --- a/molsysmt/api_forms/api_nglview_NGLWidget.py +++ b/molsysmt/api_forms/api_nglview_NGLWidget.py @@ -1,121 +1,89 @@ from molsysmt._private.exceptions import * - from molsysmt.item.nglview_NGLWidget.is_nglview_NGLWidget import is_nglview_NGLWidget as is_form from molsysmt.item.nglview_NGLWidget.extract import extract from molsysmt.item.nglview_NGLWidget.add import add from molsysmt.item.nglview_NGLWidget.append_structures import append_structures from molsysmt.item.nglview_NGLWidget.get import * from molsysmt.item.nglview_NGLWidget.set import * +from .form_attributes import form_attributes + +form_name = 'nglview.NGLWidget' +form_type = 'class' +form_info = ["NGLView visualization native object", "http://nglviewer.org/nglview/latest/_modules/nglview/widget.html"] + +form_attributes = form_attributes() +form_attributes['atom_index'] = True +form_attributes['atom_id'] = True +form_attributes['atom_name'] = True +form_attributes['atom_type'] = True +form_attributes['bond_index'] = True +form_attributes['bond_id'] = True +form_attributes['bond_name'] = True +form_attributes['bond_type'] = True +form_attributes['bond_order'] = True +form_attributes['group_index'] = True +form_attributes['group_id'] = True +form_attributes['group_name'] = True +form_attributes['group_type'] = True +form_attributes['component_index'] = True +form_attributes['molecule_index'] = True +form_attributes['molecule_id'] = True +form_attributes['molecule_name'] = True +form_attributes['molecule_type'] = True +form_attributes['chain_index'] = True +form_attributes['chain_id'] = True +form_attributes['chain_name'] = True +form_attributes['chain_type'] = True +form_attributes['entity_index'] = True +form_attributes['entity_id'] = True +form_attributes['entity_name'] = True +form_attributes['entity_type'] = True +form_attributes['coordinates'] = True +form_attributes['box'] = True -form_name='nglview.NGLWidget' -form_type='class' -form_info=["NGLView visualization native object","http://nglviewer.org/nglview/latest/_modules/nglview/widget.html"] - -form_attributes = { - - 'atom_index' : True, - 'atom_id' : True, - 'atom_name' : True, - 'atom_type' : True, - - 'bond_index' : True, - 'bond_id' : True, - 'bond_name' : True, - 'bond_type' : True, - 'bond_order' : True, - - 'group_index' : True, - 'group_id' : True, - 'group_name' : True, - 'group_type' : True, - - 'component_index' : True, - 'component_id' : False, - 'component_name' : False, - 'component_type' : False, - - 'molecule_index' : True, - 'molecule_id' : True, - 'molecule_name' : True, - 'molecule_type' : True, - - 'chain_index' : True, - 'chain_id' : True, - 'chain_name' : True, - 'chain_type' : True, - - 'entity_index' : True, - 'entity_id' : True, - 'entity_name' : True, - 'entity_type' : True, - - 'coordinates' : True, - 'velocities' : False, - 'box' : True, - 'time' : False, - 'step' : False, - - 'forcefield' : False, - 'temperature' : False, - 'pressure' : False, - 'integrator' : False, - 'damping' : False, -} def to_molsysmt_Topology(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.nglview_NGLWidget import to_molsysmt_Topology as nglview_NGLWidget_to_molsysmt_Topology - tmp_item = nglview_NGLWidget_to_molsysmt_Topology(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return nglview_NGLWidget_to_molsysmt_Topology(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_molsysmt_Structures(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.nglview_NGLWidget import to_molsysmt_Structures as nglview_NGLWidget_to_molsysmt_Structures - tmp_item = nglview_NGLWidget_to_molsysmt_Structures(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return nglview_NGLWidget_to_molsysmt_Structures(item, atom_indices=atom_indices, + structure_indices=structure_indices, check=False) - return tmp_item def to_molsysmt_MolSys(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.nglview_NGLWidget import to_molsysmt_Structures as nglview_NGLWidget_to_molsysmt_Structures - tmp_item = nglview_NGLWidget_to_molsysmt_MolSys(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return nglview_NGLWidget_to_molsysmt_MolSys(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_openmm_Topology(item, molecular_system=None, atom_indices='all', structure_indices='all'): - from molsysmt.item.nglview_NGLWidget import to_openmm_Topology as nglview_NGLWidget_to_openmm_Topology - tmp_item = nglview_NGLWidget_to_openmm_Topology(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return nglview_NGLWidget_to_openmm_Topology(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_string_pdb_text(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.nglview_NGLWidget import to_string_pdb_text as nglview_NGLWidget_to_string_pdb_text - tmp_item = nglview_NGLWidget_to_string_pdb_text(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return nglview_NGLWidget_to_string_pdb_text(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_string_aminoacids1(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.nglview_NGLWidget import to_string_aminoacids1 as nglview_NGLWidget_to_aminoacids1 - tmp_item = nglview_NGLWidget_to_aminoacids1(item, atom_indices=atom_indices, check=False) + return nglview_NGLWidget_to_aminoacids1(item, atom_indices=atom_indices, check=False) - return tmp_item def to_string_aminoacids3(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.nglview_NGLWidget import to_string_aminoacids3 as nglview_NGLWidget_to_aminoacids3 - tmp_item = nglview_NGLWidget_to_aminoacids3(item, atom_indices=atom_indices, check=False) - - return tmp_item - - + return nglview_NGLWidget_to_aminoacids3(item, atom_indices=atom_indices, check=False) diff --git a/molsysmt/api_forms/api_openmm_AmberInpcrdFile.py b/molsysmt/api_forms/api_openmm_AmberInpcrdFile.py index d308bd57a..0ba8cfaad 100644 --- a/molsysmt/api_forms/api_openmm_AmberInpcrdFile.py +++ b/molsysmt/api_forms/api_openmm_AmberInpcrdFile.py @@ -1,64 +1,16 @@ from molsysmt._private.exceptions import * - from molsysmt.item.openmm_AmberInpcrdFile.is_openmm_AmberInpcrdFile import is_openmm_AmberInpcrdFile as is_form from molsysmt.item.openmm_AmberInpcrdFile.extract import extract from molsysmt.item.openmm_AmberInpcrdFile.add import add from molsysmt.item.openmm_AmberInpcrdFile.append_structures import append_structures from molsysmt.item.openmm_AmberInpcrdFile.get import * from molsysmt.item.openmm_AmberInpcrdFile.set import * +from .form_attributes import form_attributes -form_name='openmm.AmberInpcrdFile' -form_type='class' -form_info=["",""] - -form_attributes = { - - 'atom_index' : False, - 'atom_id' : False, - 'atom_name' : False, - 'atom_type' : False, - - 'bond_index' : False, - 'bond_id' : False, - 'bond_name' : False, - 'bond_type' : False, - 'bond_order' : False, - - 'group_index' : False, - 'group_id' : False, - 'group_name' : False, - 'group_type' : False, - - 'component_index' : False, - 'component_id' : False, - 'component_name' : False, - 'component_type' : False, - - 'molecule_index' : False, - 'molecule_id' : False, - 'molecule_name' : False, - 'molecule_type' : False, - - 'chain_index' : False, - 'chain_id' : False, - 'chain_name' : False, - 'chain_type' : False, - - 'entity_index' : False, - 'entity_id' : False, - 'entity_name' : False, - 'entity_type' : False, - - 'coordinates' : True, - 'velocities' : False, - 'box' : True, - 'time' : False, - 'step' : False, - - 'forcefield' : False, - 'temperature' : False, - 'pressure' : False, - 'integrator' : False, - 'damping' : False, -} +form_name = 'openmm.AmberInpcrdFile' +form_type = 'class' +form_info = ["", ""] +form_attributes = form_attributes() +form_attributes['coordinates'] = True +form_attributes['box'] = True diff --git a/molsysmt/api_forms/api_openmm_AmberPrmtopFile.py b/molsysmt/api_forms/api_openmm_AmberPrmtopFile.py index 79afca35b..27553a3cf 100644 --- a/molsysmt/api_forms/api_openmm_AmberPrmtopFile.py +++ b/molsysmt/api_forms/api_openmm_AmberPrmtopFile.py @@ -1,66 +1,38 @@ from molsysmt._private.exceptions import * - from molsysmt.item.openmm_AmberPrmtopFile.is_openmm_AmberPrmtopFile import is_openmm_AmberPrmtopFile as is_form from molsysmt.item.openmm_AmberPrmtopFile.extract import extract from molsysmt.item.openmm_AmberPrmtopFile.add import add from molsysmt.item.openmm_AmberPrmtopFile.append_structures import append_structures from molsysmt.item.openmm_AmberPrmtopFile.get import * from molsysmt.item.openmm_AmberPrmtopFile.set import * - -form_name='openmm.AmberPrmtopFile' -form_type='class' -form_info=["",""] - -form_attributes = { - - 'atom_index' : True, - 'atom_id' : True, - 'atom_name' : True, - 'atom_type' : True, - - 'bond_index' : True, - 'bond_id' : True, - 'bond_name' : True, - 'bond_type' : True, - 'bond_order' : True, - - 'group_index' : True, - 'group_id' : True, - 'group_name' : True, - 'group_type' : True, - - 'component_index' : True, - 'component_id' : False, - 'component_name' : False, - 'component_type' : False, - - 'molecule_index' : True, - 'molecule_id' : True, - 'molecule_name' : True, - 'molecule_type' : True, - - 'chain_index' : True, - 'chain_id' : True, - 'chain_name' : True, - 'chain_type' : True, - - 'entity_index' : False, - 'entity_id' : False, - 'entity_name' : False, - 'entity_type' : False, - - 'coordinates' : False, - 'velocities' : False, - 'box' : True, - 'time' : False, - 'step' : False, - - 'forcefield_parameters' : True, - - 'forcefield' : False, - 'temperature' : False, - 'pressure' : False, - 'integrator' : False, - 'damping' : False, -} - +from .form_attributes import form_attributes + +form_name = 'openmm.AmberPrmtopFile' +form_type = 'class' +form_info = ["", ""] + +form_attributes = form_attributes() +form_attributes['atom_index'] = True +form_attributes['atom_id'] = True +form_attributes['atom_name'] = True +form_attributes['atom_type'] = True +form_attributes['bond_index'] = True +form_attributes['bond_id'] = True +form_attributes['bond_name'] = True +form_attributes['bond_type'] = True +form_attributes['bond_order'] = True +form_attributes['group_index'] = True +form_attributes['group_id'] = True +form_attributes['group_name'] = True +form_attributes['group_type'] = True +form_attributes['component_index'] = True +form_attributes['molecule_index'] = True +form_attributes['molecule_id'] = True +form_attributes['molecule_name'] = True +form_attributes['molecule_type'] = True +form_attributes['chain_index'] = True +form_attributes['chain_id'] = True +form_attributes['chain_name'] = True +form_attributes['chain_type'] = True +form_attributes['box'] = True +form_attributes['forcefield_parameters'] = True diff --git a/molsysmt/api_forms/api_openmm_Context.py b/molsysmt/api_forms/api_openmm_Context.py index 55d5a85aa..200fe8b71 100644 --- a/molsysmt/api_forms/api_openmm_Context.py +++ b/molsysmt/api_forms/api_openmm_Context.py @@ -1,73 +1,28 @@ from molsysmt._private.exceptions import * - from molsysmt.item.openmm_Context.is_openmm_Context import is_openmm_Context as is_form from molsysmt.item.openmm_Context.extract import extract from molsysmt.item.openmm_Context.add import add from molsysmt.item.openmm_Context.append_structures import append_structures from molsysmt.item.openmm_Context.get import * from molsysmt.item.openmm_Context.set import * +from .form_attributes import form_attributes -form_name='openmm.Context' -form_type='class' -form_info=["",""] - -form_attributes = { - - 'atom_index' : True, - 'atom_id' : False, - 'atom_name' : False, - 'atom_type' : False, - - 'bond_index' : False, - 'bond_id' : False, - 'bond_name' : False, - 'bond_type' : False, - 'bond_order' : False, - - 'group_index' : False, - 'group_id' : False, - 'group_name' : False, - 'group_type' : False, - - 'component_index' : False, - 'component_id' : False, - 'component_name' : False, - 'component_type' : False, - - 'molecule_index' : False, - 'molecule_id' : False, - 'molecule_name' : False, - 'molecule_type' : False, +form_name = 'openmm.Context' +form_type = 'class' +form_info = ["", ""] - 'chain_index' : False, - 'chain_id' : False, - 'chain_name' : False, - 'chain_type' : False, +form_attributes = form_attributes() +form_attributes['atom_index'] = True +form_attributes['coordinates'] = True +form_attributes['velocities'] = True +form_attributes['box'] = True +form_attributes['time'] = True +form_attributes['step'] = True +form_attributes['forcefield'] = True +form_attributes['temperature'] = True - 'entity_index' : False, - 'entity_id' : False, - 'entity_name' : False, - 'entity_type' : False, - - 'coordinates' : True, - 'velocities' : True, - 'box' : True, - 'time' : True, - 'step' : True, - - 'forcefield' : True, - 'temperature' : True, - 'pressure' : False, - 'integrator' : False, - 'damping' : False, -} def to_openmm_System(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.openmm_Context import to_openmm_System as openmm_Context_to_openmm_System - tmp_item = openmm_Context_to_openmm_System(item, atom_indices=atom_indices, check=False) - - return tmp_item - - + return openmm_Context_to_openmm_System(item, atom_indices=atom_indices, check=False) diff --git a/molsysmt/api_forms/api_openmm_GromacsGroFile.py b/molsysmt/api_forms/api_openmm_GromacsGroFile.py index 38790fc9c..8e75208b9 100644 --- a/molsysmt/api_forms/api_openmm_GromacsGroFile.py +++ b/molsysmt/api_forms/api_openmm_GromacsGroFile.py @@ -1,106 +1,71 @@ from molsysmt._private.exceptions import * - from molsysmt.item.openmm_GromacsGroFile.is_openmm_GromacsGroFile import is_openmm_GromacsGroFile as is_form from molsysmt.item.openmm_GromacsGroFile.extract import extract from molsysmt.item.openmm_GromacsGroFile.add import add from molsysmt.item.openmm_GromacsGroFile.append_structures import append_structures from molsysmt.item.openmm_GromacsGroFile.get import * from molsysmt.item.openmm_GromacsGroFile.set import * +from .form_attributes import form_attributes + +form_name = 'openmm.GromacsGroFile' +form_type = 'class' +form_info = ["", ""] + +form_attributes = form_attributes() +form_attributes['atom_index'] = True +form_attributes['atom_id'] = True +form_attributes['atom_name'] = True +form_attributes['atom_type'] = True +form_attributes['bond_index'] = True +form_attributes['bond_id'] = True +form_attributes['bond_name'] = True +form_attributes['bond_type'] = True +form_attributes['bond_order'] = True +form_attributes['group_index'] = True +form_attributes['group_id'] = True +form_attributes['group_name'] = True +form_attributes['group_type'] = True +form_attributes['molecule_index'] = True +form_attributes['molecule_id'] = True +form_attributes['molecule_name'] = True +form_attributes['molecule_type'] = True +form_attributes['chain_index'] = True +form_attributes['chain_id'] = True +form_attributes['chain_name'] = True +form_attributes['chain_type'] = True +form_attributes['coordinates'] = True +form_attributes['box'] = True -form_name='openmm.GromacsGroFile' -form_type='class' -form_info=["",""] - -form_attributes = { - - 'atom_index' : True, - 'atom_id' : True, - 'atom_name' : True, - 'atom_type' : True, - - 'bond_index' : True, - 'bond_id' : True, - 'bond_name' : True, - 'bond_type' : True, - 'bond_order' : True, - - 'group_index' : True, - 'group_id' : True, - 'group_name' : True, - 'group_type' : True, - - 'component_index' : False, - 'component_id' : False, - 'component_name' : False, - 'component_type' : False, - - 'molecule_index' : True, - 'molecule_id' : True, - 'molecule_name' : True, - 'molecule_type' : True, - - 'chain_index' : True, - 'chain_id' : True, - 'chain_name' : True, - 'chain_type' : True, - - 'entity_index' : False, - 'entity_id' : False, - 'entity_name' : False, - 'entity_type' : False, - - 'coordinates' : True, - 'velocities' : False, - 'box' : True, - 'time' : False, - 'step' : False, - - 'forcefield_parameters' : False, - - 'forcefield' : False, - 'temperature' : False, - 'pressure' : False, - 'integrator' : False, - 'damping' : False, -} def to_openmm_Topology(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.openmm_GromacsGroFile import to_openmm_Topology as openmm_GromacsGroFile_to_openmm_Topology - tmp_item = openmm_GromacsGroFile_to_openmm_Topology(item, atom_indices=atom_indices, check=False) + return openmm_GromacsGroFile_to_openmm_Topology(item, atom_indices=atom_indices, check=False) - return tmp_item def to_openmm_Modeller(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.openmm_GromacsGroFile import to_openmm_Modeller as openmm_GromacsGroFile_to_openmm_Modeller - tmp_item = openmm_GromacsGroFile_to_openmm_Modeller(item, atom_indices=atom_indices, check=False) + return openmm_GromacsGroFile_to_openmm_Modeller(item, atom_indices=atom_indices, check=False) - return tmp_item def to_molsysmt_MolSys(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.openmm_GromacsGroFile import to_molsysmt_MolSys as openmm_GromacsGroFile_to_molsysmt_MolSys - tmp_item = openmm_GromacsGroFile_to_molsysmt_MolSys(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return openmm_GromacsGroFile_to_molsysmt_MolSys(item, atom_indices=atom_indices, + structure_indices=structure_indices, check=False) - return tmp_item def to_molsysmt_Topology(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.openmm_GromacsGroFile import to_molsysmt_Topology as openmm_GromacsGroFile_to_molsysmt_Topology - tmp_item = openmm_GromacsGroFile_to_molsysmt_Topology(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return openmm_GromacsGroFile_to_molsysmt_Topology(item, atom_indices=atom_indices, + structure_indices=structure_indices, check=False) - return tmp_item def to_molsysmt_Structures(item, molecular_system, atom_indices='all', structure_indices='all'): + from molsysmt.item.openmm_GromacsGroFile import \ + to_molsysmt_Structures as openmm_GromacsGroFile_to_molsysmt_Structures - from molsysmt.item.openmm_GromacsGroFile import to_molsysmt_Structures as openmm_GromacsGroFile_to_molsysmt_Structures - - tmp_item = openmm_GromacsGroFile_to_molsysmt_Structures(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) - - return tmp_item - + return openmm_GromacsGroFile_to_molsysmt_Structures(item, atom_indices=atom_indices, + structure_indices=structure_indices, check=False) diff --git a/molsysmt/api_forms/api_openmm_GromacsTopFile.py b/molsysmt/api_forms/api_openmm_GromacsTopFile.py index f37a2450e..aba7eeeb8 100644 --- a/molsysmt/api_forms/api_openmm_GromacsTopFile.py +++ b/molsysmt/api_forms/api_openmm_GromacsTopFile.py @@ -1,82 +1,48 @@ from molsysmt._private.exceptions import * - from molsysmt.item.openmm_GromacsTopFile.is_openmm_GromacsTopFile import is_openmm_GromacsTopFile as is_form from molsysmt.item.openmm_GromacsTopFile.extract import extract from molsysmt.item.openmm_GromacsTopFile.add import add from molsysmt.item.openmm_GromacsTopFile.append_structures import append_structures from molsysmt.item.openmm_GromacsTopFile.get import * from molsysmt.item.openmm_GromacsTopFile.set import * +from .form_attributes import form_attributes + +form_name = 'openmm.GromacsTopFile' +form_type = 'class' +form_info = ["", ""] + +form_attributes = form_attributes() +form_attributes['atom_index'] = True +form_attributes['atom_id'] = True +form_attributes['atom_name'] = True +form_attributes['atom_type'] = True +form_attributes['bond_index'] = True +form_attributes['bond_id'] = True +form_attributes['bond_name'] = True +form_attributes['bond_type'] = True +form_attributes['bond_order'] = True +form_attributes['group_index'] = True +form_attributes['group_id'] = True +form_attributes['group_name'] = True +form_attributes['group_type'] = True +form_attributes['molecule_index'] = True +form_attributes['molecule_id'] = True +form_attributes['molecule_name'] = True +form_attributes['molecule_type'] = True +form_attributes['chain_index'] = True +form_attributes['chain_id'] = True +form_attributes['chain_name'] = True +form_attributes['chain_type'] = True -form_name='openmm.GromacsTopFile' -form_type='class' -form_info=["",""] - -form_attributes = { - - 'atom_index' : True, - 'atom_id' : True, - 'atom_name' : True, - 'atom_type' : True, - - 'bond_index' : True, - 'bond_id' : True, - 'bond_name' : True, - 'bond_type' : True, - 'bond_order' : True, - - 'group_index' : True, - 'group_id' : True, - 'group_name' : True, - 'group_type' : True, - - 'component_index' : False, - 'component_id' : False, - 'component_name' : False, - 'component_type' : False, - - 'molecule_index' : True, - 'molecule_id' : True, - 'molecule_name' : True, - 'molecule_type' : True, - - 'chain_index' : True, - 'chain_id' : True, - 'chain_name' : True, - 'chain_type' : True, - - 'entity_index' : False, - 'entity_id' : False, - 'entity_name' : False, - 'entity_type' : False, - - 'coordinates' : False, - 'velocities' : False, - 'box' : False, - 'time' : False, - 'step' : False, - - 'forcefield_parameters' : False, - - 'forcefield' : False, - 'temperature' : False, - 'pressure' : False, - 'integrator' : False, - 'damping' : False, -} def to_openmm_Topology(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.openmm_GromacsTopFile import to_openmm_Topology as openmm_GromacsTopFile_to_openmm_Topology - tmp_item = openmm_GromacsTopFile_to_openmm_Topology(item, atom_indices=atom_indices, check=False) + return openmm_GromacsTopFile_to_openmm_Topology(item, atom_indices=atom_indices, check=False) - return tmp_item def to_molsysmt_Topology(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.openmm_GromacsTopFile import to_molsysmt_Topology as openmm_GromacsTopFile_to_molsysmt_Topology - tmp_item = openmm_GromacsTopFile_to_molsysmt_Topology(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) - - return tmp_item - + return openmm_GromacsTopFile_to_molsysmt_Topology(item, atom_indices=atom_indices, + structure_indices=structure_indices, check=False) diff --git a/molsysmt/api_forms/api_openmm_Modeller.py b/molsysmt/api_forms/api_openmm_Modeller.py index 07e10c5e2..b3a8d1995 100644 --- a/molsysmt/api_forms/api_openmm_Modeller.py +++ b/molsysmt/api_forms/api_openmm_Modeller.py @@ -1,97 +1,75 @@ from molsysmt._private.exceptions import * - from molsysmt.item.openmm_Modeller.is_openmm_Modeller import is_openmm_Modeller as is_form from molsysmt.item.openmm_Modeller.extract import extract from molsysmt.item.openmm_Modeller.add import add from molsysmt.item.openmm_Modeller.append_structures import append_structures from molsysmt.item.openmm_Modeller.get import * from molsysmt.item.openmm_Modeller.set import * - -form_name='openmm.Modeller' -form_type='class' -form_info=["",""] - -form_attributes = { - - 'atom_index' : True, - 'atom_id' : True, - 'atom_name' : True, - 'atom_type' : True, - - 'bond_index' : True, - 'bond_id' : True, - 'bond_name' : True, - 'bond_type' : True, - 'bond_order' : False, - - 'group_index' : True, - 'group_id' : True, - 'group_name' : True, - 'group_type' : True, - - 'component_index' : True, - 'component_id' : True, - 'component_name' : True, - 'component_type' : True, - - 'molecule_index' : True, - 'molecule_id' : True, - 'molecule_name' : True, - 'molecule_type' : True, - - 'chain_index' : True, - 'chain_id' : True, - 'chain_name' : True, - 'chain_type' : True, - - 'entity_index' : True, - 'entity_id' : True, - 'entity_name' : True, - 'entity_type' : True, - - 'coordinates' : True, - 'velocities' : False, - 'box' : True, - 'time' : False, - 'step' : False, - - 'forcefield' : False, - 'temperature' : False, - 'pressure' : False, - 'integrator' : False, - 'damping' : False, -} +from .form_attributes import form_attributes + +form_name = 'openmm.Modeller' +form_type = 'class' +form_info = ["", ""] + +form_attributes = form_attributes() +form_attributes['atom_index'] = True +form_attributes['atom_id'] = True +form_attributes['atom_name'] = True +form_attributes['atom_type'] = True +form_attributes['bond_index'] = True +form_attributes['bond_id'] = True +form_attributes['bond_name'] = True +form_attributes['bond_type'] = True +form_attributes['group_index'] = True +form_attributes['group_id'] = True +form_attributes['group_name'] = True +form_attributes['group_type'] = True +form_attributes['component_index'] = True +form_attributes['component_id'] = True +form_attributes['component_name'] = True +form_attributes['component_type'] = True +form_attributes['molecule_index'] = True +form_attributes['molecule_id'] = True +form_attributes['molecule_name'] = True +form_attributes['molecule_type'] = True +form_attributes['chain_index'] = True +form_attributes['chain_id'] = True +form_attributes['chain_name'] = True +form_attributes['chain_type'] = True +form_attributes['entity_index'] = True +form_attributes['entity_id'] = True +form_attributes['entity_name'] = True +form_attributes['entity_type'] = True +form_attributes['coordinates'] = True +form_attributes['box'] = True def to_mdtraj_Trajectory(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.openmm_Modeller import to_mdtraj_Trajectory as openmm_Modeller_to_mdtraj_Trajectory - tmp_item = openmm_Modeller_to_mdtraj_Trajectory(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return openmm_Modeller_to_mdtraj_Trajectory(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_mdtraj_Topology(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.openmm_Modeller import to_mdtraj_Topology as openmm_Modeller_to_mdtraj_Topology - tmp_item = openmm_Modeller_to_mdtraj_Topology(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return openmm_Modeller_to_mdtraj_Topology(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_openmm_System(item, molecular_system, atom_indices='all', structure_indices='all', forcefield=None, non_bonded_method='no_cutoff', non_bonded_cutoff='1.0 nm', constraints=None, rigid_water=True, remove_cm_motion=True, hydrogen_mass=None, switch_distance=None, flexible_constraints=False): - from molsysmt.item.openmm_Modeller import to_openmm_System as openmm_Modeller_to_openmm_System - tmp_item = openmm_Modeller_to_openmm_System(item, atom_indices=atom_indices, structure_indices=structure_indices, - forcefield=None, non_bonded_method='no_cutoff', non_bonded_cutoff='1.0 nm', constraints=None, - rigid_water=True, remove_cm_motion=True, hydrogen_mass=None, switch_distance=None, - flexible_constraints=False, check=False) - - return tmp_item + return openmm_Modeller_to_openmm_System(item, atom_indices=atom_indices, structure_indices=structure_indices, + forcefield=None, non_bonded_method='no_cutoff', non_bonded_cutoff='1.0 nm', + constraints=None, + rigid_water=True, remove_cm_motion=True, hydrogen_mass=None, + switch_distance=None, + flexible_constraints=False, check=False) def to_openmm_Simulation(item, molecular_system, atom_indices='all', structure_indices='all', @@ -99,57 +77,50 @@ def to_openmm_Simulation(item, molecular_system, atom_indices='all', structure_i rigid_water=True, remove_cm_motion=True, hydrogen_mass=None, switch_distance=None, flexible_constraints=False, integrator='Langevin', temperature='300.0 K', collisions_rate='1.0 1/ps', integration_timestep='2.0 fs', platform='CUDA'): - from molsysmt.item.openmm_Modeller import to_openmm_Simulation as openmm_Modeller_to_openmm_Simulation - tmp_item = openmm_Modeller_to_openmm_Simulation(item, atom_indices=atom_indices, structure_indices=structure_indices, - forcefield=None, non_bonded_method='no_cutoff', non_bonded_cutoff='1.0 nm', constraints=None, - rigid_water=True, remove_cm_motion=True, hydrogen_mass=None, switch_distance=None, - flexible_constraints=False, integrator='Langevin', temperature='300.0 K', - collisions_rate='1.0 1/ps', integration_timestep='2.0 fs', platform='CUDA', - check=False) + return openmm_Modeller_to_openmm_Simulation(item, atom_indices=atom_indices, structure_indices=structure_indices, + forcefield=None, non_bonded_method='no_cutoff', + non_bonded_cutoff='1.0 nm', constraints=None, + rigid_water=True, remove_cm_motion=True, hydrogen_mass=None, + switch_distance=None, + flexible_constraints=False, integrator='Langevin', + temperature='300.0 K', + collisions_rate='1.0 1/ps', integration_timestep='2.0 fs', + platform='CUDA', + check=False) - return tmp_item def to_openmm_Topology(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.openmm_Modeller import to_openmm_Topology as openmm_Modeller_to_openmm_Topology - tmp_item = openmm_Modeller_to_openmm_Topology(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return openmm_Modeller_to_openmm_Topology(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_pdbfixer_PDBFixer(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.openmm_Modeller import to_pdbfixer_PDBFixer as openmm_Modeller_to_pdbfixer_PDBFixer - tmp_item = openmm_Modeller_to_pdbfixer_PDBFixer(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return openmm_Modeller_to_pdbfixer_PDBFixer(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_molsysmt_MolSys(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.openmm_Modeller import to_molsysmt_MolSys as openmm_Modeller_to_molsysmt_MolSys - tmp_item = openmm_Modeller_to_molsysmt_MolSys(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return openmm_Modeller_to_molsysmt_MolSys(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_file_pdb(item, molecular_system, atom_indices='all', structure_indices='all', output_filename=None): - from molsysmt.item.openmm_Modeller import to_file_pdb as openmm_Modeller_to_file_pdb - tmp_item = openmm_Modeller_to_file_pdb(item, atom_indices=atom_indices, structure_indices=structure_indices, - output_filename=output_filename, check=False) + return openmm_Modeller_to_file_pdb(item, atom_indices=atom_indices, structure_indices=structure_indices, + output_filename=output_filename, check=False) - return tmp_item def to_nglview_NGLWidget(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.openmm_Modeller import to_nglview_NGLWidget as openmm_Modeller_to_nglview_NGLWidget - tmp_item = openmm_Modeller_to_molsysmt_MolSys(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) - - return tmp_item - - + return openmm_Modeller_to_molsysmt_MolSys(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) diff --git a/molsysmt/api_forms/api_openmm_PDBFile.py b/molsysmt/api_forms/api_openmm_PDBFile.py index 8b906d41f..18b9afac9 100644 --- a/molsysmt/api_forms/api_openmm_PDBFile.py +++ b/molsysmt/api_forms/api_openmm_PDBFile.py @@ -1,122 +1,89 @@ from molsysmt._private.exceptions import * - from molsysmt.item.openmm_PDBFile.is_openmm_PDBFile import is_openmm_PDBFile as is_form from molsysmt.item.openmm_PDBFile.extract import extract from molsysmt.item.openmm_PDBFile.add import add from molsysmt.item.openmm_PDBFile.append_structures import append_structures from molsysmt.item.openmm_PDBFile.get import * from molsysmt.item.openmm_PDBFile.set import * +from .form_attributes import form_attributes + +form_name = 'openmm.PDBFile' +form_type = 'class' +form_info = ["", ""] + +form_attributes = form_attributes() +form_attributes['atom_index'] = True +form_attributes['atom_id'] = True +form_attributes['atom_name'] = True +form_attributes['atom_type'] = True +form_attributes['group_index'] = True +form_attributes['group_id'] = True +form_attributes['group_name'] = True +form_attributes['group_type'] = True +form_attributes['component_index'] = True +form_attributes['component_id'] = True +form_attributes['component_name'] = True +form_attributes['component_type'] = True +form_attributes['molecule_index'] = True +form_attributes['molecule_id'] = True +form_attributes['molecule_name'] = True +form_attributes['molecule_type'] = True +form_attributes['chain_index'] = True +form_attributes['chain_id'] = True +form_attributes['chain_name'] = True +form_attributes['chain_type'] = True +form_attributes['entity_index'] = True +form_attributes['entity_id'] = True +form_attributes['entity_name'] = True +form_attributes['entity_type'] = True +form_attributes['coordinates'] = True +form_attributes['box'] = True +form_attributes['time'] = True +form_attributes['step'] = True -form_name='openmm.PDBFile' -form_type='class' -form_info=["",""] - -form_attributes = { - - 'atom_index' : True, - 'atom_id' : True, - 'atom_name' : True, - 'atom_type' : True, - - 'bond_index' : False, - 'bond_id' : False, - 'bond_name' : False, - 'bond_type' : False, - 'bond_order' : False, - - 'group_index' : True, - 'group_id' : True, - 'group_name' : True, - 'group_type' : True, - - 'component_index' : True, - 'component_id' : True, - 'component_name' : True, - 'component_type' : True, - - 'molecule_index' : True, - 'molecule_id' : True, - 'molecule_name' : True, - 'molecule_type' : True, - - 'chain_index' : True, - 'chain_id' : True, - 'chain_name' : True, - 'chain_type' : True, - - 'entity_index' : True, - 'entity_id' : True, - 'entity_name' : True, - 'entity_type' : True, - - 'coordinates' : True, - 'velocities' : False, - 'box' : True, - 'time' : True, - 'step' : True, - - 'forcefield' : False, - 'temperature' : False, - 'pressure' : False, - 'integrator' : False, - 'damping' : False, - -} def to_molsysmt_Topology(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.openmm_PDBFile import to_molsysmt_Topology as openmm_PDBFile_to_molsysmt_Topology - tmp_item = openmm_PDBFile_to_molsysmt_Topology(item, atom_indices=atom_indices, check=False) + return openmm_PDBFile_to_molsysmt_Topology(item, atom_indices=atom_indices, check=False) - return tmp_item def to_molsysmt_Structures(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.openmm_PDBFile import to_molsysmt_Structures as openmm_PDBFile_to_molsysmt_Structures - tmp_item = openmm_PDBFile_to_molsysmt_Structures(item, atom_indices=atom_indices, check=False) + return openmm_PDBFile_to_molsysmt_Structures(item, atom_indices=atom_indices, check=False) - return tmp_item def to_molsysmt_MolSys(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.openmm_PDBFile import to_molsysmt_MolSys as openmm_PDBFile_to_molsysmt_MolSys - tmp_item = openmm_PDBFile_to_molsysmt_MolSys(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return openmm_PDBFile_to_molsysmt_MolSys(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_mdtraj_Trajectory(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.openmm_PDBFile import to_mdtraj_Trajectory as openmm_PDBFile_to_mdtraj_Trajectory - tmp_item = openmm_PDBFile_to_molsysmt_Trajectory(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return openmm_PDBFile_to_molsysmt_Trajectory(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_mdtraj_Topology(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.openmm_PDBFile import to_mdtraj_Topology as openmm_PDBFile_to_mdtraj_Topology - tmp_item = openmm_PDBFile_to_mdtraj_Topology(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return openmm_PDBFile_to_mdtraj_Topology(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_openmm_Topology(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.openmm_Topology import to_openmm_Topology as openmm_PDBFile_to_mdtraj_Topology - tmp_item = openmm_PDBFile_to_mdtraj_Topology(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return openmm_PDBFile_to_mdtraj_Topology(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_nglview_NGLWidget(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.openmm_Topology import to_nglview_NGLWidget as openmm_Topology_to_nglview_NGLWidget - tmp_item = openmm_Topology_to_nglview_NGLWidget(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) - - return tmp_item - - + return openmm_Topology_to_nglview_NGLWidget(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) diff --git a/molsysmt/api_forms/api_openmm_Simulation.py b/molsysmt/api_forms/api_openmm_Simulation.py index 7d47bf770..707aed8c1 100644 --- a/molsysmt/api_forms/api_openmm_Simulation.py +++ b/molsysmt/api_forms/api_openmm_Simulation.py @@ -1,136 +1,108 @@ from molsysmt._private.exceptions import * - from molsysmt.item.openmm_Simulation.is_openmm_Simulation import is_openmm_Simulation as is_form from molsysmt.item.openmm_Simulation.extract import extract from molsysmt.item.openmm_Simulation.add import add from molsysmt.item.openmm_Simulation.append_structures import append_structures from molsysmt.item.openmm_Simulation.get import * from molsysmt.item.openmm_Simulation.set import * - -form_name='openmm.Simulation' -form_type='class' -form_info=["",""] - -form_attributes = { - - 'atom_index' : True, - 'atom_id' : True, - 'atom_name' : True, - 'atom_type' : True, - - 'bond_index' : True, - 'bond_id' : True, - 'bond_name' : True, - 'bond_type' : True, - 'bond_order' : True, - - 'group_index' : True, - 'group_id' : True, - 'group_name' : True, - 'group_type' : True, - - 'component_index' : True, - 'component_id' : True, - 'component_name' : True, - 'component_type' : True, - - 'molecule_index' : True, - 'molecule_id' : True, - 'molecule_name' : True, - 'molecule_type' : True, - - 'chain_index' : True, - 'chain_id' : True, - 'chain_name' : True, - 'chain_type' : True, - - 'entity_index' : True, - 'entity_id' : True, - 'entity_name' : True, - 'entity_type' : True, - - 'coordinates' : True, - 'velocities' : True, - 'box' : True, - 'time' : True, - 'step' : True, - - 'forcefield' : True, - 'temperature' : True, - 'pressure' : True, - 'integrator' : True, - 'damping' : True, -} +from .form_attributes import form_attributes + +form_name = 'openmm.Simulation' +form_type = 'class' +form_info = ["", ""] + +form_attributes = form_attributes() +form_attributes['atom_index'] = True +form_attributes['atom_id'] = True +form_attributes['atom_name'] = True +form_attributes['atom_type'] = True +form_attributes['bond_index'] = True +form_attributes['bond_id'] = True +form_attributes['bond_name'] = True +form_attributes['bond_type'] = True +form_attributes['bond_order'] = True +form_attributes['group_index'] = True +form_attributes['group_id'] = True +form_attributes['group_name'] = True +form_attributes['group_type'] = True +form_attributes['component_index'] = True +form_attributes['component_id'] = True +form_attributes['component_name'] = True +form_attributes['component_type'] = True +form_attributes['molecule_index'] = True +form_attributes['molecule_id'] = True +form_attributes['molecule_name'] = True +form_attributes['molecule_type'] = True +form_attributes['chain_index'] = True +form_attributes['chain_id'] = True +form_attributes['chain_name'] = True +form_attributes['chain_type'] = True +form_attributes['entity_index'] = True +form_attributes['entity_id'] = True +form_attributes['entity_name'] = True +form_attributes['entity_type'] = True +form_attributes['coordinates'] = True +form_attributes['velocities'] = True +form_attributes['box'] = True +form_attributes['time'] = True +form_attributes['step'] = True +form_attributes['forcefield'] = True +form_attributes['temperature'] = True +form_attributes['pressure'] = True +form_attributes['integrator'] = True +form_attributes['damping'] = True def to_molsysmt_Topology(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.openmm_Simulation import to_molsysmt_Topology as openmm_Simulation_to_molsysmt_Topology - tmp_item = openmm_Simulation_to_molsysmt_Topology(item, atom_indices=atom_indices, check=False) + return openmm_Simulation_to_molsysmt_Topology(item, atom_indices=atom_indices, check=False) - return tmp_item def to_molsysmt_Structures(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.openmm_Simulation import to_molsysmt_Structures as openmm_Simulation_to_molsysmt_Structures - tmp_item = openmm_Simulation_to_molsysmt_Structures(item, atom_indices=atom_indices, - structure_indices=structure_indices, check=False) + return openmm_Simulation_to_molsysmt_Structures(item, atom_indices=atom_indices, + structure_indices=structure_indices, check=False) - return tmp_item def to_molsysmt_MolSys(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.openmm_Simulation import to_molsysmt_MolSys as openmm_Simulation_to_molsysmt_MolSys - tmp_item = openmm_Simulation_to_molsysmt_MolSys(item, atom_indices=atom_indices, - structure_indices=structure_indices, check=False) + return openmm_Simulation_to_molsysmt_MolSys(item, atom_indices=atom_indices, + structure_indices=structure_indices, check=False) - return tmp_item def to_openmm_Topology(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.openmm_Simulation import to_openmm_Topology as openmm_Simulation_to_openmm_Topology - tmp_item = openmm_Simulation_to_openmm_Topology(item, atom_indices=atom_indices, check=False) + return openmm_Simulation_to_openmm_Topology(item, atom_indices=atom_indices, check=False) - return tmp_item def to_openmm_Modeller(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.openmm_Simulation import to_openmm_Modeller as openmm_Simulation_to_openmm_Modeller - tmp_item = openmm_Simulation_to_openmm_Modeller(item, atom_indices=atom_indices, - structure_indices=structure_indices, check=False) + return openmm_Simulation_to_openmm_Modeller(item, atom_indices=atom_indices, + structure_indices=structure_indices, check=False) - return tmp_item def to_openmm_Context(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.openmm_Simulation import to_openmm_Context as openmm_Simulation_to_openmm_Context - tmp_item = openmm_Simulation_to_openmm_Context(item, atom_indices=atom_indices, - structure_indices=structure_indices, check=False) + return openmm_Simulation_to_openmm_Context(item, atom_indices=atom_indices, + structure_indices=structure_indices, check=False) - return tmp_item def to_pdbfixer_PDBFixer(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.openmm_Simulation import to_pdbfixer_PDBFixer as openmm_Simulation_to_pdbfixer_PDBFixer - tmp_item = openmm_Simulation_to_pdbfixer_PDBFixer(item, atom_indices=atom_indices, - structure_indices=structure_indices, check=False) + return openmm_Simulation_to_pdbfixer_PDBFixer(item, atom_indices=atom_indices, + structure_indices=structure_indices, check=False) - return tmp_item def to_file_pdb(item, molecular_system, atom_indices='all', structure_indices='all', output_filename=None): - from molsysmt.item.openmm_Simulation import to_file_pdb as openmm_Simulation_to_file_pdb - tmp_item = openmm_Simulation_to_file_pdb(item, atom_indices=atom_indices, - structure_indices=structure_indices, output_filename=output_filename, check=False) - - return tmp_item - - + return openmm_Simulation_to_file_pdb(item, atom_indices=atom_indices, + structure_indices=structure_indices, output_filename=output_filename, + check=False) diff --git a/molsysmt/api_forms/api_openmm_System.py b/molsysmt/api_forms/api_openmm_System.py index e562af7aa..e79cca0f9 100644 --- a/molsysmt/api_forms/api_openmm_System.py +++ b/molsysmt/api_forms/api_openmm_System.py @@ -1,80 +1,60 @@ from molsysmt._private.exceptions import * - from molsysmt.item.openmm_System.is_openmm_System import is_openmm_System as is_form from molsysmt.item.openmm_System.extract import extract from molsysmt.item.openmm_System.add import add from molsysmt.item.openmm_System.append_structures import append_structures from molsysmt.item.openmm_System.get import * from molsysmt.item.openmm_System.set import * +from .form_attributes import form_attributes + +form_name = 'openmm.System' +form_type = 'class' +form_info = ["", ""] + +form_attributes = form_attributes() +form_attributes['atom_index'] = True +form_attributes['atom_id'] = True +form_attributes['atom_name'] = True +form_attributes['atom_type'] = True +form_attributes['bond_index'] = True +form_attributes['bond_id'] = True +form_attributes['bond_name'] = True +form_attributes['bond_type'] = True +form_attributes['bond_order'] = True +form_attributes['group_index'] = True +form_attributes['group_id'] = True +form_attributes['group_name'] = True +form_attributes['group_type'] = True +form_attributes['component_index'] = True +form_attributes['molecule_index'] = True +form_attributes['molecule_id'] = True +form_attributes['molecule_name'] = True +form_attributes['molecule_type'] = True +form_attributes['chain_index'] = True +form_attributes['chain_id'] = True +form_attributes['chain_name'] = True +form_attributes['chain_type'] = True +form_attributes['entity_index'] = True +form_attributes['entity_id'] = True +form_attributes['entity_name'] = True +form_attributes['entity_type'] = True +form_attributes['box'] = True +form_attributes['forcefield'] = True +form_attributes['temperature'] = True +form_attributes['pressure'] = True +form_attributes['integrator'] = True +form_attributes['damping'] = True -form_name='openmm.System' -form_type='class' -form_info=["",""] - -form_attributes = { - - 'atom_index' : True, - 'atom_id' : True, - 'atom_name' : True, - 'atom_type' : True, - - 'bond_index' : True, - 'bond_id' : True, - 'bond_name' : True, - 'bond_type' : True, - 'bond_order' : True, - - 'group_index' : True, - 'group_id' : True, - 'group_name' : True, - 'group_type' : True, - - 'component_index' : True, - 'component_id' : False, - 'component_name' : False, - 'component_type' : False, - - 'molecule_index' : True, - 'molecule_id' : True, - 'molecule_name' : True, - 'molecule_type' : True, - - 'chain_index' : True, - 'chain_id' : True, - 'chain_name' : True, - 'chain_type' : True, - - 'entity_index' : True, - 'entity_id' : True, - 'entity_name' : True, - 'entity_type' : True, - - 'coordinates' : False, - 'velocities' : False, - 'box' : True, - 'time' : False, - 'step' : False, - - 'forcefield' : True, - 'temperature' : True, - 'pressure' : True, - 'integrator' : True, - 'damping' : True, -} def to_openmm_Context(item, molecular_system=None, atom_indices='all', structure_indices='all'): - from molsysmt.item.openmm_System import to_openmm_Context as openmm_System_to_openmm_Context - tmp_item = openmm_System_to_openmm_Context(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return openmm_System_to_openmm_Context(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_openmm_Simulation(item, molecular_system=None, atom_indices='all', structure_indices='all'): - from molsysmt.item.openmm_System import to_openmm_Simulation as openmm_System_to_openmm_Simulation - tmp_item = openmm_System_to_openmm_Simulation(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) - - return tmp_item - + return openmm_System_to_openmm_Simulation(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) diff --git a/molsysmt/api_forms/api_openmm_Topology.py b/molsysmt/api_forms/api_openmm_Topology.py index 8e8461a18..1e1aeca39 100644 --- a/molsysmt/api_forms/api_openmm_Topology.py +++ b/molsysmt/api_forms/api_openmm_Topology.py @@ -1,205 +1,159 @@ from molsysmt._private.exceptions import * - from molsysmt.item.openmm_Topology.is_openmm_Topology import is_openmm_Topology as is_form from molsysmt.item.openmm_Topology.extract import extract from molsysmt.item.openmm_Topology.add import add from molsysmt.item.openmm_Topology.append_structures import append_structures from molsysmt.item.openmm_Topology.get import * from molsysmt.item.openmm_Topology.set import * - -form_name='openmm.Topology' -form_type='class' -form_info=["",""] - -form_attributes = { - - 'atom_index' : True, - 'atom_id' : True, - 'atom_name' : True, - 'atom_type' : True, - - 'bond_index' : True, - 'bond_id' : True, - 'bond_name' : True, - 'bond_type' : True, - 'bond_order' : True, - - 'group_index' : True, - 'group_id' : True, - 'group_name' : True, - 'group_type' : True, - - 'component_index' : True, - 'component_id' : False, - 'component_name' : False, - 'component_type' : False, - - 'molecule_index' : True, - 'molecule_id' : True, - 'molecule_name' : True, - 'molecule_type' : True, - - 'chain_index' : True, - 'chain_id' : True, - 'chain_name' : True, - 'chain_type' : True, - - 'entity_index' : True, - 'entity_id' : True, - 'entity_name' : True, - 'entity_type' : True, - - 'coordinates' : False, - 'velocities' : False, - 'box' : True, - 'time' : False, - 'step' : False, - - 'forcefield' : False, - 'temperature' : False, - 'pressure' : False, - 'integrator' : False, - 'damping' : False, -} +from .form_attributes import form_attributes + +form_name = 'openmm.Topology' +form_type = 'class' +form_info = ["", ""] + +form_attributes = form_attributes() +form_attributes['atom_index'] = True +form_attributes['atom_id'] = True +form_attributes['atom_name'] = True +form_attributes['atom_type'] = True +form_attributes['bond_index'] = True +form_attributes['bond_id'] = True +form_attributes['bond_name'] = True +form_attributes['bond_type'] = True +form_attributes['bond_order'] = True +form_attributes['group_index'] = True +form_attributes['group_id'] = True +form_attributes['group_name'] = True +form_attributes['group_type'] = True +form_attributes['component_index'] = True +form_attributes['molecule_index'] = True +form_attributes['molecule_id'] = True +form_attributes['molecule_name'] = True +form_attributes['molecule_type'] = True +form_attributes['chain_index'] = True +form_attributes['chain_id'] = True +form_attributes['chain_name'] = True +form_attributes['chain_type'] = True +form_attributes['entity_index'] = True +form_attributes['entity_id'] = True +form_attributes['entity_name'] = True +form_attributes['entity_type'] = True +form_attributes['box'] = True def to_molsysmt_Topology(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.openmm_Topology import to_molsysmt_Topology as openmm_Topology_to_molsysmt_Topology - tmp_item = openmm_Topology_to_molsysmt_Topology(item, atom_indices=atom_indices, check=False) + return openmm_Topology_to_molsysmt_Topology(item, atom_indices=atom_indices, check=False) - return tmp_item def to_molsysmt_MolSys(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.openmm_Topology import to_molsysmt_MolSys as openmm_Topology_to_molsysmt_MolSys - from molsysmt.basic import get - coordinates, box = get(molecular_system, atom_indices=atom_indices, structure_indices=structure_indices, coordinates=True, box=True) + from molsysmt.basic import get - tmp_item = openmm_Topology_to_molsysmt_MolSys(item, atom_indices=atom_indices, - coordinates=coordinates, box=box, check=False) + coordinates, box = get(molecular_system, atom_indices=atom_indices, structure_indices=structure_indices, + coordinates=True, box=True) + return openmm_Topology_to_molsysmt_MolSys(item, atom_indices=atom_indices, + coordinates=coordinates, box=box, check=False) - return tmp_item def to_mdtraj_Topology(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.openmm_Topology import to_mdtraj_Topology as openmm_Topology_to_mdtraj_Topology - tmp_item = openmm_Topology_to_mdtraj_Topology(item, atom_indices=atom_indices, check=False) + return openmm_Topology_to_mdtraj_Topology(item, atom_indices=atom_indices, check=False) - return tmp_item def to_parmed_Structure(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.openmm_Topology import to_parmed_Structure as openmm_Topology_to_parmed_Structure - tmp_item = openmm_Topology_to_parmed_Structure(item, atom_indices=atom_indices, check=False) + return openmm_Topology_to_parmed_Structure(item, atom_indices=atom_indices, check=False) - return tmp_item def to_openmm_Modeller(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.openmm_Topology import to_openmm_Modeller as openmm_Topology_to_openmm_Modeller - from molsysmt.basic import get - coordinates = get(molecular_system, atom_indices=atom_indices, structure_indices=structure_indices, coordinates=True) + from molsysmt.basic import get - tmp_item = openmm_Topology_to_openmm_Modeller(item, atom_indices=atom_indices, coordinates=coordinates, check=False) + coordinates = get(molecular_system, atom_indices=atom_indices, structure_indices=structure_indices, + coordinates=True) + return openmm_Topology_to_openmm_Modeller(item, atom_indices=atom_indices, coordinates=coordinates, check=False) - return tmp_item def to_openmm_System(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.openmm_Topology import to_openmm_System as openmm_Topology_to_openmm_System + from molsysmt.basic import convert molecular_mechanics = convert(molecular_system, to_form='molsysmt.MolecularMechanics') - forcefield = molecular_mechanics.to_openmm_ForceField() system_parameters = molecular_mechanics.get_openmm_System_parameters() + return openmm_Topology_to_openmm_System(item, atom_indices=atom_indices, + forcefield=forcefield, parameters=parameters, + check=False) - tmp_item = openmm_Topology_to_openmm_System(item, atom_indices=atom_indices, - forcefield=forcefield, parameters=parameters, - check=False) - - return tmp_item def to_openmm_Context(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.openmm_Topology import to_openmm_Context as openmm_Topology_to_openmm_Context + from molsysmt.basic import convert molecular_mechanics = convert(molecular_system, to_form='molsysmt.MolecularMechanics') - forcefield = molecular_mechanics.to_openmm_ForceField() system_parameters = molecular_mechanics.get_openmm_System_parameters() + return openmm_Topology_to_openmm_Context(item, atom_indices=atom_indices, + forcefield=forcefield, parameters=parameters, + check=False) - tmp_item = openmm_Topology_to_openmm_Context(item, atom_indices=atom_indices, - forcefield=forcefield, parameters=parameters, - check=False) - - return tmp_item def to_openmm_Simulation(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.openmm_Topology import to_openmm_Simulation as openmm_Topology_to_openmm_Simulation + from molsysmt.basic import convert molecular_mechanics = convert(molecular_system, to_form='molsysmt.MolecularMechanics') - forcefield = molecular_mechanics.to_openmm_ForceField() system_parameters = molecular_mechanics.get_openmm_System_parameters() + return openmm_Topology_to_openmm_Context(item, atom_indices=atom_indices, + forcefield=forcefield, parameters=parameters, + check=False) - tmp_item = openmm_Topology_to_openmm_Context(item, atom_indices=atom_indices, - forcefield=forcefield, parameters=parameters, - check=False) - - return tmp_item def to_file_pdb(item, molecular_system, atom_indices='all', structure_indices='all', output_filename=None): - from molsysmt.item.openmm_Topology import to_file_pdb as openmm_Topology_to_file_pdb - from molsysmt.basic import get - coordinates = get(molecular_system, atom_indices=atom_indices, structure_indices=structure_indices, coordinates=True) + from molsysmt.basic import get - tmp_item = openmm_Topology_to_file_pdb(item, atom_indices=atom_indices, coordinates=coordinates, check=False) + coordinates = get(molecular_system, atom_indices=atom_indices, structure_indices=structure_indices, + coordinates=True) + return openmm_Topology_to_file_pdb(item, atom_indices=atom_indices, coordinates=coordinates, check=False) - return tmp_item def to_string_pdb_text(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.openmm_Topology import to_string_pdb_text as openmm_Topology_to_string_pdb_text - from molsysmt.basic import get - coordinates = get(molecular_system, atom_indices=atom_indices, structure_indices=structure_indices, coordinates=True) + from molsysmt.basic import get - tmp_item = openmm_Topology_to_file_pdb(item, atom_indices=atom_indices, coordinates=coordinates, check=False) + coordinates = get(molecular_system, atom_indices=atom_indices, structure_indices=structure_indices, + coordinates=True) + return openmm_Topology_to_file_pdb(item, atom_indices=atom_indices, coordinates=coordinates, check=False) - return tmp_item def to_openmm_PDBFile(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.openmm_Topology import to_openmm_PDBFile as openmm_Topology_to_openmm_PDBFile - from molsysmt.basic import get - coordinates = get(molecular_system, atom_indices=atom_indices, structure_indices=structure_indices, coordinates=True) + from molsysmt.basic import get - tmp_item = openmm_Topology_to_openmm_PDBFile(item, atom_indices=atom_indices, coordinates=coordinates, check=False) + coordinates = get(molecular_system, atom_indices=atom_indices, structure_indices=structure_indices, + coordinates=True) + return openmm_Topology_to_openmm_PDBFile(item, atom_indices=atom_indices, coordinates=coordinates, check=False) - return tmp_item def to_nglview_NGLWidget(item, molecular_system=None, atom_indices='all', structure_indices='all'): - from molsysmt.item.openmm_Topology import to_nglview_NGLWidget as openmm_Topology_to_nglview_NGLWidget - from molsysmt.basic import get - - coordinates = get(molecular_system, atom_indices=atom_indices, structure_indices=structure_indices, coordinates=True) - - tmp_item = openmm_Topology_to_nglview_NGLWidget(item, atom_indices=atom_indices, coordinates=coordinates, check=False) - - return tmp_item + from molsysmt.basic import get + coordinates = get(molecular_system, atom_indices=atom_indices, structure_indices=structure_indices, + coordinates=True) + return openmm_Topology_to_nglview_NGLWidget(item, atom_indices=atom_indices, coordinates=coordinates, check=False) diff --git a/molsysmt/api_forms/api_parmed_Structure.py b/molsysmt/api_forms/api_parmed_Structure.py index f9d68cc54..670f35791 100644 --- a/molsysmt/api_forms/api_parmed_Structure.py +++ b/molsysmt/api_forms/api_parmed_Structure.py @@ -1,161 +1,114 @@ from molsysmt._private.exceptions import * - from molsysmt.item.parmed_Structure.is_parmed_Structure import is_parmed_Structure as is_form from molsysmt.item.parmed_Structure.extract import extract from molsysmt.item.parmed_Structure.add import add from molsysmt.item.parmed_Structure.append_structures import append_structures from molsysmt.item.parmed_Structure.get import * from molsysmt.item.parmed_Structure.set import * +from .form_attributes import form_attributes + +form_name = 'parmed.Structure' +form_type = 'class' +form_info = ["", ""] + +form_attributes = form_attributes() +form_attributes['atom_index'] = True +form_attributes['atom_id'] = True +form_attributes['atom_name'] = True +form_attributes['atom_type'] = True +form_attributes['bond_index'] = True +form_attributes['bond_id'] = True +form_attributes['bond_name'] = True +form_attributes['bond_type'] = True +form_attributes['bond_order'] = True +form_attributes['group_index'] = True +form_attributes['group_id'] = True +form_attributes['group_name'] = True +form_attributes['group_type'] = True +form_attributes['component_index'] = True +form_attributes['molecule_index'] = True +form_attributes['molecule_id'] = True +form_attributes['molecule_name'] = True +form_attributes['molecule_type'] = True +form_attributes['chain_index'] = True +form_attributes['chain_id'] = True +form_attributes['chain_name'] = True +form_attributes['chain_type'] = True +form_attributes['coordinates'] = True +form_attributes['box'] = True -form_name='parmed.Structure' -form_type='class' -form_info=["",""] - -form_attributes = { - - 'atom_index' : True, - 'atom_id' : True, - 'atom_name' : True, - 'atom_type' : True, - - 'bond_index' : True, - 'bond_id' : True, - 'bond_name' : True, - 'bond_type' : True, - 'bond_order' : True, - - 'group_index' : True, - 'group_id' : True, - 'group_name' : True, - 'group_type' : True, - - 'component_index' : True, - 'component_id' : False, - 'component_name' : False, - 'component_type' : False, - - 'molecule_index' : True, - 'molecule_id' : True, - 'molecule_name' : True, - 'molecule_type' : True, - - 'chain_index' : True, - 'chain_id' : True, - 'chain_name' : True, - 'chain_type' : True, - - 'entity_index' : False, - 'entity_id' : False, - 'entity_name' : False, - 'entity_type' : False, - - 'coordinates' : True, - 'velocities' : False, - 'box' : True, - 'time' : False, - 'step' : False, - - 'forcefield' : False, - 'temperature' : False, - 'pressure' : False, - 'integrator' : False, - 'damping' : False, -} ## Methods - def to_parmed_GromacsTopologyFile(item, molecular_system, atom_indices='all', structure_indices='all'): + from molsysmt.item.parmed_Structure import \ + to_parmed_GromacsTopologyFile as parmed_Structure_to_parmed_GromacsTopologyFile - from molsysmt.item.parmed_Structure import to_parmed_GromacsTopologyFile as parmed_Structure_to_parmed_GromacsTopologyFile + return parmed_Structure_to_parmed_GromacsTopologyFile(item, atom_indices=atom_indices, check=False) - tmp_item = parmed_Structure_to_parmed_GromacsTopologyFile(item, atom_indices=atom_indices, check=False) - - return tmp_item def to_openmm_Topology(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.parmed_Structure import to_openmm_Topology as parmed_Structure_to_openmm_Topology - tmp_item = parmed_Structure_to_openmm_Topology(item, atom_indices=atom_indices, check=False) + return parmed_Structure_to_openmm_Topology(item, atom_indices=atom_indices, check=False) - return tmp_item def to_openmm_Modeller(item, molecular_system=None, atom_indices='all', structure_indices='all'): - from molsysmt.item.parmed_Structure import to_openmm_Modeller as parmed_Structure_to_openmm_Modeller - tmp_item = parmed_Structure_to_openmm_Modeller(item, atom_indices=atom_indices, - structure_indices=structure_indices, check=False) + return parmed_Structure_to_openmm_Modeller(item, atom_indices=atom_indices, + structure_indices=structure_indices, check=False) - return tmp_item def to_mdtraj_Topology(item, molecular_system=None, atom_indices='all', structure_indices='all'): - from molsysmt.item.parmed_Structure import to_mdtraj_Topology as parmed_Structure_to_mdtraj_Topology - tmp_item = parmed_Structure_to_mdtraj_Topology(item, atom_indices=atom_indices, check=False) + return parmed_Structure_to_mdtraj_Topology(item, atom_indices=atom_indices, check=False) - return tmp_item def to_mdtraj_Trajectory(item, molecular_system=None, atom_indices='all', structure_indices='all'): - from molsysmt.item.parmed_Structure import to_mdtraj_Trajectory as parmed_Structure_to_mdtraj_Trajectory - tmp_item = parmed_Structure_to_mdtraj_Trajectory(item, atom_indices=atom_indices, check=False) + return parmed_Structure_to_mdtraj_Trajectory(item, atom_indices=atom_indices, check=False) - return tmp_item def to_nglview_NGLWidget(item, molecular_system=None, atom_indices='all', structure_indices='all'): - from molsysmt.item.parmed_Structure import to_nglview_NGLWidget as parmed_Structure_to_nglview_NGLWidget - tmp_item = parmed_Structure_to_nglview_NGLWidget(item, atom_indices=atom_indices, - structure_indices=structure_indices, check=False) + return parmed_Structure_to_nglview_NGLWidget(item, atom_indices=atom_indices, + structure_indices=structure_indices, check=False) - return tmp_item def to_file_pdb(item, molecular_system=None, atom_indices='all', structure_indices='all', output_filename=None): - from molsysmt.item.parmed_Structure import to_file_pdb as parmed_Structure_to_file_pdb - tmp_item = parmed_Structure_to_file_pdb(item, atom_indices=atom_indices, - structure_indices=structure_indices, output_filename=output_filename, check=False) + return parmed_Structure_to_file_pdb(item, atom_indices=atom_indices, + structure_indices=structure_indices, output_filename=output_filename, + check=False) - return tmp_item def to_file_mol2(item, molecular_system=None, atom_indices='all', structure_indices='all', output_filename=None): - from molsysmt.item.parmed_Structure import to_file_mol2 as parmed_Structure_to_file_mol2 - tmp_item = parmed_Structure_to_file_mol2(item, atom_indices=atom_indices, - structure_indices=structure_indices, output_filename=output_filename, check=False) + return parmed_Structure_to_file_mol2(item, atom_indices=atom_indices, + structure_indices=structure_indices, output_filename=output_filename, + check=False) - return tmp_item def to_molsysmt_MolSys(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.parmed_Structure import to_molsysmt_MolSys as parmed_Structure_to_molsysmt_MolSys - tmp_item = parmed_Structure_to_molsysmt_MolSys(item, atom_indices=atom_indices, - structure_indices=structure_indices, check=False) + return parmed_Structure_to_molsysmt_MolSys(item, atom_indices=atom_indices, + structure_indices=structure_indices, check=False) - return tmp_item def to_molsysmt_Topology(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.parmed_Structure import to_molsysmt_Topology as parmed_Structure_to_molsysmt_Topology - tmp_item = parmed_Structure_to_molsysmt_Topology(item, atom_indices=atom_indices, check=False) + return parmed_Structure_to_molsysmt_Topology(item, atom_indices=atom_indices, check=False) - return tmp_item def to_molsysmt_Structures(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.parmed_Structure import to_molsysmt_Structures as parmed_Structure_to_molsysmt_Structures - tmp_item = parmed_Structure_to_molsysmt_Structures(item, atom_indices=atom_indices, - structure_indices=structure_indices, check=False) - - return tmp_item - - + return parmed_Structure_to_molsysmt_Structures(item, atom_indices=atom_indices, + structure_indices=structure_indices, check=False) diff --git a/molsysmt/api_forms/api_pdbfixer_PDBFixer.py b/molsysmt/api_forms/api_pdbfixer_PDBFixer.py index 0323e0ad4..2a6f4e7e7 100644 --- a/molsysmt/api_forms/api_pdbfixer_PDBFixer.py +++ b/molsysmt/api_forms/api_pdbfixer_PDBFixer.py @@ -1,168 +1,124 @@ from molsysmt._private.exceptions import * - from molsysmt.item.pdbfixer_PDBFixer.is_pdbfixer_PDBFixer import is_pdbfixer_PDBFixer as is_form from molsysmt.item.pdbfixer_PDBFixer.extract import extract from molsysmt.item.pdbfixer_PDBFixer.add import add from molsysmt.item.pdbfixer_PDBFixer.append_structures import append_structures from molsysmt.item.pdbfixer_PDBFixer.get import * from molsysmt.item.pdbfixer_PDBFixer.set import * +from .form_attributes import form_attributes + +form_name = 'pdbfixer.PDBFixer' +form_type = 'class' +form_info = ["", ""] + +form_attributes = form_attributes() +form_attributes['atom_index'] = True +form_attributes['atom_id'] = True +form_attributes['atom_name'] = True +form_attributes['atom_type'] = True +form_attributes['bond_index'] = True +form_attributes['bond_id'] = True +form_attributes['bond_name'] = True +form_attributes['bond_type'] = True +form_attributes['bond_order'] = True +form_attributes['group_index'] = True +form_attributes['group_id'] = True +form_attributes['group_name'] = True +form_attributes['group_type'] = True +form_attributes['component_index'] = True +form_attributes['molecule_index'] = True +form_attributes['molecule_id'] = True +form_attributes['molecule_name'] = True +form_attributes['molecule_type'] = True +form_attributes['chain_index'] = True +form_attributes['chain_id'] = True +form_attributes['chain_name'] = True +form_attributes['chain_type'] = True +form_attributes['coordinates'] = True +form_attributes['box'] = True -form_name='pdbfixer.PDBFixer' -form_type='class' -form_info=["",""] - -form_attributes = { - - 'atom_index' : True, - 'atom_id' : True, - 'atom_name' : True, - 'atom_type' : True, - - 'bond_index' : True, - 'bond_id' : True, - 'bond_name' : True, - 'bond_type' : True, - 'bond_order' : True, - - 'group_index' : True, - 'group_id' : True, - 'group_name' : True, - 'group_type' : True, - - 'component_index' : True, - 'component_id' : False, - 'component_name' : False, - 'component_type' : False, - - 'molecule_index' : True, - 'molecule_id' : True, - 'molecule_name' : True, - 'molecule_type' : True, - - 'chain_index' : True, - 'chain_id' : True, - 'chain_name' : True, - 'chain_type' : True, - - 'entity_index' : False, - 'entity_id' : False, - 'entity_name' : False, - 'entity_type' : False, - - 'coordinates' : True, - 'velocities' : False, - 'box' : True, - 'time' : False, - 'step' : False, - - 'forcefield' : False, - 'temperature' : False, - 'pressure' : False, - 'integrator' : False, - 'damping' : False, -} def to_string_aminoacids3(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.pdbfixer_PDBFixer import to_string_aminoacids3 as pdbfixer_PDBFixer_to_string_aminoacids3 - tmp_item = pdbfixer_PDBFixer_to_string_aminoacids3(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return pdbfixer_PDBFixer_to_string_aminoacids3(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_string_aminoacids1(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.pdbfixer_PDBFixer import to_string_aminoacids1 as pdbfixer_PDBFixer_to_string_aminoacids1 - tmp_item = pdbfixer_PDBFixer_to_string_aminoacids1(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return pdbfixer_PDBFixer_to_string_aminoacids1(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_biopython_Seq(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.pdbfixer_PDBFixer import to_biopython_Seq as pdbfixer_PDBFixer_to_biopython_Seq - tmp_item = pdbfixer_PDBFixer_to_biopython_Seq(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return pdbfixer_PDBFixer_to_biopython_Seq(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_biopython_SeqRecord(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.pdbfixer_PDBFixer import to_biopython_Seq as pdbfixer_PDBFixer_to_biopython_Seq - tmp_item = pdbfixer_PDBFixer_to_biopython_SeqRecord(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return pdbfixer_PDBFixer_to_biopython_SeqRecord(item, atom_indices=atom_indices, + structure_indices=structure_indices, check=False) - return tmp_item def to_mdtraj_Topology(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.pdbfixer_PDBFixer import to_mdtraj_Topology as pdbfixer_PDBFixer_to_mdtraj_Topology - tmp_item = pdbfixer_PDBFixer_to_mdtraj_Topology(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return pdbfixer_PDBFixer_to_mdtraj_Topology(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_mdtraj_Trajectory(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.pdbfixer_PDBFixer import to_mdtraj_Trajectory as pdbfixer_PDBFixer_to_mdtraj_Trajectory - tmp_item = pdbfixer_PDBFixer_to_mdtraj_Trajectory(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return pdbfixer_PDBFixer_to_mdtraj_Trajectory(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_openmm_Modeller(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.pdbfixer_PDBFixer import to_openmm_Modeller as pdbfixer_PDBFixer_to_openmm_Modeller - tmp_item = pdbfixer_PDBFixer_to_openmm_Modeller(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return pdbfixer_PDBFixer_to_openmm_Modeller(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_openmm_Topology(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.pdbfixer_PDBFixer import to_openmm_Topology as pdbfixer_PDBFixer_to_openmm_Topology - tmp_item = pdbfixer_PDBFixer_to_openmm_Topology(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return pdbfixer_PDBFixer_to_openmm_Topology(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_molsysmt_Topology(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.pdbfixer_PDBFixer import to_molsysmt_Topology as pdbfixer_PDBFixer_to_molsysmt_Topology - tmp_item = pdbfixer_PDBFixer_to_molsysmt_Topology(item, atom_indices=atom_indices, check=False) + return pdbfixer_PDBFixer_to_molsysmt_Topology(item, atom_indices=atom_indices, check=False) - return tmp_item def to_molsysmt_MolSys(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.pdbfixer_PDBFixer import to_molsysmt_MolSys as pdbfixer_PDBFixer_to_molsysmt_MolSys - tmp_item = pdbfixer_PDBFixer_to_molsysmt_MolSys(item, atom_indices=atom_indices, check=False) + return pdbfixer_PDBFixer_to_molsysmt_MolSys(item, atom_indices=atom_indices, check=False) - return tmp_item def to_parmed_Structure(item, molecular_system=None, atom_indices='all', structure_indices='all'): - from molsysmt.item.pdbfixer_PDBFixer import to_parmed_Structure as pdbfixer_PDBFixer_to_parmed_Structure - tmp_item = pdbfixer_PDBFixer_to_parmed_Structure(item, atom_indices=atom_indices, check=False) + return pdbfixer_PDBFixer_to_parmed_Structure(item, atom_indices=atom_indices, check=False) - return tmp_item def to_file_pdb(item, molecular_system=None, atom_indices='all', structure_indices='all', output_filename=None): - from molsysmt.item.pdbfixer_PDBFixer import to_file_pdb as pdbfixer_PDBFixer_to_file_pdb - tmp_item = pdbfixer_PDBFixer_to_file_pdb(item, atom_indices=atom_indices, check=False) + return pdbfixer_PDBFixer_to_file_pdb(item, atom_indices=atom_indices, check=False) - return tmp_item def to_nglview_NGLWidget(item, molecular_system=None, atom_indices='all', structure_indices='all'): - from molsysmt.item.pdbfixer_PDBFixer import to_nglview_NLGWidget as pdbfixer_PDBFixer_to_nglview_NGLWidget - tmp_item = pdbfixer_PDBFixer_to_nglview_NGLWidget(item, atom_indices=atom_indices, check=False) - - return tmp_item - + return pdbfixer_PDBFixer_to_nglview_NGLWidget(item, atom_indices=atom_indices, check=False) diff --git a/molsysmt/api_forms/api_pytraj_Topology.py b/molsysmt/api_forms/api_pytraj_Topology.py index 57e20ec03..9cfa1ad26 100644 --- a/molsysmt/api_forms/api_pytraj_Topology.py +++ b/molsysmt/api_forms/api_pytraj_Topology.py @@ -1,73 +1,43 @@ from molsysmt._private.exceptions import * import numpy as np - from molsysmt.item.pytraj_Topology.is_pytraj_Topology import is_pytraj_Topology as is_form from molsysmt.item.pytraj_Topology.extract import extract from molsysmt.item.pytraj_Topology.add import add from molsysmt.item.pytraj_Topology.append_structures import append_structures from molsysmt.item.pytraj_Topology.get import * from molsysmt.item.pytraj_Topology.set import * +from .form_attributes import form_attributes + +form_name = 'pytraj.Topology' +form_type = 'class' +form_info = ["", ""] + +form_attributes = form_attributes() +form_attributes['atom_index'] = True +form_attributes['atom_id'] = True +form_attributes['atom_name'] = True +form_attributes['atom_type'] = True +form_attributes['bond_index'] = True +form_attributes['bond_id'] = True +form_attributes['bond_name'] = True +form_attributes['bond_type'] = True +form_attributes['bond_order'] = True +form_attributes['group_index'] = True +form_attributes['group_id'] = True +form_attributes['group_name'] = True +form_attributes['group_type'] = True +form_attributes['component_index'] = True +form_attributes['molecule_index'] = True +form_attributes['molecule_id'] = True +form_attributes['molecule_name'] = True +form_attributes['molecule_type'] = True +form_attributes['chain_index'] = True +form_attributes['chain_id'] = True +form_attributes['chain_name'] = True +form_attributes['chain_type'] = True -form_name='pytraj.Topology' -form_type='class' -form_info=["",""] - -form_attributes = { - - 'atom_index' : True, - 'atom_id' : True, - 'atom_name' : True, - 'atom_type' : True, - - 'bond_index' : True, - 'bond_id' : True, - 'bond_name' : True, - 'bond_type' : True, - 'bond_order' : True, - - 'group_index' : True, - 'group_id' : True, - 'group_name' : True, - 'group_type' : True, - - 'component_index' : True, - 'component_id' : False, - 'component_name' : False, - 'component_type' : False, - - 'molecule_index' : True, - 'molecule_id' : True, - 'molecule_name' : True, - 'molecule_type' : True, - - 'chain_index' : True, - 'chain_id' : True, - 'chain_name' : True, - 'chain_type' : True, - - 'entity_index' : False, - 'entity_id' : False, - 'entity_name' : False, - 'entity_type' : False, - - 'coordinates' : False, - 'velocities' : False, - 'box' : False, - 'time' : False, - 'step' : False, - - 'forcefield' : False, - 'temperature' : False, - 'pressure' : False, - 'integrator' : False, - 'damping' : False, -} def to_molsysmt_Topology(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.pytraj_Topology import to_molsysmt_Topology as pytraj_Topology_to_molsysmt_Topology - tmp_item = pytraj_Topology_to_molsysmt_Topology(item, atom_indices=atom_indices, check=False) - - return tmp_item - + return pytraj_Topology_to_molsysmt_Topology(item, atom_indices=atom_indices, check=False) diff --git a/molsysmt/api_forms/api_pytraj_Trajectory.py b/molsysmt/api_forms/api_pytraj_Trajectory.py index 7c84f5824..e6f94dd42 100644 --- a/molsysmt/api_forms/api_pytraj_Trajectory.py +++ b/molsysmt/api_forms/api_pytraj_Trajectory.py @@ -1,99 +1,65 @@ from molsysmt._private.exceptions import * import numpy as np - from molsysmt.item.pytraj_Trajectory.is_pytraj_Trajectory import is_pytraj_Trajectory as is_form from molsysmt.item.pytraj_Trajectory.extract import extract from molsysmt.item.pytraj_Trajectory.add import add from molsysmt.item.pytraj_Trajectory.append_structures import append_structures from molsysmt.item.pytraj_Trajectory.get import * from molsysmt.item.pytraj_Trajectory.set import * +from .form_attributes import form_attributes + +form_name = 'pytraj.Trajectory' +form_type = 'class' +form_info = ["", ""] + +form_attributes = form_attributes() +form_attributes['atom_index'] = True +form_attributes['atom_id'] = True +form_attributes['atom_name'] = True +form_attributes['atom_type'] = True +form_attributes['bond_index'] = True +form_attributes['bond_id'] = True +form_attributes['bond_name'] = True +form_attributes['bond_type'] = True +form_attributes['bond_order'] = True +form_attributes['group_index'] = True +form_attributes['group_id'] = True +form_attributes['group_name'] = True +form_attributes['group_type'] = True +form_attributes['component_index'] = True +form_attributes['molecule_index'] = True +form_attributes['molecule_id'] = True +form_attributes['molecule_name'] = True +form_attributes['molecule_type'] = True +form_attributes['chain_index'] = True +form_attributes['chain_id'] = True +form_attributes['chain_name'] = True +form_attributes['chain_type'] = True +form_attributes['coordinates'] = True +form_attributes['box'] = True -form_name='pytraj.Trajectory' -form_type='class' -form_info=["",""] - -form_attributes = { - - 'atom_index' : True, - 'atom_id' : True, - 'atom_name' : True, - 'atom_type' : True, - - 'bond_index' : True, - 'bond_id' : True, - 'bond_name' : True, - 'bond_type' : True, - 'bond_order' : True, - - 'group_index' : True, - 'group_id' : True, - 'group_name' : True, - 'group_type' : True, - - 'component_index' : True, - 'component_id' : False, - 'component_name' : False, - 'component_type' : False, - - 'molecule_index' : True, - 'molecule_id' : True, - 'molecule_name' : True, - 'molecule_type' : True, - - 'chain_index' : True, - 'chain_id' : True, - 'chain_name' : True, - 'chain_type' : True, - - 'entity_index' : False, - 'entity_id' : False, - 'entity_name' : False, - 'entity_type' : False, - - 'coordinates' : True, - 'velocities' : False, - 'box' : True, - 'time' : False, - 'step' : False, - - 'forcefield' : False, - 'temperature' : False, - 'pressure' : False, - 'integrator' : False, - 'damping' : False, -} def to_pytraj_Topology(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.pytraj_Trajectory import to_pytraj_Topology as pytraj_Trajectory_to_pytraj_Topology - tmp_item = pytraj_Trajectory_to_pytraj_Topology(item, atom_indices=atom_indices, check=False) + return pytraj_Trajectory_to_pytraj_Topology(item, atom_indices=atom_indices, check=False) - return tmp_item def to_molsysmt_MolSys(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.pytraj_Trajectory import to_molsysmt_MolSys as pytraj_Trajectory_to_molsysmt_MolSys - tmp_item = pytraj_Trajectory_to_molsysmt_MolSys(item, atom_indices=atom_indices, - structure_indices=structure_indices, check=False) + return pytraj_Trajectory_to_molsysmt_MolSys(item, atom_indices=atom_indices, + structure_indices=structure_indices, check=False) - return tmp_item def to_molsysmt_Topology(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.pytraj_Trajectory import to_molsysmt_Topology as pytraj_Trajectory_to_molsysmt_Topology - tmp_item = pytraj_Trajectory_to_molsysmt_Topology(item, atom_indices=atom_indices, check=False) + return pytraj_Trajectory_to_molsysmt_Topology(item, atom_indices=atom_indices, check=False) - return tmp_item def to_molsysmt_Structures(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.pytraj_Trajectory import to_molsysmt_Structures as pytraj_Trajectory_to_molsysmt_Structures - tmp_item = pytraj_Trajectory_to_molsysmt_Structures(item, atom_indices=atom_indices, - structure_indices=structure_indices, check=False) - - return tmp_item - + return pytraj_Trajectory_to_molsysmt_Structures(item, atom_indices=atom_indices, + structure_indices=structure_indices, check=False) diff --git a/molsysmt/api_forms/api_string_aminoacids1.py b/molsysmt/api_forms/api_string_aminoacids1.py index 79bb835e7..8f514d55d 100644 --- a/molsysmt/api_forms/api_string_aminoacids1.py +++ b/molsysmt/api_forms/api_string_aminoacids1.py @@ -1,92 +1,39 @@ from molsysmt._private.exceptions import * - from molsysmt.item.string_aminoacids1.is_string_aminoacids1 import is_string_aminoacids1 as is_form from molsysmt.item.string_aminoacids1.extract import extract from molsysmt.item.string_aminoacids1.add import add from molsysmt.item.string_aminoacids1.append_structures import append_structures from molsysmt.item.string_aminoacids1.get import * from molsysmt.item.string_aminoacids1.set import * +from .form_attributes import form_attributes -form_name='string:aminoacids1' -form_type='string' -form_info=["",""] - -form_attributes = { - - 'atom_index' : False, - 'atom_id' : False, - 'atom_name' : False, - 'atom_type' : False, - - 'bond_index' : False, - 'bond_id' : False, - 'bond_name' : False, - 'bond_type' : False, - 'bond_order' : False, - - 'group_index' : True, - 'group_id' : False, - 'group_name' : True, - 'group_type' : False, - - 'component_index' : False, - 'component_id' : False, - 'component_name' : False, - 'component_type' : False, - - 'molecule_index' : False, - 'molecule_id' : False, - 'molecule_name' : False, - 'molecule_type' : False, - - 'chain_index' : False, - 'chain_id' : False, - 'chain_name' : False, - 'chain_type' : False, - - 'entity_index' : False, - 'entity_id' : False, - 'entity_name' : False, - 'entity_type' : False, +form_name = 'string:aminoacids1' +form_type = 'string' +form_info = ["", ""] - 'coordinates' : False, - 'velocities' : False, - 'box' : False, - 'time' : False, - 'step' : False, +form_attributes = form_attributes() +form_attributes['group_index'] = True +form_attributes['group_name'] = True - 'forcefield' : False, - 'temperature' : False, - 'pressure' : False, - 'integrator' : False, - 'damping' : False, -} - - -### Corresponde al formato IUPAC extended protein que aparece en Biopython +# Corresponde al formato IUPAC extended protein que aparece en Biopython def to_string_aminoacids3(item, molecular_system=None, atom_indices='all', structure_indices='all'): - from molsysmt.item.string_aminoacids1 import to_string_aminoacids3 as string_aminoacids1_to_string_aminoacids3 - tmp_item = string_aminoacids1_to_string_aminoacids3(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return string_aminoacids1_to_string_aminoacids3(item, atom_indices=atom_indices, + structure_indices=structure_indices, check=False) - return tmp_item def to_biopython_Seq(item, molecular_system=None, atom_indices='all', structure_indices='all'): - from molsysmt.item.string_aminoacids1 import to_biopython_Seq as string_aminoacids1_to_biopython_Seq - tmp_item = string_aminoacids1_to_biopython_Seq(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return string_aminoacids1_to_biopython_Seq(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item - -def to_biopython_SeqRecord(item, molecular_system=None, atom_indices='all', structure_indices='all', id=None, name=None, description=None): +def to_biopython_SeqRecord(item, molecular_system=None, atom_indices='all', structure_indices='all', id=None, name=None, + description=None): from molsysmt.item.string_aminoacids1 import to_biopython_SeqRecord as string_aminoacids1_to_biopython_SeqRecord - tmp_item = string_aminoacids1_to_biopython_SeqRecord(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) - - return tmp_item - - + return string_aminoacids1_to_biopython_SeqRecord(item, atom_indices=atom_indices, + structure_indices=structure_indices, check=False) diff --git a/molsysmt/api_forms/api_string_aminoacids3.py b/molsysmt/api_forms/api_string_aminoacids3.py index 7b4cf4412..3c8b47a31 100644 --- a/molsysmt/api_forms/api_string_aminoacids3.py +++ b/molsysmt/api_forms/api_string_aminoacids3.py @@ -1,92 +1,35 @@ from molsysmt._private.exceptions import * - from molsysmt.item.string_aminoacids3.is_string_aminoacids3 import is_string_aminoacids3 as is_form from molsysmt.item.string_aminoacids3.extract import extract from molsysmt.item.string_aminoacids3.add import add from molsysmt.item.string_aminoacids3.append_structures import append_structures from molsysmt.item.string_aminoacids3.get import * from molsysmt.item.string_aminoacids3.set import * +from .form_attributes import form_attributes -form_name='string:aminoacids3' -form_type='string' -form_info=["",""] - -form_attributes = { - - 'atom_index' : False, - 'atom_id' : False, - 'atom_name' : False, - 'atom_type' : False, - - 'bond_index' : False, - 'bond_id' : False, - 'bond_name' : False, - 'bond_type' : False, - 'bond_order' : False, - - 'group_index' : True, - 'group_id' : False, - 'group_name' : True, - 'group_type' : False, - - 'component_index' : False, - 'component_id' : False, - 'component_name' : False, - 'component_type' : False, - - 'molecule_index' : False, - 'molecule_id' : False, - 'molecule_name' : False, - 'molecule_type' : False, - - 'chain_index' : False, - 'chain_id' : False, - 'chain_name' : False, - 'chain_type' : False, - - 'entity_index' : False, - 'entity_id' : False, - 'entity_name' : False, - 'entity_type' : False, +form_name = 'string:aminoacids3' +form_type = 'string' +form_info = ["", ""] - 'coordinates' : False, - 'velocities' : False, - 'box' : False, - 'time' : False, - 'step' : False, +form_attributes = form_attributes() +form_attributes['group_index'] = True +form_attributes['group_name'] = True - 'forcefield' : False, - 'temperature' : False, - 'pressure' : False, - 'integrator' : False, - 'damping' : False, -} - - -### Corresponde al formato IUPAC extended protein que aparece en Biopython +# Corresponde al formato IUPAC extended protein que aparece en Biopython def to_string_aminoacids1(item, molecular_system=None, atom_indices='all', structure_indices='all'): - from molsysmt.item.string_aminoacids3 import to_string_aminoacids1 as string_aminoacids3_to_string_aminoacids1 - tmp_item = string_aminoacids3_to_string_aminoacids1(item, atom_indices=atom_indices, check=False) + return string_aminoacids3_to_string_aminoacids1(item, atom_indices=atom_indices, check=False) - return tmp_item def to_biopython_Seq(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.string_aminoacids3 import to_biopython_Seq as string_aminoacids3_to_biopython_Seq - tmp_item = string_aminoacids3_to_biopython_Seq(item, atom_indices=atom_indices, check=False) + return string_aminoacids3_to_biopython_Seq(item, atom_indices=atom_indices, check=False) - return tmp_item def to_biopython_SeqRecord(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.string_aminoacids3 import to_biopython_SeqRecord as string_aminoacids3_to_biopython_SeqRecord - tmp_item = string_aminoacids3_to_biopython_SeqRecord(item, atom_indices=atom_indices, check=False) - - return tmp_item - - + return string_aminoacids3_to_biopython_SeqRecord(item, atom_indices=atom_indices, check=False) diff --git a/molsysmt/api_forms/api_string_pdb_id.py b/molsysmt/api_forms/api_string_pdb_id.py index 0c0df6f2c..5c78d121e 100644 --- a/molsysmt/api_forms/api_string_pdb_id.py +++ b/molsysmt/api_forms/api_string_pdb_id.py @@ -1,100 +1,66 @@ from molsysmt._private.exceptions import * - from molsysmt.item.string_pdb_id.is_string_pdb_id import is_string_pdb_id as is_form from molsysmt.item.string_pdb_id.extract import extract from molsysmt.item.string_pdb_id.add import add from molsysmt.item.string_pdb_id.append_structures import append_structures from molsysmt.item.string_pdb_id.get import * from molsysmt.item.string_pdb_id.set import * - -form_name='string:pdb_id' -form_type='string' -form_info=["",""] - -form_attributes = { - - 'atom_index' : True, - 'atom_id' : True, - 'atom_name' : True, - 'atom_type' : True, - - 'bond_index' : False, - 'bond_id' : False, - 'bond_name' : False, - 'bond_type' : False, - 'bond_order' : False, - - 'group_index' : True, - 'group_id' : True, - 'group_name' : True, - 'group_type' : True, - - 'component_index' : False, - 'component_id' : False, - 'component_name' : False, - 'component_type' : False, - - 'molecule_index' : True, - 'molecule_id' : True, - 'molecule_name' : True, - 'molecule_type' : True, - - 'chain_index' : True, - 'chain_id' : True, - 'chain_name' : True, - 'chain_type' : True, - - 'entity_index' : True, - 'entity_id' : True, - 'entity_name' : True, - 'entity_type' : True, - - 'coordinates' : True, - 'velocities' : False, - 'box' : True, - 'time' : False, - 'step' : False, - - 'forcefield' : False, - 'temperature' : False, - 'pressure' : False, - 'integrator' : False, - 'damping' : False, -} +from .form_attributes import form_attributes + +form_name = 'string:pdb_id' +form_type = 'string' +form_info = ["", ""] + +form_attributes = form_attributes() +form_attributes['atom_index'] = True +form_attributes['atom_id'] = True +form_attributes['atom_name'] = True +form_attributes['atom_type'] = True +form_attributes['group_index'] = True +form_attributes['group_id'] = True +form_attributes['group_name'] = True +form_attributes['group_type'] = True +form_attributes['molecule_index'] = True +form_attributes['molecule_id'] = True +form_attributes['molecule_name'] = True +form_attributes['molecule_type'] = True +form_attributes['chain_index'] = True +form_attributes['chain_id'] = True +form_attributes['chain_name'] = True +form_attributes['chain_type'] = True +form_attributes['entity_index'] = True +form_attributes['entity_id'] = True +form_attributes['entity_name'] = True +form_attributes['entity_type'] = True +form_attributes['coordinates'] = True +form_attributes['box'] = True def to_file_pdb(item, molecular_system, atom_indices='all', structure_indices='all', output_filename=None): - from molsysmt.item.string_pdb_id import to_file_pdb as string_pdb_id_to_file_pdb - tmp_item = string_pdb_id_to_file_pdb(item, atom_indices=atom_indices, - structure_indices=structure_indices, - output_filename=output_filename, check=False) + return string_pdb_id_to_file_pdb(item, atom_indices=atom_indices, + structure_indices=structure_indices, + output_filename=output_filename, check=False) - return tmp_item def to_file_mmtf(item, molecular_system, atom_indices='all', structure_indices='all', output_filename=None): - from molsysmt.item.string_pdb_id import to_file_mmtf as string_pdb_id_to_file_mmtf - tmp_item = string_pdb_id_to_file_mmtf(item, atom_indices=atom_indices, - structure_indices=structure_indices, - output_filename=output_filename, check=False) + return string_pdb_id_to_file_mmtf(item, atom_indices=atom_indices, + structure_indices=structure_indices, + output_filename=output_filename, check=False) - return tmp_item def to_file_msmpk(item, molecular_system, atom_indices='all', structure_indices='all', output_filename=None): - from molsysmt.item.string_pdb_id import to_file_msmpk as string_pdb_id_to_file_msmpk - tmp_item = string_pdb_id_to_file_msmpk(item, atom_indices=atom_indices, - structure_indices=structure_indices, - output_filename=output_filename, check=False) + return string_pdb_id_to_file_msmpk(item, atom_indices=atom_indices, + structure_indices=structure_indices, + output_filename=output_filename, check=False) - return tmp_item def to_file_fasta(item, molecular_system, atom_indices='all', structure_indices='all', output_filename=None): - from sabueso.tools.string_pdb_id import to_file_fasta as string_pdb_id_to_file_fasta from sabueso.tools.file_fasta import extract as extract_file_fasta from sabueso.basic import get @@ -103,127 +69,109 @@ def to_file_fasta(item, molecular_system, atom_indices='all', structure_indices= tmp_item = string_pdb_id_to_file_fasta(item, check=False) group_indices = get(molecular_system, element='atom', indices=atom_indices, group_index=True) group_indices = np.unique(group_indices) - tmp_item = extract_file_fasta(tmp_item, group_indices=group_indices, output_filename=output_filename, copy_if_all=False) + return extract_file_fasta(tmp_item, group_indices=group_indices, output_filename=output_filename, copy_if_all=False) - return tmp_item def to_mmtf_MMTFDecoder(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.string_pdb_id import to_mmtf_MMTFDecoder as string_pdb_id_to_mmtf_MMTFDecoder - tmp_item = string_pdb_id_to_mmtf_MMTFDecoder(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return string_pdb_id_to_mmtf_MMTFDecoder(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_molsysmt_MolSys(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.string_pdb_id import to_molsysmt_MolSys as string_pdb_id_to_molsysmt_MolSys - tmp_item = string_pdb_id_to_molsysmt_MolSys(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return string_pdb_id_to_molsysmt_MolSys(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_molsysmt_Topology(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.string_pdb_id import to_molsysmt_Topology as string_pdb_id_to_molsysmt_Topology - tmp_item = string_pdb_id_to_molsysmt_Topology(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return string_pdb_id_to_molsysmt_Topology(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_molsysmt_Structures(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.string_pdb_id import to_molsysmt_Structures as string_pdb_id_to_molsysmt_Structures - tmp_item = string_pdb_id_to_molsysmt_Structures(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return string_pdb_id_to_molsysmt_Structures(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_mdtraj_Trajectory(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.string_pdb_id import to_mdtraj_Trajectory as string_pdb_id_to_mdtraj_Trajectory - tmp_item = string_pdb_id_to_mdtraj_Trajectory(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return string_pdb_id_to_mdtraj_Trajectory(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_mdtraj_Topology(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.string_pdb_id import to_mdtraj_Topology as string_pdb_id_to_mdtraj_Topology - tmp_item = string_pdb_id_to_mdtraj_Topology(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return string_pdb_id_to_mdtraj_Topology(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_parmed_Structure(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.string_pdb_id import to_parmed_Structure as string_pdb_id_to_parmed_Structure - tmp_item = string_pdb_id_to_parmed_Structure(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return string_pdb_id_to_parmed_Structure(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_pdbfixer_PDBFixer(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.string_pdb_id import to_pdbfixer_PDBFixer as string_pdb_id_to_pdbfixer_PDBFixer - tmp_item = string_pdb_id_to_pdbfixer_PDBFixer(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return string_pdb_id_to_pdbfixer_PDBFixer(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_openmm_Modeller(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.string_pdb_id import to_openmm_Modeller as string_pdb_id_to_openmm_Modeller - tmp_item = string_pdb_id_to_openmm_Modeller(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return string_pdb_id_to_openmm_Modeller(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_openmm_Topology(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.string_pdb_id import to_openmm_Topology as string_pdb_id_to_openmm_Topology - tmp_item = string_pdb_id_to_openmm_Topology(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return string_pdb_id_to_openmm_Topology(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_openmm_PDBFile(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.string_pdb_id import to_openmm_PDBFile as string_pdb_id_to_openmm_PDBFile - tmp_item = string_pdb_id_to_openmm_PDBFile(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return string_pdb_id_to_openmm_PDBFile(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_mdanalysis_Universe(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.string_pdb_id import to_mdanalysis_Universe as string_pdb_id_to_mdanalysis_Universe - tmp_item = string_pdb_id_to_mdanalysis_Universe(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return string_pdb_id_to_mdanalysis_Universe(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_pytraj_Trajectory(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.string_pdb_id import to_pytraj_Trajectory as string_pdb_id_to_pytraj_Trajectory - tmp_item = string_pdb_id_to_pytraj_Trajectory(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return string_pdb_id_to_pytraj_Trajectory(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_string_pdb_text(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.string_pdb_id import to_string_pdb_text as string_pdb_id_to_string_pdb_text - tmp_item = string_pdb_id_to_string_pdb_text(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return string_pdb_id_to_string_pdb_text(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_nglview_NGLWidget(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.string_pdb_id import to_nglview_NGLWidget as string_pdb_id_to_nglview_NGLWidget - tmp_item = string_pdb_id_to_nglview_NGLWidget(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) - - return tmp_item - + return string_pdb_id_to_nglview_NGLWidget(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) diff --git a/molsysmt/api_forms/api_string_pdb_text.py b/molsysmt/api_forms/api_string_pdb_text.py index cb0c4350e..ffd1f551f 100644 --- a/molsysmt/api_forms/api_string_pdb_text.py +++ b/molsysmt/api_forms/api_string_pdb_text.py @@ -1,176 +1,137 @@ from molsysmt._private.exceptions import * - from molsysmt.item.string_pdb_text.is_string_pdb_text import is_string_pdb_text as is_form from molsysmt.item.string_pdb_text.extract import extract from molsysmt.item.string_pdb_text.add import add from molsysmt.item.string_pdb_text.append_structures import append_structures from molsysmt.item.string_pdb_text.get import * from molsysmt.item.string_pdb_text.set import * +from .form_attributes import form_attributes + +form_name = 'string:pdb_text' +form_type = 'string' +form_info = ["Protein Data Bank file format", + "https://www.rcsb.org/pdb/static.do?p=file_formats/pdb/index.html"] + +form_attributes = form_attributes() +form_attributes['atom_index'] = True +form_attributes['atom_id'] = True +form_attributes['atom_name'] = True +form_attributes['atom_type'] = True +form_attributes['bond_index'] = True +form_attributes['bond_id'] = True +form_attributes['bond_name'] = True +form_attributes['bond_type'] = True +form_attributes['bond_order'] = True +form_attributes['group_index'] = True +form_attributes['group_id'] = True +form_attributes['group_name'] = True +form_attributes['group_type'] = True +form_attributes['component_index'] = True +form_attributes['molecule_index'] = True +form_attributes['molecule_id'] = True +form_attributes['molecule_name'] = True +form_attributes['molecule_type'] = True +form_attributes['chain_index'] = True +form_attributes['chain_id'] = True +form_attributes['chain_name'] = True +form_attributes['chain_type'] = True +form_attributes['coordinates'] = True +form_attributes['box'] = True -form_name='string:pdb_text' -form_type='string' -form_info = ["Protein Data Bank file format","https://www.rcsb.org/pdb/static.do?p=file_formats/pdb/index.html"] - -form_attributes = { - - 'atom_index' : True, - 'atom_id' : True, - 'atom_name' : True, - 'atom_type' : True, - - 'bond_index' : True, - 'bond_id' : True, - 'bond_name' : True, - 'bond_type' : True, - 'bond_order' : True, - - 'group_index' : True, - 'group_id' : True, - 'group_name' : True, - 'group_type' : True, - - 'component_index' : True, - 'component_id' : False, - 'component_name' : False, - 'component_type' : False, - - 'molecule_index' : True, - 'molecule_id' : True, - 'molecule_name' : True, - 'molecule_type' : True, - - 'chain_index' : True, - 'chain_id' : True, - 'chain_name' : True, - 'chain_type' : True, - - 'entity_index' : False, - 'entity_id' : False, - 'entity_name' : False, - 'entity_type' : False, - - 'coordinates' : True, - 'velocities' : False, - 'box' : True, - 'time' : False, - 'step' : False, - - 'forcefield' : False, - 'temperature' : False, - 'pressure' : False, - 'integrator' : False, - 'damping' : False, -} def to_molsysmt_MolSys(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.string_pdb_text import to_molsysmt_MolSys as string_pdb_text_to_molsysmt_MolSys - tmp_item = string_pdb_text_to_molsysmt_MolSys(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return string_pdb_text_to_molsysmt_MolSys(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_molsysmt_Topology(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.string_pdb_text import to_molsysmt_Topology as string_pdb_text_to_molsysmt_Topology - tmp_item = string_pdb_text_to_molsysmt_Topology(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return string_pdb_text_to_molsysmt_Topology(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_molsysmt_Structures(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.string_pdb_text import to_molsysmt_Structures as string_pdb_text_to_molsysmt_Structures - tmp_item = string_pdb_text_to_molsysmt_Structures(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return string_pdb_text_to_molsysmt_Structures(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_mdtraj_Topology(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.string_pdb_text import to_mdtraj_Topology as string_pdb_text_to_mdtraj_Topology - tmp_item = string_pdb_text_to_mdtraj_Topology(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return string_pdb_text_to_mdtraj_Topology(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_mdtraj_Trajectory(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.string_pdb_text import to_mdtraj_Trajectory as string_pdb_text_to_mdtraj_Trajectory - tmp_item = string_pdb_text_to_mdtraj_Trajectory(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return string_pdb_text_to_mdtraj_Trajectory(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_openmm_Topology(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.string_pdb_text import to_openmm_Topology as string_pdb_text_to_openmm_Topology - tmp_item = string_pdb_text_to_openmm_Topology(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return string_pdb_text_to_openmm_Topology(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_openmm_Modeller(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.string_pdb_text import to_openmm_Topology as string_pdb_text_to_openmm_Topology - tmp_item = string_pdb_text_to_openmm_Topology(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return string_pdb_text_to_openmm_Topology(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_openmm_System(item, molecular_system, atom_indices='all', structure_indices='all', forcefield=None, non_bonded_method='no_cutoff', non_bonded_cutoff='1.0 nm', constraints=None, rigid_water=True, remove_cm_motion=True, hydrogen_mass=None, switch_distance=None, flexible_constraints=False): - from molsysmt.item.string_pdb_text import to_openmm_System as string_pdb_text_to_openmm_System - tmp_item = string_pdb_text_to_openmm_System(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return string_pdb_text_to_openmm_System(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_openmm_Simulation(item, molecular_system, atom_indices='all', structure_indices='all', forcefield=None, non_bonded_method='no_cutoff', non_bonded_cutoff=None, constraints=None, rigid_water=True, remove_cm_motion=True, hydrogen_mass=None, switch_distance=None, flexible_constraints=False, integrator='Langevin', temperature='300.0 K', collisions_rate='1.0 1/ps', integration_timestep='2.0 fs', platform='CUDA'): - from molsysmt.item.string_pdb_text import to_openmm_System as string_pdb_text_to_openmm_System - tmp_item = string_pdb_text_to_openmm_Simulation(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return string_pdb_text_to_openmm_Simulation(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_openmm_PDBFile(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.string_pdb_text import to_openmm_PDBFile as string_pdb_text_to_openmm_PDBFile - tmp_item = string_pdb_text_to_openmm_PDBFile(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return string_pdb_text_to_openmm_PDBFile(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_pdbfixer_PDBFixer(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.string_pdb_text import to_pdbfixer_PDBFixer as string_pdb_text_to_pdbfixer_PDBFixer - tmp_item = string_pdb_text_to_pdbfixer_PDBFixer(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return string_pdb_text_to_pdbfixer_PDBFixer(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_nglview_NGLWidget(item, molecular_system, atom_indices='all', structure_indices='all'): - from molsysmt.item.string_pdb_text import to_nglview_NGLWidget as string_pdb_text_to_nglview_NGLWidget - tmp_item = string_pdb_text_to_nglview_NGLWidget(item, atom_indices=atom_indices, structure_indices=structure_indices, check=False) + return string_pdb_text_to_nglview_NGLWidget(item, atom_indices=atom_indices, structure_indices=structure_indices, + check=False) - return tmp_item def to_file_pdb(item, molecular_system, atom_indices='all', structure_indices='all', output_filename=None): - from molsysmt.item.string_pdb_text import to_file_pdb as string_pdb_text_to_file_pdb - tmp_item = string_pdb_text_to_file_pdb(item, atom_indices=atom_indices, structure_indices=structure_indices, - output_filename=output_filename, check=False) - - return tmp_item - + return string_pdb_text_to_file_pdb(item, atom_indices=atom_indices, structure_indices=structure_indices, + output_filename=output_filename, check=False) diff --git a/molsysmt/api_forms/form_attributes.py b/molsysmt/api_forms/form_attributes.py new file mode 100644 index 000000000..8a344e741 --- /dev/null +++ b/molsysmt/api_forms/form_attributes.py @@ -0,0 +1,58 @@ +def form_attributes(): + """ Returns a dictionary with the attributes of each form. + This is a template dictionary in which each attribute + is set to false by default. + + For each form the attributes that are present must be + set to true. + """ + return { + 'atom_index': False, + 'atom_id': False, + 'atom_name': False, + 'atom_type': False, + + 'bond_index': False, + 'bond_id': False, + 'bond_name': False, + 'bond_type': False, + 'bond_order': False, + + 'group_index': False, + 'group_id': False, + 'group_name': False, + 'group_type': False, + + 'component_index': False, + 'component_id': False, + 'component_name': False, + 'component_type': False, + + 'molecule_index': False, + 'molecule_id': False, + 'molecule_name': False, + 'molecule_type': False, + + 'chain_index': False, + 'chain_id': False, + 'chain_name': False, + 'chain_type': False, + + 'entity_index': False, + 'entity_id': False, + 'entity_name': False, + 'entity_type': False, + + 'coordinates': False, + 'velocities': False, + 'box': False, + 'time': False, + 'step': False, + + 'forcefield': False, + 'temperature': False, + 'pressure': False, + 'integrator': False, + 'damping': False, + + } diff --git a/molsysmt/basic/convert.py b/molsysmt/basic/convert.py index f6c6467b5..1efed9a92 100644 --- a/molsysmt/basic/convert.py +++ b/molsysmt/basic/convert.py @@ -3,6 +3,7 @@ from molsysmt._private.lists_and_tuples import is_list_or_tuple from molsysmt._private.selection import selection_is_all + def convert(molecular_system, to_form='molsysmt.MolSys', selection='all', structure_indices='all', syntaxis='MolSysMT', check=True, **kwargs): @@ -16,7 +17,7 @@ def convert(molecular_system, to_form='molsysmt.MolSys', selection='all', struct Parameters ---------- - item: molecular model + molecular_system: molecular model Molecular model in any supported form by MolSysMT (see: XXX). selection: str, list, tuple or np.ndarray, defaul='all' @@ -110,16 +111,22 @@ def convert(molecular_system, to_form='molsysmt.MolSys', selection='all', struct for item in molecular_system: - from_form=get_form(item) + from_form = get_form(item) - if (from_form==to_form): - tmp_item = dict_extract[from_form](item, atom_indices=atom_indices, structure_indices=structure_indices, - copy_if_all=False, check=False) + if from_form == to_form: + tmp_item = dict_extract[from_form](item, + atom_indices=atom_indices, + structure_indices=structure_indices, + copy_if_all=False, + check=False) else: if from_form in dict_convert: if to_form in dict_convert[from_form]: - tmp_item = dict_convert[from_form][to_form](item, molecular_system=molecular_system, atom_indices=atom_indices, - structure_indices=structure_indices, **conversion_arguments, **kwargs) + tmp_item = dict_convert[from_form][to_form](item, + molecular_system=molecular_system, + atom_indices=atom_indices, + structure_indices=structure_indices, + **conversion_arguments, **kwargs) if tmp_item is not None: break @@ -132,4 +139,3 @@ def convert(molecular_system, to_form='molsysmt.MolSys', selection='all', struct tmp_item = digest_output(tmp_item) return tmp_item - diff --git a/molsysmt/basic/get.py b/molsysmt/basic/get.py index 6141c275b..b08b4a11c 100644 --- a/molsysmt/basic/get.py +++ b/molsysmt/basic/get.py @@ -1,11 +1,13 @@ -from molsysmt._private.exceptions import * -from molsysmt._private.digestion import * +from molsysmt._private.exceptions import MolecularSystemNeededError +from molsysmt._private.digestion import (digest_element, digest_indices, digest_selection, + digest_syntaxis, digest_structure_indices, + digest_output, digest_argument) from molsysmt._private.lists_and_tuples import is_list_or_tuple -from molsysmt.attribute.attributes import _required_indices, attribute_synonyms, attributes +from molsysmt.attribute.attributes import _required_indices + def get(molecular_system, element='system', indices=None, selection='all', structure_indices='all', syntaxis='MolSysMT', check=True, **kwargs): - """get(item, element='system', indices=None, selection='all', structure_indices='all', syntaxis='MolSysMT') Get specific attributes and observables. @@ -15,7 +17,7 @@ def get(molecular_system, element='system', indices=None, selection='all', struc Parameters ---------- - item: molecular model + molecular_system: molecular model Molecular model in any of the supported forms by MolSysMT. (See: XXX) element: str, default='system' @@ -38,9 +40,9 @@ def get(molecular_system, element='system', indices=None, selection='all', struc Returns ------- - None - The method prints out a pandas dataframe with relevant information depending on the element - chosen. + Attributes + Returns the specified attribute. If more than one attribute is selected, it returns a list + with all the specified attributes. Examples -------- @@ -63,38 +65,16 @@ def get(molecular_system, element='system', indices=None, selection='all', struc if not is_molecular_system(molecular_system): raise MolecularSystemNeededError() - try: - element = digest_element(element) - except: - raise WrongTargetError(element) - - try: - syntaxis = digest_syntaxis(syntaxis) - except: - raise WrongSyntaxisError(syntaxis) - - try: - selection = digest_selection(selection) - except: - raise WrongSelectionError(selection) - - try: - indices = digest_indices(indices) - except: - raise WrongIndicesError() - - try: - structure_indices = digest_structure_indices(structure_indices) - except: - raise WrongStructureIndicesError() + element = digest_element(element) + syntaxis = digest_syntaxis(syntaxis) + selection = digest_selection(selection) + indices = digest_indices(indices) + structure_indices = digest_structure_indices(structure_indices) arguments = [] for key in kwargs.keys(): if kwargs[key]: - try: - arguments.append(_digest_argument(key, element)) - except: - raise WrongGetArgumentError(key) + arguments.append(digest_argument(key, element)) else: @@ -103,28 +83,25 @@ def get(molecular_system, element='system', indices=None, selection='all', struc if kwargs[key]: arguments.append(key) - if not is_list_or_tuple(molecular_system): molecular_system = [molecular_system] - forms_in = get_form(molecular_system) - if indices is None: if selection is not 'all': indices = select(molecular_system, element=element, selection=selection, syntaxis=syntaxis, check=False) else: indices = 'all' - output = [] + attributes = [] for argument in arguments: dict_indices = {} if element != 'system': if 'indices' in _required_indices[argument]: - dict_indices['indices']=indices + dict_indices['indices'] = indices if 'structure_indices' in _required_indices[argument]: - dict_indices['structure_indices']=structure_indices + dict_indices['structure_indices'] = structure_indices aux_item, aux_form = where_is_attribute(molecular_system, argument, check=False) @@ -133,21 +110,6 @@ def get(molecular_system, element='system', indices=None, selection='all', struc else: result = dict_get[aux_form][element][argument](aux_item, **dict_indices) - output.append(result) - - output=digest_output(output) - - return output - -def _digest_argument(argument, element): - - output_argument = argument.lower() - if output_argument in ['index', 'indices', 'name', 'names', 'id', 'ids', 'type', 'types', 'order']: - output_argument = ('_').join([element, output_argument]) - if output_argument in attribute_synonyms: - output_argument = attribute_synonyms[output_argument] - if output_argument in attributes: - return output_argument - else: - raise WrongGetArgumentError() + attributes.append(result) + return digest_output(attributes) diff --git a/molsysmt/basic/set.py b/molsysmt/basic/set.py index 039aaff41..0168ae0a3 100644 --- a/molsysmt/basic/set.py +++ b/molsysmt/basic/set.py @@ -1,8 +1,9 @@ -from molsysmt._private.exceptions import * from molsysmt._private.digestion import * -from molsysmt.attribute.attributes import _required_indices, attribute_synonyms, attributes -def set(molecular_system, element='system', indices=None, selection='all', structure_indices='all', syntaxis='MolSysMT', check=True, **kwargs): + +def set(molecular_system, + element='system', indices=None, selection='all', + structure_indices='all', syntaxis='MolSysMT', check=True, **kwargs): """into(item, element='system', indices=None, selection='all', structure_indices='all', syntaxis='MolSysMT') @@ -13,7 +14,7 @@ def set(molecular_system, element='system', indices=None, selection='all', struc Parameters ---------- - item: molecular model + molecular_system: molecular model Molecular model in any of the supported forms by MolSysMT. (See: XXX) element: str, default='system' @@ -25,7 +26,7 @@ def set(molecular_system, element='system', indices=None, selection='all', struc method is going to work with. The set of indices can be given by a list, tuple or numpy array of integers (0-based). - selection: str, list, tuple or np.ndarray, defaul='all' + selection: str, list, tuple or np.ndarray, default='all' Atoms selection over which this method applies. The selection can be given by a list, tuple or numpy array of integers (0-based), or by means of a string following any of the selection syntaxis parsable by MolSysMT (see: :func:`molsysmt.select`). @@ -63,39 +64,17 @@ def set(molecular_system, element='system', indices=None, selection='all', struc if check: if not is_molecular_system(molecular_system): - raise MolecularSystemNeeded() - - try: - element = digest_element(element) - except: - raise WrongTargetError(element) - - try: - syntaxis = digest_syntaxis(syntaxis) - except: - raise WrongSyntaxisError(syntaxis) - - try: - selection = digest_selection(selection, syntaxis) - except: - raise WrongSelectionError(selection) - - try: - indices = digest_indices(indices) - except: - raise WrongIndicesError() + raise TypeError("A molecular system is needed.") - try: - structure_indices = digest_structure_indices(structure_indices) - except: - raise WrongStructureIndicesError() + element = digest_element(element) + syntaxis = digest_syntaxis(syntaxis) + selection = digest_selection(selection, syntaxis) + indices = digest_indices(indices) + structure_indices = digest_structure_indices(structure_indices) value_of_attribute = {} for key in kwargs.keys(): - try: - value_of_attribute[_digest_argument(key, element)]=kwargs[key] - except: - raise WrongSetArgumentError(key) + value_of_attribute[digest_argument(key, element)]=kwargs[key] else: @@ -110,7 +89,7 @@ def set(molecular_system, element='system', indices=None, selection='all', struc # doing the work here if indices is None: - if selection is not 'all': + if selection != 'all': indices = select(molecular_system, element=element, selection=selection, syntaxis=syntaxis, check=False) else: @@ -122,18 +101,3 @@ def set(molecular_system, element='system', indices=None, selection='all', struc value = value_of_attribute[attribute] dict_set[form][element][attribute](item, indices=indices, structure_indices=structure_indices, value=value) - - pass - -def _digest_argument(argument, element): - - output_argument = argument.lower() - if output_argument in ['index', 'indices', 'name', 'names', 'id', 'ids', 'type', 'types', 'order']: - output_argument = ('_').join([element, output_argument]) - if output_argument in attribute_synonyms: - output_argument = attribute_synonyms[output_argument] - if output_argument in attributes: - return output_argument - else: - raise WrongGetArgumentError() - diff --git a/molsysmt/item/biopython_Seq/is_biopython_Seq.py b/molsysmt/item/biopython_Seq/is_biopython_Seq.py index 2859761cc..e84f27b03 100644 --- a/molsysmt/item/biopython_Seq/is_biopython_Seq.py +++ b/molsysmt/item/biopython_Seq/is_biopython_Seq.py @@ -2,7 +2,4 @@ def is_biopython_Seq(item): item_fullname = item.__class__.__module__+'.'+item.__class__.__name__ - output = (item_fullname == 'biopython.Seq') - - return output - + return item_fullname == 'biopython.Seq' diff --git a/molsysmt/item/file_mmtf/to_mdtraj.py b/molsysmt/item/file_mmtf/to_mdtraj.py index fe093ce21..e4d9a2092 100644 --- a/molsysmt/item/file_mmtf/to_mdtraj.py +++ b/molsysmt/item/file_mmtf/to_mdtraj.py @@ -132,8 +132,7 @@ def __init__(self, filename, mode='r', force_overwrite=True): self._open = False self._frame_index = 0 self._filepath = filename - try: - self.n_atoms, self.topology = self._read_topology() + self.n_atoms, self.topology = self._read_topology() elif mode == 'w': #self._open = True #if os.path.exists(filename) and not force_overwrite: @@ -300,17 +299,17 @@ def _read_topology(self): - for chain_index in transform_list['chainIndexList']: + for chain_index in transform_list['chainIndexList']: - chain = topology.add_chain() - residue = None - atomReplacements = {} + chain = topology.add_chain() + residue = None + atomReplacements = {} for atom_index in range(n_atoms): thisatomnum = mmtf_decoder.atom_id_list[atom_index] - thisatomname = - thisresnum= - thisresname= + # thisatomname = + # thisresnum= + # thisresname= for ln, line in enumerate(self._file): if ln == 1: diff --git a/molsysmt/item/has_attribute.py b/molsysmt/item/has_attribute.py deleted file mode 100644 index 6bef5c9ee..000000000 --- a/molsysmt/item/has_attribute.py +++ /dev/null @@ -1,25 +0,0 @@ -from molsysmt._private.lists_and_tuples import is_list_or_tuple - -def has_attribute(item, attribute, check=True): - - if check: - - from molsysmt.tools.item import is_item - from molsysmt.tools.attribute import is_attribute - - if not is_item(item): - raise WrongItemError(attribute) - - if not is_attribute(attribute): - raise WrongAttributeError(attribute) - - import molsysmt.tools.molecular_system import where_is_attribute - - output_item, output_form = where_is_attribute(item, attribute, check=False) - - output = False - if output_item is not None: - output = True - - return output - diff --git a/molsysmt/item/molsysmt_Topology/get.py b/molsysmt/item/molsysmt_Topology/get.py index 49bd9b3d1..f284d6424 100644 --- a/molsysmt/item/molsysmt_Topology/get.py +++ b/molsysmt/item/molsysmt_Topology/get.py @@ -284,7 +284,7 @@ def get_n_atoms_from_atom (item, indices='all', check=True): _digest_item(item, _form) indices = _digest_indices(indices) - if indices is 'all': + if indices == 'all': return get_n_atoms_from_system(item, check=False) else: return indices.shape[0] @@ -296,7 +296,7 @@ def get_n_groups_from_atom (item, indices='all', check=True): _digest_item(item, _form) indices = _digest_indices(indices) - if indices is 'all': + if indices == 'all': return get_n_groups_from_system (item, check=False) else: output = get_group_index_from_atom (item, indices=indices, check=False) @@ -310,7 +310,7 @@ def get_n_components_from_atom (item, indices='all', check=True): _digest_item(item, _form) indices = _digest_indices(indices) - if indices is 'all': + if indices == 'all': return get_n_components_from_system (item, check=False) else: output = get_component_index_from_atom (item, indices=indices, check=False) @@ -324,7 +324,7 @@ def get_n_molecules_from_atom (item, indices='all', check=True): _digest_item(item, _form) indices = _digest_indices(indices) - if indices is 'all': + if indices == 'all': return get_n_molecules_from_system (item, check=False) else: output = get_molecule_index_from_atom (item, indices=indices, check=False) @@ -338,7 +338,7 @@ def get_n_chains_from_atom (item, indices='all', check=True): _digest_item(item, _form) indices = _digest_indices(indices) - if indices is 'all': + if indices == 'all': return get_n_chains_from_system (item, check=False) else: output = get_chain_index_from_atom (item, indices=indices, check=False) @@ -352,7 +352,7 @@ def get_n_entities_from_atom (item, indices='all', check=True): _digest_item(item, _form) indices = _digest_indices(indices) - if indices is 'all': + if indices == 'all': return get_n_entities_from_system (item, check=False) else: output = get_entity_index_from_atom (item, indices=indices, check=False) diff --git a/molsysmt/item/pdbfixer_PDBFixer/extract.py b/molsysmt/item/pdbfixer_PDBFixer/extract.py index 03c28665a..83cfee96b 100644 --- a/molsysmt/item/pdbfixer_PDBFixer/extract.py +++ b/molsysmt/item/pdbfixer_PDBFixer/extract.py @@ -1,4 +1,4 @@ -from molsysmt._private.digestion import digest_item, atom_indices, structure_indices +from molsysmt._private.digestion import digest_item, digest_atom_indices, digest_structure_indices def extract(item, atom_indices='all', structure_indices='all', copy_if_all=True, check=True): @@ -27,4 +27,3 @@ def extract(item, atom_indices='all', structure_indices='all', copy_if_all=True, tmp_item = openmm_Topology_to_pdbfixer_PDBFixer(tmp_item, coordinates=coordinates, box=box, check=False) return tmp_item - diff --git a/molsysmt/native/molsys.py b/molsysmt/native/molsys.py index 24958f325..c467d0bf4 100644 --- a/molsysmt/native/molsys.py +++ b/molsysmt/native/molsys.py @@ -1,4 +1,4 @@ -class MolSys(): +class MolSys: def __init__(self): diff --git a/molsysmt/pbc/box_vectors_from_box_lengths_and_angles.py b/molsysmt/pbc/box_vectors_from_box_lengths_and_angles.py index da6a182c9..1150e10ab 100644 --- a/molsysmt/pbc/box_vectors_from_box_lengths_and_angles.py +++ b/molsysmt/pbc/box_vectors_from_box_lengths_and_angles.py @@ -1,19 +1,19 @@ -from molsysmt._private.exceptions import * -from molsysmt._private.digestion import * +from molsysmt._private.digestion import digest_box_vectors from molsysmt.lib import box as libbox import numpy as np from molsysmt import puw + def box_vectors_from_box_lengths_and_angles(lengths, angles): - lengths=digest_box_lengths(lengths) - angles=digest_box_angles(angles) + lengths = digest_box_vectors(lengths) + angles = digest_box_vectors(angles) units = puw.get_unit(lengths) lengths_value = puw.get_value(lengths) angles_value = puw.get_value(angles, to_unit='degrees') - lengths_value = np.asfortranarray(lengths_value, dtype='float64') - angles_value = np.asfortranarray(angles_value, dtype='float64') + lengths_value = np.asfortranarray(lengths_value, dtype='float64') + angles_value = np.asfortranarray(angles_value, dtype='float64') n_structures = lengths.shape[0] box = libbox.lengths_and_angles_to_box(lengths_value, angles_value, n_structures) diff --git a/molsysmt/tests/digest/test_digest.py b/molsysmt/tests/digest/test_digest.py new file mode 100644 index 000000000..92d67679f --- /dev/null +++ b/molsysmt/tests/digest/test_digest.py @@ -0,0 +1,173 @@ +# Tests for digestion functions +from molsysmt._private.exceptions import IncorrectShapeError, WrongEngineError, WrongElementError +from molsysmt._private.exceptions import WrongFormError, WrongIndicesError +from molsysmt._private.digestion.box import digest_box_vectors, digest_box_vectors_value +from molsysmt._private.digestion import digest_element, digest_engine, digest_form +from molsysmt._private.digestion import digest_indices +from molsysmt import puw +import pytest +import numpy as np + + +# Tests for digest box # + +def test_digest_box_vectors_value_with_list_and_tuple(): + lengths_list = [1, 2, 3] + lengths_expected = np.array([[1, 2, 3]]) + lengths_digested = digest_box_vectors_value(lengths_list) + assert np.all(lengths_digested == lengths_expected) + + lengths_tuple = (1, 2, 3) + lengths_digested = digest_box_vectors_value(lengths_tuple) + assert np.all(lengths_digested == lengths_expected) + + +def test_digest_box_vectors_value_with_array(): + length_array_1 = np.array([1, 2, 3]) + lengths_expected = np.array([[1, 2, 3]]) + lengths_digested = digest_box_vectors_value(length_array_1) + assert lengths_digested.shape == (1, 3) + assert np.all(lengths_digested == lengths_expected) + + length_array_2 = np.array([[1, 2, 3], + [4, 5, 6]]) + lengths_digested = digest_box_vectors_value(length_array_2) + assert lengths_digested.shape == (2, 3) + assert np.all(lengths_digested == length_array_2) + + +def test_digest_box_vectors_value_incorrect_shape_raises_error(): + lengths_list = [1, 2, 3, 4] + lengths_tuple = (1, 2, 3, 4) + + with pytest.raises(IncorrectShapeError): + digest_box_vectors_value(lengths_list) + + with pytest.raises(IncorrectShapeError): + digest_box_vectors_value(lengths_tuple) + + length_array_1 = np.array([1, 2, 3, 4]) + length_array_2 = np.array([[1], + [2], + [3], ]) + length_array_3 = np.array([[[1, 2, 3]]]) + + with pytest.raises(IncorrectShapeError): + digest_box_vectors_value(length_array_1) + with pytest.raises(IncorrectShapeError): + digest_box_vectors_value(length_array_2) + with pytest.raises(IncorrectShapeError): + digest_box_vectors_value(length_array_3) + + +def test_digest_box_vectors(): + + lengths = puw.quantity([1, 2, 3], "meters") + lengths_digested = digest_box_vectors(lengths) + assert puw.get_value(lengths_digested).shape == (1, 3) + assert np.all(puw.get_value(lengths_digested) == np.array([[1, 2, 3]])) + assert puw.get_unit(lengths_digested) == "meter" + +# Tests for digest element # + + +def test_digest_element(): + element = "ATOM" + assert digest_element(element) == "atom" + + element = "residues" + assert digest_element(element) == "group" + + +def test_digest_element_raises_error(): + + element = "cow" + with pytest.raises(WrongElementError): + digest_element(element) + + element = 20 + with pytest.raises(WrongElementError): + digest_element(element) + +# Tests for digest engine # + + +def test_digest_engine_invalid_name_raises_error(): + engine = "cow" + with pytest.raises(WrongEngineError): + digest_engine(engine) + + +def test_digest_engine_incorrect_type_raises_error(): + engine = [20, 10] + with pytest.raises(WrongEngineError): + digest_engine(engine) + + +def test_digest_engine(): + engine = "openmm" + assert digest_engine(engine) == "OpenMM" + + +# Tests for digest form +def test_digest_form(): + + form = "biopython.seq" + assert digest_form(form) == "biopython.Seq" + + forms = ["file:pdb", "openmm.system"] + assert digest_form(forms) == ["file:pdb", "openmm.System"] + + +def test_digest_form_invalid_form_name(): + + form = "cow" + with pytest.raises(WrongFormError): + digest_form(form) + + +# Tests for digest indices + + +def test_digest_indices_all(): + indices = "ALL" + assert digest_indices(indices) == "all" + + +def test_digest_indices_single_number(): + indices = 5 + assert np.all(digest_indices(indices) == np.array([5])) + + +def test_digest_indices_iterable(): + + indices = [1, 2, 3] + assert np.all(indices == np.array([1, 2, 3])) + + indices = (1, 2, 3) + assert np.all(indices == np.array([1, 2, 3])) + + indices = np.array([1, 2, 3]) + assert np.all(indices == np.array([1, 2, 3])) + + +def test_indices_incorrect_value(): + + indices = "everything" + with pytest.raises(WrongIndicesError): + digest_indices(indices) + + indices = 5.5 + with pytest.raises(WrongIndicesError): + digest_indices(indices) + + indices = puw.quantity([2, 3], "meter") + with pytest.raises(WrongIndicesError): + digest_indices(indices) + +# Test for digest item + + +def test_digest_item(): + pass + diff --git a/molsysmt/tests/exceptions/test_not_implemeted_error.py b/molsysmt/tests/exceptions/test_not_implemeted_error.py new file mode 100644 index 000000000..9e5f5e26f --- /dev/null +++ b/molsysmt/tests/exceptions/test_not_implemeted_error.py @@ -0,0 +1,17 @@ +from molsysmt._private.exceptions.not_implemented_errors import MolSysNotImplementedError +import pytest + +def raise_error(error): + raise error + + +def test_not_implemented_error(): + with pytest.raises(MolSysNotImplementedError) as exc_info: + raise_error(MolSysNotImplementedError) + + message = ( + "The method has not been implemented yet. " + f" Check for more information. " + f"Write a new issue in https://github.com/uibcdf/MolSysMT/issues asking for its implementation." + ) + assert message == str(exc_info.value) diff --git a/molsysmt/tests/exceptions/test_value_errors.py b/molsysmt/tests/exceptions/test_value_errors.py new file mode 100644 index 000000000..e0ff252c3 --- /dev/null +++ b/molsysmt/tests/exceptions/test_value_errors.py @@ -0,0 +1,63 @@ +import pytest +from molsysmt._private.exceptions.value_errors import * + +def raise_error(error): + raise error + + +def raise_error_with_argument(error, argument): + raise error(argument) + + +@pytest.fixture +def base_error_msg(): + return (" Check for more information. " + "If you still need help, open a new issue in https://github.com/uibcdf/MolSysMT/issues." + ) + + +def test_molsys_value_error(base_error_msg): + with pytest.raises(MolSysValueError) as exc_info: + raise_error(MolSysValueError) + assert base_error_msg == str(exc_info.value) + + +def test_raise_not_with_this_molecular_system(base_error_msg): + with pytest.raises(NotWithThisMolecularSystemError) as exc_info: + raise_error(NotWithThisMolecularSystemError) + msg = "This method can not be applied over this molecular system. " + msg += base_error_msg + assert msg == str(exc_info.value) + + +def test_multiple_molecular_systems(base_error_msg): + with pytest.raises(MultipleMolecularSystemsNeededError) as exc_info: + raise_error(MultipleMolecularSystemsNeededError) + msg = ('This method works only over a single molecular system. ' + 'But multiple molecular systems are provided. ') + msg += base_error_msg + assert msg == str(exc_info.value) + + +def test_not_supported_form(base_error_msg): + with pytest.raises(NotSupportedFormError) as exc_info: + raise_error_with_argument(NotSupportedFormError, type("hello")) + msg = "The input molecular system or item has a not supported form: " + msg += base_error_msg + assert msg == str(exc_info.value) + + +def test_not_with_this_form(base_error_msg): + with pytest.raises(NotWithThisFormError) as exc_info: + raise_error_with_argument(NotWithThisFormError, type("hello")) + msg = "Invalid form: " + msg += base_error_msg + assert msg == str(exc_info.value) + + +def test_wrong_get_argument(base_error_msg): + with pytest.raises(WrongGetArgumentError) as exc_info: + raise_error_with_argument(WrongGetArgumentError, "hello") + msg = "The get method was invoked with not valid input argument: \"hello\"" + msg += base_error_msg + assert msg == str(exc_info.value) diff --git a/molsysmt/tests/pbc/box_angles_from_box_vectors/test_box_angles_from_box_vectors.py b/molsysmt/tests/pbc/box_angles_from_box_vectors/test_box_angles_from_box_vectors.py index 06270cebd..2a787d899 100644 --- a/molsysmt/tests/pbc/box_angles_from_box_vectors/test_box_angles_from_box_vectors.py +++ b/molsysmt/tests/pbc/box_angles_from_box_vectors/test_box_angles_from_box_vectors.py @@ -2,33 +2,35 @@ Unit and regression test for the box_angles_from_box_vectors module of the molsysmt package. """ -# Import package, test suite, and other packages as needed +# Import package, test suite, and other packages as needed import molsysmt as msm import numpy as np # Distance between atoms in space and time -def test_box_angles_from_box_vectors_1(): + +def test_box_angles_from_box_vectors_cubic_geometry(): molsys = msm.convert(msm.demo['Met-enkephalin']['vacuum.msmpk'], to_form='molsysmt.MolSys') molsys = msm.build.solvate(molsys, box_geometry='cubic', clearance='14.0 angstroms', engine='PDBFixer') - box = msm.get(molsys, target='system', box=True) + box = msm.get(molsys, element='system', box=True) angles = msm.pbc.box_angles_from_box_vectors(box) check = np.allclose(msm.puw.get_value(angles, to_unit='degrees'), [[90.000001, 90.000001, 90.000001]]) assert check -def test_box_angles_from_box_vectors_2(): + +def test_box_angles_from_box_vectors_octahedral_geometry(): molsys = msm.convert(msm.demo['Met-enkephalin']['vacuum.msmpk'], to_form='molsysmt.MolSys') molsys = msm.build.solvate(molsys, box_geometry='truncated octahedral', clearance='14.0 angstroms', engine='PDBFixer') - box = msm.get(molsys, target='system', box=True) + box = msm.get(molsys, element='system', box=True) angles = msm.pbc.box_angles_from_box_vectors(box) check = np.allclose(msm.puw.get_value(angles, to_unit='degrees'), [[70.52878, 109.471221, 70.52878]]) assert check -def test_box_angles_from_box_vectors_3(): + +def test_box_angles_from_box_vectors_dodecahedral_geometry(): molsys = msm.convert(msm.demo['Met-enkephalin']['vacuum.msmpk'], to_form='molsysmt.MolSys') molsys = msm.build.solvate(molsys, box_geometry='rhombic dodecahedral', clearance='14.0 angstroms', engine='PDBFixer') - box = msm.get(molsys, target='system', box=True) + box = msm.get(molsys, element='system', box=True) angles = msm.pbc.box_angles_from_box_vectors(box) check = np.allclose(msm.puw.get_value(angles, to_unit='degrees'), [[60.0, 60.0, 90.000001]]) assert check - diff --git a/molsysmt/tests/pbc/box_lengths_from_box_vectors/test_box_lengths_from_box_vectors.py b/molsysmt/tests/pbc/box_lengths_from_box_vectors/test_box_lengths_from_box_vectors.py index be0ca882a..27a1a31ee 100644 --- a/molsysmt/tests/pbc/box_lengths_from_box_vectors/test_box_lengths_from_box_vectors.py +++ b/molsysmt/tests/pbc/box_lengths_from_box_vectors/test_box_lengths_from_box_vectors.py @@ -8,26 +8,29 @@ # Distance between atoms in space and time -def test_box_lengths_from_box_vectors_1(): + +def test_box_lengths_from_box_vectors_cubic_geometry(): molsys = msm.convert(msm.demo['Met-enkephalin']['vacuum.msmpk'], to_form='molsysmt.MolSys') molsys = msm.build.solvate(molsys, box_geometry='cubic', clearance='14.0 angstroms', engine='PDBFixer') - box = msm.get(molsys, target='system', box=True) + box = msm.get(molsys, element='system', box=True) lengths = msm.pbc.box_lengths_from_box_vectors(box) check = np.allclose(msm.puw.get_value(lengths, to_unit='nm'), [[3.1236, 3.1236, 3.1236]]) assert check -def test_box_lengths_from_box_vectors_2(): + +def test_box_lengths_from_box_vectors_octahedral_geometry(): molsys = msm.convert(msm.demo['Met-enkephalin']['vacuum.msmpk'], to_form='molsysmt.MolSys') molsys = msm.build.solvate(molsys, box_geometry='truncated octahedral', clearance='14.0 angstroms', engine='PDBFixer') - box = msm.get(molsys, target='system', box=True) + box = msm.get(molsys, element='system', box=True) lengths = msm.pbc.box_lengths_from_box_vectors(box) check = np.allclose(msm.puw.get_value(lengths, to_unit='nm'), [[3.1236, 3.1236, 3.1236]]) assert check -def test_box_lengths_from_box_vectors_3(): + +def test_box_lengths_from_box_vectors_dodecahedral_geometry(): molsys = msm.convert(msm.demo['Met-enkephalin']['vacuum.msmpk'], to_form='molsysmt.MolSys') molsys = msm.build.solvate(molsys, box_geometry='rhombic dodecahedral', clearance='14.0 angstroms', engine='PDBFixer') - box = msm.get(molsys, target='system', box=True) + box = msm.get(molsys, element='system', box=True) lengths = msm.pbc.box_lengths_from_box_vectors(box) check = np.allclose(msm.puw.get_value(lengths, to_unit='nm'), [[3.1236, 3.1236, 3.1236]]) assert check diff --git a/molsysmt/tests/pbc/box_shape_from_box_vectors/test_box_shape_from_box_vectors.py b/molsysmt/tests/pbc/box_shape_from_box_vectors/test_box_shape_from_box_vectors.py index 101bbdfa9..216f56827 100644 --- a/molsysmt/tests/pbc/box_shape_from_box_vectors/test_box_shape_from_box_vectors.py +++ b/molsysmt/tests/pbc/box_shape_from_box_vectors/test_box_shape_from_box_vectors.py @@ -8,24 +8,27 @@ # Distance between atoms in space and time -def test_box_shape_from_box_vectors_1(): + +def test_box_shape_from_box_vectors_cubic_geometry(): molsys = msm.convert(msm.demo['Met-enkephalin']['vacuum.msmpk'], to_form='molsysmt.MolSys') molsys = msm.build.solvate(molsys, box_geometry='cubic', clearance='14.0 angstroms', engine='PDBFixer') - box = msm.get(molsys, target='system', box=True) + box = msm.get(molsys, element='system', box=True) shape = msm.pbc.box_shape_from_box_vectors(box) assert (shape == 'cubic') -def test_box_shape_from_box_vectors_2(): + +def test_box_shape_from_box_vectors_octahedral_geometry(): molsys = msm.convert(msm.demo['Met-enkephalin']['vacuum.msmpk'], to_form='molsysmt.MolSys') molsys = msm.build.solvate(molsys, box_geometry='truncated octahedral', clearance='14.0 angstroms', engine='PDBFixer') - box = msm.get(molsys, target='system', box=True) + box = msm.get(molsys, element='system', box=True) shape = msm.pbc.box_shape_from_box_vectors(box) assert (shape == 'truncated octahedral') -def test_box_shape_from_box_vectors_3(): + +def test_box_shape_from_box_vectors_dodecahedral_geometry(): molsys = msm.convert(msm.demo['Met-enkephalin']['vacuum.msmpk'], to_form='molsysmt.MolSys') molsys = msm.build.solvate(molsys, box_geometry='rhombic dodecahedral', clearance='14.0 angstroms', engine='PDBFixer') - box = msm.get(molsys, target='system', box=True) + box = msm.get(molsys, element='system', box=True) shape = msm.pbc.box_shape_from_box_vectors(box) assert (shape == 'rhombic dodecahedral') diff --git a/molsysmt/tests/pbc/box_volumen_from_box_vectors/test_box_volume_from_box_vectors.py b/molsysmt/tests/pbc/box_volumen_from_box_vectors/test_box_volume_from_box_vectors.py index d7f34c57c..4ef31e205 100644 --- a/molsysmt/tests/pbc/box_volumen_from_box_vectors/test_box_volume_from_box_vectors.py +++ b/molsysmt/tests/pbc/box_volumen_from_box_vectors/test_box_volume_from_box_vectors.py @@ -8,27 +8,29 @@ # Distance between atoms in space and time -def test_box_volume_from_box_vectors_1(): + +def test_box_volume_from_box_vectors_cubic_geometry(): molsys = msm.convert(msm.demo['Met-enkephalin']['vacuum.msmpk'], to_form='molsysmt.MolSys') molsys = msm.build.solvate(molsys, box_geometry='cubic', clearance='14.0 angstroms', engine='PDBFixer') - box = msm.get(molsys, target='system', box=True) + box = msm.get(molsys, element='system', box=True) volume = msm.pbc.box_volume_from_box_vectors(box) check = np.allclose(msm.puw.get_value(volume, to_unit='nm**3'), [30.4765808]) assert check -def test_box_volume_from_box_vectors_2(): + +def test_box_volume_from_box_vectors_octahedral_geometry(): molsys = msm.convert(msm.demo['Met-enkephalin']['vacuum.msmpk'], to_form='molsysmt.MolSys') molsys = msm.build.solvate(molsys, box_geometry='truncated octahedral', clearance='14.0 angstroms', engine='PDBFixer') - box = msm.get(molsys, target='system', box=True) + box = msm.get(molsys, element='system', box=True) volume = msm.pbc.box_volume_from_box_vectors(box) check = np.allclose(msm.puw.get_value(volume, to_unit='nm**3'), [23.4608828]) assert check -def test_box_volume_from_box_vectors_3(): + +def test_box_volume_from_box_vectors_dodecahedral_geometry(): molsys = msm.convert(msm.demo['Met-enkephalin']['vacuum.msmpk'], to_form='molsysmt.MolSys') molsys = msm.build.solvate(molsys, box_geometry='rhombic dodecahedral', clearance='14.0 angstroms', engine='PDBFixer') - box = msm.get(molsys, target='system', box=True) + box = msm.get(molsys, element='system', box=True) volume = msm.pbc.box_volume_from_box_vectors(box) check = np.allclose(msm.puw.get_value(volume, to_unit='nm**3'), [21.5501970]) assert check - diff --git a/molsysmt/tests/pbc/unwrap/test_unwrap_molsysmt_TrajectoryDict.py b/molsysmt/tests/pbc/unwrap/test_unwrap_molsysmt_TrajectoryDict.py index ce6f61b28..fa9ab0923 100644 --- a/molsysmt/tests/pbc/unwrap/test_unwrap_molsysmt_TrajectoryDict.py +++ b/molsysmt/tests/pbc/unwrap/test_unwrap_molsysmt_TrajectoryDict.py @@ -9,15 +9,17 @@ # Distance between atoms in space and time -def test_unwrap_molsysmt_TrajectoryDict_1(): - molsys = msm.convert(msm.demo['two LJ particles']['traj.trjpk'], to_form='molsysmt.TrajectoryDict') - molsys_wrapped = msm.pbc.wrap_to_pbc(molsys) - molsys_unwrapped = msm.pbc.unwrap(molsys_wrapped) - box_length = msm.get(molsys_wrapped, target='system', box_lengths=True)[0,0] - check_limits_wrapped = ( box_length >= (np.max(molsys_wrapped['coordinates']) - np.min(molsys_wrapped['coordinates']))) - check_limits = ( box_length <= (np.max(molsys['coordinates']) - np.min(molsys['coordinates']))) - check_limits_unwrapped = ( box_length <= (np.max(molsys_unwrapped['coordinates']) - np.min(molsys['coordinates']))) - check = np.allclose(molsys_unwrapped['coordinates'][:,:,:], molsys['coordinates'][:,:,:]) - assert check_limits and check_limits_unwrapped and check_limits_wrapped and check +# TODO: This test does work because TrajectoryDict was moved to Freezer. While that gets +# fixed the test will be commented +# def test_unwrap_molsysmt_TrajectoryDict_1(): +# molsys = msm.convert(msm.demo['two LJ particles']['traj.trjpk'], to_form='molsysmt.TrajectoryDict') +# molsys_wrapped = msm.pbc.wrap_to_pbc(molsys) +# molsys_unwrapped = msm.pbc.unwrap(molsys_wrapped) +# box_length = msm.get(molsys_wrapped, element='system', box_lengths=True)[0,0] +# check_limits_wrapped = ( box_length >= (np.max(molsys_wrapped['coordinates']) - np.min(molsys_wrapped['coordinates']))) +# check_limits = ( box_length <= (np.max(molsys['coordinates']) - np.min(molsys['coordinates']))) +# check_limits_unwrapped = ( box_length <= (np.max(molsys_unwrapped['coordinates']) - np.min(molsys['coordinates']))) +# check = np.allclose(molsys_unwrapped['coordinates'][:,:,:], molsys['coordinates'][:,:,:]) +# assert check_limits and check_limits_unwrapped and check_limits_wrapped and check diff --git a/molsysmt/tests/pbc/wrap_to_mic/test_wrap_to_mic_molsysmt_MolSys.py b/molsysmt/tests/pbc/wrap_to_mic/test_wrap_to_mic_molsysmt_MolSys.py index 0d629919a..50c2f0a2a 100644 --- a/molsysmt/tests/pbc/wrap_to_mic/test_wrap_to_mic_molsysmt_MolSys.py +++ b/molsysmt/tests/pbc/wrap_to_mic/test_wrap_to_mic_molsysmt_MolSys.py @@ -9,14 +9,13 @@ # Distance between atoms in space and time + def test_wrap_to_pbc_molsysmt_MolSys_1(): molsys = msm.convert(msm.demo['chicken villin HP35']['solvated.msmpk'], to_form='molsysmt.MolSys') molsys = msm.pbc.wrap_to_mic(molsys, center_of_selection='molecule_type=="peptide"') - lengths = msm.get(molsys, target='system', box_lengths=True) + lengths = msm.get(molsys, element='system', box_lengths=True) distances = msm.structure.get_distances(molsys, molecular_system_2=[[0.0, 0.0, 0.0]]*msm.puw.unit('nm'), pbc=False) max_dist_cube = np.sqrt(3.0*(lengths[0,0]/2.0)**2) max_dist = np.max(distances) check = (max_dist < max_dist_cube) assert check - - diff --git a/molsysmt/tests/pbc/wrap_to_pbc/test_wrap_to_pbc_molsysmt_MolSys.py b/molsysmt/tests/pbc/wrap_to_pbc/test_wrap_to_pbc_molsysmt_MolSys.py index c8e7d9901..77257c851 100644 --- a/molsysmt/tests/pbc/wrap_to_pbc/test_wrap_to_pbc_molsysmt_MolSys.py +++ b/molsysmt/tests/pbc/wrap_to_pbc/test_wrap_to_pbc_molsysmt_MolSys.py @@ -9,14 +9,13 @@ # Distance between atoms in space and time + def test_wrap_to_pbc_molsysmt_MolSys_1(): molsys = msm.convert(msm.demo['chicken villin HP35']['solvated.msmpk'], to_form='molsysmt.MolSys') molsys = msm.pbc.wrap_to_pbc(molsys, center_of_selection='molecule_type=="peptide"') - lengths = msm.get(molsys, target='system', box_lengths=True) + lengths = msm.get(molsys, element='system', box_lengths=True) distances = msm.structure.get_distances(molsys, molecular_system_2=[[0.0, 0.0, 0.0]]*msm.puw.unit('nm'), pbc=False) max_dist_cube = np.sqrt(3.0*(lengths[0,0]/2.0)**2) max_dist = np.max(distances) check = (max_dist > max_dist_cube) assert check - - diff --git a/molsysmt/tests/pbc/wrap_to_pbc/test_wrap_to_pbc_molsysmt_TrajectoryDict.py b/molsysmt/tests/pbc/wrap_to_pbc/test_wrap_to_pbc_molsysmt_TrajectoryDict.py index ee5084820..c2103dc1d 100644 --- a/molsysmt/tests/pbc/wrap_to_pbc/test_wrap_to_pbc_molsysmt_TrajectoryDict.py +++ b/molsysmt/tests/pbc/wrap_to_pbc/test_wrap_to_pbc_molsysmt_TrajectoryDict.py @@ -9,15 +9,15 @@ # Distance between atoms in space and time -def test_wrap_to_pbc_molsysmt_TrajectoryDict_1(): - molsys = msm.convert(msm.demo['two LJ particles']['traj.trjpk'], to_form='molsysmt.TrajectoryDict') - distance = msm.structure.get_distances(molsys, selection=0, selection_2=1, pbc=True) - molsys_wrapped = msm.pbc.wrap_to_pbc(molsys) - distance_wrapped = msm.structure.get_distances(molsys_wrapped, selection=0, selection_2=1, pbc=True) - check_distances = np.allclose(distance[:,:,:], distance_wrapped[:,:,:]) - box_length = msm.get(molsys_wrapped, target='system', box_lengths=True)[0,0] - check_limits_wrapped = ( box_length >= (np.max(molsys_wrapped['coordinates']) - np.min(molsys_wrapped['coordinates']))) - check_limits = ( box_length <= (np.max(molsys['coordinates']) - np.min(molsys['coordinates']))) - assert check_limits and check_distances and check_limits_wrapped - - +# TODO: This test does work because TrajectoryDict was moved to Freezer. While that gets +# fixed the test will be commented +# def test_wrap_to_pbc_molsysmt_TrajectoryDict_1(): +# molsys = msm.convert(msm.demo['two LJ particles']['traj.trjpk'], to_form='molsysmt.TrajectoryDict') +# distance = msm.structure.get_distances(molsys, selection=0, selection_2=1, pbc=True) +# molsys_wrapped = msm.pbc.wrap_to_pbc(molsys) +# distance_wrapped = msm.structure.get_distances(molsys_wrapped, selection=0, selection_2=1, pbc=True) +# check_distances = np.allclose(distance[:,:,:], distance_wrapped[:,:,:]) +# box_length = msm.get(molsys_wrapped, element='system', box_lengths=True)[0,0] +# check_limits_wrapped = ( box_length >= (np.max(molsys_wrapped['coordinates']) - np.min(molsys_wrapped['coordinates']))) +# check_limits = ( box_length <= (np.max(molsys['coordinates']) - np.min(molsys['coordinates']))) +# assert check_limits and check_distances and check_limits_wrapped diff --git a/sandbox/RMSD_test_pentah5.ipynb b/sandbox/RMSD_test_pentah5.ipynb index 86eab06c5..41451d541 100644 --- a/sandbox/RMSD_test_pentah5.ipynb +++ b/sandbox/RMSD_test_pentah5.ipynb @@ -3,7 +3,11 @@ { "cell_type": "code", "execution_count": 1, - "metadata": {}, + "metadata": { + "pycharm": { + "name": "#%%\n" + } + }, "outputs": [], "source": [ "%load_ext autoreload\n", @@ -13,7 +17,11 @@ { "cell_type": "code", "execution_count": 2, - "metadata": {}, + "metadata": { + "pycharm": { + "name": "#%%\n" + } + }, "outputs": [ { "data": { @@ -40,7 +48,11 @@ { "cell_type": "code", "execution_count": 3, - "metadata": {}, + "metadata": { + "pycharm": { + "name": "#%%\n" + } + }, "outputs": [], "source": [ "molecular_system = msm.convert('pentalanine.h5')" @@ -49,7 +61,11 @@ { "cell_type": "code", "execution_count": 4, - "metadata": {}, + "metadata": { + "pycharm": { + "name": "#%%\n" + } + }, "outputs": [ { "data": { @@ -84,7 +100,11 @@ { "cell_type": "code", "execution_count": 5, - "metadata": {}, + "metadata": { + "pycharm": { + "name": "#%%\n" + } + }, "outputs": [], "source": [ "time = msm.get(molecular_system, target='system', time=True)" @@ -93,7 +113,11 @@ { "cell_type": "code", "execution_count": 13, - "metadata": {}, + "metadata": { + "pycharm": { + "name": "#%%\n" + } + }, "outputs": [], "source": [ "rmsd = msm.rmsd(molecular_system, selection='backbone', frame_indices=100, reference_frame_index=0)" @@ -102,7 +126,11 @@ { "cell_type": "code", "execution_count": 14, - "metadata": {}, + "metadata": { + "pycharm": { + "name": "#%%\n" + } + }, "outputs": [ { "name": "stdout", @@ -119,7 +147,11 @@ { "cell_type": "code", "execution_count": 15, - "metadata": {}, + "metadata": { + "pycharm": { + "name": "#%%\n" + } + }, "outputs": [], "source": [ "rmsd = msm.rmsd(molecular_system, selection='backbone', frame_indices='all', reference_frame_index=0)" @@ -128,7 +160,11 @@ { "cell_type": "code", "execution_count": 16, - "metadata": {}, + "metadata": { + "pycharm": { + "name": "#%%\n" + } + }, "outputs": [ { "data": { @@ -155,7 +191,11 @@ { "cell_type": "code", "execution_count": 17, - "metadata": {}, + "metadata": { + "pycharm": { + "name": "#%%\n" + } + }, "outputs": [], "source": [ "molecular_system_1 = msm.extract(molecular_system, frame_indices=range(0,100))\n", @@ -165,7 +205,11 @@ { "cell_type": "code", "execution_count": 18, - "metadata": {}, + "metadata": { + "pycharm": { + "name": "#%%\n" + } + }, "outputs": [ { "data": { @@ -200,7 +244,11 @@ { "cell_type": "code", "execution_count": 19, - "metadata": {}, + "metadata": { + "pycharm": { + "name": "#%%\n" + } + }, "outputs": [ { "data": { @@ -235,7 +283,11 @@ { "cell_type": "code", "execution_count": 24, - "metadata": {}, + "metadata": { + "pycharm": { + "name": "#%%\n" + } + }, "outputs": [], "source": [ "rmsd = msm.rmsd(molecular_system_1, selection='backbone', frame_indices=10,\n", @@ -245,7 +297,11 @@ { "cell_type": "code", "execution_count": 25, - "metadata": {}, + "metadata": { + "pycharm": { + "name": "#%%\n" + } + }, "outputs": [ { "name": "stdout", @@ -262,7 +318,11 @@ { "cell_type": "code", "execution_count": 26, - "metadata": {}, + "metadata": { + "pycharm": { + "name": "#%%\n" + } + }, "outputs": [], "source": [ "lrmsd = msm.least_rmsd(molecular_system, selection='backbone', frame_indices='all', reference_frame_index=0)\n", @@ -272,7 +332,11 @@ { "cell_type": "code", "execution_count": 27, - "metadata": {}, + "metadata": { + "pycharm": { + "name": "#%%\n" + } + }, "outputs": [ { "data": { @@ -300,7 +364,11 @@ { "cell_type": "code", "execution_count": 28, - "metadata": {}, + "metadata": { + "pycharm": { + "name": "#%%\n" + } + }, "outputs": [], "source": [ "fitted_molecular_system = msm.least_rmsd_fit(molecular_system, selection='backbone', frame_indices='all',\n", @@ -310,7 +378,11 @@ { "cell_type": "code", "execution_count": 29, - "metadata": {}, + "metadata": { + "pycharm": { + "name": "#%%\n" + } + }, "outputs": [], "source": [ "fitted_rmsd = msm.rmsd(fitted_molecular_system, selection='backbone', frame_indices='all', reference_frame_index=0)" @@ -319,7 +391,11 @@ { "cell_type": "code", "execution_count": 30, - "metadata": {}, + "metadata": { + "pycharm": { + "name": "#%%\n" + } + }, "outputs": [ { "data": { @@ -347,7 +423,11 @@ { "cell_type": "code", "execution_count": 31, - "metadata": {}, + "metadata": { + "pycharm": { + "name": "#%%\n" + } + }, "outputs": [], "source": [ "msm.least_rmsd_fit(molecular_system, selection='backbone', frame_indices=range(2000,4000), reference_frame_index=0)" @@ -356,7 +436,11 @@ { "cell_type": "code", "execution_count": 32, - "metadata": {}, + "metadata": { + "pycharm": { + "name": "#%%\n" + } + }, "outputs": [], "source": [ "fitted_rmsd = msm.rmsd(molecular_system, selection='backbone', frame_indices='all', reference_frame_index=0)" @@ -365,7 +449,11 @@ { "cell_type": "code", "execution_count": 33, - "metadata": {}, + "metadata": { + "pycharm": { + "name": "#%%\n" + } + }, "outputs": [ { "data": { @@ -393,7 +481,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "pycharm": { + "name": "#%%\n" + } + }, "outputs": [], "source": [] } @@ -419,4 +511,4 @@ }, "nbformat": 4, "nbformat_minor": 4 -} +} \ No newline at end of file