Skip to content

Commit

Permalink
edits public search
Browse files Browse the repository at this point in the history
added the preset function at the fetch step itself so just needs to be used once
  • Loading branch information
sameerpadhye committed Sep 24, 2024
1 parent 5625bda commit e8cfc03
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 34 deletions.
12 changes: 6 additions & 6 deletions R/external.bold.analyze.diversity.R
Original file line number Diff line number Diff line change
Expand Up @@ -140,18 +140,18 @@ bold.analyze.diversity <- function(bold_df,

# Check if data is a data frame object

if(is.data.frame(bold_df)==FALSE)
if(any(is.data.frame(bold_df)==FALSE,nrow(bold_df)==0))

{
stop("Input is not a data frame")
stop("Please re-check data input. Input needs to be a non-empty data frame")
}

# Check whether the data frame is empty

if(nrow(bold_df)==0)
# Check if taxon_rank is empty

if(is.null(taxon_rank))
{
stop("Dataframe is empty")
## Taxon rank cannot be empty
stop ("Taxon rank cannot be left empty")
}

# Empty output list
Expand Down
31 changes: 16 additions & 15 deletions R/external.bold.public.search.R
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ bold.public.search <- function(taxonomy = NULL,
if(length(trial_query_input)<=5)
{
result = fetch.public.data(query = trial_query_input)

}

else
Expand Down Expand Up @@ -133,25 +134,25 @@ bold.public.search <- function(taxonomy = NULL,
result.post.filter = Filter(function(df) nrow(df) > 0,
result.pre.filter)

# removing unwanted columns

result.rem.col=lapply(result.post.filter,
function (df)
{
res=check_and_return_preset_df(df,
category = "check_return",
preset = public.data.fields)
return(res)
}
)
# # removing unwanted columns
#
# result.rem.col=lapply(result.post.filter,
# function (df)
# {
# res=check_and_return_preset_df(df,
# category = "check_return",
# preset = public.data.fields)
# return(res)
# }
# )


# Binding the list of dataframes

result=result.rem.col%>%
bind_rows(.)%>%
dplyr::select(processid,
sampleid)
result=result.post.filter%>%
bind_rows(.)
# dplyr::select(processid,
# sampleid)

}

Expand Down
12 changes: 1 addition & 11 deletions R/helper.column_presets.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,7 @@ common_ids<-c("processid","sampleid")

public.data.fields<-bold_fields%>%
dplyr::select(field)%>%
dplyr::filter(field %in% c(common_ids,
"coord",
"inst",
"identified_by",
"sequence_run_site",
"marker_code",
"nuc_basecount",
"collection_date_start",
"collection_date_end",
"elev",
"depth"))
dplyr::filter(field %in% c(common_ids))

## Presets for export and summary

Expand Down
8 changes: 6 additions & 2 deletions R/helper.public.search.public_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,14 @@ fetch.public.data<-function (query)
# final_data.pre=reassign.data.type(final_data)

final_data$collection_date_start<-as.Date(final_data$collection_date_start,format("%Y-%m-%d"))

final_data$collection_date_end<-as.Date(final_data$collection_date_end,format("%Y-%m-%d"))

return(final_data)
final_data_preset=check_and_return_preset_df(final_data,
category = "check_return",
preset = public.data.fields)

return(final_data_preset)

}

0 comments on commit e8cfc03

Please sign in to comment.