diff options
| author | Alexander_Kabui | 2025-01-23 13:52:18 +0300 |
|---|---|---|
| committer | BonfaceKilz | 2025-02-06 12:43:15 +0300 |
| commit | 39f0fe344eb63d70b3dde4065694fbe94f0fc2e9 (patch) | |
| tree | c70cd157785266080ffd7993f49c2832b9558aac /gn3/computations/rqtl2.py | |
| parent | 3217602490a14d179820235d3d7d25a56995dc1e (diff) | |
| download | genenetwork3-39f0fe344eb63d70b3dde4065694fbe94f0fc2e9.tar.gz | |
feat: Add function to generate rqtl2 data files.
Diffstat (limited to 'gn3/computations/rqtl2.py')
| -rw-r--r-- | gn3/computations/rqtl2.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/gn3/computations/rqtl2.py b/gn3/computations/rqtl2.py index d515e74..4e72322 100644 --- a/gn3/computations/rqtl2.py +++ b/gn3/computations/rqtl2.py @@ -5,6 +5,25 @@ import json from pathlib import Path from typing import Dict +def generate_rqtl2_files(data, workspace_dir): + """Prepare data and generate necessary CSV files + required to write to control_file + """ + # Map of file names to corresponding data keys in the provided dictionary + file_to_name_map = { + "geno_file": "geno_data", + "pheno_file": "pheno_data", + "geno_map_file": "geno_map_data", + "pheno_map_file": "pheno_map_data", + "phenocovar_file": "phenocovar_data", + } + parsed_files = {} + for file_name, data_key in file_to_name_map.items(): + if data_key in data: + file_path = write_to_csv(workspace_dir, f"{file_name}.csv", data[data_key]) + parsed_files[file_name] = file_path + return {**data, **parsed_files} + def write_to_csv(work_dir, file_name, data:list[dict], headers= None, delimiter=","): |
