text: user1684: I have a fastq file from Nanopore sequencing data that contains reads from both the UK and South Africa variants of SARS-CoV-2.
  The variants are identified by three key mutations in the receptor-binding domain of Spike.
  Aim
  Firstly, I want to determine the number of reads then belongs to UK and South Africa variant. Then, I will create a bam file from the fastq file using the SARS-CoV-2 reference genome.
  Questions
  
  How do I determine the reads belonging to each variants?
  Are there any tools available to classify the reads based on the pre-defined mutation criteria?
  
  
  user73: Based on a quick request from someone else, I wrote some code a couple of years ago for assigning read groups based on variants at particular locations; this was set up for HIV variant splitting, so I expect it should also work on SARS-CoV-2 nanopore reads as well:
  https://gitlab.com/gringer/bioinfscripts/-/blob/master/samVarSplitter.pl
  It processes a SAM stream [i.e. in text mode] using Perl, so might be a bit slow, but should be fine for a few hundred thousand sequences. You'd use it as follows:
  samtools view -h mapped_reads.bam | \
    samVarSplitter.pl [-ref <refName>] [-pos <int>] | \
    samtools sort > grouped_reads.bam
  
  Then the reads can be split into different files based on their group using samtools split:
  Usage: samtools split [-u <unaccounted.bam>] [-h <unaccounted_header.sam>]
                        [-f <format_string>] [-v] <merged.bam>
  
  
original_text: 1684: <p>I have a fastq file from Nanopore sequencing data that contains reads from <strong>both</strong> the UK and South Africa variants of SARS-CoV-2.</p>
  <p>The variants are identified by three key mutations in the receptor-binding domain of Spike.</p>
  <p><strong>Aim</strong>
  Firstly, I want to determine the number of reads then belongs to UK and South Africa variant. Then, I will create a bam file from the fastq file using the SARS-CoV-2 reference genome.</p>
  <p><strong>Questions</strong></p>
  <ol>
  <li>How do I determine the reads belonging to each variants?</li>
  <li>Are there any tools available to classify the reads based on the pre-defined mutation criteria?</li>
  </ol>
   73: <p>Based on a quick request from someone else, I wrote some code a couple of years ago for assigning read groups based on variants at particular locations; this was set up for HIV variant splitting, so I expect it should also work on SARS-CoV-2 nanopore reads as well:</p>
  <p><a href="https://gitlab.com/gringer/bioinfscripts/-/blob/master/samVarSplitter.pl" rel="nofollow noreferrer">https://gitlab.com/gringer/bioinfscripts/-/blob/master/samVarSplitter.pl</a></p>
  <p>It processes a SAM stream [i.e. in text mode] using Perl, so might be a bit slow, but should be fine for a few hundred thousand sequences. You'd use it as follows:</p>
  <pre><code>samtools view -h mapped_reads.bam | \
    samVarSplitter.pl [-ref &lt;refName&gt;] [-pos &lt;int&gt;] | \
    samtools sort &gt; grouped_reads.bam
  </code></pre>
  <p>Then the reads can be split into different files based on their group using <code>samtools split</code>:</p>
  <pre><code>Usage: samtools split [-u &lt;unaccounted.bam&gt;] [-h &lt;unaccounted_header.sam&gt;]
                        [-f &lt;format_string&gt;] [-v] &lt;merged.bam&gt;
  </code></pre>
  