-
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
11 changed files
with
63,183 additions
and
228 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
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,14 @@ | ||
from molsysmt._private.digestion import digest | ||
|
||
@digest(form='file:gro') | ||
def to_molsysmt_MolSys(item, atom_indices='all', structure_indices='all', skip_digestion=False): | ||
|
||
from . import to_mdtraj_Trajectory | ||
from ..mdtraj_Trajectory import to_molsysmt_MolSys as mdtraj_Trajectory_to_molsysmt_MolSys | ||
|
||
tmp_item = to_mdtraj_Trajectory(item, skip_digestion=True) | ||
tmp_item = mdtraj_Trajectory_to_molsysmt_MolSys(tmp_item, atom_indices=atom_indices, | ||
structure_indices=structure_indices, skip_digestion=True) | ||
|
||
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,15 @@ | ||
from molsysmt._private.digestion import digest | ||
|
||
@digest(form='file:gro') | ||
def to_molsysmt_Structures(item, atom_indices='all', structure_indices='all', skip_digestion=False): | ||
|
||
from . import to_openmm_GromacsGroFile | ||
from ..openmm_GromacsGroFile import to_molsysmt_Structures as openmm_GromacsGroFile_to_molsysmt_Structures | ||
|
||
tmp_item = to_openmm_GromacsGroFile(item, skip_digestion=True) | ||
tmp_item = openmm_GromacsGroFile_to_molsysmt_Structures(tmp_item, atom_indices=atom_indices, | ||
structure_indices=structure_indices, | ||
skip_digestion=True) | ||
|
||
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,33 @@ | ||
from molsysmt._private.digestion import digest | ||
|
||
@digest(form='file:gro') | ||
def to_molsysmt_Topology(item, atom_indices='all', skip_digestion=False): | ||
|
||
#from . import to_mdtraj_Topology | ||
#from ..mdtraj_Topology import to_molsysmt_Topology as mdtraj_Topology_to_molsysmt_Topology | ||
|
||
#tmp_item = to_mdtraj_Topology(item, atom_indices=atom_indices, skip_digestion=True) | ||
#tmp_item = mdtraj_Topology_to_molsysmt_Topology(tmp_item, skip_digestion=True) | ||
|
||
from molsysmt.native import Topology | ||
from ..molsysmt_Topology import extract | ||
|
||
tmp_item = Topology() | ||
|
||
n_atoms = item.n_atoms | ||
n_groups = item.n_residues | ||
n_chains = item.n_chains | ||
n_bonds = item.n_bonds | ||
|
||
|
||
# atoms | ||
|
||
atom_name_array = np.empty(n_atoms, dtype=object) | ||
atom_id_array = np.empty(n_atoms, dtype=int) | ||
atom_type_array = np.empty(n_atoms, dtype=object) | ||
group_index_array = np.empty(n_atoms, dtype=int) | ||
chain_index_array = np.empty(n_atoms, dtype=int) | ||
|
||
|
||
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
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,135 @@ | ||
from molsysmt._private.digestion import digest | ||
from molsysmt.element.group.get_group_type import _get_group_type_from_group_name | ||
|
||
@digest(form='mdtraj.Topology') | ||
def to_molsysmt_Topology(item, atom_indices='all', skip_digestion=False): | ||
|
||
#from ..openmm_Topology import to_molsysmt_Topology as openmm_Topology_to_molsysmt_Topology | ||
|
||
#tmp_item = item.to_openmm() | ||
#tmp_item = openmm_Topology_to_molsysmt_Topology(tmp_item, atom_indices=atom_indices, skip_digestion=True) | ||
|
||
from molsysmt.native import Topology | ||
from ..molsysmt_Topology import extract | ||
|
||
tmp_item = Topology() | ||
|
||
n_atoms = item.n_atoms | ||
n_groups = item.n_residues | ||
n_chains = item.n_chains | ||
n_bonds = item.n_bonds | ||
|
||
# atoms | ||
|
||
atom_name_array = np.empty(n_atoms, dtype=object) | ||
atom_id_array = np.empty(n_atoms, dtype=int) | ||
atom_type_array = np.empty(n_atoms, dtype=object) | ||
group_index_array = np.empty(n_atoms, dtype=int) | ||
chain_index_array = np.empty(n_atoms, dtype=int) | ||
|
||
for atom_index, atom in enumerate(item.atoms): | ||
|
||
atom_name_array[atom_index] = atom.name | ||
atom_id_array[atom_index] = atom.serial | ||
atom_type_array[atom_index] = atom.element | ||
group_index_array[atom_index] = atom.residue.index | ||
chain_index_array[chain_index] = atom.residue.chain.index | ||
|
||
tmp_item.atoms["atom_name"] = atom_name_array | ||
tmp_item.atoms["atom_id"] = atom_id_array | ||
tmp_item.atoms["atom_type"] = atom_type_array | ||
tmp_item.atoms["group_index"] = group_index_array | ||
tmp_item.atoms["chain_index"] = chain_index_array | ||
|
||
del atom_name_array, atom_id_array, atom_type_array | ||
del group_index_array, chain_index_array | ||
|
||
# groups | ||
|
||
group_name_array = np.empty(n_groups, dtype=object) | ||
group_id_array = np.empty(n_groups, dtype=int) | ||
|
||
aux_dict = {} | ||
|
||
for group_index, residue in enumerate(item.residues): | ||
|
||
group_name_array[group_index] = residue.name | ||
group_id_array[group_index] = residue.resSeq | ||
|
||
if residue.name not in aux_dict: | ||
aux_dict[residue.name] = _get_group_type_from_group_name(residue.name) | ||
|
||
tmp_item.groups["group_id"] = group_id_array | ||
tmp_item.groups["group_name"] = group_name_array | ||
tmp_item.groups["group_type"] = np.array([aux_dict[ii] for ii in group_name_array], dtype=object) | ||
|
||
del group_name_array, group_id_array | ||
|
||
# chains | ||
|
||
chain_name_array = np.empty(n_chains, dtype=object) | ||
|
||
index = 0 | ||
|
||
for chain in item.chains(): | ||
|
||
chain_name_array[index] = chain.chain_id | ||
|
||
tmp_item.chains["chain_name"] = chain_name_array | ||
tmp_item.chains["chain_id"] = tmp_item.chains.index | ||
|
||
del chain_name_array | ||
|
||
# bonds | ||
|
||
bond_atom1_array = np.empty(n_bonds, dtype=int) | ||
bond_atom2_array = np.empty(n_bonds, dtype=int) | ||
bond_type_array = np.empty(n_bonds, dtype=object) | ||
bond_order_array = np.empty(n_bonds, dtype=object) | ||
|
||
for bond in item.bonds(): | ||
|
||
bond_atom1_array[index] = bond.atom1.index | ||
bond_atom2_array[index] = bond.atom2.index | ||
bond_order_array[index] = bond.order | ||
bond_type_array[index] = bond.type | ||
|
||
tmp_item.bonds["atom1_index"] = bond_atom1_array | ||
tmp_item.bonds["atom2_index"] = bond_atom2_array | ||
tmp_item.bonds["order"] = bond_order_array | ||
tmp_item.bonds["type"] = bond_type_array | ||
|
||
del bond_atom1_array, bond_atom2_array | ||
del bond_order_array, bond_type_array | ||
|
||
if tmp_item.bonds["order"].isnull().all(): | ||
tmp_item.bonds.drop("order", axis=1, inplace=True) | ||
|
||
if tmp_item.bonds["type"].isnull().all(): | ||
tmp_item.bonds.drop("type", axis=1, inplace=True) | ||
|
||
# components | ||
|
||
tmp_item.rebuild_components() | ||
|
||
# molecules | ||
|
||
tmp_item.rebuild_molecules() | ||
|
||
# chain types | ||
|
||
tmp_item.rebuild_chain_types() | ||
|
||
# entity | ||
|
||
tmp_item.rebuild_entities() | ||
|
||
# nan to None | ||
|
||
tmp_item._fix_null_values() | ||
tmp_item.bonds._sort_bonds() | ||
|
||
tmp_item = tmp_item.extract(atom_indices=atom_indices, copy_if_all=False, skip_digestion=True) | ||
|
||
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
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,17 @@ | ||
from molsysmt._private.digestion import digest | ||
|
||
@digest(form='mdtraj.Trajectory') | ||
def to_molsysmt_MolSys(item, atom_indices='all', structure_indices='all', skip_digestion=False): | ||
|
||
from molsysmt.native.molsys import MolSys | ||
from . import to_molsysmt_Topology | ||
from . import to_molsysmt_Structures | ||
|
||
tmp_item = MolSys() | ||
tmp_item.topology = to_molsysmt_Topology(item, atom_indices=atom_indices, skip_digestion=True) | ||
tmp_item.structures = to_molsysmt_Structures(item, atom_indices=atom_indices, | ||
structure_indices=structure_indices, skip_digestion=True) | ||
|
||
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,20 @@ | ||
from molsysmt._private.digestion import digest | ||
|
||
@digest(form='mdtraj.Trajectory') | ||
def to_molsysmt_Structures(item, atom_indices='all', structure_indices='all', skip_digestion=False): | ||
|
||
from molsysmt.native.structures import Structures | ||
from . import get_coordinates_from_atom, get_time_from_system, get_structure_id_from_system, get_box_from_system | ||
|
||
tmp_item = Structures() | ||
|
||
coordinates = get_coordinates_from_atom(item, indices=atom_indices, structure_indices=structure_indices, | ||
skip_digestion=True) | ||
time = get_time_from_system(item, structure_indices=structure_indices, skip_digestion=True) | ||
structure_id = get_structure_id_from_system(item, structure_indices=structure_indices, skip_digestion=True) | ||
box = get_box_from_system(item, structure_indices=structure_indices, skip_digestion=True) | ||
|
||
tmp_item.append(structure_id=structure_id, time=time, box=box, coordinates=coordinates) | ||
|
||
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,13 @@ | ||
from molsysmt._private.digestion import digest | ||
|
||
@digest(form='mdtraj.Trajectory') | ||
def to_molsysmt_Topology(item, atom_indices='all', skip_digestion=False): | ||
|
||
from . import to_mdtraj_Topology | ||
from ..mdtraj_Topology import to_molsysmt_Topology as mdtraj_Topology_to_molsysmt_Topology | ||
|
||
tmp_item = to_mdtraj_Topology(item, skip_digestion=True) | ||
tmp_item = mdtraj_Topology_to_molsysmt_Topology(tmp_item, atom_indices=atom_indices, skip_digestion=True) | ||
|
||
return tmp_item | ||
|
Oops, something went wrong.