Skip to content

Commit

Permalink
Force unix-style line endings on tsv outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
nvictus committed Feb 1, 2024
1 parent 4bcdb07 commit 1c13d84
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/cooler/cli/digest.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ def digest(chromsizes, fasta, enzyme, out, header, rel_ids):
f = open(out, "w")

if header:
frags[0:0].to_csv(f, sep="\t", index=False, header=True)
frags.to_csv(f, sep="\t", index=False, header=False)
frags[0:0].to_csv(
f, sep="\t", line_terminator='\n', index=False, header=True
)
frags.to_csv(f, sep="\t", line_terminator='\n', index=False, header=False)
f.flush()
9 changes: 8 additions & 1 deletion src/cooler/cli/dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,13 +280,20 @@ def dump(
if is_first_chunk:
if header:
chunk[0:0].to_csv(
f, sep="\t", index=False, header=True, float_format=float_format
f,
sep="\t",
line_terminator='\n',
index=False,
header=True,
float_format=float_format,
na_rep=na_rep,
)
is_first_chunk = False

chunk.to_csv(
f,
sep="\t",
line_terminator='\n',
index=False,
header=False,
float_format=float_format,
Expand Down
6 changes: 4 additions & 2 deletions src/cooler/cli/makebins.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ def makebins(chromsizes, binsize, out, header, rel_ids):
f = open(out, "w")

if header:
bins[0:0].to_csv(f, sep="\t", index=False, header=True)
bins.to_csv(f, sep="\t", index=False, header=False)
bins[0:0].to_csv(
f, sep="\t", line_terminator='\n', index=False, header=True
)
bins.to_csv(f, sep="\t", line_terminator='\n', index=False, header=False)
f.flush()

0 comments on commit 1c13d84

Please sign in to comment.