-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
149 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
library(testthat) | ||
|
||
test_that("gene_ranger throws error with no genes", { | ||
expect_error(gene_ranger()) | ||
}) | ||
|
||
test_that("gene_ranger throws error with invalid projection", { | ||
expect_error(gene_ranger(these_genes = "MYC", projection = "invalid")) | ||
}) | ||
|
||
test_that("gene_ranger throws error with invalid return format", { | ||
expect_error(gene_ranger(these_genes = "MYC", return_as = "invalid")) | ||
}) | ||
|
||
test_that("gene_ranger throws error when write_to_bed is TRUE but bed_path, track_name, or track_description is not provided", { | ||
expect_error(gene_ranger(these_genes = "MYC", write_to_bed = TRUE), "Provide a path for output bed file") | ||
expect_error(gene_ranger(these_genes = "MYC", write_to_bed = TRUE, bed_path = "my_bed"), "Provide a track name for output bed file") | ||
expect_error(gene_ranger(these_genes = "MYC", write_to_bed = TRUE, bed_path = "my_bed", track_name = "MYC"), "Provide a track description for output bed file") | ||
}) | ||
|
||
test_that("gene_ranger runs successfully with valid input", { | ||
expect_silent(gene_ranger(these_genes = "MYC")) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
library(testthat) | ||
|
||
test_that("purify_chr throws error with no projection", { | ||
expect_error(purify_chr(), "You must provide a valid projection") | ||
}) | ||
|
||
test_that("purify_chr throws error with no incoming_table", { | ||
expect_error(purify_chr(projection = "hg38"), "You must provide a data table with `incoming_table`") | ||
}) | ||
|
||
test_that("purify_chr throws error with invalid projection", { | ||
expect_error(purify_chr(projection = "invalid", incoming_table = data.frame(chrom = c("1", "2", "3"))), "This function supports the following projections") | ||
}) | ||
|
||
test_that("purify_chr adds 'chr' prefix for hg38 projection", { | ||
df = data.frame(chrom = c("1", "2", "3")) | ||
result = purify_chr(projection = "hg38", incoming_table = df) | ||
expect_equal(result$chrom, c("chr1", "chr2", "chr3")) | ||
}) | ||
|
||
test_that("purify_chr removes 'chr' prefix for grch37 projection", { | ||
df = data.frame(chrom = c("chr1", "chr2", "chr3")) | ||
result = purify_chr(projection = "grch37", incoming_table = df) | ||
expect_equal(result$chrom, c("1", "2", "3")) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
library(testthat) | ||
|
||
test_that("purify_regions handles single region string", { | ||
result <- purify_regions(these_regions = "chr1:100-500") | ||
expect_equal(nrow(result), 1) | ||
expect_equal(result$chrom, "chr1") | ||
expect_equal(result$start, 100) | ||
expect_equal(result$end, 500) | ||
}) | ||
|
||
test_that("purify_regions handles multiple region strings", { | ||
result <- purify_regions(these_regions = c("chr1:100-500", "chr2:100-500")) | ||
expect_equal(nrow(result), 2) | ||
expect_equal(result$chrom, c("chr1", "chr2")) | ||
expect_equal(result$start, c(100, 100)) | ||
expect_equal(result$end, c(500, 500)) | ||
}) | ||
|
||
test_that("purify_regions handles individual region parameters", { | ||
result <- purify_regions(qchrom = "chr1", qstart = 100, qend = 500) | ||
expect_equal(nrow(result), 1) | ||
expect_equal(result$chrom, "chr1") | ||
expect_equal(result$start, 100) | ||
expect_equal(result$end, 500) | ||
}) | ||
|
||
test_that("purify_regions handles multiple individual region parameters", { | ||
result <- purify_regions(qchrom = c("chr1", "chr2"), qstart = c(100, 200), qend = c(500, 600)) | ||
expect_equal(nrow(result), 2) | ||
expect_equal(result$chrom, c("chr1", "chr2")) | ||
expect_equal(result$start, c(100, 200)) | ||
expect_equal(result$end, c(500, 600)) | ||
}) | ||
|
||
test_that("purify_regions handles data frame input", { | ||
my_regions <- data.frame(chrom = c("chr1", "chr2"), start = c(100, 200), end = c(500, 600)) | ||
result <- purify_regions(these_regions = my_regions) | ||
expect_equal(nrow(result), 2) | ||
expect_equal(result$chrom, c("chr1", "chr2")) | ||
expect_equal(result$start, c(100, 200)) | ||
expect_equal(result$end, c(500, 600)) | ||
}) | ||
|
||
test_that("purify_regions throws error with incorrect input", { | ||
expect_error(purify_regions(qchrom = "chr1", qstart = 100)) | ||
expect_error(purify_regions(these_regions = data.frame(chrom = c("chr1", "chr2"), start = c(100, 200), end = c(50, 100)))) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
library(testthat) | ||
|
||
test_that("region_ranger throws error with no regions", { | ||
expect_error(region_ranger()) | ||
}) | ||
|
||
test_that("region_ranger throws error with invalid projection", { | ||
expect_error(region_ranger(these_regions = "chr8:127735434-127742951", projection = "invalid"), "This function supports the following projections") | ||
}) | ||
|
||
test_that("region_ranger returns correct number of columns when raw is FALSE", { | ||
result = region_ranger(these_regions = "chr8:127735434-127742951") | ||
expect_equal(ncol(result), 11) | ||
}) | ||
|
||
test_that("region_ranger returns all columns when raw is TRUE", { | ||
result = region_ranger(these_regions = "chr8:127735434-127742951", raw = TRUE) | ||
expect_true(ncol(result) > 11) | ||
}) | ||
|
||
test_that("region_ranger returns warning when no genes found", { | ||
expect_warning(region_ranger(these_regions = "chr1:1-10")) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
library(testthat) | ||
|
||
test_that("sanity_check_regions throws error with no regions", { | ||
expect_error(sanity_check_regions(), "No regions provided") | ||
}) | ||
|
||
test_that("sanity_check_regions throws error with invalid projection", { | ||
my_regions <- data.frame(chrom = c("chr1"), start = c(100), end = c(200)) | ||
expect_error(sanity_check_regions(incoming_regions = my_regions, projection = "invalid"), "Invalid projection specified") | ||
}) | ||
|
||
test_that("sanity_check_regions throws error when start is greater than end", { | ||
my_regions <- data.frame(chrom = c("chr1"), start = c(200), end = c(100)) | ||
expect_error(sanity_check_regions(incoming_regions = my_regions, projection = "hg38"), "start is greater than or equal to end") | ||
}) | ||
|
||
test_that("sanity_check_regions throws error when start or end is outside chromosomal range", { | ||
my_regions <- data.frame(chrom = c("chr1"), start = c(100), end = c(300000000)) | ||
expect_error(sanity_check_regions(incoming_regions = my_regions, projection = "hg38"), "Specified start or end coordinates fall outside the actual chromosomal range") | ||
}) | ||
|
||
test_that("sanity_check_regions runs successfully with valid input", { | ||
my_regions <- data.frame(chrom = c("chr1"), start = c(100), end = c(200)) | ||
expect_silent(sanity_check_regions(incoming_regions = my_regions, projection = "hg38")) | ||
}) | ||
|
||
test_that("sanity_check_regions runs successfully with valid input", { | ||
my_regions <- data.frame(chrom = c("1"), start = c(100), end = c(200)) | ||
expect_silent(sanity_check_regions(incoming_regions = my_regions, projection = "grch37")) | ||
}) | ||
|