-
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
14 changed files
with
234 additions
and
23 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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
from .names import n_terminal_capping_names, c_terminal_capping_names, names | ||
from .group_names import n_terminal_capping_names, c_terminal_capping_names, group_names | ||
from .is_terminal_capping import is_terminal_capping |
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
4 changes: 2 additions & 2 deletions
4
molsysmt/element/group/terminal_capping/is_terminal_capping.py
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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
from .names import names | ||
from .group_names import group_names | ||
|
||
def is_terminal_capping(name): | ||
""" | ||
To be written soon... | ||
""" | ||
|
||
return (name in names) | ||
return (name in group_names) | ||
|
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,16 @@ | ||
from molsysmt._private.digestion import digest | ||
|
||
@digest(form='file:crd') | ||
def to_molsysmt_MolSys(item, atom_indices='all', structure_indices='all', get_missing_bonds=False, | ||
skip_digestion=False): | ||
|
||
from molsysmt.native.molsys import MolSys | ||
from .to_molsysmt_Topology import to_molsysmt_Topology | ||
from .to_molsysmt_Structures import to_molsysmt_Structures | ||
|
||
tmp_item = MolSys() | ||
tmp_item.topology = to_molsysmt_Topology(item, atom_indices=atom_indices, structure_indices=structure_indices) | ||
tmp_item.structures = to_molsysmt_Structures(item, atom_indices=atom_indices, structure_indices=structure_indices) | ||
|
||
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,52 @@ | ||
from molsysmt._private.digestion import digest | ||
from molsysmt import pyunitwizard as puw | ||
import numpy as np | ||
|
||
@digest(form='file:crd') | ||
def to_molsysmt_Structures(item, atom_indices='all', structure_indices='all', skip_digestion=False): | ||
|
||
# EXT: | ||
# (i10,2x,a) natoms,'EXT' | ||
# (2I10,2X,A8,2X,A8,3F20.10,2X,A8,2X,A8,F20.10) | ||
# iatom,ires,resn,typr,x,y,z,segid,rid,wmain | ||
# standard: | ||
# (i5) natoms | ||
# (2I5,1X,A4,1X,A4,3F10.5,1X,A4,1X,A4,F10.5) | ||
# iatom,ires,resn,typr,x,y,z,segid,orig_resid,wmain | ||
|
||
from molsysmt.native.structures import Structures | ||
|
||
tmp_item = Structures() | ||
|
||
x = [] | ||
y = [] | ||
z = [] | ||
|
||
extended = False | ||
|
||
with open(item) as fff: | ||
for line in fff: | ||
if line.strip().startswith('*') or line.strip() == "": | ||
continue | ||
field = line.split() | ||
if len(field)==1: | ||
n_atoms = int(field[0]) | ||
elif len(field)==2: | ||
n_atoms = int(field[0]) | ||
extended = True | ||
else: | ||
x.append(float(field[4])) | ||
y.append(float(field[5])) | ||
z.append(float(field[6])) | ||
|
||
if len(x)!=n_atoms: | ||
raise ValueError | ||
|
||
coordinates = puw.quantity(np.expand_dims(np.column_stack([x,y,z]), axis=0), unit='angstroms', standardized=True) | ||
|
||
tmp_item.append(structure_id=[0], coordinates=coordinates) | ||
|
||
del(x,y,z,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,104 @@ | ||
from molsysmt._private.digestion import digest | ||
from molsysmt import pyunitwizard as puw | ||
from molsysmt.element.atom.get_atom_type import _get_atom_type_from_atom_name | ||
from molsysmt.element.group.get_group_type import _get_group_type_from_group_name | ||
import numpy as np | ||
|
||
@digest(form='file:crd') | ||
def to_molsysmt_Topology(item, atom_indices='all', structure_indices='all', skip_digestion=False): | ||
|
||
# EXT: | ||
# (i10,2x,a) natoms,'EXT' | ||
# (2I10,2X,A8,2X,A8,3F20.10,2X,A8,2X,A8,F20.10) | ||
# iatom,ires,resn,typr,x,y,z,segid,rid,wmain | ||
# standard: | ||
# (i5) natoms | ||
# (2I5,1X,A4,1X,A4,3F10.5,1X,A4,1X,A4,F10.5) | ||
# iatom,ires,resn,typr,x,y,z,segid,orig_resid,wmain | ||
|
||
from molsysmt.native.topology import Topology | ||
|
||
tmp_item = Topology() | ||
|
||
atom_id = [] | ||
atom_name = [] | ||
atom_type = [] | ||
group_index = [] | ||
group_id = [] | ||
group_name = [] | ||
group_type = [] | ||
chain_index = [] | ||
chain_name = [] | ||
|
||
extended = False | ||
|
||
former_group_id = -1 | ||
former_chain_name = '' | ||
|
||
aux_group_index = -1 | ||
aux_chain_index = -1 | ||
|
||
with open(item) as fff: | ||
for line in fff: | ||
if line.strip().startswith('*') or line.strip() == "": | ||
continue | ||
field = line.split() | ||
if len(field)==1: | ||
n_atoms = int(field[0]) | ||
elif len(field)==2: | ||
n_atoms = int(field[0]) | ||
extended = True | ||
else: | ||
atom_id.append(int(field[0])) | ||
atom_name.append(field[3]) | ||
|
||
aux_group_id = int(field[1]) | ||
aux_chain_name = field[7] | ||
|
||
if former_group_id!=aux_group_id: | ||
former_group_id=aux_group_id | ||
group_id.append(aux_group_id) | ||
group_name.append(field[2]) | ||
aux_group_index += 1 | ||
|
||
if former_chain_name!=aux_chain_name: | ||
former_chain_name=aux_chain_name | ||
chain_name.append(aux_chain_name) | ||
aux_chain_index += 1 | ||
|
||
group_index.append(aux_group_index) | ||
chain_index.append(aux_chain_index) | ||
|
||
if len(atom_id)!=n_atoms: | ||
raise ValueError | ||
|
||
for ii in atom_name: | ||
atom_type.append(_get_atom_type_from_atom_name(ii)) | ||
|
||
for ii in group_name: | ||
group_type.append(_get_group_type_from_group_name(ii)) | ||
|
||
n_groups = len(group_name) | ||
n_chains = len(chain_name) | ||
|
||
tmp_item.reset_atoms(n_atoms=n_atoms) | ||
tmp_item.reset_groups(n_groups=n_groups) | ||
tmp_item.reset_chains(n_chains=n_chains) | ||
|
||
tmp_item.atoms.atom_id = np.array(atom_id, dtype=int) | ||
tmp_item.atoms.atom_name = np.array(atom_name, dtype=object) | ||
tmp_item.atoms.atom_type = np.array(atom_type, dtype=object) | ||
tmp_item.atoms.group_index = np.array(group_index, dtype=int) | ||
tmp_item.atoms.chain_index = np.array(chain_index, dtype=int) | ||
tmp_item.groups.group_id = np.array(group_id, dtype=int) | ||
tmp_item.groups.group_name = np.array(group_name, dtype=object) | ||
tmp_item.groups.group_type = np.array(group_type, dtype=object) | ||
tmp_item.chains.chain_id = np.arange(n_chains, dtype=int) | ||
tmp_item.chains.chain_name = np.array(chain_name, dtype=object) | ||
|
||
del(atom_id, atom_name, atom_type, | ||
group_index, group_id, group_name, group_type, | ||
chain_index, chain_name) | ||
|
||
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 |
---|---|---|
@@ -1,10 +1,22 @@ | ||
from molsysmt._private.exceptions import NotImplementedMethodError | ||
from molsysmt._private.digestion import digest | ||
from molsysmt._private.variables import is_all | ||
|
||
@digest(form='molsysmt.MolSys') | ||
def append_structures(item, atom_indices='all', structure_indices='all', skip_digestion=False): | ||
|
||
item.append_structures(item, atom_indices=atom_indices, structure_indices=structure_indices, skip_digestion=True) | ||
@digest(form='molsysmt.MolSys', to_form='molsysmt.MolSys') | ||
def append_structures(to_item, item=None, structure_id=None, time=None, coordinates=None, velocities=None, | ||
box=None, temperature=None, potential_energy=None, kinetic_energy=None, | ||
atom_indices='all', structure_indices='all', skip_digestion=False): | ||
|
||
if item is not None: | ||
to_item.structures.append_structures(item, atom_indices=atom_indices, structure_indices=structure_indices, | ||
skip_digestion=True) | ||
else: | ||
to_item.structures.append(structure_id=structure_id, time=time, coordinates=coordinates, | ||
velocities=velocities, box=box, temperature=temperature, | ||
potential_energy=potential_energy, kinetic_energy=kinetic_energy, | ||
atom_indices=atom_indices, structure_indices=structure_indices, | ||
skip_digestion=True) | ||
|
||
pass | ||
|
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
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
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