X-Git-Url: http://woldlab.caltech.edu/gitweb/?p=erange.git;a=blobdiff_plain;f=findMotifs.py;h=a072d43432efe3d53a9455f8e92119401049f1bd;hp=e79401bf3544d8a6bb33b1c83aebb6a6fec1f227;hb=0d3e3112fd04c2e6b44a25cacef1d591658ad181;hpb=5e4ae21098dba3d1edcf11e7279da0d84c3422e4 diff --git a/findMotifs.py b/findMotifs.py index e79401b..a072d43 100755 --- a/findMotifs.py +++ b/findMotifs.py @@ -8,14 +8,17 @@ try: except: pass -import sys, os, optparse +import sys +import os +import optparse from cistematic.experiments.fasta import Fasta from cistematic.programs.meme import Meme from cistematic.programs.cisGreedy import CisGreedy +from commoncode import getConfigParser, getConfigOption, getConfigIntOption, getConfigFloatOption, getConfigBoolOption #TODO: cisSampler is not supported yet! #from cistematic.programs.cisSampler import CisSampler -print "%prog: version 3.4" +print "findMotifs: version 3.5" def main(argv=None): if not argv: @@ -23,18 +26,7 @@ def main(argv=None): usage = "usage: python %prog explabel regions.fsa [options]" - parser = optparse.OptionParser(usage=usage) - parser.add_option("--meme", action="store_true", dest="doMeme") - parser.add_option("--cisGreedy", action="store_true", dest="doCisGreedy") - parser.add_option("--logo", action="store_true", dest="saveLogo") - parser.add_option("--threshold", type="float", dest="threshold") - parser.add_option("--prefix", dest="motifPrefix") - parser.add_option("--numMotifs", dest="numMotifs") - parser.add_option("--maxWidth", type="int", dest="maxWidth") - parser.add_option("--maskLower", action="store_true", dest="maskLower") - parser.set_defaults(doMeme=False, doCisGreedy=False, saveLogo=False, - threshold=75., numMotifs="10", maxWidth=28, maskLower=False) - + parser = getParser(usage) (options, args) = parser.parse_args(argv[1:]) if len(args) < 2: @@ -55,6 +47,34 @@ def main(argv=None): doCisSampler) +def getParser(usage): + parser = optparse.OptionParser(usage=usage) + parser.add_option("--meme", action="store_true", dest="doMeme") + parser.add_option("--cisGreedy", action="store_true", dest="doCisGreedy") + parser.add_option("--logo", action="store_true", dest="saveLogo") + parser.add_option("--threshold", type="float", dest="threshold") + parser.add_option("--prefix", dest="motifPrefix") + parser.add_option("--numMotifs", dest="numMotifs") + parser.add_option("--maxWidth", type="int", dest="maxWidth") + parser.add_option("--maskLower", action="store_true", dest="maskLower") + + configParser = getConfigParser() + section = "findMotifs" + doMeme = getConfigBoolOption(configParser, section, "doMeme", False) + doCisGreedy = getConfigBoolOption(configParser, section, "doCisGreedy", False) + saveLogo = getConfigBoolOption(configParser, section, "saveLogo", False) + threshold = getConfigFloatOption(configParser, section, "threshold", 75.) + numMotifs = getConfigOption(configParser, section, "numMotifs", "10") + maxWidth = getConfigIntOption(configParser, section, "maxWidth", 28) + maskLower = getConfigBoolOption(configParser, section, "maskLower", False) + + + parser.set_defaults(doMeme=doMeme, doCisGreedy=doCisGreedy, saveLogo=saveLogo, + threshold=threshold, numMotifs=numMotifs, maxWidth=maxWidth, maskLower=maskLower) + + return parser + + def findMotifs(expbase, fsafile, doMeme=False, doCisGreedy=False, saveLogo=False, threshold=75., numMotifs="10", maxWidth=28, maskLower=False, doCisSampler=False):