Skip to content

Commit

Permalink
In process
Browse files Browse the repository at this point in the history
  • Loading branch information
dprada committed Feb 17, 2024
1 parent 7909946 commit 1e7eb97
Show file tree
Hide file tree
Showing 57 changed files with 1,515 additions and 1,110 deletions.
38 changes: 20 additions & 18 deletions molsysmt/basic/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,11 @@ def info(molecular_system,
chain_index, \
molecule_index, molecule_type, \
entity_index, entity_name = get(molecular_system, element=element, selection=selection,
syntax=syntax, atom_index=True, atom_id=True, atom_name=True,
atom_type=True, group_index=True, group_id=True, group_name=True,
group_type=True, component_index=True, chain_index=True,
molecule_index=True,
molecule_type=True, entity_index=True, entity_name=True,
syntax=syntax, skip_digestion=True, atom_index=True, atom_id=True,
atom_name=True, atom_type=True, group_index=True, group_id=True,
group_name=True, group_type=True, component_index=True,
chain_index=True, molecule_index=True, molecule_type=True,
entity_index=True, entity_name=True,
)

if not attributes_filter['atom_index']: atom_index=None
Expand Down Expand Up @@ -176,9 +176,9 @@ def info(molecular_system,
chain_index, \
molecule_index, molecule_type, \
entity_index, entity_name = get(molecular_system, element=element, selection=selection,
syntax=syntax, group_index=True, group_id=True, group_name=True,
group_type=True, n_atoms=True, component_index=True, chain_index=True,
molecule_index=True, molecule_type=True, entity_index=True,
syntax=syntax, skip_digestion=True, group_index=True, group_id=True,
group_name=True, group_type=True, n_atoms=True, component_index=True,
chain_index=True, molecule_index=True, molecule_type=True, entity_index=True,
entity_name=True)

if not attributes_filter['group_index']: group_index=None
Expand Down Expand Up @@ -206,9 +206,9 @@ def info(molecular_system,
chain_index, \
molecule_index, molecule_type, \
entity_index, entity_name = get(molecular_system, element=element, selection=selection,
syntax=syntax, component_index=True, n_atoms=True, n_groups=True,
chain_index=True, molecule_index=True, molecule_type=True,
entity_index=True, entity_name=True)
syntax=syntax, skip_digestion=True, component_index=True,
n_atoms=True, n_groups=True, chain_index=True, molecule_index=True,
molecule_type=True, entity_index=True, entity_name=True)

if not attributes_filter['component_index']: component_index=None
if not attributes_filter['n_atoms']: n_atoms=None
Expand All @@ -231,9 +231,9 @@ def info(molecular_system,
n_atoms, n_groups, n_components, \
molecule_index, molecule_type, \
entity_index, entity_name = get(molecular_system, element=element, selection=selection,
syntax=syntax, chain_index=True, chain_id=True, chain_name=True,
n_atoms=True, n_groups=True, n_components=True, molecule_index=True,
molecule_type=True, entity_index=True, entity_name=True)
syntax=syntax, skip_digestion=True, chain_index=True, chain_id=True,
chain_name=True, n_atoms=True, n_groups=True, n_components=True,
molecule_index=True, molecule_type=True, entity_index=True, entity_name=True)

if not attributes_filter['chain_index']: chain_index=None
if not attributes_filter['chain_id']: chain_id=None
Expand Down Expand Up @@ -286,7 +286,7 @@ def info(molecular_system,
molecule_index, molecule_name, molecule_type, \
n_atoms, n_groups, n_components, chain_index, \
entity_index, entity_name = get(molecular_system, element=element, selection=selection,
syntax=syntax, molecule_index=True, molecule_name=True,
syntax=syntax, skip_digestion=True, molecule_index=True, molecule_name=True,
molecule_type=True, n_atoms=True, n_groups=True, n_components=True,
chain_index=True, entity_index=True, entity_name=True)

Expand Down Expand Up @@ -321,8 +321,9 @@ def info(molecular_system,
entity_index, entity_name, entity_type, \
n_atoms, n_groups, n_components, n_chains, \
n_molecules = get(molecular_system, element=element, selection=selection,
syntax=syntax, entity_index=True, entity_name=True, entity_type=True, n_atoms=True,
n_groups=True, n_components=True, n_chains=True, n_molecules=True)
syntax=syntax, skip_digestion=True, entity_index=True, entity_name=True,
entity_type=True, n_atoms=True, n_groups=True, n_components=True, n_chains=True,
n_molecules=True)

if not attributes_filter['entity_index']: entity_index=None
if not attributes_filter['entity_name']: entity_name=None
Expand All @@ -342,7 +343,8 @@ def info(molecular_system,

n_atoms, n_groups, n_components, n_chains, n_molecules, n_entities, n_structures, \
n_ions, n_waters, n_small_molecules, n_peptides, n_proteins, n_dnas, \
n_rnas, n_lipids, n_oligosaccharides, n_saccharides = get(molecular_system, element=element, n_atoms=True, n_groups=True,
n_rnas, n_lipids, n_oligosaccharides, n_saccharides = get(molecular_system, element=element, skip_digestion=True,
n_atoms=True, n_groups=True,
n_components=True, n_chains=True, n_molecules=True, n_entities=True, n_structures=True, n_ions=True,
n_waters=True, n_small_molecules=True, n_peptides=True, n_proteins=True, n_dnas=True,
n_rnas=True, n_lipids=True, n_oligosaccharides=True, n_saccharides=True)
Expand Down
7 changes: 5 additions & 2 deletions molsysmt/basic/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ def merge(molecular_systems,
structure_indices='all',
syntax='MolSysMT',
to_form=None,
skip_digestion=False
):

"""
Expand Down Expand Up @@ -150,11 +151,11 @@ def merge(molecular_systems,
if is_all(tmp_selection):
aux_atom_indices.append(tmp_selection)
else:
aux_atom_indices.append(selection(tmp_molecular_system, selection=selection, syntax=syntax))
aux_atom_indices.append(selection(tmp_molecular_system, selection=selection, syntax=syntax, skip_digestion=True))
aux_structure_indices.append(tmp_structure_indices)
else:
aux = convert(tmp_molecular_system, to_form=to_form, selection=tmp_selection,
structure_indices=tmp_structure_indices)
structure_indices=tmp_structure_indices, skip_digestion=True)
aux_molecular_systems.append(aux)
aux_atom_indices.append('all')
aux_structure_indices.append('all')
Expand All @@ -169,6 +170,8 @@ def merge(molecular_systems,
if 'structure_indices' in input_arguments:
merge_arguments['structure_indices']=aux_structure_indices

merge_arguments['skip_digestion']=True

output = merge_function(aux_molecular_systems, **merge_arguments)

return output
Expand Down
6 changes: 6 additions & 0 deletions molsysmt/form/file_msmpk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,19 @@

from .update_file import update_file

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_molsysmt_MolSysOld import to_molsysmt_MolSysOld
from .to_molsysmt_TopologyOld import to_molsysmt_TopologyOld
from .to_molsysmt_StructuresOld import to_molsysmt_StructuresOld
from .to_nglview_NGLWidget import to_nglview_NGLWidget

_convert_to={
'file:msmpk': extract,
'molsysmt.MolSys': to_molsysmt_MolSys,
'molsysmt.Topology': to_molsysmt_Topology,
'molsysmt.Structures': to_molsysmt_Structures,
'molsysmt.MolSysOld': to_molsysmt_MolSysOld,
'molsysmt.TopologyOld': to_molsysmt_TopologyOld,
'molsysmt.StructuresOld': to_molsysmt_StructuresOld,
Expand Down
14 changes: 14 additions & 0 deletions molsysmt/form/file_msmpk/to_molsysmt_MolSys.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from molsysmt._private.digestion import digest

@digest(form='file:msmpk')
def to_molsysmt_MolSys(item, atom_indices='all', structure_indices='all', skip_digestion=False):

from .to_molsysmt_MolSysOld import to_molsysmt_MolSysOld
from ..molsysmt_MolSysOld import to_molsysmt_MolSys as molsysmt_MolSysOld_to_molsysmt_MolSys

tmp_item = to_molsysmt_MolSysOld(item, atom_indices=atom_indices, structure_indices=structure_indices,
skip_digestion=True)
tmp_item = molsysmt_MolSysOld_to_molsysmt_MolSys(tmp_item)

return tmp_item

37 changes: 27 additions & 10 deletions molsysmt/form/file_msmpk/to_molsysmt_MolSysOld.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,42 @@ def to_molsysmt_MolSysOld(item, atom_indices='all', structure_indices='all', ski
import bz2

fff = bz2.BZ2File(item,'rb')
tmp_item = pickle.load(fff)
aux_item = pickle.load(fff)
fff.close()

# lengths with nm values and time in ps

if tmp_item.structures.coordinates is not None:
value = tmp_item.structures.coordinates
if aux_item.structures.coordinates is not None:
value = aux_item.structures.coordinates
quantity = puw.quantity(value, 'nm')
tmp_item.structures.coordinates = puw.standardize(quantity)
aux_item.structures.coordinates = puw.standardize(quantity)

if tmp_item.structures.box is not None:
value = tmp_item.structures.box
if aux_item.structures.box is not None:
value = aux_item.structures.box
quantity = puw.quantity(value, 'nm')
tmp_item.structures.box = puw.standardize(quantity)
aux_item.structures.box = puw.standardize(quantity)

if tmp_item.structures.time is not None:
value = tmp_item.structures.time
if aux_item.structures.time is not None:
value = aux_item.structures.time
quantity = puw.quantity(value, 'ps')
tmp_item.structures.time = puw.standardize(quantity)
aux_item.structures.time = puw.standardize(quantity)

from molsysmt.native import MolSysOld
from copy import deepcopy

tmp_item = MolSysOld()

tmp_item.topology.atoms_dataframe = deepcopy(aux_item.topology.atoms_dataframe)
tmp_item.topology.bonds_dataframe = deepcopy(aux_item.topology.bonds_dataframe)

tmp_item.structures.n_atoms = aux_item.structures.n_atoms
tmp_item.structures.n_structures = aux_item.structures.n_structures

tmp_item.structures.coordinates = deepcopy(aux_item.structures.coordinates)
tmp_item.structures.box = deepcopy(aux_item.structures.box)
tmp_item.structures.time = deepcopy(aux_item.structures.time)

del aux_item

tmp_item = extract_molsysmt_MolSysOld(tmp_item, atom_indices=atom_indices,
structure_indices=structure_indices, copy_if_all=False, skip_digestion=True)
Expand Down
14 changes: 14 additions & 0 deletions molsysmt/form/file_msmpk/to_molsysmt_Structures.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from molsysmt._private.digestion import digest

@digest(form='file:msmpk')
def to_molsysmt_Structures(item, atom_indices='all', structure_indices='all', skip_digestion=False):

from . import to_molsysmt_MolSys
from ..molsysmt_MolSys import to_molsysmt_Structures as molsysmt_MolSys_to_molsysmt_Structures

tmp_item = to_molsysmt_MolSys(item, atom_indices=atom_indices, structure_indices=structure_indices,
skip_digestion=True)
tmp_item = molsysmt_MolSys_to_molsysmt_Structures(tmp_item, skip_digestion=True)

return tmp_item

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

@digest(form='file:msmpk')
def to_molsysmt_Topology(item, atom_indices='all', skip_digestion=False):

from . import to_molsysmt_MolSys
from ..molsysmt_MolSys import to_molsysmt_Topology as molsysmt_MolSys_to_molsysmt_Topology

tmp_item = to_molsysmt_MolSys(item, skip_digestion=True)
tmp_item = molsysmt_MolSys_to_molsysmt_Topology(tmp_item, atom_indices=atom_indices, skip_digestion=True)

return tmp_item

2 changes: 2 additions & 0 deletions molsysmt/form/molsysmt_MolSysOld/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from .set import *
from .iterators import StructuresIterator, TopologyIterator

from .to_molsysmt_MolSys import to_molsysmt_MolSys
from .to_molsysmt_TopologyOld import to_molsysmt_TopologyOld
from .to_molsysmt_StructuresOld import to_molsysmt_StructuresOld
from .to_molsysmt_MolecularMechanics import to_molsysmt_MolecularMechanics
Expand Down Expand Up @@ -44,6 +45,7 @@

_convert_to={
'molsysmt.MolSysOld': extract,
'molsysmt.MolSys': to_molsysmt_MolSys,
'molsysmt.TopologyOld': to_molsysmt_TopologyOld,
'molsysmt.StructuresOld': to_molsysmt_StructuresOld,
'molsysmt.MolecularMechanics': to_molsysmt_MolecularMechanics,
Expand Down
2 changes: 1 addition & 1 deletion molsysmt/form/molsysmt_MolSysOld/add.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import numpy as np

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

to_item.add(item)

Expand Down
2 changes: 1 addition & 1 deletion molsysmt/form/molsysmt_MolSysOld/append_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

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

item.structures.append_structures(structure_id=structure_id, time=time, coordinates=coordinates,
velocities=velocities, box=box)
Expand Down
2 changes: 1 addition & 1 deletion molsysmt/form/molsysmt_MolSysOld/copy.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from molsysmt._private.digestion import digest

@digest(form='molsysmt.MolSysOld')
def copy(item):
def copy(item, skip_digestion=False):

return item.copy()

2 changes: 1 addition & 1 deletion molsysmt/form/molsysmt_MolSysOld/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from molsysmt._private.variables import is_all

@digest(form='molsysmt.MolSysOld')
def extract(item, atom_indices='all', structure_indices='all', copy_if_all=True):
def extract(item, atom_indices='all', structure_indices='all', copy_if_all=True, skip_digestion=False):

if is_all(atom_indices) and is_all(structure_indices):
if copy_if_all:
Expand Down
Loading

0 comments on commit 1e7eb97

Please sign in to comment.