From 509e6e97af5c50603d4433b81e2a08c9103d8bac Mon Sep 17 00:00:00 2001 From: sbastkowski Date: Sun, 28 Apr 2024 19:09:12 +0100 Subject: [PATCH] More changes to support zcat on mac --- quatradis/tisp/combine.py | 5 ++++- quatradis/tisp/parser.py | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/quatradis/tisp/combine.py b/quatradis/tisp/combine.py index 642caf8..dd6e3d9 100644 --- a/quatradis/tisp/combine.py +++ b/quatradis/tisp/combine.py @@ -3,6 +3,7 @@ """ import csv import os +import sys from Bio import bgzf @@ -31,7 +32,9 @@ def prepare_and_create_tabix_for_combined_plots(tabix_plot, combined_dir): for line in tabix_plot: tabix_plot_fh.write(line + "\n") - os.system("zcat " + tabix_plot_name + " | sort -k1,1 -k2,2n | bgzip > " + sorted_tabix_plot_name + + joiner = " < " if sys.platform == "darwin" else " " + + os.system("zcat" + joiner + tabix_plot_name + " | sort -k1,1 -k2,2n | bgzip > " + sorted_tabix_plot_name + " && tabix -b 2 -e 2 " + sorted_tabix_plot_name) os.remove(tabix_plot_name) diff --git a/quatradis/tisp/parser.py b/quatradis/tisp/parser.py index a7a6f3c..3ea2df7 100644 --- a/quatradis/tisp/parser.py +++ b/quatradis/tisp/parser.py @@ -2,6 +2,7 @@ import os import pandas import subprocess +import sys from Bio import bgzf @@ -133,8 +134,9 @@ def create_file_handle(plot_file, working_dir=""): @staticmethod def get_plot_file_length(plot_file, working_dir): plot_file = working_dir + os.sep + plot_file if working_dir else plot_file + joiner = " < " if sys.platform == "darwin" else " " cat = "zcat" if plot_file[-3:] == ".gz" else "cat" - wc = subprocess.check_output(["bash", "-c", cat + " " + plot_file + " | wc | awk '{print $1}'"]) + wc = subprocess.check_output(["bash", "-c", cat + joiner + plot_file + " | wc | awk '{print $1}'"]) file_length = str(wc, 'UTF-8').strip() return int(file_length)