Created
May 25, 2016 12:58
-
-
Save jhjensen2/b33616cb5df8578a7df047baae5ac86a to your computer and use it in GitHub Desktop.
Converts name to SMILES
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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