Skip to content

Commit

Permalink
Release version 4.2.0 (#769)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: Elizabeth Wenk <ehwenk@gmail.com>
Co-authored-by: yangsophieee <sophie.yang917@gmail.com>
Co-authored-by: Sophie Yang <78716301+yangsophieee@users.noreply.github.com>
Co-authored-by: David Coleman <50344360+dcol2804@users.noreply.github.com>
Co-authored-by: GillianKowalick <z5242422@ad.unsw.edu.au>
Co-authored-by: GillianKowalick <85142592+GillianKowalick@users.noreply.github.com>
Co-authored-by: Becca-90 <z3378134@ad.unsw.edu.au>
  • Loading branch information
8 people authored Sep 18, 2023
1 parent 4b4f1dd commit 200db85
Show file tree
Hide file tree
Showing 444 changed files with 744,057 additions and 9,869 deletions.
123 changes: 64 additions & 59 deletions R/process.R

Large diffs are not rendered by default.

63 changes: 47 additions & 16 deletions R/setup.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ metadata_create_template <- function(dataset_id,
out$source$primary["key"] = dataset_id
out$source$primary["bibtype"] = "Article"

collectors <- c("last_name", "given_name", "ORCID", "affiliation")

out$contributors <- out$contributors$elements
out$contributors$data_collectors[c(exclude, "notes")] <- NULL
out$contributors$data_collectors[] <- "unknown"
out$contributors$data_collectors <- list(out$contributors$data_collectors)
out$contributors$data_collectors <- list(out$contributors$data_collectors$elements[collectors])
out$contributors$data_collectors[[1]][] <- "unknown"
out$contributors[c("assistants", "austraits_curators")] <- "unknown"

out$dataset <- out$dataset$values[c("data_is_long_format", "custom_R_code", "collection_date", "taxon_name", "location_name",
Expand Down Expand Up @@ -245,11 +246,11 @@ metadata_add_locations <- function(dataset_id, location_data) {
location_name <- metadata_user_select_column("location_name", names(location_data))

# From remaining variables, choose those to keep
location_sub <- dplyr::select(location_data, -!!location_name)
location_sub <- dplyr::select(dplyr::all_of(c("location_data"), -!!location_name))
keep <- metadata_user_select_names(paste("Indicate all columns you wish to keep as distinct location_properties in ", dataset_id), names(location_sub))

# Save and notify
metadata$locations <- dplyr::select(location_data, tidyr::one_of(keep)) %>%
metadata$locations <- dplyr::select(dplyr::all_of(c("location_data"), tidyr::one_of(keep))) %>%
split(location_data[[location_name]]) %>% lapply(as.list)

cat(sprintf("Following locations added to metadata for %s: %s\n\twith variables %s.\n\tPlease complete information in %s.\n\n", dataset_id, crayon::red(paste(names( metadata$locations), collapse = ", ")), crayon::red(paste(keep, collapse = ", ")), dataset_id %>% metadata_path_dataset_id()))
Expand Down Expand Up @@ -593,16 +594,44 @@ metadata_add_taxonomic_change <- function(dataset_id, find, replace, reason, tax
#' @return yml file with multiple taxonmic updates added
#' @export
metadata_add_taxonomic_changes_list <- function(dataset_id, taxonomic_updates) {
# read metadata

# Read metadata
metadata <- read_metadata_dataset(dataset_id)

#read in dataframe of taxonomic changes, split into single-row lists, and add to metadata file
metadata$taxonomic_updates <-
taxonomic_updates %>%
dplyr::group_split(.data$find) %>% lapply(as.list)

# write metadata

if (!all(is.na(metadata[["taxonomic_updates"]]))) {

existing_updates <- metadata[["taxonomic_updates"]] %>% util_list_to_df2()
already_exist <- c()

for (i in seq_len(nrow(taxonomic_updates))) {
# Check if the taxonomic update already exists
if (taxonomic_updates[i,]$find %in% existing_updates$find) {
# Overwrite existing taxonomic update if TRUE
existing_updates[which(existing_updates$find == taxonomic_updates[i,]$find),] <- taxonomic_updates[i,]
already_exist <- c(already_exist, taxonomic_updates[i,]$find)
} else {
# Otherwise, bind to end of existing taxonomic updates
existing_updates <- existing_updates %>% bind_rows(taxonomic_updates[i,])
}
}

if (length(already_exist) > 0) {
message(
sprintf(
green("%s") %+% red(" already exist(s) in `taxonomic_updates` and is being overwritten"),
paste(already_exist, collapse = ", ")
))
}
# Write new taxonomic updates to metadata
metadata$taxonomic_updates <- existing_updates %>% dplyr::group_split(.data$find) %>% lapply(as.list)
} else {

# Read in dataframe of taxonomic changes, split into single-row lists, and add to metadata file
metadata$taxonomic_updates <- taxonomic_updates %>% dplyr::group_split(.data$find) %>% lapply(as.list)

}

# Write metadata
write_metadata_dataset(metadata, dataset_id)
}

Expand Down Expand Up @@ -813,11 +842,13 @@ build_find_taxon <- function(taxon_name, austraits, original_name = FALSE) {

if (!original_name) {
data <- data %>%
dplyr::select(name = taxon_name, .data$dataset_id) %>%
dplyr::select(dplyr::all_of("taxon_name", "dataset_id")) %>%
rename(name = taxon_name) %>%
dplyr::distinct()
} else {
data <- data %>%
dplyr::select(name = original_name, .data$dataset_id) %>%
dplyr::select(dplyr::all_of("original_name", "dataset_id")) %>%
dplyr::rename(name = original_name) %>%
dplyr::distinct()
}

Expand Down
16 changes: 9 additions & 7 deletions R/testdata.R
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ dataset_test_worker <-
# allow some utf8 characters, those with accents over letters for foreign names
# list of codes is here: http://www.utf8-chartable.de/
# note c3 is needed because this is prefix for allowed UTF8 chars
exceptions <- c("ÁÅÀÂÄÆÃĀâíåæäãàáíčóöøéèłńl°êÜüùúû±µµ“”‘’-–—≈˜×")
exceptions <- c("ÁÅÀÂÄÆÃĀâíåæäãàáíÇčóöøéèłńl°êÜüùúû±µµ“”‘’-–—≈˜×")

is_allowed <- i %in% charToRaw(exceptions)
! (is_ascii | is_allowed)
Expand Down Expand Up @@ -525,12 +525,14 @@ dataset_test_worker <-
info = paste0(f, "-value types")
)

if(length(value_type_cols) > 0)
expect_isin(
data[[value_type_cols]] %>% unique(),
schema$value_type$values %>% names,
info = paste0(f, "-value types columns")
)
if(length(value_type_cols) > 0){
for(v in value_type_cols)
expect_isin(
data[[v]] %>% unique(),
schema$value_type$values %>% names,
info = paste(f, v, "- value types columns")
)
}

# Substitutions
if (!is.na(metadata[["substitutions"]][1])) {
Expand Down
2 changes: 1 addition & 1 deletion config/metadata.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
metadata:
title: 'AusTraits: a curated plant trait database for the Australian flora'
description: "AusTraits is a transformative database, containing measurements on the traits of Australia's plant taxa, standardised from hundreds of disconnected primary sources. While this repository contains the harmonised data, the raw data and code used to build the resource are also available on the project's GitHub repository,http://traitecoevo.github.io/austraits.build. Further information on the project is available in the associated publication and at the project website https://austraits.org."
version: "4.1.0"
version: "4.2.0"
doi: 10.5281/zenodo.3568417
structure_URI: https://github.com/traitecoevo/austraits.build
geo_location:
Expand Down
Loading

0 comments on commit 200db85

Please sign in to comment.