blasttools
Commands for turning blast queries into pandas dataframes.
Blast against any built blast databases
blasttools blast --out=my.pkl query.fasta my_blastdbs_dir/*.pot
Install
Install with
python -m pip install -U blasttools
# *OR*
python -m pip install -U 'git+https://github.com/arabidopsis/blasttools.git'
Once installed you can update with blasttools update
Common Usages:
Build some blast databases from Ensembl Plants.
blasttools plants --release=40 build triticum_aestivum zea_mays
Find out what species are available:
blasttools plants --release=40 species
Blast against my.fasta and save dataframe as a pickle file (the default is to
save as a csv file named my.fasta.csv).
blasttools plants blast --out=dataframe.pkl my.fasta triticum_aestivum zea_mays
Get your blast data!
import pandas as pd
df = pd.read_pickle('dataframe.pkl')
Parallelization
When blasting, you can specify --num-threads which is passed directly to the
underlying blast command. If you want to parallelize over species, databases or fasta files,
I suggest you use GNU Parallel [Tutorial].
parallel has a much better set of options for controlling how the parallelization works
and is also quite simple for simple things.
e.g. build blast databases from a set of fasta files concurrently:
parallel blasttools build ::: *.fa.gz
Or blast everything!
species=$(blasttools plants species)
parallel blasttools plants build ::: $species
# must have different output files here...
parallel blasttools plants blast --out=my{}.pkl my.fasta ::: $species
# or in batches of 4 species at a time
parallel -N4 blasttools plants blast --out='my{#}.pkl' my.fasta ::: $species
Then gather them all together...
blasttools concat --out=alldone.xlsx my*.pkl && rm my*.pkl
or programmatically:
from glob import glob
import pandas as pd
df = pd.concat([pd.read_pickle(f) for f in glob('my*.pkl')], ignore_index=True)
Remember: if you parallelize your blasts and use --num-threads > 1
then you are probably going to be fighting for cpu time
amongst yourselves!
Best matches
Usually if you want the top/best --best=3 will select the lowest evalue's for
each query sequence. However if you want say the best to, say, be the longest query match
then you can add --expr='qstart - qend'. (Remember we are looking for the lowest values).
XML
Blast offers an xml (--xml) output format that adds query, match, sbjct strings. The other
fields are equivalent to adding --columns='+score gaps nident positive qlen slen'.
It also offers a way to display the blast match as a pairwise alignment.
from blasttools.blastxml import hsp_match
df = pd.read_csv('results.csv')
df['alignment'] = df.apply(hsp_match, axis=1)
print(df.iloc[0].alignment)
Metadata
Release files for blasttools 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| blasttools-0.2.1.tar.gz | 21.1 kB | Without provenance | Details for blasttools-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| blasttools-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for blasttools-0.2.1-py3-none-any.whl |
Total release size: 47.1 kB
Release files / blasttools-0.2.1.tar.gz
| Download URL | blasttools-0.2.1.tar.gz |
|---|---|
| Size | 21.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c58acf08461e7aee44426dc3be3253815cb3b2f7c3261cda4650c03c1f30be8e
|
|
BLAKE2b-256 checksum How to use checksums |
adbc7c129b1bf767f0de7ae3e5caf2c3fd0be026e363d8a0f893c143fa20c5cc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.5
|
Release files / blasttools-0.2.1-py3-none-any.whl
| Download URL | blasttools-0.2.1-py3-none-any.whl |
|---|---|
| Size | 26.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d6c511caffe74a3a62dbf47ef80e2dfa31082e755aea89dea17c5f5e66fdca11
|
|
BLAKE2b-256 checksum How to use checksums |
653e3440aaa46914bb926d1eda329419cca639e8854869d422f556ecc2f7cda1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.5
|
Security for blasttools 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.