<p>What application are you using that will be okay with a mismatching quality string?</p>

<p>Use trimmomatic or cutadapt, or bcl2fastq could probably do the job too.  Those will also have the benefit of dealing properly with one-off errors, which awk and sed won't.  </p>

CC BY-SA 4.0
2020-06-11T17:31:57.770Z
2020-06-11T17:31:57.770Z
swbarnes2
<p>Skip the <code>grep</code>, use just the <code>sed</code>. Unless the header contains the long sequence as well (which I doubt it will), your command will work.</p>

<pre><code>sed 's/^ACTTAAGTGTATGTAAACTTCCGACTTCAACTGTA/TA/' SRR_1.fastq &gt; SRR_1.edited.fastq
</code></pre>

CC BY-SA 4.0
2020-06-08T15:18:26.950Z
It works but there are some sequences begining with: ACTTANGTGTATGTAAACTTCCGACTTCAACTG They are being retained. How to deal with them. Kindly guide.
Amit
CC BY-SA 4.0
2020-06-08T17:10:58.360Z
That's because `N` does not match A,T,C or G as a literal. Replace all `N` with `[ATCG]` to remove these sequences.
Ram RS
CC BY-SA 4.0
2020-06-09T14:04:25.583Z
It is worth considering thomas' point. If you'd like your QUAL lines to reflect the change to the SEQ lines. awk or bioawk might be better at this point.
Ram RS
CC BY-SA 4.0
2020-06-08T15:10:12.843Z
2020-06-08T15:10:12.843Z
Ram RS
<p>If you need the quality vector for each read, then your code will create a shift because it does not cut the quality vector. You should rather use a trimming tool a systematically cut all 33 first characters. <strong><a href="https://github.com/OpenGene/fastp" rel="nofollow noreferrer">fastp</a></strong> will allow you to do it easily with the <code>-f, --trim_front1</code> argument.</p>

