Skip to content

Instantly share code, notes, and snippets.

@jhjensen2
Created May 25, 2016 12:58
Show Gist options
  • Save jhjensen2/b33616cb5df8578a7df047baae5ac86a to your computer and use it in GitHub Desktop.
Save jhjensen2/b33616cb5df8578a7df047baae5ac86a to your computer and use it in GitHub Desktop.
Converts name to SMILES
import subprocess,sys
filename = sys.argv[1]
input = open(filename, "r+")
output = open(filename+".smiles", "w+")
for line in input:
words = line.split()
name = words[0]
nameurl = name.replace("[","%5B")
nameurl = nameurl.replace("]","%5D")
url="https://cactus.nci.nih.gov/chemical/structure/"+nameurl+"/smiles"
smiles = subprocess.check_output(['curl',url])
str = name + " " + smiles
output.write(str)
output.write("\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment