为生物学家、生物信息学等创建的http://ndbserver.rutgers.edu/适配器。
ndb_adapter的Python项目详细描述
适配器,用于直接从python(3.*)轻松访问ndb资源。
用法
适配器提供4种类型的搜索:摘要、高级、DNA和RNA。
小结
要获取结构摘要,请键入:
>>>fromndb_adapterimportNDB>>>res=NDB.summary('4Z4B')>>>res.ndb_id'4Z4B'>>>res.title'2-PYRIDYL HOECHST - A NEW GENERATION DNA-BINDING RADIOPROTECTOR'>>>res.description"DNA (5'-D(*CP*GP*CP*AP*AP*AP*TP*TP*TP*GP*CP*G)-3')">>>res.get_dict(){'Molecular Description':"DNA (5'-D(*CP*GP*CP*AP*AP*AP*TP*TP*TP*GP*CP*G)-3')",...}
如您所见,一些属性可用于摘要结果。他们的全部名单是 here。
高级搜索
要执行高级搜索,您应该使用AdvancedOptions 对象并将其作为参数从ndb传递给advanced_search函数, 但这不是必需的。那个对象有很多setters 用于修改搜索查询。看看他们,看看你想要什么。也有可能 更改结果report type, 只需将所需类型传递到构造函数。
>>>fromndb_adapterimport*# options preparation>>>opt=AdvancedSearchOptions()# default report type NDBStatus>>>opt.set_crystal_structure(yes_no_ignore=YesNoIgnore.Yes)# default and_or=AndOr.And>>>opt.set_dna(and_or=AndOr.Or,yes_no_ignore=YesNoIgnore.Yes)# search>>>res=NDB.advanced_search(opt)>>>print(res.count)4695>>>print(res.report)[<ndb_adapter.search_report.NDBStatusReportobjectat0x00000248F9E02128>,...]# working on result>>>first=res.report[0]# first structure from search# if you want have annotations in IDE (i.e. Pycharm) do something like this:>>>first=res.report[0]# type: ReportType.NDBStatus>>>print(first.title)"2-Pyridyl Hoechst - a New Generation DNA-Binding Radioprotector"
每个报表类型的结果都不同-您可以检查它们的properties或使用类型。
其中一些有statistics 另外,例如:
>>>fromndb_adapterimport*>>>opt=AdvancedSearchOptions(ReportType.RNABasePairRelFreq)>>>opt.set_hybrid(yes_no_ignore=YesNoIgnore.Yes)>>>res=NDB.advanced_search(opt)>>>print(res.statistics)Min:{'Relative cWW':0.5,'Relative tWW':0.0,'Relative cHS':0.0,'Relative tWS':0.0,...}Max:{'Relative cWW':1.0,'Relative tWW':0.05,'Relative cHS':0.06,'Relative tWS':0.06,...}Mean:{'Relative cWW':0.8,'Relative tWW':0.01,'Relative cHS':0.01,'Relative tWS':0.01,...}StandardDeviation:{'Relative cWW':0.12,'Relative tWW':0.01,'Relative cHS':0.02,'Relative tWS':0.02,...}>>print(res.statistics.min){'Relative tWS':0.0,'Relative tWW':0.0,'Relative cHH':0.0,'Relative cWW':0.5,...}
DNA搜索
Dna search 与高级搜索非常相似,但使用DnaSearchOptions和更小的 设定值的数量。
>>>fromndb_adapterimport*# options preparation>>>opt=DnaSearchOptions()>>>opt.set_structural_features(StructuralFeatures.A_DNA)# search>>>result=NDB.dna_search(opt)>>>print(result.count)393>>>str(result.report)[<ndb_adapter.search_report.SimpleReportobjectat0x00000152D0FCB438>,...]# working on result>>>first=result.report[0]# type: SimpleReport>>>print(first.title)"Crystal structure of 60-mer BFDV Capsid Protein ..."
rna搜索
Rna search 就像DNA搜索一样。选项:RnaSearchOptions。
>>>fromndb_adapterimport*# search>>>result=NDB.rna_search()# default is empty RnaSearchOptions object>>>print(result.count)3014>>>str(result.report)[<ndb_adapter.search_report.SimpleReportobjectat0x0000018B3C877E48>,...]# working on result>>>first=result.report[0]# type: SimpleReport>>>print(first.title)"Crystal structure of the bacterial A1408C-mutant ..."
结构下载
几乎每个搜索结果都可以下载相关文件(.pdb, .cif, .xml etc.) 缓冲或保存
>>>fromndb_adapterimportNDB>>>res=NDB.summary('4Z4B')>>>res.download()# .pdb is default"HEADER DNA 01-APR-15 4Z4B ...">>>fromndb_adapterimportDownloadType>>>res.download(download_type=DownloadType.Cif)'data_4Z4B\n# \n_entry.id 4Z4B ...'>>>res=NDB.advanced_search()>>>res.download(save=True)# saves n files in current directory>>>res.download(save=True,target_dir='/home/user/Downloads/')# saves n files in ~/Downloads/>>>res.report[0].download(save=True)# saves first structure file in current directory
您也可以在一行中搜索和下载:
>>>fromndb_adapterimportNDB>>>res=NDB.download('4Z4B')# like above .pdb is default"HEADER DNA 01-APR-15 4Z4B ..."# save and target dir is also available
安装
要安装,只需:
$ pip install ndb_adapter
许可证
软件是根据麻省理工学院的许可证发行的。