Skip to content

Instantly share code, notes, and snippets.

Created June 21, 2012 21:47
Show Gist options
  • Save anonymous/2968739 to your computer and use it in GitHub Desktop.
Save anonymous/2968739 to your computer and use it in GitHub Desktop.
{
"Chemical JSON": 0,
"name": ""2-thiouridine"",
"formula": "C 9 N 2 O 5 S 1",
"inchi": "InChI=1S/C9H12N2O5S/c12-3-4-6(14)7(15)8(16-4)11-2-1-5(13)10-9(11)17/h1-2,4,6-8,12,14-15H,3H2,(H,10,13,17)",
"atoms": {
"elements": [6, 7, 8, 6, 6, 6, 6, 6, 8, 7, 16, 6, 8, 6, 6, 8, 8],
"coords": {
"3d": [
12.0825, 1.1289, 0,
12.0825, 1.9539, 0,
11.4151, 0.6439, 0,
12.75, 0.6439, 0,
12.797, 2.3664, 0,
11.3681, 2.3664, 0,
11.67, -0.1407, 0,
12.495, -0.1407, 0,
13.5346, 0.8989, 0,
12.797, 3.1914, 0,
13.5115, 1.9539, 0,
11.3681, 3.1914, 0,
12.98, -0.8081, 0,
12.0825, 3.6039, 0,
11.1851, -0.8081, 0,
11.5207, -1.5618, 0,
12.0825, 4.4289, 0
]
}
},
"bonds": {
"connections": [
0, 1,
0, 2,
0, 3,
1, 4,
1, 5,
2, 6,
3, 7,
3, 8,
4, 9,
4, 10,
5, 11,
6, 14,
7, 12,
9, 13,
13, 16,
6, 7,
11, 13,
14, 15
],
"order": [1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 2, 1, 1, 1]
}
}
Traceback (most recent call last):
File "writerFail.py", line 9, in <module>
json.loads(f.writeString())
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py", line 326, in loads
return _default_decoder.decode(s)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 360, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 376, in raw_decode
obj, end = self.scan_once(s, idx)
ValueError: Expecting , delimiter: line 3 column 13 (char 36)
import urllib2
import chemkit
f = chemkit.MoleculeFile()
f.setFormat('sdf')
f.readString(urllib2.urlopen('http://www.ebi.ac.uk/chebi/saveStructure.do?defaultImage=true&chebiId=60731&imageId=0').read())
f.setFormat('cjson')
import json
json.loads(f.writeString())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment