text: user298: I am working with an amplicon kit from Swift Bioscience and they provide the primer locations in what they call a "masterfile". The format is like this:
  $ head -n2 Acel-Amplicon_56g_masterfile.txt
  1       43814951        43815064        MPL_S505N-A519T_F/2     43814932        43814951        MPL_S505N-A519T_F/2_primer      43815064  43815081 MPL_S505N-A519T_R/1_primer      GCCTGGATCTCCTTGGTGA     CTTCGGCTCCACCTGGT
  1       115256480       115256576       NRAS_G60-S65_new_R/1    115256457       115256480       NRAS_G60-S65_new_R/1_primer     115256576 115256602        NRAS_G60-S65_new_F/2_primer     TGATGGCAAATACACAGAGGAAG CAGGATTCTTACAGAAAACAAGTGGT
  
  This is the format which is understood by Swift's primer clipping tool, but in order to use other tools, I would like to convert it to BEDPE so I can then use standard tools to clip the primers from my bam files. However, I can't do that since I am not sure what the fields in this file are. 
  This is what I think thy are:
  
  Chromosome
  Target region start
  Target region end
  5' Primer name
  5' Primer start
  5' Primer end
  3' Primer name
  3' Primer start
  3' Primer end
  5' Primer sequence
  3' primer sequence
  
  Is my interpretation correct? Also, is this a standard file format or something specific to the Swift tool? I couldn't find any documentation about a "masterfile" format online.
  
  user3669: this is the swift standard primer file. You are a bit off in your interpretation of the columns (seems like you missed one as there are 12 columns, not 11 which threw everything off):
  1) Chromosome
  2) Target Start
  3) Target Stop
  4) Target Name (change which affected everything downstream in counting) 
  5) 5' Primer Start
  6) 5' Primer Stop
  7) 5' Primer Name
  8) 3' Primer Start
  9) 3' Primer Stop
  10) 3' Primer Name
  11) 5' Primer Sequence
  12) 3' Primer Sequence
  To convert to a BEDPE describing the primer locations, you only will need columns 1, 5, 6, 8, and 9 (and optionally 4). The last letter of the Region name for the denotes the strand orientation of the region. For example Region 1 has _F denoting forward or (+) strand for BEDPE usage, while region 2 has _R in name denoting reverse or (-) strand for BEDPE. Putting all this together, you can convert to BEDPE with:
  $ awk -v OFS="\t" '{ 
              o="."; 
              if($4~/_F\//){
                  o="+"
              }
              else if($4~/_R\//){
                  o="-"
              } 
              print $1,$5,$6,$1,$8,$9,$4,".",o}' foo.masterfile
  1   43814932    43814951    1   43815064    43815081    MPL_S505N-A519T_F/2 .   +
  1   115256457   115256480   1   115256576   115256602   NRAS_G60-S65_new_R/1    .   -
  
  
original_text: 298: <p>I am working with an amplicon kit from Swift Bioscience and they provide the primer locations in what they call a "masterfile". The format is like this:</p>
  
  <pre><code>$ head -n2 Acel-Amplicon_56g_masterfile.txt
  1       43814951        43815064        MPL_S505N-A519T_F/2     43814932        43814951        MPL_S505N-A519T_F/2_primer      43815064  43815081 MPL_S505N-A519T_R/1_primer      GCCTGGATCTCCTTGGTGA     CTTCGGCTCCACCTGGT
  1       115256480       115256576       NRAS_G60-S65_new_R/1    115256457       115256480       NRAS_G60-S65_new_R/1_primer     115256576 115256602        NRAS_G60-S65_new_F/2_primer     TGATGGCAAATACACAGAGGAAG CAGGATTCTTACAGAAAACAAGTGGT
  </code></pre>
  
  <p>This is the format which is understood by <a href="https://github.com/swiftbiosciences/primerclip" rel="nofollow noreferrer">Swift's primer clipping tool</a>, but in order to use other tools, I would like to convert it to BEDPE so I can then use standard tools to clip the primers from my bam files. However, I can't do that since I am not sure what the fields in this file are. </p>
  
  <p>This is what I think thy are:</p>
  
  <ol>
  <li>Chromosome</li>
  <li>Target region start</li>
  <li>Target region end</li>
  <li>5' Primer name</li>
  <li>5' Primer start</li>
  <li>5' Primer end</li>
  <li>3' Primer name</li>
  <li>3' Primer start</li>
  <li>3' Primer end</li>
  <li>5' Primer sequence</li>
  <li>3' primer sequence</li>
  </ol>
  
  <p>Is my interpretation correct? Also, is this a standard file format or something specific to the Swift tool? I couldn't find any documentation about a "masterfile" format online.</p>
   3669: <p>this is the swift standard primer file. You are a bit off in your interpretation of the columns (seems like you missed one as there are 12 columns, not 11 which threw everything off):</p>
  
  <p>1) Chromosome</p>
  
  <p>2) Target Start</p>
  
  <p>3) Target Stop</p>
  
  <p>4) <strong>Target Name</strong> (change which affected everything downstream in counting) </p>
  
  <p>5) 5' Primer Start</p>
  
  <p>6) 5' Primer Stop</p>
  
  <p>7) 5' Primer Name</p>
  
  <p>8) 3' Primer Start</p>
  
  <p>9) 3' Primer Stop</p>
  
  <p>10) 3' Primer Name</p>
  
  <p>11) 5' Primer Sequence</p>
  
  <p>12) 3' Primer Sequence</p>
  
  <p>To convert to a BEDPE describing the primer locations, you only will need columns 1, 5, 6, 8, and 9 (and optionally 4). The last letter of the Region name for the denotes the strand orientation of the region. For example Region 1 has _F denoting forward or (+) strand for BEDPE usage, while region 2 has _R in name denoting reverse or (-) strand for BEDPE. Putting all this together, you can convert to BEDPE with:</p>
  
  <pre><code><span class="math-container">$ awk -v OFS="\t" '{ 
              o="."; 
              if($4~/_F\//){
                  o="+"
              }
              else if($4~/_R\//){
                  o="-"
              } 
              print $1,$5,$6,$1,$8,$9,$</span>4,".",o}' foo.masterfile
  1   43814932    43814951    1   43815064    43815081    MPL_S505N-A519T_F/2 .   +
  1   115256457   115256480   1   115256576   115256602   NRAS_G60-S65_new_R/1    .   -
  </code></pre>
  