Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-12-19T01:08:22.137Z
Answers.LastActivityDate: 2021-12-19T01:08:22.137Z
Answers.UserDisplayName: Yannick Wurm
Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-12-12T23:51:20.477Z
Answers.LastActivityDate: 2021-12-12T23:51:20.477Z
Answers.UserDisplayName: gringer
Body: <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>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-12-11T16:52:00.337Z
Comments.Text: 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?
Comments.UserDisplayName: terdon
Tags: <gene><ngs><blast>
Title: How to retrieve fasta sequence after local blast?
ThreadText: # 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.
  
  
  ---
  
  