This file is indexed.

/usr/bin/bdgcmp is in macs 2.0.9.1-1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#! /usr/bin/python
# Time-stamp: <2011-07-08 14:41:19 Tao Liu>

import os
import sys
import logging
from optparse import OptionParser

from MACS2.IO import bedGraphIO
from MACS2.cProb import poisson_cdf

# ------------------------------------
# constants
# ------------------------------------
logging.basicConfig(level=20,
                    format='%(levelname)-5s @ %(asctime)s: %(message)s ',
                    datefmt='%a, %d %b %Y %H:%M:%S',
                    stream=sys.stderr,
                    filemode="w"
                    )

# ------------------------------------
# Misc functions
# ------------------------------------
error   = logging.critical		# function alias
warn    = logging.warning
debug   = logging.debug
info    = logging.info
# ------------------------------------
# Main function
# ------------------------------------
def main():
    usage = "usage: %prog <-t TREATMENT.BEDGRAPH> <-c CONTROL.BEDGRAPH> <-o OUTPUT.BEDGRAPH> [-m METHOD] "
    description = "Calculate scores using certain method by comparing a bedGraph file from treatment and a file from control representing local bias."
    
    optparser = OptionParser(version="%prog 0.1",description=description,usage=usage,add_help_option=False)
    optparser.add_option("-h","--help",action="help",help="Show this help message and exit.")
    optparser.add_option("-t","--tfile",dest="tfile",type="string",
                         help="Required: Treatment bedGraph file, e.g. *_treat_pileup.bdg from MACSv2")
    optparser.add_option("-c","--cfile",dest="cfile",type="string",
                         help="Required: Control bedGraph file, e.g. *_control_lambda.bdg from MACSv2")
    optparser.add_option("-o","--output",dest="ofile",type="string",
                         help="Required: The output bedGraph file to write scores.")
    optparser.add_option("-m","--method",dest="method",type="string",
                         help="Method to use while calculating a score in any bin by comparing treatment value and control value. Available choices are: ppois, substract, divide which represent Poisson Pvalue (-log10(pvalue) form) using control as lambda and treatment as observation, substraction from treatment, fold change which may be problematic if there are zero in control. Default option is ppois.",default="ppois")
    (options,args) = optparser.parse_args()

    if not options.tfile or not options.cfile or not options.ofile:
        optparser.print_help()
        sys.exit()

    available_methods = ['ppois','substract','divide']
    if options.method not in available_methods:
        sys.stderr.write("Method can only be %s" % ",".join(available_methods))
    else:
        method = options.method

    info("Read and build treatment bedGraph...")
    tbio = bedGraphIO.bedGraphIO(options.tfile)
    tbtrack = tbio.build_bdgtrack()

    info("Read and build control bedGraph...")
    cbio = bedGraphIO.bedGraphIO(options.cfile)
    cbtrack = cbio.build_bdgtrack()

    info("Calculate scores comparing treatment and control by %s..." % method)
    # build score track
    if method == 'ppois':
        sbtrack = tbtrack.overlie(cbtrack,func=lambda x,y:-1*poisson_cdf(x,y,False,True))
    elif method == 'substract':
        sbtrack = tbtrack.overlie(cbtrack,func=lambda x,y:x-y)
    elif method == 'divide':
        sbtrack = tbtrack.overlie(cbtrack,func=lambda x,y:float(x)/y)        
    else:
        raise Exception("Can't reach here!")

    info("Write to output bedGraph...")
    ofhd = open(options.ofile,"w")

    sbtrack.write_bedGraph(ofhd,name="%s_Scores" % (method.upper()),description="Scores calculated by %s" % (method.upper()))
    

if __name__ == '__main__':
    main()