added pubmed search

This commit is contained in:
Navan Chauhan 2020-08-24 16:02:32 +05:30
parent c9a140900d
commit ae27a5c999
5 changed files with 91 additions and 3 deletions

View File

@ -5,6 +5,9 @@
[![DeepSource](https://static.deepsource.io/deepsource-badge-dark-mini.svg)](https://deepsource.io/gh/navanchauhan/Curie-Web/?ref=repository-badge) [![DeepSource](https://static.deepsource.io/deepsource-badge-dark-mini.svg)](https://deepsource.io/gh/navanchauhan/Curie-Web/?ref=repository-badge)
**Do Not Forget To Change DB Host configuration!**
``` ```
export PATH=$PATH:/home/pi/Desktop/Curie-Web/app/src/scripts export PATH=$PATH:/home/pi/Desktop/Curie-Web/app/src/scripts

View File

@ -36,4 +36,7 @@ class statusForm(FlaskForm):
class generateSMILES(FlaskForm): class generateSMILES(FlaskForm):
n = IntegerField('Number of Molecules to Generate',default=1,validators=[DataRequired()]) n = IntegerField('Number of Molecules to Generate',default=1,validators=[DataRequired()])
#modelSelection = SelectField('Model',choices=[("alpha","Alpha"),("beta","Beta")]) #modelSelection = SelectField('Model',choices=[("alpha","Alpha"),("beta","Beta")])
class PyMedSearch(FlaskForm):
query = StringField('Search Query for PubMed',default="Covid-19",validators=[DataRequired()])

50
app/templates/search.html Normal file
View File

@ -0,0 +1,50 @@
{% extends 'base.html' %}
{% block main %}
<h1>Curie Search</h1>
<p>Search PubMed articles.</p>
<form action="{{ url_for('pubmed') }}" method="post" enctype="multipart/form-data">
{% include 'flash_messages.html' %}
{{ form.csrf_token }}
<div class="form-row">
{{ form.query.label }}
{{ form.query(class="form-control")}}
</div>
<!--<div class="form-row">
{\{ form.modelSelection.label }}
{\{ form.modelSelection(class="form-control")}}
</div>-->
<br>
<div class="form-row">
<button type="submit" class="btn btn-primary">Search</button>
</div>
</form>
{% if result %}
<h3>Search Results</h3>
{% for x in range(result|length) %}
<!--<i>{\{result}}</i>-->
<!--<p>{{result[x]}}</p>-->
<div class="card mb-3">
<div class="row no-gutters">
<div class="col-md-4 text-white bg-dark">
<div class="card-body">
<p class="card-text"><b>DOI: </b><a href="https://doi.org/{{result[x]['doi']}}">{{result[x]['doi']}}</a></p>
<p class="card-text"><b>PubMed ID: </b><a href="https://pubmed.ncbi.nlm.nih.gov/{{result[x]['pubmed_id']}}">{{result[x]['pubmed_id']}}</a></p>
<p class="card-text"><b>Download: </b><a href="https://sci-hub.tw/{{result[x]['doi']}}">Sci-Hub</a></p>
<p class="card-text"><b>Journal: </b>{{result[x]['journal']}}</p>
</div>
</div>
<div class="col-md-8">
<div class="card-body">
<h5 class="card-title">{{result[x]["title"]}}</h5>
<p class="card-text"><b>Abstract: </b>{{result[x]["abstract"]}}</p>
<p class="card-text"><small class="text-muted">Published on {{result[x]['publication_date']}}</small></p>
</div>
</div>
</div>
</div>
{% endfor %}
{% endif %}
{% endblock %}

View File

@ -9,10 +9,13 @@ from flask import render_template, request, flash
from werkzeug.utils import secure_filename from werkzeug.utils import secure_filename
from random import choice, shuffle from random import choice, shuffle
from string import digits, ascii_lowercase from string import digits, ascii_lowercase
from pymed import PubMed
from datetime import datetime
import json
# Note: that when using Flask-WTF we need to import the Form Class that we created # Note: that when using Flask-WTF we need to import the Form Class that we created
# in forms.py # in forms.py
from .forms import MyForm, curieForm, statusForm, generateSMILES from .forms import MyForm, curieForm, statusForm, generateSMILES, PyMedSearch
def gen_word(N, min_N_dig, min_N_low): def gen_word(N, min_N_dig, min_N_low):
choose_from = [digits]*min_N_dig + [ascii_lowercase]*min_N_low choose_from = [digits]*min_N_dig + [ascii_lowercase]*min_N_low
@ -47,6 +50,26 @@ def visualise():
"""Render visualisation page.""" """Render visualisation page."""
return render_template('visualise.html') return render_template('visualise.html')
@app.route('/Search',methods=['GET','POST'])
def pubmed():
"""Query PubMed"""
form = PyMedSearch()
pubmed = PubMed(tool="Curie", email="navanchauhan@gmail.com")
if request.method == 'POST' and form.validate_on_submit():
q = form.query.data
print(form)
print(pubmed)
results = pubmed.query(q,max_results=100)
search = []
for x in results:
search.append(x.toDict())
return render_template('search.html',result=search,form=form)
flash_errors(form)
return render_template('search.html',form=form)
@app.route('/Status',methods=['GET','POST']) @app.route('/Status',methods=['GET','POST'])
def status(): def status():
taskStatusForm = statusForm() taskStatusForm = statusForm()
@ -110,7 +133,7 @@ def wtform():
flash_errors(myform) flash_errors(myform)
return render_template('wtform.html', form=myform) return render_template('wtform.html', form=myform)
tfWorking = -1 tfWorking = 0
if tfWorking == -1: if tfWorking == -1:
try: try:

View File

@ -16,3 +16,12 @@ uvicorn
tensorflow-cpu==2.2.0 tensorflow-cpu==2.2.0
bunch bunch
tqdm tqdm
prettytable
gradio
git+https://github.com/bp-kelley/descriptastorus
pandas_flavor
subword_nmt
wget
lifelines
scikit-plot
pymed