Esempio n. 1
0
 def from_connection(connection=None):
     connection = get_connection(MODULE_NAME, connection)
     engine = create_engine(connection)
     session_maker = sessionmaker(bind=engine,
                                  autoflush=False,
                                  expire_on_commit=False)
     session = scoped_session(session_maker)
     return Manager(engine, session)
Esempio n. 2
0
    def __init__(self, connection=None):
        """
        :param Optional[str] connection: The connection string
        """
        self.connection = get_connection(MODULE_NAME, connection=connection)
        log.info('connected to %s', self.connection)
        self.engine = create_engine(self.connection)
        self.session_maker = sessionmaker(bind=self.engine,
                                          autoflush=False,
                                          expire_on_commit=False)
        self.session = self.session_maker()
        self.create_all()

        #: a cache from group id to its model
        self.group_cache = {}
        #: a cache from (tax id, gene id) to its model
        self.gene_cache = {}

        #: a cache from NCBI tax id to its model
        self.species_cache = {}
Esempio n. 3
0
# -*- coding: utf-8 -*-

import os

from bio2bel.utils import get_connection, get_data_dir

MODULE_NAME = 'phosphosite'
DATA_DIR = get_data_dir(MODULE_NAME)
DEFAULT_CACHE_CONNECTION = get_connection(MODULE_NAME)

PROTEIN_NAMESPACE = 'UNIPROT'

PHOSPHORYLATION_URL = 'https://www.phosphosite.org/downloads/Phosphorylation_site_dataset.gz'
PHOSPHORYLATION_PATH = os.path.join(DATA_DIR, 'Phosphorylation_site_dataset.gz')

ACETYLATION_URL = 'https://www.phosphosite.org/downloads/Acetylation_site_dataset.gz'
ACETYLATION_PATH = os.path.join(DATA_DIR, 'Acetylation_site_dataset.gz')

O_GALNAC_URL = 'https://www.phosphosite.org/downloads/O-GalNAc_site_dataset.gz'
O_GALNAC_PATH = os.path.join(DATA_DIR, 'O-GalNAc_site_dataset.gz')

O_GLCNAC_URL = 'https://www.phosphosite.org/downloads/O-GlcNAc_site_dataset.gz'
O_GLCNAC_PATH = os.path.join(DATA_DIR, 'O-GlcNAc_site_dataset.gz')

SUMOYLATION_URL = 'https://www.phosphosite.org/downloads/Sumoylation_site_dataset.gz'
SUMOYLATION_PATH = os.path.join(DATA_DIR, 'Sumoylation_site_dataset.gz')

UBIQUITINATION_URL = 'https://www.phosphosite.org/downloads/Ubiquitination_site_dataset.gz'
UBIQUITINATION_PATH = os.path.join(DATA_DIR, 'Ubiquitination_site_dataset.gz')

REGULATORY_SITES_URL = 'https://www.phosphosite.org/downloads/Regulatory_sites.gz'
Esempio n. 4
0
MODULE_NAME = 'pathme'
DEFAULT_PATHME_DIR = os.path.join(os.path.expanduser('~'), '.pathme')
PATHME_DIR = os.environ.get('PATHME_DIRECTORY', DEFAULT_PATHME_DIR)

KEGG_PATHWAYS_URL = 'http://rest.kegg.jp/link/pathway/'


def get_data_dir() -> str:
    """Ensure the appropriate PathMe data directory exists for the given module, then returns the file path."""
    os.makedirs(PATHME_DIR, exist_ok=True)
    return PATHME_DIR


DATA_DIR = get_data_dir()
DEFAULT_CACHE_CONNECTION = get_connection()

# Databases contained in PathMe
#: KEGG
KEGG = 'kegg'
KEGG_DIR = os.path.join(DATA_DIR, KEGG)
KEGG_BEL = os.path.join(KEGG_DIR, 'bel')
KEGG_FILES = os.path.join(KEGG_DIR, 'xml')
KEGG_CACHE = os.path.join(KEGG_DIR, 'cache')

#: Reactome
REACTOME = 'reactome'
REACTOME_DIR = os.path.join(DATA_DIR, REACTOME)
REACTOME_BEL = os.path.join(REACTOME_DIR, 'bel')
REACTOME_FILES = os.path.join(REACTOME_DIR, 'rdf')