Split a fq file into two fq files by length.
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.
• 2,007 views
•
link
4 answers
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.
• 0 views
•
link
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;}'
• 0 views
•
link
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
• 0 views
•
link
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>
• 0 views
•
link
Log in to answer this question.