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

smiles extra and decorator for rdkit functions #200

Closed
wants to merge 2 commits into from
Closed
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
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ be compatible with:
pip install "alphabase[stable]"
```

If you want to use strucutural information of aminoacids, you can install the dependencies by including the `smiles` extra:
``` bash
pip install "alphabase[smiles]"
```

NOTE: You might need to run `pip install -U pip` before installing
AlphaBase like this. Also note the double quotes `"`.

Expand Down
1 change: 1 addition & 0 deletions alphabase/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,5 @@
}
__extra_requirements__ = {
"development": "extra_requirements/development.txt",
"smiles": "extra_requirements/smiles.txt",
}
25 changes: 25 additions & 0 deletions alphabase/peptide/smiles.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import functools


def requires_rdkit(func):
@functools.wraps(func)
def wrapper(*args, **kwargs):
try:
from rdkit import Chem # noqa
except ImportError:
raise ImportError(
f"RDKit is required for the function '{func.__name__}'. "
"Please install it with 'pip install alphabase[smiles]'"
)
return func(*args, **kwargs)

return wrapper


@requires_rdkit
Copy link
Contributor

Choose a reason for hiding this comment

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

this is not code that is actually used, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes, just as a reference for @boopthesnoot

def rdkit_dependent_function(smiles):
from rdkit import Chem

# Your implementation using RDKit
mol = Chem.MolFromSmiles(smiles)
return mol
1 change: 1 addition & 0 deletions extra_requirements/smiles.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rdkit>=2024.3.3
Loading