# biotite.application.blast.BlastWebApp¶

class biotite.application.blast.BlastWebApp(program, query, database='nr', app_url='https://blast.ncbi.nlm.nih.gov/Blast.cgi', obey_rules=True, mail=None)[source]

Bases: biotite.application.webapp.WebApp

Perform a local alignment against a large sequence database using using the web-based BLAST application (by default NCBI BLAST).

Parameters
programstr

The specific BLAST program. One of ‘blastn’, ‘megablast’, ‘blastp’, ‘blastx’, ‘tblastn’ and ‘tblastx’.

querySequence or str

The query sequence. If a string is provided, it is interpreted as path to a FASTA file, if the string contains a valid FASTA file extension, otherwise it is interpreted as a single letter string representation of a sequence.

databasestr, optional

The NCBI sequence database to blast against. By default it contains all sequences (database=’nr’).

app_urlstr, optional

URL of the BLAST web app. By default NCBI BLAST is used. This can be changed to a private server or another cloud provider.

obey_rulesbool, optional

If true, the application raises an RuleViolationError, if the server is contacted too often, based on the NCBI BLAST usage rules. (Default: True)

mailstr, optional

If a mail address is provided, it will be appended in the HTTP request. This allows the NCBI to contact you in case your application sends too many requests.

set_entrez_query(self, query)[source]

Limit the size of the database. Only sequences that match the query are searched.

Parameters
queryQuery

An NCBI Entrez query.

set_max_results(self, number)[source]

Limit the maximum number of results.

Parameters
numberint

The maximum number of results.

set_max_expect_value(self, value)[source]

Set the threshold expectation value (E-value). No alignments with an E-value above this threshold will be considered.

The E-Value is the expectation value for the number of random sequences of a similar sized database getting an equal or higher score by change when aligned with the query sequence.

Parameters
valuefloat

The threshold E-value.

set_gap_penalty(self, opening, extension)[source]

Set the affine gap penalty for the alignment.

Parameters
openingfloat

The penalty for gap opening.

extensionfloat

The penalty for gap extension.

set_word_size(self, size)[source]

Set the word size for alignment seeds.

Parameters
sizeint

Word size.

set_match_reward(self, reward)[source]

Set the score of a symbol match in the alignment.

Used only in ‘blastn’ and ‘megablast’.

Parameters
rewardint

Match reward. Must be positive.

set_mismatch_penalty(self, penalty)[source]

Set the penalty of a symbol mismatch in the alignment.

Used only in ‘blastn’ and ‘megablast’.

Parameters
penaltyint

Mismatch penalty. Must be negative.

set_substitution_matrix(self, matrix_name)[source]

Set the penalty of a symbol mismatch in the alignment.

Used only in ‘blastp’, “blastx’, ‘tblastn’ and ‘tblastx’.

Parameters
matrix_namestr

Name of the substitution matrix. Default is ‘BLOSUM62’.

set_threshold(self, threshold)[source]

Set the threshold neighboring score for initial words.

Used only in ‘blastp’, “blastx’, ‘tblastn’ and ‘tblastx’.

Parameters
thresholdint

Threshold value. Must be positve.

run(self)[source]

Commence the application run. Called in start().

PROTECTED: Override when inheriting.

is_finished(self)[source]

Check if the application has finished.

PROTECTED: Override when inheriting.

Returns
finishedbool

True of the application has finished, false otherwise

wait_interval(self)[source]

The time interval of is_finished() calls in the joining process.

PROTECTED: Override when inheriting.

Returns
intervalfloat

Time (in seconds) between calls of is_finished() in join()

clean_up(self)[source]

Do clean up work after the application terminates.

PROTECTED: Optionally override when inheriting.

evaluate(self)[source]

Evaluate application results. Called in join().

PROTECTED: Override when inheriting.

get_xml_response(self)[source]

Get the raw XML response.

Returns
responsestr

The raw XML response.

get_alignments(self)[source]

Get the resulting local sequence alignments.

Returns
alignmentlist of BlastAlignment

The local sequence alignments.

app_url(self)

Get the URL of the web app.

Returns
urlstr

URL of the web app.

cancel(self)

Cancel the application when in RUNNING or FINISHED state.

get_app_state(self)

Get the current app state.

Returns
app_stateAppState

The current app state.

join(self, timeout=None)

Conclude the application run and set its state to JOINED. This can only be done from the RUNNING or FINISHED state.

If the application is FINISHED the joining process happens immediately, if otherwise the application is RUNNING, this method waits until the application is FINISHED.

Parameters
timeoutfloat, optional

If this parameter is specified, the Application only waits for finishing until this value (in seconds) runs out. After this time is exceeded a TimeoutError is raised and the application is cancelled.

Raises
TimeoutError

If the joining process exceeds the timeout value.

start(self)

Start the application run and set its state to RUNNING. This can only be done from the CREATED state.

violate_rule`(self, msg=None)

Indicate that a server rule was violated, i.e. this raises a RuleViolationError unless obey_rules is false.

PROTECTED: Do not call from outside.

Parameters
msgstr, optional

A custom message for the RuleViolationError.