From 25163ba0fed08258015e083abe123611572100fb Mon Sep 17 00:00:00 2001 From: Karim-Mane Date: Wed, 20 Sep 2023 07:32:03 +0200 Subject: [PATCH] fix conflicts with main --- .Rhistory | 512 --------- .github/workflows/R-CMD-check.yaml | 4 - .github/workflows/render_readme.yml | 28 - .github/workflows/test-coverage.yaml | 4 - CITATION.cff | 325 ------ DESCRIPTION | 54 +- Meta/vignette.rds | Bin 203 -> 0 bytes NAMESPACE | 49 - R/.DS_Store | Bin 6148 -> 0 bytes R/check_dhis2_attributes-helpers.R | 338 +----- R/check_dhis2_attributes.R | 74 -- R/read_from_dhis2-helpers.R | 124 +- R/read_from_dhis2.R | 123 +- R/read_from_file-helpers.R | 270 ----- R/read_from_file.R | 49 - R/read_from_fingertips-helpers.R | 421 +------ R/read_from_fingertips.R | 168 +-- R/read_from_redcap-helpers.R | 307 +---- R/read_from_redcap.R | 68 +- R/read_servers.R | 141 +-- R/read_servers_helpers.R | 680 +---------- R/readepi.R | 206 +--- R/readepi_helpers.R | 156 +-- R/show_example_file.R | 10 - R/show_tables.R | 92 +- README.Rmd | 153 +-- README.md | 166 +-- inst/.DS_Store | Bin 8196 -> 0 bytes inst/extdata/.DS_Store | Bin 8196 -> 0 bytes inst/extdata/fake_test.ini | 3 - inst/extdata/genomic_data/.DS_Store | Bin 6148 -> 0 bytes .../consensus_dir/consensus_genomes.fasta | 1000 ----------------- inst/extdata/test.ini | 4 - man/check_dhis2_attributes.Rd | 44 - man/connect_to_server.Rd | 17 - man/detect_separator.Rd | 22 - man/dhis2_subset_fields.Rd | 29 - man/dhis2_subset_records.Rd | 36 - man/fetch_data_from_query.Rd | 18 - man/fingertips_subset_columns.Rd | 24 - man/fingertips_subset_rows.Rd | 27 - man/get_base_name.Rd | 22 - man/get_data_elements.Rd | 18 - man/get_data_sets.Rd | 18 - man/get_extension.Rd | 22 - man/get_fingertips_metadata.Rd | 10 - man/get_id_column_name.Rd | 3 - man/get_ind_id_from_domain_id.Rd | 18 - man/get_ind_id_from_domain_name.Rd | 17 - man/get_ind_id_from_ind_name.Rd | 17 - man/get_ind_id_from_profile.Rd | 17 - man/get_organisation_units.Rd | 18 - man/get_profile_name.Rd | 18 - man/get_read_file_args.Rd | 27 - man/get_read_fingertips_args.Rd | 17 - man/get_relevant_data_elt_group.Rd | 23 - man/get_relevant_dataset.Rd | 31 - man/get_relevant_organisation_unit.Rd | 31 - man/identify_table_name.Rd | 11 - man/import_redcap_data.Rd | 21 - man/login.Rd | 5 - man/read_credentials.Rd | 20 - man/read_files.Rd | 23 - man/read_files_in_directory.Rd | 19 - man/read_from_dhis2.Rd | 12 - man/read_from_file.Rd | 46 - man/read_from_fingertips.Rd | 13 - man/read_from_redcap.Rd | 15 - man/read_multiple_files.Rd | 26 - man/read_rio_formats.Rd | 25 - man/readepi.Rd | 67 +- man/redcap_get_results.Rd | 25 - man/redcap_read.Rd | 23 - man/redcap_read_fields.Rd | 5 - man/redcap_read_records.Rd | 5 - man/redcap_read_rows_columns.Rd | 5 - man/show_tables.Rd | 21 - man/sql_select_data.Rd | 21 - man/sql_select_entire_dataset.Rd | 17 - man/sql_select_fields_only.Rd | 18 - man/sql_select_records_and_fields.Rd | 21 - man/sql_select_records_only.Rd | 21 - man/sql_server_read_data.Rd | 60 - man/visualise_table.Rd | 26 - tests/.DS_Store | Bin 8196 -> 0 bytes tests/testthat/.DS_Store | Bin 6148 -> 0 bytes .../test-check_dhis2_attributes-helpers.R | 393 ++----- tests/testthat/test-check_dhis2_attributes.R | 439 ++------ .../test-check_dhis2_attributes_helpers.R | 152 --- tests/testthat/test-read_from_dhis2.R | 134 --- tests/testthat/test-read_from_dhis2_helpers.R | 69 +- tests/testthat/test-read_from_file-helpers.R | 216 ---- tests/testthat/test-read_from_file.R | 189 ---- .../test-read_from_fingertips-helpers.R | 556 +++++++-- tests/testthat/test-read_from_fingertips.R | 280 ----- .../test-read_from_fingertips_helpers.R | 454 -------- .../testthat/test-read_from_redcap-helpers.R | 304 ++--- tests/testthat/test-read_from_redcap.R | 496 -------- .../testthat/test-read_from_redcap_helpers.R | 181 --- tests/testthat/test-read_servers.R | 12 - tests/testthat/test-read_servers_helpers.R | 379 ------- tests/testthat/test-readepi.R | 523 +-------- tests/testthat/test-readepi_helpers.R | 83 +- tests/testthat/test-show_tables.R | 65 +- vignettes/readepi.Rmd | 509 --------- 105 files changed, 1099 insertions(+), 10979 deletions(-) delete mode 100644 .Rhistory delete mode 100644 CITATION.cff delete mode 100644 Meta/vignette.rds delete mode 100644 R/.DS_Store delete mode 100644 R/read_from_file-helpers.R delete mode 100644 R/read_from_file.R delete mode 100644 inst/.DS_Store delete mode 100644 inst/extdata/.DS_Store delete mode 100644 inst/extdata/fake_test.ini delete mode 100644 inst/extdata/genomic_data/.DS_Store delete mode 100644 inst/extdata/genomic_data/consensus_dir/consensus_genomes.fasta delete mode 100644 man/check_dhis2_attributes.Rd delete mode 100644 man/detect_separator.Rd delete mode 100644 man/get_base_name.Rd delete mode 100644 man/get_data_elements.Rd delete mode 100644 man/get_data_sets.Rd delete mode 100644 man/get_extension.Rd delete mode 100644 man/get_organisation_units.Rd delete mode 100644 man/get_read_file_args.Rd delete mode 100644 man/get_relevant_data_elt_group.Rd delete mode 100644 man/get_relevant_dataset.Rd delete mode 100644 man/get_relevant_organisation_unit.Rd delete mode 100644 man/read_files.Rd delete mode 100644 man/read_files_in_directory.Rd delete mode 100644 man/read_from_file.Rd delete mode 100644 man/read_multiple_files.Rd delete mode 100644 man/read_rio_formats.Rd delete mode 100644 man/redcap_read.Rd delete mode 100644 tests/.DS_Store delete mode 100644 tests/testthat/.DS_Store delete mode 100644 tests/testthat/test-check_dhis2_attributes_helpers.R delete mode 100644 tests/testthat/test-read_from_file-helpers.R delete mode 100644 tests/testthat/test-read_from_file.R delete mode 100644 tests/testthat/test-read_from_fingertips_helpers.R delete mode 100644 tests/testthat/test-read_from_redcap_helpers.R diff --git a/.Rhistory b/.Rhistory deleted file mode 100644 index 28a90811..00000000 --- a/.Rhistory +++ /dev/null @@ -1,512 +0,0 @@ -id_column_name, field, -dbms, id_pos) -id_col_name -id_column_name <- get_id_column_name(id_col_name, j, id_position)[[1]] -all(!is.null(id_col_name) & !is.na(id_col_name)) -id_col_name[j] -id_column_name <- ifelse(all(grepl(",", id_col_name, fixed = TRUE) == TRUE & -length(id_col_name) > 1), -id_col_name[j], id_col_name) -id_column_name -j -id_col_name[j] -all(grepl(",", id_col_name, fixed = TRUE) == TRUE & -length(id_col_name) > 1) -id_col_name -id_column_name <- ifelse(all(grepl(",", id_col_name, fixed = TRUE) == TRUE & -length(id_col_name) > 1), -id_col_name[j], id_col_name) -id_column_name -id_col_name -all(grepl(",", id_col_name, fixed = TRUE) == TRUE & -length(id_col_name) > 1) -id_col_name -id_column_name=NULL -id_column_name <- ifelse(all(grepl(",", id_col_name, fixed = TRUE) == TRUE & -length(id_col_name) > 1), -id_col_name[j], id_col_name) -id_col_name[j] -id_column_name <- ifelse( -all(grepl(",", id_col_name, fixed = TRUE) == TRUE & length(id_col_name) > 1), -id_col_name[j], -id_col_name -) -id_column_name -length(id_col_name) > 1 -grepl(",", id_col_name, fixed = TRUE) == TRUE -if (all(grepl(",", id_col_name, fixed = TRUE) == TRUE & -length(id_col_name) > 1)) { -id_column_name = id_col_name -} else { -id_column_name = id_col_name[j] -} -id_col_name -id_column_name = id_col_name -author_id -id_column_name -if (all(grepl(",", id_col_name, fixed = TRUE) == TRUE & -length(id_col_name) > 1)) { -id_column_name <- id_col_name -} else { -id_column_name <- id_col_name[j] -} -all(grepl(",", id_col_name, fixed = TRUE) == TRUE & -length(id_col_name) > 1) -id_col_name -id_col_name=NULL -if (all(grepl(",", id_col_name, fixed = TRUE) == TRUE & -length(id_col_name) > 1)) { -id_column_name <- id_col_name[j] -} else { -id_column_name <- id_col_name -} -id_column_name <- ifelse(all(!is.null(id_column_name) & -!is.na(id_column_name)), -id_column_name[j], -NULL) -id_col_name=c("author_id", "rfam_acc") -id_col_name = gsub(" ", "", id_col_name) -id_col_name = unlist(strsplit(id_col_name, ",")) -id_col_name -devtools::load_all(".") -id_column_name <- get_id_column_name(id_col_name, j, id_position)[[1]] -id_pos <- get_id_column_name(id_col_name, j, id_position)[[2]] -id_pos -id_position -devtools::load_all(".") -id_column_name <- get_id_column_name(id_col_name, j, id_position)[[1]] -id_column_name -id_pos <- get_id_column_name(id_col_name, j, id_position)[[2]] -id_pos -devtools::load_all(".") -id_pos <- get_id_column_name(id_col_name, j, id_position)[[2]] -result[[table]] <- sql_select_records_and_fields(table, record, con, -id_column_name, field, -dbms, id_pos) -con = DBI::dbConnect(RMySQL::MySQL(), -driver = "", -host = "mysql-rfam-public.ebi.ac.uk", -dbname = "Rfam", -user = "rfamro", -password = "", -port = 4497 -) -result[[table]] <- sql_select_records_and_fields(table, record, con, -id_column_name, field, -dbms, id_pos) -result$family_author -data <- readepi(credentials_file, -project_id = "Rfam", -driver_name = "", -source = table_names, -records = records, -fields = fields, -id_col_name = c("author_id", "rfam_acc") -) -data$family_author -data$author -data <- readepi(credentials_file, -project_id = "Rfam", -driver_name = "", -source="select author.author_id, author.name, family_author.author_id from author left join family_author on author.author_id = family_author.author_id" -) -source="select author.author_id, author.name, family_author.author_id from author left join family_author on author.author_id = family_author.author_id" -from_query <- fetch_data_from_query(source, dbms, tables, -driver_name, host, database_name, -user, password, port) -dim(from_query$author_family_author) -devtools::load_all(".") -data <- readepi( -credentials_file, -project_id = "Rfam", -driver_name = "", -source="select author.author_id, author.name, family_author.author_id from author left join family_author on author.author_id = family_author.author_id" -) -table_names <- source[which(source %in% tables)] -source <- source[!(which(source %in% tables))] -tables -devtools::load_all(".") -idx <- which(source %in% tables) -length(idx) -devtools::load_all(".") -data <- readepi( -credentials_file, -project_id = "Rfam", -driver_name = "", -source="select author.author_id, author.name, family_author.author_id from author left join family_author on author.author_id = family_author.author_id" -) -dim(data$author_family_author) -data <- readepi( -credentials_file, -project_id = "Rfam", -driver_name = "", -source="select * from author" -) -dim(data$author) -data <- readepi( -credentials_file, -project_id = "Rfam", -driver_name = "", -source="select auhtor_id, name, last_name from author" -) -data <- readepi( -credentials_file, -project_id = "Rfam", -driver_name = "", -source="select author_id, name, last_name from author" -) -dim(data) -dim(data$author) -data <- readepi( -credentials_file, -project_id = "Rfam", -driver_name = "", -source="select * from author where author_id in ('1','20','50')" -) -dim(data$author) -data <- readepi( -credentials_file, -project_id = "Rfam", -driver_name = "", -source="select author_id, name, last_name from author where author_id in ('1','20','50')" -) -head(data$author) -dbms -devtools::load_all(".") -devtools::build_vignettes() -devtools::load_all(".") -devtools::build_readme() -devtools::load_all(".") -con <- connect_to_server( -dbms = "MySQL", -driver_name = "", -host = "mysql-rfam-public.ebi.ac.uk", -database_name = "Rfam", -user = "rfamro", -password = "", -port = 4497 -) -class(con) -driver_name = "" -length(driver_name) -devtools::load_all(".") -devtools::load_all(".") -devtools::load_all(".") -devtools::load_all(".") -devtools::load_all(".") -covr::package_coverage() -usethis::use_r("read_from_ms_sql_server-helpers") -devtools::load_all(".") -usethis::use_test("read_from_ms_sql_server-helpers") -covr::package_coverage() -covr::package_coverage() -devtools::load_all(".") -covr::package_coverage() -covr::package_coverage() -devtools::load_all(".") -devtools::load_all(".") -covr::package_coverage() -devtools::load_all(".") -covr::package_coverage() -data <- readepi( -credentials_file = credentials_file, -project_id = "DHIS2_DEMO", -dataset = "pBOMPrpg1QX", -organisation_unit = "DiszpKrYNg8", -data_element_group = NULL, -start_date = "2014", -end_date = "2023" -) -head(data$data) -data <- readepi( -credentials_file = credentials_file, -project_id = "DHIS2_DEMO", -dataset = "pBOMPrpg1QX,BfMAe6Itzgt", -organisation_unit = "DiszpKrYNg8", -data_element_group = NULL, -start_date = "2014", -end_date = "2023", -fields = c("dataElement","period","value") -) -head(data$data) -devtools::load_all(".") -data = readepi( -credentials_file = system.file("extdata", "test.ini", package = "readepi") -,project_id = "DHIS2_DEMO", -dataset = "pBOMPrpg1QX,BfMAe6Itzgt", -organisation_unit = "DiszpKrYNg8", -data_element_group = NULL, -start_date = "2014", -end_date = "2023" -)$data -dim(data) -devtools::load_all(".") -devtools::load_all(".") -devtools::load_all(".") -?REDCapR::redcap_read -devtools::load_all(".") -covr::package_coverage() -?usethis::rename_files -usethis::rename_files("tmp_read_servers.R", "read_servers.R") -devtools::load_all(".") -usethis::use_test("read_servers") -devtools::load_all(".") -devtools::load_all(".") -dbms -table_names <- "author,family_author" -fields <- c( -"author_id,name,last_name,initials", -"rfam_acc,author_id" -) -# the first string in the field vector corresponds to the name of the -# columns of interest from the first table specified in the `table_names` -# argument and so on... -data <- readepi(credentials_file, -project_id = "Rfam", -driver_name = "", -source = table_names, -fields = fields -) -credentials_file <- system.file("extdata", "test.ini", package = "readepi") -table_names <- "author,family_author" -fields <- c( -"author_id,name,last_name,initials", -"rfam_acc,author_id" -) -# the first string in the field vector corresponds to the name of the -# columns of interest from the first table specified in the `table_names` -# argument and so on... -data <- readepi(credentials_file, -project_id = "Rfam", -driver_name = "", -source = table_names, -fields = fields -) -data <- readepi(credentials_file, -project_id = "Rfam", -driver_name = "", # ODBC Driver 17 for SQL Server -source = "author" -) -fields <- "author_id,name,last_name,initials" -data <- readepi(credentials_file, -project_id = "Rfam", -driver_name = "", -source = "author", -fields = fields -) -records <- "1, 34, 15, 70, 118, 20" -data <- readepi(credentials_file, -project_id = "Rfam", -driver_name = "", -source = "author", -records = records, -id_position = 1 -) -data <- readepi(credentials_file, -project_id = "Rfam", -driver_name = "", -source = "author", -records = records, -fields = fields, -id_col_name = "author_id" -) -table_names <- "author,family_author" -data <- readepi(credentials_file, -project_id = "Rfam", -driver_name = "", -source = table_names -) -source="author,family_author" -tables=c("author","family_author") -which(source %in% tables) -class(source) -is.vector(source) -table_names <- c("author", "family_author") -data <- readepi(credentials_file, -project_id = "Rfam", -driver_name = "", -source = table_names -) -fields <- c( -"author_id,name,last_name,initials", -"rfam_acc,author_id" -) -data <- readepi(credentials_file, -project_id = "Rfam", -driver_name = "", -source = table_names, -fields = fields -) -records <- c( -"1, 34, 15, 70, 118, 20", -"RF00591,RF01420,RF01421" -) -data <- readepi(credentials_file, -project_id = "Rfam", -driver_name = "", -source = table_names, -records = records, -id_position = c(1, 1) -) -data <- readepi( -credentials_file, -project_id = "Rfam", -driver_name = "", -source = table_names, -records = records, -fields = fields, -id_col_name = c("author_id", "rfam_acc") -) -devtools::load_all(".") -covr::package_coverage() -sep <- detect_separator( -x = "My name is Karim" -) -sep -devtools::load_all(".") -devtools::load_all(".") -covr::package_coverage() -file_path = system.file("extdata", package = "readepi") -pattern = c(".txt", ".csv") -length(list.files(file_path, full.names = TRUE, -recursive = FALSE)) -files <- list.files(file_path, -full.names = TRUE, pattern = pat, -recursive = FALSE -) -pat=pattern[1] -files <- list.files(file_path, -full.names = TRUE, pattern = pat, -recursive = FALSE -) -files -dirs <- list.dirs(file_path, full.names = TRUE, recursive = FALSE) -dirs -file_path -idx <- which(files %in% dirs) -rio_extensions <- c( -"csv", "psv", "tsv", "csvy", "sas7bdat", "sav", "zsav", "dta", "xpt", -"por", "xls", "R", "RData", "rda", "rds", "rec", "mtp", "syd", "dbf", -"arff", "dif", "no recognized extension", "fwf", "csv.gz", "parquet", -"wf1", "feather", "fst", "json", "mat", "ods", "html", "xml", "yml" -) -# getting files extensions and basenames -files_extensions <- as.character(lapply(files, get_extension)) -files_extensions -files_base_names <- as.character(lapply(files, get_base_name)) -files_base_names -pat=pattern[2] -files <- list.files(file_path, -full.names = TRUE, pattern = pat, -recursive = FALSE -) -# getting files extensions and basenames -files_extensions <- as.character(lapply(files, get_extension)) -files_extensions -files -pat -pattern -result <- NULL -for (pat in pattern) { -files <- list.files(file_path, -full.names = TRUE, pattern = pat, -recursive = FALSE -) -dirs <- list.dirs(file_path, full.names = TRUE, recursive = FALSE) -res <- read_multiple_files(files, dirs) -result <- c(result, res) -} -devtools::load_all(".") -for (pat in pattern) { -files <- list.files(file_path, -full.names = TRUE, pattern = pat, -recursive = FALSE -) -dirs <- list.dirs(file_path, full.names = TRUE, recursive = FALSE) -res <- read_multiple_files(files, dirs) -result <- c(result, res) -} -result <- NULL -for (pat in pattern) { -files <- list.files(file_path, -full.names = TRUE, pattern = pat, -recursive = FALSE -) -dirs <- list.dirs(file_path, full.names = TRUE, recursive = FALSE) -res <- read_multiple_files(files, dirs) -result <- c(result, res) -} -devtools::load_all(".") -covr::package_coverage() -lintr::lint_package() -lintr::lint_package() -devtools::load_all(".") -lintr::lint_package() -devtools::load_all(".") -lintr::lint_package() -record=(1,NA,2) -record=c(1,NA,2) -anyNA(record) -devtools::load_all(".") -lintr::lint_package() -devtools::load_all(".") -lintr::lint_package() -devtools::load_all(".") -lintr::lint_package() -devtools::load_all(".") -lintr::lint_package() -devtools::load_all(".") -lintr::lint_package() -devtools::load_all(".") -lintr::lint_package() -devtools::load_all(".") -lintr::lint_package() -devtools::load_all(".") -lintr::lint_package() -devtools::load_all(".") -lintr::lint_package() -source = "select author.author_id, author.name, family_author.author_id from -author left join family_author on author.author_id = family_author.author_id" -print(source) -devtools::load_all(".") -lintr::lint_package() -devtools::load_all(".") -lintr::lint_package() -covr::package_coverage() -devtools::load_all(".") -devtools::load_all(".") -covr::package_coverage() -devtools::load_all(".") -devtools::load_all(".") -covr::package_coverage() -devtools::load_all(".") -usethis::use_tidy_description() -devtools::load_all(".") -covr::package_coverage() -devtools::load_all(".") -devtools::load_all(".") -result <- read_rio_formats( -files_extensions = ".txt", -rio_extensions = c("txt", "xlxs"), -files = system.file("extdata", "test.txt", package = "readepi"), -files_base_names = "test" -) -result <- detect_separator( -x = "My name is Karim" -) -result <- get_base_name( -x = system.file("extdata", "test.txt", package = "readepi") -) -result <- get_extension( -file_path = system.file("extdata", "test.txt", package = "readepi") -) -devtools::load_all(".") -devtools::load_all(".") -result <- read_rio_formats( -files_extensions = ".txt", -rio_extensions = c("txt", "xlxs"), -files = system.file("extdata", "test.txt", package = "readepi"), -files_base_names = "test" -) -class(result) -covr::package_coverage() diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index ff1fd8e9..81b741df 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -84,7 +84,6 @@ jobs: - uses: r-lib/actions/check-r-package@v2 id: rcmdcheck with: -<<<<<<< HEAD upload-snapshots: true # fail-fast but only if rcmdcheck step fails @@ -93,6 +92,3 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} if: always() && steps.rcmdcheck.outcome == 'failure' run: gh run cancel ${{ github.run_id }} -======= - upload-snapshots: true ->>>>>>> main diff --git a/.github/workflows/render_readme.yml b/.github/workflows/render_readme.yml index 62297a12..b103a9e6 100644 --- a/.github/workflows/render_readme.yml +++ b/.github/workflows/render_readme.yml @@ -42,11 +42,7 @@ jobs: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} steps: - name: Checkout repos -<<<<<<< HEAD uses: actions/checkout@v3 -======= - uses: actions/checkout@v2 ->>>>>>> main - name: Setup R uses: r-lib/actions/setup-r@v2 @@ -55,16 +51,11 @@ jobs: - name: Setup pandoc uses: r-lib/actions/setup-pandoc@v2 -<<<<<<< HEAD -======= - ->>>>>>> main - name: Install dependencies uses: r-lib/actions/setup-r-dependencies@v2 with: extra-packages: any::rmarkdown, local::. -<<<<<<< HEAD - name: Compile the readme run: | @@ -81,21 +72,6 @@ jobs: output_file = "README.md", output_dir = "." ) -======= - - - name: Compile the readme - run: | - tf <- tempfile(fileext = ".Rmd") - writeLines( - knitr::knit_expand( - "README.Rmd", - packagename = read.dcf("DESCRIPTION", "Package"), - gh_repo = Sys.getenv("GITHUB_REPOSITORY") - ), - tf - ) - rmarkdown::render(tf, output_file = "README.md", output_dir = ".") ->>>>>>> main shell: Rscript {0} - name: Commit files @@ -109,8 +85,4 @@ jobs: git add man/figures/ fi git diff-index --quiet HEAD || git commit -m "Automatic readme update" -<<<<<<< HEAD - git push origin || echo "No changes to push" -======= git push origin || echo "No changes to push" ->>>>>>> main diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml index 154a3403..add48dd0 100644 --- a/.github/workflows/test-coverage.yaml +++ b/.github/workflows/test-coverage.yaml @@ -51,13 +51,9 @@ jobs: - name: Test coverage run: covr::codecov(quiet = FALSE) -<<<<<<< HEAD shell: Rscript {0} - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v3 env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} -======= - shell: Rscript {0} ->>>>>>> main diff --git a/CITATION.cff b/CITATION.cff deleted file mode 100644 index 82bae015..00000000 --- a/CITATION.cff +++ /dev/null @@ -1,325 +0,0 @@ -# ----------------------------------------------------------- -# CITATION file created with {cffr} R package, v0.5.0 -# See also: https://docs.ropensci.org/cffr/ -# ----------------------------------------------------------- - -cff-version: 1.2.0 -message: 'To cite package "readepi" in publications use:' -type: software -license: MIT -title: 'readepi: Read Data From Health Information Systems' -version: 1.0.0 -abstract: Data import from several sources including files and health information - systems (HIS). The current version of the package covers HIS such as MS SQL, MySQL, - PostGRESQL servers, REDCap, DHIS2 and Fingertips. -authors: -- family-names: Mané - given-names: Karim - email: lshkm1@lshtm.ac.uk - orcid: https://orcid.org/0000-0002-9892-2999 -preferred-citation: - type: manual - title: Read Data From Health Information Systems - authors: - - family-names: Mané - given-names: Karim - email: lshkm1@lshtm.ac.uk - orcid: https://orcid.org/0000-0002-9892-2999 - - family-names: Mohammed - given-names: Nuredin - - family-names: Bah - given-names: Bubacarr - - family-names: Ahadzie - given-names: Bankolé - - family-names: Degoot - given-names: Abdoelnaser - year: '2023' - url: https://github.com/epiverse-trace/readepi -repository-code: https://github.com/epiverse-trace/readepi -url: https://github.com/epiverse-trace/readepi -contact: -- family-names: Mané - given-names: Karim - email: lshkm1@lshtm.ac.uk - orcid: https://orcid.org/0000-0002-9892-2999 -keywords: -- data-import -- epidemiology -- epiverse -- health-informatics-systems -- r -- r-package -references: -- type: software - title: checkmate - abstract: 'checkmate: Fast and Versatile Argument Checks' - notes: Imports - url: https://mllg.github.io/checkmate/ - repository: https://CRAN.R-project.org/package=checkmate - authors: - - family-names: Lang - given-names: Michel - email: michellang@gmail.com - orcid: https://orcid.org/0000-0001-9754-0393 - year: '2023' -- type: software - title: data.table - abstract: 'data.table: Extension of `data.frame`' - notes: Imports - url: https://r-datatable.com - repository: https://CRAN.R-project.org/package=data.table - authors: - - family-names: Dowle - given-names: Matt - email: mattjdowle@gmail.com - - family-names: Srinivasan - given-names: Arun - email: asrini@pm.me - year: '2023' -- type: software - title: DBI - abstract: 'DBI: R Database Interface' - notes: Imports - url: https://dbi.r-dbi.org - repository: https://CRAN.R-project.org/package=DBI - authors: - - name: R Special Interest Group on Databases (R-SIG-DB) - - family-names: Wickham - given-names: Hadley - - family-names: Müller - given-names: Kirill - email: krlmlr+r@mailbox.org - orcid: https://orcid.org/0000-0002-1416-3412 - year: '2023' -- type: software - title: dplyr - abstract: 'dplyr: A Grammar of Data Manipulation' - notes: Imports - url: https://dplyr.tidyverse.org - repository: https://CRAN.R-project.org/package=dplyr - authors: - - family-names: Wickham - given-names: Hadley - email: hadley@posit.co - orcid: https://orcid.org/0000-0003-4757-117X - - family-names: François - given-names: Romain - orcid: https://orcid.org/0000-0002-2444-4226 - - family-names: Henry - given-names: Lionel - - family-names: Müller - given-names: Kirill - orcid: https://orcid.org/0000-0002-1416-3412 - - family-names: Vaughan - given-names: Davis - email: davis@posit.co - orcid: https://orcid.org/0000-0003-4777-038X - year: '2023' -- type: software - title: fingertipsR - abstract: 'fingertipsR: Fingertips Data for Public Health' - notes: Imports - url: https://fingertips.phe.org.uk - authors: - - family-names: Fox - given-names: Sebastian - email: sebastian.fox@dhsc.gov.uk - - family-names: Flowers - given-names: Julian - year: '2023' - version: '>= 1.0.10.9001' -- type: software - title: glue - abstract: 'glue: Interpreted String Literals' - notes: Imports - url: https://glue.tidyverse.org/ - repository: https://CRAN.R-project.org/package=glue - authors: - - family-names: Hester - given-names: Jim - orcid: https://orcid.org/0000-0002-2739-7082 - - family-names: Bryan - given-names: Jennifer - email: jenny@rstudio.com - orcid: https://orcid.org/0000-0002-6983-2759 - year: '2023' -- type: software - title: httr - abstract: 'httr: Tools for Working with URLs and HTTP' - notes: Imports - url: https://httr.r-lib.org/ - repository: https://CRAN.R-project.org/package=httr - authors: - - family-names: Wickham - given-names: Hadley - email: hadley@posit.co - year: '2023' -- type: software - title: magrittr - abstract: 'magrittr: A Forward-Pipe Operator for R' - notes: Imports - url: https://magrittr.tidyverse.org - repository: https://CRAN.R-project.org/package=magrittr - authors: - - family-names: Bache - given-names: Stefan Milton - email: stefan@stefanbache.dk - - family-names: Wickham - given-names: Hadley - email: hadley@rstudio.com - year: '2023' -- type: software - title: odbc - abstract: 'odbc: Connect to ODBC Compatible Databases (using the DBI Interface)' - notes: Imports - url: https://r-dbi.github.io/odbc/ - repository: https://CRAN.R-project.org/package=odbc - authors: - - family-names: Hester - given-names: Jim - - family-names: Wickham - given-names: Hadley - email: hadley@rstudio.com - - family-names: Gjoneski - given-names: Oliver - year: '2023' -- type: software - title: pool - abstract: 'pool: Object Pooling' - notes: Imports - url: http://rstudio.github.io/pool/ - repository: https://CRAN.R-project.org/package=pool - authors: - - family-names: Cheng - given-names: Joe - email: joe@posit.co - - family-names: Borges - given-names: Barbara - - family-names: Wickham - given-names: Hadley - email: hadley@posit.co - year: '2023' -- type: software - title: REDCapR - abstract: 'REDCapR: Interaction Between R and REDCap' - notes: Imports - url: https://ouhscbbmc.github.io/REDCapR/ - repository: https://CRAN.R-project.org/package=REDCapR - authors: - - family-names: Beasley - given-names: Will - email: wibeasley@hotmail.com - orcid: https://orcid.org/0000-0002-5613-5006 - year: '2023' -- type: software - title: RMySQL - abstract: 'RMySQL: Database Interface and ''MySQL'' Driver for R' - notes: Imports - url: https://downloads.mariadb.org/connector-c/ - repository: https://CRAN.R-project.org/package=RMySQL - authors: - - family-names: Ooms - given-names: Jeroen - email: jeroen@berkeley.edu - orcid: https://orcid.org/0000-0002-4035-0289 - - family-names: James - given-names: David - - family-names: DebRoy - given-names: Saikat - - family-names: Wickham - given-names: Hadley - email: hadley@rstudio.com - - family-names: Horner - given-names: Jeffrey - year: '2023' -- type: software - title: bookdown - abstract: 'bookdown: Authoring Books and Technical Documents with R Markdown' - notes: Suggests - url: https://pkgs.rstudio.com/bookdown/ - repository: https://CRAN.R-project.org/package=bookdown - authors: - - family-names: Xie - given-names: Yihui - email: xie@yihui.name - orcid: https://orcid.org/0000-0003-0645-5666 - year: '2023' -- type: software - title: httptest - abstract: 'httptest: A Test Environment for HTTP Requests' - notes: Suggests - url: https://enpiar.com/r/httptest/ - repository: https://CRAN.R-project.org/package=httptest - authors: - - family-names: Richardson - given-names: Neal - email: neal.p.richardson@gmail.com - orcid: https://orcid.org/0009-0002-7992-3520 - year: '2023' -- type: software - title: knitr - abstract: 'knitr: A General-Purpose Package for Dynamic Report Generation in R' - notes: Suggests - url: https://yihui.org/knitr/ - repository: https://CRAN.R-project.org/package=knitr - authors: - - family-names: Xie - given-names: Yihui - email: xie@yihui.name - orcid: https://orcid.org/0000-0003-0645-5666 - year: '2023' -- type: software - title: rmarkdown - abstract: 'rmarkdown: Dynamic Documents for R' - notes: Suggests - url: https://pkgs.rstudio.com/rmarkdown/ - repository: https://CRAN.R-project.org/package=rmarkdown - authors: - - family-names: Allaire - given-names: JJ - email: jj@posit.co - - family-names: Xie - given-names: Yihui - email: xie@yihui.name - orcid: https://orcid.org/0000-0003-0645-5666 - - family-names: Dervieux - given-names: Christophe - email: cderv@posit.co - orcid: https://orcid.org/0000-0003-4474-2498 - - family-names: McPherson - given-names: Jonathan - email: jonathan@posit.co - - family-names: Luraschi - given-names: Javier - - family-names: Ushey - given-names: Kevin - email: kevin@posit.co - - family-names: Atkins - given-names: Aron - email: aron@posit.co - - family-names: Wickham - given-names: Hadley - email: hadley@posit.co - - family-names: Cheng - given-names: Joe - email: joe@posit.co - - family-names: Chang - given-names: Winston - email: winston@posit.co - - family-names: Iannone - given-names: Richard - email: rich@posit.co - orcid: https://orcid.org/0000-0003-3925-190X - year: '2023' -- type: software - title: testthat - abstract: 'testthat: Unit Testing for R' - notes: Suggests - url: https://testthat.r-lib.org - repository: https://CRAN.R-project.org/package=testthat - authors: - - family-names: Wickham - given-names: Hadley - email: hadley@posit.co - year: '2023' - version: '>= 3.0.0' diff --git a/DESCRIPTION b/DESCRIPTION index e683eb8a..c9bfde73 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,16 +1,10 @@ Package: readepi -<<<<<<< HEAD Title: Read Data From Health Information Systems Version: 1.0.0 -======= -Title: Import Data From Files and Health Information Systems Into R -Version: 0.0.1 ->>>>>>> main Authors@R: c( person("Karim", "Mané", , "lshkm1@lshtm.ac.uk", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-9892-2999")), person("Bubacarr", "Bah", , "Bubacarr.Bah1@lshtm.ac.uk", role = "ctb", -<<<<<<< HEAD comment = c(ORCID = "0000-0003-3318-6668")), person("Bankolé", "Ahadzie", , "Bankole.Ahadzie@lshtm.ac.uk", role = "ctb"), person("Nuredin", "Mohammed", , "Nuredin.Mohammed@lshtm.ac.uk", role = "ctb"), @@ -22,35 +16,13 @@ Authors@R: c( person("Andree", "Valle-Campos", , "andree.valle-campos@lshtm.ac.uk", role = "rev", comment = c(ORCID = "0000-0002-7779-481X")) ) -Description: Data import from several sources including files and health - information systems (HIS). The current version of the package covers - HIS such as MS SQL, MySQL, PostGRESQL servers, REDCap, DHIS2 and -======= - comment = c(ORCID = "0000-0003-3318-6668")), - person("Bankolé", "Ahadzie", , "Bankole.Ahadzie@lshtm.ac.uk", role = "ctb"), - person("Nuredin", "Mohammed", , - "Nuredin.Mohammed@lshtm.ac.uk", role = "ctb"), - person("Hugo", "Gruson", , "hugo.gruson@lshtm.ac.uk", role = "rev", - comment = c(ORCID = "0000-0002-4094-1476")), - person("Pratik", "Gupte", , "pratik.gupte@lshtm.ac.uk", role = "rev", - comment = c(ORCID = "0000-0001-5294-7819")), - person("Andree", "Valle-Campos", , - "andree.valle-campos@lshtm.ac.uk", role = "rev", - comment = c(ORCID = "0000-0002-7779-481X")) - ) -Description: Data import from several sources. These include files and - health information systems (HIS). The current version of the package - covers HIS such as REDCap, SQL, MySQL, PostGRESQL servers, DHIS2 and ->>>>>>> main - Fingertips. +Description: Data import from several health information systems (HIS). + The current version of the package covers HIS such as MS SQL, MySQL, + PostGRESQL servers, REDCap, DHIS2 and Fingertips. License: MIT + file LICENSE URL: https://github.com/epiverse-trace/readepi BugReports: https://github.com/epiverse-trace/readepi/issues -<<<<<<< HEAD Imports: -======= -Imports: ->>>>>>> main checkmate, data.table, DBI, @@ -61,7 +33,6 @@ Imports: magrittr, odbc, pool, -<<<<<<< HEAD REDCapR, RMySQL Suggests: @@ -70,30 +41,11 @@ Suggests: knitr, rmarkdown, testthat (>= 3.0.0) -======= - purrr, - R.utils, - readxl, - REDCapR, - rio, - RMySQL, - stringr -Suggests: - covr, - devtools, - knitr, - rmarkdown, - testthat (>= 3.0.0), - usethis ->>>>>>> main VignetteBuilder: knitr Remotes: rOpenSci/fingertipsR -<<<<<<< HEAD Config/Needs/website: epiverse-trace/epiversetheme -======= ->>>>>>> main Config/testthat/edition: 3 Encoding: UTF-8 Roxygen: list(markdown = TRUE) diff --git a/Meta/vignette.rds b/Meta/vignette.rds deleted file mode 100644 index 7752449006542c9df99c318b7976390ffd00baae..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 203 zcmV;+05ty}iwFP!0000018q>t4uUWcETy8LCMJA`dln_n(2 z3Pe_$>~`Ck+0OPDFvd6&oHOoX>4um*j17jv1oLrU8juPq9i_P<(58pBH+?C0!ylMhTy)S=CTluqprn=2*`U7j{Q{j~;>xlC F003{gU#kEB diff --git a/NAMESPACE b/NAMESPACE index 4bd9c19e..a582354e 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,58 +1,9 @@ # Generated by roxygen2: do not edit by hand -<<<<<<< HEAD export(get_dhis2_attributes) export(readepi) export(show_example_file) export(show_tables) -======= -export(check_dhis2_attributes) -export(connect_to_server) -export(detect_separator) -export(dhis2_subset_fields) -export(dhis2_subset_records) -export(fetch_data_from_query) -export(fingertips_subset_columns) -export(fingertips_subset_rows) -export(get_base_name) -export(get_data_elements) -export(get_data_sets) -export(get_extension) -export(get_fingertips_metadata) -export(get_ind_id_from_domain_id) -export(get_ind_id_from_domain_name) -export(get_ind_id_from_ind_name) -export(get_ind_id_from_profile) -export(get_organisation_units) -export(get_profile_name) -export(get_read_file_args) -export(get_read_fingertips_args) -export(get_relevant_data_elt_group) -export(get_relevant_dataset) -export(get_relevant_organisation_unit) -export(identify_table_name) -export(import_redcap_data) -export(read_credentials) -export(read_from_dhis2) -export(read_from_file) -export(read_from_fingertips) -export(read_from_redcap) -export(read_multiple_files) -export(readepi) -export(redcap_get_results) -export(redcap_read) -export(redcap_read_fields) -export(redcap_read_records) -export(redcap_read_rows_columns) -export(show_example_file) -export(show_tables) -export(sql_select_data) -export(sql_select_entire_dataset) -export(sql_select_fields_only) -export(sql_select_records_and_fields) -export(sql_select_records_only) -export(sql_server_read_data) ->>>>>>> main export(visualise_table) importFrom(magrittr,"%>%") importFrom(utils,read.table) diff --git a/R/.DS_Store b/R/.DS_Store deleted file mode 100644 index 5008ddfcf53c02e82d7eee2e57c38e5672ef89f6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0>>>>>> main } #' Get the relevant dataset #' -<<<<<<< HEAD #' @param base_url the web address of the server the user wishes to log in to #' @param username the user name #' @param password the user's password @@ -104,33 +74,23 @@ dhis2_get_relevant_attributes <- function(attribute_id = NULL, which = "dataSets") { checkmate::assert_character(base_url, len = 1L, any.missing = FALSE, - null.ok = FALSE - ) + null.ok = FALSE) checkmate::assert_character(username, len = 1L, any.missing = FALSE, - null.ok = FALSE - ) + null.ok = FALSE) checkmate::assert_character(password, len = 1L, any.missing = FALSE, - null.ok = FALSE - ) + null.ok = FALSE) checkmate::assert_character(which, len = 1L, any.missing = FALSE, - null.ok = FALSE - ) + null.ok = FALSE) checkmate::assert_character(attribute_id, len = 1L, any.missing = FALSE, - null.ok = TRUE - ) - checkmate::check_choice(which, c( - "dataSets", "organisationUnits", - "dataElementGroups", "dataElements" - )) + null.ok = TRUE) + checkmate::check_choice(which, c("dataSets", "organisationUnits", + "dataElementGroups", "dataElements")) if (is.character(attribute_id)) { - attribute_id <- unlist(strsplit(attribute_id, - ",", - fixed = TRUE - )) + attribute_id <- unlist(strsplit(attribute_id, ",", fixed = TRUE)) } response <- make_api_request(base_url, username, password, which) content <- httr::content(response, as = "parsed") @@ -151,20 +111,15 @@ dhis2_get_relevant_attributes <- function(attribute_id = NULL, attribute_id <- paste(attribute_id[idx], collapse = ",") } - res <- switch(which, - "dataSets" = list( - dataset = attribute_id, - data_sets = attributes - ), - "organisationUnits" = list( - organisation_unit = attribute_id, - org_units = attributes - ), - "dataElementGroups" = list( - data_element_group = attribute_id, - data_elt_groups = attributes - ), - "dataElements" = attributes + res <- switch( + which, + "dataSets" = list(dataset = attribute_id, + data_sets = attributes), + "organisationUnits" = list(organisation_unit = attribute_id, + org_units = attributes), + "dataElementGroups" = list(data_element_group = attribute_id, + data_elt_groups = attributes), + "dataElements" = attributes ) res } @@ -195,251 +150,20 @@ get_dhis2_attributes <- function(base_url = "https://play.dhis2.org/dev/", which = "dataSets") { checkmate::assert_character(base_url, len = 1L, any.missing = FALSE, - null.ok = FALSE, pattern = "https://" - ) + null.ok = FALSE, pattern = "https://") checkmate::assert_character(username, len = 1L, any.missing = FALSE, - null.ok = FALSE - ) + null.ok = FALSE) checkmate::assert_character(password, len = 1L, any.missing = FALSE, - null.ok = FALSE - ) + null.ok = FALSE) checkmate::assert_character(which, len = 1L, any.missing = FALSE, - null.ok = FALSE - ) - checkmate::check_choice(which, c( - "dataSets", "organisationUnits", - "dataElementGroups", "dataElements" - )) + null.ok = FALSE) + checkmate::check_choice(which, c("dataSets", "organisationUnits", + "dataElementGroups", "dataElements")) response <- make_api_request(base_url, username, password, which) content <- httr::content(response, as = "parsed") attributes <- do.call(rbind.data.frame, content[[which]]) attributes -======= -#' @param dataset the dataSets identifiers -#' @param base_url the web address of the server the user wishes to log in to -#' @param username the user name -#' @param password the user's password -#' -#' @return a list with the relevant datasets -#' @examples -#' result <- get_relevant_dataset( -#' dataset = "pBOMPrpg1QX,BfMAe6Itzgt", -#' base_url = "https://play.dhis2.org/dev/", -#' username = "admin", -#' password = "district" -#' ) -#' @export -get_relevant_dataset <- function(dataset, base_url, username, password) { - checkmate::assertCharacter(base_url, - len = 1L, null.ok = FALSE, - any.missing = FALSE - ) - checkmate::assertCharacter(username, - len = 1L, null.ok = FALSE, - any.missing = FALSE - ) - checkmate::assertCharacter(password, - len = 1L, null.ok = FALSE, - any.missing = FALSE - ) - checkmate::assert_vector(dataset, - any.missing = FALSE, min.len = 1, - null.ok = FALSE, unique = TRUE - ) - if (!is.null(dataset)) { - if (is.character(dataset)) dataset <- unlist(strsplit(dataset, ",", - fixed = TRUE)) - data_sets <- get_data_sets(base_url, username, password) - idx <- which(dataset %in% data_sets$id) - if (length(idx) == 0) { - stop("Provided dataSets not found!\n - Use get_data_sets() function to view the list of available dataSets.") - } - if (length(idx) < length(dataset)) { - warning("\nThe following dataSets were not found: ", - glue::glue_collapse(dataset[-idx], sep = ", ")) - } - dataset <- paste(dataset[idx], collapse = ",") - } - - list( - dataset, - data_sets - ) -} - - -#' Get the relevant organisation units -#' -#' @param organisation_unit the organisationUnits identifiers -#' @param base_url the web address of the server the user wishes to log in to -#' @param username the user name -#' @param password the user's password -#' -#' @return a list with the relevant organisation units -#' @examples -#' result <- get_relevant_organisation_unit( -#' organisation_unit = "DiszpKrYNg8", -#' base_url = "https://play.dhis2.org/dev/", -#' username = "admin", -#' password = "district" -#' ) -#' @export -get_relevant_organisation_unit <- function(organisation_unit, base_url, - username, password) { - checkmate::assertCharacter(base_url, - len = 1L, null.ok = FALSE, - any.missing = FALSE - ) - checkmate::assertCharacter(username, - len = 1L, null.ok = FALSE, - any.missing = FALSE - ) - checkmate::assertCharacter(password, - len = 1L, null.ok = FALSE, - any.missing = FALSE - ) - checkmate::assert_vector(organisation_unit, - any.missing = FALSE, min.len = 1, - null.ok = FALSE, unique = TRUE - ) - if (!is.null(organisation_unit)) { - if (is.character(organisation_unit)) organisation_unit <- - unlist(strsplit(organisation_unit, ",", fixed = TRUE)) - org_units <- get_organisation_units(base_url, username, password) - idx <- which(organisation_unit %in% org_units$id) - if (length(idx) == 0) { - stop("Provided organisationUnites not found!\n - Use get_organisation_units() function to view the list of available - dataSets.") - } - if (length(idx) < length(organisation_unit)) { - warning("\nThe following organisationUnite were not found: ", - glue::glue_collapse(organisation_unit[-idx], sep = ", ")) - } - organisation_unit <- paste(organisation_unit[idx], collapse = ",") - } - - list( - organisation_unit, - org_units - ) -} - - -#' Get the relevant data element groups -#' -#' @param data_element_group the dataElementGroups identifiers -#' @param base_url the web address of the server the user wishes to log in to -#' @param username the user name -#' @param password the user's password -#' -#' @return a list with the data elements of interest -#' @export -get_relevant_data_elt_group <- function(data_element_group, base_url, - username, password) { - checkmate::assertCharacter(base_url, - len = 1L, null.ok = FALSE, - any.missing = FALSE - ) - checkmate::assertCharacter(username, - len = 1L, null.ok = FALSE, - any.missing = FALSE - ) - checkmate::assertCharacter(password, - len = 1L, null.ok = FALSE, - any.missing = FALSE - ) - checkmate::assert_vector(data_element_group, - any.missing = FALSE, min.len = 0, - null.ok = TRUE, unique = TRUE - ) - checkmate::assertCharacter(base_url, - len = 1L, null.ok = FALSE, - any.missing = FALSE - ) - checkmate::assertCharacter(username, - len = 1L, null.ok = FALSE, - any.missing = FALSE - ) - checkmate::assertCharacter(password, - len = 1L, null.ok = FALSE, - any.missing = FALSE - ) - checkmate::assert_vector(data_element_group, - any.missing = FALSE, min.len = 1, - null.ok = TRUE, unique = TRUE - ) - data_elt_groups <- NULL - if (!is.null(data_element_group)) { - if (is.character(data_element_group)) data_element_group <- - unlist(strsplit(data_element_group, ",", fixed = TRUE)) - data_elt_groups <- get_organisation_units(base_url, username, password) - idx <- which(data_element_group %in% data_elt_groups$id) - if (length(idx) == 0) { - stop("Provided dataElementGroups not found!\n - Use get_organisation_units() function to view the list of available - dataSets.") - } - if (length(idx) < length(data_element_group)) { - warning("\nThe following dataElementGroups were not found: ", - glue::glue_collapse(data_element_group[-idx], sep = ", ")) - } - data_element_group <- paste(data_element_group[idx], collapse = ",") - } - - list( - data_element_group, - data_elt_groups - ) -} - -#' Get the data element identifiers and names -#' -#' @param username the user name -#' @param password the user's password -#' @param base_url the base URL of the DHIS2 server -#' -#' @export -#' -get_data_elements <- function(base_url, username, password) { - checkmate::assertCharacter(base_url, len = 1L, null.ok = TRUE, - any.missing = FALSE) - checkmate::assertCharacter(username, len = 1L, null.ok = TRUE, - any.missing = FALSE) - checkmate::assertCharacter(password, len = 1L, null.ok = TRUE, - any.missing = FALSE) - - url <- paste0(base_url, - "/api/dataElements?fields=id,name,shortName&paging=false") - r <- httr::content(httr::GET(url, httr::authenticate(username, password)), - as = "parsed") - do.call(rbind.data.frame, r$dataElements) -} - -#' Get the organisation unit identifiers and names -#' -#' @param username the user name -#' @param password the user's password -#' @param base_url the base URL of the DHIS2 server -#' -#' @export -#' -get_organisation_units <- function(base_url, username, password) { - checkmate::assertCharacter(base_url, len = 1L, null.ok = FALSE, - any.missing = FALSE) - checkmate::assertCharacter(username, len = 1L, null.ok = FALSE, - any.missing = FALSE) - checkmate::assertCharacter(password, len = 1L, null.ok = FALSE, - any.missing = FALSE) - - url <- paste0(base_url, - "/api/organisationUnits?fields=id,name,shortName&paging=false") - r <- httr::content(httr::GET(url, httr::authenticate(username, password)), - as = "parsed") - do.call(rbind.data.frame, r$organisationUnits) ->>>>>>> main } diff --git a/R/check_dhis2_attributes.R b/R/check_dhis2_attributes.R index 0451da5a..f360534f 100644 --- a/R/check_dhis2_attributes.R +++ b/R/check_dhis2_attributes.R @@ -7,7 +7,6 @@ #' @param organisation_unit the organisationUnits identifiers #' @param data_element_group the dataElementGroups identifiers #' -<<<<<<< HEAD #' @return a list of 7 elements of type `character`. #' #' @examples @@ -24,27 +23,11 @@ #' #' @keywords internal dhis2_check_attributes <- function(username, -======= -#' @return a list -#' @export -#' -#' @examples -#' attributes <- check_dhis2_attributes( -#' username = "admin", -#' password = "district", -#' base_url = "https://play.dhis2.org/dev/", -#' dataset = "pBOMPrpg1QX", -#' organisation_unit = "DiszpKrYNg8", -#' data_element_group = NULL -#' ) -check_dhis2_attributes <- function(username, ->>>>>>> main password, base_url, dataset, organisation_unit = NULL, data_element_group = NULL) { -<<<<<<< HEAD # get the relevant dataset if (!is.null(dataset)) { tmp_res <- dhis2_get_relevant_attributes( @@ -107,62 +90,5 @@ check_dhis2_attributes <- function(username, data_element_group = data_element_group, data_element_groups_details = data_elt_groups, data_elements = data_elements -======= - checkmate::assertCharacter(base_url, - len = 1L, null.ok = FALSE, - any.missing = FALSE - ) - checkmate::assertCharacter(username, - len = 1L, null.ok = FALSE, - any.missing = FALSE - ) - checkmate::assertCharacter(password, - len = 1L, null.ok = FALSE, - any.missing = FALSE - ) - checkmate::assert_vector(dataset, - any.missing = FALSE, min.len = 1, - null.ok = FALSE, unique = TRUE - ) - checkmate::assert_vector(organisation_unit, - any.missing = FALSE, min.len = 1, - null.ok = FALSE, unique = TRUE - ) - checkmate::assert_vector(data_element_group, - any.missing = FALSE, min.len = 1, - null.ok = TRUE, unique = TRUE - ) - data_elt_groups <- data_sets <- org_units <- data_elements <- NULL - - # get the relevant dataset - tmp_res <- get_relevant_dataset(dataset, base_url, username, password) - dataset <- tmp_res[[1]] - data_sets <- tmp_res[[2]] - - # get the relevant organisation units - tmp_res <- get_relevant_organisation_unit(organisation_unit, - base_url, username, - password) - organisation_unit <- tmp_res[[1]] - org_units <- tmp_res[[2]] - - # get the relevant data element groups - tmp_res <- get_relevant_data_elt_group(data_element_group, base_url, - username, password) - data_element_group <- tmp_res[[1]] - data_elt_groups <- tmp_res[[2]] - - # get the data element - data_elements <- get_data_elements(base_url, username, password) - - list( - dataset = dataset, - dataset_details = data_sets, - organisation_unit = organisation_unit, - org_units_details = org_units, - data_element_group = data_element_group, - data_element_groups_details = data_elt_groups, - data_elements = data_elements ->>>>>>> main ) } diff --git a/R/read_from_dhis2-helpers.R b/R/read_from_dhis2-helpers.R index 57619c05..b567969d 100644 --- a/R/read_from_dhis2-helpers.R +++ b/R/read_from_dhis2-helpers.R @@ -1,50 +1,29 @@ #' Check DHIS2 authentication details #' -<<<<<<< HEAD #' If the user were granted with access to the API, this will return a message #' specifying that the user was successfully connected. Otherwise, it will throw #' an error message. #' -======= ->>>>>>> main #' @param username the user name #' @param password the user's password #' @param base_url the base URL of the DHIS2 server #' -<<<<<<< HEAD #' @keywords internal #' login <- function(username, password, base_url) { checkmate::assert_character(username, len = 1L, any.missing = FALSE, - null.ok = FALSE - ) + null.ok = FALSE) checkmate::assert_character(password, len = 1L, any.missing = FALSE, - null.ok = FALSE - ) + null.ok = FALSE) checkmate::assert_character(base_url, len = 1L, any.missing = FALSE, - null.ok = FALSE - ) + null.ok = FALSE) url <- file.path(base_url, "api", "me") resp <- httr::GET(url, httr::authenticate(username, password)) httr::stop_for_status(resp) message("\nLogged in successfully!") -======= -login <- function(username, password, base_url) { - checkmate::assertCharacter(base_url, len = 1L, null.ok = FALSE, - any.missing = FALSE) - checkmate::assertCharacter(username, len = 1L, null.ok = FALSE, - any.missing = FALSE) - checkmate::assertCharacter(password, len = 1L, null.ok = FALSE, - any.missing = FALSE) - - url <- file.path(base_url, "api", "me") - resp <- httr::GET(url, httr::authenticate(username, password)) - httr::stop_for_status(resp) - R.utils::cat("\nLogged in successfully!") ->>>>>>> main } #' Subset fields when reading from DHIS2 @@ -52,7 +31,6 @@ login <- function(username, password, base_url) { #' @param fields vector of fields to select from the data frame #' @param data the input data frame #' -<<<<<<< HEAD #' @return an object of type `data.frame` with the data that contains only the #' fields of interest #' @examples @@ -76,52 +54,19 @@ login <- function(username, password, base_url) { dhis2_subset_fields <- function(data, fields) { checkmate::assert_data_frame(data, min.rows = 1L, null.ok = FALSE, - min.cols = 1L - ) + min.cols = 1L) checkmate::assert_vector(fields, min.len = 1L, null.ok = TRUE, - any.missing = FALSE - ) + any.missing = FALSE) if (!is.null(fields)) { if (is.character(fields)) { fields <- unlist(strsplit(fields, ",", - fixed = TRUE - )) + fixed = TRUE)) } idx <- which(fields %in% names(data)) if (length(idx) == 0L) stop(sprintf("Specified column not found! The data contains the following columns: %s", names(data))) -======= -#' @return the data frame with the fields of interest -#' @examples -#' results <- dhis2_subset_fields( -#' fields = c("dataElement","period","value"), -#' data = readepi( -#' credentials_file = system.file("extdata", "test.ini", package = "readepi"), -#' project_id = "DHIS2_DEMO", -#' dataset = "pBOMPrpg1QX,BfMAe6Itzgt", -#' organisation_unit = "DiszpKrYNg8", -#' data_element_group = NULL, -#' start_date = "2014", -#' end_date = "2023", -#' fields = c("dataElement","period","value") -#' )$data -#') -#' @export -dhis2_subset_fields <- function(fields, data) { - checkmate::assert_vector(fields, - any.missing = FALSE, min.len = 1, - null.ok = TRUE, unique = TRUE - ) - checkmate::assert_data_frame(data, null.ok = FALSE) - if (!is.null(fields)) { - if (is.character(fields)) fields <- unlist(strsplit(fields, ",", - fixed = TRUE)) - idx <- which(fields %in% names(data)) - if (length(idx) == 0) stop("Specified column not not!\nThe data contains the - following column:\n", names(data)) ->>>>>>> main if (length(idx) != length(fields)) { warning("The following fields were not found in the data: ", fields[-idx]) fields <- fields[idx] @@ -133,17 +78,12 @@ dhis2_subset_fields <- function(fields, data) { } -<<<<<<< HEAD #' Subset a specified set of records from a dataset imported from DHIS2 -======= -#' Title ->>>>>>> main #' #' @param records a vector of records to select from the data #' @param id_col_name the column name where the records belong to #' @param data the input data frame #' -<<<<<<< HEAD #' @return an object of type `data.frame` with the data that contains only the #' records of interest #' @examples @@ -168,58 +108,20 @@ dhis2_subset_fields <- function(fields, data) { dhis2_subset_records <- function(data, records, id_col_name) { checkmate::assert_data_frame(data, min.rows = 1L, null.ok = FALSE, - min.cols = 1L - ) + min.cols = 1L) checkmate::assert_vector(records, min.len = 1L, null.ok = TRUE, - any.missing = FALSE - ) + any.missing = FALSE) checkmate::assert_character(id_col_name, len = 1L, null.ok = TRUE, - any.missing = FALSE - ) + any.missing = FALSE) if (!is.null(records)) { if (is.character(records)) { - records <- unlist(strsplit(records, ",", - fixed = TRUE - )) + records <- unlist(strsplit(records, ",", fixed = TRUE)) } id_column_name <- id_col_name idx <- which(records %in% data[[id_column_name]]) if (length(idx) == 0L) { -======= -#' @return a data frame with the records of interest -#' @examples -#' result <- dhis2_subset_records( -#' records = c("FTRrcoaog83", "eY5ehpbEsB7", "Ix2HsbDMLea"), -#' id_col_name = "dataElement", -#' data = readepi( -#' credentials_file = system.file("extdata", "test.ini", package = "readepi"), -#' project_id = "DHIS2_DEMO", -#' dataset = "pBOMPrpg1QX", -#' organisation_unit = "DiszpKrYNg8", -#' data_element_group = NULL, -#' start_date = "2014", -#' end_date = "2023" -#' )$data -#' ) -#' -#' @export -dhis2_subset_records <- function(records, id_col_name, data) { - checkmate::assert_data_frame(data, null.ok = FALSE) - checkmate::assert_vector(records, - any.missing = FALSE, min.len = 1, - null.ok = TRUE, unique = TRUE - ) - checkmate::assertCharacter(id_col_name, len = 1, null.ok = TRUE, - any.missing = FALSE) - if (!is.null(records)) { - if (is.character(records)) records <- unlist(strsplit(records, ",", - fixed = TRUE)) - id_column_name <- id_col_name - idx <- which(records %in% data[[id_column_name]]) - if (length(idx) == 0) { ->>>>>>> main stop("Speficied records not found in column: ", id_column_name) } else if (length(idx) < length(records)) { warning("The following records were not found: ", records[-idx]) @@ -227,7 +129,6 @@ dhis2_subset_records <- function(records, id_col_name, data) { } data <- data[which(data[[id_column_name]] %in% records), ] } -<<<<<<< HEAD data } @@ -264,8 +165,3 @@ get_attributes_from_user <- function(args_list) { end_date = end_date ) } -======= - - data -} ->>>>>>> main diff --git a/R/read_from_dhis2.R b/R/read_from_dhis2.R index d22d42ba..4068b788 100644 --- a/R/read_from_dhis2.R +++ b/R/read_from_dhis2.R @@ -4,7 +4,6 @@ #' @param password the user password #' @param dataset a vector or a list of comma-separated data set identifiers #' @param organisation_unit a vector or a list of comma-separated organisation -<<<<<<< HEAD #' unit identifiers #' @param data_element_group a vector or a list of comma-separated data element #' group identifiers @@ -36,21 +35,6 @@ #' id_col_name = "dataElement" #' ) #' } -======= -#' unit identifiers -#' @param data_element_group a vector or a list of comma-separated data element -#' group identifiers -#' @param start_date the start date for the time span of the values to export -#' @param end_date the end date for the time span of the values to export -#' @param records a vector or a comma-separated string of subset of subject IDs. -#' When specified, only the records that correspond to these subjects will be -#' imported. -#' @param fields a vector or a comma-separated string of column names. -#' If provided, only those columns will be imported. -#' @param id_col_name the column name with the records of interest. -#' @returns a list of data frames -#' @export ->>>>>>> main read_from_dhis2 <- function(base_url, user_name, password, @@ -59,100 +43,39 @@ read_from_dhis2 <- function(base_url, data_element_group, start_date, end_date, -<<<<<<< HEAD records = NULL, fields = NULL, id_col_name = "dataElement") { checkmate::assert_character(base_url, len = 1L, null.ok = FALSE, - any.missing = FALSE - ) + any.missing = FALSE) checkmate::assert_character(user_name, len = 1L, null.ok = FALSE, - any.missing = FALSE - ) + any.missing = FALSE) checkmate::assert_character(password, len = 1L, null.ok = FALSE, - any.missing = FALSE - ) + any.missing = FALSE) checkmate::assert_vector(dataset, any.missing = FALSE, min.len = 1L, - null.ok = FALSE, unique = TRUE - ) + null.ok = FALSE, unique = TRUE) checkmate::assert_vector(organisation_unit, any.missing = FALSE, min.len = 1L, - null.ok = FALSE, unique = TRUE - ) + null.ok = FALSE, unique = TRUE) checkmate::assert_vector(data_element_group, any.missing = FALSE, min.len = 0L, - null.ok = TRUE, unique = TRUE - ) + null.ok = TRUE, unique = TRUE) checkmate::assert_vector(start_date, any.missing = FALSE, min.len = 0L, - null.ok = TRUE, unique = TRUE - ) + null.ok = TRUE, unique = TRUE) checkmate::assert_vector(end_date, any.missing = FALSE, min.len = 0L, - null.ok = TRUE, unique = TRUE -======= - records, - fields, - id_col_name = "dataElement") { - checkmate::assertCharacter(id_col_name, - len = 1L, null.ok = TRUE, - any.missing = FALSE - ) - checkmate::assertCharacter(base_url, - len = 1L, null.ok = FALSE, - any.missing = FALSE - ) - checkmate::assertCharacter(user_name, - len = 1L, null.ok = FALSE, - any.missing = FALSE - ) - checkmate::assertCharacter(password, - len = 1L, null.ok = FALSE, - any.missing = FALSE - ) - checkmate::assert_vector(dataset, - any.missing = FALSE, min.len = 1, - null.ok = FALSE, unique = TRUE - ) - checkmate::assert_vector(organisation_unit, - any.missing = FALSE, min.len = 1, - null.ok = FALSE, unique = TRUE - ) - checkmate::assert_vector(data_element_group, - any.missing = FALSE, min.len = 0, - null.ok = TRUE, unique = TRUE - ) - checkmate::assert_vector(start_date, - any.missing = FALSE, min.len = 0, - null.ok = TRUE, unique = TRUE - ) - checkmate::assert_vector(end_date, - any.missing = FALSE, min.len = 0, - null.ok = TRUE, unique = TRUE - ) - checkmate::assert_vector(records, - any.missing = FALSE, min.len = 0, - null.ok = TRUE, unique = TRUE - ) - checkmate::assert_vector(fields, - any.missing = FALSE, min.len = 0, - null.ok = TRUE, unique = TRUE ->>>>>>> main - ) + null.ok = TRUE, unique = TRUE) # checking user credentials login(user_name, password, base_url) # checking the attribute details -<<<<<<< HEAD attributes <- dhis2_check_attributes( -======= - attributes <- check_dhis2_attributes( ->>>>>>> main user_name, password, base_url, @@ -166,34 +89,19 @@ read_from_dhis2 <- function(base_url, file.path(base_url, "api", "dataValueSets"), httr::authenticate(user_name, password), query = list( -<<<<<<< HEAD - dataSet = attributes[["dataset"]], - orgUnit = attributes[["organisation_unit"]], + dataSet = attributes[["dataset"]], + orgUnit = attributes[["organisation_unit"]], startDate = start_date, -======= - dataSet = attributes$dataset, - orgUnit = attributes$organisation_unit, - startDate = start_date, # "2014" ->>>>>>> main - endDate = end_date + endDate = end_date ) ) %>% httr::content() %>% -<<<<<<< HEAD dplyr::bind_rows() # add the variable names tmp_data_elt <- attributes[["data_elements"]][, c("shortName", "id")] %>% dplyr::rename("dataElement" = "id") tmp_org_units <- attributes[["org_units_details"]][, c("shortName", "id")] %>% -======= - purrr::flatten_dfr() - - # add the variable names - tmp_data_elt <- attributes$data_elements[, c("shortName", "id")] %>% - dplyr::rename("dataElement" = "id") - tmp_org_units <- attributes$org_units_details[, c("shortName", "id")] %>% ->>>>>>> main dplyr::rename("orgUnit" = "id") data <- data %>% dplyr::left_join(tmp_data_elt, by = "dataElement") %>% @@ -202,7 +110,6 @@ read_from_dhis2 <- function(base_url, dplyr::rename("OrgUnitName" = "shortName") # subsetting fields -<<<<<<< HEAD data <- dhis2_subset_fields(data, fields) # subsetting records @@ -211,12 +118,4 @@ read_from_dhis2 <- function(base_url, list( data = data ) -======= - data <- dhis2_subset_fields(fields, data) - - # subsetting records - data <- dhis2_subset_records(records, id_col_name, data) - - list(data = data) ->>>>>>> main } diff --git a/R/read_from_file-helpers.R b/R/read_from_file-helpers.R deleted file mode 100644 index f47ea317..00000000 --- a/R/read_from_file-helpers.R +++ /dev/null @@ -1,270 +0,0 @@ -#' Get file extension -#' -#' @param file_path the target file path -#' -#' @return a string that corresponds to the file extension -#' @export -#' -#' @examples -#' ext <- get_extension( -#' file_path = system.file("extdata", "test.txt", package = "readepi") -#' ) -get_extension <- function(file_path) { - checkmate::assert_character(file_path, any.missing = FALSE, null.ok = FALSE, - len = 1) - checkmate::assert_file_exists(file_path) - splits <- unlist(strsplit(basename(file_path), ".", fixed = TRUE)) - extension <- splits[length(splits)] - extension -} - -#' Get file base name -#' -#' @param x the file path -#' -#' @return the file base name -#' -#' @examples -#' base_name <- get_base_name( -#' x = system.file("extdata", "test.txt", package = "readepi") -#' ) -#' @export -get_base_name <- function(x) { - checkmate::assert_character(x, any.missing = FALSE, null.ok = FALSE, - len = 1) - ext <- get_extension(x) - bn <- gsub(paste0(".", ext), "", basename(x)) - bn -} - -#' Detect separator from a string -#' -#' @param x a string -#' -#' @return a vector of identified separators -#' @export -#' -#' @examples -#' sep <- detect_separator( -#' x = "My name is Karim" -#' ) -detect_separator <- function(x) { - checkmate::assert_character(x, any.missing = FALSE, null.ok = FALSE) - special_characters <- c("\t", "|", ",", ";", " ") - sep <- NULL - for (spec.char in special_characters) { - if (stringr::str_detect(x, spec.char)) { - sep <- c(sep, spec.char) - } - } - unique(sep) -} - - -#' Title -#' -#' @param files_extensions a vector a file extensions made from your files of -#' interest -#' @param rio_extensions a vector of files extensions supported by the rio -#' package -#' @param files a vector a files of interest -#' @param files_base_names a vector of file base -#' -#' @return a list a the parameters needed to import data using rio -#' -read_rio_formats <- function(files_extensions, rio_extensions, - files, files_base_names) { - checkmate::assert_vector(files_extensions, any.missing = FALSE, - null.ok = FALSE, min.len = 1) - checkmate::assert_vector(rio_extensions, any.missing = FALSE, - null.ok = FALSE, min.len = 1) - checkmate::assert_vector(files, any.missing = FALSE, - null.ok = FALSE, min.len = 1) - checkmate::assert_vector(files_base_names, any.missing = FALSE, - null.ok = FALSE, min.len = 1) - idx <- which(files_extensions %in% rio_extensions) - result <- list() - if (length(idx) > 0) { - tmp_files <- files[idx] - tmp_bn <- files_base_names[idx] - i <- 1 - for (file in tmp_files) { - data <- rio::import(file) # , format = format, which = which - result[[tmp_bn[i]]] <- data - i <- i + 1 - } - files <- files[-idx] - files_base_names <- files_base_names[-idx] - files_extensions <- files_extensions[-idx] - } - list( - files = files, - files_base_names = files_base_names, - files_extensions = files_extensions, - result = result - ) -} - - -#' Read multiple files, including multiple files in a directory -#' -#' @param files a file or vector of file path to import -#' @param dirs a directory or a vector of directories where files will be -#' imported from -#' @param format a string used to specify the file format. This is useful when a -#' file does not have an extension, or has a file extension that does not match -#' its actual type -#' @param which a string used to specify the name of the excel sheet to import -#' -#' @return a list of data frames where each data frame contains data from a file -#' @export -#' -read_multiple_files <- function(files, dirs, format = NULL, which = NULL) { - checkmate::assert_vector(files, any.missing = FALSE, - null.ok = FALSE, min.len = 1) - checkmate::assert_vector(dirs, any.missing = FALSE, - null.ok = FALSE, min.len = 1) - checkmate::assert_character(format, null.ok = TRUE, any.missing = FALSE) - checkmate::assert_vector(which, any.missing = FALSE, min.len = 1, - null.ok = TRUE, unique = TRUE) - result <- NULL - # filter out directories from files - idx <- which(files %in% dirs) - if (length(idx) > 0) { - files <- files[-idx] - } - - # defining rio package file extensions - rio_extensions <- c( - "csv", "psv", "tsv", "csvy", "sas7bdat", "sav", "zsav", "dta", "xpt", - "por", "xls", "R", "RData", "rda", "rds", "rec", "mtp", "syd", "dbf", - "arff", "dif", "no recognized extension", "fwf", "csv.gz", "parquet", - "wf1", "feather", "fst", "json", "mat", "ods", "html", "xml", "yml" - ) - - # getting files extensions and basenames - files_extensions <- as.character(lapply(files, get_extension)) - files_base_names <- as.character(lapply(files, get_base_name)) - - # reading files with extensions that are taken care by rio - if (length(files_extensions) > 0) { - tmp.res <- read_rio_formats(files_extensions, rio_extensions, - files, files_base_names) - files <- tmp.res$files - files_base_names <- tmp.res$files_base_names - files_extensions <- tmp.res$files_extensions - result <- tmp.res$result - - # reading files which extensions are not taken care by rio - i <- 1 - for (file in files) { - if (files_extensions[i] %in% c("xlsx", "xls")) { - data <- readxl::read_xlsx(file) - result[[files_base_names[i]]] <- data - i <- i + 1 - } else { - tmp_string <- readLines(con = file, n = 1) - sep <- detect_separator(tmp_string) - if (length(sep) == 1 && sep == "|") { - sep <- "|" - } else { - sep <- sep[-(which(sep == "|"))] - if (length(sep) == 2 && " " %in% sep) { - sep <- sep[-(which(sep == " "))] - if (length(sep) > 1) { - R.utils::cat("\nCan't resolve separator in", file, "\n") - i <- i + 1 - next - } - } - } - data <- data.table::fread(file, sep = sep, nThread = 4) - result[[files_base_names[i]]] <- data - i <- i + 1 - } - } - } - - result -} - - -#' Sub-function for reading file in a directory -#' -#' @param file_path the path to the file to be read -#' @param pattern when specified, only files with this suffix will be imported -#' -#' @return a list of data frames where each contains data read from a file -#' -read_files_in_directory <- function(file_path, pattern) { - checkmate::assert_character(pattern, null.ok = TRUE, min.len = 1, - any.missing = FALSE) - checkmate::assert_character(file_path, null.ok = FALSE, len = 1, - any.missing = FALSE) - result <- NULL - if (length(list.files(file_path, full.names = TRUE, - recursive = FALSE)) == 0) { - stop("Could not find any file in ", file_path) - } - - if (!is.null(pattern)) { - for (pat in pattern) { - files <- list.files(file_path, - full.names = TRUE, pattern = pat, - recursive = FALSE - ) - if (length(files) == 0) { - next - } - dirs <- list.dirs(file_path, full.names = TRUE, recursive = FALSE) - res <- read_multiple_files(files, dirs) - result <- c(result, res) - } - } else { - files <- list.files(file_path, full.names = TRUE, recursive = FALSE) - dirs <- list.dirs(file_path, full.names = TRUE, recursive = FALSE) - result <- read_multiple_files(files, dirs) - } - - result -} - -#' Sub-function for reading files using rio package -#' -#' @param sep the separator between the columns in the file -#' @param file_path the path to the file to be read -#' @param which a string used to specify the name of the excel sheet to import -#' @param format a string used to specify the file format -#' -#' @return a list of data frames where each contains data from a file -#' -read_files <- function(sep, file_path, which, format) { - checkmate::assert_character(sep, null.ok = TRUE, len = 1, any.missing = FALSE) - checkmate::assert_character(format, null.ok = TRUE, any.missing = FALSE) - checkmate::assert_vector(which, any.missing = FALSE, min.len = 1, - null.ok = TRUE, unique = TRUE) - checkmate::assert_character(file_path, null.ok = FALSE, len = 1, - any.missing = FALSE) - result <- NULL - if (!is.null(sep)) { - result[[1]] <- data.table::fread(file_path, sep = sep) - } else if (is.null(sep)) { - if (all(!is.null(which) & !is.null(format))) { - for (wh in which) { - data <- rio::import(file_path, format = format, which = wh) - result[[wh]] <- data - } - } else if (!is.null(which) && is.null(format)) { - for (wh in which) { - data <- rio::import(file_path, which = wh) - result[[wh]] <- data - } - } else if (!is.null(format) && is.null(which)) { - result[[1]] <- rio::import(file_path, format = format) - } else { - result[[1]] <- rio::import(file_path) - } - } - - result -} diff --git a/R/read_from_file.R b/R/read_from_file.R deleted file mode 100644 index ca3f5834..00000000 --- a/R/read_from_file.R +++ /dev/null @@ -1,49 +0,0 @@ -#' Read data from file or directory -#' @param file_path the path to the file to be read. When several files need to -#' be imported from a directory, this should be the path to that directory -#' @param sep the separator between the columns in the file. This is only -#' required for space-separated files -#' @param format a string used to specify the file format. This is useful when -#' a file does not have an extension, or has a file extension that does not -#' match its actual type -#' @param which a string used to specify the name of the excel sheet to import -#' @param pattern when specified, only files with this suffix will be imported -#' from the specified directory -#' @returns a list of 1 (when reading from file) or several (when reading from -#' directory or reading several excel sheets) data frames -#' @examples -#' data <- read_from_file( -#' file_path = system.file("extdata", "test.txt", package = "readepi"), -#' sep = NULL, -#' format = NULL, -#' which = NULL, -#' pattern = NULL -#' ) -#' @export -read_from_file <- function(file_path, sep = NULL, format = NULL, which = NULL, - pattern = NULL) { - - # check the input arguments - checkmate::assert_character(sep, null.ok = TRUE, len = 1, any.missing = FALSE) - checkmate::assert_character(format, null.ok = TRUE, any.missing = FALSE) - checkmate::assert_vector(which, any.missing = FALSE, min.len = 1, - null.ok = TRUE, unique = TRUE) - checkmate::assert_character(pattern, null.ok = TRUE, min.len = 1, - any.missing = FALSE) - checkmate::assert_character(file_path, null.ok = FALSE, len = 1, - any.missing = FALSE) - - if (all(!checkmate::test_file_exists(file_path) & - !checkmate::test_directory_exists(file_path))) { - stop("Must provide a file path or directory") - } - - # reading several files from a directory - result <- list() - if (checkmate::test_directory_exists(file_path)) { - result <- read_files_in_directory(file_path, pattern) - } else if (checkmate::test_file_exists(file_path)) { - result <- read_files(sep, file_path, which, format) - } - result -} diff --git a/R/read_from_fingertips-helpers.R b/R/read_from_fingertips-helpers.R index be37bc28..d5366f76 100644 --- a/R/read_from_fingertips-helpers.R +++ b/R/read_from_fingertips-helpers.R @@ -1,6 +1,5 @@ #' get fingertips metadata #' -<<<<<<< HEAD #' @return a `list` of 3 objects of type `data.frame`. They contain information #' about the indicators in the Fingertips repository. #' @@ -9,12 +8,6 @@ #' metadata <- get_fingertips_metadata() #' } #' @keywords internal -======= -#' @return a list of data frames -#' @export -#' @examples -#' metadata <- get_fingertips_metadata() ->>>>>>> main #' get_fingertips_metadata <- function() { list( @@ -24,11 +17,7 @@ get_fingertips_metadata <- function() { fingertipsR::indicators_unique(), # indicators, ids, names area_type = fingertipsR::area_types() # area type ids, descriptions, -<<<<<<< HEAD # mapping of parent area types -======= - #mapping of parent area types ->>>>>>> main ) } @@ -37,7 +26,6 @@ get_fingertips_metadata <- function() { #' @param metadata a list with the fingertips metadata #' @param indicator_name the indicator name #' -<<<<<<< HEAD #' @return an object of type `numeric` that contains the indicator ID #' #' @examples @@ -55,12 +43,10 @@ get_fingertips_metadata <- function() { get_ind_id_from_ind_name <- function(metadata, indicator_name) { checkmate::assert_list(metadata, len = 3L, null.ok = FALSE, - any.missing = FALSE - ) + any.missing = FALSE) checkmate::assert_vector(indicator_name, min.len = 1L, null.ok = FALSE, - any.missing = FALSE - ) + any.missing = FALSE) indicator_name <- unlist(strsplit(indicator_name, ",", fixed = TRUE)) idx <- suppressWarnings( as.numeric( @@ -84,53 +70,10 @@ get_ind_id_from_ind_name <- function(metadata, indicator_name) { if (anyNA(idx)) { warning("\nThe following indicator names were not found: ", glue::glue_collapse(indicator_name[which(is.na(idx))], - sep = ", " - ), - call. = FALSE - ) + sep = ", "), call. = FALSE) } indicator_id <- metadata[["indicator_ids_names"]][["IndicatorID"]][idx[!is.na(idx)]] -======= -#' @return the indicator ID -#' @export -#' @examples -#' indicator_id <- get_ind_id_from_ind_name( -#' metadata = list( -#' indicator_profile_domain = fingertipsR::indicators(), -#' indicator_ids_names = fingertipsR::indicators_unique(), -#' area_type = fingertipsR::area_types() -#' ), -#' indicator_name = "Pupil absence" -#' ) -#' -get_ind_id_from_ind_name <- function(metadata, indicator_name) { - checkmate::assert_list(metadata, any.missing = FALSE, len = 3, - null.ok = FALSE) - checkmate::assert_vector(indicator_name, any.missing = FALSE, min.len = 0, - null.ok = TRUE, unique = TRUE - ) - - indicator_name <- unlist(strsplit(indicator_name, ",", fixed = TRUE)) - idx <- which(metadata$indicator_ids_names$IndicatorName == indicator_name) - if (length(idx) == 0) { - subs <- metadata$indicator_ids_names[grepl( - tolower(indicator_name), - tolower(metadata$indicator_ids_names$IndicatorName) - ), ] - if (nrow(subs) == 0) { - R.utils::cat("\nCould not find specified indicator name.\n - Below is the list of all indicator names in Fingertips.\n") - print(metadata$indicator_ids_names) - stop() - } else { - R.utils::cat("\nspecified indicator name not found but detected following - similar indicator names:\n") - print(subs) - } - } else { - indicator_id <- metadata$indicator_ids_names$IndicatorID[idx] ->>>>>>> main } indicator_id } @@ -141,7 +84,6 @@ get_ind_id_from_ind_name <- function(metadata, indicator_name) { #' @param domain_id the domain ID #' @param indicator_name the indicator name #' -<<<<<<< HEAD #' @return an object of type `numeric` that contains the indicator ID #' @examples #' \dontrun{ @@ -161,16 +103,13 @@ get_ind_id_from_domain_id <- function(metadata, domain_id, indicator_name = NULL) { checkmate::assert_list(metadata, len = 3L, null.ok = FALSE, - any.missing = FALSE - ) + any.missing = FALSE) checkmate::assert_vector(domain_id, min.len = 1L, null.ok = FALSE, - any.missing = FALSE - ) + any.missing = FALSE) checkmate::assert_vector(indicator_name, min.len = 1L, null.ok = TRUE, - any.missing = FALSE - ) + any.missing = FALSE) # check if the provided domain_id is part of the Fingertips idx <- domain_id %in% metadata[["indicator_profile_domain"]][["DomainID"]] @@ -202,55 +141,6 @@ get_ind_id_from_domain_id <- function(metadata, domain_id, } else { indicator_id <- unique(metadata[["indicator_profile_domain"]][["IndicatorID"]][idx]) -======= -#' @return the indicator ID -#' @export -#' @examples -#' indicator_id <- get_ind_id_from_domain_id( -#' metadata = list( -#' indicator_profile_domain = fingertipsR::indicators(), -#' indicator_ids_names = fingertipsR::indicators_unique(), -#' area_type = fingertipsR::area_types() -#' ), -#' domain_id = 1000041, -#' indicator_name = NULL -#' ) -#' -get_ind_id_from_domain_id <- function(metadata, domain_id, - indicator_name = NULL) { - checkmate::assert_list(metadata, any.missing = FALSE, len = 3, - null.ok = FALSE) - checkmate::assert_vector(indicator_name, any.missing = FALSE, min.len = 0, - null.ok = TRUE, unique = TRUE - ) - checkmate::assert_vector(domain_id, any.missing = FALSE, min.len = 0, - null.ok = TRUE, unique = TRUE) - - idx <- which(metadata$indicator_profile_domain$DomainID == domain_id) - if (length(idx) == 0) { - subs <- metadata$indicator_profile_domain[grepl( - domain_id, - metadata$indicator_profile_domain$DomainID - ), ] - if (nrow(subs) == 0) { - R.utils::cat("\nCould not find specified domain ID.\n - Below is the list of all domain IDs in Fingertips.\n") - print(metadata$indicator_profile_domain[, c("DomainID", "DomainName")]) - stop() - } else { - R.utils::cat("\nspecified domain ID not found but detected following - similar domain IDs:\n") - print(subs[, c("DomainID", "DomainName")]) - } - } else { - if (!is.null(indicator_name)) { - indicator_name <- unlist(strsplit(indicator_name, ",", fixed = TRUE)) - subs <- metadata$indicator_profile_domain[idx, ] - subs <- subs[which(subs$IndicatorName %in% indicator_name), ] - indicator_id <- subs$IndicatorID - } else { - indicator_id <- metadata$indicator_profile_domain$IndicatorID[idx] ->>>>>>> main } } indicator_id @@ -262,7 +152,6 @@ get_ind_id_from_domain_id <- function(metadata, domain_id, #' @param domain_name the domain name #' @param indicator_name the indicator name #' -<<<<<<< HEAD #' @return an object of type `numeric` that contains the indicator ID #' @examples #' \dontrun{ @@ -280,16 +169,13 @@ get_ind_id_from_domain_name <- function(metadata, domain_name, indicator_name = NULL) { checkmate::assert_list(metadata, len = 3L, null.ok = FALSE, - any.missing = FALSE - ) + any.missing = FALSE) checkmate::assert_vector(domain_name, min.len = 1L, null.ok = FALSE, - any.missing = FALSE - ) + any.missing = FALSE) checkmate::assert_vector(indicator_name, min.len = 1L, null.ok = TRUE, - any.missing = FALSE - ) + any.missing = FALSE) domain_name <- unlist(strsplit(domain_name, ",", fixed = TRUE)) idx <- suppressWarnings( as.numeric( @@ -326,54 +212,6 @@ get_ind_id_from_domain_name <- function(metadata, domain_name, } else { indicator_id <- unique(metadata[["indicator_profile_domain"]][["IndicatorID"]][idx]) -======= -#' @return the indicator ID -#' @export -#' @examples -#' indicator_id <- get_ind_id_from_domain_name( -#' metadata = list( -#' indicator_profile_domain = fingertipsR::indicators(), -#' indicator_ids_names = fingertipsR::indicators_unique(), -#' area_type = fingertipsR::area_types() -#' ), -#' domain_name = "B. Wider determinants of health", -#' ) -#' -get_ind_id_from_domain_name <- function(metadata, domain_name, - indicator_name = NULL) { - checkmate::assert_list(metadata, any.missing = FALSE, len = 3, - null.ok = FALSE) - checkmate::assert_vector(domain_name, any.missing = FALSE, min.len = 0, - null.ok = TRUE, unique = TRUE) - checkmate::assert_vector(indicator_name, any.missing = FALSE, min.len = 0, - null.ok = TRUE, unique = TRUE) - - domain_name <- unlist(strsplit(domain_name, ",", fixed = TRUE)) - idx <- which(metadata$indicator_profile_domain$DomainName == domain_name) - if (length(idx) == 0) { - subs <- metadata$indicator_profile_domain[grepl( - domain_name, - metadata$indicator_profile_domain$DomainName - ), ] - if (nrow(subs) == 0) { - R.utils::cat("\nCould not find specified domain name.\n - Below is the list of all domain names in Fingertips.\n") - print(metadata$indicator_profile_domain[, c("DomainID", "DomainName")]) - stop() - } else { - R.utils::cat("\nspecified domain name not found but detected following - similar domain names:\n") - print(subs[, c("DomainID", "DomainName")]) - } - } else { - if (!is.null(indicator_name)) { - indicator_name <- unlist(strsplit(indicator_name, ",", fixed = TRUE)) - subs <- metadata$indicator_profile_domain[idx, ] - subs <- subs[which(subs$IndicatorName %in% indicator_name)] - indicator_id <- subs$IndicatorID - } else { - indicator_id <- metadata$indicator_profile_domain$IndicatorID[idx] ->>>>>>> main } } indicator_id @@ -386,7 +224,6 @@ get_ind_id_from_domain_name <- function(metadata, domain_name, #' @param profile_name the profile name #' @param metadata the Fingertips metadata #' -<<<<<<< HEAD #' @return a `list` of 2 elements of type `character` and `numeric`. These are #' the `profile name` and their correspondent indexes. #' @examples @@ -405,80 +242,35 @@ get_ind_id_from_domain_name <- function(metadata, domain_name, get_profile_name <- function(profile_id, profile_name, metadata) { checkmate::assert_list(metadata, len = 3L, null.ok = FALSE, - any.missing = FALSE - ) + any.missing = FALSE) checkmate::assert_vector(profile_name, min.len = 1L, null.ok = TRUE, - any.missing = FALSE - ) + any.missing = FALSE) checkmate::assert_vector(profile_id, min.len = 1L, null.ok = TRUE, - any.missing = FALSE - ) + any.missing = FALSE) if (all(!is.null(profile_id) & !is.null(profile_name))) { profile_name <- unlist(strsplit(profile_name, ",", fixed = TRUE)) idx <- which( - metadata[["indicator_profile_domain"]][["ProfileID"]] == - profile_id & - metadata[["indicator_profile_domain"]][["ProfileName"]] == - profile_name - ) + metadata[["indicator_profile_domain"]][["ProfileID"]] == + profile_id & + metadata[["indicator_profile_domain"]][["ProfileName"]] == + profile_name) } else if (!is.null(profile_id) && is.null(profile_name)) { idx <- which( - metadata[["indicator_profile_domain"]][["ProfileID"]] == - profile_id - ) + metadata[["indicator_profile_domain"]][["ProfileID"]] == + profile_id) } else if (!is.null(profile_name) && is.null(profile_id)) { profile_name <- unlist(strsplit(profile_name, ",", fixed = TRUE)) idx <- which( - metadata[["indicator_profile_domain"]][["ProfileName"]] == - profile_name - ) - } - - list( - profile_name = profile_name, - profile_index = idx - ) -======= -#' @return a list with the profile name and their correspondent indexes -#' @export -#' @examples -#' res <- get_profile_name( -#' profile_id = 19, -#' profile_name = "Public Health Outcomes Framework", -#' metadata = list( -#' indicator_profile_domain = fingertipsR::indicators(), -#' indicator_ids_names = fingertipsR::indicators_unique(), -#' area_type = fingertipsR::area_types() -#' ) -#' ) -#' -get_profile_name <- function(profile_id, profile_name, metadata) { - checkmate::assert_vector(profile_id, any.missing = FALSE, min.len = 0, - null.ok = TRUE, unique = TRUE) - checkmate::assert_vector(profile_name, any.missing = FALSE, min.len = 0, - null.ok = TRUE, unique = TRUE) - checkmate::assert_vector(metadata, any.missing = FALSE, null.ok = FALSE) - - if (all(!is.null(profile_id) & !is.null(profile_name))) { - profile_name <- unlist(strsplit(profile_name, ",", fixed = TRUE)) - idx <- which(metadata$indicator_profile_domain$ProfileID == profile_id & - metadata$indicator_profile_domain$ProfileName == + metadata[["indicator_profile_domain"]][["ProfileName"]] == profile_name) - } else if (!is.null(profile_id) && is.null(profile_name)) { - idx <- which(metadata$indicator_profile_domain$ProfileID == profile_id) - } else if (!is.null(profile_name) && is.null(profile_id)) { - profile_name <- unlist(strsplit(profile_name, ",", fixed = TRUE)) - idx <- which(metadata$indicator_profile_domain$ProfileName == profile_name) } list( - profile_name, - idx + profile_name = profile_name, + profile_index = idx ) - ->>>>>>> main } #' Get indicator ID from profile ID and/or profile name @@ -490,7 +282,6 @@ get_profile_name <- function(profile_id, profile_name, metadata) { #' @param profile_name the profile name #' @param profile_id the profile ID #' -<<<<<<< HEAD #' @return an object of type `numeric` that contains the indicator ID #' @examples #' \dontrun{ @@ -504,56 +295,35 @@ get_profile_name <- function(profile_id, profile_name, metadata) { #' ) #' } #' @keywords internal -======= -#' @return the indicator ID -#' @export -#' @examples -#' res <- get_ind_id_from_profile( -#' metadata = list( -#' indicator_profile_domain = fingertipsR::indicators(), -#' indicator_ids_names = fingertipsR::indicators_unique(), -#' area_type = fingertipsR::area_types() -#' ), -#' profile_id = 19 -#' ) -#' ->>>>>>> main get_ind_id_from_profile <- function(metadata, domain_id = NULL, domain_name = NULL, indicator_name = NULL, profile_name = NULL, profile_id = NULL) { -<<<<<<< HEAD checkmate::assert_list(metadata, len = 3L, null.ok = FALSE, - any.missing = FALSE - ) + any.missing = FALSE) checkmate::assert_vector(domain_id, min.len = 0L, null.ok = TRUE, - any.missing = FALSE - ) + any.missing = FALSE) checkmate::assert_vector(domain_name, min.len = 0L, null.ok = TRUE, - any.missing = FALSE - ) + any.missing = FALSE) checkmate::assert_vector(indicator_name, min.len = 0L, null.ok = TRUE, - any.missing = FALSE - ) + any.missing = FALSE) checkmate::assert_vector(profile_id, min.len = 0L, null.ok = TRUE, - any.missing = FALSE - ) - tmp_res <- get_profile_name(profile_id, profile_name, metadata) + any.missing = FALSE) + tmp_res <- get_profile_name(profile_id, profile_name, metadata) profile_name <- tmp_res[["profile_name"]] - idx <- tmp_res[["profile_index"]] + idx <- tmp_res[["profile_index"]] if (length(idx) == 0L) { message("\nCould not find the specified profile ID or name.\n Below is the list of all profile IDs and names in Fingertips.") print( - metadata[["indicator_profile_domain"]][, c("ProfileID", "ProfileName")] - ) + metadata[["indicator_profile_domain"]][, c("ProfileID", "ProfileName")]) # nolint stop() } else { subs <- metadata[["indicator_profile_domain"]][idx, ] @@ -569,73 +339,12 @@ get_ind_id_from_profile <- function(metadata, domain_id = NULL, subs <- subs %>% dplyr::filter(subs[["IndicatorName"]] == indicator_name) } indicator_id <- subs[["IndicatorID"]] -======= - checkmate::assert_list(metadata, any.missing = FALSE, len = 3, - null.ok = FALSE) - checkmate::assert_vector(domain_id, any.missing = FALSE, min.len = 0, - null.ok = TRUE, unique = TRUE) - checkmate::assert_vector(domain_name, any.missing = FALSE, min.len = 0, - null.ok = TRUE, unique = TRUE) - checkmate::assert_vector(profile_id, any.missing = FALSE, min.len = 0, - null.ok = TRUE, unique = TRUE) - checkmate::assert_vector(profile_name, any.missing = FALSE, min.len = 0, - null.ok = TRUE, unique = TRUE) - checkmate::assert_vector(indicator_name, any.missing = FALSE, min.len = 0, - null.ok = TRUE, unique = TRUE) - - tmp_res <- get_profile_name(profile_id, profile_name, metadata) - profile_name <- tmp_res[[1]] - idx <- tmp_res[[2]] - - if (length(idx) == 0) { - if (!is.null(profile_id) && is.null(profile_name)) { - subs <- metadata$indicator_profile_domain[grepl( - profile_id, - metadata$indicator_profile_domain$ProfileID - ), ] - } else if (!is.null(profile_name) && is.null(profile_id)) { - subs <- metadata$indicator_profile_domain[grepl( - profile_name, - metadata$indicator_profile_domain$ProfileName - ), ] - } else if (all(!is.null(profile_id) & !is.null(profile_name))) { - subs <- metadata$indicator_profile_domain[( - grepl(profile_id, metadata$indicator_profile_domain$ProfileID) | - grepl(profile_name, metadata$indicator_profile_domain$ProfileName)), ] - } - - if (nrow(subs) == 0) { - R.utils::cat("\nCould not find specified profile ID or name.\n - Below is the list of all profile IDs and names in Fingertips.\n") - print(metadata$indicator_profile_domain[, c("ProfileID", "ProfileName")]) - stop() - } else { - R.utils::cat("\nspecified profile name or ID not found but detected - following similar profile IDs or names:\n") - print(subs[, c("ProfileID", "ProfileName")]) - } - } else { - subs <- metadata$indicator_profile_domain[idx, ] - if (!is.null(domain_id)) { - subs <- subs %>% dplyr::filter(subs$DomainID == domain_id) - } - if (!is.null(domain_name)) { - domain_name <- unlist(strsplit(domain_name, ",", fixed = TRUE)) - subs <- subs %>% dplyr::filter(subs$DomainName == domain_name) - } - if (!is.null(indicator_name)) { - indicator_name <- unlist(strsplit(indicator_name, ",", fixed = TRUE)) - subs <- subs %>% dplyr::filter(subs$IndicatorName == indicator_name) - } - indicator_id <- subs$IndicatorID ->>>>>>> main } indicator_id } #' Subset records when reading from Fingertips #' -<<<<<<< HEAD #' @param data the data read from Fingertips #' @param records a vector or a comma-separated string of records #' @param id_col_name the column name with the subject IDs @@ -659,48 +368,20 @@ get_ind_id_from_profile <- function(metadata, domain_id = NULL, fingertips_subset_rows <- function(data, records, id_col_name) { checkmate::assert_data_frame(data, null.ok = FALSE, min.rows = 1L, - min.cols = 1L - ) + min.cols = 1L) checkmate::assert_vector(records, min.len = 0L, null.ok = TRUE, - any.missing = FALSE - ) + any.missing = FALSE) checkmate::assert_character(id_col_name, null.ok = TRUE, len = 1L, - any.missing = FALSE - ) -======= -#' @param records a vector or a comma-separated string of records -#' @param id_col_name the column name with the subject IDs -#' @param data the data read from Fingertips -#' -#' @return a data frame with the records of interest -#' @export -#' @examples -#' res <- fingertips_subset_rows( -#' records = c("E92000001", "E12000002", "E12000009"), -#' id_col_name = "AreaCode", -#' data = readepi( -#' profile_id = 19, -#' area_type_id = 202 -#' )$data -#' ) -#' -fingertips_subset_rows <- function(records, id_col_name, data) { - checkmate::assert_data_frame(data, null.ok = FALSE) - checkmate::assert_character(id_col_name, any.missing = FALSE, len = 1, - null.ok = TRUE) - checkmate::assert_vector(records, any.missing = FALSE, min.len = 0, - null.ok = TRUE, unique = TRUE) - ->>>>>>> main + any.missing = FALSE) if (!is.null(records)) { records <- unlist(strsplit(records, ",", fixed = TRUE)) records <- gsub(" ", "", records, fixed = TRUE) if (all(records %in% data[[id_col_name]])) { - data <- data[which(data[[id_col_name]] %in% records), ] + data <- data[which(data[[id_col_name]] %in% records), ] } else { - idx <- which(records %in% data[[id_col_name]]) + idx <- which(records %in% data[[id_col_name]]) warning("\n", length(records[-idx]), " records were not found in the data.") data <- data[which(data[[id_col_name]] %in% records[idx]), ] @@ -712,7 +393,6 @@ fingertips_subset_rows <- function(records, id_col_name, data) { #' Subset columns when reading from Fingertips #' -<<<<<<< HEAD #' @param data the data read from Fingertips #' @param fields a vector or a comma-separated string of column names #' @@ -733,42 +413,15 @@ fingertips_subset_rows <- function(records, id_col_name, data) { fingertips_subset_columns <- function(data, fields) { checkmate::assert_data_frame(data, min.cols = 1L, min.rows = 1L, - null.ok = FALSE - ) + null.ok = FALSE) checkmate::assert_vector(fields, min.len = 0L, null.ok = TRUE, - any.missing = FALSE - ) -======= -#' @param fields a vector or a comma-separated string of column names -#' @param data the data read from Fingertips -#' -#' @return a data frame with the columns of interest -#' @export -#' @examples -#' res <- fingertips_subset_columns( -#' fields = c("IndicatorID", "AreaCode", "Age", "Value"), -#' data = readepi( -#' profile_id = 19, -#' area_type_id = 202 -#' )$data -#' ) -#' -fingertips_subset_columns <- function(fields, data) { - checkmate::assert_data_frame(data, null.ok = FALSE) - checkmate::assert_vector(fields, any.missing = FALSE, min.len = 0, - null.ok = TRUE, unique = TRUE) - ->>>>>>> main + any.missing = FALSE) if (!is.null(fields)) { fields <- unlist(strsplit(fields, ",", fixed = TRUE)) fields <- gsub(" ", "", fields, fixed = TRUE) - idx <- which(fields %in% names(data)) -<<<<<<< HEAD + idx <- which(fields %in% names(data)) if (length(idx) == 0L) { -======= - if (length(idx) == 0) { ->>>>>>> main stop("\nCould not find specified fields. The field names in the dataset are:\n", print(names(data))) } else if (length(idx) != length(fields)) { diff --git a/R/read_from_fingertips.R b/R/read_from_fingertips.R index 1861b32b..535ce59d 100644 --- a/R/read_from_fingertips.R +++ b/R/read_from_fingertips.R @@ -9,7 +9,6 @@ #' @param domain_id a vector of domain IDs #' @param domain_name a vector or a comma-separated list of domain names #' @param fields a vector or a comma-separated string of column names. -<<<<<<< HEAD #' If provided, only those columns will be imported. #' @param records a vector or a comma-separated string of records. #' When specified, only these records will be imported. @@ -30,118 +29,46 @@ read_from_fingertips <- function(indicator_id = NULL, indicator_name = NULL, area_type_id = NULL, parent_area_type_id = NULL, -======= -#' If provided, only those columns will be imported. -#' @param records a vector or a comma-separated string of records. -#' When specified, only these records will be imported. -#' @param id_position the column position of the variable that unique identifies -#' the subjects. When the name of the column with the subject IDs is known, -#' this can be provided using the `id_col_name` argument -#' @param id_col_name the column name with the subject IDs. -#' -#' @return a data frame -#' @export -#' -#' @examples -#' data <- read_from_fingertips(indicator_id = 90362, area_type_id = 202) -read_from_fingertips <- function(indicator_id = NULL, indicator_name = NULL, - area_type_id, parent_area_type_id = NULL, ->>>>>>> main profile_id = NULL, profile_name = NULL, domain_id = NULL, domain_name = NULL, fields = NULL, records = NULL, id_position = NULL, id_col_name = NULL) { checkmate::assert_vector(indicator_id, -<<<<<<< HEAD any.missing = FALSE, min.len = 0L, - null.ok = TRUE, unique = TRUE - ) + null.ok = TRUE, unique = TRUE) checkmate::assert_vector(indicator_name, any.missing = FALSE, min.len = 0L, - null.ok = TRUE, unique = TRUE - ) + null.ok = TRUE, unique = TRUE) checkmate::assert_vector(area_type_id, any.missing = FALSE, min.len = 0L, - null.ok = TRUE, unique = TRUE - ) + null.ok = TRUE, unique = TRUE) checkmate::assert_vector(parent_area_type_id, any.missing = FALSE, min.len = 0L, - null.ok = TRUE, unique = TRUE - ) + null.ok = TRUE, unique = TRUE) checkmate::assert_vector(profile_id, any.missing = FALSE, min.len = 0L, - null.ok = TRUE, unique = TRUE - ) + null.ok = TRUE, unique = TRUE) checkmate::assert_vector(profile_name, any.missing = FALSE, min.len = 0L, - null.ok = TRUE, unique = TRUE - ) + null.ok = TRUE, unique = TRUE) checkmate::assert_vector(domain_id, any.missing = FALSE, min.len = 0L, - null.ok = TRUE, unique = TRUE - ) + null.ok = TRUE, unique = TRUE) checkmate::assert_vector(domain_name, any.missing = FALSE, min.len = 0L, - null.ok = TRUE, unique = TRUE - ) -======= - any.missing = FALSE, min.len = 0, - null.ok = TRUE, unique = TRUE - ) - checkmate::assert_vector(indicator_name, - any.missing = FALSE, min.len = 0, - null.ok = TRUE, unique = TRUE - ) - checkmate::assert_vector(area_type_id, - any.missing = FALSE, min.len = 0, - null.ok = TRUE, unique = TRUE - ) - checkmate::assert_vector(parent_area_type_id, - any.missing = FALSE, min.len = 0, - null.ok = TRUE, unique = TRUE - ) - checkmate::assert_vector(profile_id, - any.missing = FALSE, min.len = 0, - null.ok = TRUE, unique = TRUE - ) - checkmate::assert_vector(profile_name, - any.missing = FALSE, min.len = 0, - null.ok = TRUE, unique = TRUE - ) - checkmate::assert_vector(domain_id, - any.missing = FALSE, min.len = 0, - null.ok = TRUE, unique = TRUE - ) - checkmate::assert_vector(domain_name, - any.missing = FALSE, min.len = 0, - null.ok = TRUE, unique = TRUE - ) - checkmate::assert_vector(records, - any.missing = FALSE, min.len = 0, - null.ok = TRUE, unique = TRUE - ) - checkmate::assert_vector(fields, - any.missing = FALSE, min.len = 0, - null.ok = TRUE, unique = TRUE - ) - checkmate::assert_number(id_position, null.ok = TRUE, na.ok = FALSE, - lower = 1) - checkmate::assert_character(id_col_name, any.missing = FALSE, len = 1, - null.ok = TRUE) ->>>>>>> main + null.ok = TRUE, unique = TRUE) # check if one of these is not provided - if (all(is.null(profile_id) & is.null(indicator_id) & is.null(domain_id) & - is.null(profile_name) & is.null(indicator_name) & -<<<<<<< HEAD - is.null(domain_name) & is.null(area_type_id))) { + if (all( + is.null(profile_id) & + is.null(indicator_id) & + is.null(domain_id) & + is.null(profile_name) & + is.null(indicator_name) & + is.null(domain_name) & + is.null(area_type_id))) { stop("\nPlease use the readepi:::get_fingertips_metadata() function to see the Fingertips metadata.") -======= - is.null(domain_name))) { - stop("\nPlease use the get_fingertips_metadata() function to see the - Fingertips metadata.") ->>>>>>> main } # extract the metadata @@ -151,72 +78,45 @@ read_from_fingertips <- function(indicator_id = NULL, indicator_name = NULL, if (is.null(area_type_id)) { message("\narea_type_id not provided! Please choose an area type ID from the list below:\n") -<<<<<<< HEAD print(metadata[["area_type"]]) -======= - print(metadata$area_type) ->>>>>>> main stop() } # get the indicator ID from the indicator name if (!is.null(indicator_name) && is.null(indicator_id)) { -<<<<<<< HEAD indicator_id <- get_ind_id_from_ind_name(metadata, indicator_name) -======= - indicator_id <- get_ind_id_from_ind_name(metadata, - indicator_name) ->>>>>>> main } # get the indicator ID from the domain ID if (!is.null(domain_id) && is.null(indicator_id)) { -<<<<<<< HEAD indicator_id <- get_ind_id_from_domain_id( metadata, domain_id, indicator_name ) -======= - indicator_id <- get_ind_id_from_domain_id(metadata, domain_id, - indicator_name) ->>>>>>> main } # get the indicator ID from the domain name - if (!is.null(domain_name) && - all(is.null(indicator_id) & is.null(domain_id))) { -<<<<<<< HEAD - indicator_id <- get_ind_id_from_domain_name( - metadata, domain_name, - indicator_name - ) -======= - indicator_id <- get_ind_id_from_domain_name(metadata, domain_name, - indicator_name) ->>>>>>> main + if (!is.null(domain_name) && all(is.null(indicator_id) & is.null(domain_id))) { # nolint: line_length_linter + indicator_id <- get_ind_id_from_domain_name(metadata, + domain_name, + indicator_name) } # get the indicator ID from the profile ID or profile name - if (any(!is.null(profile_id) | !is.null(profile_name)) && - is.null(indicator_id)) { - indicator_id <- get_ind_id_from_profile( - metadata, domain_id, domain_name, - indicator_name, profile_name, profile_id - ) + if (any(!is.null(profile_id) | !is.null(profile_name)) && is.null(indicator_id)) { # nolint: line_length_linter + indicator_id <- get_ind_id_from_profile(metadata, + domain_id, + domain_name, + indicator_name, + profile_name, + profile_id) } # extract the data -<<<<<<< HEAD - data <- fingertipsR::fingertips_data( -======= - data <- data <- fingertipsR::fingertips_data( ->>>>>>> main - IndicatorID = indicator_id, - AreaTypeID = area_type_id, - ParentAreaTypeID = parent_area_type_id - ) + data <- fingertipsR::fingertips_data(IndicatorID = indicator_id, + AreaTypeID = area_type_id, + ParentAreaTypeID = parent_area_type_id) # subset columns -<<<<<<< HEAD data <- fingertips_subset_columns(data, fields) # subset rows @@ -225,12 +125,4 @@ read_from_fingertips <- function(indicator_id = NULL, indicator_name = NULL, list( data = data ) -======= - data <- fingertips_subset_columns(fields, data) - - # subset rows - data <- fingertips_subset_rows(records, id_col_name, data) - - list(data = data) ->>>>>>> main } diff --git a/R/read_from_redcap-helpers.R b/R/read_from_redcap-helpers.R index 69ee9073..060241a7 100644 --- a/R/read_from_redcap-helpers.R +++ b/R/read_from_redcap-helpers.R @@ -1,21 +1,14 @@ #' Import data from REDCap under all scenari #' #' @description This is a wrapper across all the use case of reading data from -<<<<<<< HEAD #' REDCap i.e. around the function that all records and fields from the #' project, around the function that read specific records/fields or both at #' the same time -======= -#' REDCap i.e. around the function that all records and fields from the project, -#' around the function that read specific records/fields or both at the same -#' time ->>>>>>> main #' #' @param records a vector or a comma-separated string of subset of subject IDs #' @param fields a vector or a comma-separated string of column names #' @param uri the URI of the server #' @param token the user-specific string that serves as the password for a -<<<<<<< HEAD #' project #' @param id_position the column position of the variable that unique identifies #' the subjects @@ -58,72 +51,6 @@ import_redcap_data <- function(records, fields, uri, token, list( redcap_data = redcap_data, metadata = metadata -======= -#' project -#' @param id_position the column position of the variable that unique identifies -#' the subjects -#' @param id_col_name the column name with the subject IDs -#' -#' @return a list with the data of interest and its associated metadata -#' @examples -#' result = import_redcap_data( -#' uri = "https://bbmc.ouhsc.edu/redcap/api/", -#' token = "9A81268476645C4E5F03428B8AC3AA7B", -#' records = c("1", "3", "5"), -#' fields = c("record_id", "name_first", "age", "bmi"), -#' id_col_name = NULL, -#' id_position = 1 -#' ) -#' @export -import_redcap_data <- function(records, fields, uri, token, - id_position, id_col_name) { - checkmate::assert_number(id_position, null.ok = TRUE, - na.ok = FALSE) - checkmate::assert_character(token, n.chars = 32, len = 1, null.ok = FALSE, - any.missing = FALSE) - checkmate::assert_character(uri, len = 1, null.ok = FALSE, - any.missing = FALSE) - checkmate::assert_vector(records, - any.missing = FALSE, min.len = 1, - null.ok = TRUE, unique = TRUE - ) - checkmate::assert_vector(fields, - any.missing = FALSE, min.len = 1, - null.ok = TRUE, unique = TRUE - ) - checkmate::assertCharacter(id_col_name, len = 1, null.ok = TRUE, - any.missing = FALSE) - - if (all(is.null(records) & is.null(fields))) { - res <- redcap_read(uri, token, id_position) - redcap_data <- res[[1]] - metadata <- res[[2]] - } - - if (all(!is.null(records) & !is.null(fields))) { - res <- redcap_read_rows_columns(fields, uri, token, id_position, - id_col_name, records) - redcap_data <- res[[1]] - metadata <- res[[2]] - } - - if (!is.null(fields) && is.null(records)) { - res <- redcap_read_fields(fields, uri, token, id_position) - redcap_data <- res[[1]] - metadata <- res[[2]] - } - - if (!is.null(records) && is.null(fields)) { - res <- redcap_read_records(records, uri, token, - id_position, id_col_name) - redcap_data <- res[[1]] - metadata <- res[[2]] - } - - list( - redcap_data, - metadata ->>>>>>> main ) } @@ -131,7 +58,6 @@ import_redcap_data <- function(records, fields, uri, token, #' #' @param uri the URI of the REDCap project #' @param token the user-specific string that serves as the password for a -<<<<<<< HEAD #' project #' @param id_position the column position of the variable that unique identifies #' the subjects @@ -157,33 +83,6 @@ redcap_read_data <- function(uri, token, id_position) { list( redcap_data = redcap_data, metadata = metadata -======= -#' project -#' @param id_position the column position of the variable that unique identifies -#' the subjects -#' -#' @return a list with the project data and its associated metadata -#' @export -redcap_read <- function(uri, token, id_position) { - checkmate::assert_number(id_position, lower = 1, null.ok = TRUE, - na.ok = FALSE) - checkmate::assert_character(token, n.chars = 32, len = 1, null.ok = FALSE, - any.missing = FALSE) - checkmate::assert_character(uri, len = 1, null.ok = FALSE, - any.missing = FALSE) - redcap_data <- REDCapR::redcap_read( - redcap_uri = uri, token = token, records = NULL, - fields = NULL, verbose = FALSE, - id_position = as.integer(id_position) - ) - metadata <- REDCapR::redcap_metadata_read( - redcap_uri = uri, token = token, - fields = NULL, verbose = FALSE - ) - list( - redcap_data = redcap_data, - metadata = metadata ->>>>>>> main ) } @@ -192,7 +91,6 @@ redcap_read <- function(uri, token, id_position) { #' @param fields a vector or a comma-separated string of column names #' @param uri the URI of the REDCap project #' @param token the user-specific string that serves as the password for a -<<<<<<< HEAD #' project #' @param id_position the column position of the variable that unique identifies #' the subjects @@ -226,61 +124,11 @@ redcap_read_rows_columns <- function(fields, uri, token, id_position, id_position <- which(names(redcap_data[["data"]]) == id_column_name) } else { id_column_name <- names(redcap_data[["data"]])[id_position] -======= -#' project -#' @param id_position the column position of the variable that unique identifies -#' the subjects -#' @param id_col_name the column name with the subject IDs -#' @param records a vector or a comma-separated string of subset of subject IDs -#' -#' @return a list with the project data and its associated metadata with the -#' fields and records of interest -#' @export -redcap_read_rows_columns <- function(fields, uri, token, id_position, - id_col_name, records) { - checkmate::assert_number(id_position, lower = 1, null.ok = TRUE, - na.ok = FALSE) - checkmate::assert_character(token, n.chars = 32, len = 1, null.ok = FALSE, - any.missing = FALSE) - checkmate::assert_character(uri, len = 1, null.ok = FALSE, - any.missing = FALSE) - checkmate::assert_vector(records, - any.missing = FALSE, min.len = 1, - null.ok = TRUE, unique = TRUE - ) - checkmate::assert_vector(fields, - any.missing = FALSE, min.len = 1, - null.ok = TRUE, unique = TRUE - ) - checkmate::assertCharacter(id_col_name, len = 1L, null.ok = TRUE, - any.missing = FALSE) - if (is.vector(fields)) { - fields <- glue::glue_collapse(fields, sep = ", ") - } - redcap_data <- REDCapR::redcap_read( - redcap_uri = uri, token = token, - id_position = as.integer(id_position), - fields_collapsed = fields, verbose = FALSE - ) - metadata <- REDCapR::redcap_metadata_read( - redcap_uri = uri, token = token, - verbose = FALSE - ) - if (!is.null(id_col_name)) { - if (!(id_col_name %in% names(redcap_data$data))) { - stop("Specified ID column name not found!") - } - id_column_name <- id_col_name - id_position <- which(names(redcap_data$data) == id_column_name) - } else { - id_column_name <- names(redcap_data$data)[id_position] ->>>>>>> main } if (is.character(records)) { records <- gsub(" ", "", records, fixed = TRUE) records <- as.character(unlist(strsplit(records, ",", fixed = TRUE))) } -<<<<<<< HEAD if (is.numeric(redcap_data[["data"]][[id_column_name]])) { records <- as.numeric(records) } @@ -290,16 +138,6 @@ redcap_read_rows_columns <- function(fields, uri, token, id_position, list( redcap_data = redcap_data, metadata = metadata -======= - if (is.numeric(redcap_data$data[[id_column_name]])) { - records <- as.numeric(records) - } - redcap_data$data <- - redcap_data$data[which(redcap_data$data[[id_column_name]] %in% records), ] - list( - redcap_data = redcap_data, - metadata = metadata ->>>>>>> main ) } @@ -309,7 +147,6 @@ redcap_read_rows_columns <- function(fields, uri, token, id_position, #' @param fields a vector or a comma-separated string of column names #' @param uri the URI of the REDCap project #' @param token the user-specific string that serves as the password for a -<<<<<<< HEAD #' project #' @param id_position the column position of the variable that unique identifies #' the subjects @@ -332,41 +169,6 @@ redcap_read_fields <- function(fields, uri, token, id_position) { list( redcap_data = redcap_data, metadata = metadata -======= -#' project -#' @param id_position the column position of the variable that unique identifies -#' the subjects -#' -#' @return a list with the project data and its associated metadata with the -#' fields of interest -#' @export -redcap_read_fields <- function(fields, uri, token, id_position) { - checkmate::assert_number(id_position, lower = 1, null.ok = TRUE, - na.ok = FALSE) - checkmate::assert_character(token, n.chars = 32, len = 1, null.ok = FALSE, - any.missing = FALSE) - checkmate::assert_character(uri, len = 1, null.ok = FALSE, - any.missing = FALSE) - checkmate::assert_vector(fields, - any.missing = FALSE, min.len = 1, - null.ok = TRUE, unique = TRUE - ) - if (is.vector(fields)) { - fields <- glue::glue_collapse(fields, sep = ", ") - } - redcap_data <- REDCapR::redcap_read( - redcap_uri = uri, token = token, - id_position = as.integer(id_position), - fields_collapsed = fields, verbose = FALSE - ) - metadata <- REDCapR::redcap_metadata_read( - redcap_uri = uri, token = token, - verbose = FALSE - ) - list( - redcap_data = redcap_data, - metadata = metadata ->>>>>>> main ) } @@ -376,7 +178,6 @@ redcap_read_fields <- function(fields, uri, token, id_position) { #' @param records a vector or a comma-separated string of subset of subject IDs #' @param uri the URI of the REDCap project #' @param token the user-specific string that serves as the password for a -<<<<<<< HEAD #' project #' @param id_position the column position of the variable that unique identifies #' the subjects @@ -418,58 +219,6 @@ redcap_read_records <- function(records, uri, token, id_position, id_col_name) { list( redcap_data = redcap_data, metadata = metadata -======= -#' project -#' @param id_position the column position of the variable that unique identifies -#' the subjects -#' @param id_col_name the column name with the subject IDs -#' -#' @return a list with the project data and its associated metadata with the -#' records of interest -#' @export -redcap_read_records <- function(records, uri, token, id_position, id_col_name) { - checkmate::assert_number(id_position, lower = 1, null.ok = TRUE, - na.ok = FALSE) - checkmate::assert_character(token, n.chars = 32, len = 1, null.ok = FALSE, - any.missing = FALSE) - checkmate::assert_character(uri, len = 1, null.ok = FALSE, - any.missing = FALSE) - checkmate::assert_vector(records, - any.missing = FALSE, min.len = 1, - null.ok = TRUE, unique = TRUE - ) - checkmate::assertCharacter(id_col_name, len = 1L, null.ok = TRUE, - any.missing = FALSE) - if (is.vector(records)) { - records <- glue::glue_collapse(records, sep = ", ") - } - redcap_data <- REDCapR::redcap_read( - redcap_uri = uri, token = token, records = NULL, - fields = NULL, verbose = FALSE, - id_position = as.integer(id_position) - ) - if (!is.null(id_col_name)) { - if (!(id_col_name %in% names(redcap_data$data))) { - stop("Specified ID column name not found!") - } - id_column_name <- id_col_name - id_position <- which(names(redcap_data$data) == id_column_name) - } else { - id_column_name <- names(redcap_data$data)[id_position] - } - redcap_data <- REDCapR::redcap_read( - redcap_uri = uri, token = token, - id_position = as.integer(id_position), - records_collapsed = records, verbose = FALSE - ) - metadata <- REDCapR::redcap_metadata_read( - redcap_uri = uri, token = token, - verbose = FALSE - ) - list( - redcap_data = redcap_data, - metadata = metadata ->>>>>>> main ) } @@ -478,7 +227,6 @@ redcap_read_records <- function(records, uri, token, id_position, id_col_name) { #' @param redcap_data the object with redcap data #' @param metadata the object with redcap metadata #' -<<<<<<< HEAD #' @return a `list` of 2 elements of type `data.frame`. These are the dataset of #' interest and its associated metadata. #' @@ -504,13 +252,13 @@ redcap_read_records <- function(records, uri, token, id_position, id_col_name) { #' redcap_get_results <- function(redcap_data, metadata) { checkmate::assert_list(redcap_data, - null.ok = FALSE, min.len = 2L, - any.missing = FALSE - ) + null.ok = FALSE, + min.len = 2L, + any.missing = FALSE) checkmate::assert_list(metadata, - null.ok = FALSE, min.len = 2L, - any.missing = FALSE - ) + null.ok = FALSE, + min.len = 2L, + any.missing = FALSE) if (all(redcap_data[["success"]] && metadata[["success"]])) { data <- redcap_data[["data"]] meta <- metadata[["data"]] @@ -519,48 +267,5 @@ redcap_get_results <- function(redcap_data, metadata) { list( data = data, meta = meta -======= -#' @return a list with the redcap dataset and its associated metadata as -#' data frames -#' -#' @examples -#' result <- redcap_get_results( -#' redcap_data = REDCapR::redcap_read( -#' redcap_uri = "https://bbmc.ouhsc.edu/redcap/api/", -#' token = "9A81268476645C4E5F03428B8AC3AA7B", -#' records = c("1", "3", "5"), -#' fields = c("record_id", "name_first", "age", "bmi"), -#' verbose = FALSE, -#' id_position = 1L -#' ), -#' metadata = REDCapR::redcap_metadata_read( -#' redcap_uri = "https://bbmc.ouhsc.edu/redcap/api/", -#' token = "9A81268476645C4E5F03428B8AC3AA7B", -#' fields = NULL, -#' verbose = FALSE -#' ) -#' ) -#' @export -redcap_get_results <- function(redcap_data, metadata) { - checkmate::assert_list(redcap_data, null.ok = FALSE, min.len = 2, - any.missing = FALSE) - checkmate::assert_list(metadata, null.ok = FALSE, min.len = 2, - any.missing = FALSE) - if (all(redcap_data$success & metadata$success)) { - data <- redcap_data$data - meta <- metadata$data - } else if (redcap_data$success && !metadata$success) { - warning("\nNote that the metadata was not imported.") - data <- redcap_data$data - meta <- NULL - } else { - stop("Error in reading from REDCap. Please check your credentials or - project ID.") - } - - list( - data, - meta ->>>>>>> main ) } diff --git a/R/read_from_redcap.R b/R/read_from_redcap.R index bdced02f..9b4509c2 100644 --- a/R/read_from_redcap.R +++ b/R/read_from_redcap.R @@ -1,7 +1,6 @@ #' Import data from REDCap into R #' @param uri the URI of the server #' @param token the user-specific string that serves as the password for a -<<<<<<< HEAD #' project #' @param id_position the column position of the variable that unique identifies #' the subjects. When the column name with the subject IDs is known, use @@ -32,61 +31,14 @@ read_from_redcap <- function(uri, token, id_position = NULL, id_col_name = NULL, # check input variables checkmate::assert_character(token, n.chars = 32L, len = 1L, null.ok = FALSE, - any.missing = FALSE - ) + any.missing = FALSE) checkmate::assert_character(uri, len = 1L, null.ok = FALSE, - any.missing = FALSE - ) -======= -#' project -#' @param id_position the column position of the variable that unique identifies -#' the subjects. When the column name with the subject IDs is known, use -#' the `id_col_name` argument instead. default is 1 -#' @param id_col_name the column name with the subject IDs -#' @param records a vector or a comma-separated string of subset of subject IDs. -#' When specified, only the records that correspond to these subjects will -#' be imported. -#' @param fields a vector or a comma-separated string of column names. -#' If provided, only those columns will be imported. -#' @examples -#' redcap_data <- read_from_redcap( -#' uri = "https://bbmc.ouhsc.edu/redcap/api/", -#' token = "9A81268476645C4E5F03428B8AC3AA7B", -#' id_position = 1, -#' id_col_name = NULL, -#' records = NULL, -#' fields = NULL -#' ) -#' @returns a list with 2 data frames: the data of interest and the metadata -#' associated to the data. -#' @export -read_from_redcap <- function(uri, token, id_position = NULL, id_col_name = NULL, - records = NULL, fields = NULL) { - # check input variables - checkmate::assert_number(id_position, null.ok = TRUE, - na.ok = FALSE) - checkmate::assert_character(token, n.chars = 32, len = 1, null.ok = FALSE, - any.missing = FALSE) - checkmate::assert_character(uri, len = 1, null.ok = FALSE, any.missing = FALSE) - checkmate::assert_vector(records, - any.missing = FALSE, min.len = 1, - null.ok = TRUE, unique = TRUE - ) - checkmate::assert_vector(fields, - any.missing = FALSE, min.len = 1, - null.ok = TRUE, unique = TRUE - ) - checkmate::assertCharacter(id_col_name, len = 1, null.ok = TRUE, - any.missing = FALSE) - ->>>>>>> main stopifnot("Cannot specify both 'id_position' and 'id_col_name' at the same time." = !all(!is.null(id_position) & !is.null(id_col_name))) -<<<<<<< HEAD id_position <- ifelse(!is.null(id_position), id_position, 1) # nolint # importing data and the metadata into R @@ -105,23 +57,5 @@ read_from_redcap <- function(uri, token, id_position = NULL, id_col_name = NULL, list( data = tmp_res[["data"]], metadata = tmp_res[["meta"]] -======= - id_position <- ifelse(!is.null(id_position), id_position, 1) - - # importing data and the metadata into R - tmp_res <- import_redcap_data(records, fields, uri, token, - id_position, id_col_name) - redcap_data <- tmp_res[[1]] - metadata <- tmp_res[[2]] - - # checking whether the importing was successful and extract the desired - # records and columns - tmp_res <- redcap_get_results(redcap_data, metadata) - - # return the imported data - list( - data = tmp_res[[1]], - metadata = tmp_res[[2]] ->>>>>>> main ) } diff --git a/R/read_servers.R b/R/read_servers.R index c93ff8a8..b262a3cd 100644 --- a/R/read_servers.R +++ b/R/read_servers.R @@ -1,25 +1,14 @@ -<<<<<<< HEAD #' Read data from database management systems (DBMS). #' #' @description The function assumes the user has read access to the database. #' Importing data stored in DBMS into R requires the installation #' of the appropriate `driver` that is compatible with the server version #' hosting the database. See the `vignette` for how to install the driver -======= -#' Read data from relational databases hosted by a MS SQL server. -#' @description For a user with read access to a Microsoft SQL server, -#' this function allows data import from the database into R. It required the -#' installation -#' of the appropriate MS driver that is compatible with the SQL server version -#' hosting the -#' database. ->>>>>>> main #' @param user the user name #' @param password the user password #' @param host the name of the host server #' @param port the port ID #' @param database_name the name of the database that contains the table from -<<<<<<< HEAD #' which the data should be pulled #' @param source an SQL query or a vector of table names from #' the project or database. When this is not specified, the function will @@ -68,111 +57,27 @@ sql_server_read_data <- function(user = "rfamro", password = "", checkmate::assert_number(port, lower = 1L) checkmate::assert_character(user, any.missing = FALSE, len = 1L, - null.ok = FALSE - ) + null.ok = FALSE) checkmate::assert_character(dbms, any.missing = FALSE, len = 1L, - null.ok = FALSE - ) + null.ok = FALSE) checkmate::assert_character(password, any.missing = FALSE, len = 1L, - null.ok = FALSE - ) + null.ok = FALSE) checkmate::assert_character(host, any.missing = FALSE, len = 1L, - null.ok = FALSE - ) + null.ok = FALSE) checkmate::assert_character(database_name, any.missing = FALSE, len = 1L, - null.ok = FALSE - ) + null.ok = FALSE) checkmate::assert_character(driver_name, len = 1L, null.ok = FALSE, - any.missing = FALSE - ) + any.missing = FALSE) checkmate::assert_vector(source, # nolint any.missing = FALSE, min.len = 1L, -======= -#' which the data should be pulled -#' @param source and SQL query or a vector of table names from -#' the project or database. When this is not specified, the function will -#' extract data from all tables in the database. -#' @param driver_name the name of the MS driver. use `odbc::odbcListDrivers()` -#' to display the list of installed drivers -#' @param records a vector or a comma-separated string of subset of subject IDs. -#' When specified, only the records that correspond to these subjects will be -#' imported. -#' @param fields a vector of strings where each string is a comma-separated list -#' of column names. The element of this vector should be a list of column names -#' from the first table specified in the `table_names` argument and so on... -#' @param id_position a vector of the column positions of the variable that -#' unique identifies the subjects in each table. When the column name with the -#' subject IDs is known, use the `id_col_name` argument instead. default is. -#' default is 1. -#' @param id_col_name the column name with the subject IDs -#' @param dbms the SQL server type -#' @returns a list of data frames -#' @examples -#' \dontrun{ -#' data <- sql_server_read_data( -#' user = "rfamro", -#' password = "", -#' host = "mysql-rfam-public.ebi.ac.uk", -#' port = 4497, -#' database_name = "Rfam", -#' source = "author", -#' driver_name = "", -#' dbms = "MySQL" -#' ) -#' } -#' @export -#' @importFrom magrittr %>% -sql_server_read_data <- function(user, password, host, port = 1433, - database_name, driver_name, - source = NULL, records = NULL, - fields = NULL, id_position = NULL, - id_col_name = NULL, dbms) { - # check the input arguments - checkmate::assert_vector(id_position, - any.missing = FALSE, min.len = 0, - null.ok = TRUE, unique = FALSE - ) - checkmate::assert_vector(id_col_name, - any.missing = FALSE, min.len = 1, - null.ok = TRUE, unique = FALSE - ) - checkmate::assert_number(port, lower = 1) - checkmate::assert_character(user, any.missing = FALSE, len = 1, - null.ok = FALSE) - checkmate::assert_character(dbms, any.missing = FALSE, len = 1, - null.ok = FALSE) - checkmate::assert_character(password, any.missing = FALSE, len = 1, - null.ok = FALSE) - checkmate::assert_character(host, any.missing = FALSE, len = 1, - null.ok = FALSE) - checkmate::assert_character(database_name, any.missing = FALSE, len = 1, - null.ok = FALSE) - checkmate::assert_character(driver_name, len = 1, null.ok = FALSE, - any.missing = FALSE) - checkmate::assert_vector(source, - any.missing = FALSE, min.len = 1, - null.ok = TRUE, unique = TRUE - ) - checkmate::assert_vector(records, - any.missing = FALSE, min.len = 1, - null.ok = TRUE, unique = TRUE - ) - checkmate::assert_vector(fields, - any.missing = FALSE, min.len = 1, ->>>>>>> main - null.ok = TRUE, unique = TRUE - ) + null.ok = TRUE, unique = TRUE) final_result <- list() -<<<<<<< HEAD -======= - from_query <- from_table_names <- NULL ->>>>>>> main # check the id_position and id_column name if (all(!is.null(id_position) & !is.null(id_col_name))) { @@ -181,7 +86,6 @@ sql_server_read_data <- function(user, password, host, port = 1433, } # establishing the connection to the server -<<<<<<< HEAD con <- connect_to_server( dbms, driver_name, host, database_name, user, password, port @@ -189,18 +93,10 @@ sql_server_read_data <- function(user, password, host, port = 1433, # listing the names of the tables present in the database tables <- DBI::dbListTables(conn = con) -======= - con <- connect_to_server(dbms, driver_name, host, database_name, - user, password, port) - - # listing the names of the tables present in the database - tables <- DBI::dbListTables(conn = con) ->>>>>>> main table_names <- NULL # closing the connection pool::poolClose(con) -<<<<<<< HEAD # separate the sources idx <- which(source %in% tables) # nolint if (length(idx) > 0L) { @@ -215,26 +111,10 @@ sql_server_read_data <- function(user, password, host, port = 1433, driver_name, host, database_name, user, password, port ) -======= - - # separate the sources - idx <- which(source %in% tables) - if (length(idx) > 0) { - table_names <- source[idx] - source <- source[-idx] - } - - # fetch data using SQL query - if (length(source) > 0) { - from_query <- fetch_data_from_query(source, dbms, tables, - driver_name, host, database_name, - user, password, port) ->>>>>>> main final_result <- c(final_result, from_query) } # fetch data from tables -<<<<<<< HEAD if (length(table_names) > 0L) { from_table_names <- sql_select_data( table_names, dbms, id_col_name, @@ -242,13 +122,6 @@ sql_server_read_data <- function(user, password, host, port = 1433, driver_name, host, database_name, user, password, port ) -======= - if (length(table_names) > 0) { - from_table_names <- sql_select_data(table_names, dbms, id_col_name, - fields, records, id_position, - driver_name, host, database_name, - user, password, port) ->>>>>>> main final_result <- c(final_result, from_table_names) } diff --git a/R/read_servers_helpers.R b/R/read_servers_helpers.R index 1fb1da8c..356574f1 100644 --- a/R/read_servers_helpers.R +++ b/R/read_servers_helpers.R @@ -8,7 +8,6 @@ #' @param password the user's password #' @param port the server port ID #' -<<<<<<< HEAD #' @return the `connection` object #' #' @examples @@ -26,80 +25,29 @@ #' connect_to_server <- function(dbms, driver_name, host, database_name, user, password, port) { - con <- switch(dbms, + con <- switch( + dbms, "SQLServer" = pool::dbPool(odbc::odbc(), - driver = driver_name, - server = host, + driver = driver_name, + server = host, database = database_name, - uid = user, pwd = password, - port = port - ), + uid = user, + pwd = password, + port = port), "PostgreSQL" = pool::dbPool(odbc::odbc(), - driver = driver_name, - host = host, + driver = driver_name, + host = host, database = database_name, - uid = user, pwd = password, - port = port - ), - "MySQL" = pool::dbPool( - drv = RMySQL::MySQL(), - dbname = database_name, - username = user, password = password, - host = host, port = port, - driver = driver_name -======= -#' @return the connection object -#' @export -#' -#' @examples -#' con <- connect_to_server( -#' dbms = "MySQL", -#' driver_name = "", -#' host = "mysql-rfam-public.ebi.ac.uk", -#' database_name = "Rfam", -#' user = "rfamro", -#' password = "", -#' port = 4497 -#' ) -connect_to_server <- function(dbms, driver_name, host, database_name, - user, password, port) { - checkmate::assert_character(dbms, any.missing = FALSE, len = 1, - null.ok = FALSE) - checkmate::assert_character(driver_name, len = 1, null.ok = FALSE, - any.missing = FALSE) - checkmate::assert_character(host, any.missing = FALSE, len = 1, - null.ok = FALSE) - checkmate::assert_character(database_name, any.missing = FALSE, len = 1, - null.ok = FALSE) - checkmate::assert_character(user, any.missing = FALSE, len = 1, - null.ok = FALSE) - checkmate::assert_character(password, any.missing = FALSE, len = 1, - null.ok = FALSE) - checkmate::assert_number(port, lower = 1) - con <- switch(dbms, - "SQLServer" = pool::dbPool(odbc::odbc(), - driver = driver_name, - server = host, - database = database_name, - uid = user, pwd = password, - port = as.numeric(port) - ), - "PostgreSQL" = pool::dbPool(odbc::odbc(), - driver = driver_name, - host = host, - database = database_name, - uid = user, pwd = password, - port = as.numeric(port) - ), + uid = user, + pwd = password, + port = port), "MySQL" = pool::dbPool(drv = RMySQL::MySQL(), - dbname = database_name, - username = user, password = password, - host = host, port = as.numeric(port), - driver = driver_name, - maxSize = 50 ->>>>>>> main - ) - ) + dbname = database_name, + username = user, + password = password, + host = host, + port = port, + driver = driver_name)) con } @@ -109,7 +57,6 @@ connect_to_server <- function(dbms, driver_name, host, database_name, #' @param query the SQL query #' @param tables the list of all tables from the database #' -<<<<<<< HEAD #' @return a `character` with the extracted table name(s) from the SQL query #' #' @examples @@ -123,39 +70,15 @@ connect_to_server <- function(dbms, driver_name, host, database_name, identify_table_name <- function(query, tables) { checkmate::assert_character(query, any.missing = FALSE, len = 1L, - null.ok = FALSE - ) + null.ok = FALSE) checkmate::assert_vector(tables, any.missing = FALSE, min.len = 1L, - null.ok = FALSE, unique = TRUE - ) - table_name <- NULL - query <- unlist(strsplit(query, " ", fixed = TRUE)) - table_name <- query[which(query %in% tables)] - table_name <- ifelse(length(table_name) == 1, table_name, # nolint - glue::glue_collapse(table_name, sep = "_") - ) -======= -#' @return the table name of interest -#' @export -#' -#' @examples -#' table_name = identify_table_name( -#' query = "select * from author", -#' tables = c("family_author", "author", "test") -#' ) -#' -identify_table_name <- function(query, tables) { - checkmate::assert_character(query, any.missing = FALSE, len = 1, - null.ok = FALSE) - checkmate::assert_vector(tables, any.missing = FALSE, min.len = 1, null.ok = FALSE, unique = TRUE) table_name <- NULL - query <- unlist(strsplit(query, " ", fixed = TRUE)) + query <- unlist(strsplit(query, " ", fixed = TRUE)) table_name <- query[which(query %in% tables)] - table_name <- ifelse(length(table_name) == 1, table_name, + table_name <- ifelse(length(table_name) == 1L, table_name, glue::glue_collapse(table_name, sep = "_")) ->>>>>>> main table_name } @@ -171,7 +94,6 @@ identify_table_name <- function(query, tables) { #' @param password the user's password #' @param port the server port ID #' -<<<<<<< HEAD #' @return a `list` of 1 or more objects of type `data.frame` containing each #' data fetched from one table. #' @@ -195,8 +117,7 @@ fetch_data_from_query <- function(source, dbms, tables, user, password, port) { checkmate::assert_vector(tables, any.missing = FALSE, min.len = 1L, - null.ok = FALSE, unique = TRUE - ) + null.ok = FALSE, unique = TRUE) pool <- connect_to_server( dbms, driver_name, host, database_name, @@ -210,58 +131,6 @@ fetch_data_from_query <- function(source, dbms, tables, } pool::poolClose(pool) -======= -#' @return a list with the data fetched from the tables of interest -#' @export -#' -#' @examples -#' result <- fetch_data_from_query( -#' source = "select author_id, name, last_name from author", -#' dbms = "MySQL", -#' tables = c("family_author", "author"), -#' driver_name = "", -#' host = "mysql-rfam-public.ebi.ac.uk", -#' database_name = "Rfam", -#' user = "rfamro", -#' password = "", -#' port = 4497 -#' ) -#' -fetch_data_from_query <- function(source, dbms, tables, - driver_name, host, database_name, - user, password, port) { - checkmate::assert_vector(source, - any.missing = FALSE, min.len = 1, - null.ok = FALSE, unique = TRUE - ) - checkmate::assert_character(dbms, any.missing = FALSE, len = 1, - null.ok = FALSE) - checkmate::assert_vector(tables, - any.missing = FALSE, min.len = 1, - null.ok = FALSE, unique = TRUE) - checkmate::assert_character(driver_name, len = 1, null.ok = FALSE, - any.missing = FALSE) - checkmate::assert_character(host, any.missing = FALSE, len = 1, - null.ok = FALSE) - checkmate::assert_character(database_name, any.missing = FALSE, len = 1, - null.ok = FALSE) - checkmate::assert_character(user, any.missing = FALSE, len = 1, - null.ok = FALSE) - checkmate::assert_character(password, any.missing = FALSE, len = 1, - null.ok = FALSE) - checkmate::assert_number(port, lower = 1) - - pool <- connect_to_server(dbms, driver_name, host, database_name, - user, password, port) - result <- list() - for (query in source) { - table <- identify_table_name(query, tables) - stopifnot("Could not detect table name from the query" = !is.null(table)) - result[[table]] <- DBI::dbGetQuery(pool, source) - } - - pool::poolClose(pool) ->>>>>>> main result } @@ -271,21 +140,12 @@ fetch_data_from_query <- function(source, dbms, tables, #' @param table_names the name of the tables where the data was fetched from #' @param dbms the database management system type #' @param id_col_name the column names that unique identify the records in the -<<<<<<< HEAD #' tables #' @param fields a vector of strings where each string is a comma-separated list #' of column names. #' @param records a vector or a comma-separated string of subset of subject IDs. #' @param id_position a vector of the column positions of the variable that #' unique identifies the subjects in each table -======= -#' tables -#' @param fields a vector of strings where each string is a comma-separated list -#' of column names. -#' @param records a vector or a comma-separated string of subset of subject IDs. -#' @param id_position a vector of the column positions of the variable that -#' unique identifies the subjects in each table ->>>>>>> main #' @param driver_name the driver name #' @param host host server name #' @param database_name the database name @@ -293,7 +153,6 @@ fetch_data_from_query <- function(source, dbms, tables, #' @param password the user's password #' @param port the server port ID #' -<<<<<<< HEAD #' @return a `list` of 1 or more elements of type `data.frame` where every #' element contains the subset of the data from the corresponding table #' @examples @@ -313,38 +172,17 @@ fetch_data_from_query <- function(source, dbms, tables, #' port = 4497 #' ) #' } -======= -#' @return a subset of the data in the specified tables -#' @export -#' @examples -#' result = sql_select_data( -#' table_names = "author", -#' dbms = "MySQL", -#' id_col_name = "author_id", -#' fields = c("author_id", "name"), -#' records = NULL, -#' id_position = NULL, -#' driver_name = "", -#' host = "mysql-rfam-public.ebi.ac.uk", -#' database_name = "Rfam", -#' user = "rfamro", -#' password = "", -#' port = 4497 -#' ) ->>>>>>> main #' sql_select_data <- function(table_names, dbms, id_col_name, fields, records, id_position, driver_name, host, database_name, user, password, port) { -<<<<<<< HEAD checkmate::assert_vector(table_names, any.missing = FALSE, min.len = 1L, - null.ok = FALSE, unique = FALSE - ) + null.ok = FALSE, unique = FALSE) result <- list() - j <- 1 # nolint + j <- 1L for (table in table_names) { message("\nFetching data from: ", table) @@ -358,8 +196,7 @@ sql_select_data <- function(table_names, dbms, id_col_name, } else if (!is.null(records) && is.null(fields)) { record <- ifelse(all(grepl(",", records, fixed = TRUE) & length(records) > 1L), - records[j], records - ) + records[j], records) result[[table]] <- sql_select_records_only( table, record, id_col_name, id_position, dbms, driver_name, @@ -369,26 +206,20 @@ sql_select_data <- function(table_names, dbms, id_col_name, } else if (!is.null(fields) && is.null(records)) { field <- ifelse(all(grepl(",", fields, fixed = TRUE) & length(fields) > 1L), - fields[j], fields - ) - result[[table]] <- sql_select_fields_only( - table, field, dbms, driver_name, - host, database_name, user, - password, port - ) + fields[j], fields) + result[[table]] <- sql_select_fields_only(table, field, dbms, driver_name, + host, database_name, user, + password, port) } else { record <- ifelse(all(grepl(",", records, fixed = TRUE) & length(records) > 1L), - records[j], records - ) + records[j], records) field <- ifelse(all(grepl(",", fields, fixed = TRUE) & - length(fields) > 1), # nolint - fields[j], fields - ) - id_column_name <- get_id_column_name( - id_col_name, - j, id_position - )[["id_column_name"]] + length(fields) > 1L), + fields[j], fields) + id_column_name <- get_id_column_name(id_col_name, + j, + id_position)[["id_column_name"]] id_pos <- get_id_column_name(id_col_name, j, id_position)[["id_pos"]] result[[table]] <- sql_select_records_and_fields( table, record, @@ -402,89 +233,6 @@ sql_select_data <- function(table_names, dbms, id_col_name, j <- j + 1 # nolint } -======= - checkmate::assert_number(port, lower = 1) - checkmate::assert_character(password, any.missing = FALSE, len = 1, - null.ok = FALSE) - checkmate::assert_character(user, any.missing = FALSE, len = 1, - null.ok = FALSE) - checkmate::assert_character(host, any.missing = FALSE, len = 1, - null.ok = FALSE) - checkmate::assert_character(driver_name, len = 1, null.ok = FALSE, - any.missing = FALSE) - checkmate::assert_vector(table_names, - any.missing = FALSE, min.len = 1, - null.ok = FALSE, unique = FALSE - ) - checkmate::assert_character(dbms, any.missing = FALSE, len = 1, - null.ok = FALSE) - checkmate::assert_vector(id_col_name, - any.missing = FALSE, min.len = 1, - null.ok = TRUE, unique = FALSE - ) - checkmate::assert_vector(records, - any.missing = FALSE, min.len = 1, - null.ok = TRUE, unique = TRUE - ) - checkmate::assert_vector(fields, - any.missing = FALSE, min.len = 1, - null.ok = TRUE, unique = TRUE - ) - checkmate::assert_vector(id_position, - any.missing = FALSE, min.len = 0, - null.ok = TRUE, unique = FALSE - ) - checkmate::assert_character(database_name, any.missing = FALSE, len = 1, - null.ok = FALSE) - - # con <- connect_to_server(dbms, driver_name, host, database_name, - # user, password, port) - result <- list() - j <- 1 - for (table in table_names) { - R.utils::cat("\nFetching data from", table) - - # select records from table - if (all(is.null(records) & is.null(fields))) { - result[[table]] <- sql_select_entire_dataset(table, dbms, driver_name, - host, database_name, user, - password, port) - } else if (!is.null(records) && is.null(fields)) { - record <- ifelse(all(grepl(",", records, fixed = TRUE) == TRUE & - length(records) > 1), - records[j], records) - result[[table]] <- sql_select_records_only(table, record, id_col_name, - id_position, dbms, driver_name, - host, database_name, user, - password, port) - - } else if (!is.null(fields) && is.null(records)) { - field <- ifelse(all(grepl(",", fields, fixed = TRUE) == TRUE & - length(fields) > 1), - fields[j], fields) - result[[table]] <- sql_select_fields_only(table, field, dbms, driver_name, - host, database_name, user, - password, port) - } else { - record <- ifelse(all(grepl(",", records, fixed = TRUE) == TRUE & - length(records) > 1), - records[j], records) - field <- ifelse(all(grepl(",", fields, fixed = TRUE) == TRUE & - length(fields) > 1), - fields[j], fields) - id_column_name <- get_id_column_name(id_col_name, j, id_position)[[1]] - id_pos <- get_id_column_name(id_col_name, j, id_position)[[2]] - result[[table]] <- sql_select_records_and_fields(table, record, - id_column_name, field, - id_pos, dbms, - driver_name, host, - database_name, user, - password, port) - } - - j <- j + 1 - } ->>>>>>> main result } @@ -494,27 +242,13 @@ sql_select_data <- function(table_names, dbms, id_col_name, #' @param j the index #' @param id_position the id position #' -<<<<<<< HEAD #' @returns a `list` of 2 elements of type `character` and `numeric` #' corresponding to the ID column name and position #' get_id_column_name <- function(id_col_name, j, id_position) { checkmate::assert_numeric(j, lower = 1L, any.missing = FALSE, - len = 1L, null.ok = FALSE -======= -get_id_column_name <- function(id_col_name, j, id_position) { - checkmate::assert_vector(id_col_name, - any.missing = FALSE, min.len = 1, - null.ok = TRUE, unique = FALSE - ) - checkmate::assert_numeric(j, lower = 1, any.missing = FALSE, - len = 1, null.ok = FALSE) - checkmate::assert_vector(id_position, - any.missing = FALSE, min.len = 1, - null.ok = TRUE, unique = FALSE ->>>>>>> main - ) + len = 1L, null.ok = FALSE) id_column_name <- id_pos <- NULL if (!is.null(id_col_name)) { id_col_name <- gsub(" ", "", id_col_name, fixed = TRUE) @@ -529,13 +263,8 @@ get_id_column_name <- function(id_col_name, j, id_position) { } list( -<<<<<<< HEAD id_column_name = id_column_name, id_pos = id_pos -======= - id_column_name, - id_pos ->>>>>>> main ) } @@ -550,7 +279,6 @@ get_id_column_name <- function(id_col_name, j, id_position) { #' @param password the user's password #' @param port the server port ID #' -<<<<<<< HEAD #' @return an object of type `data.frame` with the entire dataset fetched from #' the specified table #' @@ -572,52 +300,13 @@ sql_select_entire_dataset <- function(table, dbms, driver_name, host, database_name, user, password, port) { checkmate::assert_character(table, any.missing = FALSE, len = 1L, - null.ok = FALSE - ) + null.ok = FALSE) con <- connect_to_server( dbms, driver_name, host, database_name, user, password, port ) query <- sprintf("select * from %s", table) -======= -#' @return a data frame with the entire dataset that is contained in the table -#' @export -#' -#' @examples -#' result <- sql_select_entire_dataset( -#' table = "author", -#' dbms = "MySQL", -#' driver_name = "", -#' host = "mysql-rfam-public.ebi.ac.uk", -#' database_name = "Rfam", -#' user = "rfamro", -#' password = "", -#' port = 4497 -#' ) -#' -sql_select_entire_dataset <- function(table, dbms, driver_name, host, - database_name, user, password, port) { - checkmate::assert_character(table, any.missing = FALSE, len = 1, - null.ok = FALSE) - checkmate::assert_character(dbms, any.missing = FALSE, len = 1, - null.ok = FALSE) - checkmate::assert_character(driver_name, len = 1, null.ok = FALSE, - any.missing = FALSE) - checkmate::assert_character(host, any.missing = FALSE, len = 1, - null.ok = FALSE) - checkmate::assert_character(database_name, any.missing = FALSE, len = 1, - null.ok = FALSE) - checkmate::assert_character(user, any.missing = FALSE, len = 1, - null.ok = FALSE) - checkmate::assert_character(password, any.missing = FALSE, len = 1, - null.ok = FALSE) - checkmate::assert_number(port, lower = 1) - - con <- connect_to_server(dbms, driver_name, host, database_name, - user, password, port) - query <- paste0("select * from ", table) ->>>>>>> main res <- DBI::dbGetQuery(con, query) pool::poolClose(con) res @@ -635,7 +324,6 @@ sql_select_entire_dataset <- function(table, dbms, driver_name, host, #' @param password the user's password #' @param port the server port ID #' @param id_column_name the column names that unique identify the records in -<<<<<<< HEAD #' the tables #' @param field a vector of strings where each string is a comma-separated list #' of column names. @@ -663,105 +351,31 @@ sql_select_entire_dataset <- function(table, dbms, driver_name, host, #' port = 4497 #' ) #' } -======= -#' the tables -#' @param field a vector of strings where each string is a comma-separated list -#' of column names. -#' @param dbms the database management system type -#' @param id_pos a vector of the column positions of the variable that -#' unique identifies the subjects in each table -#' -#' @return a data frame with the specified columns and records -#' @export -#' -#' @examples -#' result <- sql_select_records_and_fields( -#' table = "author", -#' record = c("1", "20", "50"), -#' id_column_name = "author_id", -#' field = c("author_id", "last_name"), -#' id_pos = NULL, -#' dbms = "MySQL", -#' driver_name = "", -#' host = "mysql-rfam-public.ebi.ac.uk", -#' database_name = "Rfam", -#' user = "rfamro", -#' password = "", -#' port = 4497 -#' ) ->>>>>>> main #' sql_select_records_and_fields <- function(table, record, id_column_name, field, id_pos, dbms, driver_name, host, database_name, user, password, port) { -<<<<<<< HEAD checkmate::assert_character(id_column_name, any.missing = FALSE, - null.ok = TRUE, unique = TRUE -======= - checkmate::assert_character(dbms, any.missing = FALSE, len = 1, - null.ok = FALSE) - checkmate::assert_character(driver_name, len = 1, null.ok = FALSE, - any.missing = FALSE) - checkmate::assert_character(host, any.missing = FALSE, len = 1, - null.ok = FALSE) - checkmate::assert_character(database_name, any.missing = FALSE, len = 1, - null.ok = FALSE) - checkmate::assert_character(user, any.missing = FALSE, len = 1, - null.ok = FALSE) - checkmate::assert_character(password, any.missing = FALSE, len = 1, - null.ok = FALSE) - checkmate::assert_number(port, lower = 1) - checkmate::assert_character(id_column_name, - any.missing = FALSE, - null.ok = TRUE, unique = TRUE ->>>>>>> main - ) + null.ok = TRUE, unique = TRUE) checkmate::assert_character(id_pos, any.missing = FALSE, - null.ok = TRUE, unique = TRUE - ) -<<<<<<< HEAD + null.ok = TRUE, unique = TRUE) checkmate::assert_character(table, any.missing = FALSE, len = 1L, - null.ok = FALSE - ) + null.ok = FALSE) checkmate::assert_vector(record, any.missing = FALSE, min.len = 1L, - null.ok = TRUE, unique = TRUE - ) + null.ok = TRUE, unique = TRUE) checkmate::assert_vector(field, any.missing = FALSE, min.len = 1L, - null.ok = TRUE, unique = TRUE - ) - - con <- connect_to_server( - dbms, driver_name, host, database_name, - user, password, port - ) - res <- sql_select_records_only( - table, record, id_column_name, id_pos, dbms, - driver_name, host, database_name, user, - password, port - ) -======= - checkmate::assert_character(table, any.missing = FALSE, len = 1, - null.ok = FALSE) - checkmate::assert_vector(record, - any.missing = FALSE, min.len = 1, - null.ok = TRUE, unique = TRUE - ) - checkmate::assert_vector(field, - any.missing = FALSE, min.len = 1, - null.ok = TRUE, unique = TRUE - ) + null.ok = TRUE, unique = TRUE) con <- connect_to_server(dbms, driver_name, host, database_name, user, password, port) res <- sql_select_records_only(table, record, id_column_name, id_pos, dbms, driver_name, host, database_name, user, password, port) ->>>>>>> main if (is.character(field)) { field <- as.character(lapply(field, function(x) { gsub(" ", "", x, fixed = TRUE) @@ -776,7 +390,6 @@ sql_select_records_and_fields <- function(table, record, id_column_name, field, #' Visualize the first 5 rows of the data from a table #' -<<<<<<< HEAD #' @param data_source the the URL of the HIS #' @param credentials_file the path to the file with the user-specific #' credential details for the projects of interest @@ -799,8 +412,7 @@ sql_select_records_and_fields <- function(table, record, id_column_name, field, visualise_table <- function(data_source, credentials_file, from, driver_name) { checkmate::assert_character(from, any.missing = FALSE, len = 1L, - null.ok = FALSE - ) + null.ok = FALSE) checkmate::assert_character(credentials_file, null.ok = FALSE, len = 1L) checkmate::assert_file_exists(credentials_file) checkmate::assert_character(data_source, null.ok = FALSE, len = 1L) @@ -813,43 +425,7 @@ visualise_table <- function(data_source, credentials_file, from, driver_name) { ) query <- ifelse(credentials[["dbms"]] == "MySQL", sprintf("select * from %s limit 5", from), - sprintf("select top 5 * from %s", from) - ) -======= -#' @param credentials_file the path to the file with the user-specific -#' credential details for the projects of interest -#' @param source the table name -#' @param project_id the name of the target database -#' @param driver_name the name of the MS driver -#' -#' @return return the first 5 rows of the table if display=TRUE -#' @export -#' -#' @examples -#' visualise_table( -#' credentials_file <- system.file("extdata", "test.ini", package = "readepi"), -#' source = "author", -#' project_id = "Rfam", -#' driver_name = "" -#' ) -#' -visualise_table <- function(credentials_file, source, project_id, - driver_name) { - checkmate::assert_character(source, any.missing = FALSE, len = 1, - null.ok = FALSE) - checkmate::assert_character(credentials_file, null.ok = FALSE, len = 1) - checkmate::assert_file_exists(credentials_file) - checkmate::assert_character(project_id, null.ok = FALSE, len = 1) - checkmate::assert_character(driver_name, null.ok = FALSE, len = 1) - - credentials <- read_credentials(credentials_file, project_id) - con <- connect_to_server(credentials$dbms, driver_name, credentials$host, - project_id, credentials$user, credentials$pwd, - credentials$port) - query <- ifelse(credentials$dbms == "MySQL", - paste0("select * from ", source, " limit 5"), - paste0("select top 5 * from ", source)) ->>>>>>> main + sprintf("select top 5 * from %s", from)) res <- DBI::dbGetQuery(con, query) pool::poolClose(con) print(res) @@ -861,15 +437,9 @@ visualise_table <- function(credentials_file, source, project_id, #' @param table the table name #' @param record a vector or a comma-separated string of subset of subject IDs. #' @param id_column_name the column names that unique identify the records in -<<<<<<< HEAD #' the tables #' @param id_pos a vector of the column positions of the variable that #' unique identifies the subjects in each table -======= -#' the tables -#' @param id_pos a vector of the column positions of the variable that -#' unique identifies the subjects in each table ->>>>>>> main #' @param dbms the database management system type #' @param driver_name the driver name #' @param host host server name @@ -878,7 +448,6 @@ visualise_table <- function(credentials_file, source, project_id, #' @param password the user's password #' @param port the server port ID #' -<<<<<<< HEAD #' @return an object of type `data.frame` that contains the data fetched from #' the specific table with only the records of interest. #' @@ -899,118 +468,43 @@ visualise_table <- function(credentials_file, source, project_id, #' ) #' } #' -======= -#' @return a data frame with the records of interest -#' @export -#' -#' @examples -#' result <- sql_select_records_only( -#' table = "author", -#' record = c("1", "20", "50"), -#' id_column_name = NULL, -#' id_pos = 1, -#' dbms = "MySQL", -#' driver_name = "", -#' host = "mysql-rfam-public.ebi.ac.uk", -#' database_name = "Rfam", -#' user = "rfamro", -#' password = "", -#' port = 4497 -#' ) ->>>>>>> main sql_select_records_only <- function(table, record, id_column_name, id_pos, dbms, driver_name, host, database_name, user, password, port) { checkmate::assert_vector(id_pos, -<<<<<<< HEAD any.missing = FALSE, min.len = 0L, - null.ok = TRUE, unique = FALSE - ) + null.ok = TRUE, unique = FALSE) checkmate::assert_vector(id_column_name, any.missing = FALSE, min.len = 1L, - null.ok = TRUE, unique = FALSE - ) + null.ok = TRUE, unique = FALSE) checkmate::assert_character(table, any.missing = FALSE, len = 1L, - null.ok = FALSE - ) + null.ok = FALSE) checkmate::assert_vector(record, any.missing = FALSE, min.len = 1L, - null.ok = TRUE, unique = TRUE - ) + null.ok = TRUE, unique = TRUE) - con <- connect_to_server( - dbms, driver_name, host, database_name, - user, password, port - ) + con <- connect_to_server(dbms, driver_name, host, database_name, + user, password, port) query <- ifelse(dbms == "MySQL", sprintf("select * from %s limit 5", table), - sprintf("select top 5 * from %s", table) - ) - first_5_rows <- DBI::dbGetQuery(con, query) - id_col_name <- ifelse(!is.null(id_column_name), - id_column_name, - names(first_5_rows)[id_pos] - ) - stopifnot( - "Missing or NULL value found in record argument" = - (anyNA(record) || !any(is.null(record))) -======= - any.missing = FALSE, min.len = 0, - null.ok = TRUE, unique = FALSE - ) - checkmate::assert_vector(id_column_name, - any.missing = FALSE, min.len = 1, - null.ok = TRUE, unique = FALSE - ) - checkmate::assert_character(table, any.missing = FALSE, len = 1, - null.ok = FALSE) - checkmate::assert_vector(record, - any.missing = FALSE, min.len = 1, - null.ok = TRUE, unique = TRUE - ) - checkmate::assert_character(dbms, any.missing = FALSE, len = 1, - null.ok = FALSE) - checkmate::assert_character(driver_name, len = 1, null.ok = FALSE, - any.missing = FALSE) - checkmate::assert_character(host, any.missing = FALSE, len = 1, - null.ok = FALSE) - checkmate::assert_character(database_name, any.missing = FALSE, len = 1, - null.ok = FALSE) - checkmate::assert_character(user, any.missing = FALSE, len = 1, - null.ok = FALSE) - checkmate::assert_character(password, any.missing = FALSE, len = 1, - null.ok = FALSE) - checkmate::assert_number(port, lower = 1) - - con <- connect_to_server(dbms, driver_name, host, database_name, - user, password, port) - query <- ifelse(dbms == "MySQL", - paste0("select * from ", table, " limit 5"), - paste0("select top 5 * from ", table)) + sprintf("select top 5 * from %s", table)) first_5_rows <- DBI::dbGetQuery(con, query) - id_col_name <- ifelse(!is.null(id_column_name), - id_column_name, - names(first_5_rows)[id_pos]) - stopifnot("Missing or NULL value found in record argument" = (anyNA(record) || - !any(is.null(record))) ->>>>>>> main - ) + id_col_name <- ifelse(!is.null(id_column_name), + id_column_name, + names(first_5_rows)[id_pos]) + stopifnot("Missing or NULL value found in record argument" = + (anyNA(record) || !any(is.null(record)))) if (is.vector(record)) { record <- glue::glue_collapse(record, sep = ", ") } - record <- as.character(lapply(record, function(x) { + record <- as.character(lapply(record, function(x) { gsub(" ", "", x, fixed = TRUE) })) - record <- gsub(",", "','", record, fixed = TRUE) -<<<<<<< HEAD + record <- gsub(",", "','", record, fixed = TRUE) sprintf("select * from %s where (%s in ('%s'))", table, id_col_name, record) -======= - query <- paste0("select * from ", table, - " where (", id_col_name, " in ('", record, "'))") ->>>>>>> main - res <- DBI::dbGetQuery(con, query) + res <- DBI::dbGetQuery(con, query) pool::poolClose(con) res } @@ -1028,7 +522,6 @@ sql_select_records_only <- function(table, record, id_column_name, id_pos, #' @param password the user's password #' @param port the server port ID #' -<<<<<<< HEAD #' @return an object of type `data.frame` that contains the data fetched from #' the specific table with only the fields of interest. #' @@ -1051,12 +544,10 @@ sql_select_fields_only <- function(table, field, dbms, driver_name, host, database_name, user, password, port) { checkmate::assert_character(table, any.missing = FALSE, len = 1L, - null.ok = FALSE - ) + null.ok = FALSE) checkmate::assert_vector(field, any.missing = FALSE, min.len = 1L, - null.ok = TRUE, unique = TRUE - ) + null.ok = TRUE, unique = TRUE) stopifnot( "Missing or NULL value found in record argument" = (anyNA(field) || !any(is.null(field))) # nolint @@ -1065,51 +556,6 @@ sql_select_fields_only <- function(table, field, dbms, driver_name, host, dbms, driver_name, host, database_name, user, password, port ) -======= -#' @return a data frame with the specified fields -#' @export -#' -#' @examples -#' result <- sql_select_fields_only( -#' table = "author", -#' field = c("author_id", "name", "last_name"), -#' dbms = "MySQL", -#' driver_name = "", -#' host = "mysql-rfam-public.ebi.ac.uk", -#' database_name = "Rfam", -#' user = "rfamro", -#' password = "", -#' port = 4497 -#') -#' -sql_select_fields_only <- function(table, field, dbms, driver_name, host, - database_name, user, password, port) { - checkmate::assert_character(table, any.missing = FALSE, len = 1, - null.ok = FALSE) - checkmate::assert_vector(field, - any.missing = FALSE, min.len = 1, - null.ok = TRUE, unique = TRUE - ) - checkmate::assert_character(dbms, any.missing = FALSE, len = 1, - null.ok = FALSE) - checkmate::assert_character(driver_name, len = 1, null.ok = FALSE, - any.missing = FALSE) - checkmate::assert_character(host, any.missing = FALSE, len = 1, - null.ok = FALSE) - checkmate::assert_character(database_name, any.missing = FALSE, len = 1, - null.ok = FALSE) - checkmate::assert_character(user, any.missing = FALSE, len = 1, - null.ok = FALSE) - checkmate::assert_character(password, any.missing = FALSE, len = 1, - null.ok = FALSE) - checkmate::assert_number(port, lower = 1) - - stopifnot("Missing or NULL value found in record argument" = (anyNA(field) || - !any(is.null(field))) - ) - con <- connect_to_server(dbms, driver_name, host, database_name, - user, password, port) ->>>>>>> main if (is.vector(field)) { field <- glue::glue_collapse(field, sep = ", ") } @@ -1119,11 +565,7 @@ sql_select_fields_only <- function(table, field, dbms, driver_name, host, field <- as.character(lapply(field, function(x) { gsub(",", ", ", x, fixed = TRUE) })) -<<<<<<< HEAD query <- sprintf("select %s from %s", field, table) -======= - query <- paste0("select ", field, " from ", table) ->>>>>>> main res <- DBI::dbGetQuery(con, query) pool::poolClose(con) res diff --git a/R/readepi.R b/R/readepi.R index 5bc81e4e..c597e822 100644 --- a/R/readepi.R +++ b/R/readepi.R @@ -1,4 +1,3 @@ -<<<<<<< HEAD #' Import data from different data_sources into R #' #' @description the function allows import of data from Health Information @@ -19,126 +18,50 @@ #' #' @examples #' # reading from a MySQL server +#' \dontrun{ #' data <- readepi( #' data_source = "mysql-rfam-public.ebi.ac.uk", #' credentials_file = system.file("extdata", "test.ini", package = "readepi"), #' driver_name = "", #' from = "author" #' ) +#' } #' @returns a `list` of 1 or several object of type `data frame`. #' @export readepi <- function(data_source = NULL, -======= -#' Import data from different sources into R -#' -#' @description the function allows import of data from files, folders, or -#' health information systems (HIS) -#' The HIS consist of database management systems (DBMS) and website of public -#' data collection. -#' -#' @param credentials_file the path to the file with the user-specific -#' credential details -#' for the projects of interest. It is required when importing data from DBMS. -#' This is a tab-delimited file with the following columns: -#' \enumerate{ -#' \item user_name: the user name -#' \item password: the user password (for REDCap, this corresponds to the -#' **token** that serves as password to the project) -#' \item host_name: the host name (for MS SQL servers) or the URI (for REDCap) -#' \item project_id: the project ID or the name of the database -#' you are access to. -#' \item comment: a summary description about the project or database -#' of interest -#' \item dbms: the name of the DBMS: Possible values are: 'REDCap', -#' 'SQLServer', 'MySQL', 'PostgreSQL', etc... -#' \item port: the port ID -#' } -#' Use the `show_example_file()` function to display the structure of -#' the template credentials file -#' @param file_path the path to the file to be read. When several files need to -#' be imported from a directory, this should be the path to that directory -#' @param records a vector or a comma-separated string of subject IDs. -#' When specified, only these records will be imported. -#' @param fields a vector or a comma-separated string of column names. -#' If provided, only those columns will be imported. -#' @param id_position the column position of the variable that unique identifies -#' the subjects. When the name of the column with the subject IDs is known, -#' this can be provided using the `id_col_name` argument -#' @param id_col_name the column name with the subject IDs. -#' @param ... additional arguments passed to the readepi function. -#' These are enumarated in the vignette. -#' @examples -#' # reading from a MS SQL server -#' data <- readepi( -#' credentials_file = system.file("extdata", "test.ini", package = "readepi"), -#' project_id = "Rfam", -#' driver_name = "", -#' source = "author" -#' ) -#' @returns a list of data frames. -#' @export -readepi <- function(credentials_file = NULL, - file_path = NULL, ->>>>>>> main records = NULL, fields = NULL, id_position = NULL, id_col_name = NULL, ...) { # check the input arguments -<<<<<<< HEAD checkmate::assert_character(data_source, null.ok = TRUE, any.missing = FALSE, - min.len = 0L - ) + min.len = 0L) checkmate::assert_vector(records, any.missing = FALSE, min.len = 0L, - null.ok = TRUE, unique = TRUE - ) + null.ok = TRUE, unique = TRUE) checkmate::assert_vector(fields, any.missing = FALSE, min.len = 0L, - null.ok = TRUE, unique = TRUE - ) + null.ok = TRUE, unique = TRUE) checkmate::assert_vector(id_position, any.missing = FALSE, min.len = 0L, - null.ok = TRUE, unique = FALSE - ) + null.ok = TRUE, unique = FALSE) checkmate::assert_vector(id_col_name, any.missing = FALSE, min.len = 0L, - null.ok = TRUE, unique = TRUE -======= - checkmate::assertCharacter(credentials_file, len = 1L, null.ok = TRUE) - checkmate::assertCharacter(file_path, len = 1L, null.ok = TRUE) - checkmate::assert_vector(records, - any.missing = FALSE, min.len = 1, - null.ok = TRUE, unique = TRUE - ) - checkmate::assert_vector(fields, - any.missing = FALSE, min.len = 1, - null.ok = TRUE, unique = TRUE - ) - checkmate::assert_vector(id_position, - any.missing = FALSE, min.len = 1, - null.ok = TRUE, unique = FALSE - ) - checkmate::assert_vector(id_col_name, - any.missing = FALSE, min.len = 1, - null.ok = TRUE, unique = TRUE ->>>>>>> main - ) + null.ok = TRUE, unique = TRUE) # get the additional arguments args_list <- list(...) -<<<<<<< HEAD # reading from Fingertips if (any("indicator_id" %in% names(args_list) | - "indicator_name" %in% names(args_list) | - "area_type_id" %in% names(args_list) | - "profile_id" %in% names(args_list) | - "profile_name" %in% names(args_list) | - "domain_id" %in% names(args_list) | - "domain_name" %in% names(args_list))) { + "indicator_name" %in% names(args_list) | + "area_type_id" %in% names(args_list) | + "profile_id" %in% names(args_list) | + "profile_name" %in% names(args_list) | + "domain_id" %in% names(args_list) | + "domain_name" %in% names(args_list))) { args <- get_read_fingertips_args(args_list) res <- read_from_fingertips( indicator_id = args[["indicator_id"]], @@ -153,44 +76,10 @@ readepi <- function(credentials_file = NULL, records = records, id_position = id_position, id_col_name = id_col_name -======= - # some check points - if (all(!is.null(credentials_file) & !is.null(file_path))) { - stop("Impossible to import data from DBMS and file at the same time.") - } - - # reading from file - if (!is.null(file_path)) { - args <- get_read_file_args(args_list) - res <- read_from_file(file_path, - sep = args$sep, format = args$format, - which = args$which, pattern = args$pattern - ) - } - - # reading from Fingertips - if (any("indicator_id" %in% names(args_list) | - "indicator_name" %in% names(args_list) | - "area_type_id" %in% names(args_list) | - "profile_id" %in% names(args_list) | - "profile_name" %in% names(args_list) | - "domain_id" %in% names(args_list) | - "domain_name" %in% names(args_list))) { - args <- get_read_fingertips_args(args_list) - res <- read_from_fingertips( - indicator_id = args$indicator_id, indicator_name = args$indicator_name, - area_type_id = args$area_type_id, - parent_area_type_id = args$parent_area_type_id, - profile_id = args$profile_id, profile_name = args$profile_name, - domain_id = args$domain_id, domain_name = args$domain_name, - fields = fields, records = records, - id_position = id_position, id_col_name = id_col_name ->>>>>>> main ) } # reading from DBMS -<<<<<<< HEAD if ("credentials_file" %in% names(args_list)) { credentials <- read_credentials( args_list[["credentials_file"]], @@ -206,7 +95,7 @@ readepi <- function(credentials_file = NULL, fields = fields ) } else if (credentials[["dbms"]] %in% - c("MySQL", "SQLServer", "PostgreSQL")) { + c("MySQL", "SQLServer", "PostgreSQL")) { from <- NULL driver_name <- "" if ("from" %in% names(args_list)) { @@ -243,73 +132,6 @@ readepi <- function(credentials_file = NULL, records = records, fields = fields, id_col_name = id_col_name -======= - if (!is.null(credentials_file)) { - project_id <- ifelse("project_id" %in% names(args_list), - args_list$project_id, - stop("The project ID/database name must be provided - to read data from DBMS.")) - credentials <- read_credentials(credentials_file, project_id) - if (credentials$dbms == "REDCap") { - res <- read_from_redcap( - uri = credentials$host, token = credentials$pwd, - id_position = id_position, id_col_name = id_col_name, - records = records, fields = fields - ) - } else if (credentials$dbms %in% c("MySQL", "SQLServer", "PostgreSQL")) { - if ("source" %in% names(args_list)) { - source <- args_list$source - } else { - source <- NULL - } - if ("driver_name" %in% names(args_list)) { - driver_name <- args_list$driver_name - } else { - driver_name <- "" - } - res <- sql_server_read_data( - user = credentials$user, password = credentials$pwd, - host = credentials$host, port = credentials$port, - database_name = credentials$project, source = source, - driver_name = driver_name, records = records, fields = fields, - id_position = id_position, id_col_name = id_col_name, - dbms = credentials$dbms - ) - } else if (credentials$dbms %in% c("dhis2", "DHIS2")) { - if ("dataset" %in% names(args_list)) { - dataset <- args_list$dataset - } else { - dataset <- NULL - } - if ("organisation_unit" %in% names(args_list)) { - organisation_unit <- args_list$organisation_unit - } else { - organisation_unit <- NULL - } - if ("data_element_group" %in% names(args_list)) { - data_element_group <- args_list$data_element_group - } else { - data_element_group <- NULL - } - if ("start_date" %in% names(args_list)) { - start_date <- args_list$start_date - } else { - start_date <- NULL - } - if ("end_date" %in% names(args_list)) { - end_date <- args_list$end_date - } else { - end_date <- NULL - } - res <- read_from_dhis2( - base_url = credentials$host, user_name = credentials$user, - password = credentials$pwd, dataset = dataset, - organisation_unit = organisation_unit, - data_element_group = data_element_group, - start_date = start_date, end_date = end_date, - records = records, fields = fields, - id_col_name = id_col_name ->>>>>>> main ) } } diff --git a/R/readepi_helpers.R b/R/readepi_helpers.R index 58d6792e..e0b01be4 100644 --- a/R/readepi_helpers.R +++ b/R/readepi_helpers.R @@ -1,24 +1,15 @@ #' Read credentials from a configuration file #' #' @param file_path the path to the file with the user-specific credential -<<<<<<< HEAD #' details for the projects of interest. #' @param url the URL of the HIS of interest #' #' @returns a `list` of 5 elements of type `character` or `numeric`. These #' correspond to the user's credential details. -======= -#' details for the projects of interest. -#' @param project_id for relational DB, this is the name of the database -#' that contains the table from which the data should be pulled. Otherwise, -#' it is the project ID you were given access to. -#' @returns a list with the user credential details. ->>>>>>> main #' @examples #' \dontrun{ #' credentials <- read_credentials( #' file_path = system.file("extdata", "test.ini", package = "readepi"), -<<<<<<< HEAD #' url = "mysql-rfam-public.ebi.ac.uk" #' ) #' } @@ -29,8 +20,7 @@ read_credentials <- function( url = "mysql-rfam-public.ebi.ac.uk") { checkmate::assert_character(url, len = 1L, null.ok = FALSE, - any.missing = FALSE - ) + any.missing = FALSE) checkmate::assert_file(file_path) credentials <- read.table(file_path, sep = "\t", header = TRUE) @@ -38,41 +28,12 @@ read_credentials <- function( stop("credential file should be a tab-separated file with 7 columns.") } if (!all((names(credentials) %in% - c( - "user_name", "password", "host_name", "project_id", "comment", - "dbms", "port" - )))) { -======= -#' project_id = "Rfam" -#' ) -#' } -#' @export -read_credentials <- function(file_path = system.file("extdata", "test.ini", - package = "readepi"), - project_id = NULL) { - checkmate::assertCharacter(file_path, len = 1L, null.ok = FALSE) - checkmate::assert_file_exists(file_path) - checkmate::assertCharacter(project_id, len = 1L, null.ok = FALSE) - if (!file.exists(file_path) || is.null(file_path)) { - stop("Could not find ", file_path) - } - if (is.null(project_id)) { - stop("Database name or project ID not specified!") - } - - credentials <- data.table::fread(file_path, sep = "\t") - if (ncol(credentials) != 7) { - stop("credential file should be tab-separated file with 7 columns.") - } - if (!all((names(credentials) %in% - c("user_name", "password", "host_name", "project_id", "comment", - "dbms", "port")))) { ->>>>>>> main + c("user_name", "password", "host_name", "project_id", "comment", + "dbms", "port")))) { stop("Incorrect column names found in provided credentials file.\nThe column names should be 'user_name', 'password', 'host_name', 'project_id', 'comment', 'dbms', 'port'") } -<<<<<<< HEAD idx <- which(credentials[["host_name"]] == url) if (length(idx) == 0L) { stop("Credential details for ", url, " not found in @@ -88,29 +49,11 @@ read_credentials <- function(file_path = system.file("extdata", "test.ini", project = credentials[["project_id"]][idx], dbms = credentials[["dbms"]][idx], port = credentials[["port"]][idx] -======= - idx <- which(credentials$project_id == project_id) - if (length(idx) == 0) { - stop("Credential details for ", project_id, " not found in - credential file.") - } else if (length(idx) > 1) { - stop("Multiple credential lines found for the specified project ID.\n - Credentials file should contain one line per project.") - } else { - project_credentials <- list( - user = credentials$user_name[idx], - pwd = credentials$password[idx], - host = credentials$host_name[idx], - project = credentials$project_id[idx], - dbms = credentials$dbms[idx], - port = credentials$port[idx] ->>>>>>> main ) } project_credentials } -<<<<<<< HEAD #' Get arguments for reading from Fingertips #' #' @param args_list a `list` of user specified arguments @@ -132,134 +75,41 @@ get_read_fingertips_args <- function(args_list) { checkmate::assert_list(args_list) if ("indicator_id" %in% names(args_list)) { indicator_id <- args_list[["indicator_id"]] -======= -#' Get arguments for reading from files -#' -#' @param args_list a list of user specified arguments -#' -#' @return a list of the parameters to be used for reading from file -#' @examples -#' args_list <- get_read_file_args( -#' list( -#' sep = "\t", -#' format = ".txt", -#' which = NULL -#' ) -#' ) -#' -#' @export -get_read_file_args <- function(args_list) { - checkmate::assert_list(args_list) - if ("sep" %in% names(args_list)) { - sep <- args_list$sep - } else { - sep <- NULL - } - if ("format" %in% names(args_list)) { - format <- args_list$format - } else { - format <- NULL - } - if ("which" %in% names(args_list)) { - which <- args_list$which - } else { - which <- NULL - } - if ("pattern" %in% names(args_list)) { - pattern <- args_list$pattern - } else { - pattern <- NULL - } - - list( - sep = sep, - format = format, - which = which, - pattern = pattern - ) -} - -#' Get arguments for reading from Fingertips -#' -#' @param args_list a list of user specified arguments -#' -#' @return a list of the parameters to be used for reading from Fingertips -#' @examples -#' args_list <- get_read_fingertips_args( -#' list( -#' indicator_id = 90362, -#' area_type_id = 202 -#' ) -#' ) -#' @export -get_read_fingertips_args <- function(args_list) { - checkmate::assert_list(args_list) - if ("indicator_id" %in% names(args_list)) { - indicator_id <- args_list$indicator_id ->>>>>>> main } else { indicator_id <- NULL } if ("indicator_name" %in% names(args_list)) { -<<<<<<< HEAD indicator_name <- args_list[["indicator_name"]] -======= - indicator_name <- args_list$indicator_name ->>>>>>> main } else { indicator_name <- NULL } if ("area_type_id" %in% names(args_list)) { -<<<<<<< HEAD area_type_id <- args_list[["area_type_id"]] -======= - area_type_id <- args_list$area_type_id ->>>>>>> main } else { area_type_id <- NULL } if ("profile_id" %in% names(args_list)) { -<<<<<<< HEAD profile_id <- args_list[["profile_id"]] -======= - profile_id <- args_list$profile_id ->>>>>>> main } else { profile_id <- NULL } if ("profile_name" %in% names(args_list)) { -<<<<<<< HEAD profile_name <- args_list[["profile_name"]] -======= - profile_name <- args_list$profile_name ->>>>>>> main } else { profile_name <- NULL } if ("domain_id" %in% names(args_list)) { -<<<<<<< HEAD domain_id <- args_list[["domain_id"]] -======= - domain_id <- args_list$domain_id ->>>>>>> main } else { domain_id <- NULL } if ("domain_name" %in% names(args_list)) { -<<<<<<< HEAD domain_name <- args_list[["domain_name"]] -======= - domain_name <- args_list$domain_name ->>>>>>> main } else { domain_name <- NULL } if ("parent_area_type_id" %in% names(args_list)) { -<<<<<<< HEAD parent_area_type_id <- args_list[["parent_area_type_id"]] -======= - parent_area_type_id <- args_list$parent_area_type_id ->>>>>>> main } else { parent_area_type_id <- NULL } diff --git a/R/show_example_file.R b/R/show_example_file.R index 1e84e8b4..f1c3e908 100644 --- a/R/show_example_file.R +++ b/R/show_example_file.R @@ -1,22 +1,12 @@ #' Display the structure of the credentials file -<<<<<<< HEAD #' @examples #' \dontrun{ #' show_example_file() #' } #' @export #' -show_example_file <- function() { - example_data <- data.table::fread(system.file("extdata", "test.ini", - package = "readepi" - )) -======= -#' @export -#' @examples -#' show_example_file() show_example_file <- function() { example_data <- data.table::fread(system.file("extdata", "test.ini", package = "readepi")) ->>>>>>> main print(example_data) } diff --git a/R/show_tables.R b/R/show_tables.R index bc17cfc8..2f7ac3ec 100644 --- a/R/show_tables.R +++ b/R/show_tables.R @@ -1,5 +1,4 @@ #' Display the list of tables in a database -<<<<<<< HEAD #' #' @param data_source the URL of the HIS of interest #' @param credentials_file the path to the file with the user-specific @@ -31,88 +30,31 @@ show_tables <- function(data_source, credentials_file, driver_name) { credentials <- read_credentials(credentials_file, data_source) # establishing the connection to the server - con <- switch(credentials[["dbms"]], + con <- switch( + credentials[["dbms"]], "SQLServer" = DBI::dbConnect(odbc::odbc(), - driver = driver_name, - server = credentials[["host"]], + driver = driver_name, + server = credentials[["host"]], database = credentials[["project"]], # nolint: line_length_linter - uid = credentials[["user"]], - pwd = credentials[["pwd"]], - port = as.numeric(credentials[["port"]]) # nolint: line_length_linter - ), + uid = credentials[["user"]], + pwd = credentials[["pwd"]], + port = as.numeric(credentials[["port"]])), # nolint: line_length_linter "MySQL" = DBI::dbConnect(RMySQL::MySQL(), - driver = driver_name, - host = credentials[["host"]], - dbname = credentials[["project"]], - user = credentials[["user"]], + driver = driver_name, + host = credentials[["host"]], + dbname = credentials[["project"]], + user = credentials[["user"]], password = credentials[["pwd"]], - port = as.numeric(credentials[["port"]]) # nolint: line_length_linter - ), + port = as.numeric(credentials[["port"]])), # nolint: line_length_linter "PostgreSQL" = DBI::dbConnect(odbc::odbc(), - driver = driver_name, - host = credentials[["host"]], + driver = driver_name, + host = credentials[["host"]], database = credentials[["project"]], # nolint: line_length_linter - uid = credentials[["user"]], - pwd = credentials[["pwd"]], - port = as.numeric(credentials[["port"]]) # nolint: line_length_linter - ) -======= -#' @param credentials_file the path to the file with the user-specific -#' credential details for the projects of interest. See the help of -#' the `readepi` function for more details. -#' @param project_id the name of the target database -#' @param driver_name the name of the MS driver. use `odbc::odbcListDrivers()` -#' to display the list of installed drivers -#' @examples -#' \dontrun{ -#' show_tables( -#' credentials_file = system.file("extdata", "test.ini", package = "readepi"), -#' project_id = "Rfam", -#' driver_name = "" -#' ) -#' } -#' @returns the list of tables in the specified database -#' @export -#' -show_tables <- function(credentials_file, project_id, driver_name) { - # checking input parameters - checkmate::assert_character(credentials_file, null.ok = TRUE, len = 1) - checkmate::assert_file_exists(credentials_file) - checkmate::assert_character(project_id, null.ok = FALSE, len = 1) - checkmate::assert_character(driver_name, null.ok = FALSE, len = 1) - - # reading the credentials from the credential file - stopifnot(file.exists(credentials_file)) - credentials <- read_credentials(credentials_file, project_id) - - # establishing the connection to the server - con <- switch(credentials$dbms, - "SQLServer" = DBI::dbConnect(odbc::odbc(), - driver = driver_name, - server = credentials$host, database = credentials$project, - uid = credentials$user, pwd = credentials$pwd, - port = as.numeric(credentials$port) - ), - "MySQL" = DBI::dbConnect(RMySQL::MySQL(), - driver = driver_name, - host = credentials$host, dbname = credentials$project, - user = credentials$user, password = credentials$pwd, - port = as.numeric(credentials$port) - ), - "PostgreSQL" = DBI::dbConnect(odbc::odbc(), - driver = driver_name, - host = credentials$host, database = credentials$project, - uid = credentials$user, pwd = credentials$pwd, - port = as.numeric(credentials$port) - ) ->>>>>>> main - ) + uid = credentials[["user"]], + pwd = credentials[["pwd"]], + port = as.numeric(credentials[["port"]]))) # nolint: line_length_linter # listing the names of the tables present in the database tables <- DBI::dbListTables(conn = con) -<<<<<<< HEAD tables -======= - R.utils::cat(paste(tables, collapse = "\n")) ->>>>>>> main } diff --git a/README.Rmd b/README.Rmd index 4d6db997..d2d5dc1b 100644 --- a/README.Rmd +++ b/README.Rmd @@ -18,25 +18,11 @@ knitr::opts_chunk$set( ) ``` -<<<<<<< HEAD # readepi: Read data from health information systems [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![R-CMD-check](https://github.com/epiverse-trace/readepi/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/epiverse-trace/readepi/actions/workflows/R-CMD-check.yaml) [![Codecov test coverage](https://codecov.io/gh/epiverse-trace/readepi/branch/main/graph/badge.svg)](https://app.codecov.io/gh/epiverse-trace/readepi?branch=main) [![lifecycle-concept](https://raw.githubusercontent.com/reconverse/reconverse.github.io/master/images/badge-maturing.svg)](https://www.reconverse.org/lifecycle.html#concept) -======= -# readepi - -*readepi* provides functions for importing data into __R__ from files and -common _health information systems_. - - - -[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) -[![R-CMD-check](https://github.com/epiverse-trace/readepi/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/epiverse-trace/readepi/actions/workflows/R-CMD-check.yaml) -[![Codecov test coverage](https://codecov.io/gh/epiverse-trace/readepi/branch/main/graph/badge.svg)](https://app.codecov.io/gh/epiverse-trace/readepi?branch=main) -[![lifecycle-concept](https://raw.githubusercontent.com/reconverse/reconverse.github.io/master/images/badge-maturing.svg)](https://www.reconverse.org/lifecycle.html#concept) ->>>>>>> main **{readepi}** is an R package for reading data from several health information systems (HIS) including public repositories, relational database management systems (RDBMS). @@ -58,7 +44,8 @@ common _health information systems_. You can install the development version of **{readepi}** from [GitHub](https://github.com/) with: ```{r eval=FALSE} -<<<<<<< HEAD +# install.packages("devtools") +# devtools::install_github("epiverse-trace/readepi", build_vignettes = TRUE) if (!require("pak")) install.packages("pak") pak::pak("epiverse-trace/readepi") library(readepi) @@ -162,140 +149,4 @@ Contributions are welcome via [pull requests](https://github.com/{{ gh_repo }}/p Please note that the {{ packagename }} project is released with a [Contributor Code of Conduct](https://github.com/epiverse-trace/.github/blob/main/CODE_OF_CONDUCT.md). -======= -# install.packages("devtools") -# devtools::install_github("epiverse-trace/readepi@develop", build_vignettes = TRUE) -library(readepi) -``` - -## Importing data in R -The `readepi()` function allows importing data from several file types and database management systems. These include: - -* all file formats in the [rio](https://cran.r-project.org/web/packages/rio/vignettes/rio.html) package. -* file formats that are not accounted for by `rio` -* relational database management systems (RDBMS) such as **REDCap**, **MS SQL server**, **DHIS2** -* Fingertips (repository of public health indicators in England) - -The function returns an object of class list with one or more data frames. - -### Importing data from files -```{r eval=FALSE} -# READING DATA FROM JSON file -file <- system.file("extdata", "test.json", package = "readepi") -data <- readepi(file_path = file) - -# IMPORTING DATA FROM THE SECOND EXCEL SHEET -file <- system.file("extdata", "test.xlsx", package = "readepi") -data <- readepi(file_path = file, which = "Sheet2") - -# IMPORTING DATA FROM THE FIRST AND SECOND EXCEL SHEETS -file <- system.file("extdata", "test.xlsx", package = "readepi") -data <- readepi(file_path = file, which = c("Sheet2", "Sheet1")) -``` - -### Importing data from several files in a directory -```{r eval=FALSE} -# READING ALL FILES IN A GIVEN DIRECTORY -dir_path <- system.file("extdata", package = "readepi") -data <- readepi(file_path = dir_path) - -# READING ONLY '.txt' FILES -data <- readepi(file_path = dir_path, pattern = ".txt") - -# READING '.txt' and '.xlsx' FILES -data <- readepi(file_path = dir_path, pattern = c(".txt", ".xlsx")) -``` - -### Importing data from DBMS -To read data from DBMS, users can either provide the details of the tables of interest or an SQL query (see `vignette` for illustration). The current version of `readepi` allows for data import from: -1. MS SQL server, -2. MySQL server, -3. PostgreSQL server. - -This requires the users to: - -1. install the MS SQL driver that is compatible with your SQL server version. Details about this installation process can be found in the **vignette**. -2. create a credentials file where the user credential details will be stored. Use the `show_example_file()` to see a template of this file. - -Note that the examples in this section are based on a MySQL server that does not require the user to specify the `driver name`. But it is important to keep in mind that specify the driver name is a requirement for MS SQL server. - -```{r eval=FALSE} -# DISPLAY THE STRUCTURE OF THE CREDENTIALS FILE -show_example_file() - -# DEFINING THE CREDENTIALS FILE -credentials_file <- system.file("extdata", "test.ini", package = "readepi") - -# READING ALL FIELDS AND RECORDS FROM A REDCap PROJECT -data <- readepi( - credentials_file = credentials_file, - project_id = "SD_DATA" -) -project_data <- data$data -project_metadeta <- data$metadata - -# DISPLAY THE LIST OF ALL TABLES IN A DATABASE HOSTED IN A MySQL SERVER -# for the test MySQL server, the driver name does not need to be specified -show_tables( - credentials_file = credentials_file, - project_id = "Rfam", - driver_name = "" -) - -# VISUALIZE THE FIRST 5 ROWS OF THE TABLE 'author' -visualise_table( - credentials_file = credentials_file, - source = "author", # this is the table name - project_id = "Rfam", # this is the database name - driver_name = "" -) - -# READING ALL FIELDS AND ALL RECORDS FROM A DATABASE HOSTED BY A MS SQL SERVER -data <- readepi( - credentials_file = credentials_file, - project_id = "Rfam", # this is the database name - driver_name = "", - source = "author" -) - -# READING DATA FROM DHIS2 -data <- readepi( - credentials_file = credentials_file, - project_id = "DHIS2_DEMO", - dataset = "pBOMPrpg1QX", - organisation_unit = "DiszpKrYNg8", - data_element_group = NULL, - start_date = "2014", - end_date = "2023" -) - -# READING FROM FINFERTIPS -data <- readepi( - indicator_id = 90362, - area_type_id = 202, - parent_area_type_id = 6 # optional -) -``` - -## Vignette -The vignette of the **readepi** contains detailed illustrations about the use of each function. This can be accessed by typing the command below: -```{r eval=FALSE} -# OPEN THE VIGNETTE WITHIN RSTUDIO -vignette("readepi") - -# OPEN THE VIGNETTE IN YOUR WEB BROWSER. -browseVignettes("readepi") -``` - - -## Development - -### Contributions - -Contributions are welcome via [pull requests](https://github.com/epiverse-trace/readepi/pulls). - -### Code of Conduct -Please note that the readepi project is released with a -[Contributor Code of Conduct](https://contributor-covenant.org/version/2/0/CODE_OF_CONDUCT.html). ->>>>>>> main By contributing to this project, you agree to abide by its terms. diff --git a/README.md b/README.md index e92da2aa..b7100c43 100644 --- a/README.md +++ b/README.md @@ -5,14 +5,7 @@ -<<<<<<< HEAD # readepi: Read data from health information systems -======= -# readepi - -*readepi* provides functions for importing data into **R** from files -and common *health information systems*. ->>>>>>> main @@ -56,142 +49,11 @@ You can install the development version of **{readepi}** from [GitHub](https://github.com/) with: ``` r -<<<<<<< HEAD +# install.packages("devtools") +# devtools::install_github("epiverse-trace/readepi", build_vignettes = TRUE) if (!require("pak")) install.packages("pak") pak::pak("epiverse-trace/readepi") library(readepi) -======= -# install.packages("devtools") -# devtools::install_github("epiverse-trace/readepi@develop", build_vignettes = TRUE) -library(readepi) -``` - -## Importing data in R - -The `readepi()` function allows importing data from several file types -and database management systems. These include: - -- all file formats in the - [rio](https://cran.r-project.org/web/packages/rio/vignettes/rio.html) - package. -- file formats that are not accounted for by `rio` -- relational database management systems (RDBMS) such as **REDCap**, - **MS SQL server**, **DHIS2** -- Fingertips (repository of public health indicators in England) - -The function returns an object of class list with one or more data -frames. - -### Importing data from files - -``` r -# READING DATA FROM JSON file -file <- system.file("extdata", "test.json", package = "readepi") -data <- readepi(file_path = file) - -# IMPORTING DATA FROM THE SECOND EXCEL SHEET -file <- system.file("extdata", "test.xlsx", package = "readepi") -data <- readepi(file_path = file, which = "Sheet2") - -# IMPORTING DATA FROM THE FIRST AND SECOND EXCEL SHEETS -file <- system.file("extdata", "test.xlsx", package = "readepi") -data <- readepi(file_path = file, which = c("Sheet2", "Sheet1")) -``` - -### Importing data from several files in a directory - -``` r -# READING ALL FILES IN A GIVEN DIRECTORY -dir_path <- system.file("extdata", package = "readepi") -data <- readepi(file_path = dir_path) - -# READING ONLY '.txt' FILES -data <- readepi(file_path = dir_path, pattern = ".txt") - -# READING '.txt' and '.xlsx' FILES -data <- readepi(file_path = dir_path, pattern = c(".txt", ".xlsx")) -``` - -### Importing data from DBMS - -To read data from DBMS, users can either provide the details of the -tables of interest or an SQL query (see `vignette` for illustration). -The current version of `readepi` allows for data import from: -1. MS SQL server, -2. MySQL server, -3. PostgreSQL server. - -This requires the users to: - -1. install the MS SQL driver that is compatible with your SQL server - version. Details about this installation process can be found in the - **vignette**. -2. create a credentials file where the user credential details will be - stored. Use the `show_example_file()` to see a template of this - file. - -Note that the examples in this section are based on a MySQL server that -does not require the user to specify the `driver name`. But it is -important to keep in mind that specify the driver name is a requirement -for MS SQL server. - -``` r -# DISPLAY THE STRUCTURE OF THE CREDENTIALS FILE -show_example_file() - -# DEFINING THE CREDENTIALS FILE -credentials_file <- system.file("extdata", "test.ini", package = "readepi") - -# READING ALL FIELDS AND RECORDS FROM A REDCap PROJECT -data <- readepi( - credentials_file = credentials_file, - project_id = "SD_DATA" -) -project_data <- data$data -project_metadeta <- data$metadata - -# DISPLAY THE LIST OF ALL TABLES IN A DATABASE HOSTED IN A MySQL SERVER -# for the test MySQL server, the driver name does not need to be specified -show_tables( - credentials_file = credentials_file, - project_id = "Rfam", - driver_name = "" -) - -# VISUALIZE THE FIRST 5 ROWS OF THE TABLE 'author' -visualise_table( - credentials_file = credentials_file, - source = "author", # this is the table name - project_id = "Rfam", # this is the database name - driver_name = "" -) - -# READING ALL FIELDS AND ALL RECORDS FROM A DATABASE HOSTED BY A MS SQL SERVER -data <- readepi( - credentials_file = credentials_file, - project_id = "Rfam", # this is the database name - driver_name = "", - source = "author" -) - -# READING DATA FROM DHIS2 -data <- readepi( - credentials_file = credentials_file, - project_id = "DHIS2_DEMO", - dataset = "pBOMPrpg1QX", - organisation_unit = "DiszpKrYNg8", - data_element_group = NULL, - start_date = "2014", - end_date = "2023" -) - -# READING FROM FINFERTIPS -data <- readepi( - indicator_id = 90362, - area_type_id = 202, - parent_area_type_id = 6 # optional -) ->>>>>>> main ``` ## Quick start @@ -221,12 +83,7 @@ Users can read data from a RDBMS by providing the details of the tables of interest or an SQL query (for more information, see the **vignette**). -The vignette of the **readepi** contains detailed illustrations about -the use of each function. This can be accessed by typing the command -below: - ``` r -<<<<<<< HEAD # DISPLAY THE STRUCTUTRE OF THE TEMPLATE CREDENTIAL FILE show_example_file() @@ -294,18 +151,11 @@ every argument. This can be accessed by typing the command below: vignette("readepi") # OPEN THE VIGNETTE IN YOUR WEB BROWSER. -======= -# OPEN THE VIGNETTE WITHIN RSTUDIO -vignette("readepi") - -# OPEN THE VIGNETTE IN YOUR WEB BROWSER. ->>>>>>> main browseVignettes("readepi") ``` ## Development -<<<<<<< HEAD ### Lifecycle This package is currently a *maturing*, as defined by the [RECON @@ -323,16 +173,4 @@ requests](https://github.com/%7B%7B%20gh_repo%20%7D%7D/pulls). Please note that the {{ packagename }} project is released with a [Contributor Code of Conduct](https://github.com/epiverse-trace/.github/blob/main/CODE_OF_CONDUCT.md). -======= -### Contributions - -Contributions are welcome via [pull -requests](https://github.com/epiverse-trace/readepi/pulls). - -### Code of Conduct - -Please note that the readepi project is released with a [Contributor -Code of -Conduct](https://contributor-covenant.org/version/2/0/CODE_OF_CONDUCT.html). ->>>>>>> main By contributing to this project, you agree to abide by its terms. diff --git a/inst/.DS_Store b/inst/.DS_Store deleted file mode 100644 index 4771a3dbd6f6eaffb204f49278884c28e7800049..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8196 zcmeHMO>7la6h7ayr87gJw-rip^60Y#gOx%>5amZ+e<-4b7E0+4N_np{(vj)B@@C#E z;7__DCSo*EiScKt1{W+;j3zGp3B-jPNd3jQ(S>p0%7l#z&z(CE+R~MY8kw8id*0jLdtqUsUzpju}(S? z1QG-i1QG-i1QG=P3kdL?EsH+Sy{|@-HbEdk;Fd%{ejn0YrOd=~O3CQc!A+C`uq@~9 zsPHrA0g+ESmYG;iDH*x)oGN=j?20(WfO6;Yv@~a#iRF}%%AKIx3GvE^GZaLtvtK$g zCuEdN+5~|Ffw>6C+`W<b1<|aHh2wPjfgH~2vv7k~n%!Ss#pgBC~ zj^_P7_oOo-s)MooHhgrK!d{?{3|=d3)!s z-Fv4OEv^=3t+`~ND*niaZm5sID+@K5F==ZWY$5XRyG9S>zBgQ~U z?Ob(kH6PS#u*Mi1&5w`segf6qW_9S|GyRZUyE_|%Jrj-}FK=~O59#7deK;7)7Mz|* z-zg}cE~{JDqm$!)>9oUk!+arvWKV--4av#cY}>JU=k;~Vgw<#D>*6x|2-h#UAs-bV zKZ|0ZH)WdDxy*pZSTc)j@(aJ58fgP-q)+G~U82kMHGM-@ z=ok8p{-8fmflBBwP>TlKfkrf84O*}ko6&(zbYUmD(T@Wd#1IbQ2*&UPj^Y?j;z>M> zXK)HH;6=QIm+>av#ydERckwYk#}~MOi@1aza0Nf&cU;w=Xj5-i?foNIc_=BN9i!G@E@Yw9HgLv)nm8UxbND$!C39S~sN4l&Ii1Q0mH6 ztS;afQ0iUHsg%&fd8VT@Ub`-3iZTu?V|w|r`Z}}O+-MjA(b%T@O;eO}h#8T(bsMWB zqh9H4?L3nV82#@P_bk0fAJM1u6%+R-`k8*Es~{{u73#18X(sDRtYWgZVmL97Z-Gt_L5JIKkw7is^d_&*C|p#`8FXSMeHN#~Tri-^T~D zX!-C=TH?Z7T9*0>zL)op@W?eX&vZ((TMPkt_j9S2`TvgjfB%n+k|seQLE!(10LnZ2 zI@@_~^W6(F*G_Xi%vBa?H>G6c!i_YM{ZTs3^7_kVPL L5%@`S%Oda>+Y-J( diff --git a/inst/extdata/.DS_Store b/inst/extdata/.DS_Store deleted file mode 100644 index 3e45dd9ed8eb9ec7efcbaf98364865e6f7c9665d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8196 zcmeHMTWl3Y82-O)p}R|gp+afhoc7p)!OEo|7e$cM3q_<@pcGnA%IVp)UD@s_XZM@} zUeYI`#zc()FRxyCA!-8g!9+C15W|b4pvJ@(eNZ2bi7#mUXJ<<&P=Yb>5_XcAe`n_Z z=km?>@8sVlBD5Cmac##B z-N#&~V9dc{W2c`TcE&~Z{F>U^E$eFSiBWos1Mb118y*&ox;`#u&7N6TZ<>$Tyuht_ zTaIRnQ-%@EZq-{0b$zewYb!Wh+GB4S+y)Nml+~3b{=qjrDLrySL(tx zdc5p_(CDnUtUftZi)}kLZ@Q*>zOc4i-MTo> zHp2BwZpf#^C(oi7=#7~sbtIEeG3H)DGx;d5gj#B#m9&nwQ6GO)8l~sy7#*j#=p>z{ zkLYvylFriwx=7#B5A-wrN|!JV70_Xz3iY@H4QRw-EWuK&MH|}DflcT{4|bs!eb|RV z4B>Gcz(E|r6L<eq>W}xydGu6X1cMeVEVxmI2qdqRR>(gdR zOk+n-)ddT=I-Q+BRqtv_rGzFIm0<`(eQWMDO;OH1 zW<=F>7FQ{*WLkI_=`s4>=k5vmfIg%%bdI_E9eqzf(r+M4M4LO~R));^uI^ywBxTJz^Xazm* zSlhr~WPtbXm}XRloonu2M%T1l%*W}h%&SJ|8?5s(Nv4Z(3hU_e{_*4W{q1z~`gxgc z=}}#66VY9|EEZ)kM-=!%X&*TiRN)J~?a8b$+sx$Y<>6T~X<2+n-fz(pX~X|VWC+g0 z7%&Emft@kHCn6*|613JBFb0f)H3NJ;cqn76SPO=u15GFafI|!iL7!_0_VJ3bVl9Xn zh!aH{oVa7$t6i*E3yM2AEk2yS*=dF1!rQUF59Z`zL2HcxW1!8zo;;5D{y+P@ z{%14506 -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNAGATCT -GTTCTCTAAACGAACTTTAAAATCTGTGTGGCTGTCACTCGGCTGCATGCTTAGTGCACT -CACGCAGTATAATTAATAACTAATTACTGTCGTTGACAGGACACGAGTAACTCGTCTATC -TTCTGCAGGCTGCTTACGGTTTCGTCCGTGTTGCAGCCGATCATCAGCACATCTAGGTTT -TGTCCGGGTGTGACCGAAAGGTAAGATGGAGAGCCTTGTCCCTGGTTTCAACGAGAAAAC -ACACGTCCAACTCAGTTTGCCTGTTTTACAGGTTCGCGACGTGCTCGTACGTGGCTTTGG -AGACTCCGTGGAGGAGGTCTTATCAGAGGCACGTCAACATCTTAAAGATGGCACTTGTGG -CTTAGTAGAAGTTGAAAAAGGCGTTTTGCCTCAACTTGAACAGCCCTATGTGTTCATCAA -ACGTTCGGATGCTCGAACTGCACCTCATGGTCATGTTATGGTTGAGCTGGTAGCAGAACT -CGAAGGCATTCAGTACGGTCGTAGTGGTGAGACACTTGGTGTCCTTGTCCCTCATGTGGG -CGAAATACCAGTGGCTTACCGCAAGGTTCTTCTTCGTAAGAACGGTAATAAAGGAGCTGG -TGGCCATAGTTACGGCGCCGATCTAAAGTCATTTGACTTAGGCGACGAGCTTGGCACTGA -TCCTTATGAAGATTTTCAAGAAAACTGGAACACTAAACATAGCAGTGGTGTTACCCGTGA -ACTCATGCGTGAGCTTAACGGAGGGGCATACACTCGCTATGTCGATAACAACTTCTGTGG -CCCTGATGGCTACCCTCTTGAGTGCATTAAAGACCTTCTAGCACGTGCTGGTAAAGCTTC -ATGCACTTTGTCTGAACAACTGGACTTTATTGACACTAAGAGGGGTGTATACTGCTGCCG -TGAACATGAGCATGAAATTGCTTGGTACACGGAACGTTCTGAAAAGAGCTATGAATTGCA -GACACCTTTTGAAATTAAATTGGCAAAGAAATTTGACACCTTCAATGGGGAATGTCCAAA -TTTTGTATTTCCCTTAAATTCCATAATCAAGACTATTCAACCAAGGGTTGAAAAGAAAAA -GCTTGATGGCTTTATGGGTAGAATTCGATCTGTCTATCCAGTTGCGTCACCAAATGAATG -CAACCAAATGTGCCTTTCAACTCTCATGAAGTGTGATCATTGTGGTGAAACTTCATGGCA -GACGGGCGATTTTGTTAAAGCCACTTGCGAATTTTGTGGCACTGAGAATTTGACTAAAGA -AGGTGCCACTACTTGTGGTTACTTACCCCAAAATGCTGTTGTTAAAATTTATTGTCCAGC -ATGTCACAATTCAGAAGTAGGACCTGAGCATAGTCTTGCCGAATACCATAATGAATCTGG -CTTGAAAACCATTCTTCGTAAGGGTGGTCGCACTATTGCCTTTGGAGGCTGTGTGTTCTC -TTATGTTGGTTGCCATAACAAGTGTGCCTATTGGGTTCCACGTGCTAGCGCTAACATAGG -TTGTAACCATACAGGTGTTGTTGGAGAAGGTTCCGAAGGTCTTAATGACAACCTTCTTGA -AATACTCCAAAAAGAGAAAGTCAACATCAATATTGTTGGTGACTTTAAACTTAATGAAGA -GATCGCCATTATTTTGGCATCTTTTTCTGCTTCCACAAGTGCTTTTGTGGAAACTGTGAA -AGGTTTGGATTATAAAGCATTCAAACAAATTGTTGAATCCTGTGGTAATTTTAAAGTTAC -AAAAGGAAAAGCTAAAAAAGGTGCCTGGAATATTGGTGAACAGAAATCAATACTGAGTCC -TCTTTATGCATTTGCATCAGAGGCTGCTCGTGTTGTACGATCAATTTTCTCCCGCACTCT -TGAAACTGCTCAAAATTCTGTGCGTGTTTTACAGAAGGCCGCTATAACAATACTAGATGG -AATTTCACAGTATTCACTGAGACTCATTGATGCTATGATGTTCACATCTGATTTGGCTAC -TAACAATCTAGTTGTAATGGCCTACATTACAGGTGGTGTTGTTCAGTTGACTTTGCAGTG -GCTAACTAACATCTTTGGCACTGTTTATGAAAAACTCAAACCCGTCCTTGATTGGCTTGA -AGAGAAGTTTAAGGAAGGTGTAGAGTTTCTTAGAGACGGTTGGGAAATTGTTAAATTTAT -CTCAACCTGTGCTTGTGAAATTGTCGGTGGACAAATTGTCACCTGTGCAAAGGAAATTAA -GGAGAGTGTTCAGACATTCTTTAAGCTTGTAAATAAATTTTTGGCTTTGTGTGCTGACTC -TATCATTATTGGTGGAGCTAAACTTAAAGCCTTGAATTTAGGTGAAACATTTGTCACGCA -CTCAAAGGGATTGTACAGAAAGTGTGTTAAATCCAGAGAAGAAACTGGCCTACTCATGCC -TCTAAAAGCCCCAAAAGAAATTATCTTCTTAGAGGGAGAAACACTTCCCACAGAAGTGTT -AACAGAGGAAGTTGTCTTGAAAACTGGTGATTTACAACCATTAGAACAACCTACTAGTGA -AGCTGTTGAAGCTCCATTGGTTGGTACACCAGTTTGTATTAACGGGCTTATGTTGCTCGA -AATCAAAGACACAGAAAAGTACTGTGCCCTTGCACCTAATATGATGGTAACAAACAATAC -CTTCACACTCAAAGGCGGTGCACCAACAAAGGTTACTTTTGGTGATGACACTGTGATAGA -AGTGCAAGGTTACAAGAGTGTGAATATCACTTTTGAACTTGATGAAAGGATTGATAAAGT -ACTTAATGAGAAGTGCTCTGCCTATACAGTTGAACTCGGTACAGAAGTAAATGAGTTCGC -CTGTGTTGTGGCAGATGCTGTCATAAAAACTTTGCAACCAGTATCTGAATTACTTACACC -ACTGGGCATTGATTTAGATGAGTGGAGTATGGCTACATACTACTTATTTGATGAGTCTGG -TGAGTTTAAATTGGCTTCACATATGTATTGTTCTTTTTACCCTCCAGATGAGGATGAAGA -AGAAGGTGATTGTGAAGAAGAAGAGTTTGAGCCATCAACGCAATATGAGTATGGTACTGA -AGATGATTACCAAGGTAAACCTTTGGAATTTGGTGCCACTTCTGCTGCTCTTCAACCTGA -AGAAGAGCAAGAAGAAGATTGGTTAGATGATGATAGTCAACAAACTGTTGGTCAACAAGA -CGGCAGTGAGGACAATCAGACAACTATTATTCAAACAATTGTTGAGGTTCAACCTCAATT -AGAGATGGAACTTACACCAGTTGTTCAGACTATTGAAGTGAATAGTTTTAGTGGTTATTT -AAAACTTACTGACAATGTATACATTAAAAATGCAGACATTGTGGAAGAAGCTAAAAAGGT -AAAACCAACAGTGGTTGTTAATGCAGCCAATGTTTACCTTAAACATGGAGGAGGTGTTGC -AGGAGCCTTAAATAAGGCTACTAACAATGCCATGCAAGTTGAATCTGATGATTACATAGC -TACTAATGGACCACTTAAAGTGGGTGGTAGTTGTGTTTTAAGCGGACACAATCTTGCTAA -ACACTGTCTTCATGTTGTCGGCCCAAATGTTAACAAAGGTGAAGACATTCAACTTCTTAA -GAGTGCTTATGAAAATTTTAATCAGCACGAAGTTCTACTTGCACCATTATTATCAGCTGG -TATTTTTGGTGCTGACCCTATACATTCTTTAAGAGTTTGTGTAGATACTGTTCGCACAAA -TGTCTACTTAGCTGTCTTTGATAAAAATCTCTATGACAAACTTGTTTCAAGCTTTTTGGA -AATGAAGAGTGAAAAGCAAGTTGAACAAAAGATCGCTGAGATTCCTAAAGAGGAAGTTAA -GCCATTTATAACTGAAAGTAAACCTTCAGTTGAACAGAGAAAACAAGATGATAAGAAAAT -CAAAGCTTGTGTTGAAGAAGTTACAACAACTCTGGAAGAAACTAAGTTCCTCACAGAAAA -CTTGTTACTTTATATTGACATTAATGGCAATCTTCATCCAGATTCTGCCACTCTTGTTAG -TGACATTGACATCACTTTCTTAAAGAAAGATGCTCCATATATAGTGGGTGATGTTGTTCA -AGAGGGTGTTTTAACTGCTGTGGTTATACCTACTAAAAAGGCTGGTGGCACTACTGAAAT -GCTAGCGAAAGCTTTGAGAAAAGTGCCAACAGACAATTATATAACCACTTACCCGGGTCA -GGGTTTAAATGGTTACACTGTAGAGGAGGCAAAGACAGTGCTTAAAAAGTGTAAAAGTGC -CTTTTACATTCTACCATCTATTATCTCTAATGAGAAGCAAGAAATTCTTGGAACTGTTTC -TTGGAATTTGCGAGAAATGCTTGCACATGCAGAAGAAACACGCAAATTAATGCCTGTCTG -TGTGGAAACTAAAGCCATAGTTTCAACTATACAGCGTAAATATAAGGGTATTAAAATACA -AGAGGGTGTGGTTGATTATGGTGCTAGATTTTACTTTTACACCAGTAAAACAACTGTAGC -GTCACTTATCAACACACTTAACGATCTAAATGAAACTCTTGTTACAATGCCACTTGGCTA -TGTAACACATGGCTTAAATTTGGAAGAAGCTGCTCGGTATATGAGATCTCTCAAAGTGCC -AGCTACAGTTTCTGTTTCTTCACCTGATGCTGTTACAGCGTATAATGGTTATCTTACTTC -TTCTTCTAAAACACCTGAAGAACATTTTATTGAAACCATCTCACTTGCTGGTTCCTATAA -AGATTGGTCCTATTCTGGACAATCTACACAACTAGGTATAGAATTTCTTAAGAGAGGTGA -TAAAAGTGTATATTACACTAGTAATCCTACCACATTCCACCTAGATGGTGAAGTTATCAC -CTTTGACAATCTTAAGACACTTCTTTCTTTGAGAGAAGTGAGGACTATTAAGGTGTTTAC -AACAGTAGACAACATTAACCTCCACACGCAAGTTGTGGACATGTCAATGACATATGGACA -ACAGTTTGGTCCAACTTATTTGGATGGAGCTGATGTTACTAAAATAAAACCTCATAATTC -ACATGAAGGTAAAACATTTTATGTTTTACCTAATGATGACACTCTACGTGTTGAGGCTTT -TGAGTACTACCACACAACTGATCCTAGTTTTCTGGGTAGGTACATGTCAGCATTAAATCA -CACTAAAAAGTGGAAATACCCACAAGTTAATGGTTTAACTTCTATTAAATGGGCAGATAA -CAACTGTTATCTTGCCACTGCATTGTTAACACTCCAACAAATAGAGTTGAAGTTTAATCC -ACCTGCTCTACAAGATGCTTATTACAGAGCAAGGGCTGGTGAAGCTGATAACTTTTGTGC -ACTTATCTTAGCCTACTGTAATAAGACAGTAGGTGAGTTAGGTGATGTTAGAGAAACAAT -GAGTTACTTGTTTCAACATGCCAATTTAGATTCTTGCAAAAGAGTCTTGAACGTGGTGTG -TAAAACTTGTGGACAACAGCAGACAACCCTTAAGGGTGTAGAAGCTGTTATGTACATGGG -CACACTTTCTTATGAACAATTTAAGAAAGGTGTTCAGATACCTTGTACGTGTGGTAAACA -AGCTACAAAATATCTAGTACAACAGGAGTCACCTTTTGTTATGATGTCAGCACCACCTGC -TCAGTATGAACTTAAGCATGGTACATTTACTTGTGCTAGTGAGTACACTGGTAATTACCA -GTGTGGTCACTATAAACATATAACTTCTAAAGAAACTTTGTATTGCATAGACGGTGCTTT -ACTTACAAAGTCCTCAGAATACAAAGGTCCTATTACGGATGTTTTCTACAAAGAAAACAG -TTACACAACAACCATAAAACCAGTTACTTATAAATTGGATGGTGTTGTTTGTACAGAAAT -TGACCCTAAGTTGGACAATTATTATAAGAAAGACAATTCTTATTTTACAGAGCAACCAAT -TGATCTTGTACCAAACCAACCATATCCAAACGCAAGCTTCGATAATTTTAAGTTTGTATG -TGATAATATCAAATTTGCTGATGATTTAAACCAGTTAACTGGTTATAAGAAACCTGCTTC -AAGAGAGCTTAAAGTTACATTTTTCCCTGACTTAAATGGTGATGTGGTGGCTATTGATTA -TAAACACTACACACCCTCTTTTAAGAAAGGAGCTAAATTGTTACATAAACCTATTGTTTG -GCATGTTAACAATGCAACTAATAAAGCCACGTATAAACCAAATACCTGGTGTATACGTTG -TCTTTGGAGCACAAAACCAGTTGAAACATCAAATTCGTTTGATGTACTGAAGTCAGAGGA -CGCGCAGGGAATGGATAATCTTGCCTGCGAAGATCTAAAACCAGTCTCTGAAGAAGTAGT -GGAAAATCCTACCATACAGAAAGACGTTCTTGAGTGTAATGTGAAAACTACCGAAGTTGT -AGGAGACATTATACTTAAACCAGCAAATAATAGTTTAAAAATTACAGAAGAGGTTGGCCA -CACAGATCTAATGGCTGCTTATGTAGACAATTCTAGTCTTACTATTAAGAAACCTAATGA -ATTATCTAGAGTATTAGGTTTGAAAACCCTTGCTACTCATGGTTTAGCTGCTGTTAATAG -TGTCCCTTGGGATACTATAGCTAATTATGCTAAGCCTTTTCTTAACAAAGTTGTTAGTAC -AACTACTAACATAGTTACACGGTGTTTAAACCGTGTTTGTACTAATTATATGCCTTATTT -CTTTACTTTATTGCTACAATTGTGTACTTTTACTAGAAGTACAAATTCTAGAATTAAAGC -ATCTATGCCGACTACTATAGCAAAGAATACTGTTAAGAGTGTCGGTAAATTTTGTCTAGA -GGCTTCATTTAATTATTTGAAGTCACCTAATTTTTCTAAACTGATAAATATTACAATTTG -GTTTTTACTATTAAGTGTTTGCCTAGGTTCTTTAATCTACTCAACCGCTGCTTTAGGTGT -TTTAATGTCTAATTTAGGCATGCCTTCTTACTGTACTGGTTACAGAGAAGGCTATTTGAA -CTCTACTAATGTCACTATTGCAACCTACTGTACTGGTTCTATACCTTGTAGTGTTTGTCT -TAGTGGTTTAGATTCTTTAGACACCTATCCTTCTTTAGAAACTATACAAATTACCATTTC -ATCTTTTAAATGGGATTTAACTGCTTTTGGCTTAGTTGCAGAGTGGTTTTTGGCATATAT -TCTTTTCACTAGGTTTTTCTATGTACTTGGATTGGCTGCAATCATGCAATTGTTTTTCAG -CTATTTTGCAGTACATTTTATTAGTAATTCTTGGCTTATGTGGTTAATAATTAATCTTGT -ACAAATGGCCCCGATTTCAGCTATGGTTAGAATGTACATCTTCTTTGCATCATTTTATTA -TGTATGGAAAAGTTATGTGCATGTTGTAGACGGTTGTAATTCATCAACTTGTATGATGTG -TTACAAACGTAATAGAGCAACAAGAGTCGAATGTACAACTATTGTTAATGGTGTTAGAAG -GTCCTTTTATGTCTATGCTAATGGAGGTAAAGGCTTTTGCAAACTACACAATTGGAATTG -TGTTAATTGTGATACATTCTGTGCTGGTAGTACATTTATTAGTGATGAAGTTGCGAGAGA -CTTGTCACTACAGTTTAAAAGACCAATAAATCCTACTGACCAGTCTTCTTACATCGTTGA -TAGTGTTACAGTGAAGAATGGTTCCATCCATCTTTACTTTGATAAAGCTGGTCAAAAGAC -TTATGAAAGACATTCTCTCTCTCATTTTGTTAACTTAGACAACCTGAGAGCTAATAACAC -TAAAGGTTCATTGCCTATTAATGTTATAGTTTTTGATGGTAAATCAAAATGTGAAGAATC -ATCTGCAAAATCAGCGTCTGTTTACTACAGTCAGCTTATGTGTCAACCTATACTGTTACT -AGATCAGGCATTAGTGTCTGATGTTGGTGATAGTGCGGAAGTTGCAGTTAAAATGTTTGA -TGCTTACGTTAATACGTTTTCATCAACTTTTAACGTACCAATGGAAAAACTCAAAACACT -AGTTGCAACTGCAGAAGCTGAACTTGCAAAGAATGTGTCCTTAGACAATGTCTTATCTAC -TTTTATTTCAGCAGCTCGGCAAGGGTTTGTTGATTCAGATGTAGAAACTAAAGATGTTGT -TGAATGTCTTAAATTGTCACATCAATCTGACATAGAAGTTACTGGCGATAGTTGTAATAA -CTATATGCTCACCTATAACAAAGTTGAAAACATGACACCCCGTGACCTTGGTGCTTGTAT -TGACTGTAGTGCGCGTCATATTAATGCGCAGGTAGCAAAAAGTCACAACATTGCTTTGAT -ATGGAACGTTAAAGATTTCATGTCATTGTCTGAACAACTACGAAAACAAATACGTAGTGC -TGCTAAAAAGAATAACTTACCTTTTAAGTTGACATGTGCAACTACTAGACAAGTTGTTAA -TGTTGTAACAACAAAGATAGCACTTAAGGGTGGTAAAATTGTTAATAATTGGTTGAAGCA -GTTAATTAAAGTTACACTTGTGTTCCTTTTTGTTGCTGCTATTTTCTATTTAATAACACC -TGTTCATGTCATGTCTAAACATACTGACTTTTCAAGTGAAATCATAGGATACAAGGCTAT -TGATGGTGGTGTCACTCGTGACATAGCATCTACAGATACTTGTTTTGCTAACAAACATGC -TGATTTTGACACATGGTTTAGCCAGCGTGGTGGTAGTTATACTAATGACAAAGCTTGCCC -ATTGATTGCTGCAGTCATAACAAGAGAAGTGGGTTTTGTCGTGCCTGGTTTGCCTGGCAC -GATATTACGCACAACTAATGGTGACTTTTTGCATTTCTTACCTAGAGTTTTTAGTGCAGT -TGGTAACATCTGTTACACACCATCAAAACTTATAGAGTACACTGACTTTGCAACATCAGC -TTGTGTTTTGGCTGCTGAATGTACAATTTTTAAAGATGCTTCTGGTAAGCCAGTACCATA -TTGTTATGATACCAATGTACTAGAAGGTTCTGTTGCTTATGAAAGTTTACGCCCTGACAC -ACGTTATGTGCTCATGGATGGCTCTATTATTCAATTTCCTAACACCTACCTTGAAGGTTC -TGTTAGAGTGGTAACAACTTTTGATTCTGAGTACTGTAGGCACGGCACTTGTGAAAGATC -AGAAGCTGGTGTTTGTGTATCTACTAGTGGTAGATGGGTACTTAACAATGATTATTACAG -ATCTTTACCAGGAGTTTTCTGTGGTGTAGATGCTGTAAATTTACTTACTAATATGTTTAC -ACCACTAATTCAACCTATTGGTGCTTTGGACATATCAGCATCTATAGTAGCTGGTGGTAT -TGTAGCTATCGTAGTAACATGCCTTGCCTACTATTTTATGAGGTTTAGAAGAGCTTTTGG -TGAATACAGTCATGTAGTTGCCTTTAATACTTTACTATTCCTTATGTCATTCACTGTACT -CTGTTTAACACCAGTTTACTCATTCTTACCTGGTGTTTATTCTGTTATTTACTTGTACTT -GACATTTTATCTTACTAATGATGTTTCTTTTTTAGCACATATTCAGTGGATGGTTATGTT -CACACCTTTAGTACCTTTCTGGATAACAATTGCTTATATCATTTGTATTTCCACAAAGCA -TTTCTATTGGTTCTTTAGTAATTACCTAAAGAGACGTGTAGTCTTTAATGGTGTTTCCTT -TAGTACTTTTGAAGAAGCTGCGCTGTGCACCTTTTTGTTAAATAAAGAAATGTATCTAAA -GTTGCGTAGTGATGTGCTATTACCTCTTACGCAATATAATAGATACTTAGCTCTTTATAA -TAAGTACAAGTATTTTAGTGGAGCAATGGATACAACTAGCTACAGAGAAGCTGCTTGTTG -TCATCTCGCAAAGGCTCTCAATGACTTCAGTAACTCAGGTTCTGATGTTCTTTACCAACC -ACCACAAACCTCTATCACCTCAGCTGTTTTGCAGAGTGGTTTTAGAAAAATGGCATTCCC -ATCTGGTAAAGTTGAGGGTTGTATGGTACAAGTAACTTGTGGTACAACTACACTTAACGG -TCTTTGGCTTGATGACGTAGTTTACTGTCCAAGACATGTGATCTGCACCTCTGAAGACAT -GCTTAACCCTAATTATGAAGATTTACTCATTCGTAAGTCTAATCATAATTTCTTGGTACA -GGCTGGTAATGTTCAACTCAGGGTTATTGGACATTCTATGCAAAATTGTGTACTTAAGCT -TAAGGTTGATACAGCCAATCCTAAGACACCTAAGTATAAGTTTGTTCGCATTCAACCAGG -ACAGACTTTTTCAGTGTTAGCTTGTTACAATGGTTCACCATCTGGTGTTTACCAATGTGC -TATGAGGCCCAATTTCACTATTAAGGGTTCATTCCTTAATGGTTCATGTGGTAGTGTTGG -TTTTAACATAGATTATGACTGTGTCTCTTTTTGTTACATGCACCATATGGAATTACCAAC -TGGAGTTCATGCTGGCACAGACTTAGAAGGTAACTTTTATGGACCTTTTGTTGACAGGCA -AACAGCACAAGCAGCTGGTACGGACACAACTATTACAGTTAATGTTTTAGCTTGGTTGTA -CGCTGCTGTTATAAATGGAGACAGGTGGTTTCTCAATCGATTTACCACAACTCTTAATGA -CTTTAACCTTGTGGCTATGAAGTACAATTATGAACCTCTAACACAAGACCATGTTGACAT -ACTAGGACCTCTTTCTGCTCAAACTGGAATTGCCGTTTTAGATATGTGTGCTTCATTAAA -AGAATTACTGCAAAATGGTATGAATGGACGTACCATATTGGGTAGTGCTTTATTAGAAGA -TGAATTTACACCTTTTGATGTTGTTAGACAATGCTCAGGTGTTACTTTCCAAAGTGCAGT -GAAAAGAACAATCAAGGGTACACACCACTGGTTGTTACTCACAATTTTGACTTCACTTTT -AGTTTTAGTCCAGAGTACTCAATGGTCTTTGTTCTTTTTTTTGTATGAAAATGCCTTTTT -ACCTTTTGCTATGGGTATTATTGCTATGTCTGCTTTTGCAATGATGTTTGTCAAACATAA -GCATGCATTTCTCTGTTTGTTTTTGTTACCTTCTCTTGCCACTGTAGCTTATTTTAATAT -GGTCTATATGCCTGCTAGTTGGGTGATGCGTATTATGACATGGTTGGATATGGTTGATAC -TAGTTTGAAGCTAAAAGACTGTGTTATGTATGCATCAGCTGTAGTGTTACTAATCCTTAT -GACAGCAAGAACTGTGTATGATGATGGTGCTAGGAGAGTGTGGACACTTATGAATGTCTT -GACACTCGTTTATAAAGTTTATTATGGTAATGCTTTAGATCAAGCCATTTCCATGTGGGC -TCTTATAATCTCTGTTACTTCTAACTACTCAGGTGTAGTTACAACTGTCATGTTTTTGGC -CAGAGGTATTGTTTTTATGTGTGTTGAGTATTGCCCTATTTTCTTCATAACTGGTAATAC -ACTTCAGTGTATAATGCTAGTTTATTGTTTCTTAGGCTATTTTTGTACTTGTTACTTTGG -CCTCTTTTGTTTACTCAACCGCTACTTTAGACTGACTCTTGGTGTTTATGATTACTTAGT -TTCTACACAGGAGTTTAGATATATGAATTCACAGGGACTACTCCCACCCAAGAATAGCAT -AGATGCCTTCAAACTCAACATTAAATTGTTGGGTGTTGGTGGCAAACCTTGTATCAAAGT -AGCCACTGTACAGTCTAAAATGTCAGATGTAAAGTGCACATCAGTAGTCTTACTCTCAGT -TTTGCAACAACTCAGAGTAGAATCATCATCTAAATTGTGGGCTCAATGTGTCCAGTTACA -CAATGACATTCTCTTAGCTAAAGATACTACTGAAGCCTTTGAAAAAATGGTTTCACTACT -TTCTGTTTTGCTTTCCATGCAGGGTGCTGTAGACATAAACAAGCTTTGTGAAGAAATGCT -GGACAACAGGGCAACCTTACAAGCTATAGCCTCAGAGTTTAGTTCCCTTCCATCATATGC -AGCTTTTGCTACTGCTCAAGAAGCTTATGAGCAGGCTGTTGCTAATGGTGATTCTGAAGT -TGTTCTTAAAAAGTTGAAGAAGTCTTTGAATGTGGCTAAATCTGAATTTGACCGTGATGC -AGCCATGCAACGTAAGTTGGAAAAGATGGCTGATCAAGCTATGACCCAAATGTATAAACA -GGCTAGATCTGAGGACAAGAGGGCAAAAGTTACTAGTGCTATGCAGACAATGCTTTTCAC -TATGCTTAGAAAGTTGGATAATGATGCACTCAACAACATTATCAACAATGCAAGAGATGG -TTGTGTTCCCTTGAACATAATACCTCTTACAACAGCAGCCAAACTAATGGTTGTCATACC -AGACTATAACACATATAAAAATACGTGTGATGGTACAACATTTACTTATGCATCAGCATT -GTGGGAAATCCAACAGGTTGTAGATGCAGATAGTAAAATTGTTCAACTTAGTGAAATTAG -TATGGACAATTCACCTAATTTAGCATGGCCTCTTATTGTAACAGCTTTAAGGGCCAATTC -TGCTGTCAAATTACAGAATAATGAGCTTAGTCCTGTTGCACTACGACAGATGTCTTGTGC -TGCCGGTACTACACAAACTGCTTGCACTGATGACAATGCGTTAGCTTACTACAACACAAC -AAAGGGAGGTAGGTTTGTACTTGCACTGTTATCCGATTTACAGGATTTGAAATGGGCTAG -ATTCCCTAAGAGTGATGGAACTGGTACTATCTATACAGAACTGGAACCACCTTGTAGGTT -TGTTACAGACACACCTAAAGGTCCTAAAGTGAAGTATTTATACTTTATTAAAGGATTAAA -TAACCTAAATAGAGGTATGGTACTTGGTAGTTTAGCTGCCACAGTACGTCTACAAGCTGG -TAATGCAACAGAAGTGCCTGCCAATTCAACTGTATTATCTTTCTGTGCTTTTGCTGTAGA -TGCTGCTAAAGCTTACAAAGATTATCTAGCTAGTGGGGGACAACCAATCACTAATTGTGT -TAAGATGTTGTGTACACACACTGGTACTGGTCAGGCAATAACAGTTACACCGGAAGCCAA -TATGGATCAAGAATCCTTTGGTGGTGCATCGTGTTGTCTGTACTGCCGTTGCCACATAGA -TCATCCAAATCCTAAAGGATTTTGTGACTTAAAAGGTAAGTATGTACAAATACCTACAAC -TTGTGCTAATGACCCTGTGGGTTTTACACTTAAAAACACAGTCTGTACCGTCTGCGGTAT -GTGGAAAGGTTATGGCTGTAGTTGTGATCAACTCCGCGAACCCATGCTTCAGTCAGCTGA -TGCACAATCGTTTTTAAACGGGTTTGCGGTGTAAGTGCAGCCCGTCTTACACCGTGCGGC -ACAGGCACTAGTACTGATGTCGTATACAGGGCTTTTGACATCTACAATGATAAAGTAGCT -GGTTTTGCTAAATTCCTAAAAACTAATTGTTGTCGCTTCCAAGAAAAGGACGAAGATGAC -AATTTAATTGATTCTTACTTTGTAGTTAAGAGACACACTTTCTCTAACTACCAACATGAA -GAAACAATTTATAATTTACTTAAGGATTGTCCAGCTGTTGCTAAACATGACTTCTTTAAG -TTTAGAATAGACGGTGACATGGTACCACATATATCACGTCAACGTCTTACTAAATACACA -ATGGCAGACCTCGTCTATGCTTTAAGGCATTTTGATGAAGGTAATTGTGACACATTAAAA -GAAATACTTGTCACATACAATTGTTGTGATGATGATTATTTCAATAAAAAGGACTGGTAT -GATTTTGTAGAAAACCCAGATATATTACGCGTATACGCCAACTTAGGTGAACGTGTACGC -CAAGCTTTGTTAAAAACAGTACAATTCTGTGATGCCATGCGAAATGCTGGTATTGTTGGT -GTACTGACATTAGATAATCAAGATCTCAATGGTAACTGGTATGATTTCGGTGATTTCATA -CAAACCACGCCAGGTAGTGGAGTTCCTGTTGTAGATTCTTATTATTCATTGTTAATGCCT -ATATTAACCTTGACCAGGGCTTTAACTGCAGAGTCACATGTTGACACTGACTTAACAAAG -CCTTACATTAAGTGGGATTTGTTAAAATATGACTTCACGGAAGAGAGGTTAAAACTCTTT -GACCGTTATTTTAAATATTGGGATCAGACATACCACCCAAATTGTGTTAACTGTTTGGAT -GACAGATGCATTCTGCATTGTGCAAACTTTAATGTTTTATTCTCTACAGTGTTCCCACTT -ACAAGTTTTGGACCACTAGTGAGAAAAATATTTGTTGATGGTGTTCCATTTGTAGTTTCA -ACTGGATACCACTTCAGAGAGCTAGGTGTTGTACATAATCAGGATGTAAACTTACATAGC -TCTAGACTTAGTTTTAAGGAATTACTTGTGTATGCTGCTGACCCTGCTATGCACGCTGCT -TCTGGTAATCTATTACTAGATAAACGCACTACGTGCTTTTCAGTAGCTGCACTTACTAAC -AATGTTGCTTTTCAAACTGTCAAACCTGGTAATTTTAACAAAGACTTCTATGACTTTGCT -GTGTCTAAGGGTTTCTTTAAGGAAGGAAGTTCTGTTGAATTAAAACACTTCTTCTTTGCT -CAGGATGGTAATGCTGCTATCAGCGATTATGACTACTATCGTTATAATCTACCAACAATG -TGTGATATCAGACAACTACTATTTGTAGTTGAAGTTGTTGATAAGTACTTTGATTGTTAC -GATGGTGGCTGTATTAATGCTAACCAAGTCATCGTCAACAACCTAGACAAATCAGCTGGT -TTTCCATTTAATAAATGGGGTAAGGCTAGACTTTATTATGATTCAATGAGTTATGAGGAT -CAAGATGCACTTTTCGCATATACAAAACGTAATGTCATCCCTACTATAACTCAAATGAAT -CTTAAGTATGCCATTAGTGCAAAGAATAGAGCTCGCACCGTAGCTGGTGTCTCTATCTGT -AGTACTATGACCAATAGACAGTTTCATCAAAAATTATTGAAATCAATAGCCGCCACTAGA -GGAGCTACTGTAGTAATTGGAACAAGCAAATTCTATGGTGGTTGGCACAACATGTTAAAA -ACTGTTTATAGTGATGTAGAAAACCCTCATCTTATGGGTTGGGATTATCCTAAATGTGAT -AGAGCCATGCCTAACATGCTTAGAATTATGGCCTCACTTGTTCTTGCTCGCAAACATACA -ACGTGTTGTAGCTTGTCACACCGTTTCTATAGATTAGCTAATGAGTGTGCTCAAGTATTG -AGTGAAATGGTCATGTGTGGCGGTTCACTATATGTTAAACCAGGTGGAACCTCATCAGGA -GATGCCACAACTGCTTATGCTAATAGTGTTTTTAACATTTGTCAAGCTGTCACGGCCAAT -GTTAATGCACTTTTATCTACTGATGGTAACAAAATTGCCGATAAGTATGTCCGCAATTTA -CAACACAGACTTTATGAGTGTCTCTATAGAAATAGAGATGTTGACACAGACTTTGTGAAT -GAGTTTTACGCATATTTGCGTAAACATTTCTCAATGATGATACTCTCTGACGATGCTGTT -GTGTGTTTCAATAGCACTTATGCATCTCAAGGTCTAGTGGCTAGCATAAAGAACTTTAAG -TCAGTTCTTTATTATCAAAACAATGTTTTTATGTCTGAAGCAAAATGTTGGACTGAGACT -GACCTTACTAAAGGACCTCATGAATTTTGCTCTCAACATACAATGCTAGTTAAACAGGGT -GATGATTATGTGTACCTTCCTTACCCAGATCCATCAAGAATCCTAGGGGCCGGCTGTTTT -GTAGATGATATCGTAAAAACAGATGGTACACTTATGATTGAACGGTTCGTGTCTTTAGCT -ATAGATGCTTACCCACTTACTAAACATCCTAATCAGGAGTATGCTGATGTCTTTCATTTG -TACTTACAATACATAAGAAAGCTACATGATGAGTTAACAGGACACATGTTAGACATGTAT -TCTGTTATGCTTACTAATGATAACACCTCAAGGTATTGGGAACCTGAGTTTTATGAGGCT -ATGTACACACCGCATACAGTCTTACAGGCTGTTGGGGCTTGTGTTCTTTGCAATTCACAG -ACTTCATTAAGATGTGGTGCTTGCATACGTAGACCATTCTTATGTTGTAAATGCTGTTAC -GACCATGTCATATCAACATCACATAAATTAGTCTTGTCTGTTAATCCGTATGTTTGCAAT -GCTCCAGGTTGTGATGTCACAGATGTGACTCAACTTTACTTAGGAGGTATGAGCTATTAT -TGTAAATCACATAAACCACCCATTAGTTTTCCATTGTGTGCTAATGGACAAGTTTTTGGT -TTATATAAAAATACATGTGTTGGTAGCGATAATGTTACTGACTTTAATGCAATTGCAACA -TGTGACTGGACAAATGCTGGTGATTACATTTTAGCTAACACCTGTACTGAAAGACTCAAG -CTTTTTGCAGCAGAAACGCTCAAAGCTACTGAGGAGACATTTAAACTGTCTTATGGTATT -GCTACTGTACGTGAAGTGCTGTCTGACAGAGAATTACATCTTTCATGGGAAGTTGGTAAA -CCTAGACCACCACTTAACCGAAATTATGTCTTTACTGGTTATCGTGTAACTAAAAACAGT -AAAGTACAAATAGGAGAGTACACCTTTGAAAAAGGTGACTATGGTGATGCTGTTGTTTAC -CGAGGTACAACAACTTACAAATTAAATGTTGGTGATTATTTTGTGCTGACATCACATACA -GTAATGCCATTAAGTGCACCTACACTAGTGCCACAAGAGCACTATGTTAGAATTACTGGC -TTATACCCAACACTCAATATCTCAGATGAGTTTTCTAGCAATGTTGCAAATTATCAAAAG -GTTGGTATGCAAAAGTATTCTACACTCCAGGGACCACCTGGTACTGGTAAGAGTCATTTT -GCTATTGGCCTAGCTCTCTACTACCCTTCTGCTCGCATAGTGTATACAGCTTGCTCTCAT -GCCGCTGTTGATGCACTATGTGAGAAGGCATTAAAATATTTGCCTATAGATAAATGTAGT -AGAATTATACCTGCACGTGCTCGTGTAGAGTGTTTTGATAAATTCAAAGTGAATTCAACA -TTAGAACAGTATGTCTTTTGTACTGTAAATGCATTGCCTGAGACGACAGCAGATATAGTT -GTCTTTGATGAAATTTCAATGGCCACAAATTATGATTTGAGTGTTGTCAATGCCAGATTA -CGTGCTAAGCACTATGTGTACATTGGCGACCCTGCTCAATTACCTGCACCACGCACATTG -CTAACTAAGGGCACACTAGAACCAGAATATTTCAATTCAGTGTGTAGACTTATGAAAACT -ATAGGTCCAGACATGTTCCTCGGAACTTGTCGGCGTTGTCCTGCTGAAATTGTTGACACT -GTGAGTGCTTTGGTTTATGATAATAAGCTTAAAGCACATAAAGACAAATCAGCTCAATGC -TTTAAAATGTTTTATAAGGGTGTTATCACGCATGATGTTTCATCTGCAATTAACAGGCCA -CAAATAGGCGTGGTAAGAGAATTCCTTACACGTAACCCTGCTTGGAGAAAAGCTGTCTTT -ATTTCACCTTATAATTCACAGAATGCTGTAGCCTCAAAGATTTTGGGACTACCAACTCAA -ACTGTTGATTCATCACAGGGCTCAGAATATGACTATGTCATATTCACTCAAACCACTGAA -ACAGCTCACTCTTGTAATGTAAACAGATTTAATGTTGCTATTACCAGAGCAAAAGTAGGC -ATACTTTGCATAATGTCTGATAGAGACCTTTATGACAAGTTGCAATTTACAAGTCTTGAA -ATTCCACGTAGAAATGTGGCAACTTTACAAGCTGAAAATGTAACAGGACTCTTTAAAGAT -TGTAGTAAGGTAATCACTGGGTTACATCCTACACAGGCACCTACACACCTCAGTGTTGAC -ACTAAATTCAAAACTGAAGGTTTATGTGTTGACATACCTGGCATACCTAAGGACATGACC -TATAGAAGACTCATCTCTATGATGGGTTTTAAAATGAATTATCAAGTTAATGGTTACCCT -AACATGTTTATCACCCGCGAAGAAGCTATAAGACATGTACGTGCATGGATTGGCTTCGAT -GTCGAGGGGTGTCATGCTACTAGAGAAGCTGTTGGTACCAATTTACCTTTACAGCTAGGT -TTTTCTACAGGTGTTAACCTAGTTGCTGTACCTACAGGTTATGTTGATACACCTAATAAT -ACAGATTTTTCCAGAGTTAGTGCTAAACCACCGCCTGGAGATCAATTTAAACACCTCATA -CCACTTATGTACAAAGGACTTCCTTGGAATGTAGTGCGTATAAAGATTGTACAAATGTTA -AGTGACACACTTAAAAATCTCTCTGACAGAGTCGTATTTGTCTTATGGGCACATGGCTTT -GAGTTGACATCTATGAAGTATTTTGTGAAAATAGGACCTGAGCGCACCTGTTGTCTATGT -GATAGACGTGCCACATGCTTTTCCACTGCTTCAGACACTTATGCCTGTTGGCATCATTCT -ATTGGATTTGATTACGTCTATAATCCGTTTATGATTGATGTTCAACAATGGGGTTTTACA -GGTAACCTACAAAGCAACCATGATCTGTATTGTCAAGTCCATGGTAATGCACATGTAGCT -AGTTGTGATGCAATCATGACTAGGTGTCTAGCTGTCCACGAGTGCTTTGTTAAGCGTGTT -GACTGGACTATTGAATATCCTATAATTGGTGATGAACTGAAGATTAATGCGGCTTGTAGA -AAGGTTCAACACATGGTTGTTAAAGCTGCATTATTAGCAGACAAATTCCCAGTTCTTCAC -GACATTGGTAACCCTAAAGCTATTAAGTGTGTACCTCAAGCTGATGTAGAATGGAAGTTC -TATGATGCACAGCCTTGTAGTGACAAAGCTTATAAAATAGAAGAATTATTCTATTCTTAT -GCCACACATTCTGACAAATTCACAGATGGTGTATGCCTATTTTGGAATTGCAATGTCGAT -AGATATCCTGCTAATTCCATTGTTTGTAGATTTGACACTAGAGTGCTATCTAACCTTAAC -TTGCCTNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NACAAACAATTTGATACTTATAACCTCTGGAACACTTTTACAAGACTTCAGAGTTTAGAA -AATGTGGCTTTTAATGTTGTAAATAAGGGACACTTTGATGGACAACAGGGTGAAGTACCA -GTTTCTATCATTAATAACACTGTTTACACAAAAGTTGATGGTGTTGATGTAGAATTGTTT -GAAAATAAAACAACATTACCTGTTAATGTAGCATTTGAGCTTTGGGCTAAGCGCAACATT -AAACCAGTACCAGAGGTGAAAATACTCAATAATTTGGGTGTGGACATTGCTGCTAATACT -GTGATCTGGGACTACAAAAGAGATGCTCCAGCACATATATCTACTATTGGTGTTTGTTCT -ATGACTGACATAGCCAAGAAACCAACTGAAACGATTTGTGCACCACTCACTGTCTTTTTT -GATGGTAGAGTTGATGGTCAAGTAGACTTATTTAGAAATGCCCGTAATGGTGTTCTTATT -ACAGAAGGTAGTGTTAAAGGTTTACAACCATCTGTAGGTCCCAAACAAGCTAGTCTTAAT -GGAGTCACATTAATTGGAGAAGCCGTAAAAACACAGTTCAATTATTATAAGAAAGTTGAT -GGTGTTGTCCAACAATTACCTGAAACTTACTTTACTCAGAGTAGAAATTTACAAGAATTT -AAACCCAGGAGTCAAATGGAAATTGATTTCTTAGAATTAGCTATGGATGAATTCATTGAA -CGGTATAAATTAGAAGGCTATGCCTTCGAACATATCGTTTATGGAGATTTTAGTCATAGT -CAGTTAGGTGGTTTACATCTACTGATTGGACTAGCTAAACGTTTTAAGGAATCACCTTTT -GAATTAGAAGATTTTATTCCTATGGACAGTACAGTTAAAAACTATTTCATAACAGATGCG -CAAACAGGTTCATCTAAGTGTGTGTGTTCTGTTATTGATTTATTACTTGATGATTTTGTT -GAAATAATAAAATCCCAAGATTTATCTGTAGTTTCTAAGGTTGTCAAAGTGACTATTGAC -TATACAGAAATTTCATTTATGCTTTGGTGTAAAGATGGCCATGTAGAAACATTTTACCCA -AAATTACAATCTAGTCAAGCGTGGCAACCGGGTGTTGCTATGCCTAATCTTTACAAAATG -CAAAGAATGCTATTAGAAAAGTGTGACCTTCAAAATTATGGTGATAGTGCAACATTACCT -AAAGGCATAATGATGAATGTCGCAAAATATACTCAACTGTGTCAATATTTAAACACATTA -ACATTAGCTGTACCCTATAATATGAGAGTTATACATTTTGGTGCTGGTTCTGATAAAGGA -GTTGCACCAGGTACAGCTGTTTTAAGACAGTGGTTGCCTACGGGTACGCTGCTTGTCGAT -TCAGATCTTAATGACTTTGTCTCTGATGCAGATTCAACTTTGATTGGTGATTGTGCAACT -GTACATACAGCTAATAAATGGGATCTCATTATTAGTGATATGTACGACCCTAAGACTAAA -AATGTTACAAAAGAAAATGACTCTAAAGAGGGTTTTTTCACTTACATTTGTGGGTTTATA -CAACAAAAGCTAGCTCTNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNTTTATTTGACATGAGTAAATTTCCCCTTAAATTAAGGGGTACT -GCTGTTATGTCTTTAAAAGAAGGTCAAATCAATGATATGATTTTATCTCTTCTTAGTAAA -GGTAGACTTATAATTAGAGAAAACAACAGAGTTGTTATTTCTAGTGATGTTCTTGTTAAC -AACTAAACGAACAATGTTTGTTTTTCTTGTTTTATTGCCACTAGTCTCTAGTCAGTGTGT -TAATCTTACAACCAGAACTCAATTACCCCCTGCATACACTAATTCTTTCACACGTGGTGT -TTATTACCCTGACAAAGTTTTCAGATCCTCAGTTTTACATTCAACTCAGGACTTGTTCTT -ACCTTTCTTTTCCAATGTTACTTGGTTCCATGCTATCTCTGGGACCAATGGTACTAAGAG -GTTTGATAACCCTGTCCTACCATTTAATGATGGTGTTTATTTTGCTTCCACTGAGAAGTC -TAACATAATAAGAGGCTGGATTTTTGGTACTACTTTAGATTCGAAGACCCAGTCCCTACT -TATTGTTAATAACGCTACTAATGTTGTTATTAAAGTCTGTGAATTTCAATTTTGTAATGA -TCCATTTTTGGGTGTTTACCACAAAAACAACAAAAGTTGGATGGAAAGTGAGTTCAGAGT -TTATTCTAGTGCGAATAATTGCACTTTTGAATATGTCTCTCAGCCTTTTCTTATGGACCT -TGAAGGAAAACAGGGTAATTTCAAAAATCTTAGGGAATTTGTGTTTAAGAATATTGATGG -TTATTTTAAAATATATTCTAAGCACACGCCTATTAATTTAGTGCGTGATCTCCCTCAGGG -TTTTTCGGCTTTAGAACCATTGGTAGATTTGCCAATAGGTATTAACATCACTAGGTTTCA -AACTTTACTTGCTTTACATAGAAGTTATTTGACTCCTGGTGATTCTTCTTCAGGTTGGAC -AGCTGGTGCTGCAGCTTATTATGTGGGTTATCTTCAACCTAGGACTTTTCTATTAAAATA -TAATGAAAATGGAACCATTACAGATGCTGTAGACTGTGCACTTGACCCTCTCTCAGAAAC -AAAGTGTACGTTGAAATCCTTCACTGTAGAAAAAGGAATCTATCAAACTTCTAACTTTAG -AGTCCAACCAACAGAATCTATTGTTAGATTTCCTAATATTACAAACTTGTGCCCTTTTGG -TGAAGTTTTTAACGCCACCAGATTTGCATCTGTTTATGCTTGGAACAGGAAGAGAATCAG -CAACTGTGTTGCTGATTATTCTGTCCTATATAATTCCGCATCATTTTCCACTTTTAAGTG -TTATGGAGTGTCTCCTACTAAATTAAATGATCTCTGCTTTACTAATGTCTATGCAGATTC -ATTTGTAATTAGAGGTGATGAAGTCAGACAAATCGCTCCAGGGCAAACTGGAAAGATTGC -TGATTATAATTATAAATTACCAGATGATTTTACAGGCTGCGTTATAGCTTGGAATTCTAA -CAATCTTGATTCTAAGGTTGGTGGTAATTATAATTACCTGTATAGATTGTTTAGGAAGTC -TAATCTCAAACCTTTTGAGAGAGATATTTCAACTGAAATCTATCAGGCCGGTAGCACACC -TTGTAATGGTGTTGAAGGTTTTAATTGTTACTTTCCTTTACAATCATATGGTTTCCAACC -CACTTATGGTGTTGGTTACCAACCATACAGAGTAGTAGTACTTTCTTTTGAACTTCTACA -TGCACCAGCAACTGTTTGTGGACCTAAAAAGTCTACTAATTTGGTTAAAAACAAATGTGT -CAATTTCAACTTCAATGGTTTAACAGGCACAGGTGTTCTTACTGAGTCTAACAAAAAGTT -TCTGCCTTTCCAACAATTTGGCAGAGACATTGATGACACTACTGATGCTGTCCGTGATCC -ACAGACACTTGAGATTCTTGACATTACACCATGTTCTTTTGGTGGTGTCAGTGTTATAAC -ACCAGGAACAAATACTTCTAACCAGGTTGCTGTTCTTTATCAGGGTGTTAACTGCACAGA -AGTCCCTGTTGCTATTCATGCAGATCAACTTACTCCTACTTGGCGTGTTTATTCTACAGG -TTCTAATGTTTTTCAAACACGTGCAGGCTGTTTAATAGGGGCTGAACATGTCAACAACTC -ATATGAGTGTGACATACCCATTGGTGCAGGTATATGCGCTAGTTATCAGACTCAGACTAA -TTCTCATCGGCGGGCACGTAGTGTAGCTAGTCAATCCATCATTGCCTACACTATGTCACT -TGGTGCAGAAAATTCAGTTGCTTACTCTAATAACTCTATTGCCATACCCATAAATTTTAC -TATTAGTGTTACCACAGAAATTCTACCAGTGTCTATGACCAAGACATCAGTAGATTGTAC -AATGTACATTTGTGGTGATTCAACTGAATGCAGCAATCTTTTGTTGCAATATGGCAGTTT -TTGTACACAATTAAACCGTGCTTTAACTGGAATAGCTGTTGAACAAGACAAAAACACCCA -AGAAGTTTTTGCACAAGTCAAACAAATTTACAAAACACCACCAATTAAAGATTTTGGTGG -TTTTAATTTTTCACAAATATTACCAGATCCATCAAAATCAAGCAAGAGGTCATTTATTGA -AGATCTACTTTTCAACAAAGTGACACTTGCAGATGCTGGCTTCATCAAACAATATGGTGA -TTGCCTTGGTGATATTGCTGCTAGAGACCTCATTTGTGCACAAAAGTTTAACGGCCTTAC -TGTTTTGCCACCTTTGCTCACAGATGAAATGATTGCTCAATACACTTCTGCACTGTTAGC -GGGTACAATCACTTCTGGTTGGACCTTTGGTGCAGGTGCTGCATTACAAATACCATTTGC -TATGCAAATGGCTTATAGGTTTAATGGTATTGGAGTTACACAGAATGTTCTCTATGAGAA -CCAAAAATTGATTGCCAACCAATTTAATAGTGCTATTGGCAAAATTCAAGACTCACTTTC -TTCCACAGCAAGTGCACTTGGAAAACTTCAAGATGTGGTCAACCAAAATGCACAAGCTTT -AAACACGCTTGTTAAACAACTTAGCTCCAATTTTGGTGCAATTTCAAGTGTTTTAAATGA -TATCCTTGCACGTCTTGACAAAGTTGAGGCTGAAGTGCAAATTGATAGGTTGATCACAGG -CAGACTTCAAAGTTTGCAGACATATGTGACTCAACAATTAATTAGAGCTGCAGAAATCAG -AGCTTCTGCTAATCTTGCTGCTACTAAAATGTCAGAGTGTGTACTTGGACAATCAAAAAG -AGTTGATTTTTGTGGAAAGGGCTATCATCTTATGTCCTTCCCTCAGTCAGCACCTCATGG -TGTAGTCTTCTTGCATGTGACTTATGTCCCTGCACAAGAAAAGAACTTCACAACTGCTCC -TGCCATTTGTCATGATGGAAAAGCACACTTTCCTCGTGAAGGTGTCTTTGTTTCAAATGG -CACACACTGGTTTGTAACACAAAGGAATTTTTATGAACCACAAATCATTACTACACACAA -CACATTTGTGTCTGGTAACTGTGATGTTGTAATAGGAATTGTCAACAACACAGTTTATGA -TCCTTTGCAACCTGAATTAGACTCATTCAAGGAGGAGTTAGATAAATATTTTAAGAATCA -TACATCACCAGATGTTGATTTAGGTGACATCTCTGGCATTAATGCTTCAGTTGTAAACAT -TCAAAAAGAAATTGACCGCCTCAATGAGGTTGCCAAGAATTTAAATGAATCTCTCATCGA -TCTCCAAGAACTTGGAAAGTATGAGCAGTATATAAAATGGCCATGGTACATTTGGCTAGG -TTTTATAGCTGGCTTGATTGCCATAGTAATGGTGACAATTATGCTTTGCTGTATGACCAG -TTGCTGTAGTTGTCTCAAGGGCTGTTGTTCTTGTGGATCCTGCTGCAAATTTGATGAAGA -CGACTCTGAGCCAGTGCTCAAAGGAGTCAAATTACATTACACATAAACGAACTTATGGAT -TTGTTTATGAGAATCTTCACAATTGGAACTGTAACTTTGAAGCAAGGTGAAATCAAGGAT -GCTACTCCTTCAGATTTTGTTCGCGCTACTGCAACGATACCGATACAAGCCTCACTCCCT -TTCGGATGGCTTATTGTTGGCGTTGCACTTCTTGCTGTTTTTCAGAGCGCTTCCAAAATC -ATAACCCTCAAAAAGAGATGGCAACTAGCACTCTCCAAGGGTGTTCACTTTGTTTGCAAC -TTGCTGTTGTTGTTTGTAACAGTTTACTCACACCTTTTGCTCGTTGCTGCTGGCCTTGAA -GCCCCTTTTCTCTATCTTTATGCTTTAGTCTACTTCTTGCAGAGTATAAACTTTGTAAGA -ATAATAATGAGGCTTTGGCTTTGCTGGAAATGCCGTTCCAAAAACCCATTACTTTATGAT -GCCAACTATTTTCTTTGCTGGCATACTAATTGTTACGACTATTGTATACCTTACAATAGT -GTAACTTCTTCAATTGTCATTACTTCAGGTGATGGCACAACAAGTCCTATTTCTGAACAT -GACTACCAGATTGGTGGTTATACTGAAAAATGGGAATTTGGAGTAAAAGACTGTGTTGTA -TTACACAGTTACTTCACTTCAGACTATTACCAGCTGTACTCAACTCAATTGAGTACAGAC -ACTGGTGTTGAACATGTTACCTTCTTCATCTACAATAAAATTGTTGATGAGCCTGAAGAA -CATGTCCAAATTCACACAATCGACGGTTCATCCGGAGTTGTTAATCCAGTAATGGAACCA -ATTTATGATGAACCGACGACGACTACTAGCGTGCCTTTGTAAGCACAAGCTGATGAGTAC -GAACTTATGTACTCATTCGTTTCGGAAGAGACAGGTACGTTAATAGTTAATAGCGTACTT -CTTTTTCTTGCTTTCGTGGTATTCTTGCTAGTTACACTAGCCATCCTTACTGCGCTTCGA -TTGTGTGCGTACTGCTGCAATATTGTTAACGTGAGTCTTGTAAAACCTTCTTTTTACGTT -TACTCTCGTGTTAAAAATCTGAATTCTTCTAGAGTTCCTGATCTTCTGGTCTAAACGAAC -TAAATATTATATTAGTTTTTCTGTTTGGAACTTTAATTTTAGCCATGGCAGATTCCAACG -GTACTATTACCGTTGAAGAGCTTAAAAAGCTCCTTGAACAATGGAACCTAGTAATAGGTT -TCCTATTCCTTACATGGATTTGTCTTCTACAATTTGCCTATGCCAACAGGAATAGGTTTT -TGTATATAATTAAGTTAATTTTCCTCTGGCTGTTATGGCCAGTAACTTTAGCTTGTTTTG -TGCTTGCTGCTGTTTACAGAATAAATTGGATCACCGGTGGAATTGCTATCGCAATGGCTT -GTCTTGTAGGCTTGATGTGGCTCAGCTACTTCATTGCTTCTTTCAGACTGTTTGCGCGTA -CGCGTTCCATGTGGTCATTCAATCCAGAAACTAACATTCTTCTCAACGTGCCACTCCATG -GCACTATTCTGACCAGACCGCTTCTAGAAAGTGAACTCGTAATCGGAGCTGTGATCCTTC -GTGGACATCTTCGTATTGCTGGACACCATCTAGGACGCTGTGACATCAAGGACCTGCCTA -AAGAAATCACTGTTGCTACATCACGAACGCTTTCTTATTACAAATTGGGAGCTTCGCAGC -GTGTAGCAGGTGACTCAGGTTTTGCTGCATACAGTCGCTACAGGATTGGCAACTATAAAT -TAAACACAGACCATTCCAGTAGCAGTGACAATATTGCTTTGCTTGTACAGTAAGTGACAA -CAGATGTTTCATCTCGTTGACTTTCAGGTTACTATAGCAGAGATATTACTAATTATTATG -AGGACTTTTAAAGTTTCCATTTGGAATCTTGATTACATCATAAACCTCATAATTAAAAAT -TTATCTAAGTCACTAACTGAGAATAAATATTCTCAATTAGATGAAGAGCAACCAATGGAG -ATTGATTAAACGAACATGAAAATTATTCTTTTCTTGGCACTGATAACACTCGCTACTTGT -GAGCTTTATCACTACCAAGAGTGTGTTAGAGGTACAACAGTACTTTTAAAAGAACCTTGC -TCTTCTGGAACATACGAGGGCAATTCACCATTTCATCCTCTAGCTGATAACAAATTTGCA -CTGACTTGCTTTAGCACTCAATTTGCTTTTGCTTGTCCTGACGGCGTAAAACACGTCTAT -CAGTTACGTGCCAGATCAGTTTCACCTAAACTGTTCATCAGACAAGAGGAAGTTCAAGAA -CTTTACTCTCCAATTTTTCTTATTGTTGCGGCAATAGTGTTTATAACACTTTGCTTCACA -CTCAAAAGAAAGACAGAATGATTGAACTTTCATTAATTGACTTCTATTTGTGCTTTTTAG -CCTTTCTGCTATTCCTTGTTTTAATTATGCTTATTATCTTTTGGTTCTCACTTGAACTGC -AAGATCATAATGAAACTTGTCACGCCTAAACGAACATGAAATTTCTTGTTTTCTTAGGAA -TCATCACAACTGTAGCTGCATTTCACCAAGAATGTAGTTTACAGTCATGTACTTAACATC -AACCATATGTAGTTGATGACCCGTGTCCTATTCACTTCTATTCTAAATGGTATATTAGAG -TAGGAGCTATAAAATCAGCACCTTTAATTGAATTGTGCGTGGATGAGGCTGGTTCTAAAT -CACCCATTCAGTGCATCGATATCGGTAATTATACAGTTTCCTGTTTACCTTTTACAATTA -ATTGCCAGGAACCTAAATTGGGTAGTCTTGTAGTGCGTTGTTCGTTCTATGAAGACTTTT -TAGAGTATCATGACGTTCGTGTTGTTTTAGATTTCATCTAAACGAACAAACTAAATGTCT -CTAAATGGACCCCAAAATCAGCGAAATGCACCCCGCATTACGTTTGGTGGACCCTCAGAT -TCAACTGGCAGTAACCAGAATGGAGAACGCAGTGGGGCGCGATCAAAACAACGTCGGCCC -CAAGGTTTACCCAATAATACTGCGTCTTGGTTCACCGCTCTCACTCAACATGGCAAGGAA -GACCTTAAATTCCCTCGAGGACAAGGCGTTCCAATTAACACCAATAGCAGTCCAGATGAC -CAAATTGGCTACTACCGAAGAGCTACCAGACGAATTCGTGGTGGTGACGGTAAAATGAAA -GATCTCAGTCCAAGATGGTATTTCTACTACCTAGGAACTGGGCCAGAAGCTGGACTTCCC -TATGGTGCTAACAAAGACGGCATCATATGGGTTGCAACTGAGGGAGCCTTGAATACACCA -AAAGATCACATTGGCACCCGCAATCCTGCTAACAATGCTGCAATCGTGCTACAACTTCCT -CAAGGAACAACATTGCCAAAAGGCTTCTACGCAGAAGGGAGCAGAGGCGGCAGTCAAGCC -TCTTCTCGTTCCTCATCACGTAGTCGCAACAGTTCAAGAAATTCAACTCCAGGCAGCAGT -AAACGAACTTCTCCTGCTAGAATGGCTGGCAATGGCGGTGATGCTGCTCTTGCTTTGCTG -CTGCTTGACAGATTGAACCAGCTTGAGAGCAAAATGTTTGGTAAAGGCCAACAACAACAA -GGCCAAACTGTCACTAAGAAATCTGCTGCTGAGGCTTCTAAGAAGCCTCGGCAAAAACGT -ACTGCCACTAAAGCATACAATGTAACACAAGCTTTCGGCAGACGTGGTCCAGAACAAACC -CAAGGAAATTTTGGGGACCAGGAACTAATCAGACAAGGAACTGATTACAAACATTGGCCG -CAAATTGCACAATTTGCCCCCAGCGCTTCAGCGTTCTTCGGAATGTCGCGCATTGGCATG -GAAGTCACACCTTCGGGAACGTGGTTGACCTACACAGGTGCCATCAAATTGGATGACAAA -GATCCAAATTTCAAAGATCAAGTCATTTTGCTGAATAAGCATATTGACGCATACAAAACA -TTCCCACCAACAGAGCCTAAAAAGGACAAAAAGAAGAAGGCTGATGAAACTCAAGCCTTA -CCGCAGAGACAGAAGAAACAGCAAACTGTGACTCTTCTTCCTGCTGCAGATTTGGATGAT -TTCTCCAAACAATTGCAACAATCCATGAGCAGTGCTGACTCAACTCAGGCCTAAACTCAT -GCAGACCACACAAGGCAGATGGGCTATATAAACGTTTTCGCTTTTCCGTTTACGATATAT -AGTCTACTCTTGTGCAGAATGAATTCTCGTAACTACATAGCACAAGTAGATGTAGTTAAC -TTTAATCTCACATAGCAATCTTTAATCAGTGTGTAACATTAGGGAGGACTTGAAAGAGCC -ACCACATTTTCACCGAGGCCACGCGGAGTACGATCGAGTGTACAGTGAACAATGCTAGGG -AGAGCTGCCTATATGGAAGAGCCCTAATGTGTAAAATTAATTTTAGTAGTGCTATCCNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNN ->14779 -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNAGATCT -GTTCTCTAAACGAACTTTAAAATCTGTGTGGCTGTCACTCGGCTGCATGCTTAGTGCACT -CACGCAGTATAATTAATAACTAATTACTGTCGTTGACAGGACACGAGTAACTCGTCTATC -TTCTGCAGGCTGCTTACGGTTTCGTCCGTGTTGCAGCCGATCATCAGCACATCTAGGTTT -TGTCCGGGTGTGACCGAAAGGTAAGATGGAGAGCCTTGTCCCTGGTTTCAACGAGAAAAC -ACACGTCCAACTCAGTTTGCCTGTTTTACAGGTTCGCGACGTGCTCGTACGTGGCTTTGG -AGACTCCGTGGAGGAGGTCTTATCAGAGGCACGTCAACATCTTAAAGATGGCACTTGTGG -CTTAGTAGAAGTTGAAAAAGGCGTTTTGCCTCAACTTGAACAGCCCTATGTGTTCATCAA -ACGTTCGGATGCTCGAACTGCACCTCATGGTCATGTTATGGTTGAGCTGGTAGCAGAACT -CGAAGGCATTCAGTACGGTCGTAGTGGTGAGACACTTGGTGTCCTTGTCCCTCATGTGGG -CGAAATACCAGTGGCTTACCGCAAGGTTCTTCTTCGTAAGAACGGTAATAAAGGAGCTGG -TGGCCATAGTTACGGCGCCGATCTAAAGTCATTTGACTTAGGCGACGAGCTTGGCACTGA -TCCTTATGAAGATTTTCAAGAAAACTGGAACACTAAACATAGCAGTGGTGTTACCCGTGA -ACTCATGCGTGAGCTTAACGGAGGGGCATACACTCGCTATGTTGATAACAACTTCTGTGG -CCCTGATGGCTACCCTCTTGAGTGCATTAAAGACCTTCTAGCACGTGCTGGTAAAGCTTC -ATGCACTTTGTCTGAACAACTGGACTTTATTGACACTAAGAGGGGTGTATACTGCTGCCG -TGAACATGAGCATGAAATTGCTTGGTACACGGAACGTTCTGAAAAGAGCTATGAATTGCA -GACACCTTTTGAAATTAAATTGGCAAAGAAATTTGACACCTTCAATGGGGAATGTCCAAA -TTTTGTATTTCCCTTAAATTCCATAATCAAGACTATTCAACCAAGGGTTGAAAAGAAAAA -GCTTGATGGCTTTATGGGTAGAATTCGATCTGTCTATCCAGTTGCGTCACCAAATGAATG -CAACCAAATGTGCCTTTCAACTCTCATGAAGTGTGATCATTGTGGTGAAACTTCATGGCA -GACGGGCGATTTTGTTAAAGCCACTTGCGAATTTTGTGGCACTGAGAATTTGNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNAAGGTCTTAATGACAACCTTCTTGA -AATACTCCAAAAAGAGAAAGTCAACATCAATATTGTTGGTGACTTTAAACTTAATGAAGA -GATCGCCATTATTTTGGCATCTTTTTCTGCTTCCACAAGTGCTTTTGTGGAAACTGTGAA -AGGTTTGGATTATAAAGCATTCAAACAAATTGTTGAATCCTGTGGTAATTTTAAAGTTAC -AAAAGGAAAAGCTAAAAAAGGTGCCTGGAATATTGGTGAACAGAAATCAATACTGAGTCC -TCTTTATGCATTTGCATCAGAGGCTGCTCGTGTTGTACGATCAATTTTCTCCCGCACTCT -TGAAACTGCTCAAAATTCTGTGCGTGTTTTACAGAAGGCCGCTATAACAATACTAGATGG -AATTTCACAGTATTCACTGAGACTCATTGATGCTATGATGTTCACATCTGATTTGGCTAC -TAACAATCTAGTTGTAATGGCCTACATTACAGGTGGTGTTGTTCAGTTGACTTCGCAGTG -GCTAACTAACATCTTTGGCACTGTTTATGAAAAACTCAAACCCGTCCTTGATTGGCTTGA -AGAGAAGTTTAAGGAAGGTGTAGAGTTTCTTAGAGACGGTTGGGAAATTGTTAAATTTAT -CTCAACCTGTGCTTGTGAAATTNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNTGAACTCGGTACAGAAGTAAATGAGTTCGC -CTGTGTTGTGGCAGATGCTGTCATAAAAACTTTGCAACCAGTATCTGAATTACTTACACC -ACTGGGCATTGATTTAGATGAGTGGAGTATGGCTACATACTACTTATTTGATGAGTCTGG -TGAGTTTAAATTGGCTTCACATATGTATTGTTCTTTTTACCCTCCAGATGAGGATGAAGA -AGAAGGTGATTGTGAAGAAGAAGAGTTTGAGCCATCAACTCAATATGAGTATGGTACTGA -AGATGATTACCAAGGTAAACCTTTGGAATTTGGTGCCACTTCTGCTGCTCTTCAACCTGA -AGAAGAGCAAGAAGAAGATTGGTTAGATGATGATAGTCAACAAACTGTTGGTCAACAAGA -CGGCAGTGAGGACAATCAGACAACTATTATTCAAACAATTGTTGAGGTTCAACCTCAATT -AGAGATGGAACTTACACCAGTTGTTCAGACTATTGAAGTGAATAGTTTTAGTGGTTATTT -AAAACTTACTGACAATGTATACATTAAAAATGCAGACATTGTGGAAGAAGCTAAAAAGGT -AAAACCAACAGTGGTTGTTAATGCAGCCAATGTTTACCTTAAACATGGAGGAGGTGTTGC -AGGAGCCTTAAATAAGGCTACTAACAANNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNCTTTGATAAAAATCTCTATGACAAACTTGTTTCAAGCTTTTTGGA -AATGAAGAGTGAAAAGCAAGTTGAACAAAAGATCGCTGAGATTCCTAAAGAGGAAGTTAA -GCCATTTATAACTGAAAGTAAACCTTCAGTTGAACAGAGAAAACAAGATGATAAGAAAAT -CAAAGCTTGTGTTGAAGAAGTTACAACAACTCTGGAAGAAACTAAGTTCCTCACAGAAAA -CTTGTTACTTTATATTGACATTAATGGCAATCTTCATCCAGATTCTGCCACTCTTGTTAG -TGACATTGACATCACTTTCTTAAAGAAAGATGCTCCATATATAGTGGGTGATGTTGTTCA -AGAGGGTGTTTTAACTGCTGTGGTTATACCTACTAAAAAGGCTGGTGGCACTATTGAAAT -GCTAGCGAAAGCTTTGAGAAAAGTGCCAACAGACAATTATATAACCACTTACCCGGGTCA -GGGTTTAAATGGTTACACTGTAGAGGAGGCAAAGACAGTGCTTAAAAAGTGTAAAAGTGC -CTTTTACATTCTACCATCTATTATCTCTAATGAGAAGCAAGAAATTCTTGGAACTGTTTC -TTGGAATTTGCGAGAAATGCTTGCACATGCAGAAGAAACACGCAAATTAATGCCTGTCTG -TGTGGAAACTAAAGCCATAGTTTCAACTATACAGCGTAAATATAAGGGTATTAAAATACA -AGAGGGTGTGGTTGATTATGGTGCTAGATTTTACTTTTACACCAGTAAAACAACTGTAGC -GTCACTTATCAACACACTTAACGATCTAAATGAAACTCTTGTTACAATGCCACTTGGCTA -TGTAACACATGGCTTAAATTTGGAAGAAGCTGCTCGGTATATGAGANNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNTATCTTGCCACTGCATTGTTAACACTCCAACAAATAGAGTTGAAGTTTAATCC -ACCTGCTCTACAAGATGCTTATTACAGAGCAAGGGCTGGTGAAGCTGATAACTTTTGTGC -ACTTATCTTAGCCTACTGTAATAAGACAGTAGGTGAGTTAGGTGATGTTAGAGAAACAAT -GAGTTACTTGTTTCAACATGCCAATTTAGATTCTTGCAAAAGAGTCTTGAACGTGGTGTG -TAAAACTTGTGGACAACAGCAGACAACCCTTAAGGGTGTAGAAGCTGTTATGTACATGGG -CACACTTTCTTATGAACAATTTAAGAAAGGTGTTCAGATACCTTGTACGTGTGGTAAACA -AGCTACAAAATATCTAGTACAACAGGAGTCACCTTTTGTTATGATGTCAGCACCACCTGC -TCAGTATGAACTTAAGCATGGTACATTTACTTGTGCTAGTGAGTACACTGGTAATTACCA -GTGTGGTCACTATAAACATATAACTTCTAAAGAAACTTTGTATTGCATAGACGGTGCTTT -ACTTACAAAGTCCTCAGAATACAAAGGTCCTATTACGGATGTTTTCTACAAAGAAAACAG -TTACACAACAACCATAAAACCAGTTACTTATAAATTGGATGGTGTTGTTTGTNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNCTTTTAAGAAAGGAGCTAAATTGTTACATAAACCTATTGTTTG -GCATGTTAACAATGCAACTAATAAAGCCACGTATAAACCAAATACCTGGTGTATACGTTG -TCTTTGGAGCACAAAACCAGTTGAAACATCAAATTCGTTTGATGTACTGAAGTCAGAGGA -CGCGCAGGGAATGGATAATCTTGCCTGCGAAGATCTAAAACCAGTCTCTGAAGAAGTAGT -GGAAAATCCTACCATACAGAAAGACGTTCTTGAGTGTAATGTGAAAACTACCGAAGTTGT -AGGAGACATTATACTTAAACCAGCAAATAATAGTTTAAAAATTACAGAAGAGGTTGGCCA -CACAGATCTAATGGCTGCTTATGTAGACAATTCTAGTCTTACTATTAAGAAACCTAATGA -ATTATCTAGAGTATTAGGTTTGAAAACCCTTGCTACTCATGGTTTAGCTGCTGTTAATAG -TGTCCCTTGGGATACTATAGCTAATTATGCTAAGCCTTTTCTTAACAAAGTTGTTAGTAC -AACTACTAACATAGTTACACGGTGTTTAAACCGTGTTTGTACTAATTATATGCCTTATTT -CTTTACTTTATTGCTACAATTGTGTACTTTTACTAGAAGTACAAATTCTAGAATTAAAGC -ATCTATNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNACATTTTATTAGTAATTCTTGGCTTATGTGGTTAATAATTAATCTTGT -ACAAATGGCCCCGATTTCAGCTATGGTTAGAATGTACATCTTCTTTGCATCATTTTATTA -TGTATGGAAAAGTTATGTGCATGTTGTAGACGGTTGTAATTCATCAACTTGTATGATGTG -TTACAAACGTAATAGAGCAACAAGAGTCGAATGTACAACTATTGTTAATGGTGTTAGAAG -GTCCTTTTATGTCTATGCTAATGGAGGTAAAGGCTTTTGCAAACTACACAATTGGAATTG -TGTTAATTGTGATACATTCTGTGCTGGTAGTACATTTATTAGTGATGAAGTNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNTATACTGTTACT -AGATCAGGCATTAGTGTCTGATGTTGGTGATAGTGCGGAAGTTGCAGTTAAAATGTTTGA -TGCTTACGTTAATACGTTTTCATCAACTTTTAACGTACCAATGGAAAAACTCAAAACACT -AGTTGCAACTGCAGAAGCTGAACTTGCAAAGAATGTGTCCTTAGACAATGTCTTATCTAC -TTTTATTTCAGCAGCTCGGCAAGGGTTTGTTGATTCAGATGTAGAAACTAAAGATGTTGT -TGAATGTCTTAAATTGTCACATCAATCTGACATAGAAGTTACTGGCGATAGTTGTAATAA -CTATATGCTCACCTATAACAAAGTTGAAAACATGACACCNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNTATTTTCTATTTAATAACACC -TGTTCATGTCATGTCTAAACATACTGACTTTTCAAGTGAAATCATAGGATACAAGGCTAT -TGATGGTGGTGTCACTCGTGACATAGCATCTACAGATACTTGTTTTGCTAACAAACATGC -TGATTTTGACACATGGTTTAGCCAGCGTGGTGGTAGTTATACTAATGACAAAGCTTGCCC -ATTGATTGCTGCAGTCATAACAAGAGAAGTGGGTTTTGTCGTGCCTGGTTTGCCTGGCAC -GATATTACGCACAACTAATGGTGACTTTTTGCATTTCTTACCTAGAGTTTTTAGTGCAGT -TGGTAACATCTGTTACACACCATCAAAACTTATAGAGTACACTGACTTTGCAACATCAGC -TTGTGTTTTGGCTGCTGAATGTACAATTTTTAAAGATGCTTCTGGTAAGCCAGTACCATA -TTGTTATGATACCAATGTACTAGAAGGTTCTGTTGCTTATGAAAGTTTACGCCCTGACAC -ACGTTATGTGCTCATGGATGGCTCTATTATTCAATTTCCTAACACCTACCTTGAAGGTTC -TGTTAGAGTGGTAACAACTTTTGATTCTGAGTACTGTAGGCACGGCACTTGTGAAAGATC -AGAAGCTGGTGTTTGTGTATCTACTAGTGGTAGATGGGTACTTAACAATGATTATTACAG -ATCTTTACCAGGAGTTTTCTGTGGTGTAGATGCTGTAAATTTACTTACTAATATGTTTAC -ACCACTAATTCAACCTATTGGTGCTTTGGACATATCAGCATCTATAGTAGCTGGTGGTAT -TGTAGCTATCGTAGTAACATGCCTTGCCTACTATTTTATGAGGTTTAGAAGAGCTTTTGG -TGAATACAGTCATGTAGTTGCCTTTAATACTTTACTATTCCTTATGTCATTCACTGTACT -CTGTTTAACACCAGTTTACTCATTCTTACCTGGTGTTTATTCTGTTATTTACTTGTACTT -GACATTTTATCTTACTAATGATGTTTCTTTTTTAGCACATATTCAGTGGATGGTTATGTT -CACACCTTTAGTACCTTTCTGGATAACAATTGCTTATATCATTTGTATTTCCACAAAGCA -TTTCTATTGGTTCTTTAGTAATTACCTAAAGAGACGTGTAGTCTTTAATGGTGTTTCCTT -TAGTACTTTTGAAGAAGCTGCGCTGTGCACCTTTTTGTTAAATAAAGAAATGTATCTAAA -GTTGCGTAGTGATGTGCTATTACCTCTTACGCAATATAATAGATACTTAGCTCTTTATAA -TAAGTACAAGTATTTTAGTGGAGCAATGGATACAACTAGCTACAGAGAAGCTGCTTGTTG -TCATCTCGCAAAGGCTCTCAATGACTTCAGTAACTCAGGTTCTGATGTTCTTTACCAACC -ACCACAAACCTCTATCACCTCAGCTGTTTTGCAGAGTGGTTTTAGAAAAATGGCATTCCC -ATCTGGTAAAGTTGAGGGTTGTATGGTACAAGTAACTTGTGGTACAACTACACTTAACGG -TCTTTGGCTTGATGACGTAGTTTACTGTCCAAGACATGTGATCTGCACCTCTGAAGACAT -GCTTAACCCTAATTATGAAGATTTACTCATTCGTAAGTCTAATCATAATTTCTTGGTACA -GGCTGGTAATGTTCAACTCAGGGTTATTGGACATTCTATGCAAAATTGTGTACTTAAGCT -TAAGGTTGATACAGCCAATCCTAAGACACCTAAGTATAAGTTTGTTCGCATTCAACCAGG -ACAGACTTTTTCAGTGTTAGCTTGTTACAATGGTTCACCATCTGGTGTTTACCAATGTGC -TATGAGGCCCAATTTCACTATTAAGGGTTCATTCCTTAATGGTTCATGTGGTAGTGTTGG -TTTTAACATAGATTATGACTGTGTCTCTTTTTGTTACATGCACCATATGGAATTACCAAC -TGGAGTTCATGCTGGCACAGACTTAGAAGGTAACTTTTATGGACCTTTTGTTGACAGGCA -AACAGCACAAGCAGCTGGTACGGACACAACTATTACAGTTAATGTTTTAGCTTGGTTGTA -CGCTGCTGTTATAAATGGAGACAGGTGGTTTCTCAATCGATTTACCACAACTCTTAANNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNAATTTTGACTTCACTTTT -AGTTTTAGTCCAGAGTACTCAATGGTCTTTGTTCTTTTTTTTGTATGAAAATGCCTTTTT -ACCTTTTGCTATGGGTATTATTGCTATGTCTGCTTTTGCAATGATGTTTGTCAAACATAA -GCATGCATTTCTCTGTTTGTTTTTGTTACCTTCTCTTGCCACTGTAGCTTATTTTAATAT -GGTCTATATGCCTGCTAGTTGGGTGATGCGTATTATGACATGGTTGGATATGGTTGATAC -TAGTTTGAAGCTAAAAGACTGTGTTATGTATGCATCAGCTGTAGTGTTACTAATCCTTAT -GACAGCAAGAACTGTGTATGATGATGGTGCTAGGAGAGTGTGGACACTTATGAATGTCTT -GACACTCGTTTATAAAGTTTATTATGGTAATGCTTTAGATCAAGCCATTTCCATGTGGGC -TCTTATAATCTCTGTTACTTCTAACTACTCAGGTGTAGTTACAACTGTCATGTTTTTGGC -CAGAGGTATTGTTTTTATGTGTGTTGAGTATTGCCCTATTTTCTTCATAACTGGTAATAC -ACTTCAGTGTATAATGCTAGTTTATTGTTTCTTAGGCTATTTTTGTACTTGTTACTTTGG -CCTCTTTTGTTTACTCAACCGCTACTTTAGACTGACTCTTGGTGTTTATGATTACTTAGT -TTCTACACAGGAGTTTAGATATATGAATTCACAGGGACTACTCCCACCCAAGAATAGCAT -AGATGCCTTCAAACTCAACATTAAATTGTTGGGTGTTGGTGGCAAACCTTGTATCAAAGT -AGCCACTGTACAGTCTAAAATGTCAGATGTAAAGTGCACATCAGTAGTCTTACTCTCAGT -TTTGCAACAACTCAGAGTAGAATCATCATCTAAATTGTGGGCTCAATGTGTCCAGTTACA -CAATGACATTCTCTTAGCTAAAGATACTACTGAAGCCTTTGAAAAAATGGTTTCACTACT -TTCTGTTTTGCTTTCCATGCAGGGTGCTGTAGACATAAACAAGCTTTGTGAAGAAATGCT -GGACAACAGGGCAACCTTACAAGCTATAGCCTCAGAGTTTAGTTCCCTTCCATCATATGC -AGCTTTTGCTACTGCTCAAGAAGCTTATGAGCAGGCTGTTGCTAATGGTGATTCTGAAGT -TGTTCTTAAAAAGTTGAAGAAGTCTTTGAATGTGGCTAAATCTGAATTTGACCGTGATGC -AGCCATGCAACGTAAGTTGGAAAAGATGGCTGATCAAGCTATGACCCAAATGTATAAACA -GGCTAGATCTGAGGACAAGAGGGCAAAAGTTACTAGTGCTATGCAGACAATGCTTTTCAC -TATGCTTAGAAAGTTGGATAATGATGCACTCAACAACATTATCAACAATGCAAGAGATGG -TTGTGTTCCCTTGAACATAATACCTCTTACAACAGCAGCCAAACTAATGGTTGTCATACC -AGACTATAACACATATAAAAATACGTGTGATGGTACAACATTTACTTATGCATCAGCATT -GTGGGAAATCCAACAGGTTGTAGATGCAGATAGTAAAATTGTTCAACTTAGTGAAATTAG -TATGGACAATTCACCTAATTTAGCATGGCCTCTTATTGTAACAGCTTTAAGGGCCAATTC -TGCTGTCAAATTACAGAATAATGAGCTTAGTCCTGTTGCACTACGACAGATGTCTTGTGC -TGCCGGTACTACACAAACTGCTTGCACTGATGACAATGCGTTAGCTTACTACAACACAAC -AAAGGGAGGTAGGTTTGTACTTGCACTGTTATCCGATTTACAGGATTTGAAATGGGCTAG -ATTCCCTAAGAGTGATGGAACTGGTACTATCTATACAGAACTGGAACCACCTTGTAGGTT -TGTTACAGACACACCTAAAGGTCCTAAAGTGAAGTATTTATACTTTATTAAAGGATTAAA -CAACCTAAATAGAGGTATGGTACTTGGTAGTTTAGCTGCCACAGTACGTCTACAAGCTGG -TAATGCAACAGAAGTGCCTGCCAATTCAACTGTATTATCTTTCTGTGCTTTTGCTGTAGA -TGCTGCTAAAGCTTACAAAGATTATCTAGCTAGTGGGGGACAACCAATCACTAATTGTGT -TAAGATGTTGTGTACACACACTGGTACTGGTCAGGCAATAACAGTTACACCGGAAGCCAA -TATGGATCAAGAATCCTTTGGTGGTGCATCGTGTTGTCTGTACTGCCGTTGCCACATAGA -TCATCCAAATCCTAAAGGATTTTGTGACTTAAAAGGTAAGTATGTACAAATACCTACAAC -TTGTGCTAATGACCCTGTGGGTTTTACACTTAAAAACACAGTCTGTACCGTCTGCGGTAT -GTGGAAAGGTTATGGCTGTAGTTGTGATCAACTCCGCGAACCCATGCTTCAGTCAGCTGA -TGCACAATCGTTTTTAAACGGGTTTGCGGTGTAAGTGCAGCCCGTCTTACACCGTGCGGC -ACAGGCACTAGTACTGATGTCGTATACAGGGCTTTTGACATCTACAATGATAAAGTAGCT -GGTTTTGCTAAATTCCTAAAAACTAATTGTTGCCGCTTCCAAGAAAAGGACGAAGATGAC -AATTTAATTGATTCTTACTTTGTAGTTAAGAGACACACTTTCTCTAACTACCAACATGAA -GAAACAATTTATAATTTACTTAAGGATTGTCCAGCTGTTGCTAAACATGACTTCTTTAAG -TTTAGAATAGACGGTGACATGGTACCACATATATCACGTCAACGTCTTACTAAATACACA -ATGGCAGACCTCGTCTATGCTTTAAGGCATTTTGATGAAGGTAATTGTGACACATTAAAA -GAAATACTTGTCACATACAATTGTTGTGATGATGATTATTTCAATAAAAAGGACTGGTAT -GATTTTGTAGAAAACCCAGATATATTACGCGTATACGCCAACTTAGGTGAACGTGTACGC -CAAGCTTTGTTAAAAACAGTACAATTCTGTGATGCCATGCGAAATGCTGGTATTGTTGGT -GTACTGACATTAGATAATCAAGATCTCAATGGTAACTGGTATGATTTCGGTGATTTCATA -CAAACCACGCCAGGTAGTGGAGTTCCTGTTGTAGATTCTTATTATTCATTGTTAATGCCT -ATATTAACCTTGACCAGGGCTTTAACTGCAGAGTCACATGTTGACACTGACTTAACAAAG -CCTTACATTAAGTGGGATTTGTTAAAATATGACTTCACGGAAGAGAGGTTAAAACTCTTT -GACCGTTATTTTAAATATTGGGATCAGACATACCACCCAAATTGTGTTAACTGTTTGGAT -GACAGATGCATTCTGCATTGTGCAAACTTTAATGTTTTATTCTCTACAGTGTTCCCACTT -ACAAGTTTTGGACCACTAGTGAGAAAAATATTTGTTGATGGTGTTCCATTTGTAGTTTCA -ACTGGATACCACTTCAGAGAGCTAGGTGTTGTACATAATCAGGATGTAAACTTACATAGC -TCTAGACTTAGTTTTAAGGAATTACTTGTGTATGCTGCTGACCCTGCTATGCACGCTGCT -TCTGGTAATCTATTACTAGATAAACGCACTACGTGCTTTTCAGTAGCTGCACTTACTAAC -AATGTTGCTTTTCAAACTGTCAAACCTGGTAATTTTAACAAAGACTTCTATGACTTTGCT -GTGTCTAAGGGTTTCTTTAAGGAAGGAAGTTCTGTTGAATTAAAACACTTCTTCTTTGCT -CAGGATGGTAATGCTGCTATCAGCGATTATGACTACTATCGTTATAATCTACCAACAATG -TGTGATATCAGACAACTACTATTTGTAGTTGAAGTTGTTGATAAGTACTTTGATTGTTAC -GATGGTGGCNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNCTACTGTAGTAATTGGAACAAGCAAATTCTATGGTGGTTGGCACAACATGTTAAAA -ACTGTTTATAGTGATGTAGAAAACCCTCATCTTATGGGTTGGGATTATCCTAAATGTGAT -AGAGCCATGCCTAACATGCTTAGAATTATGGCCTCACTTGTTCTTGCTCGCAAACATACA -ACGTGTTGTAGCTTGTCACACCGTTTCTATAGATTAGCTAATGAGTGTGCTCAAGTATTG -AGTGAAATGGTCATGTGTGGCGGTTCACTATATGTTAAACCAGGTGGAACCTCATCAGGA -GATGCCACAACTGCTTATGCTAATAGTGTTTTTAACATTTGTCAAGCTGTCACGGCCAAT -GTTAATGCACTTTTATCTACTGATGGTAACAAAATTGCCGATAAGTATGTCCGCAATTTA -CAACACAGACTTTATGAGTGTCTCTATAGAAATAGAGATGTTGACACAGACTTTGTGAAT -GAGTTTTACGCATATTTGCGTAAACATTTCTCAATGATGATACTCTCTGACGATGCTGTT -GTGTGTTTCAATAGCACTTATGCATCTCAAGGTCTAGTGGCTAGCATAAAGAACTTTAAG -TCAGTTCTTTATTATCAAAACAATGTTTTTATGTCTGAAGCAAAATGTTGGACTGAGACT -GACCTTACTAAAGGACCTCATGAATTTTGCTCTCAACATACAATGCTAGTTAAACAGGGT -GATGATTATGTGTACCTTCCTTACCCAGATCCATCAAGAATCCTAGGGGCCGGCTGTTTT -GTAGATGATATCGTAAAAACAGATGGTACACTTATGATTGAACGGTTCGTGTCTTTAGCT -ATAGATGCTTACCCACTTACTAAACATCCTAATCAGGAGTATGCTGATGTCTTTCATTTG -TACTTACAATACATAAGAAAGCTACATGATGAGTTAACAGGACACATGTTAGACATGTAT -TCTGTTATGCTTACTAATGATAACACCTCAAGGTATTNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNTGGTACTGGTAAGAGTCATTTT -GCTATTGGCCTAGCTCTCTACTACCCTTCTGCTCGCATAGTGTATACAGCTTGCTCTCAT -GCCGCTGTTGATGCACTATGTGAGAAGGCATTAAAATATTTGCCTATAGATAAATGTAGT -AGAATTATACCTGCACGTGCTCGTGTAGAGTGTTTTGATAAATTCAAAGTGAATTCAACA -TTAGAACAGTATGTCTTTTGTACTGTAAATGCATTGCCTGAGACGACAGCAGATATAGTT -GTCTTTGATGAAATTTCAATGGCCACAAATTATGATTTGAGTGTTGTCAATGCCAGATTA -CGTGCTAAGCACTATGTGTACATTGGCGACCCTGCTCAATTACCTGCACCACGCACATTG -CTAACTAAGGGCACACTAGAACCAGAATATTTCAATTCAGTGTGTAGACTTATGAAAACT -ATAGGTCCAGACATGTTCCTCGGAACTTGTCGGCGTTGTCCTGCTGAAATTGTTGACACT -GTGAGTGCTTTGGTTTATGATAATAGGCTTAAAGCACATAAAGACAAATCAGCTCAATGC -TTTAAAATGTTTTATAAGGGTGTTATCACGCATGATGTTTCATCTGCAATTAACAGGCCA -CAAATAGGCGTGGTAAGAGAATTCCTTACACGTAACCCTGCTTGGAGAAAAGCTGTCTTT -ATTTCACCTTATAATTCACAGAATGCTGTAGCCTCAAAGATTTTGGGACTACCAACTCAA -ACTGTTGATTCATCACAGGGCTCAGAATATGACTATGTCATATTCACTCAAACCACTGAA -ACAGCTCACTCTTGTAATGTAAACAGATTTAATGTTGCTATTACCAGAGCAAAAGTAGGC -ATACTTTGCATAATGTCTGATAGAGACCTTTATGACAAGTTGCAATTTACAAGTCTTGAA -ATTCCACGTAGGAATGTGGCAACTTTANNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNTATAAGACATGTACGTGCATGGATTGGCTTCGAT -GTCGAGGGGTGTCATGCTACTAGAGAAGCTGTTGGTACCAATTTACCTTTACAGCTAGGT -TTTTCTACAGGTGTTAACCTAGTTGCTGTACCTACAGGTTATGTTGATACACCTAATAAT -ACAGATTTTTCCAGAGTTAGTGCTAAACCACCGCCTGGAGATCAATTTAAACACCTCATA -CCACTTATGTACAAAGGACTTCCTTGGAATGTAGTGCGTATAAAGATTGTACAAATGTTA -AGTGACACACTTAAAAATCTCTCTGACAGAGTCGTATTTGTCTTATGGGCACATGGCTTT -GAGTTGACATCTATGAAGTATTTTGTGAAAATAGGACCTGAGCGCACCTGTTGTCTATGT -GATAGACGTGCCACATGCTTTTCCACTGCTTCAGACACTTATGCCTGTTGGCATCATTCT -ATTGGATTTGATTACGTCTATAATCCGTTTATGATTGATGTTCAACAATGGGGTTTTACA -GGTAACCTACAAAGCAACCATGATCTGTATTGTCAAGTCCATGGTAATGCACATGTAGCT -AGTTGTGATGCAATCATGACTAGGTGTCTAGCTGTCCACGAGTGCTTTGTTAAGCGTGTT -GACTGGACTATTGAATATCCTATAATTGGTGATGAACTGAAGATTAATGCGGCTTGTAGA -AAGGTTCAACACATGGTTGTTAAAGCTGCATTATTAGCAGACAAATTCCCAGTTCTTCAC -GACATTGGTAACCCTAAAGCTATTAAGTGTGTACCTCAAGCTGATGTAGAATGGAAGTTC -TATGATGCACAGCCTTGTAGTGACAAAGCTTATAAAATAGAAGAATTATTCTATTCTTAT -GCCACACATTCTGACAAATTCACAGATGGTGTATGCCTATTTTGGAATTGCAATGTCGAT -AGATATCCTGCTAATTCCATTGTTTGTAGATTTGACACTAGAGTGCTATCTAACCTTAAC -TTGCCTNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NACAAACAATTTGATACTTATAACCTCTGGAACACTTTTACAAGACTTCAGAGTTTAGAA -AATGTGGCTTTTAATGTTGTAAATAAGGGACACTTTGATGGACAACAGGGTGAAGTACCA -GTTTCTATCATTAATAACACTGTTTACACAAAAGTTGATGGTGTTGATGTAGAATTGTTT -GAAAATAAAACAACATTACCTGTTAATGTAGCATTTGAGCTTTGGGCTAAGCGCAACATT -AAACCAGTACCAGAGGTGAAAATACTCAATAATTTGGGTGTGGACATTGCTGCTAATACT -GTGATCTGGGACTACAAAAGAGATGCTCCAGCACATATATCTNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNTCTGTTATTGATTTATTACTTGATGATTTTGTT -GAAATAATAAAATCCCAAGATTTATCTGTAGTTTCTAAGGTTGTCAAAGTGACTATTGAC -TATACAGAAATTTCATTTATGCTTTGGTGTAAAGATGGCCATGTAGAAACATTTTACCCA -AAATTACAATCTAGTCAAGCGTGGCAACCGGGTGTTGCTATGCCTAATCTTTACAAAATG -CAAAGAATGCTATTAGAAAAGTGTGACCTTCAAAATTATGGTGATAGTGCAACATTACCT -AAAGGCATAATGATGAATGTCGCAAAATATACTCAACTGTGTCAATATTTAAACACATTA -ACATTAGCTGTACCCTATAATATGAGAGTTATACATTTTGGTGCTGGTTCTGATAAAGGA -GTTGCACCAGGTACAGCTGTTTTAAGACAGTGGTTGCCTACGGGTACGCTGCTTGTCGAT -TCAGATCTTAATGACTTTGTCTCTGATGCAGATTCAACTTTGATTGGTGATTGTGCAACT -GTACATACAGCTAATAAATGGGATCTCATTATTAGTGATATGTACGACCCTAAGACTAAA -AATGTTACAAAAGAAAATGACTCTAAAGAGGGTTTTTTCACTTACATTTGTGGGTTTATA -CAACAAAAGCTAGCTCTNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNTTACCACAAAAACAACAAAAGTTGGATGGAAAGTCA -GTTCAGAGTTTATTCTAGTGCGAATAATTGCACTTTTGAATATGTCTCTCAGCCTTTTCT -TATGGACCTTGAAGGAAAACAGGGTAATTTCAAAAATCTTAGGGAATTTGTGTTTAAGAA -TATTGATGGTTATTTTAAAATATATTCTAAGCACACGCCTATTAATTTAGTGCGTGATCT -CCCTCAGGGTTTTTCGGCTTTAGAACCATTGGTAGATTTGCCAATAGGTATTAACATCAC -TAGGTTTCAAACTTTACTTGCTTTACATAGAAGTTATTTGACTCCTGGTGATTCTNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNTAGATTTCCTAATATTACAAACTTGTG -CCCTTTTGGTGAAGTTTTTAACGCCACCAGATTTGCATCTGTTTATGCTTGGAACAGGAA -GAGAATCAGCAACTGTGTTGCTGATTATTCTGTCCTATATAATTCCGCATCATTTTCCAC -TTTTAAGTGTTATGGAGTGTCTCCTACTAAATTAAATGATCTCTGCTTTACTAATGTCTA -TGCAGATTCATTTGTAATTAGAGGTGATGAAGTCAGACAAATCGCTCCAGGGCAAACTGG -AAAGATTGCTGATTATAATTATAAATTACCAGATGATTTTACAGGCTGCGTTATAGCTTG -GAATTCTANNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNAAAAGTCTACTAATTTGGTTAAAAA -CAAATGTGTCAATTTCAACTTCAATGGTTTAACAGGCACAGGTGTTCTTACTGAGTCTAA -CAAAAAGTTTCTGCCTTTCCAACAATTTGGCAGAGACATTGATGACACTACTGATGCTGT -CCGTGATCCACAGACACTTGAGATTCTTGACATTACACCATGTTCTTTTGGTGGTGTCAG -TGTTATAACACCAGGAACAAATACTTCTAACCAGGTTGCTGTTCTTTATCAGGGTGTTAA -CTGCACAGAAGTCCCTGTTGCTATTCATGCAGATCAACTTACTCCTACTTGGCGTGTTTA -TTCTACAGGTTCTAATGTTTTTCAAACACGTNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNAATCTTTTGTTGCAATA -TGGCAGTTTTTGTACACAATTAAACCGTGCTTTAACTGGAATAGCTGTTGAACAAGACAA -AAACACCCAAGAAGTTTTTGCACAAGTCAAACAAATTTACAAAACACCACCAATTAAAGA -TTTTGGTGGTTTTAATTTTTCACAAATATTACCAGATCCATCAAAACCAAGCAAGAGGTC -ATTTATTGAAGATCTACTTTTCAACAAAGTGACACTTGCAGATGCTGGCTTCATCAAACA -ATATGGTGATTGCCTTGGTGATATTGCTGCTAGAGACCTCATTTGTGCACAAAAGTTTAA -CGGCCTTACTGTTTTGNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNTCAACCAAAATGC -ACAAGCTTTAAACACGCTTGTTAAACAACTTAGCTCCAATTTTGGTGCAATTTCAAGTGT -TTTAAATGATATCCTTGCACGTCTTGACAAAGTTGAGGCTGAAGTGCAAATTGATAGGTT -GATCACAGGCAGACTTCAAAGTTTGCAGACATATGTGACTCAACAATTAATTAGAGCTGC -AGAAATCAGAGCTTCTGCTAATCTTGCTGCTACTAAAATGTCAGAGTGTGTACTTGGACA -ATCAAAAAGAGTTGATTTTTGTGGAAAGGGCTATCATCTTATGTCCTTCCCTCAGTCAGC -ACCTCATGGTGTAGTCTTCTTGCATGTGACTTATGTCCCTGCACAAGAAAAGAACTTCAC -AACTGCTCCTGCCATTTGTCATGATGGAAAAGCACACTTTCCTCGTGAAGGTGTCTTTGT -TTCAAATGGCACACACTGGTTTGTAACACAAAGGAATTTTTATGAACCACAAATCATTAC -TACACACAACACATTTGTGTCTGGTAACTGTGATGTTGTAATAGGAATTGTCAACAACAC -AGTTTATGATCCTTTGCAACCTGAATTAGACTCATTCAAGGAGGAGTTAGATAAATATTT -TAAGAATCATACATCACCAGATGTTGATTTAGGTGACATCTCTGGCATTAATGCTTCAGT -TGTAAACATTCAAAAAGAAATTGACCGCCTCAATGAGGTTGCCAAGAATTTAAATGAATC -TCTCATCGATCTCCAAGAACTTGGAAAGTATGAGCAGTATATAAAATGGCCATGGTACAT -TTGGCTAGGTTTTATAGCTGGCTTGATTGCCATAGTAATGGTGACAATTATGCTTTGCTG -TATGACCAGTTGCTGTAGTTGTCTCAAGGGCTGTTGTTCTTGTGGATCCTGCTGCAAATT -TGATGAAGACGACTCTGAGCCAGTGCTCAAAGGAGTCAAATTACATTACACATAAACGAA -CTTATGGATTTGTTTATGAGAATCTTCACAATTGGAACTGTAACTTTGAAGCAAGGTGAA -ATCAAGGATGCTACTCCTTCAGATTTTGTTCGCGCTACTGCAACGATACCGATACAAGCC -TCACTCCCTTTCGGATGGCTTATTGTTGGCGTTGCACTTCTTGCTGTTTTTCAGAGCGCT -TCCAAAATCATAACCCTCAAAAAGAGATGGCAACTAGCACTCTCCAAGGGTGTTCACTTT -GTTTGCAACTTGCTGTTNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNGTTGCTGCT -GGCCTTGAAGCCCCTTTTCTCTATCTTTATGCTTTAGTCTACTTCTTGCAGAGTATAAAC -TTTGTAAGAATAATAATGAGGCTTTGGCTTTGCTGGAAATGCCGTTCCAAAAACCCATTA -CTTTATGATGCCAACTATTTTCTTTGCTGGCATACTAATTGTTACGACTATTGTATACCT -TACAATAGTGTAACTTCTTCAATTGTCATTACTTCAGGTGATGGCACAACAAGTCCTATT -TCTGAACATGACTACCAGATTGGTGGTTATACTGAAAAATNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNAGCACAAGCT -GATGAGTACGAACTTATGTACTCATTCGTTTCGGAAGAGACAGGTACGTTAATAGTTAAT -AGCGTACTTCTTTTTCTTGCTTTCGTGGTATTCTTGCTAGTTACACTAGCCATCCTTACT -GCGCTTCGATTGTGTGCGTACTGCTGCAATATTGTTAACGTGAGTCTTGTAAAACCTTCT -TTTTACGTTTACTCTCGTGTTAAAAATCTGAATTCTTCTAGAGTTCCTGATCTTCTGGTC -TAAACGAACTAAATATTATATTAGTTTTTCTGTTTGGAACTTTAATTTTAGCCATGGCAG -ATTCCAACGGTACTATTACCGTTGAAGAGCTTAAAAAGCTCCTTGAACAATGGAACCTAG -TAATAGGTTTCCTATTCCTTACATGGATTTGTCTTCTACAATTTGCCTATGCCAACAGGA -ATAGGTTTTTGTATATAATTAAGTTAATTTTCCTCTGGCTGTTATGGCCAGTAACTTTAG -CTTGTTTTGTGCTTGCTGCTGTTTACAGAATAAATTGGATCACCGGTGGAATTGCTATCG -CAATGGCTTGTCTTGTAGGCTTGATGTGGCTCAGCTACTTCATTGCTTCTTTCAGACTGT -TTGCGCGTACGCGTTCCATGTGGTCATTCAATCCAGAAACTAACATTCTTCTCAACGTGC -CACTCCATGGCACTATTCTGACCAGACCGCTTCTAGAAAGTGAACTCGTAATCGGAGCTG -TGATCCTTCGTGGACATCTTCGTATTGCTGGACACCATCTAGGACGCTGTGACATCAAGG -ACCTGCCTAAAGAAATCACTGTTGCTACATCACGAACGCTTTCTTATTACAAATTGGGAG -CTTCGCAGCGTGTAGCAGGTGACTCAGGTTTTGCTGCATACAGTCGCTACAGGATTGGCA -ACTATAAATTAAACACAGACCATTCCAGTAGCAGTGACAATATTGCTTTGCTTGTACAGT -AAGTGACAACAGATGTTTCATCTCGTTGACTTTCAGGTTACTATAGCAGAGATATTACTA -ATTATTATGAGGACTTTTAAAGTTTCCATTTGGAATCTTGATTACATCATAAACCTCATA -ATTAAAAATTTATCTAAGTCACTAACTGAGAATAAATATTCTCAATTAGATGAAGAGCAA -CCAATGGAGATTGATTAAACGAACATGAAAATTATTCTTTTCTTGGCACTGATAACACTC -GCTACTTGTGAGCTTTATCACTACCAAGAGTGTGTTAGAGGTACAACAGTACTTTTAAAA -GAACCTTGCTCTTCTGGAACATNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNTTCAGTNCATCGATATCGGTAATTATACAGTTTCCTGTTTACCTT -TTACAATTAATTGCCAGGAACCTAAATTGGGTAGTCTTGTAGTGCGTTGTTCGTTCTATG -AAGACTTTTTAGAGTATCATGACGTTCGTGTTGTTTTAGATTTCATCTAAACGAACAAAC -TAAATGTCTCTAAATGGACCCCAAAATCAGCGAAATGCACCCCGCATTACGTTTGGTGGA -CCCTCAGATTCAACTGGCAGTAACCAGAATGGAGAACGCAGTGGGGCGCGATCAAAACAA -CGTCGGCCCCAAGGTTTACCCAATAATACTGCGTCTTGGTTCACCGCTCTCACTCAACAT -GGCAAGGAAGACCTTAAATTCCCTCGAGGACAAGGCGTTCCAATTAACACCAATAGCAGT -CCAGATGACCAAATTGGCTACTACCGAAGAGCTACCAGACGAATTCGTGGTGGTGACGGT -AAAATGAAAGATCTCAGTCCAAGATGGTATTTCTACTACCTAGGAACTGGGCCAGAAGCT -GGACTTCCCTATGGTGCTAACAAAGACGGCATCATATGGGTTGCAACTGAGGGAGCCTTG -AATACACCAAAAGATCACATTGGCACCCGCAATCCTGCTAACAATGCTGCAATCGTGCTA -CAACTTCCTCAAGGAACAACATTGCCAAAAGGCTTCTACGCAGAAGGGAGCAGAGGCGGC -AGTCAAGCCTCTTCTCGTTCCTCATCACGTAGTCGCAACAGTTCAAGAAATTCAACTCCA -GGCAGCAGTAAACGAACTTCTCCTGCTAGAATGGCTGGCAATGGCGGTGATGCTGCTCTT -GCTTTGCTGCTGCTTGACAGATTGAACCAGCTTGAGAGCAAAATGTTTGGTAAAGGCCAA -CAACAACAAGGCCAAACTGTCACTAAGAAATCTGCTGCTGAGGCTTCTAAGAAGCCTCGG -CAAAAACGTACTGCCACTAAAGCATACAATGTAACACAAGCTTTCGGCAGACGTGGTCCA -GAACAAACCCAAGGAAATTTTGGGGACCAGGAACTAATCAGACAAGGAACTGATTACAAA -CATTGGCCGCAAATTGCACAATTTGCCCCCAGCGCTTCAGCGTTCTTCGGAATGTCGCGC -ATTGGCATGGAAGTCACACCTTCGGGAACGTGGTTGACCTACACAGGTGCCATCAAATTG -GATGACAAAGATCCAAATTTCAAAGATCAAGTCATTTTGCTGAATAAGCATATTGACGCA -TACAAAACATTCCCACCAACAGAGCCTAAAAAGGACAAAAAGAAGAAGGCTGATGAAACT -CAAGCCTTACCGCAGAGACAGAAGAAACAGCAAACTGTGACTCTTCTTCCTGCTGCAGAT -TTGGATGATTTCTCCAAACAATTGCAACAATCCATGAGCAGTGCTGACTCAACTCAGGCC -TAAACTCATGCAGACCACACAAGGCAGATGGGCTATATAAACGTTTTCGCTTTTCCGTTT -ACGATATATAGTCTACTCTTGTGCAGAATGAATTCTCGTAACTACATAGCACAAGTAGAT -GTAGTTAACTTTAATNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN -NNNNNNNNNNNNN diff --git a/inst/extdata/test.ini b/inst/extdata/test.ini index cf673bf4..7c6e20f2 100644 --- a/inst/extdata/test.ini +++ b/inst/extdata/test.ini @@ -1,8 +1,4 @@ user_name password host_name project_id comment dbms port -<<<<<<< HEAD "admin" "district" "https://play.dhis2.org/dev" "DHIS2_DEMO" "this is a test DHIS2 server" "DHIS2" "" -======= -"admin" "district" "https://play.dhis2.org/dev/" "DHIS2_DEMO" "this is a test DHIS2 server" "DHIS2" "" ->>>>>>> main "rfamro" "" "mysql-rfam-public.ebi.ac.uk" "Rfam" "this is a test MySQL server" "MySQL" 4497 "kmane" "9A81268476645C4E5F03428B8AC3AA7B" "https://bbmc.ouhsc.edu/redcap/api/" "SD_DATA" "testing access to REDCap project" "REDCap" "" diff --git a/man/check_dhis2_attributes.Rd b/man/check_dhis2_attributes.Rd deleted file mode 100644 index c4a72677..00000000 --- a/man/check_dhis2_attributes.Rd +++ /dev/null @@ -1,44 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/check_dhis2_attributes.R -\name{check_dhis2_attributes} -\alias{check_dhis2_attributes} -\title{Check the DHIS2 attributes for data import} -\usage{ -check_dhis2_attributes( - username, - password, - base_url, - dataset, - organisation_unit = NULL, - data_element_group = NULL -) -} -\arguments{ -\item{username}{the user name} - -\item{password}{the user's password} - -\item{base_url}{the web address of the server the user wishes to log in to} - -\item{dataset}{the dataSets identifiers} - -\item{organisation_unit}{the organisationUnits identifiers} - -\item{data_element_group}{the dataElementGroups identifiers} -} -\value{ -a list -} -\description{ -Check the DHIS2 attributes for data import -} -\examples{ -attributes <- check_dhis2_attributes( - username = "admin", - password = "district", - base_url = "https://play.dhis2.org/dev/", - dataset = "pBOMPrpg1QX", - organisation_unit = "DiszpKrYNg8", - data_element_group = NULL -) -} diff --git a/man/connect_to_server.Rd b/man/connect_to_server.Rd index c6085d1d..d72819ef 100644 --- a/man/connect_to_server.Rd +++ b/man/connect_to_server.Rd @@ -22,17 +22,12 @@ connect_to_server(dbms, driver_name, host, database_name, user, password, port) \item{port}{the server port ID} } \value{ -<<<<<<< HEAD the \code{connection} object -======= -the connection object ->>>>>>> main } \description{ Establish connection to the server } \examples{ -<<<<<<< HEAD \dontrun{ con <- connect_to_server( dbms = "MySQL", @@ -46,15 +41,3 @@ con <- connect_to_server( } } -======= -con <- connect_to_server( - dbms = "MySQL", - driver_name = "", - host = "mysql-rfam-public.ebi.ac.uk", - database_name = "Rfam", - user = "rfamro", - password = "", - port = 4497 -) -} ->>>>>>> main diff --git a/man/detect_separator.Rd b/man/detect_separator.Rd deleted file mode 100644 index 4f5d4b75..00000000 --- a/man/detect_separator.Rd +++ /dev/null @@ -1,22 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/read_from_file-helpers.R -\name{detect_separator} -\alias{detect_separator} -\title{Detect separator from a string} -\usage{ -detect_separator(x) -} -\arguments{ -\item{x}{a string} -} -\value{ -a vector of identified separators -} -\description{ -Detect separator from a string -} -\examples{ -sep <- detect_separator( - x = "My name is Karim" -) -} diff --git a/man/dhis2_subset_fields.Rd b/man/dhis2_subset_fields.Rd index 9c1dd821..13f88f45 100644 --- a/man/dhis2_subset_fields.Rd +++ b/man/dhis2_subset_fields.Rd @@ -4,7 +4,6 @@ \alias{dhis2_subset_fields} \title{Subset fields when reading from DHIS2} \usage{ -<<<<<<< HEAD dhis2_subset_fields(data, fields) } \arguments{ @@ -15,23 +14,11 @@ dhis2_subset_fields(data, fields) \value{ an object of type \code{data.frame} with the data that contains only the fields of interest -======= -dhis2_subset_fields(fields, data) -} -\arguments{ -\item{fields}{vector of fields to select from the data frame} - -\item{data}{the input data frame} -} -\value{ -the data frame with the fields of interest ->>>>>>> main } \description{ Subset fields when reading from DHIS2 } \examples{ -<<<<<<< HEAD \dontrun{ results <- dhis2_subset_fields( data = readepi( @@ -50,19 +37,3 @@ results <- dhis2_subset_fields( } } \keyword{internal} -======= -results <- dhis2_subset_fields( - fields = c("dataElement","period","value"), - data = readepi( - credentials_file = system.file("extdata", "test.ini", package = "readepi"), - project_id = "DHIS2_DEMO", - dataset = "pBOMPrpg1QX,BfMAe6Itzgt", - organisation_unit = "DiszpKrYNg8", - data_element_group = NULL, - start_date = "2014", - end_date = "2023", - fields = c("dataElement","period","value") - )$data -) -} ->>>>>>> main diff --git a/man/dhis2_subset_records.Rd b/man/dhis2_subset_records.Rd index 54fb3721..f8408663 100644 --- a/man/dhis2_subset_records.Rd +++ b/man/dhis2_subset_records.Rd @@ -2,7 +2,6 @@ % Please edit documentation in R/read_from_dhis2-helpers.R \name{dhis2_subset_records} \alias{dhis2_subset_records} -<<<<<<< HEAD \title{Subset a specified set of records from a dataset imported from DHIS2} \usage{ dhis2_subset_records(data, records, id_col_name) @@ -41,38 +40,3 @@ result <- dhis2_subset_records( } } \keyword{internal} -======= -\title{Title} -\usage{ -dhis2_subset_records(records, id_col_name, data) -} -\arguments{ -\item{records}{a vector of records to select from the data} - -\item{id_col_name}{the column name where the records belong to} - -\item{data}{the input data frame} -} -\value{ -a data frame with the records of interest -} -\description{ -Title -} -\examples{ -result <- dhis2_subset_records( - records = c("FTRrcoaog83", "eY5ehpbEsB7", "Ix2HsbDMLea"), - id_col_name = "dataElement", - data = readepi( - credentials_file = system.file("extdata", "test.ini", package = "readepi"), - project_id = "DHIS2_DEMO", - dataset = "pBOMPrpg1QX", - organisation_unit = "DiszpKrYNg8", - data_element_group = NULL, - start_date = "2014", - end_date = "2023" - )$data -) - -} ->>>>>>> main diff --git a/man/fetch_data_from_query.Rd b/man/fetch_data_from_query.Rd index eb8e2d01..80477576 100644 --- a/man/fetch_data_from_query.Rd +++ b/man/fetch_data_from_query.Rd @@ -36,18 +36,13 @@ fetch_data_from_query( \item{port}{the server port ID} } \value{ -<<<<<<< HEAD a \code{list} of 1 or more objects of type \code{data.frame} containing each data fetched from one table. -======= -a list with the data fetched from the tables of interest ->>>>>>> main } \description{ Fetch data from server using an SQL query } \examples{ -<<<<<<< HEAD \dontrun{ result <- fetch_data_from_query( source = "select author_id, name, last_name from author", @@ -61,18 +56,5 @@ result <- fetch_data_from_query( port = 4497 ) } -======= -result <- fetch_data_from_query( - source = "select author_id, name, last_name from author", - dbms = "MySQL", - tables = c("family_author", "author"), - driver_name = "", - host = "mysql-rfam-public.ebi.ac.uk", - database_name = "Rfam", - user = "rfamro", - password = "", - port = 4497 -) ->>>>>>> main } diff --git a/man/fingertips_subset_columns.Rd b/man/fingertips_subset_columns.Rd index 0288b028..9298c614 100644 --- a/man/fingertips_subset_columns.Rd +++ b/man/fingertips_subset_columns.Rd @@ -4,7 +4,6 @@ \alias{fingertips_subset_columns} \title{Subset columns when reading from Fingertips} \usage{ -<<<<<<< HEAD fingertips_subset_columns(data, fields) } \arguments{ @@ -15,23 +14,11 @@ fingertips_subset_columns(data, fields) \value{ an object of type \code{data.frame} with the Fingertips dataset that contains only the fields of interest -======= -fingertips_subset_columns(fields, data) -} -\arguments{ -\item{fields}{a vector or a comma-separated string of column names} - -\item{data}{the data read from Fingertips} -} -\value{ -a data frame with the columns of interest ->>>>>>> main } \description{ Subset columns when reading from Fingertips } \examples{ -<<<<<<< HEAD \dontrun{ res <- fingertips_subset_columns( data = readepi( @@ -43,14 +30,3 @@ res <- fingertips_subset_columns( } } \keyword{internal} -======= -res <- fingertips_subset_columns( - fields = c("IndicatorID", "AreaCode", "Age", "Value"), - data = readepi( - profile_id = 19, - area_type_id = 202 - )$data -) - -} ->>>>>>> main diff --git a/man/fingertips_subset_rows.Rd b/man/fingertips_subset_rows.Rd index 3d3b9853..96c4d0da 100644 --- a/man/fingertips_subset_rows.Rd +++ b/man/fingertips_subset_rows.Rd @@ -4,7 +4,6 @@ \alias{fingertips_subset_rows} \title{Subset records when reading from Fingertips} \usage{ -<<<<<<< HEAD fingertips_subset_rows(data, records, id_col_name) } \arguments{ @@ -17,25 +16,11 @@ fingertips_subset_rows(data, records, id_col_name) \value{ an object of type \code{data.frame} with the Fingertips dataset that contains only the records of interest -======= -fingertips_subset_rows(records, id_col_name, data) -} -\arguments{ -\item{records}{a vector or a comma-separated string of records} - -\item{id_col_name}{the column name with the subject IDs} - -\item{data}{the data read from Fingertips} -} -\value{ -a data frame with the records of interest ->>>>>>> main } \description{ Subset records when reading from Fingertips } \examples{ -<<<<<<< HEAD \dontrun{ res <- fingertips_subset_rows( data = readepi( @@ -48,15 +33,3 @@ res <- fingertips_subset_rows( } } \keyword{internal} -======= -res <- fingertips_subset_rows( - records = c("E92000001", "E12000002", "E12000009"), - id_col_name = "AreaCode", - data = readepi( - profile_id = 19, - area_type_id = 202 - )$data -) - -} ->>>>>>> main diff --git a/man/get_base_name.Rd b/man/get_base_name.Rd deleted file mode 100644 index d883ed4a..00000000 --- a/man/get_base_name.Rd +++ /dev/null @@ -1,22 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/read_from_file-helpers.R -\name{get_base_name} -\alias{get_base_name} -\title{Get file base name} -\usage{ -get_base_name(x) -} -\arguments{ -\item{x}{the file path} -} -\value{ -the file base name -} -\description{ -Get file base name -} -\examples{ -base_name <- get_base_name( - x = system.file("extdata", "test.txt", package = "readepi") -) -} diff --git a/man/get_data_elements.Rd b/man/get_data_elements.Rd deleted file mode 100644 index dac0595c..00000000 --- a/man/get_data_elements.Rd +++ /dev/null @@ -1,18 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/check_dhis2_attributes-helpers.R -\name{get_data_elements} -\alias{get_data_elements} -\title{Get the data element identifiers and names} -\usage{ -get_data_elements(base_url, username, password) -} -\arguments{ -\item{base_url}{the base URL of the DHIS2 server} - -\item{username}{the user name} - -\item{password}{the user's password} -} -\description{ -Get the data element identifiers and names -} diff --git a/man/get_data_sets.Rd b/man/get_data_sets.Rd deleted file mode 100644 index 2ec6b8e4..00000000 --- a/man/get_data_sets.Rd +++ /dev/null @@ -1,18 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/check_dhis2_attributes-helpers.R -\name{get_data_sets} -\alias{get_data_sets} -\title{Get the dataset identifiers and names} -\usage{ -get_data_sets(base_url, username, password) -} -\arguments{ -\item{base_url}{the base URL of the DHIS2 server} - -\item{username}{the user name} - -\item{password}{the user's password} -} -\description{ -Get the dataset identifiers and names -} diff --git a/man/get_extension.Rd b/man/get_extension.Rd deleted file mode 100644 index 34ccc3be..00000000 --- a/man/get_extension.Rd +++ /dev/null @@ -1,22 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/read_from_file-helpers.R -\name{get_extension} -\alias{get_extension} -\title{Get file extension} -\usage{ -get_extension(file_path) -} -\arguments{ -\item{file_path}{the target file path} -} -\value{ -a string that corresponds to the file extension -} -\description{ -Get file extension -} -\examples{ -ext <- get_extension( - file_path = system.file("extdata", "test.txt", package = "readepi") -) -} diff --git a/man/get_fingertips_metadata.Rd b/man/get_fingertips_metadata.Rd index 26698f8f..e23a7f6d 100644 --- a/man/get_fingertips_metadata.Rd +++ b/man/get_fingertips_metadata.Rd @@ -7,25 +7,15 @@ get_fingertips_metadata() } \value{ -<<<<<<< HEAD a \code{list} of 3 objects of type \code{data.frame}. They contain information about the indicators in the Fingertips repository. -======= -a list of data frames ->>>>>>> main } \description{ get fingertips metadata } \examples{ -<<<<<<< HEAD \dontrun{ metadata <- get_fingertips_metadata() } } \keyword{internal} -======= -metadata <- get_fingertips_metadata() - -} ->>>>>>> main diff --git a/man/get_id_column_name.Rd b/man/get_id_column_name.Rd index 81f8c762..6b839835 100644 --- a/man/get_id_column_name.Rd +++ b/man/get_id_column_name.Rd @@ -13,13 +13,10 @@ get_id_column_name(id_col_name, j, id_position) \item{id_position}{the id position} } -<<<<<<< HEAD \value{ a \code{list} of 2 elements of type \code{character} and \code{numeric} corresponding to the ID column name and position } -======= ->>>>>>> main \description{ get the id column name } diff --git a/man/get_ind_id_from_domain_id.Rd b/man/get_ind_id_from_domain_id.Rd index 3cbcd103..64cc8bdf 100644 --- a/man/get_ind_id_from_domain_id.Rd +++ b/man/get_ind_id_from_domain_id.Rd @@ -14,17 +14,12 @@ get_ind_id_from_domain_id(metadata, domain_id, indicator_name = NULL) \item{indicator_name}{the indicator name} } \value{ -<<<<<<< HEAD an object of type \code{numeric} that contains the indicator ID -======= -the indicator ID ->>>>>>> main } \description{ Get indicator ID from domain ID } \examples{ -<<<<<<< HEAD \dontrun{ indicator_id <- get_ind_id_from_domain_id( metadata = list( @@ -38,16 +33,3 @@ indicator_id <- get_ind_id_from_domain_id( } } \keyword{internal} -======= -indicator_id <- get_ind_id_from_domain_id( -metadata = list( - indicator_profile_domain = fingertipsR::indicators(), - indicator_ids_names = fingertipsR::indicators_unique(), - area_type = fingertipsR::area_types() - ), -domain_id = 1000041, -indicator_name = NULL -) - -} ->>>>>>> main diff --git a/man/get_ind_id_from_domain_name.Rd b/man/get_ind_id_from_domain_name.Rd index 93c10ca5..673ab797 100644 --- a/man/get_ind_id_from_domain_name.Rd +++ b/man/get_ind_id_from_domain_name.Rd @@ -14,17 +14,12 @@ get_ind_id_from_domain_name(metadata, domain_name, indicator_name = NULL) \item{indicator_name}{the indicator name} } \value{ -<<<<<<< HEAD an object of type \code{numeric} that contains the indicator ID -======= -the indicator ID ->>>>>>> main } \description{ Get indicator ID from domain name } \examples{ -<<<<<<< HEAD \dontrun{ indicator_id <- get_ind_id_from_domain_name( metadata = list( @@ -37,15 +32,3 @@ indicator_id <- get_ind_id_from_domain_name( } } \keyword{internal} -======= -indicator_id <- get_ind_id_from_domain_name( -metadata = list( - indicator_profile_domain = fingertipsR::indicators(), - indicator_ids_names = fingertipsR::indicators_unique(), - area_type = fingertipsR::area_types() - ), -domain_name = "B. Wider determinants of health", -) - -} ->>>>>>> main diff --git a/man/get_ind_id_from_ind_name.Rd b/man/get_ind_id_from_ind_name.Rd index bd6fcd22..65fc9a12 100644 --- a/man/get_ind_id_from_ind_name.Rd +++ b/man/get_ind_id_from_ind_name.Rd @@ -12,17 +12,12 @@ get_ind_id_from_ind_name(metadata, indicator_name) \item{indicator_name}{the indicator name} } \value{ -<<<<<<< HEAD an object of type \code{numeric} that contains the indicator ID -======= -the indicator ID ->>>>>>> main } \description{ Get indicator ID from indicator name } \examples{ -<<<<<<< HEAD \dontrun{ indicator_id <- get_ind_id_from_ind_name( metadata = list( @@ -35,15 +30,3 @@ indicator_id <- get_ind_id_from_ind_name( } } \keyword{internal} -======= -indicator_id <- get_ind_id_from_ind_name( -metadata = list( - indicator_profile_domain = fingertipsR::indicators(), - indicator_ids_names = fingertipsR::indicators_unique(), - area_type = fingertipsR::area_types() - ), -indicator_name = "Pupil absence" -) - -} ->>>>>>> main diff --git a/man/get_ind_id_from_profile.Rd b/man/get_ind_id_from_profile.Rd index 898cf07f..4c4cfa7c 100644 --- a/man/get_ind_id_from_profile.Rd +++ b/man/get_ind_id_from_profile.Rd @@ -27,17 +27,12 @@ get_ind_id_from_profile( \item{profile_id}{the profile ID} } \value{ -<<<<<<< HEAD an object of type \code{numeric} that contains the indicator ID -======= -the indicator ID ->>>>>>> main } \description{ Get indicator ID from profile ID and/or profile name } \examples{ -<<<<<<< HEAD \dontrun{ res <- get_ind_id_from_profile( metadata = list( @@ -50,15 +45,3 @@ res <- get_ind_id_from_profile( } } \keyword{internal} -======= -res <- get_ind_id_from_profile( -metadata = list( - indicator_profile_domain = fingertipsR::indicators(), - indicator_ids_names = fingertipsR::indicators_unique(), - area_type = fingertipsR::area_types() -), -profile_id = 19 -) - -} ->>>>>>> main diff --git a/man/get_organisation_units.Rd b/man/get_organisation_units.Rd deleted file mode 100644 index 87ca2b36..00000000 --- a/man/get_organisation_units.Rd +++ /dev/null @@ -1,18 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/check_dhis2_attributes-helpers.R -\name{get_organisation_units} -\alias{get_organisation_units} -\title{Get the organisation unit identifiers and names} -\usage{ -get_organisation_units(base_url, username, password) -} -\arguments{ -\item{base_url}{the base URL of the DHIS2 server} - -\item{username}{the user name} - -\item{password}{the user's password} -} -\description{ -Get the organisation unit identifiers and names -} diff --git a/man/get_profile_name.Rd b/man/get_profile_name.Rd index 670c2de5..7d8795e6 100644 --- a/man/get_profile_name.Rd +++ b/man/get_profile_name.Rd @@ -14,18 +14,13 @@ get_profile_name(profile_id, profile_name, metadata) \item{metadata}{the Fingertips metadata} } \value{ -<<<<<<< HEAD a \code{list} of 2 elements of type \code{character} and \code{numeric}. These are the \verb{profile name} and their correspondent indexes. -======= -a list with the profile name and their correspondent indexes ->>>>>>> main } \description{ Get profile name from Fingertips } \examples{ -<<<<<<< HEAD \dontrun{ res <- get_profile_name( profile_id = 19, @@ -39,16 +34,3 @@ res <- get_profile_name( } } \keyword{internal} -======= -res <- get_profile_name( -profile_id = 19, -profile_name = "Public Health Outcomes Framework", -metadata = list( - indicator_profile_domain = fingertipsR::indicators(), - indicator_ids_names = fingertipsR::indicators_unique(), - area_type = fingertipsR::area_types() - ) -) - -} ->>>>>>> main diff --git a/man/get_read_file_args.Rd b/man/get_read_file_args.Rd deleted file mode 100644 index 9546ec42..00000000 --- a/man/get_read_file_args.Rd +++ /dev/null @@ -1,27 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/readepi_helpers.R -\name{get_read_file_args} -\alias{get_read_file_args} -\title{Get arguments for reading from files} -\usage{ -get_read_file_args(args_list) -} -\arguments{ -\item{args_list}{a list of user specified arguments} -} -\value{ -a list of the parameters to be used for reading from file -} -\description{ -Get arguments for reading from files -} -\examples{ -args_list <- get_read_file_args( - list( - sep = "\t", - format = ".txt", - which = NULL - ) -) - -} diff --git a/man/get_read_fingertips_args.Rd b/man/get_read_fingertips_args.Rd index a0de9f6a..33b85301 100644 --- a/man/get_read_fingertips_args.Rd +++ b/man/get_read_fingertips_args.Rd @@ -7,24 +7,16 @@ get_read_fingertips_args(args_list) } \arguments{ -<<<<<<< HEAD \item{args_list}{a \code{list} of user specified arguments} } \value{ a \code{list} of 8 elements of type \code{character} or \code{numeric} that will be used for importing data from Fingertips -======= -\item{args_list}{a list of user specified arguments} -} -\value{ -a list of the parameters to be used for reading from Fingertips ->>>>>>> main } \description{ Get arguments for reading from Fingertips } \examples{ -<<<<<<< HEAD \dontrun{ args_list <- get_read_fingertips_args( list( @@ -35,12 +27,3 @@ args_list <- get_read_fingertips_args( } } \keyword{internal} -======= -args_list <- get_read_fingertips_args( - list( - indicator_id = 90362, - area_type_id = 202 - ) -) -} ->>>>>>> main diff --git a/man/get_relevant_data_elt_group.Rd b/man/get_relevant_data_elt_group.Rd deleted file mode 100644 index 5d775ae8..00000000 --- a/man/get_relevant_data_elt_group.Rd +++ /dev/null @@ -1,23 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/check_dhis2_attributes-helpers.R -\name{get_relevant_data_elt_group} -\alias{get_relevant_data_elt_group} -\title{Get the relevant data element groups} -\usage{ -get_relevant_data_elt_group(data_element_group, base_url, username, password) -} -\arguments{ -\item{data_element_group}{the dataElementGroups identifiers} - -\item{base_url}{the web address of the server the user wishes to log in to} - -\item{username}{the user name} - -\item{password}{the user's password} -} -\value{ -a list with the data elements of interest -} -\description{ -Get the relevant data element groups -} diff --git a/man/get_relevant_dataset.Rd b/man/get_relevant_dataset.Rd deleted file mode 100644 index 589f7cb7..00000000 --- a/man/get_relevant_dataset.Rd +++ /dev/null @@ -1,31 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/check_dhis2_attributes-helpers.R -\name{get_relevant_dataset} -\alias{get_relevant_dataset} -\title{Get the relevant dataset} -\usage{ -get_relevant_dataset(dataset, base_url, username, password) -} -\arguments{ -\item{dataset}{the dataSets identifiers} - -\item{base_url}{the web address of the server the user wishes to log in to} - -\item{username}{the user name} - -\item{password}{the user's password} -} -\value{ -a list with the relevant datasets -} -\description{ -Get the relevant dataset -} -\examples{ -result <- get_relevant_dataset( - dataset = "pBOMPrpg1QX,BfMAe6Itzgt", - base_url = "https://play.dhis2.org/dev/", - username = "admin", - password = "district" -) -} diff --git a/man/get_relevant_organisation_unit.Rd b/man/get_relevant_organisation_unit.Rd deleted file mode 100644 index d8488b99..00000000 --- a/man/get_relevant_organisation_unit.Rd +++ /dev/null @@ -1,31 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/check_dhis2_attributes-helpers.R -\name{get_relevant_organisation_unit} -\alias{get_relevant_organisation_unit} -\title{Get the relevant organisation units} -\usage{ -get_relevant_organisation_unit(organisation_unit, base_url, username, password) -} -\arguments{ -\item{organisation_unit}{the organisationUnits identifiers} - -\item{base_url}{the web address of the server the user wishes to log in to} - -\item{username}{the user name} - -\item{password}{the user's password} -} -\value{ -a list with the relevant organisation units -} -\description{ -Get the relevant organisation units -} -\examples{ -result <- get_relevant_organisation_unit( - organisation_unit = "DiszpKrYNg8", - base_url = "https://play.dhis2.org/dev/", - username = "admin", - password = "district" -) -} diff --git a/man/identify_table_name.Rd b/man/identify_table_name.Rd index 2a70997f..0dbda44b 100644 --- a/man/identify_table_name.Rd +++ b/man/identify_table_name.Rd @@ -12,28 +12,17 @@ identify_table_name(query, tables) \item{tables}{the list of all tables from the database} } \value{ -<<<<<<< HEAD a \code{character} with the extracted table name(s) from the SQL query -======= -the table name of interest ->>>>>>> main } \description{ Detect table names from an SQL query } \examples{ -<<<<<<< HEAD \dontrun{ table_name <- identify_table_name( query = "select * from author", tables = c("family_author", "author", "test") ) } -======= -table_name = identify_table_name( - query = "select * from author", - tables = c("family_author", "author", "test") -) ->>>>>>> main } diff --git a/man/import_redcap_data.Rd b/man/import_redcap_data.Rd index 2eabf1d5..7fb18d08 100644 --- a/man/import_redcap_data.Rd +++ b/man/import_redcap_data.Rd @@ -22,7 +22,6 @@ the subjects} \item{id_col_name}{the column name with the subject IDs} } \value{ -<<<<<<< HEAD a \code{list} of 2 elements of type \code{data.frame}. These are the dataset of interest and its associated metadata. } @@ -45,23 +44,3 @@ result <- import_redcap_data( } } -======= -a list with the data of interest and its associated metadata -} -\description{ -This is a wrapper across all the use case of reading data from -REDCap i.e. around the function that all records and fields from the project, -around the function that read specific records/fields or both at the same -time -} -\examples{ -result = import_redcap_data( - uri = "https://bbmc.ouhsc.edu/redcap/api/", - token = "9A81268476645C4E5F03428B8AC3AA7B", - records = c("1", "3", "5"), - fields = c("record_id", "name_first", "age", "bmi"), - id_col_name = NULL, - id_position = 1 -) -} ->>>>>>> main diff --git a/man/login.Rd b/man/login.Rd index 30c89135..39816501 100644 --- a/man/login.Rd +++ b/man/login.Rd @@ -14,13 +14,8 @@ login(username, password, base_url) \item{base_url}{the base URL of the DHIS2 server} } \description{ -<<<<<<< HEAD If the user were granted with access to the API, this will return a message specifying that the user was successfully connected. Otherwise, it will throw an error message. } \keyword{internal} -======= -Check DHIS2 authentication details -} ->>>>>>> main diff --git a/man/read_credentials.Rd b/man/read_credentials.Rd index a6d3e822..6370f2c1 100644 --- a/man/read_credentials.Rd +++ b/man/read_credentials.Rd @@ -6,31 +6,18 @@ \usage{ read_credentials( file_path = system.file("extdata", "test.ini", package = "readepi"), -<<<<<<< HEAD url = "mysql-rfam-public.ebi.ac.uk" -======= - project_id = NULL ->>>>>>> main ) } \arguments{ \item{file_path}{the path to the file with the user-specific credential details for the projects of interest.} -<<<<<<< HEAD \item{url}{the URL of the HIS of interest} } \value{ a \code{list} of 5 elements of type \code{character} or \code{numeric}. These correspond to the user's credential details. -======= -\item{project_id}{for relational DB, this is the name of the database -that contains the table from which the data should be pulled. Otherwise, -it is the project ID you were given access to.} -} -\value{ -a list with the user credential details. ->>>>>>> main } \description{ Read credentials from a configuration file @@ -39,15 +26,8 @@ Read credentials from a configuration file \dontrun{ credentials <- read_credentials( file_path = system.file("extdata", "test.ini", package = "readepi"), -<<<<<<< HEAD url = "mysql-rfam-public.ebi.ac.uk" ) } } \keyword{internal} -======= - project_id = "Rfam" -) -} -} ->>>>>>> main diff --git a/man/read_files.Rd b/man/read_files.Rd deleted file mode 100644 index 408819e2..00000000 --- a/man/read_files.Rd +++ /dev/null @@ -1,23 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/read_from_file-helpers.R -\name{read_files} -\alias{read_files} -\title{Sub-function for reading files using rio package} -\usage{ -read_files(sep, file_path, which, format) -} -\arguments{ -\item{sep}{the separator between the columns in the file} - -\item{file_path}{the path to the file to be read} - -\item{which}{a string used to specify the name of the excel sheet to import} - -\item{format}{a string used to specify the file format} -} -\value{ -a list of data frames where each contains data from a file -} -\description{ -Sub-function for reading files using rio package -} diff --git a/man/read_files_in_directory.Rd b/man/read_files_in_directory.Rd deleted file mode 100644 index a254a57f..00000000 --- a/man/read_files_in_directory.Rd +++ /dev/null @@ -1,19 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/read_from_file-helpers.R -\name{read_files_in_directory} -\alias{read_files_in_directory} -\title{Sub-function for reading file in a directory} -\usage{ -read_files_in_directory(file_path, pattern) -} -\arguments{ -\item{file_path}{the path to the file to be read} - -\item{pattern}{when specified, only files with this suffix will be imported} -} -\value{ -a list of data frames where each contains data read from a file -} -\description{ -Sub-function for reading file in a directory -} diff --git a/man/read_from_dhis2.Rd b/man/read_from_dhis2.Rd index a6f3927d..3b9aadf2 100644 --- a/man/read_from_dhis2.Rd +++ b/man/read_from_dhis2.Rd @@ -13,13 +13,8 @@ read_from_dhis2( data_element_group, start_date, end_date, -<<<<<<< HEAD records = NULL, fields = NULL, -======= - records, - fields, ->>>>>>> main id_col_name = "dataElement" ) } @@ -52,16 +47,11 @@ If provided, only those columns will be imported.} \item{id_col_name}{the column name with the records of interest.} } \value{ -<<<<<<< HEAD a \code{list} of 1 element of type \verb{data frame}. -======= -a list of data frames ->>>>>>> main } \description{ Import data form DHIS2 into R } -<<<<<<< HEAD \examples{ \dontrun{ data <- read_from_dhis2( @@ -80,5 +70,3 @@ data <- read_from_dhis2( } } \keyword{internal} -======= ->>>>>>> main diff --git a/man/read_from_file.Rd b/man/read_from_file.Rd deleted file mode 100644 index 292914c5..00000000 --- a/man/read_from_file.Rd +++ /dev/null @@ -1,46 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/read_from_file.R -\name{read_from_file} -\alias{read_from_file} -\title{Read data from file or directory} -\usage{ -read_from_file( - file_path, - sep = NULL, - format = NULL, - which = NULL, - pattern = NULL -) -} -\arguments{ -\item{file_path}{the path to the file to be read. When several files need to -be imported from a directory, this should be the path to that directory} - -\item{sep}{the separator between the columns in the file. This is only -required for space-separated files} - -\item{format}{a string used to specify the file format. This is useful when -a file does not have an extension, or has a file extension that does not -match its actual type} - -\item{which}{a string used to specify the name of the excel sheet to import} - -\item{pattern}{when specified, only files with this suffix will be imported -from the specified directory} -} -\value{ -a list of 1 (when reading from file) or several (when reading from -directory or reading several excel sheets) data frames -} -\description{ -Read data from file or directory -} -\examples{ -data <- read_from_file( - file_path = system.file("extdata", "test.txt", package = "readepi"), - sep = NULL, - format = NULL, - which = NULL, - pattern = NULL -) -} diff --git a/man/read_from_fingertips.Rd b/man/read_from_fingertips.Rd index 09a47ee7..0629c8bd 100644 --- a/man/read_from_fingertips.Rd +++ b/man/read_from_fingertips.Rd @@ -7,11 +7,7 @@ read_from_fingertips( indicator_id = NULL, indicator_name = NULL, -<<<<<<< HEAD area_type_id = NULL, -======= - area_type_id, ->>>>>>> main parent_area_type_id = NULL, profile_id = NULL, profile_name = NULL, @@ -53,24 +49,15 @@ this can be provided using the \code{id_col_name} argument} \item{id_col_name}{the column name with the subject IDs.} } \value{ -<<<<<<< HEAD a \code{list} of 1 element of type \code{data.frame}. This contains the imported dataset of interest -======= -a data frame ->>>>>>> main } \description{ Read from Fingertips } \examples{ -<<<<<<< HEAD \dontrun{ data <- read_from_fingertips(indicator_id = 90362, area_type_id = 202) } } \keyword{internal} -======= -data <- read_from_fingertips(indicator_id = 90362, area_type_id = 202) -} ->>>>>>> main diff --git a/man/read_from_redcap.Rd b/man/read_from_redcap.Rd index 2e8d9f45..844fc0c7 100644 --- a/man/read_from_redcap.Rd +++ b/man/read_from_redcap.Rd @@ -33,19 +33,13 @@ be imported.} If provided, only those columns will be imported.} } \value{ -<<<<<<< HEAD a \code{list} of 2 elements of type \code{data.frame}. They include a data frame of the dataset of interest and its associated metadata. -======= -a list with 2 data frames: the data of interest and the metadata -associated to the data. ->>>>>>> main } \description{ Import data from REDCap into R } \examples{ -<<<<<<< HEAD \dontrun{ redcap_data <- read_from_redcap( uri = "https://bbmc.ouhsc.edu/redcap/api/", @@ -54,15 +48,6 @@ redcap_data <- read_from_redcap( id_col_name = NULL, records = NULL, fields = NULL -======= -redcap_data <- read_from_redcap( - uri = "https://bbmc.ouhsc.edu/redcap/api/", - token = "9A81268476645C4E5F03428B8AC3AA7B", - id_position = 1, - id_col_name = NULL, - records = NULL, - fields = NULL ->>>>>>> main ) } } diff --git a/man/read_multiple_files.Rd b/man/read_multiple_files.Rd deleted file mode 100644 index dd8f9fd9..00000000 --- a/man/read_multiple_files.Rd +++ /dev/null @@ -1,26 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/read_from_file-helpers.R -\name{read_multiple_files} -\alias{read_multiple_files} -\title{Read multiple files, including multiple files in a directory} -\usage{ -read_multiple_files(files, dirs, format = NULL, which = NULL) -} -\arguments{ -\item{files}{a file or vector of file path to import} - -\item{dirs}{a directory or a vector of directories where files will be -imported from} - -\item{format}{a string used to specify the file format. This is useful when a -file does not have an extension, or has a file extension that does not match -its actual type} - -\item{which}{a string used to specify the name of the excel sheet to import} -} -\value{ -a list of data frames where each data frame contains data from a file -} -\description{ -Read multiple files, including multiple files in a directory -} diff --git a/man/read_rio_formats.Rd b/man/read_rio_formats.Rd deleted file mode 100644 index 8987fa51..00000000 --- a/man/read_rio_formats.Rd +++ /dev/null @@ -1,25 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/read_from_file-helpers.R -\name{read_rio_formats} -\alias{read_rio_formats} -\title{Title} -\usage{ -read_rio_formats(files_extensions, rio_extensions, files, files_base_names) -} -\arguments{ -\item{files_extensions}{a vector a file extensions made from your files of -interest} - -\item{rio_extensions}{a vector of files extensions supported by the rio -package} - -\item{files}{a vector a files of interest} - -\item{files_base_names}{a vector of file base} -} -\value{ -a list a the parameters needed to import data using rio -} -\description{ -Title -} diff --git a/man/readepi.Rd b/man/readepi.Rd index df0384d9..33c07ca7 100644 --- a/man/readepi.Rd +++ b/man/readepi.Rd @@ -2,18 +2,10 @@ % Please edit documentation in R/readepi.R \name{readepi} \alias{readepi} -<<<<<<< HEAD \title{Import data from different data_sources into R} \usage{ readepi( data_source = NULL, -======= -\title{Import data from different sources into R} -\usage{ -readepi( - credentials_file = NULL, - file_path = NULL, ->>>>>>> main records = NULL, fields = NULL, id_position = NULL, @@ -22,7 +14,6 @@ readepi( ) } \arguments{ -<<<<<<< HEAD \item{data_source}{the URL of the HIS} \item{records}{a vector or a comma-separated string of subject IDs. @@ -50,66 +41,12 @@ systems (DBMS) and website of public data collection. } \examples{ # reading from a MySQL server +\dontrun{ data <- readepi( data_source = "mysql-rfam-public.ebi.ac.uk", credentials_file = system.file("extdata", "test.ini", package = "readepi"), driver_name = "", from = "author" -======= -\item{credentials_file}{the path to the file with the user-specific -credential details -for the projects of interest. It is required when importing data from DBMS. -This is a tab-delimited file with the following columns: -\enumerate{ -\item user_name: the user name -\item password: the user password (for REDCap, this corresponds to the -\strong{token} that serves as password to the project) -\item host_name: the host name (for MS SQL servers) or the URI (for REDCap) -\item project_id: the project ID or the name of the database -you are access to. -\item comment: a summary description about the project or database -of interest -\item dbms: the name of the DBMS: Possible values are: 'REDCap', -'SQLServer', 'MySQL', 'PostgreSQL', etc... -\item port: the port ID -} -Use the \code{show_example_file()} function to display the structure of -the template credentials file} - -\item{file_path}{the path to the file to be read. When several files need to -be imported from a directory, this should be the path to that directory} - -\item{records}{a vector or a comma-separated string of subject IDs. -When specified, only these records will be imported.} - -\item{fields}{a vector or a comma-separated string of column names. -If provided, only those columns will be imported.} - -\item{id_position}{the column position of the variable that unique identifies -the subjects. When the name of the column with the subject IDs is known, -this can be provided using the \code{id_col_name} argument} - -\item{id_col_name}{the column name with the subject IDs.} - -\item{...}{additional arguments passed to the readepi function. -These are enumarated in the vignette.} -} -\value{ -a list of data frames. -} -\description{ -the function allows import of data from files, folders, or -health information systems (HIS) -The HIS consist of database management systems (DBMS) and website of public -data collection. -} -\examples{ -# reading from a MS SQL server -data <- readepi( - credentials_file = system.file("extdata", "test.ini", package = "readepi"), - project_id = "Rfam", - driver_name = "", - source = "author" ->>>>>>> main ) } +} diff --git a/man/redcap_get_results.Rd b/man/redcap_get_results.Rd index 333f4fba..dcc5dae0 100644 --- a/man/redcap_get_results.Rd +++ b/man/redcap_get_results.Rd @@ -12,19 +12,13 @@ redcap_get_results(redcap_data, metadata) \item{metadata}{the object with redcap metadata} } \value{ -<<<<<<< HEAD a \code{list} of 2 elements of type \code{data.frame}. These are the dataset of interest and its associated metadata. -======= -a list with the redcap dataset and its associated metadata as -data frames ->>>>>>> main } \description{ Check and return data fetch from redcap } \examples{ -<<<<<<< HEAD \dontrun{ result <- redcap_get_results( redcap_data = REDCapR::redcap_read( @@ -45,22 +39,3 @@ result <- redcap_get_results( } } -======= -result <- redcap_get_results( -redcap_data = REDCapR::redcap_read( - redcap_uri = "https://bbmc.ouhsc.edu/redcap/api/", - token = "9A81268476645C4E5F03428B8AC3AA7B", - records = c("1", "3", "5"), - fields = c("record_id", "name_first", "age", "bmi"), - verbose = FALSE, - id_position = 1L - ), -metadata = REDCapR::redcap_metadata_read( - redcap_uri = "https://bbmc.ouhsc.edu/redcap/api/", - token = "9A81268476645C4E5F03428B8AC3AA7B", - fields = NULL, - verbose = FALSE - ) -) -} ->>>>>>> main diff --git a/man/redcap_read.Rd b/man/redcap_read.Rd deleted file mode 100644 index 85c46166..00000000 --- a/man/redcap_read.Rd +++ /dev/null @@ -1,23 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/read_from_redcap-helpers.R -\name{redcap_read} -\alias{redcap_read} -\title{Read all rows and columns from redcap} -\usage{ -redcap_read(uri, token, id_position) -} -\arguments{ -\item{uri}{the URI of the REDCap project} - -\item{token}{the user-specific string that serves as the password for a -project} - -\item{id_position}{the column position of the variable that unique identifies -the subjects} -} -\value{ -a list with the project data and its associated metadata -} -\description{ -Read all rows and columns from redcap -} diff --git a/man/redcap_read_fields.Rd b/man/redcap_read_fields.Rd index 5871871e..67acf0b8 100644 --- a/man/redcap_read_fields.Rd +++ b/man/redcap_read_fields.Rd @@ -18,13 +18,8 @@ project} the subjects} } \value{ -<<<<<<< HEAD a \code{list} of 2 elements of type \code{data.frame} that contain the project data with the fields of interest and its associated metadata. -======= -a list with the project data and its associated metadata with the -fields of interest ->>>>>>> main } \description{ Subset fields from a REDCap project diff --git a/man/redcap_read_records.Rd b/man/redcap_read_records.Rd index 1b055d9e..9dd36922 100644 --- a/man/redcap_read_records.Rd +++ b/man/redcap_read_records.Rd @@ -20,13 +20,8 @@ the subjects} \item{id_col_name}{the column name with the subject IDs} } \value{ -<<<<<<< HEAD a \code{list} of 2 elements of type \code{data.frame} that contain the project data with the records of interest and its associated metadata. -======= -a list with the project data and its associated metadata with the -records of interest ->>>>>>> main } \description{ Subset records from a REDCap project diff --git a/man/redcap_read_rows_columns.Rd b/man/redcap_read_rows_columns.Rd index 205c1176..eb71eb50 100644 --- a/man/redcap_read_rows_columns.Rd +++ b/man/redcap_read_rows_columns.Rd @@ -22,14 +22,9 @@ the subjects} \item{records}{a vector or a comma-separated string of subset of subject IDs} } \value{ -<<<<<<< HEAD a \code{list} of 2 elements of type \code{data.frame} that contain the project data with only the records and fields of interest and its associated metadata. -======= -a list with the project data and its associated metadata with the -fields and records of interest ->>>>>>> main } \description{ Subset records and columns from a REDCap project diff --git a/man/show_tables.Rd b/man/show_tables.Rd index 43b915cf..64e4f6aa 100644 --- a/man/show_tables.Rd +++ b/man/show_tables.Rd @@ -4,36 +4,21 @@ \alias{show_tables} \title{Display the list of tables in a database} \usage{ -<<<<<<< HEAD show_tables(data_source, credentials_file, driver_name) } \arguments{ \item{data_source}{the URL of the HIS of interest} -======= -show_tables(credentials_file, project_id, driver_name) -} -\arguments{ ->>>>>>> main \item{credentials_file}{the path to the file with the user-specific credential details for the projects of interest. See the help of the \code{readepi} function for more details.} -<<<<<<< HEAD -======= -\item{project_id}{the name of the target database} - ->>>>>>> main \item{driver_name}{the name of the MS driver. use \code{odbc::odbcListDrivers()} to display the list of installed drivers} } \value{ -<<<<<<< HEAD a \code{character} that contains the list of all tables found in the specified database -======= -the list of tables in the specified database ->>>>>>> main } \description{ Display the list of tables in a database @@ -41,16 +26,10 @@ Display the list of tables in a database \examples{ \dontrun{ show_tables( -<<<<<<< HEAD credentials_file = system.file("extdata", "test.ini", package = "readepi"), data_source = "mysql-rfam-public.ebi.ac.uk", driver_name = "" -======= - credentials_file = system.file("extdata", "test.ini", package = "readepi"), - project_id = "Rfam", - driver_name = "" ->>>>>>> main ) } } diff --git a/man/sql_select_data.Rd b/man/sql_select_data.Rd index 007c0191..21893623 100644 --- a/man/sql_select_data.Rd +++ b/man/sql_select_data.Rd @@ -48,18 +48,13 @@ unique identifies the subjects in each table} \item{port}{the server port ID} } \value{ -<<<<<<< HEAD a \code{list} of 1 or more elements of type \code{data.frame} where every element contains the subset of the data from the corresponding table -======= -a subset of the data in the specified tables ->>>>>>> main } \description{ Subset data read from servers } \examples{ -<<<<<<< HEAD \dontrun{ result <- sql_select_data( table_names = "author", @@ -76,21 +71,5 @@ result <- sql_select_data( port = 4497 ) } -======= -result = sql_select_data( - table_names = "author", - dbms = "MySQL", - id_col_name = "author_id", - fields = c("author_id", "name"), - records = NULL, - id_position = NULL, - driver_name = "", - host = "mysql-rfam-public.ebi.ac.uk", - database_name = "Rfam", - user = "rfamro", - password = "", - port = 4497 -) ->>>>>>> main } diff --git a/man/sql_select_entire_dataset.Rd b/man/sql_select_entire_dataset.Rd index c5b37d45..1fb9b4c2 100644 --- a/man/sql_select_entire_dataset.Rd +++ b/man/sql_select_entire_dataset.Rd @@ -33,18 +33,13 @@ sql_select_entire_dataset( \item{port}{the server port ID} } \value{ -<<<<<<< HEAD an object of type \code{data.frame} with the entire dataset fetched from the specified table -======= -a data frame with the entire dataset that is contained in the table ->>>>>>> main } \description{ Fetch entire dataset in a table } \examples{ -<<<<<<< HEAD \dontrun{ result <- sql_select_entire_dataset( table = "author", @@ -57,17 +52,5 @@ result <- sql_select_entire_dataset( port = 4497 ) } -======= -result <- sql_select_entire_dataset( - table = "author", - dbms = "MySQL", - driver_name = "", - host = "mysql-rfam-public.ebi.ac.uk", - database_name = "Rfam", - user = "rfamro", - password = "", - port = 4497 -) ->>>>>>> main } diff --git a/man/sql_select_fields_only.Rd b/man/sql_select_fields_only.Rd index 5ca4dbda..232fabf7 100644 --- a/man/sql_select_fields_only.Rd +++ b/man/sql_select_fields_only.Rd @@ -36,18 +36,13 @@ sql_select_fields_only( \item{port}{the server port ID} } \value{ -<<<<<<< HEAD an object of type \code{data.frame} that contains the data fetched from the specific table with only the fields of interest. -======= -a data frame with the specified fields ->>>>>>> main } \description{ Select specified fields from a table } \examples{ -<<<<<<< HEAD \dontrun{ result <- sql_select_fields_only( table = "author", @@ -61,18 +56,5 @@ result <- sql_select_fields_only( port = 4497 ) } -======= -result <- sql_select_fields_only( - table = "author", - field = c("author_id", "name", "last_name"), - dbms = "MySQL", - driver_name = "", - host = "mysql-rfam-public.ebi.ac.uk", - database_name = "Rfam", - user = "rfamro", - password = "", - port = 4497 -) ->>>>>>> main } diff --git a/man/sql_select_records_and_fields.Rd b/man/sql_select_records_and_fields.Rd index 5d408b00..b2d5af12 100644 --- a/man/sql_select_records_and_fields.Rd +++ b/man/sql_select_records_and_fields.Rd @@ -48,18 +48,13 @@ unique identifies the subjects in each table} \item{port}{the server port ID} } \value{ -<<<<<<< HEAD an object of type \code{data.frame} that contains the dataset with the specified fields and records. -======= -a data frame with the specified columns and records ->>>>>>> main } \description{ Select specified records and fields from a table } \examples{ -<<<<<<< HEAD \dontrun{ result <- sql_select_records_and_fields( table = "author", @@ -76,21 +71,5 @@ result <- sql_select_records_and_fields( port = 4497 ) } -======= -result <- sql_select_records_and_fields( - table = "author", - record = c("1", "20", "50"), - id_column_name = "author_id", - field = c("author_id", "last_name"), - id_pos = NULL, - dbms = "MySQL", - driver_name = "", - host = "mysql-rfam-public.ebi.ac.uk", - database_name = "Rfam", - user = "rfamro", - password = "", - port = 4497 -) ->>>>>>> main } diff --git a/man/sql_select_records_only.Rd b/man/sql_select_records_only.Rd index dc1d89ac..499ade28 100644 --- a/man/sql_select_records_only.Rd +++ b/man/sql_select_records_only.Rd @@ -44,18 +44,13 @@ unique identifies the subjects in each table} \item{port}{the server port ID} } \value{ -<<<<<<< HEAD an object of type \code{data.frame} that contains the data fetched from the specific table with only the records of interest. -======= -a data frame with the records of interest ->>>>>>> main } \description{ Select specified records from a table } \examples{ -<<<<<<< HEAD \dontrun{ result <- sql_select_records_only( table = "author", @@ -73,19 +68,3 @@ result <- sql_select_records_only( } } -======= -result <- sql_select_records_only( - table = "author", - record = c("1", "20", "50"), - id_column_name = NULL, - id_pos = 1, - dbms = "MySQL", - driver_name = "", - host = "mysql-rfam-public.ebi.ac.uk", - database_name = "Rfam", - user = "rfamro", - password = "", - port = 4497 -) -} ->>>>>>> main diff --git a/man/sql_server_read_data.Rd b/man/sql_server_read_data.Rd index ba82ed33..cfa88460 100644 --- a/man/sql_server_read_data.Rd +++ b/man/sql_server_read_data.Rd @@ -2,7 +2,6 @@ % Please edit documentation in R/read_servers.R \name{sql_server_read_data} \alias{sql_server_read_data} -<<<<<<< HEAD \title{Read data from database management systems (DBMS).} \usage{ sql_server_read_data( @@ -12,27 +11,12 @@ sql_server_read_data( port = 1433L, database_name = "Rfam", driver_name = "", -======= -\title{Read data from relational databases hosted by a MS SQL server.} -\usage{ -sql_server_read_data( - user, - password, - host, - port = 1433, - database_name, - driver_name, ->>>>>>> main source = NULL, records = NULL, fields = NULL, id_position = NULL, id_col_name = NULL, -<<<<<<< HEAD dbms = "MySQL" -======= - dbms ->>>>>>> main ) } \arguments{ @@ -50,16 +34,11 @@ which the data should be pulled} \item{driver_name}{the name of the MS driver. use \code{odbc::odbcListDrivers()} to display the list of installed drivers} -<<<<<<< HEAD \item{source}{an SQL query or a vector of table names from -======= -\item{source}{and SQL query or a vector of table names from ->>>>>>> main the project or database. When this is not specified, the function will extract data from all tables in the database.} \item{records}{a vector or a comma-separated string of subset of subject IDs. -<<<<<<< HEAD When specified, only the records that correspond to these subjects will be imported.} @@ -72,26 +51,12 @@ and so on...} unique identifies the subjects in each table. When the column name with the subject IDs is known, use the \code{id_col_name} argument instead. default is 1.} -======= -When specified, only the records that correspond to these subjects will be -imported.} - -\item{fields}{a vector of strings where each string is a comma-separated list -of column names. The element of this vector should be a list of column names -from the first table specified in the \code{table_names} argument and so on...} - -\item{id_position}{a vector of the column positions of the variable that -unique identifies the subjects in each table. When the column name with the -subject IDs is known, use the \code{id_col_name} argument instead. default is. -default is 1.} ->>>>>>> main \item{id_col_name}{the column name with the subject IDs} \item{dbms}{the SQL server type} } \value{ -<<<<<<< HEAD a \code{list} of 1 or several objects of type \code{data.frame}. The number of elements in the list depends on the number of tables from which the data is fetched. @@ -101,22 +66,10 @@ The function assumes the user has read access to the database. Importing data stored in DBMS into R requires the installation of the appropriate \code{driver} that is compatible with the server version hosting the database. See the \code{vignette} for how to install the driver -======= -a list of data frames -} -\description{ -For a user with read access to a Microsoft SQL server, -this function allows data import from the database into R. It required the -installation -of the appropriate MS driver that is compatible with the SQL server version -hosting the -database. ->>>>>>> main } \examples{ \dontrun{ data <- sql_server_read_data( -<<<<<<< HEAD user = "rfamro", password = "", host = "mysql-rfam-public.ebi.ac.uk", @@ -129,16 +82,3 @@ data <- sql_server_read_data( } } \keyword{internal} -======= - user = "rfamro", - password = "", - host = "mysql-rfam-public.ebi.ac.uk", - port = 4497, - database_name = "Rfam", - source = "author", - driver_name = "", - dbms = "MySQL" -) -} -} ->>>>>>> main diff --git a/man/visualise_table.Rd b/man/visualise_table.Rd index fa0628aa..a25b9de7 100644 --- a/man/visualise_table.Rd +++ b/man/visualise_table.Rd @@ -4,7 +4,6 @@ \alias{visualise_table} \title{Visualize the first 5 rows of the data from a table} \usage{ -<<<<<<< HEAD visualise_table(data_source, credentials_file, from, driver_name) } \arguments{ @@ -14,32 +13,16 @@ visualise_table(data_source, credentials_file, from, driver_name) credential details for the projects of interest} \item{from}{the table name} -======= -visualise_table(credentials_file, source, project_id, driver_name) -} -\arguments{ -\item{credentials_file}{the path to the file with the user-specific -credential details for the projects of interest} - -\item{source}{the table name} - -\item{project_id}{the name of the target database} ->>>>>>> main \item{driver_name}{the name of the MS driver} } \value{ -<<<<<<< HEAD prints the first 5 rows of the specified table -======= -return the first 5 rows of the table if display=TRUE ->>>>>>> main } \description{ Visualize the first 5 rows of the data from a table } \examples{ -<<<<<<< HEAD \dontrun{ visualise_table( data_source = "mysql-rfam-public.ebi.ac.uk", @@ -48,13 +31,4 @@ visualise_table( driver_name = "" ) } -======= -visualise_table( - credentials_file <- system.file("extdata", "test.ini", package = "readepi"), - source = "author", - project_id = "Rfam", - driver_name = "" -) - ->>>>>>> main } diff --git a/tests/.DS_Store b/tests/.DS_Store deleted file mode 100644 index 02636bcefe48515c3e1091a46040530e0588a219..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8196 zcmeHMYitx%6h3EKV0NHzi#$53(4{LvaFKR-$WyitP)bQ_x1}#&o$ZWtWI9uJW_OXM zNn?B@g7KI5{;7%4@WX@%Ka7uGnrIY5h+yI${oxPP#6M`F(R1&e68Z{1Onij7$-QUJ zJ?G4wbMANU?b!kVHWkeVfEoZ$sdLKa(=bEha^9ykC7h`wiewKEzz`S^BC<0Lgq6kD0_%B3&?rh%FS?+x)jm9VfQ3P(w2=MbEL7me~NXI1=M+Xg}1R%;w z0MY1~>HuMr2x%syw#3vm4I&@5pY4i1-Uah~^9`xL-ebUOYMLv19kJyfaRU(gi20f=Z?D{!Y zJ!m+CMaKxNM#tgGes5r%2>4UK?-hb(p_pT==v$o@>DeW#g|x|ZF@ID0NML)ef6yxU zM3b3%`T4Q43zn{^yXW5e&D(dk>^t!ArK*LCSoLB}>!%R8f&Hj$6}ro|84UFq{-EWW zwtKXvWczmBvASGi*s8{#W3fxime*A2as93d(Nq(aCDqjPZUT(D>~RaH!{S*vSZKDo<`P%*V$)4Gn)-ZGy)fq!^ITGP87 zBX2p(j7hUC_iK7jNqWuphm$*YYI^UWH#|%(`qh{Ur!$SZeuS^wX81w-h~?5(eH1Rg zXRogJ`$I;-YA+MK*eBt9E6t02BMCR#W7>gNAfX6Jt=^%kef*V;rfHd%s+QL*>&$Ws zX1gVu08N`Aam~IWG$u3aOPvDdI6h4j5<4gD|zJ{;kn|Kc2!}E9nKgQ4T3;Yr<;#ItcKjKe#9e>5& zlnP~mQmd>|>Xf8%x3XSID;uR3%0%W2O!i7?A%5DCK$$ZlGecS2O3z z0+}m!ELplTxpsYe%Z|(qOi2(<;O=HL3kXjFzJRdU?&-hN_oZI?)QZ;H35lpE}CK=v(o7tX_n@EJk&Tlfxsfa?TP6&GR+t|X{(psvRI za051A8aLrCd;l}pNT6-Q1K5ro*ogxK+9Q}l10Ta<=%9;bJVC%6#W8~IGx#i?!sqY| zzKAd5DH1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0>>>>>> main }) diff --git a/tests/testthat/test-check_dhis2_attributes_helpers.R b/tests/testthat/test-check_dhis2_attributes_helpers.R deleted file mode 100644 index f623dd97..00000000 --- a/tests/testthat/test-check_dhis2_attributes_helpers.R +++ /dev/null @@ -1,152 +0,0 @@ -httptest::with_mock_api({ - test_that("the API request is working fine", { - response <- make_api_request( - base_url = file.path("https:/", "play.dhis2.org", "dev"), - username = "admin", - password = "district", - which = "dataElements" - ) - expect_type(response, "list") - expect_length(response, 8L) - expect_identical(response[["status_code"]], 200L) - }) - - test_that("dhis2_get_relevant_attributes works as expected with valid - dataSets", { - result <- dhis2_get_relevant_attributes( - attribute_id = "pBOMPrpg1QX,BfMAe6Itzgt", - base_url = file.path("https:/", "play.dhis2.org", "dev"), - username = "admin", - password = "district", - which = "dataSets" - ) - expect_type(result, "list") - expect_identical(result[["dataset"]], "pBOMPrpg1QX,BfMAe6Itzgt") - expect_s3_class(result[["data_sets"]], "data.frame") - }) - - test_that("dhis2_get_relevant_attributes works as expected with valid - dataElements", { - result <- dhis2_get_relevant_attributes( - attribute_id = "FTRrcoaog83", - base_url = file.path("https:/", "play.dhis2.org", "dev"), - username = "admin", - password = "district", - which = "dataElements" - ) - expect_s3_class(result, "data.frame") - }) - - test_that("dhis2_get_relevant_attributes works as expected with valid - organisationUnits", { - result <- dhis2_get_relevant_attributes( - attribute_id = "Rp268JB6Ne4", - base_url = file.path("https:/", "play.dhis2.org", "dev"), - username = "admin", - password = "district", - which = "organisationUnits" - ) - expect_type(result, "list") - expect_identical(result[["organisation_unit"]], "Rp268JB6Ne4") - expect_s3_class(result[["org_units"]], "data.frame") - }) - - test_that("dhis2_get_relevant_attributes works as expected with valid - dataElementGroups", { - result <- dhis2_get_relevant_attributes( - attribute_id = "oDkJh5Ddh7d", - base_url = file.path("https:/", "play.dhis2.org", "dev"), - username = "admin", - password = "district", - which = "dataElementGroups" - ) - expect_type(result, "list") - expect_identical(result[["data_element_group"]], "oDkJh5Ddh7d") - expect_s3_class(result[["data_elt_groups"]], "data.frame") - }) - - test_that("get_dhis2_attributes works as expected", { - attributes <- get_dhis2_attributes( - base_url = file.path("https:/", "play.dhis2.org", "dev"), - username = "admin", - password = "district", - which = "dataSets" - ) - expect_s3_class(attributes, "data.frame") - expect_identical(ncol(attributes), 3L) - expect_named(attributes, c("name", "shortName", "id")) - }) -}) - -test_that("the API request fails as expected", { - expect_error( - make_api_request( - base_url = file.path("test", "play.dhis2.org", "dev"), - username = "admin", - password = "district", - which = "dataElements" - ), - regexp = cat("The 'base_url' should start with 'https://'") - ) -}) - -test_that("the API request fails with an incorrect attribute", { - expect_error( - make_api_request( - base_url = file.path("test", "play.dhis2.org", "dev"), - username = "admin", - password = "district", - which = "test" - ), - regexp = cat("The expected values for the 'which' argument are: - 'dataSets, 'organisationUnits', 'dataElementGroups', 'dataElements'") - ) -}) - -test_that("dhis2_get_relevant_attributes fails as expected", { - expect_error( - dhis2_get_relevant_attributes( - attribute_id = "pBOMPrpg1QX,BfMAe6Itzgt", - base_url = file.path("test", "play.dhis2.org", "dev"), - username = "admin", - password = "district", - which = "dataSets" - ), - regexp = cat("The 'base_url' should start with 'https://'") - ) - - expect_error( - dhis2_get_relevant_attributes( - attribute_id = "pBOMPrpg1QX,BfMAe6Itzgt", - base_url = file.path("https:/", "play.dhis2.org", "dev"), - username = "admin", - password = "district", - which = "test" - ), - regexp = cat("The expected values for the 'which' argument are: - 'dataSets, 'organisationUnits', 'dataElementGroups', 'dataElements'") - ) - - expect_error( - dhis2_get_relevant_attributes( - attribute_id = "test", - base_url = file.path("https:/", "play.dhis2.org", "dev"), - username = "admin", - password = "district", - which = "dataSets" - ), - regexp = cat("The provided attribute ID not found.") - ) - - expect_warning( - dhis2_get_relevant_attributes( - attribute_id = "pBOMPrpg1QX, test", - base_url = file.path("https:/", "play.dhis2.org", "dev"), - username = "admin", - password = "district", - which = "dataSets" - ), - regexp = cat("Assertion on',attribute_id,'failed: 'test' is not a valid - dataSet ID.") - ) -}) diff --git a/tests/testthat/test-read_from_dhis2.R b/tests/testthat/test-read_from_dhis2.R index 8aacbc3f..0e4daef4 100644 --- a/tests/testthat/test-read_from_dhis2.R +++ b/tests/testthat/test-read_from_dhis2.R @@ -1,4 +1,3 @@ -<<<<<<< HEAD test_that("read_from_dhis2 works as expected", { data <- read_from_dhis2( base_url = file.path("https:/", "play.dhis2.org", "dev"), @@ -116,136 +115,3 @@ test_that("read_from_dhis2 fails with a wrong user_name", { regexp = cat("Assertion on',user_name,'failed: Must be provided.") ) }) -======= -test_that("login works as expected", { - expect_output( - login( - username = "admin", - password = "district", - base_url = file.path("https:/", "play.dhis2.org", "dev", "") - ), - "" - ) -}) - -test_that("login fails as expected", { - expect_error( - login( - username = NULL, - password = "district", - base_url = file.path("https:/", "play.dhis2.org", "dev", "") - ), - regexp = cat("Assertion on',username,'failed: Must be specified.") - ) - - expect_error( - login( - username = NA, - password = "district", - base_url = file.path("https:/", "play.dhis2.org", "dev", "") - ), - regexp = cat("Assertion on',username,'failed: Must be specified.") - ) - - expect_error( - login( - username = c("admin", "admin1"), - password = "district", - base_url = file.path("https:/", "play.dhis2.org", "dev", "") - ), - regexp = cat("Assertion on',username,'failed: Must be of type character - with length 1.") - ) - - expect_error( - login( - username = "admin", - password = NULL, - base_url = file.path("https:/", "play.dhis2.org", "dev", "") - ), - regexp = cat("Assertion on',password,'failed: Must be specified.") - ) - - expect_error( - login( - username = "admin", - password = NA, - base_url = file.path("https:/", "play.dhis2.org", "dev", "") - ), - regexp = cat("Assertion on',password,'failed: Must be specified.") - ) - - expect_error( - login( - username = "admin", - password = c("district", "district1"), - base_url = file.path("https:/", "play.dhis2.org", "dev", "") - ), - regexp = cat("Assertion on',password,'failed: Must be of type character - with length 1.") - ) - - expect_error( - login( - username = "admin", - password = "district", - base_url = NULL - ), - regexp = cat("Assertion on',base_url,'failed: Must be specified.") - ) - - expect_error( - login( - username = "admin", - password = "district", - base_url = NA - ), - regexp = cat("Assertion on',base_url,'failed: Must be specified.") - ) - - expect_error( - login( - username = "admin", - password = "district", - base_url = c(file.path("https:/", "play.dhis2.org", "dev", ""), - "https://play.dhis2.org/dev/test/") - ), - regexp = cat("Assertion on',base_url,'failed: Must be of type character - with length 1.") - ) -}) - -test_that("dhis2_subset_fields works as expected", { - result <- dhis2_subset_fields( - fields = c("dataElement", "period", "value"), - data = readepi( - credentials_file = system.file("extdata", "test.ini", package = "readepi") - , project_id = "DHIS2_DEMO", - dataset = "pBOMPrpg1QX,BfMAe6Itzgt", - organisation_unit = "DiszpKrYNg8", - data_element_group = NULL, - start_date = "2014", - end_date = "2023" - )$data - ) - expect_s3_class(result, "data.frame") -}) - -test_that("dhis2_subset_records works as expected", { - result <- dhis2_subset_records( - records = c("FTRrcoaog83", "eY5ehpbEsB7", "Ix2HsbDMLea"), - id_col_name = "dataElement", - data = readepi( - credentials_file = system.file("extdata", "test.ini", - package = "readepi"), - project_id = "DHIS2_DEMO", - dataset = "pBOMPrpg1QX", - organisation_unit = "DiszpKrYNg8", - data_element_group = NULL, - start_date = "2014", - end_date = "2023" - )$data - ) - expect_s3_class(result, "data.frame") -}) ->>>>>>> main diff --git a/tests/testthat/test-read_from_dhis2_helpers.R b/tests/testthat/test-read_from_dhis2_helpers.R index dd81ea90..64dcd02d 100644 --- a/tests/testthat/test-read_from_dhis2_helpers.R +++ b/tests/testthat/test-read_from_dhis2_helpers.R @@ -25,8 +25,7 @@ test_that("login fails as expected", { test_that("dhis2_subset_fields works as expected", { data <- readepi( credentials_file = system.file("extdata", "test.ini", - package = "readepi" - ), + package = "readepi"), data_source = "https://play.dhis2.org/dev", dataset = "pBOMPrpg1QX,BfMAe6Itzgt", organisation_unit = "DiszpKrYNg8", @@ -34,18 +33,16 @@ test_that("dhis2_subset_fields works as expected", { start_date = "2014", end_date = "2023" )[["data"]] - results <- dhis2_subset_fields( - data = data, - fields = c("dataElement", "period", "value") - ) + results <- dhis2_subset_fields(data = data, + fields = c("dataElement", "period", "value")) expect_s3_class(results, "data.frame") expect_length(results, 3L) expect_named(results, c("dataElement", "period", "value")) }) test_that("dhis2_subset_fields fails as expected", { - data <- readepi( - credentials_file = system.file("extdata", "test.ini", package = "readepi"), + data <- readepi(credentials_file = system.file("extdata", "test.ini", + package = "readepi"), data_source = "https://play.dhis2.org/dev", dataset = "pBOMPrpg1QX,BfMAe6Itzgt", organisation_unit = "DiszpKrYNg8", @@ -54,20 +51,15 @@ test_that("dhis2_subset_fields fails as expected", { end_date = "2023" )[["data"]] expect_error( - dhis2_subset_fields( - data = data, - fields = c(1, 2, 3) # nolint - ), + dhis2_subset_fields(data = data, fields = c(1, 2, 3)), # nolint regexp = cat("The value for the 'fields' argument should be a vector of - character.") - ) + character.")) }) test_that("dhis2_subset_records works as expected", { data <- readepi( credentials_file = system.file("extdata", "test.ini", - package = "readepi" - ), + package = "readepi"), data_source = "https://play.dhis2.org/dev", dataset = "pBOMPrpg1QX,BfMAe6Itzgt", organisation_unit = "DiszpKrYNg8", @@ -86,8 +78,7 @@ test_that("dhis2_subset_records works as expected", { test_that("dhis2_subset_records fails as expected", { data <- readepi( credentials_file = system.file("extdata", "test.ini", - package = "readepi" - ), + package = "readepi"), data_source = "https://play.dhis2.org/dev", dataset = "pBOMPrpg1QX,BfMAe6Itzgt", organisation_unit = "DiszpKrYNg8", @@ -111,11 +102,10 @@ test_that("dhis2_subset_fields sends a warning when the provided field is not found", { data <- readepi( credentials_file = system.file("extdata", "test.ini", - package = "readepi" - ), - data_source = "https://play.dhis2.org/dev", - dataset = "pBOMPrpg1QX,BfMAe6Itzgt", - organisation_unit = "DiszpKrYNg8", + package = "readepi"), + data_source = "https://play.dhis2.org/dev", + dataset = "pBOMPrpg1QX,BfMAe6Itzgt", + organisation_unit = "DiszpKrYNg8", data_element_group = NULL, start_date = "2014", end_date = "2023" @@ -134,24 +124,19 @@ test_that("dhis2_subset_fields sends a warning when the provided field is not test_that("dhis2_subset_records sends a warning when the provided record is not found", { data <- readepi( - credentials_file = system.file("extdata", "test.ini", - package = "readepi" - ), - data_source = "https://play.dhis2.org/dev", - dataset = "pBOMPrpg1QX", - organisation_unit = "DiszpKrYNg8", - data_element_group = NULL, - start_date = "2014", - end_date = "2023" - )[["data"]] + credentials_file = system.file("extdata", "test.ini", # nolint: line_length_linter + package = "readepi"), + data_source = "https://play.dhis2.org/dev", + dataset = "pBOMPrpg1QX", + organisation_unit = "DiszpKrYNg8", + data_element_group = NULL, + start_date = "2014", + end_date = "2023")[["data"]] - expect_warning( - dhis2_subset_records( - data = data, - records = c("FTRrcoaog83", "eY5ehpbEsB7", "test"), - id_col_name = "dataElement" - ), - regexp = cat("Assertion on',records,'failed: 'test' is not a valid - record.") - ) + expect_warning(dhis2_subset_records(data = data, + records = c("FTRrcoaog83", + "eY5ehpbEsB7", + "test"), + id_col_name = "dataElement"), + regexp = cat("Assertion on',records,'failed: 'test' is not a valid record.")) # nolint: line_length_linter }) diff --git a/tests/testthat/test-read_from_file-helpers.R b/tests/testthat/test-read_from_file-helpers.R deleted file mode 100644 index bad31d3f..00000000 --- a/tests/testthat/test-read_from_file-helpers.R +++ /dev/null @@ -1,216 +0,0 @@ -test_that("get_extension works as expected", { - result <- get_extension( - file_path = system.file("extdata", "test.txt", package = "readepi") - ) - expect_type(result, "character") -}) - -test_that("get_base_name works as expected", { - result <- get_base_name( - x = system.file("extdata", "test.txt", package = "readepi") - ) - expect_type(result, "character") -}) - -test_that("detect_separator works as expected", { - result <- detect_separator( - x = "My name is Karim" - ) - expect_type(result, "character") -}) - -test_that("read_rio_formats works as expected", { - result <- read_rio_formats( - files_extensions = ".txt", - rio_extensions = c("txt", "xlxs"), - files = system.file("extdata", "test.txt", package = "readepi"), - files_base_names = "test" - ) - expect_type(result, "list") -}) - -test_that("read_multiple_files works as expected", { - result <- read_multiple_files( - files = system.file("extdata", "test.txt", package = "readepi"), - dirs = list.dirs( - path = system.file("extdata", package = "readepi") - ), - format = c("txt", "csv"), - which = NULL - ) - expect_type(result, "list") -}) - -test_that("read_files_in_directory works as expected", { - res <- read_files_in_directory( - file_path = system.file("extdata", package = "readepi"), - pattern = ".txt" - ) - expect_type(res, "list") - - res <- read_files_in_directory( - file_path = system.file("extdata", package = "readepi"), - pattern = NULL - ) - expect_type(res, "list") -}) - -test_that("read_files_in_directory fails as expected", { - expect_error( - read_files_in_directory( - file_path = NULL, - pattern = ".txt" - ), - regexp = cat("Assertion on',file_path,'failed: Must be provided.") - ) - - expect_error( - read_files_in_directory( - file_path = NA, - pattern = ".txt" - ), - regexp = cat("Assertion on',file_path,'failed: Missing value not allowed for - file_path.") - ) - - expect_error( - read_files_in_directory( - file_path = system.file("extdata", package = "readepi"), - pattern = NA - ), - regexp = cat("Assertion on',file_path,'failed: Missing value not allowed for - pattern.") - ) -}) - -test_that("read_files works as expected", { - res <- read_files( - file_path = system.file("extdata", "test.xlsx", package = "readepi"), - sep = NULL, - format = NULL, - which = "Sheet1" - ) - expect_type(res, "list") - - res <- read_files( - file_path = system.file("extdata", "test.xlsx", package = "readepi"), - sep = NULL, - format = NULL, - which = NULL - ) - expect_type(res, "list") - - res <- read_files( - file_path = system.file("extdata", "test.txt", package = "readepi"), - sep = "\t", - format = ".txt", - which = NULL - ) - expect_type(res, "list") -}) - -test_that("read_files fails as expected", { - expect_error( - read_files( - file_path = NULL, - sep = NULL, - format = NULL, - which = NULL - ), - regexp = cat("Assertion on',file_path,'failed: Must be provided.") - ) - - expect_error( - read_files( - file_path = NA, - sep = NULL, - format = NULL, - which = NULL - ), - regexp = cat("Assertion on',file_path,'failed: Missing value not allowed for - file_path.") - ) - - expect_error( - read_files( - file_path = system.file("extdata", "test.xlsx", package = "readepi"), - sep = c(" ", "\t"), - format = NULL, - which = NULL - ), - regexp = cat("Assertion on',sep,'failed: Must be a character of length 1.") - ) - - expect_error( - read_files( - file_path = system.file("extdata", "test.xlsx", package = "readepi"), - sep = NA, - format = NULL, - which = NULL - ), - regexp = cat("Assertion on',sep,'failed: Missing value not allowed - for sep.") - ) - - expect_error( - read_files( - file_path = system.file("extdata", "test.txt", package = "readepi"), - sep = "\t", - format = NA, - which = NULL - ), - regexp = cat("Assertion on',sep,'failed: Missing value not allowed - for format") - ) - - expect_error( - read_files( - file_path = system.file("extdata", "test.txt", package = "readepi"), - sep = "\t", - format = NULL, - which = NA - ), - regexp = cat("Assertion on',sep,'failed: Missing value not allowed - for which") - ) -}) - -test_that("read_files fails as expected", { - expect_error( - fingertips_subset_rows( - records = NA, - id_col_name = "Species", - data = iris - ), - regexp = cat("Assertion on',records,'failed: Missing value not allowed for - records.") - ) - - expect_error( - fingertips_subset_rows( - records = "setosa", - id_col_name = NULL, - data = iris - ), - regexp = cat("Assertion on',id_col_name,'failed: Must be specified.") - ) - - expect_error( - fingertips_subset_rows( - records = "setosa", - id_col_name = "Species", - data = NULL - ), - regexp = cat("Assertion on',data,'failed: Must be specified.") - ) -}) - -test_that("read_files fails as expected", { - expect_error( - fingertips_subset_columns( - fields = "Sepal.Width,Petal.Length", - data = NULL - ), - regexp = cat("Assertion on',data,'failed: Must be provided") - ) -}) diff --git a/tests/testthat/test-read_from_file.R b/tests/testthat/test-read_from_file.R deleted file mode 100644 index 0a3eab8c..00000000 --- a/tests/testthat/test-read_from_file.R +++ /dev/null @@ -1,189 +0,0 @@ -test_that("read_from_file works properly when reading from an excel file - with 1 sheet", { - data <- read_from_file( - file_path = system.file("extdata", "test.xlsx", package = "readepi"), - sep = NULL, format = NULL, - which = NULL, pattern = NULL - ) - expect_type(data, "list") -}) - -test_that("read_from_file works properly when reading from an excel file with - several sheets", { - data <- read_from_file( - file_path = system.file("extdata", "test.xlsx", package = "readepi"), - sep = NULL, format = NULL, - which = c("Sheet1", "Sheet2"), pattern = NULL - ) - expect_type(data, "list") -}) - -test_that("read_from_file works as expected when reading from file", { - data <- read_from_file( - file_path = system.file("extdata", "test.txt", package = "readepi"), - sep = "\t", format = NULL, - which = NULL, pattern = NULL - ) - expect_type(data, "list") -}) - -test_that("read_from_file works as expected when reading from file", { - data <- read_from_file( - file_path = system.file("extdata", "test.txt", package = "readepi"), - sep = NULL, format = NULL, - which = NULL, pattern = NULL - ) - expect_type(data, "list") -}) - -test_that("read_from_file works as expected when reading from file", { - data <- read_from_file( - file_path = system.file("extdata", "test.txt", package = "readepi"), - sep = NULL, format = "txt", - which = NULL, pattern = NULL - ) - expect_type(data, "list") -}) - -test_that("read_from_file works as expected when reading from directory - given 1 pattern", { - data <- read_from_file( - file_path = system.file("extdata", package = "readepi"), - pattern = "txt" - ) - expect_type(data, "list") -}) - -test_that("read_from_file works as expected when reading from directory given - several pattern", { - data <- read_from_file( - file_path = system.file("extdata", package = "readepi"), - pattern = ".txt" - ) - expect_type(data, "list") -}) - -test_that("read_from_file works as expected when reading from directory given - several pattern", { - data <- read_from_file( - file_path = system.file("extdata", package = "readepi"), - pattern = c(".txt", ".csv") - ) - expect_type(data, "list") -}) - -test_that("read_from_file works as expected when reading from directory", { - data <- read_from_file(file_path = system.file("extdata", - package = "readepi")) - expect_type(data, "list") -}) - -test_that("read_from_file fails as expected", { - expect_error( - read_from_file( - file_path = system.file("extdata", "test.txt", package = "readepi"), - sep = c(" ", "\t"), - format = ".txt", - which = "Sheet2", - pattern = ".txt" - ), - regexp = cat("Assertion on',sep,'failed: Must be of type 'character' - of length 1.") - ) - - expect_error( - read_from_file( - file_path = system.file("extdata", "test.txt", package = "readepi"), - sep = NA, - format = ".txt", - which = "Sheet2", - pattern = ".txt" - ), - regexp = cat("Assertion on',sep,'failed: Missing value not allowed - for sep.") - ) - - expect_error( - read_from_file( - file_path = system.file("extdata", "test.txt", package = "readepi"), - sep = " ", - format = 1, - which = "Sheet2", - pattern = ".txt" - ), - regexp = cat("Assertion on',format,'failed: Must be of type 'character' - not 'numeric'.") - ) - - expect_error( - read_from_file( - file_path = system.file("extdata", "test.txt", package = "readepi"), - sep = " ", - format = NA, - which = "Sheet2", - pattern = ".txt" - ), - regexp = cat("Assertion on',format,'failed: Missing value not allowed - for format.") - ) - - expect_error( - read_from_file( - file_path = NULL, - sep = " ", - format = "txt", - which = "Sheet2", - pattern = NULL - ), - regexp = cat("Assertion on',file_path,'failed: Must be provided") - ) - - expect_error( - read_from_file( - file_path = NA, - sep = " ", - format = "txt", - which = "Sheet2", - pattern = NULL - ), - regexp = cat("Assertion on',file_path,'failed: Missing value not allowed for - file_path") - ) - - expect_error( - read_from_file( - file_path = c(system.file("extdata", "test.txt", package = "readepi"), - system.file("extdata", "fake_test.txt", package = "readepi")), - sep = " ", - format = "txt", - which = "Sheet2", - pattern = NULL - ), - regexp = cat("Assertion on',file_path,'failed: Must be a character of - length 1") - ) - - expect_error( - read_from_file( - file_path = system.file("extdata", "test.txt", package = "readepi"), - sep = " ", - format = "txt", - which = NA, - pattern = NULL - ), - regexp = cat("Assertion on',file_path,'failed: Missing value not allowed - for which") - ) - - expect_error( - read_from_file( - file_path = system.file("extdata", "test.txt", package = "readepi"), - sep = " ", - format = "txt", - which = "Sheet2", - pattern = NA - ), - regexp = cat("Assertion on',file_path,'failed: Missing value not allowed - for pattern") - ) -}) diff --git a/tests/testthat/test-read_from_fingertips-helpers.R b/tests/testthat/test-read_from_fingertips-helpers.R index 76cc0de1..709dfa1c 100644 --- a/tests/testthat/test-read_from_fingertips-helpers.R +++ b/tests/testthat/test-read_from_fingertips-helpers.R @@ -1,146 +1,454 @@ -test_that("get_fingertips_metadata works as expected", { - metadata <- get_fingertips_metadata() - expect_type(metadata, "list") - expect_length(metadata, 3) - expect_named(metadata, c("indicator_profile_domain", "indicator_ids_names", - "area_type")) - expect_s3_class(metadata$indicator_profile_domain, "data.frame") - expect_s3_class(metadata$indicator_ids_names, "data.frame") - expect_s3_class(metadata$area_type, "data.frame") -}) - -test_that("get_ind_id_from_ind_name works as expected", { - indicator_id <- get_ind_id_from_ind_name( - metadata = list( - indicator_profile_domain = fingertipsR::indicators(), - indicator_ids_names = fingertipsR::indicators_unique(), - area_type = fingertipsR::area_types() - ), - indicator_name = "Pupil absence" +test_that("fingertips_subset_rows works as expected", { + testthat::skip_on_cran() + testthat::skip_if_offline() + data <- readepi( + data_source = NULL, profile_id = 19L, + area_type_id = 202L + )[["data"]] + res <- fingertips_subset_rows( + data = data, + records = c("E92000001", "E12000002", "E12000009"), + id_col_name = "AreaCode" + ) + expect_s3_class(res, "data.frame") + expect_length(unique(res[["AreaCode"]]), 3L) + expect_identical( + unique(res[["AreaCode"]]), + c("E92000001", "E12000002", "E12000009") ) - expect_vector(indicator_id) }) -test_that("get_ind_id_from_domain_id works as expected", { - indicator_id <- get_ind_id_from_domain_id( - metadata = list( - indicator_profile_domain = fingertipsR::indicators(), - indicator_ids_names = fingertipsR::indicators_unique(), - area_type = fingertipsR::area_types() +test_that("fingertips_subset_rows fails as expected", { + testthat::skip_on_cran() + testthat::skip_if_offline() + data <- readepi( + data_source = NULL, profile_id = 19L, + area_type_id = 202L + )[["data"]] + expect_warning( + fingertips_subset_rows( + data = data, + records = c("E92000001", "E12000002", "Karim"), + id_col_name = "AreaCode" ), - domain_id = 1000041, - indicator_name = "Pupil absence" + regexp = cat("'Karim' is not a valid record.") ) - expect_vector(indicator_id) +}) - indicator_id <- get_ind_id_from_domain_id( - metadata = list( - indicator_profile_domain = fingertipsR::indicators(), - indicator_ids_names = fingertipsR::indicators_unique(), - area_type = fingertipsR::area_types() - ), - domain_id = 1000041, - indicator_name = NULL +test_that("fingertips_subset_columns works as expected", { + testthat::skip_on_cran() + testthat::skip_if_offline() + data <- readepi( + data_source = NULL, profile_id = 19L, + area_type_id = 202L + )[["data"]] + res <- fingertips_subset_columns( + data = data, + fields = c("IndicatorID", "AreaCode", "Age", "Value") ) - expect_vector(indicator_id) + expect_s3_class(res, "data.frame") + expect_named(res, c("IndicatorID", "AreaCode", "Age", "Value")) + expect_identical(ncol(res), 4L) }) - -test_that("get_ind_id_from_domain_name works as expected", { - indicator_id <- get_ind_id_from_domain_name( - metadata = list( - indicator_profile_domain = fingertipsR::indicators(), - indicator_ids_names = fingertipsR::indicators_unique(), - area_type = fingertipsR::area_types() +test_that("fingertips_subset_columns fails as expected", { + testthat::skip_on_cran() + testthat::skip_if_offline() + data <- readepi( + data_source = NULL, profile_id = 19L, + area_type_id = 202L + )[["data"]] + expect_error( + fingertips_subset_columns( + data = data, + fields = c("Karim", "mane") ), - domain_name = "B. Wider determinants of health", - indicator_name = "Pupil absence" + regexp = cat("The provided field names are not part of the data.") ) - expect_vector(indicator_id) - indicator_id <- get_ind_id_from_domain_name( - metadata = list( - indicator_profile_domain = fingertipsR::indicators(), - indicator_ids_names = fingertipsR::indicators_unique(), - area_type = fingertipsR::area_types() + expect_warning( + fingertips_subset_columns( + data = data, + fields = c("IndicatorID", "AreaCode", "Age", "mane") ), - domain_name = "B. Wider determinants of health", - indicator_name = NULL + regexp = cat("'mane' is an invalid field name.") ) - expect_vector(indicator_id) }) -test_that("get_ind_id_from_profile works as expected", { - indicator_id <- get_ind_id_from_profile( - metadata = list( - indicator_profile_domain = fingertipsR::indicators(), - indicator_ids_names = fingertipsR::indicators_unique(), - area_type = fingertipsR::area_types() - ), - domain_id = 1000041, - domain_name = "B. Wider determinants of health", - indicator_name = "Pupil absence", - profile_name = "Public Health Outcomes Framework", - profile_id = 19 - ) - expect_vector(indicator_id) +httptest::with_mock_api({ + test_that("get_fingertips_metadata works as expected", { + metadata <- get_fingertips_metadata() + expect_type(metadata, "list") + expect_length(metadata, 3L) + expect_named(metadata, c( + "indicator_profile_domain", + "indicator_ids_names", + "area_type" + )) + expect_s3_class(metadata[["indicator_profile_domain"]], "data.frame") + expect_s3_class(metadata[["indicator_ids_names"]], "data.frame") + expect_s3_class(metadata[["area_type"]], "data.frame") + }) - indicator_id <- get_ind_id_from_profile( - metadata = list( - indicator_profile_domain = fingertipsR::indicators(), - indicator_ids_names = fingertipsR::indicators_unique(), - area_type = fingertipsR::area_types() - ), - domain_id = NULL, - domain_name = NULL, - indicator_name = NULL, - profile_name = "Public Health Outcomes Framework", - profile_id = NULL - ) - expect_vector(indicator_id) + test_that("get_ind_id_from_ind_name works as expected", { + indicator_id <- get_ind_id_from_ind_name( + metadata = list( + indicator_profile_domain = fingertipsR::indicators(), + indicator_ids_names = fingertipsR::indicators_unique(), + area_type = fingertipsR::area_types() + ), + indicator_name = "Pupil absence" + ) + expect_vector(indicator_id) + expect_type(indicator_id, "integer") + expect_length(indicator_id, 1L) + expect_identical(indicator_id, 10301L) + }) - indicator_id <- get_ind_id_from_profile( - metadata = list( - indicator_profile_domain = fingertipsR::indicators(), - indicator_ids_names = fingertipsR::indicators_unique(), - area_type = fingertipsR::area_types() - ), - domain_id = NULL, - domain_name = NULL, - indicator_name = NULL, - profile_name = NULL, - profile_id = 19 - ) - expect_vector(indicator_id) -}) + test_that("get_ind_id_from_ind_name fails as expected", { + expect_error( + get_ind_id_from_ind_name( + metadata = list( + indicator_profile_domain = fingertipsR::indicators(), + indicator_ids_names = fingertipsR::indicators_unique(), + area_type = fingertipsR::area_types() + ), + indicator_name = 10L + ), + regexp = cat("Indicator_name should be of type character.") + ) -test_that("get_profile_name works as expected", { - res <- get_profile_name(profile_id = 19, - profile_name = "Public Health Outcomes Framework", - metadata = list( - indicator_profile_domain = fingertipsR::indicators(), - indicator_ids_names = fingertipsR::indicators_unique(), - area_type = fingertipsR::area_types() - )) - expect_type(res, "list") - expect_length(res, 2) - expect_type(res[[1]], "character") - expect_type(res[[2]], "integer") -}) + expect_error( + get_ind_id_from_ind_name( + metadata = list( + indicator_profile_domain = fingertipsR::indicators(), + indicator_ids_names = fingertipsR::indicators_unique(), + area_type = fingertipsR::area_types() + ), + indicator_name = "test" + ), + regexp = cat("'test' is not a valid indicator name.") + ) -test_that("fingertips_subset_rows works as expected", { - res <- fingertips_subset_rows( - records = "setosa", - id_col_name = "Species", - data = iris - ) - expect_s3_class(res, "data.frame") -}) + expect_warning( + get_ind_id_from_ind_name( + metadata = list( + indicator_profile_domain = fingertipsR::indicators(), + indicator_ids_names = fingertipsR::indicators_unique(), + area_type = fingertipsR::area_types() + ), + indicator_name = c("Pupil absence", "test") + ), + regexp = cat("'test' is not a valid indicator name.") + ) + }) -test_that("fingertips_subset_columns works as expected", { - res <- fingertips_subset_columns( - fields = c("Sepal.Width", "Petal.Length"), - data = iris - ) - expect_s3_class(res, "data.frame") + test_that("get_ind_id_from_domain_id works as expected", { + indicator_id <- get_ind_id_from_domain_id( + metadata = list( + indicator_profile_domain = fingertipsR::indicators(), + indicator_ids_names = fingertipsR::indicators_unique(), + area_type = fingertipsR::area_types() + ), + domain_id = 1000041L, + indicator_name = "Pupil absence" + ) + expect_vector(indicator_id) + expect_type(indicator_id, "integer") + expect_length(indicator_id, 1L) + + indicator_id <- get_ind_id_from_domain_id( + metadata = list( + indicator_profile_domain = fingertipsR::indicators(), + indicator_ids_names = fingertipsR::indicators_unique(), + area_type = fingertipsR::area_types() + ), + domain_id = 1000041L, + indicator_name = NULL + ) + expect_vector(indicator_id) + expect_type(indicator_id, "integer") + expect_length(indicator_id, 42L) + }) + + test_that("get_ind_id_from_domain_id works as expected", { + expect_error( + get_ind_id_from_domain_id( + metadata = list( + indicator_profile_domain = fingertipsR::indicators(), + indicator_ids_names = fingertipsR::indicators_unique(), + area_type = fingertipsR::area_types() + ), + domain_id = 1000041L, + indicator_name = 10L + ), + regexp = cat("Indicator_name should be of type character.") + ) + + expect_warning( + get_ind_id_from_domain_id( + metadata = list( + indicator_profile_domain = fingertipsR::indicators(), + indicator_ids_names = fingertipsR::indicators_unique(), + area_type = fingertipsR::area_types() + ), + domain_id = c(1000041L, 0L), + indicator_name = NULL + ), + regexp = cat("'0' is an invalid domain ID.") + ) + + expect_error( + get_ind_id_from_domain_id( + metadata = list( + indicator_profile_domain = fingertipsR::indicators(), + indicator_ids_names = fingertipsR::indicators_unique(), + area_type = fingertipsR::area_types() + ), + domain_id = c(-1L, 0L), + indicator_name = NULL + ), + regexp = cat("Provided domain IDs are invalid.") + ) + }) + + test_that("get_ind_id_from_domain_name works as expected", { + indicator_id <- get_ind_id_from_domain_name( + metadata = list( + indicator_profile_domain = fingertipsR::indicators(), + indicator_ids_names = fingertipsR::indicators_unique(), + area_type = fingertipsR::area_types() + ), + domain_name = "B. Wider determinants of health", + indicator_name = "Pupil absence" + ) + expect_vector(indicator_id) + expect_type(indicator_id, "integer") + expect_length(indicator_id, 1L) + + indicator_id <- get_ind_id_from_domain_name( + metadata = list( + indicator_profile_domain = fingertipsR::indicators(), + indicator_ids_names = fingertipsR::indicators_unique(), + area_type = fingertipsR::area_types() + ), + domain_name = "B. Wider determinants of health", + indicator_name = NULL + ) + expect_vector(indicator_id) + expect_type(indicator_id, "integer") + expect_length(indicator_id, 42L) + }) + + test_that("get_ind_id_from_domain_name fails as expected", { + expect_error( + get_ind_id_from_domain_name( + metadata = list( + indicator_profile_domain = fingertipsR::indicators(), + indicator_ids_names = fingertipsR::indicators_unique(), + area_type = fingertipsR::area_types() + ), + domain_name = c("Karim", "Mane"), + indicator_name = NULL + ), + regexp = cat("The provided domain names are invalid.") + ) + + expect_warning( + get_ind_id_from_domain_name( + metadata = list( + indicator_profile_domain = fingertipsR::indicators(), + indicator_ids_names = fingertipsR::indicators_unique(), + area_type = fingertipsR::area_types() + ), + domain_name = c("B. Wider determinants of health", "Mane"), + indicator_name = NULL + ), + regexp = cat("'Mane' is an invalid domain name.") + ) + }) + + test_that("get_ind_id_from_profile works as expected when all arguments are + provided", { + indicator_id <- get_ind_id_from_profile( + metadata = list( + indicator_profile_domain = + fingertipsR::indicators(), + indicator_ids_names = + fingertipsR::indicators_unique(), + area_type = fingertipsR::area_types() + ), + domain_id = 1000041L, + domain_name = "B. Wider determinants of health", + indicator_name = "Pupil absence", + profile_name = "Public Health Outcomes Framework", + profile_id = 19L + ) + expect_vector(indicator_id) + expect_type(indicator_id, "integer") + expect_length(indicator_id, 1L) + }) + + test_that("get_ind_id_from_profile works as expected when only the profile + name is provided", { + indicator_id <- get_ind_id_from_profile( + metadata = list( + indicator_profile_domain = + fingertipsR::indicators(), + indicator_ids_names = + fingertipsR::indicators_unique(), + area_type = fingertipsR::area_types() + ), + domain_id = NULL, + domain_name = NULL, + indicator_name = NULL, + profile_name = "Public Health Outcomes Framework", + profile_id = NULL + ) + expect_vector(indicator_id) + expect_type(indicator_id, "integer") + expect_length(indicator_id, 179L) + }) + + test_that("get_ind_id_from_profile works as expected when only the profile + and indicator names is provided", { + indicator_id <- get_ind_id_from_profile( + metadata = list( + indicator_profile_domain = + fingertipsR::indicators(), + indicator_ids_names = + fingertipsR::indicators_unique(), + area_type = fingertipsR::area_types() + ), + domain_id = NULL, + domain_name = NULL, + indicator_name = "Pupil absence", + profile_name = "Public Health Outcomes Framework", + profile_id = NULL + ) + expect_vector(indicator_id) + expect_type(indicator_id, "integer") + expect_length(indicator_id, 1L) + expect_identical(indicator_id, 10301L) + + indicator_id <- get_ind_id_from_profile( + metadata = list( + indicator_profile_domain = + fingertipsR::indicators(), + indicator_ids_names = + fingertipsR::indicators_unique(), + area_type = fingertipsR::area_types() + ), + domain_id = NULL, + domain_name = NULL, + indicator_name = "Pupil absence", + profile_name = NULL, + profile_id = 19L + ) + expect_vector(indicator_id) + expect_type(indicator_id, "integer") + expect_length(indicator_id, 1L) + expect_identical(indicator_id, 10301L) + }) + + test_that("get_ind_id_from_profile works as expected when only the profile + name is provided", { + indicator_id <- get_ind_id_from_profile( + metadata = list( + indicator_profile_domain = + fingertipsR::indicators(), + indicator_ids_names = + fingertipsR::indicators_unique(), + area_type = fingertipsR::area_types() + ), + domain_id = NULL, + domain_name = NULL, + indicator_name = NULL, + profile_name = NULL, + profile_id = 19L + ) + expect_vector(indicator_id) + expect_type(indicator_id, "integer") + expect_length(indicator_id, 179L) + }) + + test_that("get_ind_id_from_profile works as expected when the profile ID and + domain name is provided", { + indicator_id <- get_ind_id_from_profile( + metadata = list( + indicator_profile_domain = + fingertipsR::indicators(), + indicator_ids_names = + fingertipsR::indicators_unique(), + area_type = fingertipsR::area_types() + ), + domain_id = NULL, + domain_name = "B. Wider determinants of health", + indicator_name = NULL, + profile_name = NULL, + profile_id = 19L + ) + expect_vector(indicator_id) + expect_type(indicator_id, "integer") + expect_length(indicator_id, 42L) + }) + + test_that("get_ind_id_from_profile works as expected when the profile ID and + domain name is provided", { + indicator_id <- get_ind_id_from_profile( + metadata = list( + indicator_profile_domain = + fingertipsR::indicators(), + indicator_ids_names = + fingertipsR::indicators_unique(), + area_type = fingertipsR::area_types() + ), + domain_id = 1000041L, + domain_name = NULL, + indicator_name = NULL, + profile_name = NULL, + profile_id = 19L + ) + expect_vector(indicator_id) + expect_type(indicator_id, "integer") + expect_length(indicator_id, 42L) + }) + + test_that("get_ind_id_from_profile fails as expected", { + expect_error( + get_ind_id_from_profile( + metadata = list( + indicator_profile_domain = fingertipsR::indicators(), + indicator_ids_names = fingertipsR::indicators_unique(), + area_type = fingertipsR::area_types() + ), + domain_id = NULL, + domain_name = NULL, + indicator_name = NULL, + profile_name = "Karim", + profile_id = NULL + ), + regexp = cat("'Karim' is an invalid profile name.") + ) + }) + + test_that("get_profile_name works as expected", { + res <- get_profile_name( + profile_id = 19L, + profile_name = "Public Health Outcomes Framework", + metadata = list( + indicator_profile_domain = fingertipsR::indicators(), + indicator_ids_names = fingertipsR::indicators_unique(), + area_type = fingertipsR::area_types() + ) + ) + expect_type(res, "list") + expect_length(res, 2L) + expect_named(res, c("profile_name", "profile_index")) + expect_type(res[["profile_name"]], "character") + expect_identical(res[["profile_name"]], "Public Health Outcomes Framework") + expect_vector(res[["profile_index"]]) + expect_type(res[["profile_index"]], "integer") + expect_length(res[["profile_index"]], 179L) + }) }) diff --git a/tests/testthat/test-read_from_fingertips.R b/tests/testthat/test-read_from_fingertips.R index 07bf1dbc..05ca29fc 100644 --- a/tests/testthat/test-read_from_fingertips.R +++ b/tests/testthat/test-read_from_fingertips.R @@ -1,4 +1,3 @@ -<<<<<<< HEAD # httptest::with_mock_api({ # # }) @@ -10,19 +9,10 @@ test_that("read_from_fingertips works", { area_type_id = 202L, parent_area_type_id = 6L, profile_id = 19L, profile_name = "Public Health Outcomes Framework", domain_id = 1000049L, domain_name = "A. Overarching indicators", -======= -test_that("read_from_fingertips works", { - data <- read_from_fingertips( - indicator_id = 90362, indicator_name = "Healthy life expectancy at birth", - area_type_id = 202, parent_area_type_id = 6, - profile_id = 19, profile_name = "Public Health Outcomes Framework", - domain_id = 1000049, domain_name = "A. Overarching indicators", ->>>>>>> main fields = NULL, records = NULL, id_position = NULL, id_col_name = NULL ) expect_type(data, type = "list") -<<<<<<< HEAD expect_length(data, 1L) expect_named(data, "data") expect_s3_class(data[["data"]], "data.frame") @@ -30,22 +20,12 @@ test_that("read_from_fingertips works", { data <- read_from_fingertips( indicator_id = 90362L, indicator_name = NULL, area_type_id = 202L, parent_area_type_id = NULL, -======= - expect_length(data, 1) - expect_named(data, "data") - expect_s3_class(data$data, "data.frame") - - data <- read_from_fingertips( - indicator_id = 90362, indicator_name = NULL, - area_type_id = 202, parent_area_type_id = NULL, ->>>>>>> main profile_id = NULL, profile_name = NULL, domain_id = NULL, domain_name = NULL, fields = NULL, records = NULL, id_position = NULL, id_col_name = NULL ) expect_type(data, type = "list") -<<<<<<< HEAD expect_length(data, 1L) expect_named(data, "data") expect_s3_class(data[["data"]], "data.frame") @@ -53,22 +33,12 @@ test_that("read_from_fingertips works", { data <- read_from_fingertips( indicator_id = c(90362, 90283), indicator_name = NULL, # nolint area_type_id = 202L, parent_area_type_id = NULL, -======= - expect_length(data, 1) - expect_named(data, "data") - expect_s3_class(data$data, "data.frame") - - data <- read_from_fingertips( - indicator_id = c(90362, 90283), indicator_name = NULL, - area_type_id = 202, parent_area_type_id = NULL, ->>>>>>> main profile_id = NULL, profile_name = NULL, domain_id = NULL, domain_name = NULL, fields = NULL, records = NULL, id_position = NULL, id_col_name = NULL ) expect_type(data, type = "list") -<<<<<<< HEAD expect_length(data, 1L) expect_named(data, "data") expect_s3_class(data[["data"]], "data.frame") @@ -76,22 +46,12 @@ test_that("read_from_fingertips works", { data <- read_from_fingertips( indicator_id = 90362L, indicator_name = NULL, area_type_id = 202L, parent_area_type_id = NULL, -======= - expect_length(data, 1) - expect_named(data, "data") - expect_s3_class(data$data, "data.frame") - - data <- read_from_fingertips( - indicator_id = 90362, indicator_name = NULL, - area_type_id = 202, parent_area_type_id = NULL, ->>>>>>> main profile_id = NULL, profile_name = NULL, domain_id = NULL, domain_name = NULL, fields = NULL, records = c("E92000001", "E12000002"), id_position = NULL, id_col_name = "AreaCode" ) expect_type(data, type = "list") -<<<<<<< HEAD expect_length(data, 1L) expect_named(data, "data") expect_s3_class(data[["data"]], "data.frame") @@ -99,22 +59,12 @@ test_that("read_from_fingertips works", { data <- read_from_fingertips( indicator_id = 90362L, indicator_name = NULL, area_type_id = 202L, parent_area_type_id = NULL, -======= - expect_length(data, 1) - expect_named(data, "data") - expect_s3_class(data$data, "data.frame") - - data <- read_from_fingertips( - indicator_id = 90362, indicator_name = NULL, - area_type_id = 202, parent_area_type_id = NULL, ->>>>>>> main profile_id = NULL, profile_name = NULL, domain_id = NULL, domain_name = NULL, fields = c("IndicatorID", "AreaCode", "Age", "Value"), records = NULL, id_position = NULL, id_col_name = NULL ) expect_type(data, type = "list") -<<<<<<< HEAD expect_length(data, 1L) expect_named(data, "data") expect_s3_class(data[["data"]], "data.frame") @@ -122,15 +72,6 @@ test_that("read_from_fingertips works", { data <- read_from_fingertips( indicator_id = 90362L, indicator_name = NULL, area_type_id = 202L, parent_area_type_id = NULL, -======= - expect_length(data, 1) - expect_named(data, "data") - expect_s3_class(data$data, "data.frame") - - data <- read_from_fingertips( - indicator_id = 90362, indicator_name = NULL, - area_type_id = 202, parent_area_type_id = NULL, ->>>>>>> main profile_id = NULL, profile_name = NULL, domain_id = NULL, domain_name = NULL, fields = c("IndicatorID", "AreaCode", "Age", "Value"), @@ -138,7 +79,6 @@ test_that("read_from_fingertips works", { id_position = NULL, id_col_name = "AreaCode" ) expect_type(data, type = "list") -<<<<<<< HEAD expect_length(data, 1L) expect_named(data, "data") expect_s3_class(data[["data"]], "data.frame") @@ -149,52 +89,12 @@ test_that("read_from_fingertips works with domain name or ID", { data <- read_from_fingertips( indicator_id = NULL, indicator_name = "Pupil absence", area_type_id = 101L, parent_area_type_id = NULL, -======= - expect_length(data, 1) - expect_named(data, "data") - expect_s3_class(data$data, "data.frame") -}) - -test_that("read_from_fingertips works when only indicator name is provided", { - data <- read_from_fingertips( - indicator_id = NULL, indicator_name = "Pupil absence", - area_type_id = 202, parent_area_type_id = NULL, - profile_id = NULL, profile_name = NULL, - domain_id = 1000041, domain_name = NULL, - fields = NULL, records = NULL, - id_position = NULL, id_col_name = NULL - ) - expect_type(data, type = "list") - expect_length(data, 1) - expect_named(data, "data") - expect_s3_class(data$data, "data.frame") - - data <- read_from_fingertips( - indicator_id = NULL, indicator_name = "Pupil absence", - area_type_id = 202, parent_area_type_id = 6, - profile_id = NULL, profile_name = NULL, - domain_id = 1000041, domain_name = NULL, - fields = NULL, records = NULL, - id_position = NULL, id_col_name = NULL - ) - expect_type(data, type = "list") - expect_length(data, 1) - expect_named(data, "data") - expect_s3_class(data$data, "data.frame") -}) - -test_that("read_from_fingertips works with domain name or ID", { - data <- read_from_fingertips( - indicator_id = NULL, indicator_name = "Pupil absence", - area_type_id = 202, parent_area_type_id = NULL, ->>>>>>> main profile_id = NULL, profile_name = NULL, domain_id = NULL, domain_name = "B. Wider determinants of health", fields = NULL, records = NULL, id_position = NULL, id_col_name = NULL ) expect_type(data, type = "list") -<<<<<<< HEAD expect_length(data, 1L) expect_named(data, "data") expect_s3_class(data[["data"]], "data.frame") @@ -204,22 +104,10 @@ test_that("read_from_fingertips works with domain name or ID", { area_type_id = 101L, parent_area_type_id = NULL, profile_id = NULL, profile_name = NULL, domain_id = 1000049L, domain_name = NULL, -======= - expect_length(data, 1) - expect_named(data, "data") - expect_s3_class(data$data, "data.frame") - - data <- read_from_fingertips( - indicator_id = NULL, indicator_name = "Pupil absence", - area_type_id = 202, parent_area_type_id = NULL, - profile_id = NULL, profile_name = NULL, - domain_id = 1000049, domain_name = NULL, ->>>>>>> main fields = NULL, records = NULL, id_position = NULL, id_col_name = NULL ) expect_type(data, type = "list") -<<<<<<< HEAD expect_length(data, 1L) expect_named(data, "data") expect_s3_class(data[["data"]], "data.frame") @@ -230,61 +118,24 @@ test_that("read_from_fingertips works with profile name or ID", { data <- read_from_fingertips( indicator_id = NULL, indicator_name = "Pupil absence", area_type_id = 101L, parent_area_type_id = NULL, -======= - expect_length(data, 1) - expect_named(data, "data") - expect_s3_class(data$data, "data.frame") -}) - -test_that("read_from_fingertips works with profile name or ID", { - data <- read_from_fingertips( - indicator_id = NULL, indicator_name = "Pupil absence", - area_type_id = 202, parent_area_type_id = NULL, - profile_id = 19, profile_name = NULL, - domain_id = NULL, domain_name = NULL, - fields = NULL, records = NULL, - id_position = NULL, id_col_name = NULL - ) - expect_type(data, type = "list") - expect_length(data, 1) - expect_named(data, "data") - expect_s3_class(data$data, "data.frame") - - data <- read_from_fingertips( - indicator_id = NULL, indicator_name = "Pupil absence", - area_type_id = 202, parent_area_type_id = NULL, ->>>>>>> main profile_id = NULL, profile_name = "Public Health Outcomes Framework", domain_id = NULL, domain_name = NULL, fields = NULL, records = NULL, id_position = NULL, id_col_name = NULL ) expect_type(data, type = "list") -<<<<<<< HEAD expect_length(data, 1L) expect_named(data, "data") expect_s3_class(data[["data"]], "data.frame") -======= - expect_length(data, 1) - expect_named(data, "data") - expect_s3_class(data$data, "data.frame") ->>>>>>> main }) test_that("read_from_fingertips fails with bad indicator ID", { -<<<<<<< HEAD testthat::skip_on_cran() expect_error( read_from_fingertips( indicator_id = NA, indicator_name = NULL, area_type_id = 202L, parent_area_type_id = NULL, -======= - expect_error( - data = read_from_fingertips( - indicator_id = NA, indicator_name = NULL, - area_type_id = 202, parent_area_type_id = NULL, ->>>>>>> main profile_id = NULL, profile_name = NULL, domain_id = NULL, domain_name = NULL, fields = NULL, records = NULL, @@ -293,7 +144,6 @@ test_that("read_from_fingertips fails with bad indicator ID", { regexp = cat("Assertion on',indicator_id,'failed: Missing value not allowed.") ) -<<<<<<< HEAD }) test_that("read_from_fingertips fails with bad indicator name", { @@ -302,27 +152,6 @@ test_that("read_from_fingertips fails with bad indicator name", { read_from_fingertips( indicator_id = 90362L, indicator_name = NA, area_type_id = 202L, parent_area_type_id = NULL, -======= - - expect_error( - data = read_from_fingertips( - indicator_id = "90362", indicator_name = NULL, - area_type_id = 202, parent_area_type_id = NULL, - profile_id = NULL, profile_name = NULL, - domain_id = NULL, domain_name = NULL, - fields = NULL, records = NULL, - id_position = NULL, id_col_name = NULL - ), - regexp = cat("Assertion on',indicator_id,'failed: Must be of type numeric.") - ) -}) - -test_that("read_from_fingertips fails with bad indicator name", { - expect_error( - data = read_from_fingertips( - indicator_id = 90362, indicator_name = NA, - area_type_id = 202, parent_area_type_id = NULL, ->>>>>>> main profile_id = NULL, profile_name = NULL, domain_id = NULL, domain_name = NULL, fields = NULL, records = NULL, @@ -334,16 +163,10 @@ test_that("read_from_fingertips fails with bad indicator name", { }) test_that("read_from_fingertips fails with bad area type ID", { -<<<<<<< HEAD testthat::skip_on_cran() expect_error( read_from_fingertips( indicator_id = 90362L, indicator_name = NULL, -======= - expect_error( - data = read_from_fingertips( - indicator_id = 90362, indicator_name = NULL, ->>>>>>> main area_type_id = NA, parent_area_type_id = NULL, profile_id = NULL, profile_name = NULL, domain_id = NULL, domain_name = NULL, @@ -353,7 +176,6 @@ test_that("read_from_fingertips fails with bad area type ID", { regexp = cat("Assertion on',area_type_id,'failed: Missing value not allowed.") ) -<<<<<<< HEAD }) test_that("read_from_fingertips fails with bad parent area type ID", { @@ -362,27 +184,6 @@ test_that("read_from_fingertips fails with bad parent area type ID", { read_from_fingertips( indicator_id = 90362L, indicator_name = NULL, area_type_id = 202L, parent_area_type_id = NA, -======= - - expect_error( - data = read_from_fingertips( - indicator_id = 90362, indicator_name = NULL, - area_type_id = "202", parent_area_type_id = NULL, - profile_id = NULL, profile_name = NULL, - domain_id = NULL, domain_name = NULL, - fields = NULL, records = NULL, - id_position = NULL, id_col_name = NULL - ), - regexp = cat("Assertion on',area_type_id,'failed: Must be of type numeric.") - ) -}) - -test_that("read_from_fingertips fails with bad parent area type ID", { - expect_error( - data = read_from_fingertips( - indicator_id = 90362, indicator_name = NULL, - area_type_id = 202, parent_area_type_id = NA, ->>>>>>> main profile_id = NULL, profile_name = NULL, domain_id = NULL, domain_name = NULL, fields = NULL, records = NULL, @@ -391,7 +192,6 @@ test_that("read_from_fingertips fails with bad parent area type ID", { regexp = cat("Assertion on',parent_area_type_id,'failed: Missing value not allowed.") ) -<<<<<<< HEAD }) test_that("read_from_fingertips fails with bad profile ID", { @@ -400,34 +200,11 @@ test_that("read_from_fingertips fails with bad profile ID", { read_from_fingertips( indicator_id = 10301L, indicator_name = NULL, area_type_id = 202L, parent_area_type_id = NULL, -======= - - expect_error( - data = read_from_fingertips( - indicator_id = 90362, indicator_name = NULL, - area_type_id = 202, parent_area_type_id = "6", - profile_id = NULL, profile_name = NULL, - domain_id = NULL, domain_name = NULL, - fields = NULL, records = NULL, - id_position = NULL, id_col_name = NULL - ), - regexp = cat("Assertion on',parent_area_type_id,'failed: Must be of - type numeric.") - ) -}) - -test_that("read_from_fingertips fails with bad profile ID", { - expect_error( - data = read_from_fingertips( - indicator_id = 10301, indicator_name = NULL, - area_type_id = 202, parent_area_type_id = NULL, ->>>>>>> main profile_id = NA, profile_name = NULL, domain_id = NULL, domain_name = NULL, fields = NULL, records = NULL, id_position = NULL, id_col_name = NULL ), -<<<<<<< HEAD regexp = cat("Assertion on',profile_id,'failed: Missing value not allowed.") ) @@ -436,15 +213,6 @@ test_that("read_from_fingertips fails with bad profile ID", { read_from_fingertips( indicator_id = 10301L, indicator_name = NULL, area_type_id = 202L, parent_area_type_id = NULL, -======= - regexp = cat("Assertion on',profile_id,'failed: Missing value not allowed.") - ) - - expect_error( - data = read_from_fingertips( - indicator_id = 10301, indicator_name = NULL, - area_type_id = 202, parent_area_type_id = NULL, ->>>>>>> main profile_id = "19", profile_name = NULL, domain_id = NULL, domain_name = NULL, fields = NULL, records = NULL, @@ -455,18 +223,11 @@ test_that("read_from_fingertips fails with bad profile ID", { }) test_that("read_from_fingertips fails with bad profile name", { -<<<<<<< HEAD testthat::skip_on_cran() expect_error( read_from_fingertips( indicator_id = 10301L, indicator_name = NULL, area_type_id = 202L, parent_area_type_id = NULL, -======= - expect_error( - data = read_from_fingertips( - indicator_id = 10301, indicator_name = NULL, - area_type_id = 202, parent_area_type_id = NULL, ->>>>>>> main profile_id = NULL, profile_name = NA, domain_id = NULL, domain_name = NULL, fields = NULL, records = NULL, @@ -478,24 +239,16 @@ test_that("read_from_fingertips fails with bad profile name", { }) test_that("read_from_fingertips fails with bad domain ID", { -<<<<<<< HEAD testthat::skip_on_cran() expect_error( read_from_fingertips( indicator_id = 10301L, indicator_name = NULL, area_type_id = 202L, parent_area_type_id = NULL, -======= - expect_error( - data = read_from_fingertips( - indicator_id = 10301, indicator_name = NULL, - area_type_id = 202, parent_area_type_id = NULL, ->>>>>>> main profile_id = NULL, profile_name = NULL, domain_id = NA, domain_name = NULL, fields = NULL, records = NULL, id_position = NULL, id_col_name = NULL ), -<<<<<<< HEAD regexp = cat("Assertion on',domain_id,'failed: Missing value not allowed.") ) @@ -504,15 +257,6 @@ test_that("read_from_fingertips fails with bad domain ID", { read_from_fingertips( indicator_id = 10301L, indicator_name = NULL, area_type_id = 202L, parent_area_type_id = NULL, -======= - regexp = cat("Assertion on',domain_id,'failed: Missing value not allowed.") - ) - - expect_error( - data = read_from_fingertips( - indicator_id = 10301, indicator_name = NULL, - area_type_id = 202, parent_area_type_id = NULL, ->>>>>>> main profile_id = NULL, profile_name = NULL, domain_id = "1000041", domain_name = NULL, fields = NULL, records = NULL, @@ -523,18 +267,11 @@ test_that("read_from_fingertips fails with bad domain ID", { }) test_that("read_from_fingertips fails with bad domain name", { -<<<<<<< HEAD testthat::skip_on_cran() expect_error( read_from_fingertips( indicator_id = 10301L, indicator_name = NULL, area_type_id = 202L, parent_area_type_id = NULL, -======= - expect_error( - data = read_from_fingertips( - indicator_id = 10301, indicator_name = NULL, - area_type_id = 202, parent_area_type_id = NULL, ->>>>>>> main profile_id = NULL, profile_name = NULL, domain_id = NULL, domain_name = NA, fields = NULL, records = NULL, @@ -546,18 +283,11 @@ test_that("read_from_fingertips fails with bad domain name", { }) test_that("read_from_fingertips fails with bad records", { -<<<<<<< HEAD testthat::skip_on_cran() expect_error( read_from_fingertips( indicator_id = 10301L, indicator_name = NULL, area_type_id = 202L, parent_area_type_id = NULL, -======= - expect_error( - data = read_from_fingertips( - indicator_id = 10301, indicator_name = NULL, - area_type_id = 202, parent_area_type_id = NULL, ->>>>>>> main profile_id = NULL, profile_name = NULL, domain_id = NULL, domain_name = NULL, fields = NULL, records = NA, @@ -568,18 +298,11 @@ test_that("read_from_fingertips fails with bad records", { }) test_that("read_from_fingertips fails with bad fields", { -<<<<<<< HEAD testthat::skip_on_cran() expect_error( read_from_fingertips( indicator_id = 10301L, indicator_name = NULL, area_type_id = 202L, parent_area_type_id = NULL, -======= - expect_error( - data = read_from_fingertips( - indicator_id = 10301, indicator_name = NULL, - area_type_id = 202, parent_area_type_id = NULL, ->>>>>>> main profile_id = NULL, profile_name = NULL, domain_id = NULL, domain_name = NULL, fields = NA, records = NULL, @@ -588,7 +311,6 @@ test_that("read_from_fingertips fails with bad fields", { regexp = cat("Assertion on',fields,'failed: Missing value not allowed.") ) }) -<<<<<<< HEAD test_that("read_from_fingertips fails when no argument is provided", { testthat::skip_on_cran() @@ -621,5 +343,3 @@ test_that("read_from_fingertips fails when the area_type_id is not provided", { regexp = cat("Assertion on',area_type_id,'failed: Must be provided.") ) }) -======= ->>>>>>> main diff --git a/tests/testthat/test-read_from_fingertips_helpers.R b/tests/testthat/test-read_from_fingertips_helpers.R deleted file mode 100644 index 709dfa1c..00000000 --- a/tests/testthat/test-read_from_fingertips_helpers.R +++ /dev/null @@ -1,454 +0,0 @@ -test_that("fingertips_subset_rows works as expected", { - testthat::skip_on_cran() - testthat::skip_if_offline() - data <- readepi( - data_source = NULL, profile_id = 19L, - area_type_id = 202L - )[["data"]] - res <- fingertips_subset_rows( - data = data, - records = c("E92000001", "E12000002", "E12000009"), - id_col_name = "AreaCode" - ) - expect_s3_class(res, "data.frame") - expect_length(unique(res[["AreaCode"]]), 3L) - expect_identical( - unique(res[["AreaCode"]]), - c("E92000001", "E12000002", "E12000009") - ) -}) - -test_that("fingertips_subset_rows fails as expected", { - testthat::skip_on_cran() - testthat::skip_if_offline() - data <- readepi( - data_source = NULL, profile_id = 19L, - area_type_id = 202L - )[["data"]] - expect_warning( - fingertips_subset_rows( - data = data, - records = c("E92000001", "E12000002", "Karim"), - id_col_name = "AreaCode" - ), - regexp = cat("'Karim' is not a valid record.") - ) -}) - -test_that("fingertips_subset_columns works as expected", { - testthat::skip_on_cran() - testthat::skip_if_offline() - data <- readepi( - data_source = NULL, profile_id = 19L, - area_type_id = 202L - )[["data"]] - res <- fingertips_subset_columns( - data = data, - fields = c("IndicatorID", "AreaCode", "Age", "Value") - ) - expect_s3_class(res, "data.frame") - expect_named(res, c("IndicatorID", "AreaCode", "Age", "Value")) - expect_identical(ncol(res), 4L) -}) - -test_that("fingertips_subset_columns fails as expected", { - testthat::skip_on_cran() - testthat::skip_if_offline() - data <- readepi( - data_source = NULL, profile_id = 19L, - area_type_id = 202L - )[["data"]] - expect_error( - fingertips_subset_columns( - data = data, - fields = c("Karim", "mane") - ), - regexp = cat("The provided field names are not part of the data.") - ) - - expect_warning( - fingertips_subset_columns( - data = data, - fields = c("IndicatorID", "AreaCode", "Age", "mane") - ), - regexp = cat("'mane' is an invalid field name.") - ) -}) - -httptest::with_mock_api({ - test_that("get_fingertips_metadata works as expected", { - metadata <- get_fingertips_metadata() - expect_type(metadata, "list") - expect_length(metadata, 3L) - expect_named(metadata, c( - "indicator_profile_domain", - "indicator_ids_names", - "area_type" - )) - expect_s3_class(metadata[["indicator_profile_domain"]], "data.frame") - expect_s3_class(metadata[["indicator_ids_names"]], "data.frame") - expect_s3_class(metadata[["area_type"]], "data.frame") - }) - - test_that("get_ind_id_from_ind_name works as expected", { - indicator_id <- get_ind_id_from_ind_name( - metadata = list( - indicator_profile_domain = fingertipsR::indicators(), - indicator_ids_names = fingertipsR::indicators_unique(), - area_type = fingertipsR::area_types() - ), - indicator_name = "Pupil absence" - ) - expect_vector(indicator_id) - expect_type(indicator_id, "integer") - expect_length(indicator_id, 1L) - expect_identical(indicator_id, 10301L) - }) - - test_that("get_ind_id_from_ind_name fails as expected", { - expect_error( - get_ind_id_from_ind_name( - metadata = list( - indicator_profile_domain = fingertipsR::indicators(), - indicator_ids_names = fingertipsR::indicators_unique(), - area_type = fingertipsR::area_types() - ), - indicator_name = 10L - ), - regexp = cat("Indicator_name should be of type character.") - ) - - expect_error( - get_ind_id_from_ind_name( - metadata = list( - indicator_profile_domain = fingertipsR::indicators(), - indicator_ids_names = fingertipsR::indicators_unique(), - area_type = fingertipsR::area_types() - ), - indicator_name = "test" - ), - regexp = cat("'test' is not a valid indicator name.") - ) - - expect_warning( - get_ind_id_from_ind_name( - metadata = list( - indicator_profile_domain = fingertipsR::indicators(), - indicator_ids_names = fingertipsR::indicators_unique(), - area_type = fingertipsR::area_types() - ), - indicator_name = c("Pupil absence", "test") - ), - regexp = cat("'test' is not a valid indicator name.") - ) - }) - - test_that("get_ind_id_from_domain_id works as expected", { - indicator_id <- get_ind_id_from_domain_id( - metadata = list( - indicator_profile_domain = fingertipsR::indicators(), - indicator_ids_names = fingertipsR::indicators_unique(), - area_type = fingertipsR::area_types() - ), - domain_id = 1000041L, - indicator_name = "Pupil absence" - ) - expect_vector(indicator_id) - expect_type(indicator_id, "integer") - expect_length(indicator_id, 1L) - - indicator_id <- get_ind_id_from_domain_id( - metadata = list( - indicator_profile_domain = fingertipsR::indicators(), - indicator_ids_names = fingertipsR::indicators_unique(), - area_type = fingertipsR::area_types() - ), - domain_id = 1000041L, - indicator_name = NULL - ) - expect_vector(indicator_id) - expect_type(indicator_id, "integer") - expect_length(indicator_id, 42L) - }) - - test_that("get_ind_id_from_domain_id works as expected", { - expect_error( - get_ind_id_from_domain_id( - metadata = list( - indicator_profile_domain = fingertipsR::indicators(), - indicator_ids_names = fingertipsR::indicators_unique(), - area_type = fingertipsR::area_types() - ), - domain_id = 1000041L, - indicator_name = 10L - ), - regexp = cat("Indicator_name should be of type character.") - ) - - expect_warning( - get_ind_id_from_domain_id( - metadata = list( - indicator_profile_domain = fingertipsR::indicators(), - indicator_ids_names = fingertipsR::indicators_unique(), - area_type = fingertipsR::area_types() - ), - domain_id = c(1000041L, 0L), - indicator_name = NULL - ), - regexp = cat("'0' is an invalid domain ID.") - ) - - expect_error( - get_ind_id_from_domain_id( - metadata = list( - indicator_profile_domain = fingertipsR::indicators(), - indicator_ids_names = fingertipsR::indicators_unique(), - area_type = fingertipsR::area_types() - ), - domain_id = c(-1L, 0L), - indicator_name = NULL - ), - regexp = cat("Provided domain IDs are invalid.") - ) - }) - - test_that("get_ind_id_from_domain_name works as expected", { - indicator_id <- get_ind_id_from_domain_name( - metadata = list( - indicator_profile_domain = fingertipsR::indicators(), - indicator_ids_names = fingertipsR::indicators_unique(), - area_type = fingertipsR::area_types() - ), - domain_name = "B. Wider determinants of health", - indicator_name = "Pupil absence" - ) - expect_vector(indicator_id) - expect_type(indicator_id, "integer") - expect_length(indicator_id, 1L) - - indicator_id <- get_ind_id_from_domain_name( - metadata = list( - indicator_profile_domain = fingertipsR::indicators(), - indicator_ids_names = fingertipsR::indicators_unique(), - area_type = fingertipsR::area_types() - ), - domain_name = "B. Wider determinants of health", - indicator_name = NULL - ) - expect_vector(indicator_id) - expect_type(indicator_id, "integer") - expect_length(indicator_id, 42L) - }) - - test_that("get_ind_id_from_domain_name fails as expected", { - expect_error( - get_ind_id_from_domain_name( - metadata = list( - indicator_profile_domain = fingertipsR::indicators(), - indicator_ids_names = fingertipsR::indicators_unique(), - area_type = fingertipsR::area_types() - ), - domain_name = c("Karim", "Mane"), - indicator_name = NULL - ), - regexp = cat("The provided domain names are invalid.") - ) - - expect_warning( - get_ind_id_from_domain_name( - metadata = list( - indicator_profile_domain = fingertipsR::indicators(), - indicator_ids_names = fingertipsR::indicators_unique(), - area_type = fingertipsR::area_types() - ), - domain_name = c("B. Wider determinants of health", "Mane"), - indicator_name = NULL - ), - regexp = cat("'Mane' is an invalid domain name.") - ) - }) - - test_that("get_ind_id_from_profile works as expected when all arguments are - provided", { - indicator_id <- get_ind_id_from_profile( - metadata = list( - indicator_profile_domain = - fingertipsR::indicators(), - indicator_ids_names = - fingertipsR::indicators_unique(), - area_type = fingertipsR::area_types() - ), - domain_id = 1000041L, - domain_name = "B. Wider determinants of health", - indicator_name = "Pupil absence", - profile_name = "Public Health Outcomes Framework", - profile_id = 19L - ) - expect_vector(indicator_id) - expect_type(indicator_id, "integer") - expect_length(indicator_id, 1L) - }) - - test_that("get_ind_id_from_profile works as expected when only the profile - name is provided", { - indicator_id <- get_ind_id_from_profile( - metadata = list( - indicator_profile_domain = - fingertipsR::indicators(), - indicator_ids_names = - fingertipsR::indicators_unique(), - area_type = fingertipsR::area_types() - ), - domain_id = NULL, - domain_name = NULL, - indicator_name = NULL, - profile_name = "Public Health Outcomes Framework", - profile_id = NULL - ) - expect_vector(indicator_id) - expect_type(indicator_id, "integer") - expect_length(indicator_id, 179L) - }) - - test_that("get_ind_id_from_profile works as expected when only the profile - and indicator names is provided", { - indicator_id <- get_ind_id_from_profile( - metadata = list( - indicator_profile_domain = - fingertipsR::indicators(), - indicator_ids_names = - fingertipsR::indicators_unique(), - area_type = fingertipsR::area_types() - ), - domain_id = NULL, - domain_name = NULL, - indicator_name = "Pupil absence", - profile_name = "Public Health Outcomes Framework", - profile_id = NULL - ) - expect_vector(indicator_id) - expect_type(indicator_id, "integer") - expect_length(indicator_id, 1L) - expect_identical(indicator_id, 10301L) - - indicator_id <- get_ind_id_from_profile( - metadata = list( - indicator_profile_domain = - fingertipsR::indicators(), - indicator_ids_names = - fingertipsR::indicators_unique(), - area_type = fingertipsR::area_types() - ), - domain_id = NULL, - domain_name = NULL, - indicator_name = "Pupil absence", - profile_name = NULL, - profile_id = 19L - ) - expect_vector(indicator_id) - expect_type(indicator_id, "integer") - expect_length(indicator_id, 1L) - expect_identical(indicator_id, 10301L) - }) - - test_that("get_ind_id_from_profile works as expected when only the profile - name is provided", { - indicator_id <- get_ind_id_from_profile( - metadata = list( - indicator_profile_domain = - fingertipsR::indicators(), - indicator_ids_names = - fingertipsR::indicators_unique(), - area_type = fingertipsR::area_types() - ), - domain_id = NULL, - domain_name = NULL, - indicator_name = NULL, - profile_name = NULL, - profile_id = 19L - ) - expect_vector(indicator_id) - expect_type(indicator_id, "integer") - expect_length(indicator_id, 179L) - }) - - test_that("get_ind_id_from_profile works as expected when the profile ID and - domain name is provided", { - indicator_id <- get_ind_id_from_profile( - metadata = list( - indicator_profile_domain = - fingertipsR::indicators(), - indicator_ids_names = - fingertipsR::indicators_unique(), - area_type = fingertipsR::area_types() - ), - domain_id = NULL, - domain_name = "B. Wider determinants of health", - indicator_name = NULL, - profile_name = NULL, - profile_id = 19L - ) - expect_vector(indicator_id) - expect_type(indicator_id, "integer") - expect_length(indicator_id, 42L) - }) - - test_that("get_ind_id_from_profile works as expected when the profile ID and - domain name is provided", { - indicator_id <- get_ind_id_from_profile( - metadata = list( - indicator_profile_domain = - fingertipsR::indicators(), - indicator_ids_names = - fingertipsR::indicators_unique(), - area_type = fingertipsR::area_types() - ), - domain_id = 1000041L, - domain_name = NULL, - indicator_name = NULL, - profile_name = NULL, - profile_id = 19L - ) - expect_vector(indicator_id) - expect_type(indicator_id, "integer") - expect_length(indicator_id, 42L) - }) - - test_that("get_ind_id_from_profile fails as expected", { - expect_error( - get_ind_id_from_profile( - metadata = list( - indicator_profile_domain = fingertipsR::indicators(), - indicator_ids_names = fingertipsR::indicators_unique(), - area_type = fingertipsR::area_types() - ), - domain_id = NULL, - domain_name = NULL, - indicator_name = NULL, - profile_name = "Karim", - profile_id = NULL - ), - regexp = cat("'Karim' is an invalid profile name.") - ) - }) - - test_that("get_profile_name works as expected", { - res <- get_profile_name( - profile_id = 19L, - profile_name = "Public Health Outcomes Framework", - metadata = list( - indicator_profile_domain = fingertipsR::indicators(), - indicator_ids_names = fingertipsR::indicators_unique(), - area_type = fingertipsR::area_types() - ) - ) - expect_type(res, "list") - expect_length(res, 2L) - expect_named(res, c("profile_name", "profile_index")) - expect_type(res[["profile_name"]], "character") - expect_identical(res[["profile_name"]], "Public Health Outcomes Framework") - expect_vector(res[["profile_index"]]) - expect_type(res[["profile_index"]], "integer") - expect_length(res[["profile_index"]], 179L) - }) -}) diff --git a/tests/testthat/test-read_from_redcap-helpers.R b/tests/testthat/test-read_from_redcap-helpers.R index b8d06667..ba935424 100644 --- a/tests/testthat/test-read_from_redcap-helpers.R +++ b/tests/testthat/test-read_from_redcap-helpers.R @@ -1,157 +1,181 @@ -test_that("import_redcap_data works as expected", { - result <- import_redcap_data( - uri = "https://bbmc.ouhsc.edu/redcap/api/", - token = "9A81268476645C4E5F03428B8AC3AA7B", - records = c("1", "3", "5"), - fields = c("record_id", "name_first", "age", "bmi"), - id_col_name = NULL, - id_position = 1 - ) - expect_type(result, "list") - expect_length(result, 2) -}) - -test_that("redcap_get_results works as expected", { - result <- redcap_get_results( - redcap_data = REDCapR::redcap_read( - redcap_uri = "https://bbmc.ouhsc.edu/redcap/api/", +httptest::with_mock_api({ + test_that("import_redcap_data works as expected", { + result <- import_redcap_data( + uri = file.path("https:/", "bbmc.ouhsc.edu", "redcap", "api", ""), token = "9A81268476645C4E5F03428B8AC3AA7B", records = c("1", "3", "5"), - fields = c("record_id", "name_first", "age", "bmi"), verbose = FALSE, - id_position = 1L), - metadata = REDCapR::redcap_metadata_read( - redcap_uri = "https://bbmc.ouhsc.edu/redcap/api/", - token = "9A81268476645C4E5F03428B8AC3AA7B", - fields = NULL, - verbose = FALSE) - ) - expect_type(result, "list") - expect_length(result, 2) -}) + fields = c("record_id", "name_first", "age", "bmi"), + id_col_name = NULL, + id_position = 1L + ) + expect_type(result, "list") + expect_length(result, 2L) + expect_named(result, c("redcap_data", "metadata")) + expect_type(result[["redcap_data"]], "list") + expect_type(result[["metadata"]], "list") + expect_length(result[["redcap_data"]], 12L) + expect_length(result[["metadata"]], 8L) + }) -test_that("redcap_get_results fails with bad redcap_data", { - expect_error( - redcap_get_results( - redcap_data = NULL, - metadata = REDCapR::redcap_metadata_read( + test_that("redcap_get_results works as expected", { + result <- redcap_get_results( + redcap_data = REDCapR::redcap_read( redcap_uri = "https://bbmc.ouhsc.edu/redcap/api/", token = "9A81268476645C4E5F03428B8AC3AA7B", - fields = NULL, - verbose = FALSE) - ), - regexp = cat("Assertion on',redcap_data,'failed: Must be provided") - ) - - expect_error( - redcap_get_results( - redcap_data = NA, + records = c("1", "3", "5"), + fields = c("record_id", "name_first", "age", "bmi"), verbose = FALSE, + id_position = 1L + ), metadata = REDCapR::redcap_metadata_read( redcap_uri = "https://bbmc.ouhsc.edu/redcap/api/", token = "9A81268476645C4E5F03428B8AC3AA7B", fields = NULL, - verbose = FALSE) - ), - regexp = cat("Assertion on',redcap_data,'failed: Missing value not allowed - for redcap_data") - ) -}) + verbose = FALSE + ) + ) + expect_type(result, "list") + expect_length(result, 2L) + expect_named(result, c("data", "meta")) + expect_s3_class(result[["data"]], "data.frame") + expect_s3_class(result[["meta"]], "data.frame") + }) -test_that("redcap_get_results fails with bad redcap_data", { - expect_error( - redcap_get_results( - redcap_data = REDCapR::redcap_read( - redcap_uri = "https://bbmc.ouhsc.edu/redcap/api/", - token = "9A81268476645C4E5F03428B8AC3AA7B", - records = c("1", "3", "5"), - fields = c("record_id", "name_first", "age", "bmi"), verbose = FALSE, - id_position = 1L), - metadata = NULL - ), - regexp = cat("Assertion on',metadata,'failed: Must be provided") - ) + test_that("redcap_get_results fails with bad redcap_data", { + expect_error( + redcap_get_results( + redcap_data = NULL, + metadata = REDCapR::redcap_metadata_read( + redcap_uri = "https://bbmc.ouhsc.edu/redcap/api/", + token = "9A81268476645C4E5F03428B8AC3AA7B", + fields = NULL, + verbose = FALSE + ) + ), + regexp = cat("Assertion on',redcap_data,'failed: Must be provided") + ) - expect_error( - redcap_get_results( - redcap_data = REDCapR::redcap_read( - redcap_uri = "https://bbmc.ouhsc.edu/redcap/api/", - token = "9A81268476645C4E5F03428B8AC3AA7B", - records = c("1", "3", "5"), - fields = c("record_id", "name_first", "age", "bmi"), verbose = FALSE, - id_position = 1L), - metadata = NA - ), - regexp = cat("Assertion on',metadata,'failed: Missing value not allowed - for metadata") - ) -}) + expect_error( + redcap_get_results( + redcap_data = NA, + metadata = REDCapR::redcap_metadata_read( + redcap_uri = "https://bbmc.ouhsc.edu/redcap/api/", + token = "9A81268476645C4E5F03428B8AC3AA7B", + fields = NULL, + verbose = FALSE + ) + ), + regexp = cat("Assertion on',redcap_data,'failed: Missing value not allowed + for redcap_data") + ) + }) -test_that("redcap_read works as expected", { - res <- redcap_read( - uri = "https://bbmc.ouhsc.edu/redcap/api/", - token = "9A81268476645C4E5F03428B8AC3AA7B", - id_position = 1 - ) - expect_type(res, "list") - expect_length(res, 2) - expect_named(res, c("redcap_data", "metadata")) - expect_type(res$redcap_data, "list") - expect_type(res$metadata, "list") -}) + test_that("redcap_get_results fails with bad metadata", { + expect_error( + redcap_get_results( + redcap_data = REDCapR::redcap_read( + redcap_uri = "https://bbmc.ouhsc.edu/redcap/api/", + token = "9A81268476645C4E5F03428B8AC3AA7B", + records = c("1", "3", "5"), + fields = c("record_id", "name_first", "age", "bmi"), verbose = FALSE, + id_position = 1L + ), + metadata = NULL + ), + regexp = cat("Assertion on',metadata,'failed: Must be provided") + ) -test_that("redcap_read works as expected", { - res <- redcap_read( - uri = "https://bbmc.ouhsc.edu/redcap/api/", - token = "9A81268476645C4E5F03428B8AC3AA7B", - id_position = 1 - ) - expect_type(res, "list") - expect_length(res, 2) - expect_named(res, c("redcap_data", "metadata")) - expect_type(res$redcap_data, "list") - expect_type(res$metadata, "list") -}) + expect_error( + redcap_get_results( + redcap_data = REDCapR::redcap_read( + redcap_uri = "https://bbmc.ouhsc.edu/redcap/api/", + token = "9A81268476645C4E5F03428B8AC3AA7B", + records = c("1", "3", "5"), + fields = c("record_id", "name_first", "age", "bmi"), verbose = FALSE, + id_position = 1L + ), + metadata = NA + ), + regexp = cat("Assertion on',metadata,'failed: Missing value not allowed + for metadata") + ) + }) -test_that("redcap_read_rows_columns works as expected", { - res <- redcap_read_rows_columns( - uri = "https://bbmc.ouhsc.edu/redcap/api/", - token = "9A81268476645C4E5F03428B8AC3AA7B", - id_position = 1, - id_col_name = NULL, - fields = c("record_id", "name_first", "age", "bmi"), - records = c("1", "3", "5") - ) - expect_type(res, "list") - expect_length(res, 2) - expect_named(res, c("redcap_data", "metadata")) - expect_type(res$redcap_data, "list") - expect_type(res$metadata, "list") -}) + test_that("redcap_read_data works as expected", { + result <- redcap_read_data( + uri = "https://bbmc.ouhsc.edu/redcap/api/", + token = "9A81268476645C4E5F03428B8AC3AA7B", + id_position = 1L + ) + expect_type(result, "list") + expect_length(result, 2L) + expect_named(result, c("redcap_data", "metadata")) + expect_type(result[["redcap_data"]], "list") + expect_type(result[["metadata"]], "list") + expect_length(result[["redcap_data"]], 12L) + expect_length(result[["metadata"]], 8L) + }) -test_that("redcap_read_fields works as expected", { - res <- redcap_read_fields( - uri = "https://bbmc.ouhsc.edu/redcap/api/", - token = "9A81268476645C4E5F03428B8AC3AA7B", - id_position = 1, - fields = c("record_id", "name_first", "age", "bmi") - ) - expect_type(res, "list") - expect_length(res, 2) - expect_named(res, c("redcap_data", "metadata")) - expect_type(res$redcap_data, "list") - expect_type(res$metadata, "list") -}) + test_that("redcap_read_rows_columns works as expected", { + result <- redcap_read_rows_columns( + uri = "https://bbmc.ouhsc.edu/redcap/api/", + token = "9A81268476645C4E5F03428B8AC3AA7B", + id_position = 1L, + id_col_name = NULL, + fields = c("record_id", "name_first", "age", "bmi"), + records = c("1", "3", "5") + ) + expect_type(result, "list") + expect_length(result, 2L) + expect_named(result, c("redcap_data", "metadata")) + expect_type(result[["redcap_data"]], "list") + expect_type(result[["metadata"]], "list") + expect_length(result[["redcap_data"]], 12L) + expect_length(result[["metadata"]], 8L) + }) + + test_that("redcap_read_fields works as expected", { + result <- redcap_read_fields( + uri = "https://bbmc.ouhsc.edu/redcap/api/", + token = "9A81268476645C4E5F03428B8AC3AA7B", + id_position = 1L, + fields = c("record_id", "name_first", "age", "bmi") + ) + expect_type(result, "list") + expect_length(result, 2L) + expect_named(result, c("redcap_data", "metadata")) + expect_type(result[["redcap_data"]], "list") + expect_type(result[["metadata"]], "list") + expect_length(result[["redcap_data"]], 12L) + expect_length(result[["metadata"]], 8L) + }) + + test_that("redcap_read_records works as expected", { + result <- redcap_read_records( + uri = "https://bbmc.ouhsc.edu/redcap/api/", + token = "9A81268476645C4E5F03428B8AC3AA7B", + id_position = 1L, + records = c("1", "2", "3"), + id_col_name = NULL + ) + expect_type(result, "list") + expect_length(result, 2L) + expect_named(result, c("redcap_data", "metadata")) + expect_type(result[["redcap_data"]], "list") + expect_type(result[["metadata"]], "list") + expect_length(result[["redcap_data"]], 12L) + expect_length(result[["metadata"]], 8L) + }) -test_that("redcap_read_records works as expected", { - res <- redcap_read_records( - uri = "https://bbmc.ouhsc.edu/redcap/api/", - token = "9A81268476645C4E5F03428B8AC3AA7B", - id_position = 1, - records = c("1", "2", "3"), - id_col_name = NULL - ) - expect_type(res, "list") - expect_length(res, 2) - expect_named(res, c("redcap_data", "metadata")) - expect_type(res$redcap_data, "list") - expect_type(res$metadata, "list") + test_that("redcap_read_records fails as expected", { + expect_error( + redcap_read_records( + uri = "https://bbmc.ouhsc.edu/redcap/api/", + token = "9A81268476645C4E5F03428B8AC3AA7B", + id_position = NULL, + records = c("1", "2", "3"), + id_col_name = "Karim" + ), + regexp = cat("'Karim' is an invalid column name.") + ) + }) }) diff --git a/tests/testthat/test-read_from_redcap.R b/tests/testthat/test-read_from_redcap.R index 0c5df3a1..49b31355 100644 --- a/tests/testthat/test-read_from_redcap.R +++ b/tests/testthat/test-read_from_redcap.R @@ -1,4 +1,3 @@ -<<<<<<< HEAD httptest::with_mock_api({ test_that("read_from_redcap works with valid input", { res <- read_from_redcap( @@ -459,499 +458,4 @@ httptest::with_mock_api({ allowed. Please specify 1 ID column name.") ) }) -======= -test_that("read_from_redcap works with valid input", { - res <- read_from_redcap( - uri = "https://bbmc.ouhsc.edu/redcap/api/", - token = "9A81268476645C4E5F03428B8AC3AA7B", - id_position = 1, - id_col_name = NULL, - records = NULL, - fields = NULL - ) - expect_type(res, "list") - expect_length(res, 2) - expect_named(res, c("data", "metadata")) - expect_s3_class(res$data, class = "data.frame") - expect_s3_class(res$metadata, class = "data.frame") -}) - -test_that("read_from_redcap works with valid input", { - res <- read_from_redcap( - uri = "https://bbmc.ouhsc.edu/redcap/api/", - token = "9A81268476645C4E5F03428B8AC3AA7B", - id_position = NULL, - id_col_name = "record_id", - records = NULL, - fields = NULL - ) - expect_type(res, "list") - expect_length(res, 2) - expect_named(res, c("data", "metadata")) - expect_s3_class(res$data, class = "data.frame") - expect_s3_class(res$metadata, class = "data.frame") -}) - -test_that("read_from_redcap works with valid input", { - res <- read_from_redcap( - uri = "https://bbmc.ouhsc.edu/redcap/api/", - token = "9A81268476645C4E5F03428B8AC3AA7B", - id_position = 1, - id_col_name = NULL, - fields = c("record_id", "name_first", "age", "bmi"), - records = c("1", "3", "5") - ) - expect_type(res, "list") - expect_length(res, 2) - expect_named(res, c("data", "metadata")) - expect_s3_class(res$data, class = "data.frame") - expect_s3_class(res$metadata, class = "data.frame") -}) - -test_that("read_from_redcap works with valid input", { - res <- read_from_redcap( - uri = "https://bbmc.ouhsc.edu/redcap/api/", - token = "9A81268476645C4E5F03428B8AC3AA7B", - id_position = NULL, - id_col_name = "record_id", - fields = c("record_id", "name_first", "age", "bmi"), - records = c("1", "3", "5") - ) - expect_type(res, "list") - expect_length(res, 2) - expect_named(res, c("data", "metadata")) - expect_s3_class(res$data, class = "data.frame") - expect_s3_class(res$metadata, class = "data.frame") -}) - -test_that("read_from_redcap works with valid input", { - res <- read_from_redcap( - uri = "https://bbmc.ouhsc.edu/redcap/api/", - token = "9A81268476645C4E5F03428B8AC3AA7B", - id_position = 1, - id_col_name = NULL, - fields = "record_id,name_first,age,bmi", - records = "1,3,5" - ) - expect_type(res, "list") - expect_length(res, 2) - expect_named(res, c("data", "metadata")) - expect_s3_class(res$data, class = "data.frame") - expect_s3_class(res$metadata, class = "data.frame") -}) - -test_that("read_from_redcap works with valid input", { - res <- read_from_redcap( - uri = "https://bbmc.ouhsc.edu/redcap/api/", - token = "9A81268476645C4E5F03428B8AC3AA7B", - id_position = NULL, - id_col_name = "record_id", - fields = "record_id,name_first,age,bmi", - records = "1,3,5" - ) - expect_type(res, "list") - expect_length(res, 2) - expect_named(res, c("data", "metadata")) - expect_s3_class(res$data, class = "data.frame") - expect_s3_class(res$metadata, class = "data.frame") -}) - -test_that("read_from_redcap works with valid input", { - res <- read_from_redcap( - uri = "https://bbmc.ouhsc.edu/redcap/api/", - token = "9A81268476645C4E5F03428B8AC3AA7B", - id_position = 1, - id_col_name = NULL, - fields = NULL, - records = "1,3,5" - ) - expect_type(res, "list") - expect_length(res, 2) - expect_named(res, c("data", "metadata")) - expect_s3_class(res$data, class = "data.frame") - expect_s3_class(res$metadata, class = "data.frame") -}) - -test_that("read_from_redcap works with valid input", { - res <- read_from_redcap( - uri = "https://bbmc.ouhsc.edu/redcap/api/", - token = "9A81268476645C4E5F03428B8AC3AA7B", - id_position = NULL, - id_col_name = "record_id", - fields = NULL, - records = "1,3,5" - ) - expect_type(res, "list") - expect_length(res, 2) - expect_named(res, c("data", "metadata")) - expect_s3_class(res$data, class = "data.frame") - expect_s3_class(res$metadata, class = "data.frame") -}) - -test_that("read_from_redcap works with valid input", { - res <- read_from_redcap( - uri = "https://bbmc.ouhsc.edu/redcap/api/", - token = "9A81268476645C4E5F03428B8AC3AA7B", - id_position = 1, - id_col_name = NULL, - fields = "record_id, name_first, age, bmi", - records = NULL - ) - expect_type(res, "list") - expect_length(res, 2) - expect_named(res, c("data", "metadata")) - expect_s3_class(res$data, class = "data.frame") - expect_s3_class(res$metadata, class = "data.frame") -}) - -test_that("read_from_redcap works with valid input", { - res <- read_from_redcap( - uri = "https://bbmc.ouhsc.edu/redcap/api/", - token = "9A81268476645C4E5F03428B8AC3AA7B", - id_position = NULL, - id_col_name = "record_id", - fields = "record_id, name_first, age, bmi", - records = NULL - ) - expect_type(res, "list") - expect_length(res, 2) - expect_named(res, c("data", "metadata")) - expect_s3_class(res$data, class = "data.frame") - expect_s3_class(res$metadata, class = "data.frame") -}) - -test_that("read_from_redcap works with valid input", { - res <- read_from_redcap( - uri = "https://bbmc.ouhsc.edu/redcap/api/", - token = "9A81268476645C4E5F03428B8AC3AA7B", - id_position = NULL, - id_col_name = "record_id", - fields = "record_id, name_first, age, bmi", - records = "1, 3, 5" - ) - expect_type(res, "list") - expect_length(res, 2) - expect_named(res, c("data", "metadata")) - expect_s3_class(res$data, class = "data.frame") - expect_s3_class(res$metadata, class = "data.frame") -}) - -test_that("read_from_redcap works with valid input", { - res <- read_from_redcap( - uri = "https://bbmc.ouhsc.edu/redcap/api/", - token = "9A81268476645C4E5F03428B8AC3AA7B", - id_position = 1, - id_col_name = NULL, - fields = "record_id, name_first, age, bmi", - records = "1, 3, 5" - ) - expect_type(res, "list") - expect_length(res, 2) - expect_named(res, c("data", "metadata")) - expect_s3_class(res$data, class = "data.frame") - expect_s3_class(res$metadata, class = "data.frame") -}) - -test_that("read_from_redcap works with valid input", { - res <- read_from_redcap( - uri = "https://bbmc.ouhsc.edu/redcap/api/", - token = "9A81268476645C4E5F03428B8AC3AA7B", - id_position = 1, - id_col_name = NULL, - fields = NULL, - records = c("1", "3", "5") - ) - expect_type(res, "list") - expect_length(res, 2) - expect_named(res, c("data", "metadata")) - expect_s3_class(res$data, class = "data.frame") - expect_s3_class(res$metadata, class = "data.frame") -}) - -test_that("read_from_redcap works with valid input", { - res <- read_from_redcap( - uri = "https://bbmc.ouhsc.edu/redcap/api/", - token = "9A81268476645C4E5F03428B8AC3AA7B", - id_position = NULL, - id_col_name = "record_id", - fields = NULL, - records = c("1", "3", "5") - ) - expect_type(res, "list") - expect_length(res, 2) - expect_named(res, c("data", "metadata")) - expect_s3_class(res$data, class = "data.frame") - expect_s3_class(res$metadata, class = "data.frame") -}) - -test_that("read_from_redcap works with valid input", { - res <- read_from_redcap( - uri = "https://bbmc.ouhsc.edu/redcap/api/", - token = "9A81268476645C4E5F03428B8AC3AA7B", - id_position = 1, - id_col_name = NULL, - fields = c("record_id", "name_first", "age", "bmi"), - records = NULL - ) - expect_type(res, "list") - expect_length(res, 2) - expect_named(res, c("data", "metadata")) - expect_s3_class(res$data, class = "data.frame") - expect_s3_class(res$metadata, class = "data.frame") -}) - -test_that("read_from_redcap works with valid input", { - res <- read_from_redcap( - uri = "https://bbmc.ouhsc.edu/redcap/api/", - token = "9A81268476645C4E5F03428B8AC3AA7B", - id_position = NULL, - id_col_name = "record_id", - fields = c("record_id", "name_first", "age", "bmi"), - records = NULL - ) - expect_type(res, "list") - expect_length(res, 2) - expect_named(res, c("data", "metadata")) - expect_s3_class(res$data, class = "data.frame") - expect_s3_class(res$metadata, class = "data.frame") -}) - -test_that("read_from_redcap fails with incorrect id_position", { - expect_error( - read_from_redcap( - uri = "https://bbmc.ouhsc.edu/redcap/api/", - token = "9A81268476645C4E5F03428B8AC3AA7B", - id_position = "1", - id_col_name = NULL, - fields = c("record_id", "name_first", "age", "bmi"), - records = c("1", "3", "5") - ), - regexp = cat("Assertion on',id_position,'failed: Must be of type 'numeric' - not 'character'.") - ) - - expect_error( - read_from_redcap( - uri = "https://bbmc.ouhsc.edu/redcap/api/", - token = "9A81268476645C4E5F03428B8AC3AA7B", - id_position = -1, - id_col_name = NULL, - fields = c("record_id", "name_first", "age", "bmi"), - records = c("1", "3", "5") - ), - regexp = cat("Assertion on',id_position,'failed: Negative value not - allowed.") - ) - - expect_error( - read_from_redcap( - uri = "https://bbmc.ouhsc.edu/redcap/api/", - token = "9A81268476645C4E5F03428B8AC3AA7B", - id_position = 0, - id_col_name = NULL, - fields = c("record_id", "name_first", "age", "bmi"), - records = c("1", "3", "5") - ), - regexp = cat("Assertion on',id_position,'failed: Must be greater than or - equal to 1.") - ) - - expect_error( - read_from_redcap( - uri = "https://bbmc.ouhsc.edu/redcap/api/", - token = "9A81268476645C4E5F03428B8AC3AA7B", - id_position = NA, - id_col_name = NULL, - fields = c("record_id", "name_first", "age", "bmi"), - records = c("1", "3", "5") - ), - regexp = cat("Assertion on',id_position,'failed: Missing value not - allowed.") - ) -}) - -test_that("read_from_redcap fails with wrong token", { - expect_error( - read_from_redcap( - uri = "https://bbmc.ouhsc.edu/redcap/api/", - token = 1234, - id_position = 1, - id_col_name = NULL, - fields = c("record_id", "name_first", "age", "bmi"), - records = c("1", "3", "5") - ), - regexp = cat("Assertion on',token,'failed: Must be of type 'character' - not numeric") - ) - - expect_error( - read_from_redcap( - uri = "https://bbmc.ouhsc.edu/redcap/api/", - token = "1234", - id_position = 1, - id_col_name = NULL, - fields = c("record_id", "name_first", "age", "bmi"), - records = c("1", "3", "5") - ), - regexp = cat("Assertion on',token,'failed: Must be of length 32.") - ) - - expect_error( - read_from_redcap( - uri = "https://bbmc.ouhsc.edu/redcap/api/", - token = c("9A81268476645C4E5F03428B8AC3AA7B", - "9A81268476645C4E5F03428B8AC3AA7B"), - id_position = 1, - id_col_name = NULL, - fields = c("record_id", "name_first", "age", "bmi"), - records = c("1", "3", "5") - ), - regexp = cat("Assertion on',token,'failed: Multiple tokens not allowed. - Please provide only 1 token.") - ) - - expect_error( - read_from_redcap( - uri = "https://bbmc.ouhsc.edu/redcap/api/", - token = NULL, - id_position = 1, - id_col_name = NULL, - fields = c("record_id", "name_first", "age", "bmi"), - records = c("1", "3", "5") - ), - regexp = cat("Assertion on',token,'failed: Must be provided.") - ) - - expect_error( - read_from_redcap( - uri = "https://bbmc.ouhsc.edu/redcap/api/", - token = NA, - id_position = 1, - id_col_name = NULL, - fields = c("record_id", "name_first", "age", "bmi"), - records = c("1", "3", "5") - ), - regexp = cat("Assertion on',token,'failed: Missing value not allowed.") - ) -}) - -test_that("read_from_redcap fails with incorrect URI", { - expect_error( - read_from_redcap( - uri = NULL, - token = "9A81268476645C4E5F03428B8AC3AA7B", - id_position = 1, - id_col_name = NULL, - fields = c("record_id", "name_first", "age", "bmi"), - records = c("1", "3", "5") - ), - regexp = cat("Assertion on',uri,'failed: Must be provided.") - ) - - expect_error( - read_from_redcap( - uri = NA, - token = "9A81268476645C4E5F03428B8AC3AA7B", - id_position = 1, - id_col_name = NULL, - fields = c("record_id", "name_first", "age", "bmi"), - records = c("1", "3", "5") - ), - regexp = cat("Assertion on',uri,'failed: Missing value not allowed.") - ) - - expect_error( - read_from_redcap( - uri = c("https://bbmc.ouhsc.edu/redcap/api/", - "https://bbmc.ouhsc.edu/redcap/api/"), - token = "9A81268476645C4E5F03428B8AC3AA7B", - id_position = 1, - id_col_name = NULL, - fields = c("record_id", "name_first", "age", "bmi"), - records = c("1", "3", "5") - ), - regexp = cat("Assertion on',uri,'failed: Multiple URI not allowed. Please - provide only 1 URI.") - ) -}) - -test_that("read_from_redcap fails with incorrect records", { - expect_error( - read_from_redcap( - uri = "https://bbmc.ouhsc.edu/redcap/api/", - token = "9A81268476645C4E5F03428B8AC3AA7B", - id_position = 1, - id_col_name = NULL, - fields = c("record_id", "name_first", "age", "bmi"), - records = NA - ), - regexp = cat("Assertion on',records,'failed: Missing value not allowed.") - ) - - expect_error( - read_from_redcap( - uri = "https://bbmc.ouhsc.edu/redcap/api/", - token = "9A81268476645C4E5F03428B8AC3AA7B", - id_position = NULL, - id_col_name = "record_id", - fields = c("record_id", "name_first", "age", "bmi"), - records = NA - ), - regexp = cat("Assertion on',records,'failed: Missing value not allowed.") - ) -}) - -test_that("read_from_redcap fails with incorrect fields", { - expect_error( - read_from_redcap( - uri = "https://bbmc.ouhsc.edu/redcap/api/", - token = "9A81268476645C4E5F03428B8AC3AA7B", - id_position = 1, - id_col_name = NULL, - fields = NA, - records = c("1", "2", "3") - ), - regexp = cat("Assertion on',fileds,'failed: Missing value not allowed.") - ) - - expect_error( - read_from_redcap( - uri = "https://bbmc.ouhsc.edu/redcap/api/", - token = "9A81268476645C4E5F03428B8AC3AA7B", - id_position = NULL, - id_col_name = "record_id", - fields = NA, - records = c("1", "2", "3") - ), - regexp = cat("Assertion on',fileds,'failed: Missing value not allowed.") - ) -}) - -test_that("read_from_redcap fails with incorrect id_col_name", { - expect_error( - read_from_redcap( - uri = "https://bbmc.ouhsc.edu/redcap/api/", - token = "9A81268476645C4E5F03428B8AC3AA7B", - id_position = NULL, - id_col_name = NA, - fields = c("record_id", "name_first", "age", "bmi"), - records = c("1", "2", "3") - ), - regexp = cat("Assertion on',id_col_name,'failed: Missing value - not allowed.") - ) - - expect_error( - read_from_redcap( - uri = "https://bbmc.ouhsc.edu/redcap/api/", - token = "9A81268476645C4E5F03428B8AC3AA7B", - id_position = NULL, - id_col_name = c("record_id", "name_first"), - fields = c("record_id", "name_first", "age", "bmi"), - records = c("1", "2", "3") - ), - regexp = cat("Assertion on',id_col_name,'failed: Multiple ID columns not - allowed. Please specify 1 ID column name.") - ) ->>>>>>> main }) diff --git a/tests/testthat/test-read_from_redcap_helpers.R b/tests/testthat/test-read_from_redcap_helpers.R deleted file mode 100644 index ba935424..00000000 --- a/tests/testthat/test-read_from_redcap_helpers.R +++ /dev/null @@ -1,181 +0,0 @@ -httptest::with_mock_api({ - test_that("import_redcap_data works as expected", { - result <- import_redcap_data( - uri = file.path("https:/", "bbmc.ouhsc.edu", "redcap", "api", ""), - token = "9A81268476645C4E5F03428B8AC3AA7B", - records = c("1", "3", "5"), - fields = c("record_id", "name_first", "age", "bmi"), - id_col_name = NULL, - id_position = 1L - ) - expect_type(result, "list") - expect_length(result, 2L) - expect_named(result, c("redcap_data", "metadata")) - expect_type(result[["redcap_data"]], "list") - expect_type(result[["metadata"]], "list") - expect_length(result[["redcap_data"]], 12L) - expect_length(result[["metadata"]], 8L) - }) - - test_that("redcap_get_results works as expected", { - result <- redcap_get_results( - redcap_data = REDCapR::redcap_read( - redcap_uri = "https://bbmc.ouhsc.edu/redcap/api/", - token = "9A81268476645C4E5F03428B8AC3AA7B", - records = c("1", "3", "5"), - fields = c("record_id", "name_first", "age", "bmi"), verbose = FALSE, - id_position = 1L - ), - metadata = REDCapR::redcap_metadata_read( - redcap_uri = "https://bbmc.ouhsc.edu/redcap/api/", - token = "9A81268476645C4E5F03428B8AC3AA7B", - fields = NULL, - verbose = FALSE - ) - ) - expect_type(result, "list") - expect_length(result, 2L) - expect_named(result, c("data", "meta")) - expect_s3_class(result[["data"]], "data.frame") - expect_s3_class(result[["meta"]], "data.frame") - }) - - test_that("redcap_get_results fails with bad redcap_data", { - expect_error( - redcap_get_results( - redcap_data = NULL, - metadata = REDCapR::redcap_metadata_read( - redcap_uri = "https://bbmc.ouhsc.edu/redcap/api/", - token = "9A81268476645C4E5F03428B8AC3AA7B", - fields = NULL, - verbose = FALSE - ) - ), - regexp = cat("Assertion on',redcap_data,'failed: Must be provided") - ) - - expect_error( - redcap_get_results( - redcap_data = NA, - metadata = REDCapR::redcap_metadata_read( - redcap_uri = "https://bbmc.ouhsc.edu/redcap/api/", - token = "9A81268476645C4E5F03428B8AC3AA7B", - fields = NULL, - verbose = FALSE - ) - ), - regexp = cat("Assertion on',redcap_data,'failed: Missing value not allowed - for redcap_data") - ) - }) - - test_that("redcap_get_results fails with bad metadata", { - expect_error( - redcap_get_results( - redcap_data = REDCapR::redcap_read( - redcap_uri = "https://bbmc.ouhsc.edu/redcap/api/", - token = "9A81268476645C4E5F03428B8AC3AA7B", - records = c("1", "3", "5"), - fields = c("record_id", "name_first", "age", "bmi"), verbose = FALSE, - id_position = 1L - ), - metadata = NULL - ), - regexp = cat("Assertion on',metadata,'failed: Must be provided") - ) - - expect_error( - redcap_get_results( - redcap_data = REDCapR::redcap_read( - redcap_uri = "https://bbmc.ouhsc.edu/redcap/api/", - token = "9A81268476645C4E5F03428B8AC3AA7B", - records = c("1", "3", "5"), - fields = c("record_id", "name_first", "age", "bmi"), verbose = FALSE, - id_position = 1L - ), - metadata = NA - ), - regexp = cat("Assertion on',metadata,'failed: Missing value not allowed - for metadata") - ) - }) - - test_that("redcap_read_data works as expected", { - result <- redcap_read_data( - uri = "https://bbmc.ouhsc.edu/redcap/api/", - token = "9A81268476645C4E5F03428B8AC3AA7B", - id_position = 1L - ) - expect_type(result, "list") - expect_length(result, 2L) - expect_named(result, c("redcap_data", "metadata")) - expect_type(result[["redcap_data"]], "list") - expect_type(result[["metadata"]], "list") - expect_length(result[["redcap_data"]], 12L) - expect_length(result[["metadata"]], 8L) - }) - - test_that("redcap_read_rows_columns works as expected", { - result <- redcap_read_rows_columns( - uri = "https://bbmc.ouhsc.edu/redcap/api/", - token = "9A81268476645C4E5F03428B8AC3AA7B", - id_position = 1L, - id_col_name = NULL, - fields = c("record_id", "name_first", "age", "bmi"), - records = c("1", "3", "5") - ) - expect_type(result, "list") - expect_length(result, 2L) - expect_named(result, c("redcap_data", "metadata")) - expect_type(result[["redcap_data"]], "list") - expect_type(result[["metadata"]], "list") - expect_length(result[["redcap_data"]], 12L) - expect_length(result[["metadata"]], 8L) - }) - - test_that("redcap_read_fields works as expected", { - result <- redcap_read_fields( - uri = "https://bbmc.ouhsc.edu/redcap/api/", - token = "9A81268476645C4E5F03428B8AC3AA7B", - id_position = 1L, - fields = c("record_id", "name_first", "age", "bmi") - ) - expect_type(result, "list") - expect_length(result, 2L) - expect_named(result, c("redcap_data", "metadata")) - expect_type(result[["redcap_data"]], "list") - expect_type(result[["metadata"]], "list") - expect_length(result[["redcap_data"]], 12L) - expect_length(result[["metadata"]], 8L) - }) - - test_that("redcap_read_records works as expected", { - result <- redcap_read_records( - uri = "https://bbmc.ouhsc.edu/redcap/api/", - token = "9A81268476645C4E5F03428B8AC3AA7B", - id_position = 1L, - records = c("1", "2", "3"), - id_col_name = NULL - ) - expect_type(result, "list") - expect_length(result, 2L) - expect_named(result, c("redcap_data", "metadata")) - expect_type(result[["redcap_data"]], "list") - expect_type(result[["metadata"]], "list") - expect_length(result[["redcap_data"]], 12L) - expect_length(result[["metadata"]], 8L) - }) - - test_that("redcap_read_records fails as expected", { - expect_error( - redcap_read_records( - uri = "https://bbmc.ouhsc.edu/redcap/api/", - token = "9A81268476645C4E5F03428B8AC3AA7B", - id_position = NULL, - records = c("1", "2", "3"), - id_col_name = "Karim" - ), - regexp = cat("'Karim' is an invalid column name.") - ) - }) -}) diff --git a/tests/testthat/test-read_servers.R b/tests/testthat/test-read_servers.R index b7acbfbe..eb626c5e 100644 --- a/tests/testthat/test-read_servers.R +++ b/tests/testthat/test-read_servers.R @@ -3,31 +3,19 @@ test_that("sql_server_read_data works as expected", { user = "rfamro", password = "", host = "mysql-rfam-public.ebi.ac.uk", -<<<<<<< HEAD port = 4497L, -======= - port = 4497, ->>>>>>> main database_name = "Rfam", source = "author", driver_name = "", dbms = "MySQL" -<<<<<<< HEAD ) -======= - ) ->>>>>>> main expect_type(result, "list") result <- sql_server_read_data( user = "rfamro", password = "", host = "mysql-rfam-public.ebi.ac.uk", -<<<<<<< HEAD port = 4497L, -======= - port = 4497, ->>>>>>> main database_name = "Rfam", source = "select * from author", driver_name = "", diff --git a/tests/testthat/test-read_servers_helpers.R b/tests/testthat/test-read_servers_helpers.R index d920a7eb..7eeabe8a 100644 --- a/tests/testthat/test-read_servers_helpers.R +++ b/tests/testthat/test-read_servers_helpers.R @@ -6,302 +6,9 @@ test_that("connect_to_server works as expected", { database_name = "Rfam", user = "rfamro", password = "", -<<<<<<< HEAD port = 4497L ) expect_type(con, "environment") -======= - port = 4497 - ) -}) - -test_that("connect_to_server fails with incorrect dbms", { - expect_error( - connect_to_server( - dbms = NA, - driver_name = "", - host = "mysql-rfam-public.ebi.ac.uk", - database_name = "Rfam", - user = "rfamro", - password = "", - port = 4497 - ), - regexp = cat("Assertion on',dbms,'failed: Missing value not - allowed.") - ) - - expect_error( - connect_to_server( - dbms = NULL, - driver_name = "", - host = "mysql-rfam-public.ebi.ac.uk", - database_name = "Rfam", - user = "rfamro", - password = "", - port = 4497 - ), - regexp = cat("Assertion on',dbms,'failed: Must be provided.") - ) - - expect_error( - connect_to_server( - dbms = c("MySQL", "test"), - driver_name = "", - host = "mysql-rfam-public.ebi.ac.uk", - database_name = "Rfam", - user = "rfamro", - password = "", - port = 4497 - ), - regexp = cat("Assertion on',dbms,'failed: Must be of type character - with length 1.") - ) -}) - -test_that("connect_to_server fails with incorrect driver_name", { - expect_error( - connect_to_server( - dbms = "MySQL", - driver_name = NA, - host = "mysql-rfam-public.ebi.ac.uk", - database_name = "Rfam", - user = "rfamro", - password = "", - port = 4497 - ), - regexp = cat("Assertion on',driver_name,'failed: Missing value not - allowed.") - ) - - expect_error( - connect_to_server( - dbms = "MySQL", - driver_name = NULL, - host = "mysql-rfam-public.ebi.ac.uk", - database_name = "Rfam", - user = "rfamro", - password = "", - port = 4497 - ), - regexp = cat("Assertion on',driver_name,'failed: Must be provided.") - ) - - expect_error( - connect_to_server( - dbms = "MySQL", - driver_name = c("ODBC Driver 17 for SQL Server", ""), - host = "mysql-rfam-public.ebi.ac.uk", - database_name = "Rfam", - user = "rfamro", - password = "", - port = 4497 - ), - regexp = cat("Assertion on',driver_name,'failed: Must be of type charater - with length 1.") - ) -}) - -test_that("connect_to_server fails with incorrect host", { - expect_error( - connect_to_server( - dbms = "MySQL", - driver_name = "", - host = NA, - database_name = "Rfam", - user = "rfamro", - password = "", - port = 4497 - ), - regexp = cat("Assertion on',host,'failed: Missing value not - allowed for host name.") - ) - - expect_error( - connect_to_server( - dbms = "MySQL", - driver_name = "", - host = NULL, - database_name = "Rfam", - user = "rfamro", - password = "", - port = 4497 - ), - regexp = cat("Assertion on',host,'failed: Must be provided.") - ) - - expect_error( - connect_to_server( - dbms = "MySQL", - driver_name = "", - host = c("mysql-rfam-public.ebi.ac.uk", "test"), - database_name = "Rfam", - user = "rfamro", - password = "", - port = 4497 - ), - regexp = cat("Assertion on',host,'failed: Must be of type character - with length 1.") - ) -}) - -test_that("connect_to_server fails with incorrect database_name", { - expect_error( - connect_to_server( - dbms = "MySQL", - driver_name = "", - host = "mysql-rfam-public.ebi.ac.uk", - database_name = NA, - user = "rfamro", - password = "", - port = 4497 - ), - regexp = cat("Assertion on',database_name,'failed: Missing value not - allowed for database_name name.") - ) - - expect_error( - connect_to_server( - dbms = "MySQL", - driver_name = "", - host = "mysql-rfam-public.ebi.ac.uk", - database_name = NULL, - user = "rfamro", - password = "", - port = 4497 - ), - regexp = cat("Assertion on',database_name,'failed: Must be provided.") - ) - - expect_error( - connect_to_server( - dbms = "MySQL", - driver_name = "", - host = "mysql-rfam-public.ebi.ac.uk", - database_name = c("Rfam", "test"), - user = "rfamro", - password = "", - port = 4497 - ), - regexp = cat("Assertion on',database_name,'failed: Must be of type character - with length 1.") - ) -}) - -test_that("connect_to_server fails with incorrect user", { - expect_error( - connect_to_server( - dbms = "MySQL", - driver_name = "", - host = "mysql-rfam-public.ebi.ac.uk", - database_name = "Rfam", - user = NA, - password = "", - port = 4497 - ), - regexp = cat("Assertion on',user,'failed: Missing value not - allowed for user name.") - ) - - expect_error( - connect_to_server( - dbms = "MySQL", - driver_name = "", - host = "mysql-rfam-public.ebi.ac.uk", - database_name = "Rfam", - user = NULL, - password = "", - port = 4497 - ), - regexp = cat("Assertion on',user,'failed: Must be provided.") - ) - - expect_error( - connect_to_server( - dbms = "MySQL", - driver_name = "", - host = "mysql-rfam-public.ebi.ac.uk", - database_name = "Rfam", - user = c("rfamro", "test"), - password = "", - port = 4497 - ), - regexp = cat("Assertion on',user,'failed: Must be of type character - with length 1.") - ) -}) - -test_that("connect_to_server fails with incorrect password", { - expect_error( - connect_to_server( - dbms = "MySQL", - driver_name = "", - host = "mysql-rfam-public.ebi.ac.uk", - database_name = "Rfam", - user = "rfamro", - password = NA, - port = 4497 - ), - regexp = cat("Assertion on',password,'failed: Missing value not - allowed for password name.") - ) - - expect_error( - connect_to_server( - dbms = "MySQL", - driver_name = "", - host = "mysql-rfam-public.ebi.ac.uk", - database_name = "Rfam", - user = "rfamro", - password = NULL, - port = 4497 - ), - regexp = cat("Assertion on',user,'failed: Must be provided.") - ) - - expect_error( - connect_to_server( - dbms = "MySQL", - driver_name = "", - host = "mysql-rfam-public.ebi.ac.uk", - database_name = "Rfam", - user = "rfamro", - password = c("", "pass"), - port = 4497 - ), - regexp = cat("Assertion on',password,'failed: Must be of type character - with length 1.") - ) -}) - -test_that("connect_to_server fails with incorrect port", { - expect_error( - connect_to_server( - dbms = "MySQL", - driver_name = "", - host = "mysql-rfam-public.ebi.ac.uk", - database_name = "Rfam", - user = "rfamro", - password = "", - port = -4497 - ), - regexp = cat("Assertion on',port,'failed: Negative value not - allowed for port name.") - ) - - expect_error( - connect_to_server( - dbms = "MySQL", - driver_name = "", - host = "mysql-rfam-public.ebi.ac.uk", - database_name = "Rfam", - user = "rfamro", - password = "", - port = 0 - ), - regexp = cat("Assertion on',port,'failed: Must be greater than or - equal to 1.") - ) ->>>>>>> main }) test_that("identify_table_name works as expected", { @@ -310,11 +17,8 @@ test_that("identify_table_name works as expected", { tables = c("family_author", "author", "test") ) expect_type(table_name, "character") -<<<<<<< HEAD expect_length(table_name, 1L) expect_identical(table_name, "author") -======= ->>>>>>> main }) test_that("identify_table_name fails with an incorrect query", { @@ -324,11 +28,7 @@ test_that("identify_table_name fails with an incorrect query", { tables = c("family_author", "author", "test") ), regexp = cat("Assertion on',query,'failed: Missing value not allowed for -<<<<<<< HEAD the 'query' argument.") -======= - query.") ->>>>>>> main ) expect_error( @@ -356,11 +56,7 @@ test_that("identify_table_name fails with incorrect tables", { tables = NA ), regexp = cat("Assertion on',tables,'failed: Missing value not allowed for -<<<<<<< HEAD the 'tables' argument.") -======= - tables.") ->>>>>>> main ) expect_error( @@ -382,7 +78,6 @@ test_that("fetch_data_from_query works as expected", { database_name = "Rfam", user = "rfamro", password = "", -<<<<<<< HEAD port = 4497L ) expect_type(result, "list") @@ -422,11 +117,6 @@ test_that("fetch_data_from_query fails with incorrect tables", { ), regexp = cat("Assertion on',tables,'failed: Must be provided.") ) -======= - port = 4497 - ) - expect_type(result, "list") ->>>>>>> main }) test_that("sql_select_data works as expected", { @@ -442,7 +132,6 @@ test_that("sql_select_data works as expected", { database_name = "Rfam", user = "rfamro", password = "", -<<<<<<< HEAD port = 4497L ) expect_type(result, "list") @@ -548,17 +237,11 @@ test_that("sql_select_data fails with incorrect table_names", { ), regexp = cat("Assertion on',tables,'failed: Must be provided.") ) -======= - port = 4497 - ) - expect_type(result, "list") ->>>>>>> main }) test_that("get_id_column_name works as expected", { result <- get_id_column_name( id_col_name = c("author_id", "rfam_acc"), -<<<<<<< HEAD j = 1L, id_position = c(1, 1) # nolint ) @@ -598,12 +281,6 @@ test_that("sql_select_data fails with incorrect j", { ), regexp = cat("Assertion on',j,'failed: Must be a numeric with length 1.") ) -======= - j = 1, - id_position = c(1, 1) - ) - expect_type(result, "list") ->>>>>>> main }) test_that("sql_select_entire_dataset works as expected", { @@ -615,16 +292,11 @@ test_that("sql_select_entire_dataset works as expected", { database_name = "Rfam", user = "rfamro", password = "", -<<<<<<< HEAD port = 4497L -======= - port = 4497 ->>>>>>> main ) expect_s3_class(result, "data.frame") }) -<<<<<<< HEAD test_that("sql_select_entire_dataset fails with incorrect table", { expect_error( sql_select_entire_dataset( @@ -670,27 +342,10 @@ test_that("sql_select_records_and_fields works as expected", { user = "rfamro", password = "", port = 4497L -======= -test_that("sql_select_records_and_fields works as expected", { - result <- sql_select_records_and_fields( - table = "author", - record = c("1", "20", "50"), - id_column_name = "author_id", - field = c("author_id", "last_name"), - id_pos = NULL, - dbms = "MySQL", - driver_name = "", - host = "mysql-rfam-public.ebi.ac.uk", - database_name = "Rfam", - user = "rfamro", - password = "", - port = 4497 ->>>>>>> main ) expect_s3_class(result, "data.frame") }) -<<<<<<< HEAD test_that("sql_select_records_and_fields fails as expected", { expect_error( sql_select_records_and_fields( @@ -779,21 +434,12 @@ test_that("visualise_table works as expected", { credentials_file = system.file("extdata", "test.ini", package = "readepi"), from = "author", driver_name = "" -======= -test_that("visualise_table works as expected", { - result <- visualise_table( - credentials_file <- system.file("extdata", "test.ini", package = "readepi"), - source = "author", - project_id = "Rfam", - driver_name = "" ->>>>>>> main ) expect_s3_class(result, "data.frame") }) test_that("sql_select_records_only works as expected", { result <- sql_select_records_only( -<<<<<<< HEAD table = "author", record = c("1", "20", "50"), id_column_name = NULL, @@ -805,26 +451,12 @@ test_that("sql_select_records_only works as expected", { user = "rfamro", password = "", port = 4497L -======= - table = "author", - record = c("1", "20", "50"), - id_column_name = NULL, - id_pos = 1, - dbms = "MySQL", - driver_name = "", - host = "mysql-rfam-public.ebi.ac.uk", - database_name = "Rfam", - user = "rfamro", - password = "", - port = 4497 ->>>>>>> main ) expect_s3_class(result, "data.frame") }) test_that("sql_select_fields_only works as expected", { result <- sql_select_fields_only( -<<<<<<< HEAD table = "author", field = c("author_id", "name", "last_name"), dbms = "MySQL", @@ -834,17 +466,6 @@ test_that("sql_select_fields_only works as expected", { user = "rfamro", password = "", port = 4497L -======= - table = "author", - field = c("author_id", "name", "last_name"), - dbms = "MySQL", - driver_name = "", - host = "mysql-rfam-public.ebi.ac.uk", - database_name = "Rfam", - user = "rfamro", - password = "", - port = 4497 ->>>>>>> main ) expect_s3_class(result, "data.frame") }) diff --git a/tests/testthat/test-readepi.R b/tests/testthat/test-readepi.R index 49bb23f4..9c2b6b6b 100644 --- a/tests/testthat/test-readepi.R +++ b/tests/testthat/test-readepi.R @@ -1,6 +1,5 @@ test_that("readepi works as expected when reading from DBMS", { data <- readepi( -<<<<<<< HEAD data_source = "mysql-rfam-public.ebi.ac.uk", credentials_file = system.file("extdata", "test.ini", package = "readepi"), driver_name = "", @@ -9,42 +8,18 @@ test_that("readepi works as expected when reading from DBMS", { fields = NULL, id_position = 1L, id_col_name = NULL -======= - credentials_file = system.file("extdata", "test.ini", package = "readepi"), - project_id = "Rfam", - file_path = NULL, - sep = NULL, - format = NULL, - which = NULL, - pattern = NULL, - driver_name = "", - table_name = "author", - records = NULL, - fields = NULL, - id_position = 1, - id_col_name = NULL ->>>>>>> main ) expect_type(data, "list") }) test_that("readepi works as expected when reading from Fingertips", { data <- readepi( -<<<<<<< HEAD indicator_id = 90362L, area_type_id = 202L, indicator_name = "Healthy life expectancy at birth", domain_id = 1000049L, domain_name = "A. Overarching indicators", profile_id = 19L, -======= - indicator_id = 90362, - area_type_id = 202, - indicator_name = "Healthy life expectancy at birth", - domain_id = 1000049, - domain_name = "A. Overarching indicators", - profile_id = 19, ->>>>>>> main profile_name = "Public Health Outcomes Framework", fields = c("IndicatorID", "AreaCode", "Age", "Value"), records = c("E12000002", "E12000001", "E12000009"), @@ -53,13 +28,8 @@ test_that("readepi works as expected when reading from Fingertips", { expect_type(data, "list") data <- readepi( -<<<<<<< HEAD indicator_id = 90362L, area_type_id = 202L, -======= - indicator_id = 90362, - area_type_id = 202, ->>>>>>> main records = NULL, fields = NULL, id_position = NULL, @@ -68,13 +38,8 @@ test_that("readepi works as expected when reading from Fingertips", { expect_type(data, "list") data <- readepi( -<<<<<<< HEAD indicator_id = 90362L, area_type_id = 202L, -======= - indicator_id = 90362, - area_type_id = 202, ->>>>>>> main indicator_name = "Healthy life expectancy at birth", records = NULL, fields = NULL, @@ -84,11 +49,7 @@ test_that("readepi works as expected when reading from Fingertips", { expect_type(data, "list") data <- readepi( -<<<<<<< HEAD area_type_id = 202L, -======= - area_type_id = 202, ->>>>>>> main indicator_name = "Healthy life expectancy at birth", records = NULL, fields = NULL, @@ -96,18 +57,12 @@ test_that("readepi works as expected when reading from Fingertips", { id_col_name = NULL ) expect_type(data, "list") -<<<<<<< HEAD expect_length(data, 1L) expect_named(data, "data") expect_s3_class(data[["data"]], "data.frame") data <- readepi( area_type_id = 202L, -======= - - data <- readepi( - area_type_id = 202, ->>>>>>> main domain_name = "A. Overarching indicators", records = NULL, fields = NULL, @@ -117,13 +72,8 @@ test_that("readepi works as expected when reading from Fingertips", { expect_type(data, "list") data <- readepi( -<<<<<<< HEAD area_type_id = 202L, domain_id = 1000049L, -======= - area_type_id = 202, - domain_id = 1000049, ->>>>>>> main records = NULL, fields = NULL, id_position = NULL, @@ -132,13 +82,8 @@ test_that("readepi works as expected when reading from Fingertips", { expect_type(data, "list") data <- readepi( -<<<<<<< HEAD area_type_id = 202L, profile_id = 19L, -======= - area_type_id = 202, - profile_id = 19, ->>>>>>> main records = NULL, fields = NULL, id_position = NULL, @@ -147,11 +92,7 @@ test_that("readepi works as expected when reading from Fingertips", { expect_type(data, "list") data <- readepi( -<<<<<<< HEAD area_type_id = 202L, -======= - area_type_id = 202, ->>>>>>> main profile_name = "Public Health Outcomes Framework", records = NULL, fields = NULL, @@ -161,7 +102,6 @@ test_that("readepi works as expected when reading from Fingertips", { expect_type(data, "list") }) -<<<<<<< HEAD test_that("readepi works as expected when reading from DBMS", { data <- readepi( data_source = "mysql-rfam-public.ebi.ac.uk", @@ -171,79 +111,12 @@ test_that("readepi works as expected when reading from DBMS", { records = NULL, fields = NULL, id_position = 1L -======= - -test_that("readepi works as expected when reading from file", { - data <- readepi( - credentials_file = NULL, - project_id = NULL, - file_path = system.file("extdata", "test.json", package = "readepi"), - sep = NULL, - format = NULL, - which = NULL, - pattern = NULL, - driver_name = NULL, - table_name = NULL, - records = NULL, - fields = NULL, - id_position = 1 - ) - expect_type(data, "list") -}) - -test_that("readepi works as expected when reading from DBMS", { - data <- readepi( - credentials_file = system.file("extdata", "test.ini", package = "readepi"), - project_id = "Rfam", - file_path = NULL, - sep = NULL, - format = NULL, - which = NULL, - pattern = NULL, - driver_name = "", - table_name = "author", - records = NULL, - fields = NULL, - id_position = 1 - ) - expect_type(data, "list") -}) - -test_that("readepi works as expected when reading from a directory", { - data <- readepi( - credentials_file = NULL, - project_id = NULL, - file_path = system.file("extdata", package = "readepi"), - sep = NULL, - format = NULL, - which = NULL, - pattern = "txt", - driver_name = NULL, - table_name = NULL, - records = NULL, - fields = NULL, - id_position = 1 - ) - expect_type(data, "list") -}) - -test_that("readepi works as expected when reading from DHIS2", { - data <- readepi( - credentials_file = system.file("extdata", "test.ini", package = "readepi"), - project_id = "DHIS2_DEMO", - dataset = "pBOMPrpg1QX", - organisation_unit = "DiszpKrYNg8", - data_element_group = NULL, - start_date = "2014", - end_date = "2023" ->>>>>>> main ) expect_type(data, "list") }) test_that("readepi fails as expected when reading from DHIS2", { expect_error( -<<<<<<< HEAD readepi( data_source = "https://play.dhis2.org/dev", credentials_file = NULL, @@ -252,225 +125,118 @@ test_that("readepi fails as expected when reading from DHIS2", { data_element_group = NULL, start_date = "2014", end_date = "202L3" -======= - data <- readepi( - credentials_file = NULL, - project_id = "DHIS2_DEMO", - dataset = "pBOMPrpg1QX", - organisation_unit = "DiszpKrYNg8", - data_element_group = NULL, - start_date = "2014", - end_date = "2023" ->>>>>>> main ), regexp = cat("Assertion on',credentials_file,'failed: Must be specified.") ) expect_error( -<<<<<<< HEAD readepi( data_source = "https://play.dhis2.org/dev", - credentials_file = c( - system.file("extdata", "test.ini", - package = "readepi" - ), - system.file("extdata", "fake_test.ini", - package = "readepi" - ) - ), -======= - data <- readepi( - credentials_file = c( - system.file("extdata", "test.ini", package = "readepi"), - system.file("extdata", "fake_test.ini", package = "readepi") - ), - project_id = "DHIS2_DEMO", ->>>>>>> main + credentials_file = c(system.file("extdata", "test.ini", + package = "readepi"), + system.file("extdata", "fake_test.ini", + package = "readepi")), dataset = "pBOMPrpg1QX", organisation_unit = "DiszpKrYNg8", data_element_group = NULL, start_date = "2014", -<<<<<<< HEAD end_date = "202L3" -======= - end_date = "2023" ->>>>>>> main ), regexp = cat("Assertion on',credentials_file,'failed: Must be of type character with length 1.") ) expect_error( -<<<<<<< HEAD readepi( data_source = "https://play.dhis2.org/dev", - credentials_file = system.file("extdata", "test.ini", - package = "readepi" - ), -======= - data <- readepi( credentials_file = system.file("extdata", "test.ini", package = "readepi"), - project_id = "DHIS2_DEMO", ->>>>>>> main dataset = NA, organisation_unit = "DiszpKrYNg8", data_element_group = NULL, start_date = "2014", -<<<<<<< HEAD end_date = "202L3" -======= - end_date = "2023" ->>>>>>> main ), regexp = cat("Assertion on',dataset,'failed: Missing value not allowed.") ) expect_error( -<<<<<<< HEAD readepi( data_source = "https://play.dhis2.org/dev", - credentials_file = system.file("extdata", "test.ini", - package = "readepi" - ), -======= - data <- readepi( credentials_file = system.file("extdata", "test.ini", package = "readepi"), - project_id = "DHIS2_DEMO", ->>>>>>> main dataset = NULL, organisation_unit = "DiszpKrYNg8", data_element_group = NULL, start_date = "2014", -<<<<<<< HEAD end_date = "202L3" -======= - end_date = "2023" ->>>>>>> main ), regexp = cat("Assertion on',dataset,'failed: Must be specified.") ) expect_error( -<<<<<<< HEAD readepi( data_source = "https://play.dhis2.org/dev", - credentials_file = system.file("extdata", "test.ini", - package = "readepi" - ), -======= - data <- readepi( credentials_file = system.file("extdata", "test.ini", package = "readepi"), - project_id = "DHIS2_DEMO", ->>>>>>> main dataset = "pBOMPrpg1QX", organisation_unit = NA, data_element_group = NULL, start_date = "2014", -<<<<<<< HEAD end_date = "202L3" -======= - end_date = "2023" ->>>>>>> main ), regexp = cat("Assertion on',organisation_unit,'failed: Missing value not allowed.") ) expect_error( -<<<<<<< HEAD readepi( data_source = "https://play.dhis2.org/dev", - credentials_file = system.file("extdata", "test.ini", - package = "readepi" - ), -======= - data <- readepi( credentials_file = system.file("extdata", "test.ini", package = "readepi"), - project_id = "DHIS2_DEMO", ->>>>>>> main dataset = "pBOMPrpg1QX", organisation_unit = NULL, data_element_group = NULL, start_date = "2014", -<<<<<<< HEAD end_date = "202L3" -======= - end_date = "2023" ->>>>>>> main ), regexp = cat("Assertion on',organisation_unit,'failed: Must be specified.") ) expect_error( -<<<<<<< HEAD readepi( data_source = "https://play.dhis2.org/dev", - credentials_file = system.file("extdata", "test.ini", - package = "readepi" - ), -======= - data <- readepi( credentials_file = system.file("extdata", "test.ini", package = "readepi"), - project_id = "DHIS2_DEMO", ->>>>>>> main dataset = "pBOMPrpg1QX", organisation_unit = "DiszpKrYNg8", data_element_group = NA, start_date = "2014", -<<<<<<< HEAD end_date = "202L3" -======= - end_date = "2023" ->>>>>>> main ), regexp = cat("Assertion on',data_element_group,'failed: Missing value not allowed.") ) expect_error( -<<<<<<< HEAD readepi( data_source = "https://play.dhis2.org/dev", - credentials_file = system.file("extdata", "test.ini", - package = "readepi" - ), -======= - data <- readepi( credentials_file = system.file("extdata", "test.ini", package = "readepi"), - project_id = "DHIS2_DEMO", ->>>>>>> main dataset = "pBOMPrpg1QX", organisation_unit = "DiszpKrYNg8", data_element_group = NULL, start_date = NA, -<<<<<<< HEAD end_date = "202L3" -======= - end_date = "2023" ->>>>>>> main ), regexp = cat("Assertion on',start_date,'failed: Missing value not allowed.") ) expect_error( -<<<<<<< HEAD readepi( data_source = "https://play.dhis2.org/dev", - credentials_file = system.file("extdata", "test.ini", - package = "readepi" - ), -======= - data <- readepi( credentials_file = system.file("extdata", "test.ini", package = "readepi"), - project_id = "DHIS2_DEMO", ->>>>>>> main dataset = "pBOMPrpg1QX", organisation_unit = "DiszpKrYNg8", data_element_group = NULL, @@ -483,7 +249,6 @@ test_that("readepi fails as expected when reading from DHIS2", { test_that("readepi works as expected when reading from REDCap", { data <- readepi( -<<<<<<< HEAD data_source = "https://bbmc.ouhsc.edu/redcap/api/", credentials_file = system.file("extdata", "test.ini", package = "readepi"), records = c("1", "3", "5"), @@ -546,93 +311,16 @@ test_that("readepi works as expected when reading from REDCap", { expect_named(data, c("data", "metadata")) expect_s3_class(data[["data"]], class = "data.frame") expect_s3_class(data[["metadata"]], class = "data.frame") -======= - credentials_file = system.file("extdata", "test.ini", package = "readepi"), - project_id = "SD_DATA", - records = c("1", "3", "5"), - fields = c("record_id", "name_first", "age", "bmi"), - id_col_name = "record_id" - ) - expect_type(data, "list") - expect_length(data, 2) - expect_named(data, c("data", "metadata")) - expect_s3_class(data$data, class = "data.frame") - expect_s3_class(data$metadata, class = "data.frame") - - data <- readepi( - credentials_file = system.file("extdata", "test.ini", package = "readepi"), - project_id = "SD_DATA", - records = c("1", "3", "5"), - fields = c("record_id", "name_first", "age", "bmi"), - id_position = 1 - ) - expect_type(data, "list") - expect_length(data, 2) - expect_named(data, c("data", "metadata")) - expect_s3_class(data$data, class = "data.frame") - expect_s3_class(data$metadata, class = "data.frame") - - data <- readepi( - credentials_file = system.file("extdata", "test.ini", package = "readepi"), - project_id = "SD_DATA", - records = "1, 3, 5", - fields = "record_id, name_first, age, bmi", - id_position = 1 - ) - expect_type(data, "list") - expect_length(data, 2) - expect_named(data, c("data", "metadata")) - expect_s3_class(data$data, class = "data.frame") - expect_s3_class(data$metadata, class = "data.frame") - - data <- readepi( - credentials_file = system.file("extdata", "test.ini", package = "readepi"), - project_id = "SD_DATA", - records = "1, 3, 5", - fields = "record_id, name_first, age, bmi", - id_col_name = "record_id" - ) - expect_type(data, "list") - expect_length(data, 2) - expect_named(data, c("data", "metadata")) - expect_s3_class(data$data, class = "data.frame") - expect_s3_class(data$metadata, class = "data.frame") - - data <- readepi( - credentials_file = system.file("extdata", "test.ini", package = "readepi"), - project_id = "SD_DATA", - records = NULL, - fields = NULL - ) - expect_type(data, "list") - expect_length(data, 2) - expect_named(data, c("data", "metadata")) - expect_s3_class(data$data, class = "data.frame") - expect_s3_class(data$metadata, class = "data.frame") ->>>>>>> main }) test_that("readepi fails as expected when reading from REDCap", { expect_error( -<<<<<<< HEAD readepi( - credentials_file = c( - system.file("extdata", "test.ini", - package = "readepi" - ), - system.file("extdata", "fake_test.ini", - package = "readepi" - ) - ), + credentials_file = c(system.file("extdata", "test.ini", + package = "readepi"), + system.file("extdata", "fake_test.ini", + package = "readepi")), data_source = "https://bbmc.ouhsc.edu/redcap/api/", -======= - data <- readepi( - credentials_file = c( - system.file("extdata", "test.ini", package = "readepi"), - system.file("extdata", "fake_test.ini", package = "readepi") - ), - project_id = "SD_DATA", ->>>>>>> main records = "1, 3, 5", fields = "record_id, name_first, age, bmi", id_col_name = "id" @@ -642,38 +330,21 @@ test_that("readepi fails as expected when reading from REDCap", { ) expect_error( -<<<<<<< HEAD readepi( credentials_file = NULL, data_source = "https://bbmc.ouhsc.edu/redcap/api/", records = "1, 3, 5", fields = "record_id, name_first, age, bmi", id_col_name = "id" -======= - data <- readepi( - credentials_file = NULL, - project_id = "SD_DATA", - records = "1, 3, 5", - fields = "record_id, name_first, age, bmi", - id_col_name = "id" ->>>>>>> main ), regexp = cat("Assertion on',credentials_file,'failed: Must be specified.") ) expect_error( -<<<<<<< HEAD readepi( - credentials_file = system.file("extdata", "test.ini", - package = "readepi" - ), - data_source = "https://bbmc.ouhsc.edu/redcap/api/", -======= - data <- readepi( credentials_file = system.file("extdata", "test.ini", package = "readepi"), - project_id = "SD_DATA", ->>>>>>> main + data_source = "https://bbmc.ouhsc.edu/redcap/api/", records = NA, fields = "record_id, name_first, age, bmi", id_col_name = "id" @@ -682,18 +353,10 @@ test_that("readepi fails as expected when reading from REDCap", { ) expect_error( -<<<<<<< HEAD readepi( - credentials_file = system.file("extdata", "test.ini", - package = "readepi" - ), - data_source = "https://bbmc.ouhsc.edu/redcap/api/", -======= - data <- readepi( credentials_file = system.file("extdata", "test.ini", package = "readepi"), - project_id = "SD_DATA", ->>>>>>> main + data_source = "https://bbmc.ouhsc.edu/redcap/api/", records = "1, 3, 5", fields = NA, id_col_name = "id" @@ -702,18 +365,10 @@ test_that("readepi fails as expected when reading from REDCap", { ) expect_error( -<<<<<<< HEAD readepi( - credentials_file = system.file("extdata", "test.ini", - package = "readepi" - ), - data_source = "https://bbmc.ouhsc.edu/redcap/api/", -======= - data <- readepi( credentials_file = system.file("extdata", "test.ini", package = "readepi"), - project_id = "SD_DATA", ->>>>>>> main + data_source = "https://bbmc.ouhsc.edu/redcap/api/", records = "1, 3, 5", fields = "record_id, name_first, age, bmi", id_col_name = NA @@ -723,18 +378,10 @@ test_that("readepi fails as expected when reading from REDCap", { ) expect_error( -<<<<<<< HEAD readepi( - credentials_file = system.file("extdata", "test.ini", - package = "readepi" - ), - data_source = "https://bbmc.ouhsc.edu/redcap/api/", -======= - data <- readepi( credentials_file = system.file("extdata", "test.ini", package = "readepi"), - project_id = "SD_DATA", ->>>>>>> main + data_source = "https://bbmc.ouhsc.edu/redcap/api/", records = "1, 3, 5", fields = "record_id, name_first, age, bmi", id_col_name = NULL, @@ -745,64 +392,23 @@ test_that("readepi fails as expected when reading from REDCap", { ) }) -<<<<<<< HEAD test_that("readepi fails as expected when reading from DBMS", { expect_error( readepi( credentials_file = system.file("extdata", "test.ini", package = "readepi"), data_source = "mysql-rfam-public.ebi.ac.uk", -======= -test_that("readepi fails as expected when reading from DBMS, - files and folders", { - expect_error( - data <- readepi( - credentials_file = system.file("extdata", "test.ini", - package = "readepi"), - project_id = "Rfam", - file_path = system.file("extdata", "test.json", package = "readepi"), - sep = NULL, - format = NULL, - which = NULL, - pattern = NULL, - driver_name = "", - table_name = "author", - records = NULL, - fields = NULL, - id_position = 1 - ), - regexp = cat("Assertion on',credentials_file,' and,'file_path',failed: - Must specify either the file path or the credential file, - not both at the same time.") - ) - - expect_error( - data <- readepi( - credentials_file = system.file("extdata", "test.ini", - package = "readepi"), - project_id = "Rfam", - file_path = NULL, - sep = NULL, - format = NULL, - which = NULL, - pattern = NULL, ->>>>>>> main driver_name = NULL, table_name = "author", records = NULL, fields = NULL, -<<<<<<< HEAD id_position = 1L -======= - id_position = 1 ->>>>>>> main ), regexp = cat("Assertion on',driver_name,failed: MS driver name must be provided.") ) expect_error( -<<<<<<< HEAD readepi( credentials_file = NULL, data_source = "mysql-rfam-public.ebi.ac.uk", @@ -815,50 +421,12 @@ test_that("readepi fails as expected when reading from DBMS, regexp = cat("Assertion on',credentials_file,and,'file_path', failed: Must provide either a file path, or a directory or a credential file.") -======= - data <- readepi( - credentials_file = NULL, - project_id = "Rfam", - file_path = NULL, - sep = NULL, - format = NULL, - which = NULL, - pattern = NULL, - driver_name = NULL, - table_name = "author", - records = NULL, - fields = NULL, - id_position = 1 - ), - regexp = cat("Assertion on',credentials_file,and,'file_path',failed: - Must provide either a file path, or a directory or a credential - file.") - ) - - expect_error( - data <- readepi( - credentials_file = NULL, - project_id = NULL, - file_path = system.file("extdata", "test.txt", package = "readepi"), - sep = c(",", "\t"), - format = NULL, - which = NULL, - pattern = NULL, - driver_name = NULL, - table_name = NULL, - records = NULL, - fields = NULL, - id_position = 1 - ), - regexp = cat("Assertion on',sep,'failed: Must be a character of length 1.") ->>>>>>> main ) }) test_that("readepi fails as expected when reading from Fingertips", { expect_error( -<<<<<<< HEAD readepi( indicator_id = NA, area_type_id = 202L, @@ -866,15 +434,6 @@ test_that("readepi fails as expected when reading from Fingertips", { domain_id = 1000049L, domain_name = "A. Overarching indicators", profile_id = 19L, -======= - data <- readepi( - indicator_id = NA, - area_type_id = 202, - indicator_name = "Healthy life expectancy at birth", - domain_id = 1000049, - domain_name = "A. Overarching indicators", - profile_id = 19, ->>>>>>> main profile_name = "Public Health Outcomes Framework", fields = c("IndicatorID", "AreaCode", "Age", "Value"), records = c("E12000002", "E12000001", "E12000009"), @@ -885,7 +444,6 @@ test_that("readepi fails as expected when reading from Fingertips", { ) expect_error( -<<<<<<< HEAD readepi( indicator_id = 90362L, area_type_id = 202L, @@ -893,15 +451,6 @@ test_that("readepi fails as expected when reading from Fingertips", { domain_id = 1000049L, domain_name = "A. Overarching indicators", profile_id = 19L, -======= - data <- readepi( - indicator_id = 90362, - area_type_id = 202, - indicator_name = NA, - domain_id = 1000049, - domain_name = "A. Overarching indicators", - profile_id = 19, ->>>>>>> main profile_name = "Public Health Outcomes Framework", fields = c("IndicatorID", "AreaCode", "Age", "Value"), records = c("E12000002", "E12000001", "E12000009"), @@ -912,7 +461,6 @@ test_that("readepi fails as expected when reading from Fingertips", { ) expect_error( -<<<<<<< HEAD readepi( indicator_id = 90362L, area_type_id = NA, @@ -920,15 +468,6 @@ test_that("readepi fails as expected when reading from Fingertips", { domain_id = 1000049L, domain_name = "A. Overarching indicators", profile_id = 19L, -======= - data <- readepi( - indicator_id = 90362, - area_type_id = NA, - indicator_name = "Healthy life expectancy at birth", - domain_id = 1000049, - domain_name = "A. Overarching indicators", - profile_id = 19, ->>>>>>> main profile_name = "Public Health Outcomes Framework", fields = c("IndicatorID", "AreaCode", "Age", "Value"), records = c("E12000002", "E12000001", "E12000009"), @@ -939,7 +478,6 @@ test_that("readepi fails as expected when reading from Fingertips", { ) expect_error( -<<<<<<< HEAD readepi( indicator_id = 90362L, area_type_id = 202L, @@ -947,15 +485,6 @@ test_that("readepi fails as expected when reading from Fingertips", { domain_id = NA, domain_name = "A. Overarching indicators", profile_id = 19L, -======= - data <- readepi( - indicator_id = 90362, - area_type_id = 202, - indicator_name = "Healthy life expectancy at birth", - domain_id = NA, - domain_name = "A. Overarching indicators", - profile_id = 19, ->>>>>>> main profile_name = "Public Health Outcomes Framework", fields = c("IndicatorID", "AreaCode", "Age", "Value"), records = c("E12000002", "E12000001", "E12000009"), @@ -965,7 +494,6 @@ test_that("readepi fails as expected when reading from Fingertips", { ) expect_error( -<<<<<<< HEAD readepi( indicator_id = 90362L, area_type_id = 202L, @@ -973,15 +501,6 @@ test_that("readepi fails as expected when reading from Fingertips", { domain_id = 1000049L, domain_name = NA, profile_id = 19L, -======= - data <- readepi( - indicator_id = 90362, - area_type_id = 202, - indicator_name = "Healthy life expectancy at birth", - domain_id = 1000049, - domain_name = NA, - profile_id = 19, ->>>>>>> main profile_name = "Public Health Outcomes Framework", fields = c("IndicatorID", "AreaCode", "Age", "Value"), records = c("E12000002", "E12000001"), @@ -992,19 +511,11 @@ test_that("readepi fails as expected when reading from Fingertips", { ) expect_error( -<<<<<<< HEAD readepi( indicator_id = 90362L, area_type_id = 202L, indicator_name = "Healthy life expectancy at birth", domain_id = 1000049L, -======= - data <- readepi( - indicator_id = 90362, - area_type_id = 202, - indicator_name = "Healthy life expectancy at birth", - domain_id = 1000049, ->>>>>>> main domain_name = "A. Overarching indicators", profile_id = NA, profile_name = "Public Health Outcomes Framework", @@ -1016,7 +527,6 @@ test_that("readepi fails as expected when reading from Fingertips", { ) expect_error( -<<<<<<< HEAD readepi( indicator_id = 90362L, area_type_id = 202L, @@ -1024,15 +534,6 @@ test_that("readepi fails as expected when reading from Fingertips", { domain_id = 1000049L, domain_name = "A. Overarching indicators", profile_id = 19L, -======= - data <- readepi( - indicator_id = 90362, - area_type_id = 202, - indicator_name = "Healthy life expectancy at birth", - domain_id = 1000049, - domain_name = "A. Overarching indicators", - profile_id = 19, ->>>>>>> main profile_name = NA, fields = c("IndicatorID", "AreaCode", "Age", "Value"), records = c("E12000002", "E12000001", "E12000009"), diff --git a/tests/testthat/test-readepi_helpers.R b/tests/testthat/test-readepi_helpers.R index 6d910a27..c66a8eb8 100644 --- a/tests/testthat/test-readepi_helpers.R +++ b/tests/testthat/test-readepi_helpers.R @@ -1,6 +1,5 @@ test_that("read_credentials works as expected", { res <- read_credentials( -<<<<<<< HEAD file_path = system.file("extdata", "test.ini", package = "readepi"), url = "mysql-rfam-public.ebi.ac.uk" ) @@ -19,25 +18,10 @@ test_that("read_credentials works as expected", { expect_identical(res[["dbms"]], "MySQL") expect_type(res[["port"]], "integer") expect_identical(res[["port"]], 4497L) -======= - file_path = system.file("extdata", "test.ini", package = "readepi"), - project_id = "Rfam" - ) - expect_type(res, "list") - expect_length(res, 6) - expect_named(res, c("user", "pwd", "host", "project", "dbms", "port")) - expect_type(res$user, "character") - expect_type(res$pwd, "character") - expect_type(res$host, "character") - expect_type(res$project, "character") - expect_type(res$dbms, "character") - expect_type(res$port, "integer") ->>>>>>> main }) test_that("read_credentials fails as expected", { expect_error( -<<<<<<< HEAD read_credentials( file_path = system.file("extdata", "fake_test.ini", package = "readepi"), url = "mysql-rfam-public.ebi.ac.uk" @@ -48,8 +32,7 @@ test_that("read_credentials fails as expected", { expect_error( read_credentials( file_path = system.file("extdata", "bad_column_name.ini", - package = "readepi" - ), + package = "readepi"), url = "mysql-rfam-public.ebi.ac.uk" ), regexp = cat("Unexpected column name(s) in the provided credential file. @@ -201,68 +184,4 @@ test_that("get_read_fingertips_args fails as expected", { ) ) expect_identical(res[["parent_area_type_id"]], 6L) -======= - res <- read_credentials( - file_path = NULL, - project_id = "Rfam" - ), - regexp = cat("Assertion on',file_path,'failed: Must provide a path to - the credential file.") - ) - - expect_error( - res <- read_credentials( - file_path = c(system.file("extdata", "test.ini", package = "readepi"), - system.file("extdata", "test.ini", package = "readepi")), - project_id = "Rfam" - ), - regexp = cat("Assertion on',file_path,'failed: Impossible to read from - multiple credential files.") - ) - - expect_error( - res <- read_credentials( - file_path = system.file("extdata", "test.ini", package = "readepi"), - project_id = NULL - ), - regexp = cat("Assertion on',project_id,'failed: Must provide the database - name or the project ID (for REDCap).") - ) - - expect_error( - res <- read_credentials( - file_path = system.file("extdata", "test.ini", package = "readepi"), - project_id = c("Rfam", "TEST_REDCap") - ), - regexp = cat("Assertion on',project_id,'failed: Impossible to read from - multiple databases or projects.") - ) -}) - -test_that("get_read_file_args works as expected", { - res <- get_read_file_args( - list( - sep = "\t", - format = ".txt", - which = NULL - ) - ) - expect_type(res, "list") - expect_length(res, 4) - expect_named(res, c("sep", "format", "which", "pattern")) -}) - -test_that("get_read_fingertips_args works as expected", { - res <- get_read_fingertips_args( - list( - indicator_id = 90362, - area_type_id = 202 - ) - ) - expect_type(res, "list") - expect_length(res, 8) - expect_named(res, c("indicator_id", "indicator_name", "area_type_id", - "profile_id", "profile_name", "domain_id", "domain_name", - "parent_area_type_id")) ->>>>>>> main }) diff --git a/tests/testthat/test-show_tables.R b/tests/testthat/test-show_tables.R index 3b2a776c..94558c2f 100644 --- a/tests/testthat/test-show_tables.R +++ b/tests/testthat/test-show_tables.R @@ -1,44 +1,20 @@ test_that("Function 'show_tables' correctly displays the table names", { -<<<<<<< HEAD tables <- show_tables( data_source = "mysql-rfam-public.ebi.ac.uk", credentials_file = system.file("extdata", "test.ini", package = "readepi"), driver_name = "" ) expect_type(tables, "character") -======= - expect_output( - show_tables( - credentials_file = system.file("extdata", "test.ini", - package = "readepi"), - project_id = "Rfam", - driver_name = "" - ), - "" - ) ->>>>>>> main }) test_that("show_tables fails as expected", { expect_error( show_tables( -<<<<<<< HEAD data_source = "mysql-rfam-public.ebi.ac.uk", - credentials_file = c( - system.file("extdata", "test.ini", - package = "readepi" - ), - system.file("extdata", "test.ini", - package = "readepi" - ) - ), -======= credentials_file = c(system.file("extdata", "test.ini", package = "readepi"), system.file("extdata", "test.ini", package = "readepi")), - project_id = "Rfam", ->>>>>>> main driver_name = "" ), regexp = cat("Assertion on',credentials_file,'failed: Must be of type @@ -47,15 +23,9 @@ test_that("show_tables fails as expected", { expect_error( show_tables( -<<<<<<< HEAD data_source = "mysql-rfam-public.ebi.ac.uk", credentials_file = NULL, driver_name = "" -======= - credentials_file = NULL, - project_id = "Rfam", - driver_name = "" ->>>>>>> main ), regexp = cat("Assertion on',credentials_file,'failed: Credential file not found.") @@ -63,56 +33,25 @@ test_that("show_tables fails as expected", { expect_error( show_tables( -<<<<<<< HEAD data_source = c( "mysql-rfam-public.ebi.ac.uk", "mysql-rfam-public.ebi.ac.uk" ), credentials_file = system.file("extdata", "test.ini", - package = "readepi" - ), - driver_name = "" - ), - regexp = cat("Assertion on',data_source,'failed: Must be of type 'character' -======= - credentials_file = system.file("extdata", "fake_test.ini", package = "readepi"), - project_id = c("Rfam", "TEST_READEPI"), driver_name = "" ), - regexp = cat("Assertion on',project_id,'failed: Must be of type 'character' ->>>>>>> main + regexp = cat("Assertion on',data_source,'failed: Must be of type 'character' of length 1.") ) expect_error( show_tables( -<<<<<<< HEAD data_source = NULL, credentials_file = system.file("extdata", "test.ini", - package = "readepi" - ), - driver_name = "" - ), - regexp = cat("Assertion on',data_source,'failed: Must be specified.") -======= - credentials_file = system.file("extdata", "fake_test.ini", package = "readepi"), - project_id = NULL, driver_name = "" ), - regexp = cat("Assertion on',project_id,'failed: Must be specified.") - ) - - expect_error( - show_tables( - credentials_file = system.file("extdata", "fake_test.ini", - package = "readepi"), - project_id = "Rfam", - driver_name = c("", "ODBC Driver 17 for SQL Server") - ), - regexp = cat("Assertion on',driver_name,'failed: Must be of type - 'character' of length 1.") ->>>>>>> main + regexp = cat("Assertion on',data_source,'failed: Must be specified.") ) }) diff --git a/vignettes/readepi.Rmd b/vignettes/readepi.Rmd index 15deeb48..5da3b21a 100644 --- a/vignettes/readepi.Rmd +++ b/vignettes/readepi.Rmd @@ -1,5 +1,4 @@ --- -<<<<<<< HEAD title: "readepi: Reading data from health information systems" output: bookdown::html_vignette2: @@ -9,17 +8,10 @@ pkgdown: as_is: false vignette: > %\VignetteIndexEntry{Reading data from health information systems} -======= -title: "readepi-vignette" -output: rmarkdown::html_vignette -vignette: > - %\VignetteIndexEntry{readepi-vignette} ->>>>>>> main %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- -<<<<<<< HEAD # Overview Health-related data in general, and epidemiological data in particular, are stored in files, relation database management systems (RDBMS), or health information systems (HIS). Each category includes numerous options, such as various file formats, RDBMS types, and HIS APIs. Import data from such repositories involve the usage of different format-specific functions or API-specific packages, which is an exhausting task for end users. @@ -36,17 +28,10 @@ knitr::opts_chunk[["set"]]( message = FALSE, warning = FALSE, dpi = 300L -======= -```{r, include = FALSE} -knitr::opts_chunk$set( - collapse = TRUE, - comment = "#>" ->>>>>>> main ) ``` ```{r setup} -<<<<<<< HEAD # LOAD readepi library("readepi") # nolint ``` @@ -64,71 +49,6 @@ Mac users can follow the instructions below to install the MS SQL ODBC driver. C 1. installation of MS SQL driver 17 on Mac -======= -library(readepi) -``` - -# Reading data from file or directory - -`readepi` provides functions for reading data from `common health information systems` as well as from various file types. When several files of different formats are stored in the same folder, the user can provide `readepi` with a specific pattern, allowing reading only the matching files. - -When reading data from file or directory, the function expects the following arguments: -* *file_path*: the path to the file of interest. When several files need to be imported from a directory, this should be the path to that directory, -* *sep*: the separator between the columns in the file. This is only required for space-separated files, -* *format*: a string used to specify the file format. This is useful when a file does not have an extension, or has a file extension that does not match its actual type, -* *which*: a string used to specify which objects should be extracted (e.g. the name of the excel sheet to import), -* *pattern*: when provided, only files that contain this pattern will be imported from the specified directory. -The function will return an object of class list with one or more data frames. - -## importing data from JSON file -Many database management systems (DBMS) can export data into `JSON` format that can be read into R using the `readepi()` function. -```{r eval=FALSE} -file <- system.file("extdata", "test.json", package = "readepi") -data <- readepi(file_path = file) -``` - -## importing data from excel file -`readepi()` can import data from MS excel file with a single sheet. The user must specify the names of the excel sheets with the data of interest when the files contains several sheets. -```{r eval=FALSE} -# IMPORTING DATA FROM THE SECOND EXCEL SHEET -file <- system.file("extdata", "test.xlsx", package = "readepi") -data <- readepi(file_path = file, which = "Sheet2") - -# IMPORTING DATA FROM THE FIRST AND SECOND EXCEL SHEETS -file <- system.file("extdata", "test.xlsx", package = "readepi") -data <- readepi(file_path = file, which = c("Sheet2", "Sheet1")) -``` - -## importing data from several files in a directory -`readepi()` can be used to read data from multiple files that are all stored in the same directory. When there are different file format in that directory, the user is expected to specify the file type of interest with the `pattern` argument. -```{r eval=FALSE} -# READING ALL FILES IN THE GIVEN DIRECTOR -dir_path <- system.file("extdata", package = "readepi") -data <- readepi(file_path = dir_path) - -# READING ONLY '.txt' FILES -data <- readepi(file_path = dir_path, pattern = ".txt") - -# READING '.txt' and '.xlsx' FILES -data <- readepi(file_path = dir_path, pattern = c(".txt", ".xlsx")) -``` - -# importing from DBMS (database management systems) -Users should be granted with read access to be able to pull data from the DBMS. - -## Reading data from relational database management systems (RDBMS): HDSS, EMRS, REDCap -Research data are usually stored in either relational databases or NoSQL databases. At the MRCG@LSHTM, project data are stored in relational databases. The HDSS and EMRS host databases that run under MS SQL Server, while REDCap (that uses an EAV schema) run under a MySQL server. -To import data from MS SQL Servers (HDSS or EMRS) into R, some dependencies need to be installed first. - -### installation of dependencies -If you are using a Unix-based system, you will need to install the MS ODBC driver that is compatible with the version of the target MS SQL server. For **SQL server 2019, version 15.0**, we installed **ODBC Driver 17 for SQL Server** on the mac OS which is compatible with the test server. - -#### installation of MS SQL driver on Mac -Mac users can follow the instructions below to install the MS SQL ODBC driver. - -##### installation of MS SQL driver 17 or 18 on Mac -Open the terminal, and run the followings: ->>>>>>> main ```{bash eval=FALSE} driver=17 brew install unixodbc @@ -139,12 +59,8 @@ brew install mssql-tools ODBCSYSINI=/ ``` -<<<<<<< HEAD 2. installation of MS SQL driver 13.1 on Mac -======= -##### installation of MS SQL driver 13.1 on Mac ->>>>>>> main ```{bash eval=FALSE} brew install unixodbc brew tap microsoft/mssql-release https://github.com/Microsoft/homebrew-mssql-release @@ -154,17 +70,12 @@ brew install mssql-tools@14.0.6.0 ODBCSYSINI=/ ``` -<<<<<<< HEAD ## MS SQL drivers for Linux-based systems Note that this requires **Ubuntu 16.04 and above**. Choose the appropriate driver, open the terminal and type the instructions below: 1. installation of MS SQL driver version 17 on `Ubuntu` -======= -#### installation of MS SQL driver version 17 or 18 on `Ubuntu` -Note that this requires **Ubuntu 16.04 and above**. Open the terminal and type the code below: ->>>>>>> main ```{bash eval=FALSE} driver=17 sudo su @@ -180,13 +91,8 @@ source ~/.bashrc sudo apt-get install -y unixodbc-dev ``` -<<<<<<< HEAD 2. installation of MS SQL driver version 13.1 on `Ubuntu` -======= -#### installation of MS SQL driver version 13.1 on `Ubuntu` -Note that this works for older versions of Ubuntu, including version 16.04. ->>>>>>> main ```{bash eval=FALSE} sudo su curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - @@ -200,23 +106,14 @@ source ~/.bashrc sudo apt-get install unixodbc-dev ``` -<<<<<<< HEAD 3. installation of MS SQL driver on other Linux distributions To install an MS SQL driver for other Linux distributions, such as Debian and Fedora, click [here](https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-ver15&tabs=ubuntu18-install%2Cubuntu17-install%2Cubuntu16-install%2Cubuntu16-13-install%2Crhel7-offline) and follow the instructions. After the installation, check the installed drivers using: -======= -#### installation of MS SQL driver on other Linux distributions -When working on a Linux distribution other than Ubuntu, follow the instructions [here](https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-ver15&tabs=ubuntu18-install%2Cubuntu17-install%2Cubuntu16-install%2Cubuntu16-13-install%2Crhel7-offline) for the MS SQL driver installation process. - - -After the driver installation, the list of drivers can be displayed in R using: ->>>>>>> main ```{r eval=FALSE} odbc::odbcListDrivers() ``` -<<<<<<< HEAD If this command does not return the list of installed drivers or if you are facing issues during the driver installation process, consult [the odbc github page](https://github.com/r-dbi/odbc#installation) or the [MS documentation on this topic](https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/install-microsoft-odbc-driver-sql-server-macos?view=sql-server-ver15). It is also important to view the data stored in the MS SQL server. For that purpose, we recommend you to install a graphical user interface (GUI) such as `Azure Data Studio`. @@ -269,65 +166,11 @@ show_tables( data_source = "mysql-rfam-public.ebi.ac.uk", credentials_file = credentials_file, driver_name = "" -======= -If the command above does not return the list of installed drivers or if you are facing issues during the driver installation process, consult -[the odbc github page](https://github.com/r-dbi/odbc#installation) or the [MS documentation on this topic](https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/install-microsoft-odbc-driver-sql-server-macos?view=sql-server-ver15) - - -**Note that it is important to view the data that is stored in the MS SQL server. We recommend to install a GUI such as `Azure Data Studio` for that purpose.** - -## importing from MS SQL or MySQL server -The current version of `readepi` allows for data import from: -1. MS SQL server, -2. MySQL server, -3. PostgreSQL server. -To be able to read data these data management information systems, the **readepi()** expects the following arguments: - -* *credentials_file*: the path to the file with the user-specific credential details for the projects of interest. This is a tab-delimited file with the following 7 columns: - -`user_name`: the user name, -`password`: the user password (for REDCap, this corresponds to the **token** that serves as password to the project), -`host_name`: the host name (for HDSS and EMRS) or the URI (for REDCap), -`project_id`: the project ID (for REDCap) or the name of the database (for HDSS and EMRS) you are access to, -`comment`: a summary description about the project or database of interest, -`dbms`: the name of the DBMS: 'redcap' or 'REDCap' when reading from REDCap, 'sqlserver' or 'SQLServer' when reading from MS SQL Server, -`port`: the port ID (used for MS SQL Servers only). - -* *project_id*: for relational DB, this is the name of the database that contains the table from which the data should be pulled. Otherwise, it is the project ID you were given access to. Note that this should be similar to the value of the **project_id** field in the credential file. -* *driver_name*: the name of the MS driver (only for HDSS and EMRS). use `odbc::odbcListDrivers()` to display the list of installed drivers, -* *source*: This can be a vector of the table names or an SQL query. When table names are specified, subsetting from tables is done by specifying the `fields` and `records` parameters -* *records*: a vector or a comma-separated string of a subset of subject IDs. When specified, only the records that correspond to these subjects will be imported, -* *fields*: a vector or a comma-separated string of column names. If provided, only those columns will be imported, -* *id_position*: the column position of the variable that unique identifies the subjects. default is 1. -* *id_col_name*: the name of the column that unique identifies the subjects. - - -Use the `show_example_file()` as below to view the credentials file used as template in the **readepi** package. -```{r eval=FALSE} -# DISPLAY THE STRUCTURE OF THE CREDENTIALS FILE -show_example_file() -``` -All demos in the sections below rely on the credentials stored in the template file, defined as described above, and that is part of the `readepi` package. -Also, these examples are based on a MySQL server that does not require the user to specify the `driver name`. But it is important to keep in mind that specify the driver name is a requirement for MS SQL server. -```{r eval=FALSE} -# DEFINING THE CREDENTIALS FILE -credentials_file <- system.file("extdata", "test.ini", package = "readepi") -``` - -### list the names of all tables in the database -To displays the list of tables from the database of interest, use: -```{r eval=FALSE} -show_tables( - credentials_file = credentials_file, - project_id = "Rfam", # this is the database name - driver_name = "" # ODBC Driver 17 for SQL Server ->>>>>>> main ) # use driver_name = "ODBC Driver 17 for SQL Server" when reading from MS SQL # server ``` -<<<<<<< HEAD ### Fetching data using table names ```{r eval=FALSE} @@ -345,48 +188,20 @@ dat <- readepi( credentials_file = credentials_file, from = "author", # this is the table name driver_name = "" -======= -Note that in the above, the value for the `project_id` argument is the name of the database of interest. - -### fetching the data using table names -```{r eval=FALSE} -# READING ALL FIELDS AND ALL RECORDS FROM ONE TABLE (`author`) -data <- readepi(credentials_file, - project_id = "Rfam", - driver_name = "", # ODBC Driver 17 for SQL Server - source = "author" -) - -# VISUALIZE THE FIRST 5 ROWS OF THE TABLE 'author' -visualise_table( - credentials_file = credentials_file, - source = "author", # this is the table name - project_id = "Rfam", # this is the database name - driver_name = "" ->>>>>>> main ) # READING SPECIFIED FIELDS AND ALL RECORDS FROM ONE TABLE fields <- "author_id,name,last_name,initials" -<<<<<<< HEAD dat <- readepi( data_source = "mysql-rfam-public.ebi.ac.uk", credentials_file = credentials_file, from = "author", # this is the table name driver_name = "", fields = fields # these are the columns of interest. -======= -data <- readepi(credentials_file, - project_id = "Rfam", - driver_name = "", - source = "author", - fields = fields ->>>>>>> main ) # READING SPECIFIED RECORDS AND ALL FIELDS FROM ONE TABLE records <- "1, 34, 15, 70, 118, 20" -<<<<<<< HEAD dat <- readepi( data_source = "mysql-rfam-public.ebi.ac.uk", credentials_file = credentials_file, @@ -405,40 +220,15 @@ dat <- readepi( records = records, fields = fields, id_col_name = "author_id" -======= -data <- readepi(credentials_file, - project_id = "Rfam", - driver_name = "", - source = "author", - records = records, - id_position = 1 -) - -# READING SPECIFIED FIELDS AND RECORDS ONE THE TABLE -data <- readepi(credentials_file, - project_id = "Rfam", - driver_name = "", - source = "author", - records = records, - fields = fields, - id_col_name = "author_id" ->>>>>>> main ) # READING DATA FROM SEVERAL TABLES table_names <- c("author", "family_author") -<<<<<<< HEAD dat <- readepi( data_source = "mysql-rfam-public.ebi.ac.uk", credentials_file = credentials_file, from = table_names, # this is the table name driver_name = "" -======= -data <- readepi(credentials_file, - project_id = "Rfam", - driver_name = "", - source = table_names ->>>>>>> main ) # READING DATA FROM SEVERAL TABLES AND SUBSETTING FIELDS ACROSS TABLES @@ -449,20 +239,12 @@ fields <- c( # the first string in the field vector corresponds to the name of the # columns of interest from the first table specified in the `table_names` # argument and so on... -<<<<<<< HEAD dat <- readepi( data_source = "mysql-rfam-public.ebi.ac.uk", credentials_file = credentials_file, from = table_names, # this is the table name driver_name = "", fields = fields -======= -data <- readepi(credentials_file, - project_id = "Rfam", - driver_name = "", - source = table_names, - fields = fields ->>>>>>> main ) # READING DATA FROM SEVERAL TABLES AND SUBSETTING RECORDS ACROSS TABLES @@ -474,7 +256,6 @@ records <- c( # interest from the first table specified in the `table_name` argument and so # on... when the id column is not the first column in a table, # use the `id_position`" -<<<<<<< HEAD dat <- readepi( data_source = "mysql-rfam-public.ebi.ac.uk", credentials_file = credentials_file, @@ -482,19 +263,10 @@ dat <- readepi( driver_name = "", records = records, id_position = c(1, 1) # nolint -======= -data <- readepi(credentials_file, - project_id = "Rfam", - driver_name = "", - source = table_names, - records = records, - id_position = c(1, 1) ->>>>>>> main ) # READING DATA FROM SEVERAL TABLES AND SUBSETTING RECORDS AND FIELDS ACROSS # TABLES -<<<<<<< HEAD dat <- readepi( data_source = "mysql-rfam-public.ebi.ac.uk", credentials_file = credentials_file, @@ -584,93 +356,10 @@ dat <- readepi( data_source = "https://bbmc.ouhsc.edu/redcap/api/", credentials_file = credentials_file, fields = fields -======= -data <- readepi( - credentials_file, - project_id = "Rfam", - driver_name = "", - source = table_names, - records = records, - fields = fields, - id_col_name = c("author_id", "rfam_acc") -) -``` - -### fetching the data using an SQL query -```{r eval=FALSE} -# SELECT FEW COLUMNS FROM ONE TABLE AND LEFT JOIN WITH ANOTHER TABLE -data <- readepi( - credentials_file, - project_id = "Rfam", - driver_name = "", - source = "select author.author_id, author.name, family_author.author_id from - author left join family_author on author.author_id = family_author.author_id" -) - -# SELECT ALL DATA FROM THE author TABLE -data <- readepi( - credentials_file, - project_id = "Rfam", - driver_name = "", - source = "select * from author" -) - -# SELECT FEW COLUMNS FROM THE author TABLE -data <- readepi( - credentials_file, - project_id = "Rfam", - driver_name = "", - source = "select author_id, name, last_name from author" -) - -# SELECT FEW RECORDS FROM THE author TABLE -data <- readepi( - credentials_file, - project_id = "Rfam", - driver_name = "", - source = "select * from author where author_id in ('1','20','50')" -) - -# SELECT FEW RECORDS AND FIELDS FROM THE author TABLE -data <- readepi( - credentials_file, - project_id = "Rfam", - driver_name = "", - source = "select author_id, name, last_name from author where - author_id in ('1','20','50')" -) -``` - -## importing from REDCap -To import data from REDCap, the user must call the `readepi` function with the following arguments: - -* *credentials_file*: the credentials file (required) -* *project_id*: the project ID (required) -* *records*: the list of the desired records (optional) -* *fields*: the list of the desired columns (optional) - -Both the data and its associated metadata will be will be returned after a successful import. - -```{r eval=FALSE} -# READING ALL FIELDS AND RECORDS FROM A REDCap PROJECT -data <- readepi( - credentials_file = credentials_file, - project_id = "SD_DATA" -) -project_data <- data$data -project_metadeta <- data$metadata - -# READING SPECIFIC FIELDS AND ALL RECORDS FROM THE PROJECT -fields <- c("record_id", "name_first", "age", "bmi") -data <- readepi(credentials_file, - project_id = "SD_DATA", - fields = fields ->>>>>>> main ) # READING SPECIFIC RECORDS AND ALL FIELDS FROM THE PROJECT records <- c("1", "3", "5") -<<<<<<< HEAD dat <- readepi( data_source = "https://bbmc.ouhsc.edu/redcap/api/", credentials_file = credentials_file, @@ -759,95 +448,10 @@ dat <- readepi( data_element_group = NULL, start_date = "2014", end_date = "2023" -======= -data <- readepi(credentials_file, - project_id = "SD_DATA", - records = records, - id_col_name = "record_id" -) - -# READING SPECIFIC RECORDS AND FIELDS FROM THE PROJECT -data <- readepi(credentials_file, - project_id = "SD_DATA", - records = records, - fields = fields, - id_col_name = "record_id" -) -project_data <- data$data -project_metadeta <- data$metadata -``` - - -## importing from DHIS2 -To import data from **DHIS2**, the user must call the `readepi` function with the following arguments: - -* *credentials_file*: the credentials file (required) -* *project_id*: the project ID (required) -* *dataset*: the dataset identifier (required) -* *organisation_unit*: the organisation unit identifier (required) -* *data_element_group*: the data element group (optional) -* *start_date*: the start date for the time span of the values to export (required) -* *end_date*: the end date for the time span of the values to export (required) -* *id_col_name*: the column name with the records of interest (optional) -* *records*: the list of the desired records (optional) -* *fields*: the list of the desired columns (optional) - -```{r eval=FALSE} -# GETTING THE DATA ELEMENT IDENTIFIERS AND NAMES -data_elements <- get_data_elements( - base_url = "https://play.dhis2.org/dev/", - username = "admin", - password = "district" -) - -# GETTING THE DATASET IDENTIFIERS AND NAMES -datasets <- get_data_sets( - base_url = "https://play.dhis2.org/dev/", - username = "admin", - password = "district" -) - -# GETTING THE ORGANISATION UNIT IDENTIFIERS AND NAMES -organisation_units <- get_data_sets( - base_url = "https://play.dhis2.org/dev/", - username = "admin", - password = "district" -) - -# GETTING THE DATA ELEMENT GROUP IDENTIFIERS AND NAMES -data_element_groups <- get_organisation_units( - base_url = "https://play.dhis2.org/dev/", - username = "admin", - password = "district" -) - -# READING THE DATASET ID `pBOMPrpg1QX` -data <- readepi( - credentials_file = credentials_file, - project_id = "DHIS2_DEMO", - dataset = "pBOMPrpg1QX", - organisation_unit = "DiszpKrYNg8", - data_element_group = NULL, - start_date = "2014", - end_date = "2023" -) - -# READING DATA FROM 2 DATASETS `pBOMPrpg1QX` -data <- readepi( - credentials_file = credentials_file, - project_id = "DHIS2_DEMO", - dataset = "pBOMPrpg1QX,BfMAe6Itzgt", - # same as dataset=c("pBOMPrpg1QX","BfMAe6Itzgt") - organisation_unit = "DiszpKrYNg8", - data_element_group = NULL, - start_date = "2014", - end_date = "2023" ->>>>>>> main ) # READING SPECIFIC DATA ELEMENTS FROM THE DATASET ID `pBOMPrpg1QX` data_elts <- c("FTRrcoaog83", "eY5ehpbEsB7", "Ix2HsbDMLea") -<<<<<<< HEAD dat <- readepi( data_source = "https://play.dhis2.org/dev", credentials_file = credentials_file, @@ -896,57 +500,10 @@ It is worth noting that, while reading such data, the `readepi()` function makes ### Examples This section provides various examples demonstrating how **{readepi}** imports data from Fingertips-based APIs. -======= -data <- readepi( - credentials_file = credentials_file, - project_id = "DHIS2_DEMO", - dataset = "pBOMPrpg1QX", - organisation_unit = "DiszpKrYNg8", - data_element_group = NULL, - start_date = "2014", - end_date = "2023", - records = data_elts, - id_col_name = "dataElement" -) - -# READING SPECIFIC COLUMNS FROM A DATASET -data <- readepi( - credentials_file = credentials_file, - project_id = "DHIS2_DEMO", - dataset = "pBOMPrpg1QX,BfMAe6Itzgt", - organisation_unit = "DiszpKrYNg8", - data_element_group = NULL, - start_date = "2014", - end_date = "2023", - fields = c("dataElement", "period", "value") -) - -test_data <- data$data -``` - -## importing from Fingertips -[Fingertips](https://fingertips.phe.org.uk/) is a repository of public health data indicators in England. The data in Fingertips website is organised into themed profiles. The `readepi()` function takes the arguments listed below to import data from Fingertips through its API: - -* *indicator_id*: the indicator ID -* *indicator_name*: the indicator name -* *area_type_id*: the area type ID. This determines the geographic area for the imported data -* *parent_area_type_id*: the parent area type code of the specified area type ID -* *profile_id*: the profile ID -* *profile_name*: the profile name -* *domain_id*: the domain ID -* *domain_name*: the domain name -* *records*: the list of the desired records -* *fields*: the list of the desired columns -* *id_col_name*: the column name with the records of interest -* *id_position*: the column position of the variable that unique identifies the subjects. default is 1. - -Note that the `readepi()` function makes call of wrapper around the major function in the [fingertipsR](https://docs.ropensci.org/fingertipsR/) package. ->>>>>>> main ```{r eval=FALSE} # GET THE INFORMATION ABOUT THE INDICATOR PROFILES, DOMAIN, AREA TYPE, ... metadata <- get_fingertips_metadata() -<<<<<<< HEAD head(metadata[["indicator_profile_domain"]]) head(metadata[["indicator_ids_names"]]) head(metadata[["area_type"]]) @@ -1006,69 +563,3 @@ dat <- readepi( id_col_name = "AreaCode" ) ``` -======= -head(metadata$indicator_profile_domain) -# indicator_profile_domain contains the indicator, profile, -# and domain information. -head(metadata$indicator_ids_names) -# indicator_ids_names contains the list of indicators IDs together -# with their names. -head(metadata$area_type) -# area_type contains the list of all area types with their associated -# parent area types. - -# IMPORTING DATA USING THE INDICATOR ID -data <- readepi( - indicator_id = 90362, - area_type_id = 202 -) - -# IMPORTING DATA USING THE INDICATOR NAME -data <- readepi( - indicator_name = "Healthy life expectancy at birth", - area_type_id = 202 -) - -# IMPORTING DATA USING THE DOMAIN NAME -data <- readepi( - domain_name = "A. Overarching indicators", - area_type_id = 202 -) - -data <- readepi( - indicator_name = "Healthy life expectancy at birth", - area_type_id = 202, - domain_name = "A. Overarching indicators" -) - -# IMPORTING DATA USING THE PROFILE ID -data <- readepi( - profile_id = 19, - area_type_id = 202 -) - -# IMPORTING DATA FROM SPECIFIC INDICATOR, DOMAIN, PROFILE, AREA TYPE -data <- readepi( - indicator_id = 90362, - indicator_name = "Healthy life expectancy at birth", - area_type_id = 202, parent_area_type_id = 6, - profile_id = 19, - profile_name = "Public Health Outcomes Framework", - domain_id = 1000049, domain_name = "A. Overarching indicators", - fields = NULL, records = NULL, - id_position = NULL, id_col_name = NULL -) - -# IMPORTING DATA AND SUBSETTING SPECIFIC RECORDS AND FIELDS -data <- readepi( - indicator_id = 90362, - area_type_id = 202, - fields = c("IndicatorID", "AreaCode", "Age", "Value"), - records = c("E92000001", "E12000002", "E12000009"), - id_col_name = "AreaCode" -) -``` - - - ->>>>>>> main