Skip to main content
Skip table of contents

Import Export Assets

This RMarkdown file demonstrate two workflows: Export and import assets.This workflow showcases the reusability of assets in GastroPlus X and is particularly useful for: - Sharing asset libraries between projects - Creating standardized asset collections - Backing up specific assets - Collaborating across different research teams

The specified assets will be exported to intermediate project and then be imported from there to another project. The script utilizes the gastroPlusAPI package to communicate with the GastroPlus X 10.2 service.

To customize your study with this script for a different assets / project, please make changes to the “Setup Input Information” section.

Configure required packages

  1. Load other necessary necessary packages(tidyverse) required to execute the data manipulation in the script

  2. Load gastroPlusAPI package

R
library(tidyverse)
library(gastroPlusAPI)

Set working directory

Setting the working directory to the current script location ensures relative paths work correctly.

R
if (rstudioapi::isAvailable()){
  current_working_directory <- dirname(rstudioapi::getSourceEditorContext()$path)
  setwd(current_working_directory)
}

Start GPX Service

Establishes a connection to the GastroPlus service, which allows R to communicate with GastroPlus through its API.

R
gpx_service <- start_service(verbose=FALSE)
CODE
✔ Configured the GastroPlus Service
R
gpx_service$is_alive()
CODE
[1] TRUE

Setup Input Information: Export

Make modification to the variables in this chunk to customize workflow.

project_path_1 = Location of the project which assets will be exported from

asset_type_to_be_exported & assets_to_be_exported = List of assets which will be exported. Details can be retrieved by get_project_assets()

R
project_path_1 <- "../../ProjectFiles/GPX Library.gpproject"

asset_type_to_be_exported <- "Compound"
assets_to_be_exported <- c("Atenolol", "Ranitidine")

Export specified assets

Based on the variables assigned in the previous code chunk, following chunk will export assets to an intermediate project, which will be created.

R
#Load the project
open_project(project_path_1)

#Assign the assets to be exported
project_asset <- ProjectAsset$new(asset_type = asset_type_to_be_exported, assets = assets_to_be_exported)

export_assets_from_project(export_location = "../../ProjectFiles/",
                           export_project_name = "Project_for_exported_assets",
                           assets = c(project_asset))

Setup Input Information: Import

Make modification to the variables in this chunk to customize workflow.

intermediate_project = Location of the intermediate project, which was created in the previous chunk

project_path_2 = Location of the project which assets will be imported to

asset_type_to_be_imported & assets_to_be_imported = List of assets which will be imported. Details can be retrieved by get_project_assets()

R
intermediate_project <- "../../ProjectFiles/Project_for_exported_assets.gpproject"

project_path_2 <- "../../ProjectFiles/Metoprolol.gpproject"

asset_type_to_be_imported <- "Compound"
assets_to_be_imported <- c("Atenolol", "Ranitidine")

Import specified assets

Based on the variables assigned in the previous code chunk, following chunk will import assets from the intermediate project, which was created in previous chunk.

Imported assets can be listed by get_project_assets()$assets

Please save project in order to save imported assets (see save_project()).

R
#Load the intermediate project
open_project(project_path_2)

project_asset <- ProjectAsset$new(asset_type = asset_type_to_be_imported, assets = assets_to_be_imported)

import_assets_to_project(file_location = intermediate_project,
                         assets = c(project_asset))

Kill GPX Service

Properly shut down the GPX service to free system resources.

R
gpx_service$kill()
CODE
[1] TRUE
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.