CC BY-SA 4.0
2020-06-08T15:50:21.473Z
What should be the command line , I typed fastp -i SRR_1.fastq -o trimSRR1.fq -f 33 and it gives an error ERROR: trim_front1 (--trim_front1) should be 0 ~ 30, suggest 0 ~ 4. Kindly help.
Amit
CC BY-SA 4.0
2020-06-08T15:59:28.747Z
strange! I did'nt know it was restricted to 30. You can run fastp twice with 20 in the first trimming and 13 in second one? not really convenient but it should work!
thomas duge de bernonville
CC BY-SA 4.0
2020-06-09T05:14:43.557Z
you may alternatively had a look at Trimmomatic (http://www.usadellab.org/cms/?page=trimmomatic). It has a `HEADCROP` argument, but I don't know if it also restricted in length.
thomas duge de bernonville
CC BY-SA 4.0
2020-06-08T15:22:38.407Z
2020-06-08T15:22:38.407Z
thomas duge de bernonville
<p>I have a FASTQ file:</p>

<pre><code>@NS500455:80:HG7TNBGXB:1:11101:17723:1055 1:N:0:ATCACG
ACTTANGTGTATGTAAACTTCCGACTTCAACTGTATAGGGATCCNAGCTCCAATTCGCCCTATAGTGAGTCGTAT
+
/AAAA#EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE#EEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
@NS500455:80:HG7TNBGXB:1:11101:8821:1057 1:N:0:ATCACG
ACTTANGTGATGTAAACTTCCGACTTCAACTGTATAATAAATATCTAGATCGGAAGAGCACACGTCCGAACTCCA
</code></pre>

<p>I want to remove the string  ACTTAAGTGTATGTAAACTTCCGACTTCAACTG from it while retaining the sequences starting from TA onwards.
I wrote <code>grep "ACTTAAGTGTATGTAAACTTCCGACTTCAACTGTA" SRR_1.fastq | sed "s/ACTTAAGTGTATGTAAACTTCCGACTTCAACTGTA/TA/g"</code>, but it removes the headers of the FASTQ file as well.</p>

<p>The desired output would be </p>

<pre><code>@NS500455:80:HG7TNBGXB:1:11101:17723:1055 1:N:0:ATCACG
TATAGGGATCCNAGCTCCAATTCGCCCTATAGTGAGTCGTAT
+
/AAAA#EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE#EEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
@NS500455:80:HG7TNBGXB:1:11101:8821:1057 1:N:0:ATCACG
TATAATAAATATCTAGATCGGAAGAGCACACGTCCGAACTCCA
</code></pre>

<p>How to do this. I dont want to use cutadapt.</p>

<p>Kindly help.</p>

<fastq>
FASTQ file trimming
# FASTQ file trimming

(Asked by: username_0 on 2020-06-08)

I have a FASTQ file:
@NS500455:80:HG7TNBGXB:1:11101:17723:1055 1:N:0:ATCACG
ACTTANGTGTATGTAAACTTCCGACTTCAACTGTATAGGGATCCNAGCTCCAATTCGCCCTATAGTGAGTCGTAT
+
/AAAA#EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE#EEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
@NS500455:80:HG7TNBGXB:1:11101:8821:1057 1:N:0:ATCACG
ACTTANGTGATGTAAACTTCCGACTTCAACTGTATAATAAATATCTAGATCGGAAGAGCACACGTCCGAACTCCA

I want to remove the string  ACTTAAGTGTATGTAAACTTCCGACTTCAACTG from it while retaining the sequences starting from TA onwards.
I wrote grep "ACTTAAGTGTATGTAAACTTCCGACTTCAACTGTA" SRR_1.fastq | sed "s/ACTTAAGTGTATGTAAACTTCCGACTTCAACTGTA/TA/g", but it removes the headers of the FASTQ file as well.
The desired output would be 
@NS500455:80:HG7TNBGXB:1:11101:17723:1055 1:N:0:ATCACG
TATAGGGATCCNAGCTCCAATTCGCCCTATAGTGAGTCGTAT
+
/AAAA#EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE#EEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
@NS500455:80:HG7TNBGXB:1:11101:8821:1057 1:N:0:ATCACG
TATAATAAATATCTAGATCGGAAGAGCACACGTCCGAACTCCA

How to do this. I dont want to use cutadapt.
Kindly help.

**Tags:** fastq

---

## 3 answers

### Answer by username_1 on 2020-06-11. Score: 4

What application are you using that will be okay with a mismatching quality string?

Use trimmomatic or cutadapt, or bcl2fastq could probably do the job too. Those will also have the benefit of dealing properly with one-off errors, which awk and sed won't.


---

### Answer by username_2 on 2020-06-08. Score: 3

Skip the grep, use just the sed. Unless the header contains the long sequence as well (which I doubt it will), your command will work.
sed 's/^ACTTAAGTGTATGTAAACTTCCGACTTCAACTGTA/TA/' SRR_1.fastq > SRR_1.edited.fastq

> **Comments:**
> **username_0**: It works but there are some sequences begining with: ACTTANGTGTATGTAAACTTCCGACTTCAACTG They are being retained. How to deal with them. Kindly guide.  
> **username_2**: That's because `N` does not match A,T,C or G as a literal. Replace all `N` with `[ATCG]` to remove these sequences.  
> **username_2**: It is worth considering thomas' point. If you'd like your QUAL lines to reflect the change to the SEQ lines. awk or bioawk might be better at this point.  

---

### Answer by username_3 on 2020-06-08. Score: 2

If you need the quality vector for each read, then your code will create a shift because it does not cut the quality vector. You should rather use a trimming tool a systematically cut all 33 first characters. **[fastp](https://github.com/OpenGene/fastp)** will allow you to do it easily with the `-f, --trim_front1` argument.

> **Comments:**
> **username_0**: What should be the command line , I typed fastp -i SRR_1.fastq -o trimSRR1.fq -f 33 and it gives an error ERROR: trim_front1 (--trim_front1) should be 0 ~ 30, suggest 0 ~ 4. Kindly help.  
> **username_3**: strange! I did'nt know it was restricted to 30. You can run fastp twice with 20 in the first trimming and 13 in second one? not really convenient but it should work!  
> **username_3**: you may alternatively had a look at Trimmomatic (http://www.usadellab.org/cms/?page=trimmomatic). It has a `HEADCROP` argument, but I don't know if it also restricted in length.  

---

