Split a fq file into two fq files by length.
4
0
Entering edit mode
23 months ago

There is an fq file after trimming. I want to split it into two fq files, one for the first 1-34 nt and the other for 35-71 not, but I don't know what command to write. I would appreciate it if you could help me.

split fastq • 876 views
ADD COMMENT
1
Entering edit mode
23 months ago
seqkit subseq -r 1:34 in.fq.gz -o a.fq.gz

seqkit subseq -r 35:-1 in.fa.gz -o b.fq.gz

But if it's amplicon sequencing, it would not so easy. seqkit amplicon may help.

ADD COMMENT
1
Entering edit mode
23 months ago
gunzip -c in.R1.fq.gz  |\
paste - - - - |\
awk -F '\t' '{L=length($2);F="";if(L<=34) {F="f34.fq"} else if (L<=71) {F="f71.fq"} else {next;} printf("%s\n%s\n%s\n%s\n",$1,$2,$3,$4) >>F;}'
ADD COMMENT
1
Entering edit mode
23 months ago
GenoMax 141k

You could also use reformat.sh from BBMap suite.

# to get the left part of the read

reformat.sh -Xmx2g in=input.fq.gz outm=out.fq.gz forcetrimright=34

# to get the right part of the read

reformat.sh -Xmx2g in=input.fq.gz outm=out.fq.gz forcetrimleft=34
ADD COMMENT
1
Entering edit mode
23 months ago

for bases from 1-34:

cutadapt -u -37 <input.fastq> -o <output.fastq>

for bases from 35th onwards including 35th base

cuatadapt -u 34 <input.fastq> -o <output.fastq>
ADD COMMENT

Login before adding your answer.

Traffic: 2009 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6