X-Git-Url: http://woldlab.caltech.edu/gitweb/?p=erange.git;a=blobdiff_plain;f=featureIntersects.py;h=cd357cc072c5cc7aa4460371439ef59c428873f5;hp=e0b77267a32b6cd12751f96617cb017c30d9b671;hb=0d3e3112fd04c2e6b44a25cacef1d591658ad181;hpb=5e4ae21098dba3d1edcf11e7279da0d84c3422e4 diff --git a/featureIntersects.py b/featureIntersects.py index e0b7726..cd357cc 100755 --- a/featureIntersects.py +++ b/featureIntersects.py @@ -9,10 +9,13 @@ try: except: pass -import sys, optparse +import sys +import optparse from cistematic.core import featuresIntersecting +from commoncode import getConfigParser, getConfigOption, getConfigIntOption -print "%prog: version 1.0" + +print "featureIntersects: version 1.1" def main(argv=None): @@ -21,10 +24,7 @@ def main(argv=None): usage = "usage: python %s tabfile [--cistype type] [--radius radius]" - parser = optparse.OptionParser(usage=usage) - parser.add_option("--cistype", action="store_false", dest="cistype") - parser.add_option("--radius", type="int", dest="radius") - parser.set_defaults(cistype="TFBSCONSSITES", radius=100) + parser = makeParser(usage) (options, args) = parser.parse_args(argv[1:]) if len(args) < 1: @@ -36,6 +36,21 @@ def main(argv=None): featureIntersects(tabfile, options.cistype, options.radius) +def makeParser(usage=""): + parser = optparse.OptionParser(usage=usage) + parser.add_option("--cistype", action="store_false", dest="cistype") + parser.add_option("--radius", type="int", dest="radius") + + configParser = getConfigParser() + section = "featureIntersects" + cistype = getConfigOption(configParser, section, "cistype", "TFBSCONSSITES") + radius = getConfigIntOption(configParser, section, "radius", 100) + + parser.set_defaults(cistype=cistype, radius=radius) + + return parser + + def featureIntersects(tabFileName, cistype="TFBSCONSSITES", radius=100): tabfile = open(tabFileName) previous = ""