TaxoTagger

DNA barcode identification, powered by semantic searching.

1
mention
1
contributor

Cite this software

What TaxoTagger can do for you

pypi badge Static Badge

TaxoTagger is a Python library for DNA barcode identification, powered by semantic searching.

Features:

  • 🚀 Effortlessly build vector databases from DNA sequences (FASTA files)
  • ⚡ Achieve highly efficient and accurate semantic searching
  • 🔥 Easily extend support for various embedding models

Installation

TaxoTagger requires Python 3.10 or later.

# create an virtual environment
conda create -n venv-3.10 python=3.10
conda activate venv-3.10

# install the `taxotagger` package
pip install --pre taxotagger

Usage

Build a vector database from a FASTA file

from taxotagger import ProjectConfig
from taxotagger import TaxoTagger

config = ProjectConfig()
tt = TaxoTagger(config)

# creating the database will take ~30s
tt.create_db('data/database.fasta')

The data/database.fasta is available at repo data folder.

By default, the ~/.cache/mycoai folder is used to store the vector database and the embedding model. The MycoAI-CNN.pt model is automatically downloaded to this folder if it is not there, and the vector database is created and named after the model.

Conduct a semantic search with FASTA file

from taxotagger import ProjectConfig
from taxotagger import TaxoTagger

config = ProjectConfig()
tt = TaxoTagger(config)

# semantic search and return the top 1 result for each query sequence
res = tt.search('data/query.fasta', limit = 1)

The data/query.fasta file contains two query sequences: KY106088 and KY106087.

The search results res will be a dictionary with taxonomic level names as keys and matched results as values for each of the two query sequences. For example, res['phylum'] will look like:

[
    [{"id": "KY106088", "distance": 1.0, "entity": {"phylum": "Ascomycota"}}],
    [{"id": "KY106087", "distance": 0.9999998807907104, "entity": {"phylum": "Ascomycota"}}]
]

The first inner list is the top results for the first query sequence, and the second inner list is the top results for the second query sequence.

The id field is the sequence ID of the matched sequence. The distance field is the cosine similarity between the query sequence and the matched sequence with a value between 0 and 1, the closer to 1, the more similar. The entity field is the taxonomic information of the matched sequence.

We can see that the top 1 results for both query sequences are exactly themselves. This is because the query sequences are also in the database. You can try with different query sequences to see the search results.

Docs

Please visit the official documentation for more details.

Question and feedback

Please submit an issue if you have any question or feedback.

Logo of TaxoTagger
Keywords
Programming languages
  • Python 94%
  • Makefile 5%
  • Mustache 1%
License
</>Source code
Packages
pypi.org

Participating organisations

Netherlands eScience Center
CBS-KNAW Fungal Biodiversity Centre

Mentions

Contributors

Related projects

AID

Artificial Intelligence for DNA barcode identification

Updated 4 months ago
Finished