<p>FWIW, In the <a href="https://sequenceserver.com" rel="nofollow noreferrer">Sequenceserver BLAST software</a>, you can just click on &quot;download alignment&quot; to extract the aligning region.</p>

CC BY-SA 4.0
2021-12-19T01:08:22.137Z
2021-12-19T01:08:22.137Z
Yannick Wurm
<p>My usual approach for extracting sequence from a reference genome is to use <code>samtools faidx</code>:</p>
<pre><code># create genome index; slow; only do once per reference genome
samtools faidx reference_genome.fa
# extract sequence for a specific match
samtools faidx reference_genome.fa chromosome_name1:posStart1-posEnd1 &gt; match1.fa
samtools faidx reference_genome.fa chromosome_name2:posStart2-posEnd2 &gt; match2.fa
</code></pre>
<p>You haven't mentioned how many BLAST results you have, or what format they're in, so I'm not sure if it's practical to do this manually, or if it needs to be automated in some way.</p>

CC BY-SA 4.0
2021-12-12T23:51:20.477Z
2021-12-12T23:51:20.477Z
gringer
<p>I have created a Blast database using a reference genome. Then, I have performed a local blast search in command line using a gene of interest. I have obtained some hits with the usual Blasting information. Now, I want to extract the exact matching sequence from the blast search with their corresponding start and stop position. I have a <code>.gff</code> file for the genes as well for the reference genome. Can you give me any suggestions on how to do that? Thanks a lot.</p>

CC BY-SA 4.0
2021-12-11T16:52:00.337Z
Please [edit] your question and add an example of the relevant files so we can understand what you need. Do you have multiple HSPs you want to combine? Do you need to model splicing? If you already have the gff of the target sequence, why were you blasting?
terdon
<gene><ngs><blast>
How to retrieve fasta sequence after local blast?
# How to retrieve fasta sequence after local blast?

(Asked by: username_0 on 2021-12-09)

I have created a Blast database using a reference genome. Then, I have performed a local blast search in command line using a gene of interest. I have obtained some hits with the usual Blasting information. Now, I want to extract the exact matching sequence from the blast search with their corresponding start and stop position. I have a `.gff` file for the genes as well for the reference genome. Can you give me any suggestions on how to do that? Thanks a lot.

**Tags:** gene, ngs, blast
> **Comments:**
> **username_1**: Please [edit] your question and add an example of the relevant files so we can understand what you need. Do you have multiple HSPs you want to combine? Do you need to model splicing? If you already have the gff of the target sequence, why were you blasting?  

---

## 2 answers

### Answer by username_2 on 2021-12-19. Score: 0 | Accepted answer

FWIW, In the [Sequenceserver BLAST software](https://sequenceserver.com), you can just click on "download alignment" to extract the aligning region.


---

### Answer by username_3 on 2021-12-12. Score: 1

My usual approach for extracting sequence from a reference genome is to use samtools faidx:
# create genome index; slow; only do once per reference genome
samtools faidx reference_genome.fa
# extract sequence for a specific match
samtools faidx reference_genome.fa chromosome_name1:posStart1-posEnd1 > match1.fa
samtools faidx reference_genome.fa chromosome_name2:posStart2-posEnd2 > match2.fa

You haven't mentioned how many BLAST results you have, or what format they're in, so I'm not sure if it's practical to do this manually, or if it needs to be automated in some way.


---

