Hello,

I have created a local blast database and blasted some genes against the reference using

    blastn -query a.fasta -db BLASTDATABASE -max_target_seqs 5 -outfmt 6 -out output

I obtain a ~98% similarity score for the best hit. Now, I want to extract the `fasta` sequence of that BLAST search together with the 200 bp flanking sequence from both start and stop sides for designing a primer.

Can you please give me a suggestion on how to do this for a single BLAST search?

Thank you.
For extracting the region + context of the hit, you're best of with using `blastdbcmd`. it has an option `-range` that you can use to extract a certain region from a hit in the blastdb .

As with the approach https://www.biostars.org/u/50673/ proposed (for the query) you can extract the start & stop from the blast hit table and use that in the blastdbcmd (potentially recalculating them with + and - 200 bp )