hi,
I have fastq files of reads and i would like to finish this script in order to select the "good" reads from the "bad" reads and after that to save my results in new fastq files(good.fastq bad.fastq) .
Thanks for the help
gc()
rm(list=ls())
library(ShortRead)
showMethods(readFastq)
showMethods(writeFastq)
library(Biostrings)
#read bait sequences
baitseq <- readLines("Downloads/bait_seq.txt")
baitseq
#choose case
num <- 1
exptPath <- ("Downloads/INDEX1_reads.fastq")
exptPath
#read data
fq <- readFastq(dirPath=exptPath)
sread(fq)
#count ocurrences of bait
pos <- grepl(baitseq[num],sread(fq))
pos[1:25]
# number of reads
length(pos)
# number of hits
sum(pos)
# fuzzy match - 2 substitutions
fpos <- agrep(baitseq[num],sread(fq), max = list(sub = 2, ins=0, del=0))
fpos[1:25]
# number of fuzzy hits
length(fpos)
# save "good" reads from from fuzzy match in "*.good.fq" file and "bad" reads in *".bad.fq" file
?????
I have fastq files of reads and i would like to finish this script in order to select the "good" reads from the "bad" reads and after that to save my results in new fastq files(good.fastq bad.fastq) .

Thanks for the help
gc()
rm(list=ls())
library(ShortRead)
showMethods(readFastq)
showMethods(writeFastq)
library(Biostrings)
#read bait sequences
baitseq <- readLines("Downloads/bait_seq.txt")
baitseq
#choose case
num <- 1
exptPath <- ("Downloads/INDEX1_reads.fastq")
exptPath
#read data
fq <- readFastq(dirPath=exptPath)
sread(fq)
#count ocurrences of bait
pos <- grepl(baitseq[num],sread(fq))
pos[1:25]
# number of reads
length(pos)
# number of hits
sum(pos)
# fuzzy match - 2 substitutions
fpos <- agrep(baitseq[num],sread(fq), max = list(sub = 2, ins=0, del=0))
fpos[1:25]
# number of fuzzy hits
length(fpos)
# save "good" reads from from fuzzy match in "*.good.fq" file and "bad" reads in *".bad.fq" file
?????