forked from Bioconductor/BSgenome
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTODO
93 lines (81 loc) · 2.24 KB
/
TODO
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
- Try harder to reproduce the following issue with parallel retrieval of
sequences. Reported by email directly to me by Juri Reimand on 2014/11/19.
Systems I tried this so far:
OS R BioC could reproduce?
petty Snow Leopard 3.2.2 3.1 no
morelia Mavericks 3.2.2 3.1 no
perceval Snow Leopard 3.2.2 3.2 no
rhino04 Ubuntu 14.04.2 LTS 3.2.0 3.2 no
rhino04 Ubuntu 14.04.2 LTS 3.2.0 3.1 no
latitude Ubuntu 14.04.3 LTS 3.2.1 3.2 no
latitude Ubuntu 14.04.3 LTS 3.2.1 3.1 no
latitude Ubuntu 14.04.3 LTS 3.1.2 3.0 no
latitude Ubuntu 14.04.3 LTS 3.1.1 2.14 no
#+begin_src R
## test_mclapply_on_BSgenome.R file send by Juri Reimand on 2014/11/19
library(parallel)
library(Biostrings)
library(BSgenome)
library(BSgenome.Hsapiens.UCSC.hg19)
# simulate some DNA coordinates
dfr = data.frame(chr=paste0("chr", rep(1:10, each=100)), pos=round(1e6*runif(1000))+1e6, stringsAsFactors=F)
# fetch nucleotides with one command
test_ref_all = getSeq(Hsapiens, dfr$chr, dfr$pos, dfr$pos, as.character=TRUE)
# function to fetch nucleotides one by one
get_seq = function(i, dfr) {
cat('.')
getSeq(Hsapiens, dfr[i,"chr"], dfr[i,"pos"], dfr[i,"pos"], as.character=T)
}
# use above function to retrieve nucleotides using single processor core
test_ref_single_core = sapply(1:nrow(dfr), get_seq, dfr)
# use above function to retrieve nucleotides using multiple processor cores
test_ref_multicore = unlist(mclapply(1:nrow(dfr), get_seq, dfr, mc.cores=8))
table(test_ref_all==test_ref_single_core)
#TRUE
#1000
table(test_ref_multicore==test_ref_single_core)
#FALSE TRUE
# 23 977
R.Version()
#$platform
#[1] "x86_64-apple-darwin10.8.0"
#
#$arch
#[1] "x86_64"
#
#$os
#[1] "darwin10.8.0"
#
#$system
#[1] "x86_64, darwin10.8.0"
#
#$status
#[1] ""
#
#$major
#[1] "3"
#
#$minor
#[1] "1.0"
#
#$year
#[1] "2014"
#
#$month
#[1] "04"
#
#$day
#[1] "10"
#
#$`svn rev`
#[1] "65387"
#
#$language
#[1] "R"
#
#$version.string
#[1] "R version 3.1.0 (2014-04-10)"
#
#$nickname
#[1] "Spring Dance"
#+end_src