From 18864f74ed1d48f1bffa9991c0777a43582cff96 Mon Sep 17 00:00:00 2001 From: Florian Finkernagel Date: Fri, 22 Jun 2018 14:05:37 +0200 Subject: [PATCH 1/2] greatly improve speed of pandasGEXpress.get_ordered_idx --- cmapPy/pandasGEXpress/parse_gctx.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmapPy/pandasGEXpress/parse_gctx.py b/cmapPy/pandasGEXpress/parse_gctx.py index b70e29d..1856aa2 100644 --- a/cmapPy/pandasGEXpress/parse_gctx.py +++ b/cmapPy/pandasGEXpress/parse_gctx.py @@ -229,12 +229,14 @@ def get_ordered_idx(id_type, id_list, meta_df): if id_type is None: id_list = range(0, len(list(meta_df.index))) elif id_type == "id": - id_list = [list(meta_df.index).index(str(i)) for i in id_list] + lookup = {x: i for (i,x) in enumerate(meta_df.index)} + id_list = [lookup[str(i)] for i in id_list] return sorted(id_list) else: return None + def parse_metadata_df(dim, meta_group, convert_neg_666): """ Reads in all metadata from .gctx file to pandas DataFrame From c1653b5c9ab12e2f0c136ca2ddf48f04d990b578 Mon Sep 17 00:00:00 2001 From: Florian Finkernagel Date: Fri, 22 Jun 2018 14:09:26 +0200 Subject: [PATCH 2/2] removed newline --- cmapPy/pandasGEXpress/parse_gctx.py | 1 - 1 file changed, 1 deletion(-) diff --git a/cmapPy/pandasGEXpress/parse_gctx.py b/cmapPy/pandasGEXpress/parse_gctx.py index 1856aa2..1a5fbac 100644 --- a/cmapPy/pandasGEXpress/parse_gctx.py +++ b/cmapPy/pandasGEXpress/parse_gctx.py @@ -236,7 +236,6 @@ def get_ordered_idx(id_type, id_list, meta_df): return None - def parse_metadata_df(dim, meta_group, convert_neg_666): """ Reads in all metadata from .gctx file to pandas DataFrame