Classes | Functions | Variables

bbcflib::genrep_cache Namespace Reference

Classes

class  Assembly
class  Store
class  Ass

Functions

def dec
def cached_ass
def cached
def init
def configuration
def get_session

Variables

tuple home_dir = os.getenv('HOME')
string conf_file = '.genrepcache.conf'
tuple conf_path = os.path.join(home_dir, conf_file)
dictionary default_conf
string section = 'GenRep cache'
tuple Base = declarative_base()
tuple metadata = MetaData()
tuple grc
tuple ass
tuple config = ConfigParser.ConfigParser()
tuple nb = config.getint(section, 'time_limit')
tuple connector = json.loads(config.get(section, 'connector'))
tuple assembly_cache = json.loads(config.get(section, 'assembly_cache'))
tuple unique_ids = json.loads(config.get(section, 'unique_ids'))
tuple timedelta = datetime.timedelta(days=nb)
tuple DBSession = init(connector, metadata, [grc, ass], echo=False)
tuple session = get_session()
tuple a = Assembly('mm9')

Detailed Description

Build a local database that store queries to GenRep. Once stored, result are fetched from it
instead of from GenRep web-service.

Use it :
from bbcflib import genrep_cache as genrep
print genrep.Assembly('mm9').chrnames

Warning :
You can only call Assembly and all methods belonging to it.
Direct calls to GenRep() or GenRepObject() are not supported

Functioning :
On import it create the configuration file `.genrepcache.conf` in your home directory with 
parameters :
    db_name = Database name.
    time_limit = Time limit when a cached response must be reloaded (in days).
    assembly_cache = List of methods you want to cache.
    unique_ids = Important attributes in your class that will determine the uniqueness of the child object
    connector = Default connector : change it to what you want and supported by sqlalchemy 
(see http://docs.sqlalchemy.org/en/latest/core/engines.html#supported-databases).

Then on method call, if the method is not in `assembly_cache` parameter, your call is redirected
to the original GenRep library, else the response is fetched from the local database (if query already logged
and not outdated)


Function Documentation

def bbcflib::genrep_cache::cached (   obj,
  func,
  uid,
  args,
  kw,
  _property 
)
Look if the method is already cached and not outdated
then return the response
def bbcflib::genrep_cache::cached_ass (   args,
  kw 
)
Cache assembly
def bbcflib::genrep_cache::dec (   obj,
  func,
  _property = False 
)
Hook to fetch response from cache if there is one.
def bbcflib::genrep_cache::init (   connector,
  metadata,
  tables,
  echo = False 
)
Initialization of the engine.

Variable Documentation

tuple bbcflib::genrep_cache::ass
Initial value:
00001 Table('ass', metadata,
00002     Column('args', Text, primary_key=True),
00003     Column('kw', Text, primary_key=True),
00004     Column('assembly', PickleType),
00005     Column('date', DateTime))
dictionary bbcflib::genrep_cache::default_conf
Initial value:
00001 {'db_name' : 'genrepcache.sqlite',
00002                 'time_limit' : 14,
00003                 'assembly_cache' : ['chrnames', 'fasta_path', 'get_sqlite_url', 'sqlite_path'],
00004                 'unique_ids' : ['intype', 'nr_assembly_id', 'source_id'],
00005                 }
tuple bbcflib::genrep_cache::grc
Initial value:
00001 Table('grc', metadata,
00002      Column('uid', Text, primary_key=True),
00003      Column('args', Text, primary_key=True),
00004      Column('kw', Text, primary_key=True),
00005      Column('response', Text),
00006      Column('date', DateTime))
 All Classes Namespaces Functions