def inhibitor_search_results(search): results = [] search_string = search.data[ 'search'] # search string given the user input data if search_string: if search.data['select'] == 'Inhibitor ChEMBL ID': qry = db_session.query(Inhibitors).filter( Inhibitors.ChEMBL_ID.contains( search_string)) # search for chembl ID that is # same as the search string - use ilike for case sensitive search results = qry.all() elif search.data['select'] == 'Inhibitor Name': qry = db_session.query(Inhibitors).filter( Inhibitors.INN_Name.contains(search_string)) results = qry.all() elif search.data['select'] == 'Targets': qry = db_session.query(Inhibitors).filter( Inhibitors.Targets.contains(search_string)) results = qry.all() if not results: flash('No results found!') return redirect('/Inhibitor') else: # display results return render_template("inhibitor_search_results.html", results=results)
def search_results(search): results = [] search_string = search.data['search'] if search_string: if search.data['select'] == 'Item': qry = db_session.query(Store, Item).filter( Item.id==Store.item_id).filter( Item.name.contains(search_string)) results = [item[0] for item in qry.all()] elif search.data['select'] == 'Store': qry = db_session.query(Store).filter( Store.store_name.contains(search_string)) results = qry.all() elif search.data['select'] == 'Date_to_purchase': qry = db_session.query(Store).filter( Store.date_to_purchase.contains(search_string)) results = qry.all() else: qry = db_session.query(Store) results = qry.all() else: qry = db_session.query(Store) results = qry.all() if not results: flash('No results found!') return redirect('/') else: # display results table = Results(results) table.border = True return render_template('results.html', table=table)
def search_results(search): results = [] search_string = search.data['search'] if search_string: if search.data['select'] == 'Tweets': qry = db_session.query(Tweets).filter( Tweets.id).filter( Tweets.text.contains(search_string)) results = qry.all() elif search.data['select'] == 'Speeches': qry = db_session.query(Speeches).filter( Speeches.text.contains(search_string)) results = qry.all() elif search.data['select'] == 'Interviews': qry = db_session.query(Interviews).filter( Interviews.text.contains(search_string)) results = qry.all() elif search.data['select'] == 'AllAbove': qry = db_session.query(Tweets, Speeches, Interviews).filter( Interviews.text.contains(search_string)) results = qry.all() else: qry = db_session.query(Album) results = qry.all() if not results: flash('No results found!') return redirect('/') else: # display results table = Results(results) table.border = True return render_template('results.html', table=table)
def search_results(search): results = [] search_string = search.data['search'] if search_string: if search.data['select'] == 'Especie': qry = db_session.query(Info, Especie).filter( Especie.id==Info.especie_id).filter( Especie.name.contains(search_string)) results = [item[0] for item in qry.all()] elif search.data['select'] == 'Info': qry = db_session.query(Info).filter( Info.nombre_cadena.contains(search_string)) results = qry.all() elif search.data['select'] == 'Accesion': qry = db_session.query(Info).filter( Info.accesion.contains(search_string)) results = qry.all() else: qry = db_session.query(Info) results = qry.all() else: qry = db_session.query(Info) results = qry.all() if not results: flash('No results found!') return redirect('/') else: # display results table = Results(results) print(results) table.border = True return render_template('results.html', table=table)
def resultats_recherche(recherche): resultats = [] resultats_cherche = recherche.data['recherche'] if resultats_cherche: if recherche.data['selection'] == 'etablissement': qry = db_session.query(Contrevenants).filter( Contrevenants.etablissement.contains(resultats_cherche)) resultats = qry.all() elif recherche.data['selection'] == 'proprietaire': qry = db_session.query(Contrevenants).filter( Contrevenants.proprietaire.contains(resultats_cherche)) resultats = qry.all() elif recherche.data['selection'] == 'rue': qry = db_session.query(Contrevenants).filter( Contrevenants.adresse.contains(resultats_cherche)) resultats = qry.all() else: qry = db_session.query(Contrevenants) resultats = qry.all() else: qry = db_session.query(Contrevenants) resultats = qry.all() if not resultats: flash('Aucun resultat trouve!') return redirect('/') else: # afficher resultats tableau = Resultats(resultats) tableau.border = True return render_template('resultats.html', table=tableau)
def search_results(search): results = [] search_string = search.data['search'] if search_string: if search.data['select'] == 'Artist': qry = db_session.query( Album, Artist).filter(Artist.id == Album.artist_id).filter( Artist.name.contains(search_string)) results = [item[0] for item in qry.all()] elif search.data['select'] == 'Album': qry = db_session.query(Album).filter( Album.title.contains(search_string)) results = qry.all() elif search.data['select'] == 'Publisher': qry = db_session.query(Album).filter( Album.publisher.contains(search_string)) results = qry.all() else: qry = db_session.query(Album) results = qry.all() else: qry = db_session.query(Album) results = qry.all() if not results: flash('No results found!') return redirect('/') else: # display results table = Results(results) table.border = True return render_template('results.html', table=table)
def search_results(search): results = [] search_string = search.data['search'] if search_string: if search.data['select'] == 'Points': qry = db_session.query(Point, ).filter( .id==Point._id).filter( .name.contains(search_string)) results = [item[0] for item in qry.all()] elif search.data['select'] == 'Points': qry = db_session.query(Point).filter( Point.title.contains(search_string)) results = qry.all() else: qry = db_session.query(Point) results = qry.all() else: qry = db_session.query(Point) results = qry.all() if not results: return redirect('/') else: # display results table = Results(results) table.border = True return render_template('results.html', table=table)
def getJSON(courseNum): all_assignments = db_session.query(Assignment).filter_by( class_id=courseNum).all() returnList = [] assignmentsList = [] for assign in all_assignments: assignmentObject = {} assignmentObject['name'] = assign.name assignmentObject['assignment_id'] = assign.id grades = [] gradeQuery = db_session.query(Grade).filter_by( assignment_id=assign.id).order_by(Grade.id.desc()).all() for grade in gradeQuery: gradeObject = {} gradeObject['grade_id'] = grade.id gradeObject['percent'] = grade.grade grades.append(gradeObject) assignmentObject['grades'] = grades returnList.append(assignmentObject) apiDictionary = {} classQuery = db_session.query(Class).filter_by(id=courseNum).first() apiDictionary['course_num'] = courseNum apiDictionary['course_name'] = classQuery.name apiDictionary['professor'] = classQuery.professor apiDictionary['time'] = classQuery.time apiDictionary['assignments'] = returnList return json.dumps(apiDictionary)
def search_results(search): results = [] search_string = search.data['search'] if search_string: if search.data['select'] == 'Version': qry = db_session.query(EnvironmentRequest).filter( EnvironmentRequest.version.contains(search_string)) results = qry.all() elif search.data['select'] == 'Environment Number': qry = db_session.query(EnvironmentRequest).join( Environment).filter(Environment.number == int(search_string)) results = qry.all() else: qry = db_session.query(EnvironmentRequest) results = qry.all() if not results: flash('No results found!') return redirect('/') else: # display results table = Results(results) table.border = True return render_template('results.html', table=table)
def i_search_results(search): results = [] search_string = search.data['search'] if search_string: if search.data['select'] == ' ChEMBL ID ': qry = db_session.query(inhibitor_information).filter( inhibitor_information.chembl_ID.ilike( search_string)) # search for chembl ID that is # same as the search string - use ilike for case sensitive search results = qry.all() elif search.data['select'] == 'GSK Name': qry = db_session.query(inhibitor_information).filter( inhibitor_information.name.ilike(search_string)) results = qry.all() else: qry = db_session.query(inhibitor_information) results = qry.all() if not results: flash('No results found!') return redirect('/Inhibitor') else: # display results return render_template('inhib_results.html', results=results)
def configuration_type(form): k = 0 conf_type = 1 ctr1 = 0 i = 1 q = True while q: qry1 = db_session.query(Configuration).filter(Configuration.id == i) configuration1 = qry1.first() if configuration1 is None: q = False continue ctr2 = 0 a1 = object_as_dict(configuration1) for key in set(a1) & set(form): if a1[key] == form[key]: ctr2+=1 if ctr2 > ctr1: ctr1 = ctr2 conf_type = i i+=1 qry2 = db_session.query(Configuration).filter(Configuration.id == conf_type) configuration1 = qry2.first() return configuration1.artist
def search_results(search): results = [] search_string = search.data['search'] if search_string: if search.data['select'] == 'Academic': qry = db_session.query( Biography, Academic).filter(Academic.id == Biography.academics_id).filter( Academic.name.contains(search_string)) results = [item[0] for item in qry.all()] elif search.data['select'] == 'Biography': qry = db_session.query(Biography).filter( Biography.title.contains(search_string)) results = qry.all() elif search.data['select'] == 'Publisher': qry = db_session.query(Biography).filter( Biography.publisher.contains(search_string)) results = qry.all() else: qry = db_session.query(Biography) results = qry.all() else: qry = db_session.query(Biography) results = qry.all() if not results: flash('No results found!') return redirect('/') else: # display results table = Results(results) table.border = True return render_template('results.html', table=table)
def search_results(search): results = [] search_string = search.data['search'] if search_string: if search.data['select'] == 'Username': qry = db_session.query(Userdata).filter( Userdata.username.contains(search_string)) results = qry.all() elif search.data['select'] == 'User_id': qry = db_session.query(Userdata).filter( Userdata.user_id.contains(search_string)) results = qry.all() else: qry = db_session.query(Userdata) results = qry.all() else: qry = db_session.query(Userdata) results = qry.all() if not results: flash('No results found!') return redirect('/') else: table = Results(results) table.border = True return render_template('results.html', table=table)
def info(id): qry = db_session.query(Album).filter(Album.id==id) album = qry.first() element = object_as_dict(album) results_conf = [] results_conf = db_session.query(Configuration) table1 = table_as_dict_conf(results_conf) table = info_table(table1,element) return render_template('info.html', table=table, element=element)
def Kinase_search_results(search): results = [] search_string = search.data[ 'search'] # search string given the user input data if search_string: if search.data[ 'select'] == 'Kinase Gene Name': # check if protein kinase name was selected qry = db_session.query(Kinase).filter( Kinase.Kinase_Gene_Name.contains(search_string)) results = qry.all() # output all the query results iqry = db_session.query(Kinase, Inhibitors)\ .filter(Inhibitors.Targets.contains(search_string))\ .join(Kinase, Inhibitors.Targets.contains(search_string) == Kinase.Kinase_Gene_Name.contains(search_string)) inhibresults = iqry.all() pqry = db_session.query(Kinase, Phosphosite)\ .filter(Kinase.Kinase_Gene_Name.contains(search_string))\ .join(Phosphosite, Kinase.Kinase_Gene_Name.contains(search_string) == Phosphosite.KINASE_GENE_NAME.contains(search_string)) phosphresults = pqry.all( ) # run a join query to find out kinase substrates elif search.data[ 'select'] == 'Kinase Uniprot ID': # check if uniprot id was selected qry = db_session.query(Kinase).filter( Kinase.UniProt_ID.ilike(search_string)) results = qry.all() iqry = db_session.query(Kinase, Inhibitors)\ .filter(Kinase.UniProt_ID.contains(search_string))\ .join(Inhibitors, Kinase.Kinase_Gene_Name == Inhibitors.Targets) inhibresults = iqry.all() pqry = db_session.query(Kinase, Phosphosite)\ .filter(Kinase.UniProt_ID.contains(search_string))\ .join(Phosphosite, Kinase.Kinase_Gene_Name == Phosphosite.KINASE_GENE_NAME.ilike(search_string)) phosphresults = pqry.all( ) # run a join query to find out kinase substrates elif search.data[ 'select'] == 'Alias Name': # check if alias name was selected #search_string = search_string.upper() kinase = db_session.query(Kinase).filter( Kinase.Alias.contains(search_string)) # query alias name qry = db_session.query(Kinase).filter( Kinase.Alias.contains(search_string)) results = qry.all() # output all the query results iqry = db_session.query(Kinase, Inhibitors)\ .filter(Kinase.Alias.contains(search_string))\ .join(Inhibitors, Kinase.Alias.contains(search_string) == Inhibitors.Targets.contains(search_string)) inhibresults = iqry.all() pqry = db_session.query(Kinase, Phosphosite)\ .filter(Kinase.Alias.contains(search_string))\ .join(Phosphosite, Kinase.Alias.contains(search_string) == Phosphosite.KINASE_GENE_NAME.ilike(search_string)) phosphresults = pqry.all( ) # run a join query to find out kinase substrates if not results: # if no results were found flash('No results found!') #flash the error message return redirect('/kinase') # and return back to kinase search else: return render_template("kinase_search_results.html", results=results, inhibresults=inhibresults, phosphresults=phosphresults)
def fav(): user_id = request.args.get("user")[:5] all_fav = db_session.query(Favorite).all() my_fav_books = [ fav.book for fav in all_fav if int(fav.user) == int(user_id) ] print(my_fav_books) books_list = db_session.query(Book).filter(Book.id.in_( tuple(my_fav_books))).all() return render_template("fav.html", books=books_list)
def index(): total_gain = 0 total_spend = 0 qry_res = db_session.query(Reservation) reservations = qry_res.all() pd = PayDay(start_date, final_date) for reservation in reservations: pd.update(reservation) total_gain += reservation.value pd_Table = pd.get() pd_Table_context = reversed(pd_Table) qry_spe = db_session.query(Spend) spends = qry_spe.all() pm = PayMonth(pd) for spend in spends: pm.update(spend) total_spend += spend.value pm_Table = pm.get() pm_Table_asList = [line for line in pm_Table] pm_Table_context = reversed(pm_Table) # get YEAR-MONTH list as String year_month_List = [] gain_List = [] spend_List = [] balance_List = [] balanceCum_List = [] for i in range(0,len(pm_Table)): s = "%s-%s" % (pm_Table[i][0].year, pm_Table[i][0].strftime('%b')) year_month_List.append(s) gain_List.append(pm_Table[i][6]) spend_List.append(-pm_Table[i][7]) balance_List.append(pm_Table[i][6] - pm_Table[i][7]) if i==0: balanceCum_List.append( balance_List[i]) else: balanceCum_List.append( balanceCum_List[i-1] + balance_List[i]) return render_template('index.html', pd_Table = pd_Table_context, pm_Table = pm_Table_context, total_balance = (total_gain - total_spend), year_month_List = year_month_List, gain_List = gain_List, spend_List = spend_List, balance_List = balance_List, balanceCum_List = balanceCum_List)
def anonymous(): categories = db_session.query(Category).all() # check if url is called with category id category_id = request.args.get("id") books = db_session.query(Book).all() # check if category id is provided in url if category_id is not None: books = [book for book in books if book.category == int(category_id)] # if all passes it is redirected to the actual responce/page return render_template("home.html", data={}, categories=categories, books=books)
def register(): try: if request.method == 'POST': user = User() username = request.form['username'] email = request.form['email'] password = request.form['pass'] confirm_password = request.form['confirm_pass'] qry = db_session.query(User).filter(User.username == username) qry_email = db_session.query(User).filter(User.email == email) qry = qry.first() qry_email = qry_email.first() if qry is not None or qry_email is not None: flash( 'Username/email is already taken, please choose another.') return render_template('register.html') if not validate_email(email): flash("Invalid email address.") return render_template('register.html') if email[-17:] != '@cvdequipment.com': flash('Please enter a valid CVD email address') return render_template('register.html') if password != confirm_password: flash('Passwords do not match.') return render_template('register.html') user.username = username user.email = email user.password = user.hash_password(password) qry = db_session() qry.add(user) qry.commit() flash("Registration Successful") session['logged_in'] = True session['username'] = username user.set_permission_level() return redirect(url_for('index')) except Exception as e: return str(e) return render_template('register.html')
def k_search_results(search): results = [] search_string = search.data[ 'search'] # search string given the user input data if search_string: if search.data[ 'select'] == 'Protein Kinase Name': # check if protein kinase name was selected qry = db_session.query(Kinase_Information).filter( Kinase_Information.kinase.ilike( search_string)) #qry the database for kinase information #use ilike for case sensitive search results = qry.all() # output all the query results iqry = db_session.query(Kinase_Information, inhibitor_information)\ .filter(Kinase_Information.kinase.ilike(search_string))\ .join(inhibitor_information, Kinase_Information.kinase == inhibitor_information.target1) # run a join query to find out inhibitors inhibresults = iqry.all() pqry = db_session.query(Kinase_Information, Kinase_Phosphosite)\ .filter(Kinase_Information.kinase.ilike(search_string))\ .join(Kinase_Phosphosite, Kinase_Information.kinase == Kinase_Phosphosite.gene) phosphresults = pqry.all( ) # run a join query to find out kinase substrates elif search.data[ 'select'] == 'Alias Name': # check if alias name was selected #search_string = search_string.upper() qry = db_session.query(Kinase_Information).filter( Kinase_Information.Alias.contains( search_string)) # query alias names results = qry.all() if not results: # if no results were found.. flash('No results found!') #.. flash the error message return redirect('/kinase') # and return back to kinase search elif search.data[ 'select'] == 'Alias Name': # if the user selected Alias .. return render_template( 'alias.html', results=results) # .. direct them to the alias page else: # display results return render_template( 'kinase_results.html', results=results, inhibresults=inhibresults, phosphresults=phosphresults) # render the kinase results page
def substrateprofile(Substrate): qry = db_session.query(Phosphosite).filter( Phosphosite.PHOSPHO_ID.ilike(Substrate)) results = qry.all() return render_template( 'phosphosite_search.html', results=results) # render the inhibitor results page
def weld(): flash('WELD') qry = db_session.query(Schedule).filter( Schedule.machine_center == 'WELD').filter(Schedule.archived == 0) table = Results(qry) table.border = True return render_template('search.html', table=table)
def delete_req(id): """ Delete the item in the database that matches the specified id in the URL """ qry = db_session.query(EnvironmentRequest).filter( EnvironmentRequest.id == id) req = qry.first() if req: form = EnvironmentRequestForm(formdata=request.form, obj=req) if request.method == 'GET': form.keep_data.data = req.keep_data form.keep_ld.data = req.keep_ld form.backup_db.data = req.backup_db if request.method == 'POST' and form.validate(): # delete the item from the database db_session.delete(req) db_session.commit() flash('Request deleted successfully!') return redirect('/') return render_template('delete_request.html', form=form) else: return 'Error deleting #{id}'.format(id=id)
def inhibprofile(chembl): qry = db_session.query(inhibitor_information).filter( inhibitor_information.chembl_ID.ilike(chembl)) results = qry.all() return render_template( 'inhib_results.html', results=results) # render the inhibitor results page
def optimize(id): search = UserSearchForm(request.form) # item = db_session.query(Item).get(id) item = join_item_seller(db_session).filter(Item.id == id).first() if request.method == 'POST': buyer_name = search.data['search'] buyer = db_session.query(User).\ filter(User.name==buyer_name.lower()).\ filter(User.user_type=='Buyer').first() if buyer: baseline_rates = get_shipment( from_address=f'{item.street}, {item.city}, ' \ f'{item.state}, {item.zip}, {item.country}', to_address=f'{buyer.street}, {buyer.city}, ' \ f'{buyer.state}, {buyer.zip}, {buyer.country}') similar_items = join_item_seller(db_session).filter( Item.product.contains(item.product)).all() results = get_shipping_options(buyer=buyer, items=similar_items) else: flash('Invalid buyer! Please register before placing any orders!') return redirect(f'/buy/{id}') else: baseline_rates = [] similar_items = join_item_seller(db_session).filter( Item.product.contains(item.product)) results = get_shipping_options(buyer=None, items=similar_items) return render_template('optimize.html', results=results, form=search, baseline_rates=baseline_rates)
def protocolo_print(): if request.method == 'GET': id=request.args.get('id', None) formato=request.args.get('formato', None) fid = id.zfill(3) fform = formato[1:] name = fform + fid filename, fname, qry3= gd.generate_doc(formato, id) ps = qry3.plano.split(' ') count = 0 planos = [] for x in ps: if x: ps1 = x.split('Rev._') qry4 = db_session.query(plano).filter(plano.codigo==ps1[0] and plano.rev==ps1[1].rstrip()).first() print(qry4) tmpfile = gd.download(service, qry4.id_google) name1 = name + str(count) + ".pdf" count = count + 1 upload2 = gd.upload_file(service, 'DataBase', tmpfile, name1, 'application/pdf') planos.append(upload2['id']) upload1 = gd.upload_file(service, 'DataBase', filename, fname, 'application/msword') embedLink = upload1['embedLink'] downloadlink = 'https://drive.google.com/uc?id=' + upload1['id'] return render_template('pages/result_protocolo.html',embedLink = embedLink, downloadlink = downloadlink, planos=planos)
def d2v(file): #loading model #flash(file) #for testings redirection d2v_model = gensim.models.doc2vec.Doc2Vec.load('doc2vec.model') inferred_vector=d2v_model.docvecs[int(file)] sims=d2v_model.docvecs.most_similar([inferred_vector],topn=len(d2v_model.docvecs)) #split the sims tuples into tags and scores to fetch the corresponding docs tags, scores = map(list, zip(*sims)) tags=list(map(int,tags)) #cast as ints most_rel=tags[1:11] #getting 10 most related documents #retrieve the 10 most related documents query=db_session.query(Data).filter(or_(Data.file.contains(most_rel[0]), Data.file.contains(most_rel[1]), Data.file.contains(most_rel[2]), Data.file.contains(most_rel[3]), Data.file.contains(most_rel[4]), Data.file.contains(most_rel[5]), Data.file.contains(most_rel[6]), Data.file.contains(most_rel[7]), Data.file.contains(most_rel[8]), Data.file.contains(most_rel[9]))) #query=db_session.query(Data).filter(Data.file.contains(m) for m in most_rel) results=query.all() if not results: #Test to see if the tags were actually generated for the documents tags=list(map(str, tags)) flash(tags[9]) flash('No results found!') return redirect('/') else: table=Doc2VecResults(results) table.border=True return render_template('doc2vecresults.html', table=table)
def getData(): name = request.args.get('q', None) print(name) qry = db_session.query(ubicacion).all() ubica = [x.codigo+' '+x.ubicacion for x in qry] json_str = json.dumps(ubica) return jsonify(json_str)
def planogetData(): name = request.args.get('q', None) print(name) qry = db_session.query(plano).all() planos = [x.codigo+'Rev._'+ x.rev + ' ' for x in qry] json_str = json.dumps(planos) return jsonify(json_str)
def inhib_INN_Name_profile(INN_Name): qry = db_session.query(Inhibitors).filter( Inhibitors.INHIBITOR_ID.ilike(INN_Name)) results = qry.all() return render_template( 'inhibitor_search.html', results=results) # render the inhibitor results page