Source code for ndb_adapter.ndb

import requests
import ndb_adapter.report_parser as parser
from ndb_adapter.advanced_search_options import AdvancedSearchOptions
from ndb_adapter.dna_search_options import DnaSearchOptions
from ndb_adapter.ndb_base import NDBBase
from ndb_adapter.ndb_download import DownloadHelper, DownloadType
from ndb_adapter.rna_search_options import RnaSearchOptions
from ndb_adapter.search_result import SimpleResult, AdvancedResult
from ndb_adapter.summary_result import SummaryResult


[docs]class NDB(NDBBase): """Main class for search in NDB - all methods are static""" @staticmethod @staticmethod @staticmethod @staticmethod
[docs] def summary(structure_id: str) -> SummaryResult: """Summary search in NDb :param structure_id: structure NDB ID or PDB ID e.g. 4Z6C :type structure_id: str :return: search summary result :rtype: SummaryResult """ params = { 'searchTarget': structure_id } with requests.session() as session: resp = session.post(NDBBase._summaryUrl, data=params) text = resp.text report = parser.parse_summary(text) return report
@staticmethod
[docs] def download(structure_id: str, download_type: DownloadType=DownloadType.Pdb, save: bool=False, target_dir: str='') -> str: """Download PDB from NDB :param download_type: file download type (default value is DownloadType.PDB) :type download_type: DownloadType :param target_dir: where to save file (default value is current dir) :type target_dir: str :param save: tells if file should be saved or not (default value = False) :type save: bool :param structure_id: structure NDB ID or PDB ID e.g. 4Z6C :type structure_id: str :return: string or None :rtype: str """ return DownloadHelper.download(structure_id, download_type, save, target_dir)