Library implementing API for Basic Local Alignment Search Tool
API specification: https://ncbi.github.io/blast-cloud/dev/api.html
- Python >= 3.6
- requests 2.18.4
-
Create new instance of
BlastClientfrom BlastApi import BlastClient bc = BlastClient()
-
Launch a search using
BlastClient::search()methodrequest_id, estimated_time = bc.search('u00001', 'nt', 'blastn')
-
BlastClient::search()method will return tuple of(request_id, estimated_time).request_id- can be used to retrieve resultsestimated_time(RTOE) - estimated time in seconds until the search is completed
-
You can check the status of the search by using
BlastClient::check_submission_status()status = bc.check_submission_status(request_id)
Method will return
statusas one ofWAITING,UNKNOWN, orREADY. -
Once the search is finished, you may retrieve results by invoking
BlastClient::get_results()results = bc.get_results(request_id)
HTMLis default format of results -
BlastClient::wait_for_results()can be used as a combination ofBlastClient::check_submission_status()andBlastClient::get_results(). It'll wait until search is finished and retrieve results.results = bc.wait_for_results(request_id, estimated_time=estimated_time)
Note that
estimated_timeparameter is optional and doesn't need to be specified. Instead every 2 seconds method will check search status and when it'sREADYretrieve results
-
BlastClient::search()query- Search query.database- Name of existing database or one uploaded to blastdb_customprogramBLAST Program. One of:['blastn', 'megablast', 'blastp', 'blastx', 'tblastn', 'tblastx']filterLow complexity filtering.Fto disable.TorLto enable. Prepend “m” for mask at lookup (e.g.,mL)format_type- Report type. One of:['HTML', 'Text', 'XML', 'XML2', 'JSON2', 'Tabular']. Default:'HTML'.expect- Expect value. Number greater than zero.nucl_rewardReward for matching bases (BLASTN and megaBLAST). Integer greater than zero.gapcostsGap existence and extension costs. Tuple of two positive integers.matrixScoring matrix name. One of:['BLOSUM45', 'BLOSUM50', 'BLOSUM62', 'BLOSUM80', 'BLOSUM90', 'PAM250', 'PAM30' or 'PAM70']. Default:'BLOSUM62'hitlist_size- Number of databases sequences to keep. Integer greater than zero.descriptions- Number of descriptions to print (applies toHTMLandText). Integer greater than zero.alignmentsNumber of alignments to print (applies toHTMLandText). Integer greater than zero.ncbi_giShow NCBI GIs in report.'T'or'F'threshold- Neighboring score for initial words. Positive integer (BLASTP default is 11). Does not apply to BLASTN or MegaBLAST).word_size- Size of word for initial matches. Positive integer.composition_based_statistics- Composition based statistics algorithm to use. One of[0, 1, 2, 3]. See comp_based_stats in BLAST+ user manual for details.num_threads- Number of virtual CPUs to use. Integer greater than zero (default is 1). Supported only on the cloud
-
BlastClient::check_submission_status()request_id- ID of requested search
-
BlastClient::get_results()request_id- ID of requested searchformat_type- Report type. One of:['HTML', 'Text', 'XML', 'XML2', 'JSON2', 'Tabular']. Default:'HTML'.hitlist_size- Number of databases sequences to keep. Integer greater than zero.descriptions- Number of descriptions to print (applies toHTMLandText). Integer greater than zero.alignments- Number of alignments to print (applies toHTMLandText). Integer greater than zero.ncbi_gi- Show NCBI GIs in report.'T'or'F'format_object- Object type.SearchInfo(status check) orAlignment(report formatting). OnlyAlignmentis valid for retrieving results.results_file_path- Results relative file path (applies toXML2andJSON2).
-
BlastClient::wait_for_results()- The same as for
BlastClient::check_submission_status()andBlastClient::get_results()
- The same as for
Parameters in bold are required.