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.
- 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.
You can install blastwrapper via Poetry or pip.
See package on PyPI https://pypi.org/project/blastwrapper/0.1.0/
-
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
pip install blastwrapperput_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.
from blastwrapper import put_query, check_status, get_results
sequence = "ATCGATCGATCG"
rid = put_query(sequence) # Returns the RID of the submitted queryimport 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)results = get_results(rid)
print(results.text) # Print the results in the selected format- 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).
- 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).
- 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).
For testing see the tests/ directory. It is highly recommended to run tests via poetry.
poetry run pytest -vThis project is licensed under the MIT License – see the LICENSE file for details.