# Primers in reverse reads only?

**URL:** <https://forum.qiime2.org/t/primers-in-reverse-reads-only/22674>\
**Category:** Other Bioinformatics Tools\
**Created:** [April 4, 2022, 2:41pm UTC](https://forum.qiime2.org/t/primers-in-reverse-reads-only/22674 "2022-04-04T14:41:08Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![saatkinson](https://forum.qiime2.org/user_avatar/forum.qiime2.org/saatkinson/32/6074_2.png) [@saatkinson](https://forum.qiime2.org/u/saatkinson)\
**Post date:** [April 4, 2022, 2:41pm UTC](https://forum.qiime2.org/t/primers-in-reverse-reads-only/22674/1 "2022-04-04T14:41:09Z")

</div>

Hello,

I'm working on an analysis and found [this post](https://forum.qiime2.org/t/finding-primers-in-raw-files-and-quality-control/1621) detailing how to look for primers in the raw reads to determine if cutadapt should be run. I ran these commands and got the resulting primer counts:

```auto
#Count primers in forward reads
zgrep "^CCTACGGGNGGC[AT]GCAG" fastqs/Day-4-CCL28-529L-1*R1*.gz | wc -l
0
#Count primers in reverse reads
zgrep "^GACTAC[ACT][ACG]GGGTATCTAATCC" fastqs/Day-4-CCL28-529L-1*R2*.gz | wc -l
206283
#Count total reverse reads
zgrep "@M" fastqs/Day-4-CCL28-529L-1*R2*.gz | wc -l
214168

```

I've never experienced finding primers in only one of the read pairs. And this is 96% of the reverse reads having primers (much, much more than the 25% cutoff mentioned in the previous post), but none of the forward reads. I was wondering if this was something I should be concerned about and if not, whether using cutadapt to remove the reverse primer only would cause issues.

Thanks!  
Samantha

---

<div class="post-metadata">

**Author:** ![colinbrislawn](https://forum.qiime2.org/user_avatar/forum.qiime2.org/colinbrislawn/32/6221_2.png) [@colinbrislawn](https://forum.qiime2.org/u/colinbrislawn)\
**Post date:** [April 5, 2022, 2:18pm UTC](https://forum.qiime2.org/t/primers-in-reverse-reads-only/22674/2 "2022-04-05T14:18:21Z")

</div>

Hello Samantha,

Yeah, that is a little surprising, but not impossible. However, I'm guessing the issue is with the grep search.

For the forward reads, only exact matches (with an `A` or `T` in the middle) would be returned, so a small change would throw it off.

```auto
Matched: CCTACGGGNGGCTGCAGAAAAAAAAAAAAAA
Missed: CCTACGGGNGGCTGCACAAAAAAAAAAAAAA
Missed: CTACGGGNGGCTGCAGAAAAAAAAAAAAAA
Missed: CCCTACGGGNGGCTGCAGAAAAAAAAAAAAAA

```

Try loosening up that zgrep search so it can capture small deviations in the expected primer:

```bash
zgrep "CCTACGGGNGGC[AT]GCAG"
zgrep "CCTACGGGNGGC[AT]"
zgrep "GGGNGGC[AT]GCAG"

```

Let us know what you find,  
Colin

P.S. I've moved this to Other Bioinformatics Tools as it's related to grep / zgrep 👍

---

<div class="post-metadata">

**Author:** ![saatkinson](https://forum.qiime2.org/user_avatar/forum.qiime2.org/saatkinson/32/6074_2.png) [@saatkinson](https://forum.qiime2.org/u/saatkinson)\
**Post date:** [April 5, 2022, 2:47pm UTC](https://forum.qiime2.org/t/primers-in-reverse-reads-only/22674/3 "2022-04-05T14:47:49Z")

</div>

Hi Colin,

Thanks for the reply. I tried the zgrep commands you recommend for the forward reads and all are still zero:

```auto
zgrep "CCTACGGGNGGC[AT]GCAG" fastqs/Day-4-CCL28-529L-1*R1*.gz | wc -l
0
zgrep "CCTACGGGNGGC[AT]" fastqs/Day-4-CCL28-529L-1*R1*.gz | wc -l
0
zgrep "GGGNGGC[AT]GCAG" fastqs/Day-4-CCL28-529L-1*R1*.gz | wc -l
0

```

I added another zgrep that replaces the N with any character and now the number of primers in reverse reads is basically the same as reverse (which doesn't have any N's).

```auto
zgrep "CCTACGGG.GGC[AT]GCAG" fastqs/Day-4-CCL28-529L-1*R1*.gz | wc -l
208350

```

Thanks for your help, it appears that zgrep was breaking because it couldn't find an "N" exactly.

> P.S. I've moved this to Other Bioinformatics Tools as it's related to grep / zgrep 👍

Sorry about that, I was thinking in terms of the reads themselves, not the tool!

Thanks,  
Samantha

---

<div class="post-metadata">

**Author:** ![colinbrislawn](https://forum.qiime2.org/user_avatar/forum.qiime2.org/colinbrislawn/32/6221_2.png) [@colinbrislawn](https://forum.qiime2.org/u/colinbrislawn)\
**Post date:** [April 5, 2022, 3:14pm UTC](https://forum.qiime2.org/t/primers-in-reverse-reads-only/22674/4 "2022-04-05T15:14:32Z")

</div>

OK, I'm glad we figured it out!

> [@saatkinson](#):
>
> Thanks for your help, it appears that zgrep was breaking because it couldn't find an "N" exactly.

For future users, here's what happened:

In the vocabulary of primer design, N is any Nucleotide, but grep does not know this and searched for a literal `N`. Once we translate this to the vocab of regular expressions (`.` for any character) it works as intended!

---

<div class="post-metadata">

**Author:** ![saatkinson](https://forum.qiime2.org/user_avatar/forum.qiime2.org/saatkinson/32/6074_2.png) [@saatkinson](https://forum.qiime2.org/u/saatkinson)\
**Post date:** [April 25, 2022, 6:54pm UTC](https://forum.qiime2.org/t/primers-in-reverse-reads-only/22674/5 "2022-04-25T18:54:49Z")

</div>

Hi Colin,

I had a quick follow-up question about this. When I first ran the zgrep commands I had a ^ at the beginning to tell the regex to only look at the beginning of reads. Your examples did not include this, and I was wondering if using the ^ would be more accurate to search for primers (since they would be at the beginning of the read)? I do get less counts when I run with the caret (as expected). Is it acceptable to limit the search to the beginning of the read or does the caret throw something off/skew something?

Thanks,  
Samantha

---

<div class="post-metadata">

**Author:** ![colinbrislawn](https://forum.qiime2.org/user_avatar/forum.qiime2.org/colinbrislawn/32/6221_2.png) [@colinbrislawn](https://forum.qiime2.org/u/colinbrislawn)\
**Post date:** [April 26, 2022, 1:34am UTC](https://forum.qiime2.org/t/primers-in-reverse-reads-only/22674/6 "2022-04-26T01:34:08Z")

</div>

> [@saatkinson](#):
>
> Is it acceptable to limit the search to the beginning of the read or does the caret throw something off/skew something?

It's totally acceptable! You can choose how to select the primers you want.

> [@saatkinson](#):
>
> Your examples did not include this, and I was wondering if using the ^ would be more accurate to search for primers (since they would be at the beginning of the read)? I do get less counts when I run with the caret (as expected).

Because matching from the start of the read is more specific / restrictive, it will miss results with extra characters before it, just like you observed. When I made my suggestions, I was hoping to find more results, so I went with the most general / least restrictive regular expression by dropping the `^`carrot.

* * *

I guess this opens a bigger questions about specific vs accurate primers:

> [@saatkinson](#):
>
> I was wondering if using the ^ would be **more accurate** to search for primers (since they would be at the beginning of the read)? I do get less counts when I run with the caret ( **as expected** ). (emphasis added)

Would the more specific regex search be more accurate, or do we expect some reads to have extra basepairs before the primer leading to this more specific regex being less accurate because it misses some reads?

🤔

---

<div class="post-metadata">

**Author:** ![system](https://forum-qiime2-org.s3.dualstack.us-west-2.amazonaws.com/original/3X/2/1/21af5fe23cb6f4579467c66a9ed94e55274ca7bd.svg) [@system](https://forum.qiime2.org/u/system)\
**Post date:** [May 27, 2022, 7:34am UTC](https://forum.qiime2.org/t/primers-in-reverse-reads-only/22674/7 "2022-05-27T07:34:53Z")

</div>

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.
