Skip to content

Commit

Permalink
In process
Browse files Browse the repository at this point in the history
  • Loading branch information
dprada committed Feb 14, 2024
1 parent e9f4aaa commit c6e2836
Show file tree
Hide file tree
Showing 24 changed files with 437 additions and 427 deletions.
Binary file added molsysmt/data/databases/components.pkl
Binary file not shown.
4 changes: 2 additions & 2 deletions molsysmt/element/group/get_group_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@ def _get_group_type_from_group_name(group_name):
output = 'water'
elif is_ion(group_name):
output = 'ion'
elif is_small_molecule(group_name):
output = 'small molecule'
elif is_amino_acid(group_name):
output = 'amino acid'
elif is_terminal_capping(group_name):
output = 'terminal capping'
elif is_nucleotide(group_name):
output = 'nucleotide'
elif is_small_molecule(group_name):
output = 'small molecule'
elif is_lipid(group_name):
output = 'lipid'
elif is_saccharide(group_name):
Expand Down
15 changes: 15 additions & 0 deletions molsysmt/element/group/small_molecule/make_components_pkl.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# wget https://files.wwpdb.org/pub/pdb/data/monomers/components.cif

from molsysmt.native import CIFFileHandler
import pickle

handler = CIFFileHandler('components.cif')
cif_entries = handler.parse()
output = {}

for value, key in cif_entries.items():
output[key['_chem_comp']['three_letter_code']]=key['_chem_comp']['name']

with open('components.pkl', 'wb') as fp:
pickle.dump(output, fp)

21 changes: 17 additions & 4 deletions molsysmt/element/group/small_molecule/small_molecule_names.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
small_molecule_names = [
'HED', # PDBID 181L
'BNZ', # PDBID 181L
]
import pickle
import sys

if sys.version_info[1]==10:
from importlib.resources import files
def path(package, file):
return files(package).joinpath(file)
elif sys.version_info[1] in (8,9):
from pathlib import PurePath
parent = PurePath(__file__).parent
def path(package, file):
data_dir = package.split('.')[-1]
return parent.joinpath('../data/'+data_dir+'/'+file).__str__()


with open(path('molsysmt.data.databases','components.pkl'), 'rb') as fff:
small_molecule_names = pickle.load(fff)

212 changes: 0 additions & 212 deletions molsysmt/element/group/small_molecule/test.ipynb

This file was deleted.

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

from .to_molsysmt_CIFFileHandler import to_molsysmt_CIFFileHandler

_convert_to={
'file:cif': extract,
'molsysmt.CIFFileHandler': to_molsysmt_CIFFileHandler,
}

6 changes: 6 additions & 0 deletions molsysmt/form/file_pdb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
from .to_mdtraj_PDBTrajectoryFile import to_mdtraj_PDBTrajectoryFile
from .to_mdtraj_Topology import to_mdtraj_Topology
from .to_mdtraj_Trajectory import to_mdtraj_Trajectory
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
Expand All @@ -50,6 +53,9 @@
'mdtraj.PDBTrajectoryFile': to_mdtraj_PDBTrajectoryFile,
'mdtraj.Topology': to_mdtraj_Topology,
'mdtraj.Trajectory': to_mdtraj_Trajectory,
'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
16 changes: 16 additions & 0 deletions molsysmt/form/file_pdb/to_molsysmt_MolSys.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from molsysmt._private.digestion import digest

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

from molsysmt.native 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

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

@digest(form='file:pdb')
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_box_from_system

tmp_item = Structures()

coordinates = get_coordinates_from_atom(item, indices=atom_indices, structure_indices=structure_indices,
skip_digestion=True)
box = get_box_from_system(item, structure_indices=structure_indices, skip_digestion=True)

tmp_item.append_structures(coordinates=coordinates, box=box)

return tmp_item

13 changes: 13 additions & 0 deletions molsysmt/form/file_pdb/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:pdb')
def to_molsysmt_Topology(item, atom_indices='all', skip_digestion=False):

from . import to_openmm_PDBFile
from ..openmm_PDBFile import to_molsysmt_Topology as openmm_PDBFile_to_molsysmt_Topology

tmp_item = to_openmm_PDBFile(item, skip_digestion=True)
tmp_item = openmm_PDBFile_to_molsysmt_Topology(tmp_item, atom_indices=atom_indices, skip_digestion=True)

return tmp_item

4 changes: 2 additions & 2 deletions molsysmt/form/mmtf_MMTFDecoder/to_molsysmt_MolSys.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ def to_molsysmt_MolSys(item, atom_indices='all', structure_indices='all', skip_d
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)
tmp_item.molecular_mechanics = to_molsysmt_MolecularMechanics(item, atom_indices=atom_indices,
skip_digestion=True)
#tmp_item.molecular_mechanics = to_molsysmt_MolecularMechanics(item, atom_indices=atom_indices,
# skip_digestion=True)

return tmp_item

8 changes: 4 additions & 4 deletions molsysmt/form/mmtf_MMTFDecoder/to_molsysmt_Structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
@digest(form='mmtf.MMTFDecoder')
def to_molsysmt_Structures(item, atom_indices='all', structure_indices='all', skip_digestion=False):

from molsysmt.native.structures_old import StructuresOld
from molsysmt.form.molsysmt_StructuresOld import extract as extract_molsysmt_StructuresOld
from molsysmt.native.structures import Structures
from molsysmt.form.molsysmt_Structures import extract as extract_molsysmt_Structures
from molsysmt.pbc import get_box_from_lengths_and_angles

n_atoms = item.num_atoms
Expand Down Expand Up @@ -150,12 +150,12 @@ def to_molsysmt_Structures(item, atom_indices='all', structure_indices='all', sk

bioassembly[aux_bioassembly['name']] = aux

tmp_item = StructuresOld(structure_id=structure_id, time=time, coordinates=coordinates, box=box,
tmp_item = Structures(structure_id=structure_id, time=time, coordinates=coordinates, box=box,
occupancy=occupancy, b_factor=b_factor, alternate_location=alternate_location, bioassembly=bioassembly)

if not is_all(atom_indices)*is_all(structure_indices):

tmp_item = extract_molsysmt_StructuresOld(tmp_item, atom_indices=atom_indices,
tmp_item = extract_molsysmt_Structures(tmp_item, atom_indices=atom_indices,
structure_indices=structure_indices, skip_digestion=True)

return tmp_item
Expand Down
Loading

0 comments on commit c6e2836

Please sign in to comment.