A wrapper for submitting and retrieving BLAST queries
Project description
BlastWrapper
BlastWrapper is a Python package designed to interact with the BLAST (Basic Local Alignment Search Tool) API provided by NCBI. It allows users to submit, check the status of, and retrieve results from BLAST queries using simple functions.
Features
- Submit a BLAST query with specific parameters (e.g., program, database).
- Check the status of the BLAST query (whether it is still running or completed).
- Retrieve results from completed BLAST queries in various formats.
Installation
You can install blastwrapper via Poetry or pip (if published to PyPI in the future).
Using Poetry
-
Install Poetry if you haven't already:
Poetry installation guide -
Clone the repository and install the dependencies:
git clone https://github.com/yourusername/BLASTWrapper.git cd BLASTWrapper poetry install
Using pip
pip install blastwrapper
Usage
Functions Overview
put_query: Submits a BLAST query to the server and returns a RID (Request ID).
check_status: Checks if the BLAST query has completed by monitoring the status with the provided RID.
get_results: Retrieves the results of the BLAST query after it has completed.
Step 1: Submit a BLAST query
from blastwrapper import put_query, check_status, get_results
sequence = "ATCGATCGATCG"
rid = put_query(sequence) # Returns the RID of the submitted query
Step 2: Check the status of the BLAST query
import time
status = "NOT READY"
while status != "READY":
time.sleep(60) # Wait for 1 minute before checking again. Do not lower this, as BLAST requires this as a minimum wait time
status = check_status(rid, time_elapsed=60)
Step 3: Get the results after the job completes
results = get_results(rid)
print(results.text) # Print the results in the selected format
Parameters for put_query:
- sequence: The query sequence to search for (required).
- program: The BLAST program to use (default: "blastn").
- database: The BLAST database to search (default: "core_nt").
- short_query, filter, expect, nuc_rew, nuc_pen, word_size, gap_cost, matrix, cbs, ht_list, fmt_type, description, alignment, report: Various other parameters that have same default values as BLAST documentation you can customize (refer to NCBI BLAST documentation).
Parameters for check_status:
- rid (required): The request ID (RID) obtained from the put_query function.
- time_elapsed (required): Time in seconds since the query was submitted. This can be used to track how long the query has been running.
- fmt_type, fmt_object, align_view, descr, align, report: Additional customization parameters for status checking that have same default values as BLAST documentation (refer to NCBI BLAST documentation).
Parameters for get_results:
- rid: The request ID (RID) obtained from the put_query function.
- view_res: The format of the result view (default: "FromRes").
- fmt_type: The format type for the results (default: "Text").
- descr, align, report: Other parameters to customize the result display that have same default values as BLAST documentation (refer to NCBI BLAST documentation).
Testing
For testing see the tests/ directory. It is highly recommended to run tests via poetry.
poetry run pytest -v
License
This project is licensed under the MIT License – see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file blastwrapper-0.1.0.tar.gz.
File metadata
- Download URL: blastwrapper-0.1.0.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
06529534a8eb5d7980c4eb5d360792cb3f4bf162312556a29ed3847266cb4d8b
|
|
| MD5 |
1116e4edc90e73748131a933e4b07781
|
|
| BLAKE2b-256 |
7c5c35c9579035472b619ac0af84839ce4ff98cb2d0c0aa7e3248972b6b6e883
|
File details
Details for the file blastwrapper-0.1.0-py3-none-any.whl.
File metadata
- Download URL: blastwrapper-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0ae12ebe28a4326e617aefa575ce23e5143419cb32062c5d1234c5dfdec1b5d8
|
|
| MD5 |
25ab0d407273fbc3b9c8f28c2cbcc6e7
|
|
| BLAKE2b-256 |
9acee5fc517060f6908c6758297f03fd7f9f5736d180e9fe7c81db2ddb6242c5
|