title: Rename Multi-FASTA sequence headers using Master File of similar names
body: <p>I have multiple FASTA files that are using very simple headers which identify the specimen. However, I would like to make the headers much more detailed by adding geographic location, source and culture date.</p>
  <p>My first thought is to use <code>stringr</code> package in <code>R</code> to read in each FASTA and replace any matching sequence ID with the appropriate string.</p>
  <p>Using a .xlsx with the necessary data and specimen ID I can create a .txt with a series of strings with the new names I desire. Using this &quot;Master Text&quot; file I would like to rename each of the sequences in each FASTA appropriately through matching the Specimen ID.</p>
  <p>So I created <code>rename.txt</code> in the following format:</p>
  <pre><code>SpecimenID|ST|Geographic Location|Source|CultDate
  VRE32491|736|PUH - 10C|Blood|2016-12-07
  VRE32493|1471|PUH - 10N|Tissue/Surgical|2016-12-08
  VRE32503|1471|PUH - 11N|Wound|2017-01-05
  VRE32504|1471|PUH - EMEP|Blood|2017-01-10
  VRE32514|1471|PUH - 6F|Wound|2017-01-20
  </code></pre>
  <p>Using <code>Biostrings::readDNAStringSet(*.fasta)</code> I am able to obtain the names for each sequence using <code>names()</code> on the object. I want to create a matching string from <code>rename.txt</code> that will enable me to simply rename the DNAStringSet object using <code>names({DNAStringSet object}) &lt;- {matching string}</code>.</p>
  <p>What my problem is that I can't seem to extract a character string set from the <code>rename.txt</code>.</p>
  <p>Below is some code anyone can use for a reprex to simulate my issue:</p>
  <pre><code>cat(
    &quot;&gt;VRE32493&quot;, &quot;AGCT&quot;,
    &quot;&gt;VRE32503&quot;, &quot;CAGT&quot;,
    &quot;&gt;VRE32504&quot;, &quot;TCAA&quot;,
    file = &quot;example.fasta&quot;, sep = &quot;\n&quot;
  )
  
  cat(
    &quot;SpecimenID|ST|Geographic Location|Source|CultDate&quot;,
    &quot;VRE32491|736|PUH - 10C|Blood|2016-12-07&quot;,
    &quot;VRE32493|1471|PUH - 10N|Tissue/Surgical|2016-12-08&quot;,
    &quot;VRE32503|1471|PUH - 11N|Wound|2017-01-05&quot;,
    &quot;VRE32504|1471|PUH - EMEP|Blood|2017-01-10&quot;,
    &quot;VRE32514|1471|PUH - 6F|Wound|2017-01-20&quot;,
    file = &quot;example.txt&quot;, sep = &quot;\n&quot;
  )
  
  origMult &lt;- Biostrings::readDNAStringSet(&quot;example.fasta&quot;)
  fasta_rename &lt;- read.delim(&quot;example.txt&quot;, skip = 1, header = F)
  </code></pre>
  <p>Expected output of <code>example.fasta</code>:</p>
  <pre><code>&gt;VRE32493|1471|PUH - 10N|Tissue/Surgical|2016-12-08
  AGCT
  &gt;VRE32503|1471|PUH - 11N|Wound|2017-01-05
  CAGT
  &gt;VRE32504|1471|PUH - EMEP|Blood|2017-01-10
  TCAA
  </code></pre>