tests/testthat/test_025annotation_kegg.R

start <- as.POSIXlt(Sys.time())
context("025annotation_kegg.R")
## 2017-12, exported functions in annotation_kegg:
## load_kegg_annotations(), map_kegg_to_ensembl()
## There are some functions in ontology_kegg which probably should be moved here.

## load_kegg_annotations()

## rest.kegg.jp  finally moved to https, sadly KEGGREST has not (yet).
test_kegg <- load_kegg_annotations()
actual <- head(test_kegg[["GID"]])
expected <- c("b0001", "b0002", "b0003", "b0004", "b0005", "b0006")
## 01
test_that("Do we get the expected KEGG GIDs?", {
  expect_equal(expected, actual)
})
kegg_ids <- head(test_kegg[["kegg_geneid"]])

actual <- head(test_kegg[["GID"]])
expected <- c("b0001", "b0002", "b0003", "b0004", "b0005", "b0006")
## 02
test_that("Do we get the expected ncbi gene IDs?", {
  expect_equal(expected, actual)
})

actual <- head(test_kegg[["ncbi_proteinid"]])
expected <- c("NP_414542", "NP_414543", "NP_414544",
              "NP_414545", "NP_414546", "NP_414547")
## 03
test_that("Do we get the expected ncbi protein IDs?", {
  expect_equal(expected, actual)
})

actual <- head(test_kegg[["uniprotid"]])
expected <- c("P0AD86", "P00561", "P00547", "P00934",
              "P75616", "P0A8I3")
## 04
test_that("Do we get the expected uniprot IDs?", {
  expect_equal(expected, actual)
})

actual <- head(test_kegg[["pathways"]])
expected <- c(
    "",
    "eco00260, eco00261, eco00270, eco00300, eco01100, eco01110, eco01120, eco01230",
    "eco00260, eco01100, eco01110, eco01120, eco01230",
    "eco00260, eco00750, eco01100, eco01110, eco01120, eco01230",
    "",
    "")
## 05
test_that("Do we get the expected KEGG pathways?", {
  expect_equal(expected, actual)
})

## map_kegg_ensembl()
mapped <- map_kegg_dbs(kegg_ids)
## Picked up a new mapping!
expected <- c(6, 7)
actual <- dim(mapped)
## 0607
test_that("Do we get the expected db mapping size?", {
  expect_equal(expected[1], actual[1])
  expect_equal(expected[2], actual[2])
})

end <- as.POSIXlt(Sys.time())
elapsed <- round(x = as.numeric(end - start))
message("\nFinished 025annotation_kegg.R in ", elapsed,  " seconds.")
elsayed-lab/hpgltools documentation built on May 9, 2024, 5:02 a.m.