diff options
author | Alexander_Kabui | 2022-09-07 00:13:34 +0300 |
---|---|---|
committer | Alexander_Kabui | 2022-09-07 00:13:34 +0300 |
commit | f24df16b8629d9c4f869c0ccdaa245e8ba7a0b2e (patch) | |
tree | d6f6f82376c9bf362950b69579a30a2c10b6e049 /wqflask | |
parent | d6c8505606b7b9fa1e41b3ee8bca303a0f8d6597 (diff) | |
download | genenetwork2-f24df16b8629d9c4f869c0ccdaa245e8ba7a0b2e.tar.gz |
filter list vals with index
Diffstat (limited to 'wqflask')
-rw-r--r-- | wqflask/wqflask/correlation/pre_computes.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/wqflask/wqflask/correlation/pre_computes.py b/wqflask/wqflask/correlation/pre_computes.py index eb089a03..aacc3071 100644 --- a/wqflask/wqflask/correlation/pre_computes.py +++ b/wqflask/wqflask/correlation/pre_computes.py @@ -194,6 +194,10 @@ def read_text_file(sample_dict, file_path): return_list[0] = return_list[0][1:] return return_list + def filter_line_with_index(line, index): + lst = parse_line_csv(line) + return ",".join([lst[i] for i in index]) + def __fetch_id_positions__(all_ids, target_ids): _vals = [] _posit = [0] # alternative for parsing @@ -203,14 +207,10 @@ def read_text_file(sample_dict, file_path): _vals.append(target_ids[strain]) _posit.append(idx) - else: - _vals.append("") # todo;modify x_vals to take string rust - return (_posit, _vals) with open(file_path, "r") as file_handler: all_ids = file_handler.readline() _posit, sample_vals = __fetch_id_positions__( parse_line_csv(all_ids)[1:], sample_dict) - - return (sample_vals, [",".join(parse_line_csv(line)) + return (sample_vals, [filter_line_with_index(line, _posit) for line in file_handler.readlines()]) |