text: user1935: I have a very, very long list of genome coordinates of areas. I need to gather a sequence in order to compare it to another database of sequences that I have. How do I produce the genome sequences from these coordinates in R?
  I am very new to this and need a detailed answer.
  
  user77: This doesn't use R, but a simple and quite convenient method is to use bedtools getfasta with your fasta file. You'll need to make a BED file out of the RepeatMasker output:
  awk 'BEGIN{OFS="\t"}{name=sprintf("%s_%s", $10, $11); strand="+"; if($9 == "C"){strand="-"}; print $5,$6-1,$7,name,".", strand}' repeatmasker.output > rmsk.bed
  
  Then, given that and your genome.fa fasta:
  bedtools getfasta -name -s -fi genome.fa -bed rmsk.bed -fo output.fa
  
  This will produce a multiline fasta file names like AluSx_SINE/Alu (due to the -name option) where the sequences are reverse complemented if appropriate.
  You can install bedtools either via conda (conda install -c bioconda bedtools) or github.
  
original_text: 1935: <p>I have a very, very long list of genome coordinates of areas. I need to gather a sequence in order to compare it to another database of sequences that I have. How do I produce the genome sequences from these coordinates in R?</p>
  
  <p>I am very new to this and need a detailed answer.</p>
   77: <p>This doesn't use R, but a simple and quite convenient method is to use <code>bedtools getfasta</code> with your fasta file. You'll need to make a BED file out of the RepeatMasker output:</p>
  
  <pre><code>awk 'BEGIN{OFS="\t"}{name=sprintf("%s_%s", $10, $11); strand="+"; if($9 == "C"){strand="-"}; print $5,$6-1,$7,name,".", strand}' repeatmasker.output &gt; rmsk.bed
  </code></pre>
  
  <p>Then, given that and your <code>genome.fa</code> fasta:</p>
  
  <pre><code>bedtools getfasta -name -s -fi genome.fa -bed rmsk.bed -fo output.fa
  </code></pre>
  
  <p>This will produce a multiline fasta file names like <code>AluSx_SINE/Alu</code> (due to the <code>-name</code> option) where the sequences are reverse complemented if appropriate.</p>
  
  <p>You can install bedtools either via conda (<code>conda install -c bioconda bedtools</code>) or <a href="https://github.com/arq5x/bedtools2/releases/download/v2.26.0/bedtools-2.26.0.tar.gz" rel="nofollow noreferrer">github</a>.</p>
  