This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
emp = Employees('stephen', 'bournemouth', 30) | |
for key, value in emp.__dict__.items(): | |
print('{} = {}'.format(key, value)) | |
emp('Simon') | |
print('#####################################') | |
for key, value in emp.__dict__.items(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Employees(object): | |
def __init__(self, name, location, age): | |
self._name = name | |
self._age = age | |
self._location = location | |
# attribute re-assignment | |
def __call__(self, *args, **employee_info): | |
if hasattr(self, '_name') and len(args) == 1: | |
self._name = args[0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Employees(object): | |
def __init__(self, name, location, age): | |
self._name = name | |
self._age = age | |
self._location = location | |
emp = Employees('stephen', 'bournemouth', 30) | |
for key, value in emp.__dict__.items(): | |
print('{} = {}'.format(key, value)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
...if block above... | |
--> | |
{% else %} | |
<h1>Explore BacGenomePipeline</h1> | |
{% with messages = get_flashed_messages(category_filter=['success']) %} | |
{% if messages %} | |
{% for message in messages %} | |
<h5 class="col-lg-4 col-sm-12 alert alert-success" role="alert" >{{message}}</h5> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@app.route('/logout') | |
@login_required | |
def logout(): | |
logout_user() | |
flash('You have successfully logged out', category='success') | |
session['username'] = None | |
return redirect(url_for('landing_page')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="container"> | |
<div class="carousel-caption text-start"> | |
{% if active_user %} | |
<h1>Welcome {{ active_user }}</h1> | |
<h1>Explore BacGenomePipeline</h1> | |
<p>Raw reads to annotated bacterial Genome</p> | |
{% else %} | |
<h1>Explore BacGenomePipeline</h1> | |
{% with messages = get_flashed_messages(category_filter=['success']) %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@app.route('/', methods=['GET', 'POST']) | |
def landing_page(): | |
try: | |
active_user = session['username'] | |
active_user = re.findall('[A-Z][^A-Z]*', active_user) | |
active_user = ' '.join(active_user) | |
return render_template('landing_page.html', active_user=active_user) | |
except (KeyError, TypeError): | |
return render_template('landing_page.html') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@app.route('/login', methods=['POST', 'GET']) | |
def login(): | |
form = LoginForm() | |
if form.validate_on_submit(): | |
user = User.query.filter_by(email=form.email.data).first() | |
if user is None: | |
flash('Please register to gain access', category='danger') | |
return redirect(url_for('register')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fig = px.bar(plot_df, x='Provider County', y="Observed Prescribing Rate per 100 Visits", color="Provider County", | |
animation_frame="Year", animation_group="Provider County", range_y=[3, 70], | |
title='Antibiotic Prescribing rates in US counties') | |
fig.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
keys = [i for i in range(65)] | |
all_dataframes = {} | |
for i, county in zip(keys, df['Provider County'].unique()): | |
df2 = df[df['Provider County'] == county].sort_values('Year', ascending=True) | |
all_dataframes[i] = df2 | |
master_df = [] | |
for i in all_dataframes: | |
master_df.append(all_dataframes[i]) |