Skip to content

Commit

Permalink
in process
Browse files Browse the repository at this point in the history
  • Loading branch information
dprada committed Oct 21, 2023
1 parent eafcb0f commit 907ee5e
Show file tree
Hide file tree
Showing 27 changed files with 752 additions and 3 deletions.
1 change: 1 addition & 0 deletions devtools/requirements.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ production:
- *setup_channels
dependencies: &production_dependencies
- *setup_dependencies
- h5py
- numpy
- numba
- pyunitwizard
Expand Down
9 changes: 8 additions & 1 deletion molsysmt/basic/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,14 @@ def _convert_one_to_one(molecular_system,
'copy_if_all'})

if len(missing_arguments)>0:
raise NotCompatibleConversionError(from_form, to_form, missing_arguments)

missing_arguments.discard('compression')
missing_arguments.discard('compression_opts')
missing_arguments.discard('int_precision')
missing_arguments.discard('float_precision')

if len(missing_arguments)>0:
raise NotCompatibleConversionError(from_form, to_form, missing_arguments)

output = function(molecular_system, **conversion_arguments, **kwargs)

Expand Down
31 changes: 31 additions & 0 deletions molsysmt/form/file_msmh5/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
form_name = 'file:msmh5'
form_type = 'file'
form_info = ["", ""]

from .is_form import is_form

from .attributes import attributes
from .has_attribute import has_attribute

from .extract import extract
from .copy import copy
from .add import add
from .merge import merge
from .append_structures import append_structures
from .get import *
from .set import *
from .iterators import StructuresIterator, TopologyIterator

from .to_molsysmt_MolSys import to_molsysmt_MolSys
from .to_molsysmt_Topology import to_molsysmt_Topology
from .to_molsysmt_Structures import to_molsysmt_Structures
from .to_nglview_NGLWidget import to_nglview_NGLWidget

_convert_to={
'file:msmh5': extract,
'molsysmt.MolSys': to_molsysmt_MolSys,
'molsysmt.Topology': to_molsysmt_Topology,
'molsysmt.Structures': to_molsysmt_Structures,
'nglview.NGLWidget': to_nglview_NGLWidget,
}

8 changes: 8 additions & 0 deletions molsysmt/form/file_msmh5/add.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from molsysmt._private.exceptions import NotImplementedMethodError
from molsysmt._private.digestion import digest

@digest(form='file:msmh5', to_form='file:msmh5')
def add(to_item, item, atom_indices='all', structure_indices='all'):

raise NotImplementedMethodError()

8 changes: 8 additions & 0 deletions molsysmt/form/file_msmh5/append_structures.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from molsysmt._private.exceptions import NotImplementedMethodError
from molsysmt._private.digestion import digest

@digest(form='file:msmh5')
def append_structures(item, structure_id=None, time=None, coordinates=None, box=None):

raise NotImplementedMethodError()

39 changes: 39 additions & 0 deletions molsysmt/form/file_msmh5/attributes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from molsysmt.attribute.attributes import attributes as _all_attributes

attributes = {ii:False for ii in _all_attributes}

attributes['atom_index'] = True
attributes['atom_id'] = True
attributes['atom_name'] = True
attributes['atom_type'] = True
attributes['bond_index'] = True
attributes['bond_id'] = True
attributes['bond_type'] = True
attributes['bond_order'] = True
attributes['group_index'] = True
attributes['group_id'] = True
attributes['group_name'] = True
attributes['group_type'] = True
attributes['component_index'] = True
attributes['component_id'] = True
attributes['component_name'] = True
attributes['component_type'] = True
attributes['molecule_index'] = True
attributes['molecule_id'] = True
attributes['molecule_name'] = True
attributes['molecule_type'] = True
attributes['chain_index'] = True
attributes['chain_id'] = True
attributes['chain_name'] = True
attributes['chain_type'] = True
attributes['entity_index'] = True
attributes['entity_id'] = True
attributes['entity_name'] = True
attributes['entity_type'] = True
attributes['coordinates'] = True
attributes['velocities'] = True
attributes['box'] = True
attributes['time'] = True
attributes['structure_id'] = True

del(_all_attributes)
16 changes: 16 additions & 0 deletions molsysmt/form/file_msmh5/copy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from molsysmt._private.exceptions import NotImplementedMethodError
from molsysmt._private.digestion import digest
from molsysmt._private.variables import is_all

@digest(form='file:msmh5')
def copy(item, output_filename=None):

if output_filename is None:
output_filename = item

from shutil import copy as copy_file
copy_file(item, output_filename)
tmp_item = output_filename

return tmp_item

27 changes: 27 additions & 0 deletions molsysmt/form/file_msmh5/extract.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from molsysmt._private.exceptions import NotImplementedMethodError
from molsysmt._private.digestion import digest
from molsysmt._private.variables import is_all

@digest(form='file:msmh5')
def extract(item, atom_indices='all', structure_indices='all', output_filename=None, copy_if_all=True):

if output_filename is None:
output_filename = item

if is_all(atom_indices) and is_all(structure_indices):

if copy_if_all or (output_filename!=item):

from shutil import copy as copy_file
copy_file(item, output_filename)
tmp_item = output_filename

else:

tmp_item = item
else:

raise NotImplementedMethodError()

return tmp_item

Loading

0 comments on commit 907ee5e

Please sign in to comment.