Ejemplo n.º 1
0
def load_environment(global_conf, app_conf):
    """Configure the Pylons environment via the ``pylons.config``
    object
    """
    # Pylons paths
    root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    paths = dict(root=root,
                 controllers=os.path.join(root, 'controllers'),
                 static_files=os.path.join(root, 'public'),
                 templates=[os.path.join(root, 'templates')])

    # Initialize config with the basic options
    config.init_app(global_conf, app_conf, package='helloworld', paths=paths)

    config['routes.map'] = make_map()
    config['pylons.app_globals'] = app_globals.Globals()
    config['pylons.h'] = helloworld.lib.helpers

    # Create the Mako TemplateLookup, with the default auto-escaping
    config['pylons.app_globals'].mako_lookup = TemplateLookup(
        directories=paths['templates'],
        error_handler=handle_mako_error,
        module_directory=os.path.join(app_conf['cache_dir'], 'templates'),
        input_encoding='utf-8',
        default_filters=['escape'],
        imports=['from webhelpers.html import escape'])
Ejemplo n.º 2
0
def load_environment(global_conf, app_conf):
    """Configure the Pylons environment via the ``pylons.config``
    object
    """
    # Pylons paths
    root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    paths = dict(root=root,
                 controllers=os.path.join(root, 'controllers'),
                 static_files=os.path.join(root, 'public'),
                 templates=[os.path.join(root, 'templates')])

    # Initialize config with the basic options
    config.init_app(global_conf, app_conf, package='helloworld',
                    template_engine='mako', paths=paths)

    config['routes.map'] = make_map()
    config['pylons.g'] = app_globals.Globals()
    config['pylons.h'] = helloworld.lib.helpers

    # Customize templating options via this variable
    tmpl_options = config['buffet.template_options']

    # CONFIGURATION OPTIONS HERE (note: all config options will override
    # any Pylons config options)
    engine = engine_from_config(config, 'sqlalchemy.')
    init_model(engine)
Ejemplo n.º 3
0
def load_environment(global_conf, app_conf):
    """Configure the Pylons environment via the ``pylons.config``
    object
    """
    # Pylons paths
    root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    paths = dict(root=root,
                 controllers=os.path.join(root, 'controllers'),
                 static_files=os.path.join(root, 'public'),
                 templates=[os.path.join(root, 'templates')])

    # Initialize config with the basic options
    config.init_app(global_conf, app_conf, package='helloworld', paths=paths)

    config['routes.map'] = make_map()
    config['pylons.app_globals'] = app_globals.Globals()
    config['pylons.h'] = helloworld.lib.helpers

    # Create the Mako TemplateLookup, with the default auto-escaping
    config['pylons.app_globals'].mako_lookup = TemplateLookup(
        directories=paths['templates'],
        error_handler=handle_mako_error,
        module_directory=os.path.join(app_conf['cache_dir'], 'templates'),
        input_encoding='utf-8', default_filters=['escape'],
        imports=['from webhelpers.html import escape'])
Ejemplo n.º 4
0
def load_environment(global_conf, app_conf):
    """Configure the Pylons environment via the ``pylons.config``
    object
    """
    config = PylonsConfig()

    # Pylons paths
    root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    paths = dict(root=root,
                 controllers=os.path.join(root, 'controllers'),
                 static_files=os.path.join(root, 'public'),
                 templates=[os.path.join(root, 'templates')])

    # Initialize config with the basic options
    config.init_app(global_conf, app_conf, package='helloworld', paths=paths)

    config['routes.map'] = make_map(config)
    config['pylons.app_globals'] = app_globals.Globals(config)
    config['pylons.h'] = helloworld.lib.helpers

    # Setup cache object as early as possible
    import pylons
    pylons.cache._push_object(config['pylons.app_globals'].cache)

    # Create the Genshi TemplateLoader
    config['pylons.app_globals'].genshi_loader = TemplateLoader(
        paths['templates'], auto_reload=True)

    # CONFIGURATION OPTIONS HERE (note: all config options will override
    # any Pylons config options)

    # Setup the database connection (bind to an engine)

    import json
    #logging.info ('global_conf=%s' %(json.dumps(global_conf, indent=4)))
    #logging.info ('app_conf=%s' %(json.dumps(app_conf, indent=4)))

    db_engine = sqlalchemy.create_engine (config['sqlalchemy.url']);
    model.init_model (db_engine)

    return config
