<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>

CC BY-SA 4.0
2022-02-25T21:34:51.163Z
Fantastic, good response.
M__
CC BY-SA 4.0
2021-05-27T12:07:44.807Z
2021-05-27T12:07:44.807Z
gringer
<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>

CC BY-SA 4.0
2022-03-02T00:39:03.967Z
I don't think that's possible in general. You can obviously map the reads to the references and split but that's if you trust the references and in that case why do you even need the reads? Just thinking out loud.
juanjo75es
<sam><variant-calling><nanopore><covid-19><sars-cov-2>
Detecting SARS-CoV-2 variants from the mixed virus population
# Detecting SARS-CoV-2 variants from the mixed virus population

(Asked by: username_0 on 2021-05-26)

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**

1. How do I determine the reads belonging to each variants?
2. Are there any tools available to classify the reads based on the pre-defined mutation criteria?

**Tags:** sam, variant-calling, nanopore, covid-19, sars-cov-2
> **Comments:**
> **username_1**: I don't think that's possible in general. You can obviously map the reads to the references and split but that's if you trust the references and in that case why do you even need the reads? Just thinking out loud.  

---

## 1 answers

### Answer by username_2 on 2021-05-27. Score: 2

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 ] [-pos ] | \
  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 ] [-h ]
                      [-f ] [-v]

> **Comments:**
> **username_3**: Fantastic, good response.  

---

