Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelkyu committed Dec 12, 2018
1 parent 52b2c55 commit a267da4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
13 changes: 6 additions & 7 deletions ddot/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -817,11 +817,6 @@ def load_edgeMatrix(ndex_uuid,
cx = json.load(response.raw)
if verbose:
print('NDEx download and CX parse time (sec):', time.time() - start)

# tmp = response.content
# if verbose:
# print('NDEx download time (sec):', time.time() - start)
# cx = json.loads(tmp)

start_loop = time.time()

Expand All @@ -833,12 +828,16 @@ def load_edgeMatrix(ndex_uuid,
if 'matrix_dtype' in aspect:
dtype = np.dtype(aspect.get('matrix_dtype')[0].get('v'))

dim = (len(rows), len(cols))
dim = (len(rows), len(cols))
if sys.version_info.major==3:
X_buf = bytearray(dim[0] * dim[1] * np.dtype(dtype).itemsize)
else:
raise Exception("Not supported")
pointer = 0

if verbose:
print('Dim:', dim)
print('Bytes:', len(X_buf))

for aspect in cx:
if 'matrix' in aspect:
Expand All @@ -853,7 +852,7 @@ def load_edgeMatrix(ndex_uuid,

# Create a NumPy array, which is nothing but a glorified
# pointer in C to the binary data in RAM
X = np.frombuffer(binary_data, dtype=dtype).reshape(dim)
X = np.frombuffer(X_buf, dtype=dtype).reshape(dim)

if verbose:
print('Iterate through CX and construct array time (sec):', time.time() - start_loop)
Expand Down
4 changes: 3 additions & 1 deletion examples/Load_example_datasets.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,9 @@
],
"source": [
"## Download human gene-gene similarity network from NDEx\n",
"## -- WARNING: This network is very large (19,009-by-19,009 matrix). Downloading will take ~10 min for a fast internet connection.\n",
"## -- WARNING: This network is very large (19,009-by-19,009 matrix).\n",
"## -- Downloading will take ~10 min for a fast internet connection.\n",
"## -- *** Requires about 7 Gb to download and process **\n",
"sim, sim_names = ddot.ndex_to_sim_matrix(\n",
" ndex_url=ddot.HUMAN_GENE_SIMILARITIES_URL,\n",
" input_fmt='cx_matrix',\n",
Expand Down

0 comments on commit a267da4

Please sign in to comment.