This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to confirm forward and reverse primer matches the beggining of each read and keep only reads with fwd and rev primers ?

I have a sipmle script in command line to Check primers in fastq file but this is for one primer only.

cat 4C_Blaise_pool_1_H1_TSS_fastq | paste - - - - | awk '{if ($0~/\tAACGAAAGAAATTAAAGGATAACTG/)print}' | awk -F '\t' '{print $1"\n"$2"\n"$3"\n"$4}' > 4C_Blaise_pool_1_H1_TSS_Rev.fastq

I would like to include in my if the second primer as well in rder to check if each read starts with one one two primers and then write a new fastq only with the reads which include the forward and reverse primers. Any help with that??

sequencing fastq filtering reads primers

1 answer

with bash , use paste with two input stream (8 columns)

paste     <(cat R1.fq | paste - - - - ) \
          <(cat R2.fq | paste - - - - ) \ 
         | awk  -F '\t' '($2~/^ABC/ && $6 ~ /^ABCD/ )' |\
         tr "\t" "\n"

output is an interleaved fastq

Log in to answer this question.