diff options
| author | Alexander_Kabui | 2025-01-23 13:59:20 +0300 |
|---|---|---|
| committer | BonfaceKilz | 2025-02-06 12:43:15 +0300 |
| commit | 18d1541f056cc28219dd993e89ed64f8bd73aca7 (patch) | |
| tree | 2fb860d03970d2742f163bb889379bf34a5dbbf8 | |
| parent | 0169bd8b4ffe5cb5676e2fe2e4f0f82cdd104047 (diff) | |
| download | genenetwork3-18d1541f056cc28219dd993e89ed64f8bd73aca7.tar.gz | |
feat: Add function to prepare files and workspace directory for computation.
| -rw-r--r-- | gn3/computations/rqtl2.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/gn3/computations/rqtl2.py b/gn3/computations/rqtl2.py index 95d8225..9377fd5 100644 --- a/gn3/computations/rqtl2.py +++ b/gn3/computations/rqtl2.py @@ -76,3 +76,20 @@ def create_file(file_path): except FileExistsError: return False, "File Already Exists" + +def prepare_files(tmpdir): + """Prepare necessary files and workspace dir for computation.""" + workspace_dir = os.path.join(tmpdir, str(uuid.uuid4())) # + os.makedirs(workspace_dir) + input_file = os.path.join(workspace_dir, f"rqtl2-input-{uuid.uuid4()}.json") + output_file = os.path.join(workspace_dir, f"rqtl2-output-{uuid.uuid4()}.json") + + # to ensure streaming api has access to file even after computation ends + # .. Create the log file outside the workspace_dir + log_file = os.path.join(tmpdir, f"rqtl2-log-{uuid.uuid4()}") + for file_path in [input_file, output_file, log_file]: + create_file(file_path) + return workspace_dir, input_file, output_file, log_file + + + |
