diff options
author | Alexander_Kabui | 2023-06-21 01:06:54 +0300 |
---|---|---|
committer | Alexander_Kabui | 2023-06-21 01:06:54 +0300 |
commit | 11769b10c683a935dd2420d8bcdfafb7f8f974a0 (patch) | |
tree | 2183a59f3c989be2820f6cd0e5c25078d6e18da4 | |
parent | 09ab7df7a5cedb3bf09117626a46185ad46566f8 (diff) | |
download | genenetwork3-feature/lmdb-rust.tar.gz |
add lmdb rust caller functionfeature/lmdb-rust
-rw-r--r-- | gn3/computations/rust_correlation.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/gn3/computations/rust_correlation.py b/gn3/computations/rust_correlation.py index 546da0e..f9e8ff4 100644 --- a/gn3/computations/rust_correlation.py +++ b/gn3/computations/rust_correlation.py @@ -172,3 +172,26 @@ def parse_tissue_corr_data(symbol_name: str, results = (x_vals, data) return results + + +def run_lmdb_correlation(lmdb_info:dict): + """ + how is this correlation different from the one above: + 1) all the preparsing is done in rust which is consinderally fast + 2) file are read directly format of the file is lmdb + can also compute correlation or unprocessed csv files + """ + tmp_json_file = os.path.join(tmp_dir, f"{random_string(10)}.json") + output_file = os.path.join(tmp_dir, f"{random_string(10)}.txt") + with open(tmp_json_file, "w", encoding="utf-8") as outputfile: + json.dump({"outputfile": output_file, **lmdb_info}) + command_list = [CORRELATION_COMMAND, json_file, TMPDIR] + try: + subprocess.run(command_list, check=True, capture_output=True) + except subprocess.CalledProcessError as cpe: + actual_command = ( + os.readlink(CORRELATION_COMMAND) + if os.path.islink(CORRELATION_COMMAND) + else CORRELATION_COMMAND) + raise Exception(command_list, actual_command, cpe.stdout) from cpe + return parse_correlation_output(output_file, corr_type) |