Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update Cellosaurus functions and add tests #17

Merged
merged 5 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export(grep_file_names)
export(httpRequestUniChem)
export(infer_gencode_type)
export(listColToDT)
export(mapCellosaursAccessionsToFields)
export(moleculeQuery)
export(parseJSON)
export(postRequestUniChem)
Expand Down
330 changes: 83 additions & 247 deletions R/getCellosaurusAPI.R

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions man/dot-constructCellosaurusURL.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 0 additions & 19 deletions man/dot-parseCellosaurusTXTResponse.Rd

This file was deleted.

24 changes: 24 additions & 0 deletions man/mapCellosaursAccessionsToFields.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 5 additions & 21 deletions man/searchCellosaurusAPI.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions tests/testthat.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
library(AnnotationGx)
library(testthat)

test_check("AnnotationGx")
34 changes: 34 additions & 0 deletions tests/testthat/test_getCellosaurusAPI.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
library(testthat)


test_that("searchCellosaurusAPI returns expected results", {
# Test case 1: Search for cell line "MCF-7"
result1 <- searchCellosaurusAPI("MCF-7")
expect_equal(nrow(result1), 1)
expect_true(grepl("MCF-7", result1$Name))

# Test case 2: Search for cell line "HeLa"
result2 <- searchCellosaurusAPI("HeLa")
expect_equal(nrow(result2), 1)
# expect "HeLa" in the name
expect_true(grepl("HeLa", result2$Name))
})

test_that("getCellosaurusAccesions returns expected results", {
# Test case 1: Retrieve Cellosaurus accessions for sample IDs "HeLa" and "22rv1"
samples <- c("HeLa", "MCF-7")
result <- getCellosaurusAccesions(samples)
expect_equal(nrow(result), 2)
expect_true(grepl("HeLa", result$Name[1]))
expect_true(grepl("MCF-7", result$Name[2]))
})

test_that("mapCellosaursAccessionsToFields returns expected results", {
# Test case 1: Map Cellosaurus accessions to fields "id" and "ac"
accessions <- c("CVCL_0031", "CVCL_0030")
fields <- c("id", "ac")
result <- mapCellosaursAccessionsToFields(accessions, fields)
expect_equal(nrow(result), 2)
expect_equal(result$Accession, c("CVCL_0031", "CVCL_0030"))
})

Loading