|
|
|
|
| system("cd data; unzip Processed_K50_dG_datasets.zip") |
|
|
|
|
| ThermoMPNN_splits <- arrow::read_parquet("intermediate/ThermoMPNN_splits.parquet") |
|
|
|
|
| |
|
|
| |
| dataset1 <- readr::read_csv( |
| file = "data/Processed_K50_dG_datasets/Tsuboyama2023_Dataset1_20230416.csv", |
| show_col_types = FALSE) |
|
|
| |
| |
|
|
| dataset1 |> |
| arrow::write_parquet( |
| "intermediate/dataset1.parquet") |
|
|
|
|
|
|
| |
|
|
| |
| |
| |
| |
|
|
| dataset2 <- readr::read_csv( |
| file = "data/Processed_K50_dG_datasets/Tsuboyama2023_Dataset2_Dataset3_20230416.csv", |
| show_col_types = FALSE) |> |
| dplyr::mutate( |
| log10_K50_trypsin_ML = as.numeric(log10_K50_trypsin_ML), |
| log10_K50_chymotrypsin_ML = as.numeric(log10_K50_chymotrypsin_ML), |
| dG_ML = as.numeric(dG_ML), |
| ddG_ML = as.numeric(ddG_ML)) |
| |
|
|
| dataset2 |> |
| arrow::write_parquet( |
| "intermediate/dataset2.parquet") |
| |
|
|
| dataset3 <- dataset2 |> |
| dplyr::filter(!is.na(ddG_ML)) |
|
|
| dataset3 |> |
| arrow::write_parquet( |
| "intermediate/dataset3.parquet") |
|
|
|
|
|
|
| dataset3_single <- dataset3 |> |
| dplyr::filter(!(mut_type |> stringr::str_detect("(ins|del|[:])"))) |
| |
|
|
| ThermoMPNN_splits |> dplyr::group_by(split_name) |> |
| dplyr::do({ |
| split <- . |
| split_name <- split$split_name[1] |
| mutant_set <- dataset3_single |> |
| dplyr::filter(mut_type != "wt") |> |
| dplyr::semi_join(split, by = c("WT_name" = "id")) |
| cat("Writing out split ", split_name, ", nrow: ", nrow(mutant_set), "\n", sep = "") |
| |
| arrow::write_parquet( |
| x = mutant_set, |
| sink = paste0("intermediate/dataset3_single_", split_name, ".parquet")) |
| data.frame() |
| }) |
|
|
|
|
| |
|
|
| system("cd data && unzip AlphaFold_model_PDBs.zip") |
|
|
|
|
| assemble_models <- function( |
| data_path, |
| dataset_tag, |
| pattern, |
| output_path) { |
|
|
| cat( |
| "data path: ", data_path, "\n", |
| "dataset_tag: ", dataset_tag, "\n", |
| "pattern: ", pattern, "\n", |
| "output path: ", output_path, "\n", |
| sep = "") |
|
|
| file_index <- 1 |
| models <- list.files( |
| path = data_path, |
| full.names = TRUE, |
| pattern = pattern, |
| recursive = TRUE) |> |
| purrr::map_dfr(.f = function(path) { |
| file_handle <- path |> |
| file(open = "rb") |> |
| gzcon() |
|
|
| if( file_index %% 10 == 0) { |
| cat("Reading '", path, "' ", file_index, "\n", sep = "") |
| } |
| file_index <<- file_index + 1 |
|
|
| lines <- file_handle |> readLines() |
| file_handle |> close() |
|
|
| data.frame( |
| dataset_tag = dataset_tag, |
| id = path |> basename() |> stringr::str_replace(".pdb", ""), |
| pdb = lines |> paste0(collapse = "\n")) |
| }) |
| models |> arrow::write_parquet(output_path) |
| } |
|
|
|
|
| assemble_models( |
| data_path = "data/AlphaFold_model_PDBs", |
| dataset_tag = "all", |
| pattern = "*.pdb", |
| output_path = "intermediate/all_pdbs.parquet") |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
|
|