Package: ndb_adapter
Adapter for easy access to NDB resources directly from python (3.*).UsageAdapter offers 4 types of search: summary, advanced, dna and rna.SummaryTo get summary of structure, type:>>>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')",...}As you see some properties are available for summary result. Full list of them ishere.Advanced searchTo perform advanced search you should useAdvancedOptionsobject and pass it as argument toadvanced_searchfunction from NDB,
however it’s not required. That object has a lot ofsettersfor modify search query. Look at them to search what you want. It’s also possible to
change resultreport type,
just pass wanted type into constructor.>>>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"Every report type result is different - you can examine theirspropertiesor use typing.Some of them hasstatisticsalso, for example:>>>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 searchDna searchis very similar to advanced search, but withDnaSearchOptionsand smaller
amount of setters.>>>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 searchRna searchis just like dna search. Options: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 ..."Structure DownloadAlmost on every result of search you can download related files(.pdb, .cif, .xml etc.)to buffer or save.>>>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 directoryYou can also search and download in one line:>>>fromndb_adapterimportNDB>>>res=NDB.download('4Z4B')# like above .pdb is default"HEADER DNA 01-APR-15 4Z4B ..."# save and target dir is also availableRequirementspython 3.*requestsxlrdInstallationTo install, simply:$pipinstallndb_adapterDocumentationDocumentation is available athttps://michsior14.github.io/ndb_adapter/.LicenceSoftware is distributed under the MIT Licence.