Ejemplo n.º 1
0
def main():
	start_time = time()
	args = parse_args()

	if not os.path.exists(args.outdir):
		os.mkdir(args.outdir)
	os.chmod(args.outdir, 0o775)

	print 'Converting motifs...'
	sys.stdout.write('Motif is ')
	if args.type == 'iupac':
		print 'IUPAC'
		meme = parse_iupac(args.motif, args.outdir)
	elif args.type == 'matrix':
		print 'matrix'
		matrix = [map(float, x.split()) for x in args.motif.splitlines()]
		meme = meme_util.create_meme(matrix, os.path.join(args.outdir, 'input'))
	print 'Running TOMTOM...'
	print 'Parameters:'
	print '  -thresh %.2f' % (args.thresh)
	if args.evalue:
		print '  -evalue'
	print '  -min-overlap %d' % (args.min_overlap)
	print 'Looking among %s motifs' % ('central' if args.central else 'all')
	sys.stdout.flush()
	run_tomtom(meme, args.outdir, args.central, args.thresh, args.min_overlap, args.evalue)
	print 'Done in %.2fs' % (time() - start_time)
	sys.stdout.flush()
Ejemplo n.º 2
0
def main():
	try:
		args = parse_args()
	except argparse.ArgumentError as ae:
		print json.dumps({'name': ae.message.capitalize(), 'file': None})
		sys.exit(1)

	pspm = json.loads(urllib2.unquote(args.matrix))

	if not os.path.exists(args.outdir):
		os.mkdir(args.outdir)
	os.chmod(args.outdir, 0o775)

	meme_fname = create_meme(pspm, os.path.join(args.outdir, 'input'))

	exit_status = run_tomtom(meme_fname, args.outdir, 
		args.db, args.th, args.evalue, args.min_overlap)

	if exit_status == 0:
		print json.dumps({'name': 'TOMTOM results',
			'file': os.path.relpath(os.path.join(args.outdir, 'tomtom.html'), config.base_path)})
	else:
		print json.dumps({'name': ('An error occured (ERROR %d)'
			'. Please report this error with the following code: <code>%s</code>') % \
			(exit_status, os.path.basename(args.outdir)), 'file': None})
Ejemplo n.º 3
0
def main():
    try:
        args = parse_args()
    except argparse.ArgumentError as ae:
        print json.dumps({'name': ae.message.capitalize(), 'file': None})
        sys.exit(1)

    pspm = json.loads(urllib2.unquote(args.matrix))

    if not os.path.exists(args.outdir):
        os.mkdir(args.outdir)
    os.chmod(args.outdir, 0o775)

    meme_fname = create_meme(pspm, os.path.join(args.outdir, 'input'))

    exit_status = run_tomtom(meme_fname, args.outdir, args.db, args.th,
                             args.evalue, args.min_overlap)

    if exit_status == 0:
        print json.dumps({
            'name':
            'TOMTOM results',
            'file':
            os.path.relpath(os.path.join(args.outdir, 'tomtom.html'),
                            config.base_path)
        })
    else:
        print json.dumps({'name': ('An error occured (ERROR %d)'
         '. Please report this error with the following code: <code>%s</code>') % \
         (exit_status, os.path.basename(args.outdir)), 'file': None})
Ejemplo n.º 4
0
def main():
    start_time = time()
    args = parse_args()

    if not os.path.exists(args.outdir):
        os.mkdir(args.outdir)
    os.chmod(args.outdir, 0o775)

    print 'Converting motifs...'
    sys.stdout.write('Motif is ')
    if args.type == 'iupac':
        print 'IUPAC'
        meme = parse_iupac(args.motif, args.outdir)
    elif args.type == 'matrix':
        print 'matrix'
        matrix = [map(float, x.split()) for x in args.motif.splitlines()]
        meme = meme_util.create_meme(matrix,
                                     os.path.join(args.outdir, 'input'))
    print 'Running TOMTOM...'
    print 'Parameters:'
    print '  -thresh %.2f' % (args.thresh)
    if args.evalue:
        print '  -evalue'
    print '  -min-overlap %d' % (args.min_overlap)
    print 'Looking among %s motifs' % ('central' if args.central else 'all')
    sys.stdout.flush()
    run_tomtom(meme, args.outdir, args.central, args.thresh, args.min_overlap,
               args.evalue)
    print 'Done in %.2fs' % (time() - start_time)
    sys.stdout.flush()
Ejemplo n.º 5
0
def main():
	args = parse_args()

	pspm = json.loads(urllib2.unquote(''.join(sys.stdin).decode('utf-8')))

	meme = create_meme(pspm, '%s_%d' % (args.id, time()))

	out_dir = os.path.join(config.tmp_dir, '%s_%d' % (args.id, time()))
	if not os.path.exists(out_dir):
		os.mkdir(out_dir)
	os.chmod(out_dir, 0o775)

	with open(run_meme2images(meme, args.format, out_dir)) as f:
		print f.read()
Ejemplo n.º 6
0
def main():
    args = parse_args()

    pspm = json.loads(urllib2.unquote(''.join(sys.stdin).decode('utf-8')))

    meme = create_meme(pspm, '%s_%d' % (args.id, time()))

    out_dir = os.path.join(config.tmp_dir, '%s_%d' % (args.id, time()))
    if not os.path.exists(out_dir):
        os.mkdir(out_dir)
    os.chmod(out_dir, 0o775)

    with open(run_meme2images(meme, args.format, out_dir)) as f:
        print f.read()