Hi,
I have a fastq file named fastq1
which I upload in R using:
StreamFastq1=ShortRead::FastqStreamer(con=fastq1,n=2000000)
fastq1yield=ShortRead::yield(StreamFastq1)
I then use the narrow funstion to narrow the reads of fastq1yield:
fastq1yield_narrowed@sread=Biostrings::narrow(fastq1yield@sread,start=1,end=Cut_pos)
Where Cut_pos
is a vector of same length as fastq1yield
, but with different values for each entry. So I cut the sequences in different places resulting in different lengths for each sequence in fastq1yield_narrowed.
Then I save the file using:
ShortRead::writeFastq(object=fastq1yield_narrowed,file="fastq1yield_narrowed.fastq.gz",mode="w",compress=TRUE)
Everything looks good in the new fastq1yield_narrowed
file, except when I try to load it in R again using:
StreamFastq1_narrowed=ShortRead::FastqStreamer(con=fastq1yield_narrowed,n=2000000)
fastq1yield_narrowed=ShortRead::yield(StreamFastq1_narrowed)
I get the following error:
Error in add(bin) : internal: buf != <newline>
Why is this happening? Is there any way of solving this?
I also tried to read the whole file in R at once using:
fastq1yield_narrowed=ShortRead::readFastq(fastq1yield_narrowed)
And I get the following error:
Error: Input/Output
file(s):
fastq1yield_narrowed.fastq.gz
message: IncompatibleTypes
message: invalid class “ShortReadQ” object: some sread and quality widths differ
Which means that I cant read a fastq file with different lengths. Is there a way to solve this?
You shouldn't be using direct slot access (@...); ShortRead::narrow() operates on the fastq object.