Example #1
0
def high_importance_papers():
    hi_papers = Paper.objects(high_importance=True).select_related()
    enzyme_types = EnzymeType.objects()

    tags = []
    for paper in hi_papers:
        for tag in paper.tags:
            if tag not in tags:
                tags.append(str(tag))
    tags = sorted(tags)

    data_by_tag = {}
    for tag in tags:
        hi_q = db.Q(high_importance=True)
        tag_q = db.Q(tags=tag)

        papers_data = list(
            Paper.objects(hi_q & tag_q).only(
                *papers_table.PAPERS_TABLE_FIELDS).order_by(
                    '-status').as_pymongo())
        papers_data = papers_table.process_papers_dict(papers_data,
                                                       show_owner=False)
        data_by_tag[tag] = papers_data

    enzyme_full_names = {}
    for enz_type in enzyme_types:
        enzyme_full_names[enz_type.enzyme_type] = enz_type.full_name

    return render_template('edit_tables/high_importance_papers.html',
                           data_by_tag=data_by_tag,
                           tags=tags,
                           enzyme_full_names=enzyme_full_names)
Example #2
0
def papers_that_need_data():
    user = user_datastore.get_user(current_user.id)
    title = "Papers that require curating"

    args = request.args.to_dict()
    q_no_user = db.Q(owner=None)
    q_no_data = db.Q(status__nin=['Complete - Awaiting review', 'Complete'])
    if 'enzyme_type' in args:
        q_e_type = db.Q(tags=args['enzyme_type'])
        title += f" - {args['enzyme_type']}"
    else:
        q_e_type = db.Q()

    papers_data = list(
        Paper.objects(q_no_user & q_no_data & q_e_type).only(
            *papers_table.PAPERS_TABLE_FIELDS).order_by(
                '-status').as_pymongo())
    papers_data = papers_table.process_papers_dict(papers_data,
                                                   show_owner=False)

    return render_template('edit_tables/edit_papers.html',
                           papers_data=papers_data,
                           papers_table_height='80vh',
                           papers_button_columns=['self_assign'],
                           show_owner=False,
                           title=title,
                           row_click_modal=False)
Example #3
0
def papers_with_orhpan_sequences():
    title = "Papers with orphan sequences"

    activity_enzyme_names = list(
        set(Activity.objects().distinct('enzyme_name')))
    paper_ids = []
    for name in activity_enzyme_names:
        if len(Sequence.objects(enzyme_name=name)) == 0:
            act = Activity.objects(enzyme_name=name)[0]
            paper_ids.append(act.paper)

    papers_data = list(
        Paper.objects(id__in=paper_ids).only(
            *papers_table.PAPERS_TABLE_FIELDS).order_by(
                '-status').as_pymongo())
    papers_data = papers_table.process_papers_dict(papers_data,
                                                   show_owner=False)

    return render_template('edit_tables/edit_papers.html',
                           papers_data=papers_data,
                           papers_table_height='80vh',
                           papers_button_columns=['delete', 'edit'],
                           show_owner=True,
                           title=title,
                           row_click_modal=False)
Example #4
0
def edit_papers():
    papers_data = list(Paper.objects().only(*papers_table.PAPERS_TABLE_FIELDS).order_by('-status').as_pymongo())
    papers_data = papers_table.process_papers_dict(papers_data)

    return render_template('edit_tables/edit_papers.html',
                           papers_data=papers_data, papers_table_height='80vh',
                           papers_button_columns=['delete', 'edit', 'link'],
                           show_owner=True,
                           title="Super contributor access to all papers",
                           row_click_modal=False)
Example #5
0
def my_papers():
    user = user_datastore.get_user(current_user.id)
    papers_data = list(Paper.objects(owner=user).only(*papers_table.PAPERS_TABLE_FIELDS).order_by('-status').as_pymongo())
    papers_data = papers_table.process_papers_dict(papers_data)

    papers_button_columns = ['edit']
    if user.has_role('paper_adder'):
        papers_button_columns.append('delete')

    return render_template('edit_tables/edit_papers.html',
                           papers_data=papers_data, papers_table_height='80vh',
                           papers_button_columns=papers_button_columns,
                           show_owner=True,
                           title=f"Papers assigned to {user.first_name} {user.last_name}",
                           row_click_modal=False)
Example #6
0
def enzyme_champion_papers(enzyme_type):
    user = user_datastore.get_user(current_user.id)
    enzyme_type_obj = EnzymeType.objects(enzyme_type=enzyme_type)[0]
    if enzyme_type_obj not in user.enzyme_champion:
        flash('No access', 'danger')
        return redirect(url_for('main_site.home'))

    papers_data = list(Paper.objects(tags=enzyme_type).only(*papers_table.PAPERS_TABLE_FIELDS).order_by('-status').as_pymongo())
    papers_data = papers_table.process_papers_dict(papers_data)

    return render_template('edit_tables/edit_papers.html',
                           papers_data=papers_data, papers_table_height='80vh',
                           papers_button_columns=['delete', 'edit'],
                           show_owner=True,
                           title=f"Enzyme champion for {enzyme_type} papers",
                           row_click_modal=False)
Example #7
0
def show_papers():

    args = request.args.to_dict()
    title = "Papers"

    if 'reviewed' in args:
        revQ = db.Q(reviewed=True)
    else:
        revQ = db.Q()

    status_query = db.Q(status_not='Data required')

    if 'enzyme_type' in args:
        enzyme_type_query = db.Q(tags=args['enzyme_type'])
        title += f" - featuring {args['enzyme_type']} enzymes"
    else:
        enzyme_type_query = db.Q()

    papers = Paper.objects(enzyme_type_query & revQ)

    if 'enzyme_name' in args:
        papers = filter_papers_by_enzyme_name(papers, args['enzyme_name'])
        title += f" - featuring {args['enzyme_name']}"

    if 'reaction' in args:
        papers = filter_papers_by_reaction(papers, args['reaction'])
        title += f" - featuring a {args['reaction']} reaction"

    paper_ids = [paper.id for paper in papers]
    papers_data = list(
        Paper.objects(id__in=paper_ids).only(
            *papers_table.PAPERS_TABLE_FIELDS).order_by(
                '-status').as_pymongo())
    papers_data = papers_table.process_papers_dict(papers_data)

    return render_template('edit_tables/edit_papers.html',
                           papers_data=papers_data,
                           papers_table_height='80vh',
                           papers_button_columns=[],
                           show_owner=True,
                           title=title,
                           row_click_modal=True)