Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-06-11T17:31:57.770Z
Answers.LastActivityDate: 2020-06-11T17:31:57.770Z
Answers.UserDisplayName: swbarnes2
Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-06-08T15:18:26.950Z
Answers.Text: It works but there are some sequences begining with: ACTTANGTGTATGTAAACTTCCGACTTCAACTG They are being retained. How to deal with them. Kindly guide.
Answers.UserDisplayName: Amit
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-06-08T17:10:58.360Z
Answers.Text: That's because `N` does not match A,T,C or G as a literal. Replace all `N` with `[ATCG]` to remove these sequences.
Answers.UserDisplayName: Ram RS
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-06-09T14:04:25.583Z
Answers.Text: 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.
Answers.UserDisplayName: Ram RS
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-06-08T15:10:12.843Z
Answers.LastActivityDate: 2020-06-08T15:10:12.843Z
Answers.UserDisplayName: Ram RS
Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-06-08T15:50:21.473Z
Answers.Text: 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.
Answers.UserDisplayName: Amit
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-06-08T15:59:28.747Z
Answers.Text: 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!
Answers.UserDisplayName: thomas duge de bernonville
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-06-09T05:14:43.557Z
Answers.Text: 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.
Answers.UserDisplayName: thomas duge de bernonville
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-06-08T15:22:38.407Z
Answers.LastActivityDate: 2020-06-08T15:22:38.407Z
Answers.UserDisplayName: thomas duge de bernonville
Body: <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>
  
Tags: <fastq>
Title: FASTQ file trimming
ThreadText: # 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 username_3' 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.  
  
  ---
  
  