Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example09 #113

Merged
merged 9 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 27 additions & 20 deletions chilife/chilife.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,7 @@ def create_dlibrary(
resname: str = None,
dihedrals: ArrayLike = None,
weights: ArrayLike = None,
sort_atoms = True,
permanent: bool = False,
default: bool = False,
force: bool = False,
Expand Down Expand Up @@ -649,7 +650,7 @@ def create_dlibrary(
"residue number"
)

struct, spin_atoms = pre_add_library(pdb, spin_atoms, uniform_topology=False)
struct, spin_atoms = pre_add_library(pdb, spin_atoms, uniform_topology=False, sort_atoms=sort_atoms)
res1 = struct.select_atoms(f'resnum {site1}')
res2 = struct.select_atoms(f'resnum {site2}')

Expand Down Expand Up @@ -769,6 +770,7 @@ def pre_add_library(
pdb: str,
spin_atoms: List[str],
uniform_topology: bool = True,
sort_atoms = True,
) -> Tuple[MDAnalysis.Universe, Dict]:
"""Helper function to sort PDBs, save spin atoms, update lists, etc. when adding a SpinLabel or dSpinLabel.

Expand All @@ -790,27 +792,32 @@ def pre_add_library(
spin_atoms : dict
Dictionary of spin atoms and weights if specified.
"""
# Sort the PDB for optimal dihedral definitions
pdb_lines, bonds = sort_pdb(pdb, uniform_topology=uniform_topology, return_bonds=True)
bonds = get_min_topol(pdb_lines, forced_bonds=bonds)

# Write a temporary file with the sorted atoms
if isinstance(pdb_lines[0], list):
with tempfile.NamedTemporaryFile(suffix=".pdb", mode="w+", delete=False) as tmpfile:
for i, model in enumerate(pdb_lines):
tmpfile.write(f"MODEL {i + 1}\n")
for atom in model:
tmpfile.write(atom)
tmpfile.write("ENDMDL\n")
else:
with tempfile.NamedTemporaryFile(suffix=".pdb", mode="w+", delete=False) as tmpfile:
for line in pdb_lines:
tmpfile.write(line)
if sort_atoms:
# Sort the PDB for optimal dihedral definitions
pdb_lines, bonds = sort_pdb(pdb, uniform_topology=uniform_topology, return_bonds=True)
bonds = get_min_topol(pdb_lines, forced_bonds=bonds)

# Write a temporary file with the sorted atoms
if isinstance(pdb_lines[0], list):
with tempfile.NamedTemporaryFile(suffix=".pdb", mode="w+", delete=False) as tmpfile:
for i, model in enumerate(pdb_lines):
tmpfile.write(f"MODEL {i + 1}\n")
for atom in model:
tmpfile.write(atom)
tmpfile.write("ENDMDL\n")
else:
with tempfile.NamedTemporaryFile(suffix=".pdb", mode="w+", delete=False) as tmpfile:
for line in pdb_lines:
tmpfile.write(line)

# Load sorted atom pdb using MDAnalysis and remove tempfile
struct = mda.Universe(tmpfile.name, in_memory=True)
struct.universe.add_bonds(bonds)
os.remove(tmpfile.name)
struct = mda.Universe(tmpfile.name, in_memory=True)
struct.add_bonds(bonds)
os.remove(tmpfile.name)
else:
struct = mda.Universe(pdb, in_memory=True)
bonds = chilife.guess_bonds(struct.atoms.positions, struct.atoms.types)
struct.add_bonds(bonds)

# Store spin atoms if provided
if spin_atoms is not None:
Expand Down
116 changes: 116 additions & 0 deletions examples/09 - Bifunctional Labels/09 - Bifunctional Labels.ipynb

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
57 changes: 57 additions & 0 deletions examples/09 - Bifunctional Labels/Exp_Data.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
19.04371135 0
19.52893153 0
20.01415171 0
20.49937088 0
20.98459106 0
21.46981124 0.000148602
21.95503143 0
22.44025161 0.001277658
22.9254718 0.001709512
23.41069198 0.002466733
23.89591216 0.006279774
24.38113132 0.011409769
24.86635151 0.014555304
25.35157169 0.014929992
25.83679188 0.01278915
26.32201206 0.008920883
26.80723225 0.004488191
27.29245243 0.001023366
27.77767261 0
28.26289177 0
28.74811196 0
29.23333214 0.000203712
29.71855233 0.00051705
30.20377251 0.000427106
30.68899269 1.6869E-05
31.17421288 0
31.65943306 0
32.14465222 0
32.62987241 0
33.11509259 0
33.60031278 0
34.08553296 0
34.57075314 0
35.05597333 0
35.54119351 0
36.02641267 0
36.51163286 0
36.99685304 0
37.48207322 0
37.96729341 0
38.45251359 0
38.93773378 0
39.42295396 0
39.90817312 0
40.39339331 0
40.87861349 0
41.36383367 0
41.84905386 0
42.33427404 0
42.81949423 0
43.30471441 0
43.78993357 0
44.27515376 0
44.76037394 0
45.24559412 0
45.73081431 0
46.21603449 0
30 changes: 29 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,34 @@
[project]
name = "chilife"
dynamic = ["version"]
description = 'A package for modeling non-canonical amino acid side chain ensembles.'
license= {name = 'GNU GPLv3', file = 'LICENSE'}
authors=[{name = 'Maxx Tessmer', email='[email protected]'},
{name = 'Stefan Stoll', email='[email protected]'}]
keywords=['Spin-label', 'EPR', 'DEER', 'PELDOR', 'Side-chain']
dynamic = ["version", "readme"]
requires-python = ">= 3.8,<=3.11"
dependencies = ['numpy>=1.23.0',
'scipy>=1.6.3',
'matplotlib>=3.3.4',
'numba>=0.57.0',
'mdanalysis>=2.0.0',
'tqdm>=4.45.0',
'pytest>=6.2.2',
'memoization>=0.3.1',
'argparse>=1.4.0',
'setuptools>=53.0.0',
'igraph>=0.11.2',
'rtoml>=0.9.0']

classifiers=['License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11']

[project.urls]
homepage = 'https://github.com/StollLab/chiLife'
documentation = "stolllab.github.io/chiLife/"

[tool.setuptools.dynamic]
version = {attr = "chilife.__version__"}
Expand Down
28 changes: 2 additions & 26 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,35 +23,11 @@ def __init__(self, *args, **kwargs):

setup(
name='chilife',
python_requires='>=3.8',
packages=['chilife'],
package_data={'chilife': ['data/*', 'data/*/*', 'data/*/*/*']},
scripts=['scripts/update_rotlib.py', 'scripts/oldProteinIC.py'],
license='GNU GPLv3',
license_files=('LICENSE'),
author='Maxx Tessmer',
author_email='[email protected]',
install_requires=['numpy>=1.23.0',
'scipy>=1.6.3',
'matplotlib>=3.3.4',
'numba>=0.57.0',
'mdanalysis>=2.0.0',
'tqdm>=4.45.0',
'pytest>=6.2.2',
'memoization>=0.3.1',
'argparse>=1.4.0',
'setuptools>=53.0.0',
'igraph>=0.11.2',
'rtoml>=0.9.0'],
url='https://github.com/StollLab/chiLife',
project_urls = {'Source': 'https://github.com/StollLab/chiLife'},
keywords=['Spin label', 'EPR', 'DEER', 'PELDOR', 'Side chain'],
description='A package for modeling non-canonical amino acid side chain ensembles.',
long_description=readme,
long_description_content_type='text/markdown',
cmdclass={'install': PostInstall},
classifiers=['License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11'])
cmdclass={'install': PostInstall})