From 56fd31bbc3f43f7289396181a1fa6e94d211fd0b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 23 Oct 2024 00:57:59 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/rds2py/generics.py | 1 - src/rds2py/read_sce.py | 35 ++++++++++++++++++++++++++--------- test.json | 2 +- 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/src/rds2py/generics.py b/src/rds2py/generics.py index 9c7e973..cde2c21 100644 --- a/src/rds2py/generics.py +++ b/src/rds2py/generics.py @@ -37,7 +37,6 @@ "RangedSummarizedExperiment": "rds2py.parse_ranged_summarized_experiment", # single-cell experiment "SingleCellExperiment": "rds2py.parse_single_cell_experiment", - } diff --git a/src/rds2py/read_sce.py b/src/rds2py/read_sce.py index b612f67..a908539 100644 --- a/src/rds2py/read_sce.py +++ b/src/rds2py/read_sce.py @@ -7,8 +7,7 @@ def parse_single_cell_experiment(robject: dict): - """Parse an R object as - :py:class:`~singlecellexperiment.SingleCellExperiment.SingleCellExperiment`. + """Parse an R object as :py:class:`~singlecellexperiment.SingleCellExperiment.SingleCellExperiment`. Args: robject: @@ -24,7 +23,9 @@ def parse_single_cell_experiment(robject: dict): _cls = get_class(robject) if _cls not in ["SingleCellExperiment"]: - raise RuntimeError(f"`robject` does not contain a 'SingleCellExperiment' object, contains `{_cls}`.") + raise RuntimeError( + f"`robject` does not contain a 'SingleCellExperiment' object, contains `{_cls}`." + ) robject["class_name"] = "RangedSummarizedExperiment" _rse = _dispatcher(robject) @@ -32,25 +33,41 @@ def parse_single_cell_experiment(robject: dict): # check red. dims, alternative expts robj_reduced_dims = None robj_altExps = None - col_attrs = _dispatcher(robject["attributes"]["int_colData"]["attributes"]["listData"]["attributes"]["names"]) + col_attrs = _dispatcher( + robject["attributes"]["int_colData"]["attributes"]["listData"]["attributes"][ + "names" + ] + ) for idx in range(len(col_attrs)): idx_col = col_attrs[idx] - idx_value = robject["attributes"]["int_colData"]["attributes"]["listData"]["data"][idx] + idx_value = robject["attributes"]["int_colData"]["attributes"]["listData"][ + "data" + ][idx] if idx_col == "reducedDims" and idx_value["data"] is not None: - robj_reduced_dims = _dispatcher(robject["attributes"]["int_colData"]["attributes"]["listData"]["data"]) + robj_reduced_dims = _dispatcher( + robject["attributes"]["int_colData"]["attributes"]["listData"]["data"] + ) if idx_col == "altExps": - alt_names = idx_value["attributes"]["listData"]["attributes"]["names"]["data"] + alt_names = idx_value["attributes"]["listData"]["attributes"]["names"][ + "data" + ] robj_altExps = {} for idx_alt_names in range(len(alt_names)): altn = alt_names[idx_alt_names] - alt_key = list(idx_value["attributes"]["listData"]["data"][idx_alt_names]["attributes"].keys())[0] + alt_key = list( + idx_value["attributes"]["listData"]["data"][idx_alt_names][ + "attributes" + ].keys() + )[0] robj_altExps[altn] = _dispatcher( - idx_value["attributes"]["listData"]["data"][idx_alt_names]["attributes"][alt_key] + idx_value["attributes"]["listData"]["data"][idx_alt_names][ + "attributes" + ][alt_key] ) # ignore colpairs for now, does anyone even use this ? diff --git a/test.json b/test.json index 2901991..867350b 100644 --- a/test.json +++ b/test.json @@ -1,2 +1,2 @@ {'type': 'S4', 'package_name': 'SummarizedExperiment', 'class_name': 'SummarizedExperiment', 'attributes': {'colData': {'type': 'S4', 'package_name': 'S4Vectors', 'class_name': 'DFrame', 'attributes': {'rownames': {'type': 'string', 'data': ['A', 'B', 'C', 'D', 'E', 'F'], 'class_name': 'string_vector'}, 'nrows': {'type': 'integer', 'data': array([6], dtype=int32), 'attributes': {}, 'class_name': 'integer_vector'}, 'listData': {'type': 'vector', 'data': [{'type': 'string', 'data': ['ChIP', 'Input', 'ChIP', 'Input', 'ChIP', 'Input'], 'class_name': 'string_vector'}], 'attributes': {'names': {'type': 'string', 'data': ['Treatment'], 'class_name': 'string_vector'}}, 'class_name': 'vector'}, 'elementType': {'type': 'string', 'data': ['ANY'], 'class_name': 'string_vector'}, 'elementMetadata': {'type': 'other', 'data': None, 'attributes': None, 'class_name': None}, 'metadata': {'type': 'vector', 'data': [], 'attributes': {}, 'class_name': 'vector'}}}, 'elementMetadata': {'type': 'S4', 'package_name': 'S4Vectors', 'class_name': 'DFrame', 'attributes': {'rownames': {'type': 'other', 'data': None, 'attributes': None, 'class_name': None}, 'nrows': {'type': 'integer', 'data': array([200], dtype=int32), 'attributes': {}, 'class_name': 'integer_vector'}, 'listData': {'type': 'vector', 'data': [{'type': 'string', 'data': ['chr1', 'chr1', 'chr1', 'chr1', 'chr1', 'chr1', 'chr1', 'chr1', 'chr1', 'chr1', 'chr1', 'chr1', 'chr1', 'chr1', 'chr1', 'chr1', 'chr1', 'chr1', 'chr1', 'chr1', 'chr1', 'chr1', 'chr1', 'chr1', 'chr1', 'chr1', 'chr1', 'chr1', 'chr1', 'chr1', 'chr1', 'chr1', 'chr1', 'chr1', 'chr1', 'chr1', 'chr1', 'chr1', 'chr1', 'chr1', 'chr1', 'chr1', 'chr1', 'chr1', 'chr1', 'chr1', 'chr1', 'chr1', 'chr1', 'chr1', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2', 'chr2'], 'class_name': 'string_vector'}], 'attributes': {'names': {'type': 'string', 'data': ['seqs'], 'class_name': 'string_vector'}}, 'class_name': 'vector'}, 'elementType': {'type': 'string', 'data': ['ANY'], 'class_name': 'string_vector'}, 'elementMetadata': {'type': 'other', 'data': None, 'attributes': None, 'class_name': None}, 'metadata': {'type': 'vector', 'data': [], 'attributes': {}, 'class_name': 'vector'}}}, 'assays': {'type': 'S4', 'package_name': 'SummarizedExperiment', 'class_name': 'SimpleAssays', 'attributes': {'data': {'type': 'S4', 'package_name': 'S4Vectors', 'class_name': 'SimpleList', 'attributes': {'listData': {'type': 'vector', 'data': [{'type': 'double', 'data': array([5984.7896784 , 4351.34643709, 2763.82637297, ..., 20.0651535 , - 2590.73635628, 4687.51702976]), 'attributes': {'dim': {'type': 'integer', 'data': array([200, 6], dtype=int32), 'attributes': {}, 'class_name': 'integer_vector'}}, 'class_name': 'double_vector'}], 'attributes': {'names': {'type': 'string', 'data': ['counts'], 'class_name': 'string_vector'}}, 'class_name': 'vector'}, 'elementType': {'type': 'string', 'data': ['ANY'], 'class_name': 'string_vector'}, 'elementMetadata': {'type': 'other', 'data': None, 'attributes': None, 'class_name': None}, 'metadata': {'type': 'vector', 'data': [], 'attributes': {}, 'class_name': 'vector'}}}}}, 'NAMES': {'type': 'other', 'data': None, 'attributes': None, 'class_name': None}, 'metadata': {'type': 'vector', 'data': [], 'attributes': {}, 'class_name': 'vector'}}} \ No newline at end of file + 2590.73635628, 4687.51702976]), 'attributes': {'dim': {'type': 'integer', 'data': array([200, 6], dtype=int32), 'attributes': {}, 'class_name': 'integer_vector'}}, 'class_name': 'double_vector'}], 'attributes': {'names': {'type': 'string', 'data': ['counts'], 'class_name': 'string_vector'}}, 'class_name': 'vector'}, 'elementType': {'type': 'string', 'data': ['ANY'], 'class_name': 'string_vector'}, 'elementMetadata': {'type': 'other', 'data': None, 'attributes': None, 'class_name': None}, 'metadata': {'type': 'vector', 'data': [], 'attributes': {}, 'class_name': 'vector'}}}}}, 'NAMES': {'type': 'other', 'data': None, 'attributes': None, 'class_name': None}, 'metadata': {'type': 'vector', 'data': [], 'attributes': {}, 'class_name': 'vector'}}}