Bioconductor / Biostrings

Efficient manipulation of biological strings
https://bioconductor.org/packages/Biostrings
57 stars 16 forks source link

loading "tictoc" package makes the object lost and cannot assign again #99

Closed qifei9 closed 1 year ago

qifei9 commented 1 year ago

Once the "tictoc" package is loaded, the DNAStringSet object become NULL. The readDNAStringSet can read the seq in, but cannot assign the DNAStringSet object to variables.

> seq <- Biostrings::readDNAStringSet("./a.fa")

> print(seq) # normal
DNAStringSet object of length 20:
...

> library('tictoc')

> print(seq) # the output become NULL
NULL

> seq <- Biostrings::readDNAStringSet("./a.fa")  # try to assign it again

> print(seq)  # still NULL
NULL

> Biostrings::readDNAStringSet("./a.fa")  # normal
DNAStringSet object of length 20:
...

> a <- 'a'
> print(a)
[1] "a"  # can assign other things

sessionInfo:

R version 4.2.3 (2023-03-15)
Platform: x86_64-conda-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS/LAPACK: /home/qifei/mambaforge/envs/r4.2/lib/libmkl_rt.so.2

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

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

other attached packages:
[1] tictoc_1.1      nvimcom_0.9-144

loaded via a namespace (and not attached):
 [1] zlibbioc_1.44.0        compiler_4.2.3         IRanges_2.32.0         XVector_0.38.0         tools_4.2.3
 [6] GenomeInfoDbData_1.2.9 RCurl_1.98-1.12        crayon_1.5.2           Biostrings_2.66.0      S4Vectors_0.36.0
[11] BiocGenerics_0.44.0    GenomeInfoDb_1.34.8    bitops_1.0-7           stats4_4.2.3
hpages commented 1 year ago

Hi,

Unfortunately, the tictoc package defines a print() method for List objects that breaks print() on all List derivatives in Bioconductor:

library(IRanges)
x1 <- IntegerList(a=11:13, b=21:22, compress=FALSE)
x1
# IntegerList of length 2
# [["a"]] 11 12 13
# [["b"]] 21 22

is(x1, "List")
# [1] TRUE

library(GenomicRanges)
x2 <- GRangesList(a=GRanges("chr1:99-299"), b=GRanges("chr2:88-95"))
x2
# GRangesList object of length 2:
# $a
# GRanges object with 1 range and 0 metadata columns:
#       seqnames    ranges strand
#          <Rle> <IRanges>  <Rle>
#   [1]     chr1    99-299      *
#   -------
#   seqinfo: 2 sequences from an unspecified genome; no seqlengths
#
# $b
# GRanges object with 1 range and 0 metadata columns:
#       seqnames    ranges strand
#          <Rle> <IRanges>  <Rle>
#  [1]     chr2     88-95      *
#   -------
#   seqinfo: 2 sequences from an unspecified genome; no seqlengths

is(x2, "List")
# [1] TRUE

library(Biostrings)
x3 <- DNAStringSet(c("AAACTT", "GTTAT"))
x3
# DNAStringSet object of length 2:
#     width seq
# [1]     6 AAACTT
# [2]     5 GTTAT

is(x3, "List")
# [1] TRUE

Before loading tictoc, print() works fine on x1, x2, and x3. However, after loading it:

library(tictoc)
print(x1)
# NULL
print(x2)
# NULL
print(x3)
# NULL

This is because tictoc:::print.List() gets in the way.

We will soon implement a workaround in Bioconductor. The workaround will consist in defining the following print() methods:

print.SimpleList <- print.default
print.CompressedList <- print.default
print.XVectorList <- print.default

This "repairs" print() on x1, x2, and x3.

In the mean time, please refrain from using print() and use show() instead (the latter is preferred anyways).

Additionally, someone maybe should contact the tictoc folks and kindly point them to the fact that their List class causes some really unfortunate conflicts with the widely used List class and subclasses defined in Bioconductor (the latters have been around for at least 12 years).

See https://github.com/waldronlab/MultiAssayExperiment/issues/321 for a similar issue caused by tictoc's List class and methods.

Cheers, H.

qifei9 commented 1 year ago

Many thanks for your reply and explanation! @hpages

sizrailev commented 1 year ago

Hi @qifei9, I am the maintainer of the tictoc package and the problem is now fixed in the new version of tictoc v1.2. (update from CRAN). Thank you for reporting and thanks @LiNk-NY for posting.

qifei9 commented 1 year ago

Hi @qifei9, I am the maintainer of the tictoc package and the problem is now fixed in the new version of tictoc v1.2. (update from CRAN). Thank you for reporting and thanks @LiNk-NY for posting.

Many thanks to your work! and also many thanks to @LiNk-NY and all the developers of Biostrings!

hpages commented 1 year ago

yeah thanks @sizrailev , this is great!