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

moltosmiles function? #23

Open
richardskim111 opened this issue Jul 24, 2020 · 3 comments
Open

moltosmiles function? #23

richardskim111 opened this issue Jul 24, 2020 · 3 comments
Labels
enhancement New feature or request

Comments

@richardskim111
Copy link
Contributor

Hi! I'm new to MolecularGraph.jl. Does it currently support a function to convert a GraphMol instance into a SMILES string?

@mojaie
Copy link
Owner

mojaie commented Jul 25, 2020

Thank you for your interest.
Unfortunately, GraphMol to SMILES converter is not supported yet.

@hhaensel
Copy link
Contributor

I just added a PR that supports molecule generation from inchi strings. During my research for a solution I stumbled across OpenBabel which is an amazing ChemConverter.
If you install it on your system, you can easily convert between any file formats, e.g.

babel_cmd = raw"C:\Temp\OpenBabel\obabel.exe" # or wherever your babel is located
smiles = rstrip(read(`$babel_cmd -:"InChI=1/C2H6O/c1-2-3/h3H,2H2,1H3" -iinchi -osmi`, String))
# "CCO"

using MolecularGraph

mol = smilestomol("CCO")
sdf = printv2mol(mol)
smiles = rstrip(read(`$babel_cmd -:"$sdf" -imol -osmi`, String))
# "CCO"

This still has some overhead in calling an external program but is still pretty fast.

It would be tempting to build an OpenBabel.jl package ...

@timoleistner
Copy link

Adding to @hhaensel's comment, with openbabel_jll one can use the ExecutableProduct, removing the overhead of calling an external program:

using openbabel_jll
inchi = "InChI=1/C2H6O/c1-2-3/h3H,2H2,1H3"
smiles = rstrip(readchomp(`$(obabel()) -:$inchi -i inchi -o smiles`))

I would love to see this approach applied more broadly in this package to enable more flexible format conversion.

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

No branches or pull requests

4 participants