scout/build/panel.py
def build_panel(panel_info, adapter):
    """Build a gene_panel object

        Args:
            panel_info(dict): A dictionary with panel information
            adapter (scout.adapter.MongoAdapter)

        Returns:
            panel_obj(dict)

    gene_panel = dict(
        panel_id = str, # required
        institute = str, # institute_id, required
        version = float, # required
        date = datetime, # required
        display_name = str, # default is panel_name
        genes = list, # list of panel genes, sorted on panel_gene['symbol']
    )

    """
    
    panel_name = panel_info.get('panel_id', panel_info.get('panel_name'))
    if not panel_name:
        raise KeyError("Panel has to have a id")
    
    panel_obj = dict(panel_name = panel_name)
    LOG.info("Building panel with name: {0}".format(panel_name))

    try:
        institute_id = panel_info['institute']
    except KeyError as err:
        raise KeyError("Panel has to have a institute")

    # Check if institute exists in database
    if adapter.institute(institute_id) is None:
        raise IntegrityError("Institute %s could not be found" % institute_id)
    
    panel_obj['institute'] = panel_info['institute']
    
    panel_obj['version'] = float(panel_info['version'])
    
    try:
        panel_obj['date'] = panel_info['date']
    except KeyError as err:
        raise KeyError("Panel has to have a date")


    panel_obj['display_name'] = panel_info.get('display_name', panel_obj['panel_name'])
    
    gene_objs = []
    fail = False
    for gene_info in panel_info.get('genes', []):
        try:
            gene_obj = build_gene(gene_info, adapter)
            gene_objs.append(gene_obj)
        except IntegrityError as err:
            LOG.warning(err)
            fail=True
    
    if fail:
        raise IntegrityError("Some genes did not exist in database. Please see log messages.")

    panel_obj['genes'] = gene_objs

    return panel_obj
def build_panel(panel_info, adapter):
    panel_name = panel_info.get('panel_id', panel_info.get('panel_name'))
    if not panel_name:
        raise KeyError("Panel has to have a id")
    
    panel_obj = dict(panel_name = panel_name)
    LOG.info("Building panel with name: {0}".format(panel_name))

    try:
        institute_id = panel_info['institute']
    except KeyError as err:
        raise KeyError("Panel has to have a institute")

    # Check if institute exists in database
    if adapter.institute(institute_id) is None:
        raise IntegrityError("Institute %s could not be found" % institute_id)
    
    panel_obj['institute'] = panel_info['institute']
    
    panel_obj['version'] = float(panel_info['version'])
    
    try:
        panel_obj['date'] = panel_info['date']
    except KeyError as err:
        raise KeyError("Panel has to have a date")


    panel_obj['display_name'] = panel_info.get('display_name', panel_obj['panel_name'])
    
    gene_objs = []
    fail = False
    for gene_info in panel_info.get('genes', []):
        try:
            gene_obj = build_gene(gene_info, adapter)
            gene_objs.append(gene_obj)
        except IntegrityError as err:
            LOG.warning(err)
            fail=True
    
    if fail:
        raise IntegrityError("Some genes did not exist in database. Please see log messages.")

    panel_obj['genes'] = gene_objs

    return panel_obj
def build_panel ( panel_info , adapter ) : panel_name = panel_info . get ( 'panel_id' , panel_info . get ( 'panel_name' ) ) if not panel_name : raise KeyError ( "Panel has to have a id" ) panel_obj = dict ( panel_name = panel_name ) LOG . info ( "Building panel with name: {0}" . format ( panel_name ) ) try : institute_id = panel_info [ 'institute' ] except KeyError as err : raise KeyError ( "Panel has to have a institute" ) # Check if institute exists in database if adapter . institute ( institute_id ) is None : raise IntegrityError ( "Institute %s could not be found" % institute_id ) panel_obj [ 'institute' ] = panel_info [ 'institute' ] panel_obj [ 'version' ] = float ( panel_info [ 'version' ] ) try : panel_obj [ 'date' ] = panel_info [ 'date' ] except KeyError as err : raise KeyError ( "Panel has to have a date" ) panel_obj [ 'display_name' ] = panel_info . get ( 'display_name' , panel_obj [ 'panel_name' ] ) gene_objs = [ ] fail = False for gene_info in panel_info . get ( 'genes' , [ ] ) : try : gene_obj = build_gene ( gene_info , adapter ) gene_objs . append ( gene_obj ) except IntegrityError as err : LOG . warning ( err ) fail = True if fail : raise IntegrityError ( "Some genes did not exist in database. Please see log messages." ) panel_obj [ 'genes' ] = gene_objs return panel_obj
Build a gene_panel object

        Args:
            panel_info(dict): A dictionary with panel information
            adapter (scout.adapter.MongoAdapter)

        Returns:
            panel_obj(dict)

    gene_panel = dict(
        panel_id = str, # required
        institute = str, # institute_id, required
        version = float, # required
        date = datetime, # required
        display_name = str, # default is panel_name
        genes = list, # list of panel genes, sorted on panel_gene['symbol']
    )
Build a gene_panel object