simonboothroyd / plotmol Goto Github PK
View Code? Open in Web Editor NEWInteractive plotting of data annotated with molecule structures.
License: MIT License
Interactive plotting of data annotated with molecule structures.
License: MIT License
It would be great to expose other sources of data that get passed to ColumnDataSource
like some sort of molecule title, so that a custom tooltip_template
could take advantage of them.
Line 103 in 19a0aa8
def custom_tooltip_template() -> str:
"""Returns the a custom html based template to use for the figure hover pop-up with the molecule image and name."""
return """
<div>
<div>
<img src="@image" ></img>
</div>
<div>
<span style="font-size: 10px; color: #696;">$molecule_name</span>
</div>
</div>
"""
I believe this'll only work with Python 3.8+ due to Literal
:
ImportError: cannot import name 'Literal' from 'typing'
The library can no longer be installed with pip, directly from GitHub. It's probably related to the latest changes to the pyproject.toml file.
mkdir plotmol-pip-install-test && cd plotmol-pip-install-test
python -m venv .venv
source .venv/bin/activate
pip install git+https://github.com/SimonBoothroyd/plotmol.git
And we get:
Collecting git+https://github.com/SimonBoothroyd/plotmol.git
Cloning https://github.com/SimonBoothroyd/plotmol.git to /tmp/pip-req-build-c7b87b4s
Running command git clone --filter=blob:none --quiet https://github.com/SimonBoothroyd/plotmol.git /tmp/pip-req-build-c7b87b4s
Resolved https://github.com/SimonBoothroyd/plotmol.git to commit 4490e2c4aea4a035357049e0598cecd2a00c02e0
Installing build dependencies ... done
Getting requirements to build wheel ... error
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> [93 lines of output]
Traceback (most recent call last):
File "/tmp/pip-build-env-v7yxd7wt/overlay/lib/python3.11/site-packages/setuptools/config/expand.py", line 80, in __getattr__
return next(
^^^^^
File "/tmp/pip-build-env-v7yxd7wt/overlay/lib/python3.11/site-packages/setuptools/config/expand.py", line 81, in <genexpr>
ast.literal_eval(value)
File "/usr/lib/python3.11/ast.py", line 110, in literal_eval
return _convert(node_or_string)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/ast.py", line 109, in _convert
return _convert_signed_num(node)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/ast.py", line 83, in _convert_signed_num
return _convert_num(node)
^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/ast.py", line 74, in _convert_num
_raise_malformed_node(node)
File "/usr/lib/python3.11/ast.py", line 71, in _raise_malformed_node
raise ValueError(msg + f': {node!r}')
ValueError: malformed node or string on line 10: <ast.Subscript object at 0x7fe73052b400>
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/tmp/pip-build-env-v7yxd7wt/overlay/lib/python3.11/site-packages/setuptools/config/expand.py", line 192, in read_attr
return getattr(StaticModule(module_name, spec), attr_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/pip-build-env-v7yxd7wt/overlay/lib/python3.11/site-packages/setuptools/config/expand.py", line 86, in __getattr__
raise AttributeError(f"{self.name} has no attribute {attr}") from e
AttributeError: plotmol has no attribute __version__
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/whoeverest/Code/plotmol-test/.venv/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
main()
File "/home/whoeverest/Code/plotmol-test/.venv/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/whoeverest/Code/plotmol-test/.venv/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
return hook(config_settings)
^^^^^^^^^^^^^^^^^^^^^
File "/tmp/pip-build-env-v7yxd7wt/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 325, in get_requires_for_build_wheel
return self._get_build_requires(config_settings, requirements=['wheel'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/pip-build-env-v7yxd7wt/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 295, in _get_build_requires
self.run_setup()
File "/tmp/pip-build-env-v7yxd7wt/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 311, in run_setup
exec(code, locals())
File "<string>", line 1, in <module>
File "/tmp/pip-build-env-v7yxd7wt/overlay/lib/python3.11/site-packages/setuptools/__init__.py", line 103, in setup
return distutils.core.setup(**attrs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/pip-build-env-v7yxd7wt/overlay/lib/python3.11/site-packages/setuptools/_distutils/core.py", line 159, in setup
dist.parse_config_files()
File "/tmp/pip-build-env-v7yxd7wt/overlay/lib/python3.11/site-packages/setuptools/dist.py", line 627, in parse_config_files
pyprojecttoml.apply_configuration(self, filename, ignore_option_errors)
File "/tmp/pip-build-env-v7yxd7wt/overlay/lib/python3.11/site-packages/setuptools/config/pyprojecttoml.py", line 66, in apply_configuration
config = read_configuration(filepath, True, ignore_option_errors, dist)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/pip-build-env-v7yxd7wt/overlay/lib/python3.11/site-packages/setuptools/config/pyprojecttoml.py", line 131, in read_configuration
return expand_configuration(asdict, root_dir, ignore_option_errors, dist)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/pip-build-env-v7yxd7wt/overlay/lib/python3.11/site-packages/setuptools/config/pyprojecttoml.py", line 156, in expand_configuration
return _ConfigExpander(config, root_dir, ignore_option_errors, dist).expand()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/pip-build-env-v7yxd7wt/overlay/lib/python3.11/site-packages/setuptools/config/pyprojecttoml.py", line 204, in expand
self._expand_all_dynamic(dist, package_dir)
File "/tmp/pip-build-env-v7yxd7wt/overlay/lib/python3.11/site-packages/setuptools/config/pyprojecttoml.py", line 249, in _expand_all_dynamic
version=self._obtain_version(dist, package_dir),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/pip-build-env-v7yxd7wt/overlay/lib/python3.11/site-packages/setuptools/config/pyprojecttoml.py", line 298, in _obtain_version
return _expand.version(self._obtain(dist, "version", package_dir))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/pip-build-env-v7yxd7wt/overlay/lib/python3.11/site-packages/setuptools/config/pyprojecttoml.py", line 287, in _obtain
return self._expand_directive(
^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/pip-build-env-v7yxd7wt/overlay/lib/python3.11/site-packages/setuptools/config/pyprojecttoml.py", line 281, in _expand_directive
return _expand.read_attr(directive["attr"], package_dir, root_dir)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/pip-build-env-v7yxd7wt/overlay/lib/python3.11/site-packages/setuptools/config/expand.py", line 195, in read_attr
module = _load_spec(spec, module_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/pip-build-env-v7yxd7wt/overlay/lib/python3.11/site-packages/setuptools/config/expand.py", line 215, in _load_spec
spec.loader.exec_module(module) # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen importlib._bootstrap_external>", line 940, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/tmp/pip-req-build-c7b87b4s/plotmol/__init__.py", line 8, in <module>
from ._plotmol import InputSizeError, default_tooltip_template, scatter
File "/tmp/pip-req-build-c7b87b4s/plotmol/_plotmol.py", line 4, in <module>
import bokeh.models
ModuleNotFoundError: No module named 'bokeh'
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
Plotmol will currently draw multiple molecules in the tooltip image above each other it would be great to have the option to draw the molecules side by side as well. For this we could try and split the molecule using Chem.GetMolFrags(rdkit_mol, asMols=True)
and if we have more than one molecule we can break up the SVG into a grid and rdkit should work out where to place the molecules automatically.
rdkit_mol = Chem.RemoveHs(Chem.MolFromSmiles(smiles))
rdkit_mol = Draw.PrepareMolForDrawing(rdkit_mol, forceCoords=True)
mols = Chem.GetMolFrags(rdkit_mol, asMols=True)
if len(mols) == 2:
drawer = Draw.rdMolDraw2D.MolDraw2DSVG(400, 200, 200, 200)
drawer.DrawMolecules(mols)
else:
drawer = Draw.rdMolDraw2D.MolDraw2DSVG(400, 200)
drawer.DrawMolecule(rdkit_mol)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.