Esempio n. 1
0
def get_datastore(project_id=None):
    global _datastore
    global x_custom_populations_map

    #sys.stderr.write("get_datastore(%s) called\n" % project_id)
    # xBrowse instances can optionally use a secondary datastore
    # whether a secondary datastore should be used is determined by whether settings.SECONDARY_DATASTORE_PROJECTS is set
    if hasattr(settings, 'SECONDARY_DATASTORE_PROJECTS'):
        if project_id is None:
            raise Exception(
                "project_id is required if secondary datastore is used, else we don't know which database to use"
            )
        if project_id in settings.SECONDARY_DATASTORE_PROJECTS:
            #sys.stderr.write("get secondary datastore for %s\n" % project_id)
            return _get_secondary_datastore()
        #else:
        #sys.stderr.write("get new 3.0 datastore for %s\n" % project_id)

    if _datastore is None:
        if x_custom_populations_map is None:
            raise Exception('x_custom_populations_map has not been set yet')
        #sys.stderr.write("create new 3.0 datastore for %s\n" % project_id)
        _datastore = MongoDatastore(
            settings.DATASTORE_DB,
            get_annotator(),
            get_custom_population_store(),
            x_custom_populations_map,
        )
    return _datastore
Esempio n. 2
0
def get_project_datastore(project_id=None):
    global _project_datastore
    global x_custom_populations_map

    # see note on get_datastore()
    if hasattr(settings, 'SECONDARY_DATASTORE_PROJECTS'):
        if project_id is None:
            raise Exception(
                "project_id is required if secondary datastore is used, else we don't know which database to use"
            )
        if project_id in settings.SECONDARY_DATASTORE_PROJECTS:
            #sys.stderr.write("Using secondary project datastore: %s\n" % project_id)
            return _get_secondary_project_datastore()
        #else:
        #sys.stderr.write("Using new project datastore: %s\n" % project_id)

    if _project_datastore is None:
        if x_custom_populations_map is None:
            raise Exception('x_custom_populations_map has not been set yet')
        _project_datastore = MongoDatastore(
            settings.PROJECT_DATASTORE_DB,
            get_annotator(),
            get_custom_population_store(),
            x_custom_populations_map,
        )
    return _project_datastore
Esempio n. 3
0
def _get_secondary_project_datastore():
    global _secondary_project_datastore
    global x_custom_populations_map

    if _secondary_project_datastore is None:
        _secondary_project_datastore = MongoDatastore(
            settings.SECONDARY_PROJECT_DATASTORE_DB,
            get_annotator(),
            get_custom_population_store(),
            x_custom_populations_map,
        )
    return _secondary_project_datastore
Esempio n. 4
0
File: mall.py Progetto: zmcv/seqr
def get_mongo_project_datastore():
    global _project_mongo_datastore

    if _project_mongo_datastore is None:
        if x_custom_populations_map is None:
            raise Exception('x_custom_populations_map has not been set yet')
        _project_mongo_datastore = MongoDatastore(
            settings.PROJECT_DATASTORE_DB,
            get_annotator(),
            get_custom_population_store(),
            x_custom_populations_map,
        )

    return _project_mongo_datastore
Esempio n. 5
0
File: mall.py Progetto: zmcv/seqr
def get_datastore(project=None):
    global _mongo_datastore
    global _elasticsearch_datastore
    global x_custom_populations_map

    if project.get_elasticsearch_index() is None:
        if _mongo_datastore is None:
            if x_custom_populations_map is None:
                raise Exception(
                    'x_custom_populations_map has not been set yet')
            _mongo_datastore = MongoDatastore(
                settings.DATASTORE_DB,
                get_annotator(),
                get_custom_population_store(),
                x_custom_populations_map,
            )
        return _mongo_datastore
    else:
        if _elasticsearch_datastore is None:
            _elasticsearch_datastore = ElasticsearchDatastore(get_annotator())
        return _elasticsearch_datastore
Esempio n. 6
0
django.setup()

import pymongo
from xbrowse.reference import Reference
from xbrowse.annotation import VariantAnnotator
from xbrowse.coverage import CoverageDatastore
from xbrowse.datastore import MongoDatastore
import reference_settings
import annotator_settings
from xbrowse_server.base.models import Project, Family, Individual
reference_db = pymongo.MongoClient('xbrowse_reference')
reference = Reference(reference_settings)

annotator_db = pymongo.MongoClient('xbrowse_annotator')
annotator = VariantAnnotator(annotator_settings, reference)
annotator._ensure_indices()

datastore_db = pymongo.MongoClient('xbrowse_datastore')
datastore = MongoDatastore(datastore_db, annotator)

user_ns = {
    'annotator': annotator,
    'datastore': datastore,
    'Project': Project,
    'Family': Family,
    'Individual': Individual,
}

import IPython
IPython.embed(user_ns=user_ns)
    population_frequency_store_settings)

vep_settings = imp.load_source('vep_settings',
                               SETTINGS_DIR + 'vep_settings.py')
VEP_ANNOTATOR = HackedVEPAnnotator(vep_settings)

annotator_settings = imp.load_source('annotator_settings',
                                     SETTINGS_DIR + 'annotator_settings.py')
ANNOTATOR = VariantAnnotator(
    settings_module=annotator_settings,
    reference=REFERENCE,
    population_frequency_store=POPULATION_FREQUENCY_STORE,
    vep_annotator=VEP_ANNOTATOR,
)

_conn = pymongo.Connection()
datastore_db = _conn['xbrowse_datastore']
population_datastore_db = _conn['xbrowse_pop_datastore']

DATASTORE = MongoDatastore(datastore_db, ANNOTATOR)
POPULATION_DATASTORE = PopulationDatastore(population_datastore_db, ANNOTATOR)

coverage_db = _conn['xbrowse_coverage']
COVERAGE_STORE = CoverageDatastore(coverage_db, REFERENCE)

project_datastore_db = _conn['xbrowse_proj_store']
PROJECT_DATASTORE = ProjectDatastore(project_datastore_db, ANNOTATOR)

cnv_store_settings = imp.load_source('cnv_store_settings',
                                     SETTINGS_DIR + 'cnv_store_settings.py')
CNV_STORE = CNVStore(cnv_store_settings, REFERENCE)