Skip to content

Commit

Permalink
Save n in header
Browse files Browse the repository at this point in the history
  • Loading branch information
Phlya committed Jul 17, 2020
1 parent 898d060 commit e7f86d8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion coolpuppy/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,9 +532,10 @@ def _excepthook(exc_type, value, tb):
json.dump(outdict, fp) # , sort_keys=True, indent=4)
logging.info(f"Saved individual pileups to {json_path}")
else:
pup = PU.pileupsWithControl(nproc)
pup, n = PU.pileupsWithControl(nproc)
headerdict = vars(args)
headerdict['resolution'] = int(c.binsize)
headerdict['n'] = int(n)
try:
save_array_with_header(pup, headerdict, os.path.join(args.outdir, outname))
except FileNotFoundError:
Expand Down
3 changes: 2 additions & 1 deletion coolpuppy/coolpup.py
Original file line number Diff line number Diff line change
Expand Up @@ -1160,6 +1160,7 @@ def pileupsWithControl(self, nproc=1):
loops, nums, cov_starts, cov_ends, ns = list(zip(*mymap(f, self.chroms)))
loop = np.sum(loops, axis=0)
n = np.sum(ns)
n_return = n
num = np.sum(nums, axis=0)
if self.coverage_norm:
cov_start = np.sum(cov_starts, axis=0)
Expand Down Expand Up @@ -1191,7 +1192,7 @@ def pileupsWithControl(self, nproc=1):
if nproc > 1:
p.close()
loop[~np.isfinite(loop)] = 0
return loop
return loop, n_return

def pileupsByWindow(
self, chrom, expected=False, ctrl=False,
Expand Down

0 comments on commit e7f86d8

Please sign in to comment.