diff --git a/MACS3/Commands/pileup_cmd.py b/MACS3/Commands/pileup_cmd.py index 933100b9..e50d054e 100644 --- a/MACS3/Commands/pileup_cmd.py +++ b/MACS3/Commands/pileup_cmd.py @@ -4,7 +4,7 @@ under the terms of the BSD License (see the file LICENSE included with the distribution). """ -# Time-stamp: <2024-10-02 16:51:15 Tao Liu> +# Time-stamp: <2024-11-30 00:04:48 Tao Liu> # ------------------------------------ # python modules # ------------------------------------ @@ -16,7 +16,8 @@ # ------------------------------------ # from MACS3.Utilities.Constants import * from MACS3.Utilities.OptValidator import opt_validate_pileup -from MACS3.Signal.Pileup import pileup_and_write_se, pileup_and_write_pe +from MACS3.Signal.Pileup import pileup_and_write_se +from MACS3.IO.BedGraphIO import bedGraphIO # ------------------------------------ # Main function # ------------------------------------ @@ -35,7 +36,7 @@ def run(o_options): # error = options.error # 0 output arguments - options.PE_MODE = options.format in ('BAMPE', 'BEDPE') + options.PE_MODE = options.format in ('BAMPE', 'BEDPE', 'FRAG') # 0 prepare output file outfile = os.path.join(options.outdir, options.outputfile).encode() @@ -51,8 +52,9 @@ def run(o_options): t0 = treat.total # total fragments info("# total fragments/pairs in alignment file: %d" % (t0)) info("# Pileup paired-end alignment file.") - pileup_and_write_pe(treat, outfile) - + bdg = treat.pileup_bdg() + bdgio = bedGraphIO(outfile, data=bdg) + bdgio.write_bedGraph(trackline=False) else: (tsize, treat) = load_tag_files_options(options) diff --git a/MACS3/IO/BedGraphIO.py b/MACS3/IO/BedGraphIO.py index 6fdd6b50..de55d40a 100644 --- a/MACS3/IO/BedGraphIO.py +++ b/MACS3/IO/BedGraphIO.py @@ -1,6 +1,6 @@ # cython: language_level=3 # cython: profile=True -# Time-stamp: <2024-10-08 10:07:47 Tao Liu> +# Time-stamp: <2024-11-30 00:04:35 Tao Liu> """Module Description: IO Module for bedGraph file @@ -56,10 +56,10 @@ class bedGraphIO: If any of the above two criteria is violated, parsering will fail. """ - bedGraph_filename = cython.declare(str, visibility='public') + bedGraph_filename = cython.declare(bytes, visibility='public') data = cython.declare(object, visibility='public') - def __init__(self, bedGraph_filename: str, data=None): + def __init__(self, bedGraph_filename: bytes, data=None): """f must be a filename or a file handler. """ diff --git a/MACS3/IO/Parser.py b/MACS3/IO/Parser.py index 49954944..bb31a18a 100644 --- a/MACS3/IO/Parser.py +++ b/MACS3/IO/Parser.py @@ -1,7 +1,7 @@ # cython: language_level=3 # cython: profile=True # cython: linetrace=True -# Time-stamp: <2024-10-22 10:25:23 Tao Liu> +# Time-stamp: <2024-11-29 23:30:03 Tao Liu> """Module for all MACS Parser classes for input. Please note that the parsers are for reading the alignment files ONLY. @@ -1528,6 +1528,10 @@ def pe_parse_line(self, thisline: bytes): raise Exception("Less than 5 columns found at this line: %s\n" % thisline) + @cython.ccall + def build_petrack(self): + return self.build_petrack2() + @cython.ccall def build_petrack2(self): """Build PETrackII from all lines. diff --git a/MACS3/Signal/PairedEndTrack.py b/MACS3/Signal/PairedEndTrack.py index 72c39d91..d20e46a1 100644 --- a/MACS3/Signal/PairedEndTrack.py +++ b/MACS3/Signal/PairedEndTrack.py @@ -1,6 +1,6 @@ # cython: language_level=3 # cython: profile=True -# Time-stamp: <2024-10-15 15:56:00 Tao Liu> +# Time-stamp: <2024-11-29 23:37:25 Tao Liu> """Module for filter duplicate tags from paired-end data @@ -749,6 +749,8 @@ def add_loc(self, self.buf_size[chromosome] += self.buffer_size self.locations[chromosome].resize((self.buf_size[chromosome]), refcheck=False) + self.barcodes[chromosome].resize((self.buf_size[chromosome]), + refcheck=False) self.locations[chromosome][i] = (start, end, count) self.barcodes[chromosome][i] = bn self.size[chromosome] = i + 1 diff --git a/MACS3/Utilities/OptValidator.py b/MACS3/Utilities/OptValidator.py index ae7d98eb..cfa4e564 100644 --- a/MACS3/Utilities/OptValidator.py +++ b/MACS3/Utilities/OptValidator.py @@ -1,4 +1,4 @@ -# Time-stamp: <2024-11-29 22:11:31 Tao Liu> +# Time-stamp: <2024-11-29 23:48:10 Tao Liu> """Module Description This code is free software; you can redistribute it and/or modify it @@ -104,6 +104,7 @@ def opt_validate_callpeak(options): # setting it as 'all' if options.format == 'FRAG' and options.keepduplicates != "all": logger.warning("Since the format is 'FRAG', `--keep-dup` will be set as 'all'.") + options.keepduplicates = "all" if options.extsize < 1: logger.error("--extsize must >= 1!") @@ -537,7 +538,7 @@ def opt_validate_pileup(options): elif options.format == "BEDPE": options.parser = BEDPEParser elif options.format == "FRAG": - options.parser = FragParser + options.parser = FragParser else: logger.error("Format \"%s\" cannot be recognized!" % (options.format)) sys.exit(1)