NCBI Blast API 的调用

由 admin 发布

介绍

在NCIBI的Develop版块中,含有官方的APIs调用方法,包括了Entrez Programming Utilities (E-utilities)、BLAST URL API、PubChem Power User Gateway (PUG)、PubMed Central (PMC) APIs。

因此,NCBI的BLAST比对不仅有网页端的在线程序,也含有本地脚本的使用方法。本篇文章着重介绍Blast比对的方法。

使用方法

NCBI Blast API调用的官网文档

相关参数:

ParameterDefinitionTypeCMDAllowed values
QUERYSearch queryStringPut *Accession, GI, or FASTA.
DATABASEBLAST databaseStringPut *Database from appendix 2 or one uploaded to blastdb_custom (see appendix 4)
PROGRAMBLAST programStringPut *One of blastn, blastp, blastx, tblastn, tblastx. To enable megablast, use PROGRAM=blastn&MEGABLAST=on.
FILTERLow complexity filteringStringPutF to disable. T or L to enable. Prepend “m” for mask at lookup (e.g., mL)
FORMAT_TYPEReport typeStringPut, GetHTML, Text, XML, XML2, JSON2, or Tabular. HTML is the default.
EXPECTExpect valueDoublePutNumber greater than zero.
NUCL_REWARDReward for matching bases (BLASTN and megaBLAST)IntegerPutInteger greater than zero.
NUCL_PENALTYCost for mismatched bases (BLASTN and megaBLAST)IntegerPutInteger less than zero.
GAPCOSTSGap existence and extension costsStringPutPair of positive integers separated by a space such as “11 1”.
MATRIXScoring matrix nameStringPutOne of BLOSUM45, BLOSUM50, BLOSUM62, BLOSUM80, BLOSUM90, PAM250, PAM30 or PAM70. Default: BLOSUM62 for all applicable programs
HITLIST_SIZENumber of databases sequences to keepIntegerPut,GetInteger greater than zero.
DESCRIPTIONSNumber of descriptions to print (applies to HTML and Text)IntegerPut,GetInteger greater than zero.
ALIGNMENTSNumber of alignments to print (applies to HTML and Text)IntegerPut,GetInteger greater than zero.
NCBI_GIShow NCBI GIs in reportStringPut, GetT or F
RIDBLAST search request identifierStringGet , Delete The Request ID (RID) returned when the search was submitted
THRESHOLDNeighboring score for initial wordsIntegerPutPositive integer (BLASTP default is 11). Does not apply to BLASTN or MegaBLAST).
WORD_SIZESize of word for initial matchesIntegerPutPositive integer.
COMPOSITION_BASED_STATISTICSComposition based statistics algorithm to useIntegerPutOne of 0, 1, 2, or 3. See comp_based_stats command line option in the BLAST+ user manual for details.
FORMAT_OBJECTObject typeStringGetSearchInfo (status check) or Alignment (report formatting).
NUM_THREADSNumber of virtual CPUs to useIntegerPutInteger greater than zero and less than the maximum number of cores on the instance (default is the maximum number of cores on the instance). Supported only on the cloud

示例

官方文档中,含有Perl语言的脚本(官方示例),本文提供Python版本的代码

import requests
headers={
    'Content-type':'application/x-www-form-urlencoded'
}

#以下参数根据自己的需求写
data={
    'CMD':'Put',
    'PROGRAM':program,  #比如 blastp,blastn等
    'DATABASE':database,
    'QUERY':encoded_query
}

r=requests.post(url,headers=headers)
#若响应值为json格式,可使用print(r.json())
print(r.text)



暂无评论

发表评论