title: replace header in a file (fasta) if match with another file.txt
body: <p>I have a file Pseudo.fasta that looks like this</p>
  <pre><code>&gt;Pseudomonas_brassicacearum_51MFCVI2.1_ABFDHLDI_02438
  AATCGCAATTTGCCCAAA
  &gt;Pseudomonas_brassicacearum_51MFCVI2.1_ABFDHLDI_03705
  GATCCTTAACGGA
  &gt;Pseudomonas_brassicacearum_PP1_210F_EGEGDKLG_01471
  AGGCCTTAAACCTT
  </code></pre>
  <p>and another file.txt with two columns: 1 column that partially match the header of the .fasta file and a second column and the file looks like this.</p>
  <pre><code>Pseudomonas_brassicacearum_51MFCVI2.1   JW5VryPcbM
  Pseudomonas_brassicacearum_51MFCVI2.1   JW5VryPcbM
  Pseudomonas_brassicacearum_PP1_210F     nxUvzhi39L
  </code></pre>
  <p>Basically I want to replace the header with the second column of the second file if the first column of the first file match (the first part) of the fasta header.</p>
  <p>The deisred output should look like this</p>
  <pre><code>&gt;JW5VryPcbM_1
  AATCGCAATTTGCCCAAA
  &gt;JW5VryPcbM_2
  GATCCTTAACGGA
  &gt;nxUvzhi39L_1
  AGGCCTTAAACCTT
  </code></pre>
  <p>I was trying to do that with awk</p>
  <pre><code>awk -F &quot;\t&quot; 'FNR==NR {f2[$1]=$2;next} $2 in f2 {$2=f2[$2]}1' file.txt FS='&gt;' OFS='&gt;' Pseudomo.fasta 
  </code></pre>
  <p>but this solution only works if the the strings to match are exactly the same.</p>
  <p>After this I would apply this awk line to add a number in case of duplicates in the headers</p>
  <pre><code>awk '{print $0 (/^&gt;/ ? &quot;_&quot; (++c[$1]) : &quot;&quot;)}' Pseudo.fasta
  </code></pre>
  <p>It would be also cool to maybe directly pipe this last with the previous command.
  Any suggestion?
  Thanks!</p>