Skip to content

Commit 24f67f4

Browse files
committed
Better naming
1 parent 5390e55 commit 24f67f4

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

coolpuppy/__main__.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,9 @@ def main():
152152
else:
153153
balance = args.weight_name
154154

155-
coolname = args.coolfile.split('::')[0].split('/')[-1].split('.')[0]
155+
coolname = os.path.splitext(os.path.basename(c.filename))[0]
156156
if args.baselist != '-':
157-
bedname = args.baselist.split('/')[-1].split('.bed')[0].split('_mm9')[0].split('_mm10')[0]
157+
bedname = os.path.splitext(os.path.basename(args.baselist))[0].split('_mm9')[0].split('_mm10')[0]
158158
else:
159159
bedname = 'stdin'
160160
import sys
@@ -320,12 +320,6 @@ def main():
320320
rescale=args.rescale,
321321
rescale_pad=args.rescale_pad,
322322
rescale_size=args.rescale_size)
323-
if args.save_all:
324-
outdict = {'%s:%s-%s' % key : (val[0], val[1].tolist())
325-
for key,val in finloops.items()}
326-
import json
327-
with open(os.path.join(args.outdir, outname)[:-4] + '.json', 'w') as fp:
328-
json.dump(outdict, fp)#, sort_keys=True, indent=4)
329323

330324
p = Pool(nproc)
331325
data = p.map(prepare_single, finloops.items())
@@ -343,6 +337,16 @@ def main():
343337
os.mkdir(args.outdir)
344338
data.to_csv(os.path.join(args.outdir, outname),
345339
sep='\t', index=False)
340+
finally:
341+
logging.info("Saved enrichment table to %s" % os.path.join(args.outdir, outname))
342+
343+
if args.save_all:
344+
outdict = {'%s:%s-%s' % key : (val[0], val[1].tolist())
345+
for key,val in finloops.items()}
346+
import json
347+
with open(os.path.join(args.outdir, outname)[:-4] + '.json', 'w') as fp:
348+
json.dump(outdict, fp)#, sort_keys=True, indent=4)
349+
logging.info("Saved individual pileups to %s.json" % os.path.join(args.outdir, outname)[:-4])
346350
else:
347351
loop = pileupsWithControl(mids=mids, filename=args.coolfile,
348352
pad=pad, nproc=nproc,
@@ -368,6 +372,8 @@ def main():
368372
except FileExistsError:
369373
pass
370374
np.savetxt(os.path.join(args.outdir, outname), loop)
375+
finally:
376+
logging.info("Saved output to %s" % os.path.join(args.outdir, outname))
371377

372378
def plotpuppy():
373379
import matplotlib

0 commit comments

Comments
 (0)