title: retaining text after delimiter in fasta headers using awk
body: <p>I have what should be a simple problem, but my lack of awk knowledge is holding me back. </p>
  
  <p>I would like to clean up the headers of a fasta file that is in this format:</p>
  
  <pre><code>&gt;HWGG454_Clocus2_Locus3443_allele1
  ATTCTACTACTACTCT
  &gt;GHW757_clocus37_Locus555662_allele2
  CTTCCCTACGATG
  &gt;TY45_clocus23_Locus800_allele0
  TTCTACTTCATCT
  </code></pre>
  
  <p>I would like to clean up each header (line starting with ">") to retain only the informative part, which is the second  "_Locus*" with or without the allele part. </p>
  
  <p>I thought awk would be the easy way to do this, but I cant quite get it to work. </p>
  
  <p>If I wanted to retain just the first column of text up to the "_" delimiter for the header, and the sequences below, I run this (assuming this toy example is in the file test.fasta): </p>
  
  <pre><code> cat test.fasta | awk -F '_' '{print $1}'
  
  &gt;HWGG454
  ATTCTACTACTACTCT
  &gt;GHW757
  CTTCCCTACGATG
  &gt;TY45
  TTCTACTTCATCT
  </code></pre>
  
  <p>But, what I want is to retain just the "Locus*" text, which is after the 3rd delimiter, but, using this code I get this:</p>
  
  <pre><code>cat test.fasta | awk -F '_' '{print $3}'
  Locus3443
  
  Locus555662
  
  Locus800
  </code></pre>
  
  <p>What am I doing wrong here? </p>
  
  <p>thanks.</p>