title: more efficient awk parser for different combinations of data
body: <p>I have an awk parser, that works great if the data is NC_0000 (four digits), but if it is not that then the data is parsed. I'm not sure the most efficient way to obtain the desired output.  Thank you :).</p>
  
  <p>Code:</p>
  
  <pre><code>awk 'FNR &gt; 1 &amp;&amp; match($0, /NC_0000([0-9]*)\..*g\.([0-9]+)(.)&gt;(.)/, a){ print a[1], a[2], a[2], a[3], a[4] }' OFS='\t' ${id}.txt &gt; ${id}_parse.txt
  </code></pre>
  
  <p>For example: </p>
  
  <pre><code>NC_000013.10:g.20763466G&gt;A
  NC_00001.10:g.20763477C&gt;G 
  </code></pre>
  
  <p>would be parsed into the desired output of </p>
  
  <pre><code>13  20763466    20763466    G   A 
  1   20763477    20763477    C   G
  </code></pre>
  
  <p>but this</p>
  
  <pre><code>NC_000004.11:g.41749507G&gt;T
  </code></pre>
  
  <p>would not work.  The desired output format is listed below and is always that way.  Thank you :).</p>
  
  <p>parse rules:</p>
  
  <ol>
  <li><p>4 zeros after the NC_ (not always the case) and the digits before the .</p></li>
  <li><p>digits after the g. repeated twice separated by a tab</p></li>
  <li><p>letter before the ></p></li>
  <li><p>letter after the ></p></li>
  </ol>
  
  <p>added using </p>
  
  <pre><code>awk -F"[_.&gt;]" '{a=length($4);b=substr($4,1,a-1);print $2+0,b,b,substr($4,a),$5}' OFS="\t" Target.txt
  0
  4004    244     244     G       A               NC
  3924    288     288     C       A               NC
  3924    385     385     G       A               NC
  </code></pre>
  
  <p>Thank you:)</p>