Ejemplo n.º 5
0
def load_environment(global_conf, app_conf):
    """Configure the Pylons environment via the ``pylons.config``
    object
    """
    config = PylonsConfig()
    
    # Pylons paths
    root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    paths = dict(root=root,
                 controllers=os.path.join(root, 'controllers'),
                 static_files=os.path.join(root, 'public'),
                 templates=[os.path.join(root, 'templates')])

    # Initialize config with the basic options
    config.init_app(global_conf, app_conf, package='helloworld', paths=paths)

    config['routes.map'] = make_map(config)
    config['pylons.app_globals'] = app_globals.Globals(config)
    config['pylons.h'] = helloworld.lib.helpers
    
    # Setup cache object as early as possible
    import pylons
    pylons.cache._push_object(config['pylons.app_globals'].cache)
    

    # Create the Mako TemplateLookup, with the default auto-escaping
    config['pylons.app_globals'].mako_lookup = TemplateLookup(
        directories=paths['templates'],
        error_handler=handle_mako_error,
        module_directory=os.path.join(app_conf['cache_dir'], 'templates'),
        input_encoding='utf-8', default_filters=['escape'],
        imports=['from webhelpers.html import escape'])

    # Setup the SQLAlchemy database engine
    engine = engine_from_config(config, 'sqlalchemy.')
    init_model(engine)

    # CONFIGURATION OPTIONS HERE (note: all config options will override
    # any Pylons config options)
    
    return config
Ejemplo n.º 6
0
def load_environment(global_conf, app_conf):
    """Configure the Pylons environment via the ``pylons.config``
    object
    """
    config = PylonsConfig()

    # Pylons paths
    root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    paths = dict(root=root,
                 controllers=os.path.join(root, 'controllers'),
                 static_files=os.path.join(root, 'public'),
                 templates=[os.path.join(root, 'templates')])

    # Initialize config with the basic options
    config.init_app(global_conf, app_conf, package='helloworld', paths=paths)

    config['routes.map'] = make_map(config)
    config['pylons.app_globals'] = app_globals.Globals(config)
    config['pylons.h'] = helloworld.lib.helpers

    # Setup cache object as early as possible
    import pylons
    pylons.cache._push_object(config['pylons.app_globals'].cache)

    # Create the Mako TemplateLookup, with the default auto-escaping
    config['pylons.app_globals'].mako_lookup = TemplateLookup(
        directories=paths['templates'],
        error_handler=handle_mako_error,
        module_directory=os.path.join(app_conf['cache_dir'], 'templates'),
        input_encoding='utf-8',
        default_filters=['escape'],
        imports=['from markupsafe import escape'])

    # CONFIGURATION OPTIONS HERE (note: all config options will override
    # any Pylons config options)

    return config
