Skip to content

Commit

Permalink
In process
Browse files Browse the repository at this point in the history
  • Loading branch information
dprada committed Nov 2, 2023
1 parent 38a19d1 commit d9439b8
Show file tree
Hide file tree
Showing 62 changed files with 5,069 additions and 92 deletions.
2 changes: 1 addition & 1 deletion molsysmt/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.8.3+17.gcda3efaf.dirty"
__version__ = "0.8.3+19.g38a19d1b.dirty"
8 changes: 6 additions & 2 deletions molsysmt/form/file_msmh5/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,22 @@

from .to_molsysmt_MSMH5FileHandler import to_molsysmt_MSMH5FileHandler
from .to_molsysmt_MolSys import to_molsysmt_MolSys
from .to_molsysmt_MolSysNEW import to_molsysmt_MolSysNEW
from .to_molsysmt_Topology import to_molsysmt_Topology
from .to_molsysmt_Topology2 import to_molsysmt_Topology2
from .to_molsysmt_TopologyNEW import to_molsysmt_TopologyNEW
from .to_molsysmt_Structures import to_molsysmt_Structures
from .to_molsysmt_StructuresNEW import to_molsysmt_StructuresNEW
from .to_nglview_NGLWidget import to_nglview_NGLWidget

_convert_to={
'file:msmh5': extract,
'molsysmt.MSMH5FileHandler': to_molsysmt_MSMH5FileHandler,
'molsysmt.MolSys': to_molsysmt_MolSys,
'molsysmt.MolSysNEW': to_molsysmt_MolSysNEW,
'molsysmt.Topology': to_molsysmt_Topology,
'molsysmt.Topology2': to_molsysmt_Topology2,
'molsysmt.TopologyNEW': to_molsysmt_TopologyNEW,
'molsysmt.Structures': to_molsysmt_Structures,
'molsysmt.StructuresNEW': to_molsysmt_StructuresNEW,
'nglview.NGLWidget': to_nglview_NGLWidget,
}

10 changes: 9 additions & 1 deletion molsysmt/form/file_msmh5/to_molsysmt_MolSys.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,13 @@
@digest(form='file:msmh5')
def to_molsysmt_MolSys(item, atom_indices='all', structure_indices='all'):

raise NotImplementedError
from . import to_molsysmt_MSMH5FileHandler
from ..molsysmt_MSMH5FileHandler import to_molsysmt_MolSys as molsysmt_MSMH5FileHandler_to_molsysmt_MolSys

handler = to_molsysmt_MSMH5FileHandler(item)
tmp_item = molsysmt_MSMH5FileHandler_to_molsysmt_MolSys(handler, atom_indices=atom_indices,
structure_indices=structure_indices)
handler.close()

return tmp_item

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

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

from . import to_molsysmt_MSMH5FileHandler
from ..molsysmt_MSMH5FileHandler import to_molsysmt_MolSysNEW as molsysmt_MSMH5FileHandler_to_molsysmt_MolSys

handler = to_molsysmt_MSMH5FileHandler(item)
tmp_item = molsysmt_MSMH5FileHandler_to_molsysmt_MolSysNEW(handler, atom_indices=atom_indices,
structure_indices=structure_indices)
handler.close()

return tmp_item

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

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

from . import to_molsysmt_MSMH5FileHandler
from ..molsysmt_MSMH5FileHandler import to_molsysmt_StructuresNEW as molsysmt_MSMH5FileHandler_to_molsysmt_StructuresNEW

handler = to_molsysmt_MSMH5FileHandler(item)
tmp_item = molsysmt_MSMH5FileHandler_to_molsysmt_StructuresNEW(handler, atom_indices=atom_indices,
structure_indices=structure_indices)
handler.close()

return tmp_item
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from molsysmt._private.digestion import digest

@digest(form='file:msmh5')
def to_molsysmt_Topology2(item, atom_indices='all'):
def to_molsysmt_TopologyNEW(item, atom_indices='all'):

from . import to_molsysmt_MSMH5FileHandler
from ..molsysmt_MSMH5FileHandler import to_molsysmt_Topology2 as molsysmt_MSMH5FileHandler_to_molsysmt_Topology2
from ..molsysmt_MSMH5FileHandler import to_molsysmt_TopologyNEW as molsysmt_MSMH5FileHandler_to_molsysmt_TopologyNEW

