scout/server/blueprints/panels/views.py
def panels():
    """Show all panels for a case."""
    if request.method == 'POST':
        # update an existing panel
        csv_file = request.files['csv_file']
        content = csv_file.stream.read()
        lines = None
        try:
            if b'\n' in content:
                lines = content.decode('utf-8', 'ignore').split('\n')
            else:
                lines = content.decode('windows-1252').split('\r')
        except Exception as err:
            flash('Something went wrong while parsing the panel CSV file! ({})'.format(err), 'danger')
            return redirect(request.referrer)

        new_panel_name = request.form.get('new_panel_name')
        if new_panel_name: #create a new panel
            new_panel_id = controllers.new_panel(
                store=store,
                institute_id=request.form['institute'],
                panel_name=new_panel_name,
                display_name=request.form['display_name'],
                csv_lines=lines,
            )
            if new_panel_id is None:
                flash('Something went wrong and the panel list was not updated!','warning')
                return redirect(request.referrer)
            else:
                flash("new gene panel added, {}!".format(new_panel_name),'success')
            return redirect(url_for('panels.panel', panel_id=new_panel_id))

        else: # modify an existing panel
            update_option = request.form['modify_option']
            panel_obj= controllers.update_panel(
                                   store=store,
                                   panel_name=request.form['panel_name'],
                                   csv_lines=lines,
                                   option=update_option
             )
            if panel_obj is None:
                return abort(404, "gene panel not found: {}".format(request.form['panel_name']))
            else:
                return redirect(url_for('panels.panel', panel_id=panel_obj['_id']))

    institutes = list(user_institutes(store, current_user))
    panel_names = [name
                   for institute in institutes
                   for name in
                   store.gene_panels(institute_id=institute['_id']).distinct('panel_name')]

    panel_versions = {}
    for name in panel_names:
        panel_versions[name]=store.gene_panels(panel_id=name)

    panel_groups = []
    for institute_obj in institutes:
         institute_panels = store.latest_panels(institute_obj['_id'])
         panel_groups.append((institute_obj, institute_panels))

    return dict(panel_groups=panel_groups, panel_names=panel_names,
                panel_versions=panel_versions, institutes=institutes)
def panels():
    if request.method == 'POST':
        # update an existing panel
        csv_file = request.files['csv_file']
        content = csv_file.stream.read()
        lines = None
        try:
            if b'\n' in content:
                lines = content.decode('utf-8', 'ignore').split('\n')
            else:
                lines = content.decode('windows-1252').split('\r')
        except Exception as err:
            flash('Something went wrong while parsing the panel CSV file! ({})'.format(err), 'danger')
            return redirect(request.referrer)

        new_panel_name = request.form.get('new_panel_name')
        if new_panel_name: #create a new panel
            new_panel_id = controllers.new_panel(
                store=store,
                institute_id=request.form['institute'],
                panel_name=new_panel_name,
                display_name=request.form['display_name'],
                csv_lines=lines,
            )
            if new_panel_id is None:
                flash('Something went wrong and the panel list was not updated!','warning')
                return redirect(request.referrer)
            else:
                flash("new gene panel added, {}!".format(new_panel_name),'success')
            return redirect(url_for('panels.panel', panel_id=new_panel_id))

        else: # modify an existing panel
            update_option = request.form['modify_option']
            panel_obj= controllers.update_panel(
                                   store=store,
                                   panel_name=request.form['panel_name'],
                                   csv_lines=lines,
                                   option=update_option
             )
            if panel_obj is None:
                return abort(404, "gene panel not found: {}".format(request.form['panel_name']))
            else:
                return redirect(url_for('panels.panel', panel_id=panel_obj['_id']))

    institutes = list(user_institutes(store, current_user))
    panel_names = [name
                   for institute in institutes
                   for name in
                   store.gene_panels(institute_id=institute['_id']).distinct('panel_name')]

    panel_versions = {}
    for name in panel_names:
        panel_versions[name]=store.gene_panels(panel_id=name)

    panel_groups = []
    for institute_obj in institutes:
         institute_panels = store.latest_panels(institute_obj['_id'])
         panel_groups.append((institute_obj, institute_panels))

    return dict(panel_groups=panel_groups, panel_names=panel_names,
                panel_versions=panel_versions, institutes=institutes)
def panels ( ) : if request . method == 'POST' : # update an existing panel csv_file = request . files [ 'csv_file' ] content = csv_file . stream . read ( ) lines = None try : if b'\n' in content : lines = content . decode ( 'utf-8' , 'ignore' ) . split ( '\n' ) else : lines = content . decode ( 'windows-1252' ) . split ( '\r' ) except Exception as err : flash ( 'Something went wrong while parsing the panel CSV file! ({})' . format ( err ) , 'danger' ) return redirect ( request . referrer ) new_panel_name = request . form . get ( 'new_panel_name' ) if new_panel_name : #create a new panel new_panel_id = controllers . new_panel ( store = store , institute_id = request . form [ 'institute' ] , panel_name = new_panel_name , display_name = request . form [ 'display_name' ] , csv_lines = lines , ) if new_panel_id is None : flash ( 'Something went wrong and the panel list was not updated!' , 'warning' ) return redirect ( request . referrer ) else : flash ( "new gene panel added, {}!" . format ( new_panel_name ) , 'success' ) return redirect ( url_for ( 'panels.panel' , panel_id = new_panel_id ) ) else : # modify an existing panel update_option = request . form [ 'modify_option' ] panel_obj = controllers . update_panel ( store = store , panel_name = request . form [ 'panel_name' ] , csv_lines = lines , option = update_option ) if panel_obj is None : return abort ( 404 , "gene panel not found: {}" . format ( request . form [ 'panel_name' ] ) ) else : return redirect ( url_for ( 'panels.panel' , panel_id = panel_obj [ '_id' ] ) ) institutes = list ( user_institutes ( store , current_user ) ) panel_names = [ name for institute in institutes for name in store . gene_panels ( institute_id = institute [ '_id' ] ) . distinct ( 'panel_name' ) ] panel_versions = { } for name in panel_names : panel_versions [ name ] = store . gene_panels ( panel_id = name ) panel_groups = [ ] for institute_obj in institutes : institute_panels = store . latest_panels ( institute_obj [ '_id' ] ) panel_groups . append ( ( institute_obj , institute_panels ) ) return dict ( panel_groups = panel_groups , panel_names = panel_names , panel_versions = panel_versions , institutes = institutes )
Show all panels for a case.
Show all panels for a case .