Skip to content

Instantly share code, notes, and snippets.

@pckujawa
Created March 29, 2012 02:30
Show Gist options
  • Save pckujawa/2232604 to your computer and use it in GitHub Desktop.
Save pckujawa/2232604 to your computer and use it in GitHub Desktop.
telling python how to create a dict out of your object (via interpreter on KEGG web API data)
>>> from SOAPpy import WSDL
>>> wsdl = 'http://soap.genome.jp/KEGG.wsdl'
>>> serv = WSDL.Proxy(wsdl)
>>> pathways = serv.list_pathways('map')
>>> ps=pathways
>>> ps[0]
<SOAPpy.Types.structType item at 37525944>: {'definition': 'Glycolysis / Gluconeogenesis - Reference pathway', 'entry_id': 'path:map00010'}
>>> ps[0].__dict__
{'_attrs': {},
'_cache': None,
'_data': None,
'_keyord': [u'entry_id', u'definition'],
'_name': u'item',
'_ns': u'SOAP/KEGG',
'_type': 'struct',
'_typed': 1,
u'definition': 'Glycolysis / Gluconeogenesis - Reference pathway',
u'entry_id': 'path:map00010'}
>>> dict(ps[0])
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
ValueError: dictionary update sequence element #0 has length 13; 2 is required
>>> dict([ps[0]])
{'path:map00010': 'Glycolysis / Gluconeogenesis - Reference pathway'}
@pckujawa
Copy link
Author

The gist is, I assume, the keyord member in the class - I assume it tells python how to create a dict (i.e. use entry_id as the key and definition as the value).

For KEGG info, see http://www.kegg.jp/kegg/soap/doc/keggapi_manual.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment