CIRpy
CIRpy copied to clipboard
Suggestion of code sample: get SMILES of list of molecules
Dear CIRpy developers, I would like to give you a code sample that could be useful for many people and could be provided in some form in the basic documentation (or even integrated as a function). This simple code gets a list of molecule names in a text file and outputs their SMILES in the command prompt.
#!/usr/bin/python
# -*- coding: Latin-1 -*-
# ----- Get SMILES from list of names -----
#
import cirpy
with open("names.txt") as file:
data = file.readlines()
for molecule in data:
name = molecule.rstrip("\n\r")
SMILES = cirpy.resolve(name, 'smiles')
print name, SMILES