Why I'm getting an error when using ShortRead package's FastqStreamerList function?
1
1
Entering edit mode
@simonasjuzenas-8655
Last seen 6.4 years ago
Lithuania/Kaunas/LSMU

Hi all,

I don't understand why I'm getting this error, when using ShortRead package' s FastqStreamerList function.

My code:

fql<-FastqStreamerList(c("a.fastq.gz", "b.fastq.gz"), n=1e6)
while(length(object <- yield(fql))) {
  writeFastq(object, "pooled.fastq.gz", "a", compress=TRUE)
}

Error in (function (classes, fdef, mtable)  :
  unable to find an inherited method for function ‘yield’ for signature ‘"FastqStreamerList"’

It says that "FastqStreamerList" its not inherited method for "yield" function whereas, in ShortRead's Vignette "FastqStreamerList" usage is described like this:

## FastqSampler and FastqStreamer
FastqSampler(con, n=1e6, readerBlockSize=1e8, verbose=FALSE,ordered = FALSE)
FastqSamplerList(..., n=1e6, readerBlockSize=1e8, verbose=FALSE,ordered = FALSE)
FastqStreamer(con, n, readerBlockSize=1e8, verbose=FALSE)
FastqStreamerList(..., n, readerBlockSize=1e8, verbose=FALSE)
yield(x, ...)

So where is the problem?

> sessionInfo()
R version 3.2.2 (2015-08-14)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 14.04.3 LTS

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=lt_LT.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=lt_LT.UTF-8    LC_MESSAGES=en_US.UTF-8    LC_PAPER=lt_LT.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=lt_LT.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats4    parallel  stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] ShortRead_1.26.0        GenomicAlignments_1.4.1 Rsamtools_1.20.4        GenomicRanges_1.20.5    GenomeInfoDb_1.4.2     
 [6] Biostrings_2.36.3       XVector_0.8.0           IRanges_2.2.7           S4Vectors_0.6.3         BiocParallel_1.2.20    
[11] BiocGenerics_0.14.0    

loaded via a namespace (and not attached):
 [1] lattice_0.20-33      bitops_1.0-6         grid_3.2.2           futile.options_1.0.0 zlibbioc_1.14.0      hwriter_1.3.2       
 [7] latticeExtra_0.6-26  futile.logger_1.4.1  RColorBrewer_1.1-2   lambda.r_1.1.7       tools_3.2.2          Biobase_2.28.0
shortread fastqSteamerList • 1.2k views
ADD COMMENT
0
Entering edit mode
@martin-morgan-1513
Last seen 13 days ago
United States

I guess you mean the reference manual page ?FastqStreamerList rather than vignette. The manual page is documenting several functions together; it doesn't imply that all functions work with one another. You could write the while() loop as

fsl <- FastqStreamerList(c("a.fastq.gz", "b.fastq.gz"), n=1e6)

repeat {
    s1 = yield(fsl[[1]])
    if (length(s1) == 0)
        break
    s2 = yield(fsl[[2]])
    cat("lengths:", length(s1), length(s2), "\n")
}

I'm not sure what you want to do to create 'pooled', concatenate chunks with append(s1, s2). Or maybe you're trying to concatenate? Then something like

fsl <- FastqStreamerList(c("a.fastq.gz", "b.fastq.gz"), n=100)
for (i in seq_along(fsl)) {
    fs = fsl[[i]]
    repeat {
        s = yield(fs)
        if (length(s) == 0)
            break
        ## writeFastq(...)
    }
}    

 

 

ADD COMMENT
0
Entering edit mode

Thank you for help, Martin! Yes, I was trying to concatenate .fasta.gz files. Usually I'm using this code:

fq<-readFastq(c("a.fastq.gz", "b.fastq.gz"))
writeFastq(fq, "pooled.fastq.gz", mode="a", compress=TRUE)

It works fine but it takes a lot of time to concatenate some files, so I was looking for better option to do this using R.

ADD REPLY

Login before adding your answer.

Traffic: 511 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