Thank you, that should do the trick for me! Suddenly I feel silly for asking. Im at a loss how I missed that.More
Upvote
VOTE
Downvote
In Python you could try pysmiles.
Starting from the SMILES description you should be able to create a NetworkX graph object with code along the lines of
from pysmiles import read_smiles
import networkx as nx
smiles = 'C1CC[13CH2]CC1C1CCCCC1'
mol = read_smiles(smiles)
In Python you could try pysmiles. Starting from the SMILES description you should be able to create a NetworkX graph object with code along the lines of
from pysmiles import read_smilesimport networkx as nxsmiles = 'C1CC[13CH2]CC1C1CCCCC1'mol = read_smiles(smiles)
In addition to the other good answers, I'd recommend rdkit, an open-source, freely available software for chemoinformatics. Most people use rdkit via its Python interface.
The license is quite permissive; you don't need to worry about what type of work (commercial, personal, or academic) you are doing.
The Python API makes using rdkit easy, but all the core functions are written C++, making it fast and efficient. The Python API provides access to these functions in Python, making it flexible and easy to learn. If you happen to be fluent in C++, a C++ API is available.
It does a whole lot more than convert SMILES to structures; see some examples here.
Here is one way to convert a SMILES to a structure in rdkit.
from rdkit import Chem
from rdkit.Chem import Draw
import matplotlib.pyplot as plt
%matplotlib inline
penicillin_g_smiles = 'CC1([C@@H](N2[C@H](S1)[C@@H](C2=O)NC(=O)Cc3ccccc3)C(=O)O)C'
penicillin_g = Chem.MolFromSmiles(penicillin_g_smiles)
Draw.MolToMPL(penicillin_g, size=(200, 200))
Here's a picture of the code and the resulting image.
In addition to the other good answers, I'd recommend rdkit, an open-source, freely available software for chemoinformatics. Most people use rdkit via its Python interface.
The license is quite permissive; you don't need to worry about what type of work (commercial, personal, or academic) you are doing.
The Python API makes using rdkit easy, but all the core functions are written C++, making it fast and efficient. The Python API provides access to these functions in Python, making it flexible and easy to learn. If you happen to be fluent in C++, a C++ API is available.
It does a whole lot more than convert SMILES to structures; see some examples here.
Here is one way to convert a SMILES to a structure in rdkit.
from rdkit import Chemfrom rdkit.Chem import Drawimport matplotlib.pyplot as plt%matplotlib inlinepenicillin_g_smiles = 'CC1([C@@H](N2[C@H](S1)[C@@H](C2=O)NC(=O)Cc3ccccc3)C(=O)O)C'penicillin_g = Chem.MolFromSmiles(penicillin_g_smiles)Draw.MolToMPL(penicillin_g, size=(200, 200))
Here's a picture of the code and the resulting image.
I'm surprised that you've had difficulty finding a toolkit - is it that the licence must be MIT or as permissive? I guess that you will be using this in software you are making, rather than a one-off data conversion?
For example, OpenBabel (C++), Chemistry Development Kit (Java), etc - in addition, the CDK can interface with R - would seem to suit your needs?
I'm surprised that you've had difficulty finding a toolkit - is it that the licence must be MIT or as permissive? I guess that you will be using this in software you are making, rather than a one-off data conversion?
For example, OpenBabel (C++), Chemistry Development Kit (Java), etc - in addition, the CDK can interface with R - would seem to suit your needs?
@BootstrapBill Hah! Geoff is right - probably it is easier for me to find them since I already know about them! :) Thats the difficulty of answering questions, of course. I was really just checking that you hadnt already found and rejected the ones on the wikipedia list.More
at the moment it is just for a one-off data conversion. at some point later it might be in the software, but then it would be okay to spend some money. also Im suprise that youre surprised - may I ask what search terms you used?More
Upvote
VOTE
Downvote
For those who want to convert a few SMILES strings to images, you can also use the CDK 1.5-based Depict utility from John May (www.simolecule.com/cdkdepict/, GitHub). It provides various options and outputs Scalable Vector Graphics (which can be easily converted into other formats).
Thus, with the basic web API you can create a script to convert all SMILES strings too, e.g. using the RCurl package. This StackOverflow post explains how you convert the SVG to other formats.
However, since you probably prefer a pure R-based solution, please do have a look at the rcdk package.
For those who want to convert a few SMILES strings to images, you can also use the CDK 1.5-based Depict utility from John May (www.simolecule.com/cdkdepict/, GitHub). It provides various options and outputs Scalable Vector Graphics (which can be easily converted into other formats).
Thus, with the basic web API you can create a script to convert all SMILES strings too, e.g. using the RCurl package. This StackOverflow post explains how you convert the SVG to other formats.
However, since you probably prefer a pure R-based solution, please do have a look at the rcdk package.
The CDK Smiles Depict tool converts from SMILES to 2D Structure (as mentioned above). The URl in a previous answer looks obsolete, but the tool can be found here More
According to the website, Open Babel should do the trick: Documentation - SMILES, Sourceforge.
For example, the following code will give you a neat SVG file of the molecule benzene:
If you experience problems using it, you are welcome to ask more specifically.
Alternatively, you can use a web-query from the national cancer institute. It is easily accessible by the following code
For example: benzene,
"structure identifier"=c1ccccc1,"representation"=image.Another open source solution, where you can directly export the structure into a molecular editor is Avogadro. (It uses Open Babel though.)
Depending on the actual problem, however, there might already be more advanced routines.
According to the website, Open Babel should do the trick: Documentation - SMILES, Sourceforge.
For example, the following code will give you a neat SVG file of the molecule benzene:
If you experience problems using it, you are welcome to ask more specifically.
Alternatively, you can use a web-query from the national cancer institute. It is easily accessible by the following code
For example: benzene,
"structure identifier"=c1ccccc1,"representation"=image.Another open source solution, where you can directly export the structure into a molecular editor is Avogadro. (It uses Open Babel though.)
Depending on the actual problem, however, there might already be more advanced routines.
More
VOTE
VOTE
In Python you could try pysmiles.
Starting from the SMILES description you should be able to create a NetworkX graph object with code along the lines of
In Python you could try pysmiles.
Starting from the SMILES description you should be able to create a NetworkX graph object with code along the lines of
More
VOTE
In addition to the other good answers, I'd recommend
rdkit, an open-source, freely available software for chemoinformatics. Most people userdkitvia its Python interface.Here are some
rdkitbasics:rdkiteasy, but all the core functions are written C++, making it fast and efficient. The Python API provides access to these functions in Python, making it flexible and easy to learn. If you happen to be fluent in C++, a C++ API is available.Here is one way to convert a SMILES to a structure in rdkit.
Here's a picture of the code and the resulting image.
In addition to the other good answers, I'd recommend
rdkit, an open-source, freely available software for chemoinformatics. Most people userdkitvia its Python interface.Here are some
rdkitbasics:rdkiteasy, but all the core functions are written C++, making it fast and efficient. The Python API provides access to these functions in Python, making it flexible and easy to learn. If you happen to be fluent in C++, a C++ API is available.Here is one way to convert a SMILES to a structure in rdkit.
Here's a picture of the code and the resulting image.
More
VOTE
VOTE
I'm surprised that you've had difficulty finding a toolkit - is it that the licence must be MIT or as permissive? I guess that you will be using this in software you are making, rather than a one-off data conversion?
For example, OpenBabel (C++), Chemistry Development Kit (Java), etc - in addition, the CDK can interface with R - would seem to suit your needs?
I'm surprised that you've had difficulty finding a toolkit - is it that the licence must be MIT or as permissive? I guess that you will be using this in software you are making, rather than a one-off data conversion?
For example, OpenBabel (C++), Chemistry Development Kit (Java), etc - in addition, the CDK can interface with R - would seem to suit your needs?
More
VOTE
VOTE
VOTE
VOTE
For those who want to convert a few SMILES strings to images, you can also use the CDK 1.5-based Depict utility from John May (www.simolecule.com/cdkdepict/, GitHub). It provides various options and outputs Scalable Vector Graphics (which can be easily converted into other formats).
For example, caffeine with title: https://www.simolecule.com/cdkdepict/depict/bow/svg?smi=CN1C%3DNC2%3DC1C(%3DO)N(C(%3DO)N2C)C%20caffeine&abbr=on&hdisp=bridgehead&showtitle=true&zoom=1.6&annotate=none
Thus, with the basic web API you can create a script to convert all SMILES strings too, e.g. using the RCurl package. This StackOverflow post explains how you convert the SVG to other formats.
However, since you probably prefer a pure R-based solution, please do have a look at the rcdk package.
For those who want to convert a few SMILES strings to images, you can also use the CDK 1.5-based Depict utility from John May (www.simolecule.com/cdkdepict/, GitHub). It provides various options and outputs Scalable Vector Graphics (which can be easily converted into other formats).
For example, caffeine with title: https://www.simolecule.com/cdkdepict/depict/bow/svg?smi=CN1C%3DNC2%3DC1C(%3DO)N(C(%3DO)N2C)C%20caffeine&abbr=on&hdisp=bridgehead&showtitle=true&zoom=1.6&annotate=none
Thus, with the basic web API you can create a script to convert all SMILES strings too, e.g. using the RCurl package. This StackOverflow post explains how you convert the SVG to other formats.
However, since you probably prefer a pure R-based solution, please do have a look at the rcdk package.
More
VOTE
VOTE
VOTE