Ejemplo n.º 7
0
def load_environment(global_conf, app_conf):
    """Configure the Pylons environment via the ``pylons.config``
	object
	"""
    # Pylons paths
    root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    paths = dict(
        root=root,
        controllers=os.path.join(root, "controllers"),
        static_files=os.path.join(root, "public"),
        templates=[os.path.join(root, "templates")],
    )

    # Initialize config with the basic options
    config.init_app(global_conf, app_conf, package="helloworld", template_engine="mako", paths=paths)

    config["routes.map"] = make_map()
    config["pylons.g"] = app_globals.Globals()
    config["pylons.h"] = helloworld.lib.helpers

    # Customize templating options via this variable
    # tmpl_options = config['buffet.template_options']

    # CONFIGURATION OPTIONS HERE (note: all config options will override
    # any Pylons config options)

    # 2008-10-05 Use the strict behaviour of the template context object
    # config['pylons.strict_c'] = True

    # 2008-10-05 Create the Mako TemplateLookup, with the default auto-escaping. it doesn't work though.
    config["pylons.g"].mako_lookup = TemplateLookup(
        directories=paths["templates"],
        module_directory=os.path.join(app_conf["cache_dir"], "templates"),
        input_encoding="utf-8",
        output_encoding="utf-8",
        imports=["from webhelpers.html import escape"],
        default_filters=["escape"],
    )

    # 2008-10-05 setup the database connection
    drivername = config["app_conf"]["drivername"]
    hostname = config["app_conf"]["hostname"]
    dbname = config["app_conf"]["dbname"]
    schema = config["app_conf"]["schema"]
    db_user = config["app_conf"]["db_user"]
    db_passwd = config["app_conf"]["db_passwd"]
    pool_recycle = int(config["app_conf"]["pool_recycle"])
    # model.setup()

    model.db = model.Stock_250kDB.Stock_250kDB(
        drivername=drivername,
        username=db_user,
        password=db_passwd,
        hostname=hostname,
        database=dbname,
        schema=schema,
        pool_recycle=pool_recycle,
    )
    model.db.setup(create_tables=False)

    model.genome_db = model.GenomeDB.GenomeDatabase(
        drivername=drivername,
        username=db_user,
        password=db_passwd,
        hostname=hostname,
        database="genome",
        schema=schema,
        pool_recycle=pool_recycle,
    )

    # from variation.src import dbsnp
    # snp_db = dbsnp.DBSNP(drivername=drivername, username=db_user, password=db_passwd, \
    # 				hostname=hostname, database='dbsnp', schema=schema, pool_recycle=pool_recycle)

    # from variation.src import StockDB
    model.stock_db = model.StockDB.StockDB(
        drivername=drivername,
        username=db_user,
        password=db_passwd,
        hostname=hostname,
        database="stock",
        schema=schema,
        pool_recycle=pool_recycle,
    )

    model.at_db = model.AtDB.AtDB(
        drivername=drivername,
        username=db_user,
        password=db_passwd,
        hostname=hostname,
        database="at",
        schema=schema,
        pool_recycle=pool_recycle,
    )
    """
	for entity in entities:
		if entity.__module__==db.__module__:	#entity in the same module
			entity.metadata = metadata
			#using_table_options_handler(entity, schema=self.schema)
	"""
    model.genome_db.setup(create_tables=False)
    # snp_db.setup(create_tables=False)
    model.stock_db.setup(create_tables=False)
    model.at_db.setup(create_tables=False)

    from variation.src.DrawSNPRegion import DrawSNPRegion

    def dealWithGeneAnnotation():
        gene_annotation_picklef = "/Network/Data/250k/tmp-yh/at_gene_model_pickelf"
        DrawSNPRegion_ins = DrawSNPRegion(
            db_user=db_user,
            db_passwd=db_passwd,
            hostname=hostname,
            database=dbname,
            input_fname="/tmp/dumb",
            output_dir="/tmp",
            debug=0,
        )
        gene_annotation = DrawSNPRegion_ins.dealWithGeneAnnotation(
            gene_annotation_picklef, cls_with_db_args=DrawSNPRegion_ins
        )
        return gene_annotation

    model.gene_annotation = dealWithGeneAnnotation()

    # 2008-11-05 a dictionary to link two tables of types in order for cross-linking between pages of DisplayTopSNPTestRM and ScoreRankHistogram/DisplayResultsGene
    model.CandidateGeneTopSNPTestRMType_id_min_distance2ScoreRankHistogramType_id = {}
    ScoreRankHistogramType = model.Stock_250kDB.ScoreRankHistogramType
    CandidateGeneTopSNPTestRMType = model.Stock_250kDB.CandidateGeneTopSNPTestRMType

    rows = model.db.metadata.bind.execute(
        "select s.id as sid, s.min_distance, s.call_method_id, c.id as cid from %s s, %s c where s.null_distribution_type_id=c.null_distribution_type_id and\
					s.results_type=c.results_type and s.get_closest=c.get_closest and s.min_MAF=c.min_MAF and \
					s.allow_two_sample_overlapping=c.allow_two_sample_overlapping"
        % (ScoreRankHistogramType.table.name, CandidateGeneTopSNPTestRMType.table.name)
    )  # 2008-1-8 temporarily set call_method_id=17 cuz CandidateGeneTopSNPTestRMType doesn't include call_method_id

    for row in rows:
        key_tuple = (row.cid, row.min_distance, row.call_method_id)
        model.CandidateGeneTopSNPTestRMType_id_min_distance2ScoreRankHistogramType_id[key_tuple] = row.sid

        # 2009-4-10 takes too long in individual request, put here. used in Accession.py
    from variation.src.common import map_perlegen_ecotype_name2accession_id, fillInPhenotypeMethodID2ecotype_id_set

    model.ecotype_name2accession_id = map_perlegen_ecotype_name2accession_id(model.db.metadata.bind)
    # 2009-11-17
    model.PhenotypeMethodID2ecotype_id_set = fillInPhenotypeMethodID2ecotype_id_set(model.Stock_250kDB.PhenotypeAvg)
    # 2009-11-17
    from variation.src.common import fillInCallMethodID2ecotype_id_set

    model.CallMethodID2ecotype_id_set = fillInCallMethodID2ecotype_id_set(model.Stock_250kDB.CallInfo)