handler = to_molsysmt_MSMH5FileHandler(item)
tmp_item = molsysmt_MSMH5FileHandler_to_molsysmt_Topology2(handler, atom_indices=atom_indices)
tmp_item = molsysmt_MSMH5FileHandler_to_molsysmt_TopologyNEW(handler, atom_indices=atom_indices)
handler.close()

return tmp_item
8 changes: 6 additions & 2 deletions molsysmt/form/molsysmt_MSMH5FileHandler/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,21 @@
from .iterators import StructuresIterator, TopologyIterator

from .to_molsysmt_MolSys import to_molsysmt_MolSys
from .to_molsysmt_MolSysNEW import to_molsysmt_MolSysNEW
from .to_molsysmt_Topology import to_molsysmt_Topology
from .to_molsysmt_Topology2 import to_molsysmt_Topology2
from .to_molsysmt_TopologyNEW import to_molsysmt_TopologyNEW
from .to_molsysmt_Structures import to_molsysmt_Structures
from .to_molsysmt_StructuresNEW import to_molsysmt_StructuresNEW
from .to_nglview_NGLWidget import to_nglview_NGLWidget

_convert_to={
'molsysmt.MSMH5FileHandler': extract,
'molsysmt.MolSys': to_molsysmt_MolSys,
'molsysmt.MolSysNEW': to_molsysmt_MolSysNEW,
'molsysmt.Topology': to_molsysmt_Topology,
'molsysmt.Topology2': to_molsysmt_Topology2,
'molsysmt.TopologyNEW': to_molsysmt_TopologyNEW,
'molsysmt.Structures': to_molsysmt_Structures,
'molsysmt.StructuresNEW': to_molsysmt_StructuresNEW,
'nglview.NGLWidget': to_nglview_NGLWidget,
}

10 changes: 9 additions & 1 deletion molsysmt/form/molsysmt_MSMH5FileHandler/to_molsysmt_MolSys.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,13 @@
@digest(form='molsysmt.MSMH5FileHandler')
def to_molsysmt_MolSys(item, atom_indices='all', structure_indices='all'):

raise NotImplementedError
from .to_molsysmt_Topology import to_molsysmt_Topology
from .to_molsysmt_Structures import to_molsysmt_Structures
from molsysmt.native import MolSys

tmp_item = MolSys()
tmp_item.topology = to_molsysmt_Topology(item, atom_indices=atom_indices)
tmp_item.structures = to_molsysmt_Structures(item, atom_indices=atom_indices, structure_indices=structure_indices)

return tmp_item

15 changes: 15 additions & 0 deletions molsysmt/form/molsysmt_MSMH5FileHandler/to_molsysmt_MolSysNEW.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from molsysmt._private.digestion import digest

@digest(form='molsysmt.MSMH5FileHandler')
def to_molsysmt_MolSysNEW(item, atom_indices='all', structure_indices='all'):

from .to_molsysmt_TopologyNEW import to_molsysmt_TopologyNEW
from .to_molsysmt_StructuresNEW import to_molsysmt_StructuresNEW
from molsysmt.native import MolSysNEW

tmp_item = MolSysNEW()
tmp_item.topology = to_molsysmt_TopologyNEW(item, atom_indices=atom_indices)
tmp_item.structures = to_molsysmt_StructuresNEW(item, atom_indices=atom_indices, structure_indices=structure_indices)

return tmp_item

110 changes: 110 additions & 0 deletions molsysmt/form/molsysmt_MSMH5FileHandler/to_molsysmt_StructuresNEW.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
from molsysmt._private.digestion import digest
from molsysmt import pyunitwizard as puw
import numpy as np

@digest(form='molsysmt.MSMH5FileHandler')
def to_molsysmt_StructuresNEW(item, atom_indices='all', structure_indices='all'):

from molsysmt.native import StructuresNEW

structures_ds = item.file['structures']

n_atoms = structures_ds.attrs['n_atoms']
n_structures = structures_ds.attrs['n_structures']

length_unit = puw.unit(structures_ds.attrs['length_unit'])
time_unit = puw.unit(structures_ds.attrs['time_unit'])
energy_unit = puw.unit(structures_ds.attrs['energy_unit'])
temperature_unit = puw.unit(structures_ds.attrs['temperature_unit'])

standard_length_unit = puw.get_standard_units(length_unit)
standard_time_unit = puw.get_standard_units(time_unit)
standard_energy_unit = puw.get_standard_units(energy_unit)
standard_temperature_unit = puw.get_standard_units(temperature_unit)

tmp_item = StructuresNEW()

tmp_item.n_atoms = n_atoms
tmp_item.n_structures = n_structures

