icarda-git / QBMS

R package to query Breeding Management System (BMS) database
https://icarda-git.github.io/QBMS/
GNU General Public License v3.0
8 stars 5 forks source link

Get list_crops working with DeltaBreed #16

Closed nickpalladino closed 6 months ago

nickpalladino commented 8 months ago
khaled-alshamaa commented 6 months ago
  • allow base URLs with multiple /'s in path to support DeltaBreed, ex: https://sandbox.breedinginsight.net/v1/programs/025a8e6e-15fc-4488-8d26-41eb16107a95

    • Not sure what case that relied on the regex before that this would affect
  • add brapi v2 support to list_crops

Thanks for adding BrAPI v2 support to list_crops :-) On the other hand, that regex used to extract the DNS name out of the full link that users my insert (e.g., the GUI login page). You have to use the path parameter to provide the API path (e.g., v1/programs/025a8e6e-15fc-4488-8d26-41eb16107a95 in your case).

khaled-alshamaa commented 6 months ago

Please find below an example script using QBMS to query and retrieve data from DeltaBreed server:

# DeltaBreed: https://sandbox.breedinginsight.net/
# username:   guestusr@mailinator.com
# password:   guestusr1 

install.packages("remotes")
remotes::install_github("icarda-git/QBMS")

library(QBMS)

set_qbms_config(url = 'https://sandbox.breedinginsight.net/', 
                path = 'v1/programs/025a8e6e-15fc-4488-8d26-41eb16107a95', 
                engine = '', 
                brapi_ver = 'v2')

# Once you are logged into DeltaBreed, under the BrAPI tab, generate an access 
# token to permit access via BrAPI
set_token(readline('token:'))

# get the list of crops
list_crops()

# list all breeding programs in the selected crop
list_programs()

# select a breeding program by name
set_program("Public (PUBL)")

# list all studies/trials in the selected program
list_trials()

# select a specific study/trial by name
set_trial("Performance Trial 2023B")

# list all environments/locations information in the selected study/trial
list_studies()

# select a specific environment/location by name
set_study("Parlier FA23")

# retrieve general information, data, and germplasm list 
# of the selected environment/location
info <- get_study_info()
data <- get_study_data()
germplasm <- get_germplasm_list()

# get observation variable ontology in the selected study/trial
ontology <- get_trial_obs_ontology()

# retrieve multi-environment trial data of the selected study/trial
MET <- get_trial_data()