BRENDAのWebserviceを使う
酵素情報データベースBRENDAは今年から結構まともなWebserviceを提供している。
http://www.brenda-enzymes.info/soap/
上記ページではPHPとPythonでの使用例を挙げてくれている。
Pythonからの使用例中では大概返ってくる型がdictionaryになっているのだが、自分がやってみたところ、SOAPのオブジェクトがリストで返ってくる。
そこで下記のような関数を噛ませる必要があるように思うので晒します。
from SOAPpy import WSDL wsdl = 'http://www.brenda-enzymes.org/soap/brenda.wsdl' serv = WSDL.Proxy(wsdl) def getDic(soap_object): attributes = getattr(soap_object, 'item') dictionary = {} for attribute in attributes: key = getattr(attribute, 'key') value = getattr(attribute, 'value') dictionary[key] = value return dictionary soap_objects = serv.getKeggPathway({'ecNumber':'1.1.1.2'}) results = [] for soap_object in soap_objects: dic = getDic(soap_object) results.append(dic) print results
BRENDAはなぜdictionaryが返ってくると言っているのだろう?
SOAPオブジェクトが返ってくるのオレの環境だけ?