Skip to content

Commit

Permalink
Merge pull request #8 from microbiomeDB/treeSE
Browse files Browse the repository at this point in the history
allow collections list to have no ancestor ids for all collections
  • Loading branch information
d-callan authored Jun 5, 2024
2 parents 62c0f66 + cba987a commit 905e3f1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
15 changes: 11 additions & 4 deletions R/class-Collections.R
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,18 @@ check_collections <- function(object) {
return(TRUE)
}

# check that at least one ancestorIdColumn is shared between collections
# check that at least one ancestorIdColumn is shared between collections, or there are no ancestors
firstCollectionAncestorIds <- object[[1]]@ancestorIdColumns
if (!all(sapply(object, function(x) any(x@ancestorIdColumns %in% firstCollectionAncestorIds)))) {
msg <- "at least one ancestorIdColumn must be shared between collections"
errors <- c(errors, msg)
if (!!length(firstCollectionAncestorIds)) {
if (!all(sapply(object, function(x) any(x@ancestorIdColumns %in% firstCollectionAncestorIds)))) {
msg <- "at least one ancestorIdColumn must be shared between collections"
errors <- c(errors, msg)
}
} else {
if (any(sapply(object, function(x) !!length(x@ancestorIdColumns)))) {
msg <- "at least one ancestorIdColumn must be shared between collections"
errors <- c(errors, msg)
}
}

if (length(errors) == 0) {
Expand Down
5 changes: 2 additions & 3 deletions R/internal-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,8 @@ getCollectionName <- function(collectionId, dataSourceName, ontology = NULL) {
# w columns like `iri` and `label`
collectionLabel <- unique(ontology$label[ontology$iri == collectionId])
if (collectionLabel %in% c('Kingdom','Phylum','Class','Order','Family','Genus','Species')) {
collectionLabel <- unique(paste(collectionLabel, paste0("(", ontology$parentlabel[ontology$iri == collectionId], ")")))
}
print(collectionLabel)
collectionLabel <- unique(paste(collectionLabel, paste0("(", ontology$parentlabel[ontology$iri == collectionId], ")")))
}

if (length(collectionLabel) == 1) {
return(paste(dataSourceName, collectionLabel))
Expand Down

0 comments on commit 905e3f1

Please sign in to comment.