# Coordinates

if structures_ds['coordinates'].shape[0]>0:

tmp_item.coordinates = puw.quantity(np.zeros([n_structures, n_atoms, 3], dtype='float64'),
standard_length_unit)
tmp_item.coordinates[:,:,:] = puw.quantity(structures_ds['coordinates'][:,:,:],
length_unit)

else:

tmp_item.coordinates = None

# Velocities

if structures_ds['velocities'].shape[0]>0:

tmp_item.velocities = puw.quantity(np.zeros([n_structures, n_atoms, 3], dtype='float64'),
standard_length_unit/standard_time_unit)
tmp_item.velocities[:,:,:] = puw.quantity(structures_ds['velocities'][:,:,:],
length_unit/time_unit)

else:

tmp_item.velocities = None

# Box

if structures_ds['box'].shape[0]>0:

tmp_item.box = puw.quantity(np.zeros([n_structures, 3, 3], dtype='float64'),
standard_length_unit)
tmp_item.box[:,:,:] = puw.quantity(structures_ds['box'][:,:,:],
length_unit)

else:

tmp_item.box = None

# Kinetic Energy

if structures_ds['kinetic_energy'].shape[0]>0:

tmp_item.kinetic_energy = puw.quantity(np.zeros([n_structures], dtype='float64'),
standard_energy_unit)
tmp_item.kinetic_energy[:] = puw.quantity(structures_ds['kinetic_energy'][:],
energy_unit)

else:

tmp_item.kinetic_energy = None

# Potential Energy

if structures_ds['potential_energy'].shape[0]>0:

tmp_item.potential_energy = puw.quantity(np.zeros([n_structures], dtype='float64'),
standard_energy_unit)
tmp_item.potential_energy[:] = puw.quantity(structures_ds['potential_energy'][:],
energy_unit)

else:

tmp_item.potential_energy = None

# Temperature

if structures_ds['temperature'].shape[0]>0:

tmp_item.temperature = puw.quantity(np.zeros([n_structures], dtype='float64'),
standard_temperature_unit)
tmp_item.temperature[:] = puw.quantity(structures_ds['temperature'][:],
temperature_unit)

else:

tmp_item.temperature = None


return tmp_item

Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
import numpy as np

@digest(form='molsysmt.MSMH5FileHandler')
def to_molsysmt_Topology2(item, atom_indices='all'):
def to_molsysmt_TopologyNEW(item, atom_indices='all'):

from molsysmt.native import Topology2
from molsysmt.native import TopologyNEW

topology_ds = item.file['topology']

tmp_item = Topology2()
tmp_item = TopologyNEW()

# Atoms

Expand Down
33 changes: 33 additions & 0 deletions molsysmt/form/molsysmt_MolSysNEW/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
form_name = 'molsysmt.MolSysNEW'
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_TopologyNEW import to_molsysmt_TopologyNEW
from .to_molsysmt_StructuresNEW import to_molsysmt_StructuresNEW
from .to_molsysmt_MolecularMechanics import to_molsysmt_MolecularMechanics
from .to_molsysmt_MolecularMechanicsDict import to_molsysmt_MolecularMechanicsDict
from .to_file_msmpk import to_file_msmpk

_convert_to={
'molsysmt.MolSysNEW': extract,
'molsysmt.TopologyNEW': to_molsysmt_TopologyNEW,
'molsysmt.StructuresNEW': to_molsysmt_StructuresNEW,
'molsysmt.MolecularMechanics': to_molsysmt_MolecularMechanics,
'molsysmt.MolecularMechanicsDict': to_molsysmt_MolecularMechanicsDict,
'file:msmpk': to_file_msmpk,
}

12 changes: 12 additions & 0 deletions molsysmt/form/molsysmt_MolSysNEW/add.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from molsysmt._private.exceptions import NotImplementedMethodError
from molsysmt._private.digestion import digest
from molsysmt import pyunitwizard as puw
import numpy as np

@digest(form='molsysmt.MolSysNEW', to_form='molsysmt.MolSysNEW')
def add(to_item, item, atom_indices='all', structure_indices='all'):

to_item.add(item)

pass

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

@digest(form='molsysmt.MolSysNEW')
def append_structures(item, structure_id=None, time=None, coordinates=None, velocities=None,
box=None):

item.structures.append_structures(structure_id=structure_id, time=time, coordinates=coordinates,
velocities=velocities, box=box)

pass

Loading

0 comments on commit d9439b8

Please sign in to comment.