From a40e25dc5e86d545db189ae5a9dda621f1db1e3a Mon Sep 17 00:00:00 2001 From: Meng Wang Date: Wed, 9 Dec 2020 20:28:04 -0500 Subject: [PATCH 1/2] Add --fixedStep option for bigwigCompare --- deeptools/bigwigCompare.py | 8 +++++++- deeptools/writeBedGraph_bam_and_bw.py | 14 +++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/deeptools/bigwigCompare.py b/deeptools/bigwigCompare.py index e4d69da20..aa0b17e47 100644 --- a/deeptools/bigwigCompare.py +++ b/deeptools/bigwigCompare.py @@ -93,6 +93,11 @@ def parse_arguments(args=None): 'zeros may be wrong and this option should be used ', action='store_true') + parser.add_argument('--fixedStep', + help='Output in fixed step of bin size (as specified by --binSize), not merging ' + 'neighboring bins with same values in the output file', + action='store_true') + return parser @@ -168,7 +173,8 @@ def main(args=None): format=args.outFileFormat, smoothLength=False, missingDataAsZero=not args.skipNonCoveredRegions, - extendPairedEnds=False) + extendPairedEnds=False, + fixedStep=args.fixedStep) # Clean up temporary bigWig files, if applicable if not args.deepBlueKeepTemp: diff --git a/deeptools/writeBedGraph_bam_and_bw.py b/deeptools/writeBedGraph_bam_and_bw.py index 61cd47a42..7410470f2 100644 --- a/deeptools/writeBedGraph_bam_and_bw.py +++ b/deeptools/writeBedGraph_bam_and_bw.py @@ -45,7 +45,7 @@ def writeBedGraph_wrapper(args): def writeBedGraph_worker( chrom, start, end, tileSize, defaultFragmentLength, bamOrBwFileList, func, funcArgs, extendPairedEnds=True, smoothLength=0, - skipZeroOverZero=False, missingDataAsZero=False, fixed_step=False): + skipZeroOverZero=False, missingDataAsZero=False, fixedStep=False): r""" Writes a bedgraph having as base a number of bam files. @@ -103,12 +103,12 @@ def writeBedGraph_worker( value = func(tileCoverage, funcArgs) - if fixed_step: + if fixedStep: writeStart = start + tileIndex * tileSize writeEnd = min(writeStart + tileSize, end) try: - _file.write(toBytes("%s\t%d\t%d\t%.2f\n" % (chrom, writeStart, - writeEnd, value))) + _file.write(toBytes("{0}\t{1}\t{2}\t{3:g}\n".format(chrom, writeStart, + writeEnd, value))) except TypeError: _file.write(toBytes("{}\t{}\t{}\t{}\n".format(chrom, writeStart, writeEnd, value))) @@ -130,7 +130,7 @@ def writeBedGraph_worker( writeStart = writeEnd writeEnd = min(writeStart + tileSize, end) - if not fixed_step: + if not fixedStep: # write remaining value if not a nan if previousValue and writeStart != end and \ not np.isnan(previousValue): @@ -146,7 +146,7 @@ def writeBedGraph( bamOrBwFileList, outputFileName, fragmentLength, func, funcArgs, tileSize=25, region=None, blackListFileName=None, numberOfProcessors=1, format="bedgraph", extendPairedEnds=True, missingDataAsZero=False, - skipZeroOverZero=False, smoothLength=0, fixed_step=False, verbose=False): + skipZeroOverZero=False, smoothLength=0, fixedStep=False, verbose=False): r""" Given a list of bamfiles, a function and a function arguments, this method writes a bedgraph file (or bigwig) file @@ -205,7 +205,7 @@ def writeBedGraph( res = mapReduce.mapReduce((tileSize, fragmentLength, bamOrBwFileList, func, funcArgs, extendPairedEnds, smoothLength, - skipZeroOverZero, missingDataAsZero, fixed_step), + skipZeroOverZero, missingDataAsZero, fixedStep), writeBedGraph_wrapper, chromNamesAndSize, genomeChunkLength=genomeChunkLength, From 430c161447a2be374fea5b89bafb5aa7704bd99a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gr=C3=BCning?= Date: Tue, 4 Apr 2023 19:14:19 +0200 Subject: [PATCH 2/2] trigger new build --- deeptools/bigwigCompare.py | 1 - 1 file changed, 1 deletion(-) diff --git a/deeptools/bigwigCompare.py b/deeptools/bigwigCompare.py index aa0b17e47..fd427f0cc 100644 --- a/deeptools/bigwigCompare.py +++ b/deeptools/bigwigCompare.py @@ -97,7 +97,6 @@ def parse_arguments(args=None): help='Output in fixed step of bin size (as specified by --binSize), not merging ' 'neighboring bins with same values in the output file', action='store_true') - return parser