1 # Time-stamp: <2024-10-02 15:55:43 Tao Liu>
3 """Description: Fine-tuning script to call broad peaks from a single
4 bedGraph track for scores.
6 This code is free software; you can redistribute it and/or modify it
7 under the terms of the BSD License (see the file LICENSE included with
12 # ------------------------------------
14 # ------------------------------------
17 from MACS3
.IO
import BedGraphIO
18 # ------------------------------------
20 # ------------------------------------
22 # ------------------------------------
24 # ------------------------------------
25 from MACS3
.Utilities
.Logger
import logging
27 logger
= logging
.getLogger(__name__
)
30 error
= logger
.critical
33 # ------------------------------------
35 # ------------------------------------
37 # ------------------------------------
39 # ------------------------------------
43 info("Read and build bedGraph...")
44 bio
= BedGraphIO
.bedGraphIO(options
.ifile
)
45 btrack
= bio
.read_bedGraph(baseline_value
=0)
47 info("Call peaks from bedGraph...")
49 bpeaks
= btrack
.call_broadpeaks(options
.cutoffpeak
, options
.cutofflink
, options
.minlen
, options
.lvl1maxgap
, options
.lvl2maxgap
)
51 info("Write peaks...")
54 bf
= open(os
.path
.join(options
.outdir
, options
.ofile
), "w")
55 options
.oprefix
= options
.ofile
57 bf
= open(os
.path
.join(options
.outdir
, "%s_c%.1f_C%.2f_l%d_g%d_G%d_broad.bed12" % (options
.oprefix
,options
.cutoffpeak
, options
.cutofflink
, options
.minlen
, options
.lvl1maxgap
, options
.lvl2maxgap
)), "w")
58 bpeaks
.write_to_gappedPeak(bf
, name_prefix
=(options
.oprefix
+"_broadRegion").encode(), score_column
="score", trackline
=options
.trackline
)