Skip to content

Commit

Permalink
Merge pull request #31 from klarman-cell-observatory/boli
Browse files Browse the repository at this point in the history
Reformat shlex usage
  • Loading branch information
bli25 committed Jul 14, 2020
2 parents 3217e7f + 0ecb425 commit 3801d29
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pegasusio/text_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
import re
from shlex import quote
import shlex
import numpy as np
import pandas as pd
from scipy.io import mmread, mmwrite
Expand Down Expand Up @@ -141,7 +141,7 @@ def load_one_mtx_file(path: str, file_name: str, genome: str, modality: str) ->
if os.path.exists(mtx_fifo):
os.unlink(mtx_fifo)
os.mkfifo(mtx_fifo)
subprocess.Popen(f"gzip -dc {quote(mtx_file)} > {quote(mtx_fifo)}", shell = True)
subprocess.Popen(f"gunzip -c {shlex.quote(mtx_file)} > {shlex.quote(mtx_fifo)}", shell = True)
row_ind, col_ind, data, shape = read_mtx(mtx_fifo)
os.unlink(mtx_fifo)
else:
Expand Down Expand Up @@ -254,7 +254,7 @@ def _write_mtx(unidata: UnimodalData, output_dir: str, precision: int):
if os.path.exists(fifo_file):
os.unlink(fifo_file)
os.mkfifo(fifo_file)
pobj = subprocess.Popen(f"gzip < {quote(fifo_file)} > {quote(mtx_file)}", shell = True)
pobj = subprocess.Popen(f"gzip < {shlex.quote(fifo_file)} > {shlex.quote(mtx_file)}", shell = True)
write_mtx(fifo_file, matrix.data, matrix.indices, matrix.indptr, matrix.shape[0], matrix.shape[1], precision = precision) # matrix is cell x gene csr_matrix, will write as gene x cell
assert pobj.wait() == 0
os.unlink(fifo_file)
Expand Down Expand Up @@ -343,7 +343,7 @@ def load_csv_file(
if os.path.exists(csv_fifo):
os.unlink(csv_fifo)
os.mkfifo(csv_fifo)
subprocess.Popen(f"gzip -dc {quote(input_csv)} > {quote(csv_fifo)}", shell = True)
subprocess.Popen(f"gunzip -c {shlex.quote(input_csv)} > {shlex.quote(csv_fifo)}", shell = True)
row_ind, col_ind, data, shape, rowkey, rownames, colnames = read_csv(csv_fifo, sep)
os.unlink(csv_fifo)
else:
Expand Down

0 comments on commit 3801d29

Please sign in to comment.