title: How to rename headers in many multi-fasta files with the name of a file?
body: <p>I have a directory with several hundred multi-FASTA files. These files are called with the name of the species or genus, such as:</p>
  
  <pre><code>Bubo_bubo.fasta
  Poa_CC7849.fasta
  Homo_sapiens.fasta
  ...
  </code></pre>
  
  <p>Inside each filem the headers are automatically generated by <a href="https://github.com/trinityrnaseq/trinityrnaseq/wiki" rel="nofollow noreferrer">Trinity assembler</a> and look similar to this example:</p>
  
  <pre><code>&gt;c5_g1_i1 len=168 path=[174:0-148 24:148-168]
  </code></pre>
  
  <p>I would like to rename the headers in each of these files adding information about the species that it is coming from. So in other words, the header should contain in the beginning the name of the file. For example, if the header above comes from <code>Bubo_bubo.fasta</code> it should look like:</p>
  
  <pre><code>&gt;Bubu_bubo_c5_g1_i1 len=168 path=[174:0-148 24:148-168]
  </code></pre>
  
  <p>So I want to write a loop that will take a file name and use this to add this information in each fasta header in this particular file and I want to do that for all the files in the directory.</p>