Skip to content

Commit

Permalink
More changes to support zcat on mac
Browse files Browse the repository at this point in the history
  • Loading branch information
sbastkowski committed Apr 28, 2024
1 parent 5235196 commit 509e6e9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion quatradis/tisp/combine.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""
import csv
import os
import sys

from Bio import bgzf

Expand Down Expand Up @@ -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)

Expand Down
4 changes: 3 additions & 1 deletion quatradis/tisp/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os
import pandas
import subprocess
import sys

from Bio import bgzf

Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 509e6e9

Please sign in to comment.