from Bio.Blast.Applications import NcbiblastnCommandline
from Bio import SeqIO

# Configuration
query_file = "C:\\Users\\...\\ITS_otu.fasta"
db_file = "D:\\...\\unite_db"
output_file = "C:\\Users\\...\\OTUs_UNITElocal.csv"
evalue_threshold = 1e-5

# Full path to the blastn executable
blastn_path = "D:\\...\\blastn"

# Run BLAST
blastn_cline = NcbiblastnCommandline(
    blastn_path,
    query=query_file,
    db=db_file,
    evalue=evalue_threshold,
    outfmt=6,
    out=output_file,
)

print(f"Running BLAST:{blastn_cline}")
stdout, stderr = blastn_cline()
