From 9c98575e712d623083347271389395b2a90a6484 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Fri, 17 Jun 2022 14:12:25 +0530 Subject: gn3: genodb: Allow retrieval of the entire genotype matrix. * gn3/genodb.py: Document nparray in the module docstring. (nparray): New function. --- gn3/genodb.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gn3/genodb.py b/gn3/genodb.py index ba668d2..7ffaf8b 100644 --- a/gn3/genodb.py +++ b/gn3/genodb.py @@ -5,6 +5,7 @@ database. It exports the following functions. * open - Open a genotype database * matrix - Get current matrix +* nparray - Get matrix as a 2D numpy array * row - Get row of matrix * column - Get column of matrix @@ -15,6 +16,7 @@ from gn3 import genodb with genodb.open('/tmp/bxd') as db: matrix = genodb.matrix(db) + print(genodb.nparray(matrix)) print(genodb.row(matrix, 17)) print(genodb.column(matrix, 13)) ''' @@ -58,6 +60,11 @@ def matrix(db): np.reshape(np.frombuffer(read_optimized_blob[nrows*ncols :], dtype=np.uint8), (nrows, ncols))) +def nparray(matrix): + '''Get matrix as a 2D numpy array.''' + # pylint: disable=redefined-outer-name + return matrix.array + def row(matrix, index): '''Get row of matrix.''' # pylint: disable=redefined-outer-name -- cgit v1.2.3