def extract_genes(pmid): log_it_info('extract_genes', 'BEGIN', str(pmid)) try: check_for_other_users(current_user.name) words = model.execute(find_genes_in_abstract(pmid), current_user.name) feature_name_words = words['features'].keys() alias_name_words = words['aliases'].keys() message = 'No genes found.' feature_message = words['feature_message'] alias_message = words['alias_message'] if feature_message != '' and alias_message != '': message = feature_message + ', ' + alias_message elif feature_message != '': message = feature_message elif alias_message != '': message = alias_message log_it_info('extract_genes', 'SUCCESS') return_value = json.dumps({'message':message, 'highlight_red':list(alias_name_words), 'highlight_blue':list(feature_name_words)}) return return_value except Exception as e: flash(e.message, 'error') log_it_info('extract_genes', 'FAILURE') logging.error(e.message) return 'Error.'
def link_ref(pmid): try: check_for_other_users(current_user.name) if request.method == "POST": tasks = check_form_validity_and_convert_to_tasks(request.form) model.execute(link_paper(pmid, tasks), current_user.name, commit=True) #Link successful summary = model.execute(get_ref_summary(pmid), current_user.name) flash("Reference for pmid = " + pmid + " has been added into the database and associated with the following data:<br>" + str(summary), 'success') except Exception as e: flash(e.message, 'error') return redirect(request.args.get("next") or url_for("reference"))
def discard_ref(pmid): try: check_for_other_users(current_user.name) if request.method == "POST": moved = model.execute(move_reftemp_to_refbad(pmid), current_user.name, commit=True) if not moved: raise MoveRefException('An error occurred when deleting the reference for pmid=" + pmid + " from the database.') #Reference deleted flash("Reference for pmid=" + pmid + " has been removed from the database.", 'success') except Exception as e: flash(e.message, 'error') return redirect(request.args.get("next") or url_for("reference"))
def reference(): refs=[] num_of_refs=0 try: check_for_other_users(current_user.name) refs = model.execute(get_reftemps(), current_user.name) num_of_refs = len(refs) except Exception as e: flash(str(e), 'error') return render_template('literature_review.html', ref_list=refs, ref_count=num_of_refs, user=current_user.name)
def extract_genes(pmid): try: check_for_other_users(current_user.name) features = model.execute(find_genes_in_abstract(pmid), current_user.name) names = [] for feature in features: if feature.gene_name is not None: names.append(feature.gene_name) else: names.append(feature.name) if len(names) > 0: return str(", ".join(names)) else: return 'No genes found.' except Exception as e: flash(e.message, 'error') return 'Test string'
def discard_ref(pmid): log_it_info('discard_ref', 'BEGIN', str(pmid)) response = "" try: check_for_other_users(current_user.name) #if request.method == "POST": moved = model.execute(move_reftemp_to_refbad(pmid), current_user.name, commit=True) if not moved: raise MoveRefException('An error occurred when deleting the reference for pmid=" + pmid + " from the database.') #Reference deleted response = "Reference for pmid=" + pmid + " has been removed from the database." log_it_info('discard_ref', 'SUCCESS') except Exception as e: response = "Error:<br>" + e.message log_it_info('discard_ref', 'FAILURE') logging.error(e.message) return response
def remove_multiple(pmids): try: check_for_other_users(current_user.name) if request.method == "POST": to_be_removed = pmids.split('_') to_be_removed.remove('') for pmid in to_be_removed: moved = model.execute(move_reftemp_to_refbad(pmid), current_user.name, commit=True) if not moved: raise MoveRefException('An error occurred when deleting the reference for pmid=" + pmid + " from the database.') #Reference deleted flash("References for pmids= " + str(to_be_removed) + " have been removed from the database.", 'success') except Exception as e: flash(e.message, 'error') return redirect(request.args.get("next") or url_for("reference"))
def reference(): form = ManyReferenceForms(request.form) refs=[] num_of_refs=0 try: check_for_other_users(current_user.name) refs = model.execute(get_reftemps(), current_user.name) for ref in refs: form.create_reference_form(ref.pubmed_id) num_of_refs = len(refs) except Exception as e: flash(str(e), 'error') return render_template('literature_review.html', ref_list=refs, ref_count=num_of_refs, form=form)
def link_ref(pmid): log_it_info('link_ref', 'BEGIN', str(pmid)) response = "" try: check_for_other_users(current_user.name) log_it('check_for_other_users', 'SUCCESS') #if request.method == "POST": tasks = check_form_validity_and_convert_to_tasks(request.form) log_it('check_form_validity_and_convert_to_tasks', 'SUCCESS', str(tasks)) model.execute(link_paper(pmid, tasks), current_user.name, commit=True) log_it('link_paper', 'SUCCESS') #Link successful summary = model.execute(get_ref_summary(pmid), current_user.name) response = summary log_it_info('link_ref', 'SUCCESS') except Exception as e: response = "Error:<br>" + e.message; log_it_info('link_ref', 'FAILURE') return response
def login(): form = LoginForm(request.form) try: if request.method == "POST" and form.validate(): username = form.username.data.lower() password = form.password.data remember = False check_for_other_users(username) logged_in = login_lit_review_user(username, password, model, remember) if not logged_in: raise LoginException('Login unsuccessful. Reason unknown.') #Login successful. flash("Logged in!", 'login') current_user.login() return redirect(request.args.get("next") or url_for("index")) except Exception as e: flash(e.message, 'error') return render_template("login.html", form=form)