Closed bjonnh closed 9 years ago
Looks useful! I use imolecule as a front end to some crystallography software. I wrote an all-js interactive highlighter there:
What's your use case? Would it be more useful to highlight in Python notebook code, or to do it interactively with the output?
Either way, I like the idea. Regarding OB colors, I'd rather convert them to hex python side. It saves us from having to duplicate color data.
I use that to highlight substructures in compounds. I have a series of filters (smarts) and apply them to each molecules then display them. That said if you made the highlighter already, I may just tweak it.
Sounds like python functionality is the way to go.
Let's either add in a full list of color options, or edit this openbabel function to convert "green" to hex before sending to js. I like the idea of supporting arbitrary hex values, but either way works.
I made a better highlighter, now you can give the highlights with hex codes.
import pybel
import imolecule
mol = pybel.readstring("smi","OCN(CC)CCS")
pybel._operations['highlight'].Do(mol.OBMol, "[#6][#7] #FF0000")
pybel._operations['highlight'].Do(mol.OBMol, "[#1][#8] #0000FF")
pybel._operations['highlight'].Do(mol.OBMol, "[#16][#6] #00FF00")
imolecule.draw(mol, shader="phong",format="pybel")
This is cool!
The only things left are to revert the display_html
patch and remove all the whitespace edits (they gunk up commit history).
display_html
commit, you can just chop it off of your history with git reset --hard HEAD^ && git push -f origin develop
.%s/\t/ /g
and %s/\s\+$//g
. You may need to go in and make sure everything lines up after removing tabs - shouldn't take more than a minute.Should be ok, I rewrote history (bad I know…) but everything is fine now.
Can be used with pybel (or anything that sets the "color" property of atoms).
For now, only green is supported, I have to check openbabel source for a list of colors they allow.