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

Easy creation of ResidueChemTemplates #223

Merged
merged 4 commits into from
Nov 5, 2024
Merged

Conversation

diogomart
Copy link
Contributor

The default dict from the meeko data folder ("residue_chem_templates.json") can be loaded with

templates = ResidueChemTemplates.create_from_defaults()

Additional templates can be added with

templates.add_json_file("NAKB_templates")

it looks for files in the current working directory, and in the meeko data folder where "residue_chem_templates.json" and "NAKB_templates.json" are currently located. For files in the meeko data folder the ".json" suffix is optional, as per the example above.

templates = ResidueChemTemplates.create_from_defaults()
templates.add_json_file("NAKB_templates")
@diogomart diogomart requested a review from rwxayheee November 5, 2024 08:23
@diogomart
Copy link
Contributor Author

Additionally, this PR deletes old data files that are no longer in use. It also deletes a few methods in "PDBQTReceptor.py" that were used for receptor preparation before the chorizos (now polymers) were created. I tested adding interaction fingerprints to vina results with ringtail, and that worked. I tested ringtail because ringtail depends on PDBQTReceptor.py to add interactions.

Copy link
Contributor

@rwxayheee rwxayheee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good, thanks!

@rwxayheee
Copy link
Contributor

rwxayheee commented Nov 5, 2024

Works for Python3.10. There's a small problem with importlib.resources.files (maybe only with Python3.9):

/Users/amyhe/micromamba/envs/meeko_tutorial_py39/bin/mk_prepare_receptor.py:4: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
  __import__('pkg_resources').require('meeko==0.6.0a3')
Traceback (most recent call last):
  File "/Users/amyhe/micromamba/envs/meeko_tutorial_py39/bin/mk_prepare_receptor.py", line 7, in <module>
    exec(compile(f.read(), __file__, 'exec'))
  File "/Users/amyhe/Downloads/tutorial2/Meeko/scripts/mk_prepare_receptor.py", line 12, in <module>
    from meeko.reactive import atom_name_to_molsetup_index, assign_reactive_types_by_index
  File "/Users/amyhe/Downloads/tutorial2/Meeko/meeko/__init__.py", line 28, in <module>
    from .polymer import Polymer
  File "/Users/amyhe/Downloads/tutorial2/Meeko/meeko/polymer.py", line 34, in <module>
    data_path = resources.files("meeko.data")
  File "/Users/amyhe/micromamba/envs/meeko_tutorial_py39/lib/python3.9/importlib/resources.py", line 147, in files
    return _common.from_package(_get_package(package))
  File "/Users/amyhe/micromamba/envs/meeko_tutorial_py39/lib/python3.9/importlib/_common.py", line 14, in from_package
    return fallback_resources(package.__spec__)
  File "/Users/amyhe/micromamba/envs/meeko_tutorial_py39/lib/python3.9/importlib/_common.py", line 18, in fallback_resources
    package_directory = pathlib.Path(spec.origin).parent
  File "/Users/amyhe/micromamba/envs/meeko_tutorial_py39/lib/python3.9/pathlib.py", line 1082, in __new__
    self = cls._from_parts(args, init=False)
  File "/Users/amyhe/micromamba/envs/meeko_tutorial_py39/lib/python3.9/pathlib.py", line 707, in _from_parts
    drv, root, parts = self._parse_args(args)
  File "/Users/amyhe/micromamba/envs/meeko_tutorial_py39/lib/python3.9/pathlib.py", line 691, in _parse_args
    a = os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not NoneType

bfc2a2e uses the importlib_resources backport as a walkaround for py3.9.

50f9c29 is a small fix for #221

--write_pdb uses only first character of filename
@rwxayheee rwxayheee merged commit d33aed5 into develop Nov 5, 2024
1 check passed
@diogomart
Copy link
Contributor Author

importlib_resources is not on standard library, and importlib.resources is working for me on python 3.9.20. Could you double check?

@rwxayheee
Copy link
Contributor

rwxayheee commented Nov 5, 2024

It didn't work on Mac with Python 3.9.20. Maybe it's OS specific. Is the backport not a default library on Linux?

importlib.resources is introduced in Py3.9. It also won't work with earlier python.

@diogomart
Copy link
Contributor Author

importlib.resources doesn't work on 3.8, and some of the type hints we are using also don't work on 3.8. So we should restrict to python3.9 or later anyway.

importlib_resources is not standard on linux. At least not with python packaged by conda-forge, I don't know if that makes a difference. So on a Mac, Python3.9 comes with importlib_resources but not with importlib.resources? If that's the case, which is weird, we could simply

try:
    from importlib.resources import files
except:
    from importlib_resources import files

@diogomart diogomart deleted the easy_load_res_templates branch November 6, 2024 22:34
@diogomart
Copy link
Contributor Author

Just for the record, we settled on #225 a0193ab

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants