1 # Time-stamp: <2024-10-02 16:42:02 Tao Liu>
3 """Description: combine replicates
5 This code is free software; you can redistribute it and/or modify it
6 under the terms of the BSD License (see the file LICENSE included with
12 from MACS3
.IO
import BedGraphIO
13 from MACS3
.Utilities
.OptValidator
import opt_validate_cmbreps
15 # ------------------------------------
17 # ------------------------------------
19 # ------------------------------------
21 # ------------------------------------
23 # ------------------------------------
25 # ------------------------------------
29 options
= opt_validate_cmbreps(options
)
32 # debug = options.debug
33 # error = options.error
35 info("Read and build bedGraph for each replicate...")
38 for ifile
in options
.ifile
:
39 info("Read file #%d" % i
)
40 reps
.append(BedGraphIO
.bedGraphIO(ifile
).read_bedGraph())
44 info("combining tracks 1-%i with method '%s'" % (i
- 1, options
.method
))
45 cmbtrack
= reps
[0].overlie([reps
[j
] for j
in range(1, i
- 1)], func
=options
.method
)
48 ofile
= BedGraphIO
.bedGraphIO(os
.path
.join(options
.outdir
, options
.ofile
), data
=cmbtrack
)
49 info("Write bedGraph of combined scores...")
50 ofile
.write_bedGraph(name
="%s_combined_scores" % (options
.method
.upper()), description
="Scores calculated by %s" % (options
.method
.upper()))
51 info("Finished '%s'! Please check '%s'!" % (options
.method
, ofile
.bedGraph_filename
))