This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Obtaining only the aligned regions in BLAST

Hello I have a subject nucleotide sequence which I would like to align to various complete genomes. I am using standalone blastn for the same. Can someone pls tell me how I can retrieve the aligned regions in a separate file. Thanks

blast blastn standaloneblast
blastn -help

Check the formatting options

add sseq to output format. -outfmt '6 std sseq'. for more details get the full help as mentioned by @5heikki

Thank you! But from the above output format we will get the positions of the aligned regions alone in the genome. Is there any way to obtain the sequence in a separate file?

From the above you should get 13 column output where the last column displays aligned subject sequence. If you're on Windows, use -outfmt "6 std sseq" instead of -outfmt '6 std sseq'

Assuming your BLAST output goes into a file called blastout.tsv and you used -outfmt '6 std sseq' , then

cut -f 2,13 blastout.tsv | awk '{printf(">%s\n%s\n", $1, $2); }' > blastout.aligned.fasta

should do the trick (not on Windows, unless you're using Cygwin or something similar).

0 answers

No answers yet.

Log in to answer this question.