-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
1,128 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from molsysmt._private.exceptions import ArgumentError | ||
|
||
def digest_compression(compression, caller=None): | ||
|
||
if isinstance(compression, str): | ||
|
||
if caller.endswith('to_file_msmh5'): | ||
if compression in ['gzip', 'lzf', 'szip']: | ||
return compression | ||
|
||
raise ArgumentError('compression', value=compression, caller=caller, message=None) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from molsysmt._private.exceptions import ArgumentError | ||
|
||
def digest_compression_opts(compression_opts, caller=None): | ||
|
||
if isinstance(compression_opts, int): | ||
|
||
if caller.endswith('to_file_msmh5'): | ||
if 0<=compression_opts<=9: | ||
return compression_opts | ||
|
||
raise ArgumentError('compression_opts', value=compression_opts, caller=caller, message=None) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from molsysmt._private.exceptions import ArgumentError | ||
|
||
def digest_float_precision(float_precision, caller=None): | ||
|
||
if isinstance(float_precision, str): | ||
|
||
if caller.endswith('to_file_msmh5'): | ||
if float_precision in ['single', 'double']: | ||
return float_precision | ||
|
||
raise ArgumentError('float_precision', value=float_precision, caller=caller, message=None) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from molsysmt._private.exceptions import ArgumentError | ||
|
||
def digest_int_precision(int_precision, caller=None): | ||
|
||
if isinstance(int_precision, str): | ||
|
||
if caller.endswith('to_file_msmh5'): | ||
if int_precision in ['single', 'double']: | ||
return int_precision | ||
|
||
raise ArgumentError('int_precision', value=int_precision, caller=caller, message=None) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from molsysmt._private.digestion import digest | ||
|
||
@digest(form='file:msmh5') | ||
def to_molsysmt_MSMH5FileHandler(item, atom_indices='all'): | ||
|
||
from molsysmt.native import MSMH5FileHandler | ||
|
||
return MSMH5FileHandler(item, io_mode='r') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
form_name = 'molsysmt.MSMH5FileHandler' | ||
form_type = 'class' | ||
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={ | ||
'molsysmt.MSMH5FileHandler': extract, | ||
'molsysmt.MolSys': to_molsysmt_MolSys, | ||
'molsysmt.Topology': to_molsysmt_Topology, | ||
'molsysmt.Structures': to_molsysmt_Structures, | ||
'nglview.NGLWidget': to_nglview_NGLWidget, | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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='molsysmt.MSMH5FileHandler', to_form='molsysmt.MSMH5FileHandler') | ||
def add(to_item, item, atom_indices='all', structure_indices='all'): | ||
|
||
raise NotImplementedMethodError() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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='molsysmt.MSMH5FileHandler') | ||
def append_structures(item, structure_id=None, time=None, coordinates=None, box=None): | ||
|
||
raise NotImplementedMethodError() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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='molsysmt.MSMH5FileHandler') | ||
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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='molsysmt.MSMH5FileHandler') | ||
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 | ||
|
Oops, something went wrong.