- 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

