Skip to content

Commit

Permalink
Note/dev (#6)
Browse files Browse the repository at this point in the history
Update Sonar to the latest version
Run pre-commit to FIX python code format
Add more examples in example.py
  • Loading branch information
silenus092 authored Dec 16, 2022
1 parent ee6e064 commit 9e2ec74
Show file tree
Hide file tree
Showing 27 changed files with 2,116 additions and 560 deletions.
77 changes: 52 additions & 25 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,33 @@
app = Dash(__name__, use_pages=True)
app.layout = html.Div(
[
html.H1("MonkeyPox Radar", style={'display':'inline-block'}),

html.Img(src=r'assets/hpi_logo.png',alt='Img_HPI', style={'float':'right', 'height':'15%', 'width':'15%'}),
html.Img(src=r'assets/rki_logo.png',alt='Img_RKI', style={'float':'right', 'height':'15%', 'width':'15%'}),
html.Img(src=r'assets/DAKI-FWS_logo.png',alt='Img_DAKI-FWS', style={'float':'right', 'height':'15%', 'width':'15%'}),

html.H1("MonkeyPox Radar", style={"display": "inline-block"}),
html.Img(
src=r"assets/hpi_logo.png",
alt="Img_HPI",
style={"float": "right", "height": "15%", "width": "15%"},
),
html.Img(
src=r"assets/rki_logo.png",
alt="Img_RKI",
style={"float": "right", "height": "15%", "width": "15%"},
),
html.Img(
src=r"assets/DAKI-FWS_logo.png",
alt="Img_DAKI-FWS",
style={"float": "right", "height": "15%", "width": "15%"},
),
html.Div("A genomic surveiillance dashboard for MonkeyPox."),
html.Br(),
html.Div(
[
html.Div(
dcc.Link(
html.A(f"{page['name']}"), href=page["relative_path"], style={'color':'black', 'display':'inline-block'}
html.A(f"{page['name']}"),
href=page["relative_path"],
style={"color": "black", "display": "inline-block"},
)
#f"{page['name']}", href=page["relative_path"]
# f"{page['name']}", href=page["relative_path"]
)
for page in dash.page_registry.values()
]
Expand All @@ -31,24 +43,39 @@
html.Hr(),
html.Br(),
# style={'height':'99999999px;', 'width':'100%', 'bottom':'0', 'left':'0', 'position':'absolute'}
html.Footer([
html.A("About MPXRadar", href="About", style={'color':'black', 'display':'inline-block'}),
html.Div(children="Supported by:", style={'float':'right', "margin-right": "250px"}),
html.Br(),
html.A("Contact Us", href="Contact", style={'color':'black'}),
html.Br(),
html.A("Imprint", href="Home", style={'color':'black'}),
html.Br(),
html.A("App:", href="Tool", style={'color':'black'}),



html.Img(src=r'assets/denbi_cloud_logo.png',alt='Img_RKI', style={'float':'right', 'height':'15%', 'width':'15%'}),
html.Div(children="on the basis of a decision"),
html.Div(children="by the German Bundestag"),
html.Img(src=r'assets/Bundesministerium_für_Wirtschaft_und_Energie_Logo.svg.png',alt='Img_RKI', style={'float':'right', 'height':'15%', 'width':'15%'}),]),
html.Footer(
[
html.A(
"About MPXRadar",
href="About",
style={"color": "black", "display": "inline-block"},
),
html.Div(
children="Supported by:",
style={"float": "right", "margin-right": "250px"},
),
html.Br(),
html.A("Contact Us", href="Contact", style={"color": "black"}),
html.Br(),
html.A("Imprint", href="Home", style={"color": "black"}),
html.Br(),
html.A("App:", href="Tool", style={"color": "black"}),
html.Img(
src=r"assets/denbi_cloud_logo.png",
alt="Img_RKI",
style={"float": "right", "height": "15%", "width": "15%"},
),
html.Div(children="on the basis of a decision"),
html.Div(children="by the German Bundestag"),
html.Img(
src=r"assets/Bundesministerium_für_Wirtschaft_und_Energie_Logo.svg.png",
alt="Img_RKI",
style={"float": "right", "height": "15%", "width": "15%"},
),
]
),
]
)

if __name__ == "__main__":
app.run_server(debug=True, host="0.0.0.0")
app.run_server(debug=True, host="0.0.0.0")
2 changes: 1 addition & 1 deletion assets/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
width: 100%;
max-width: 400px;
height: auto;
}
}
130 changes: 127 additions & 3 deletions example.app.py → example_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@
from dash import State
import dash_bootstrap_components as dbc
from dotenv import load_dotenv
import pandas as pd

from pages.app_controller import get_all_references
from pages.app_controller import get_freq_mutation
from pages.app_controller import get_value_by_reference
from pages.app_controller import match_controller
from pages.app_controller import sonarBasicsChild
from pages.libs.mpxsonar.src.mpxsonar.sonar import parse_args
Expand All @@ -20,6 +23,53 @@
# stylesheet with the .dbc class
dbc_css = "https://cdn.jsdelivr.net/gh/AnnMarieW/dash-bootstrap-templates/dbc.min.css"
app = Dash(__name__, external_stylesheets=[dbc.themes.BOOTSTRAP, dbc_css])
df = pd.DataFrame(
{
"First Name": ["Arthur", "Ford", "Zaphod", "Trillian"],
"Last Name": ["Dent", "Prefect", "Beeblebrox", "Astra"],
}
)
# preload
dat_checkbox_list_of_dict = get_all_references()


tool_checkbox_cards = html.Div(
[
dbc.Card(
[
dbc.CardBody(
[
dbc.CardHeader("FILTER"),
dbc.Row(
[
html.H3("Reference", className="card-title"),
dbc.Col(
[
dcc.Checklist(
id="reference-selection",
options=dat_checkbox_list_of_dict,
labelStyle={"display": "block"},
style={
"height": 100,
"width": 200,
"overflow": "auto",
},
)
]
),
dbc.Spinner(html.Div(id="loading-output")),
html.Div(id="display-selected-values"),
html.Hr(),
html.Div(id="table1-results"),
]
),
]
),
]
),
]
)

custom_cmd_cards = html.Div(
[
dbc.Card(
Expand Down Expand Up @@ -113,7 +163,7 @@
"1.The output will be showed in the below section."
),
html.Ul(
"2. Available reference: NC_063383.1, NC_003310.1, ON563414.3, MN648051.1, MT903344.1, ON585033.1, and ON568298.1 "
"2. Available reference: NC_063383.1, ON563414.3 and MT903344.1"
),
],
title="Note>",
Expand All @@ -131,10 +181,32 @@
id="cmd-1",
),
dbc.Badge(
"match --profile del:1-6",
"match --profile del:1-60",
color="white",
text_color="primary",
className="border me-1",
id="cmd-3",
),
dbc.Badge(
"match --profile ^C162331T",
color="white",
text_color="primary",
className="border me-1",
id="cmd-4",
),
dbc.Badge(
"match --profile OPG188:L246F --profile MPXV-UK_P2-164:L246F ",
color="white",
text_color="primary",
className="border me-1",
id="cmd-5",
),
dbc.Badge(
"match --profile A151461C del:=1-=6",
color="white",
text_color="primary",
className="border me-1",
id="cmd-8",
),
dbc.Badge(
"match --LENGTH >197120 <197200",
Expand All @@ -148,6 +220,7 @@
color="white",
text_color="primary",
className="border me-1",
id="cmd-9",
),
dbc.Badge(
"list-prop",
Expand All @@ -168,6 +241,30 @@
"List all properties",
target="cmd-7",
),
dbc.Tooltip(
"Select all samples that have or in range 1-60 deletion mutation (e.g., del:1-60, del:1-6, del:11-20)",
target="cmd-3",
),
dbc.Tooltip(
"Select all samples except samples contain C162331T mutation (^ = exclude)",
target="cmd-4",
),
dbc.Tooltip(
"Combine with 'OR'; for example, get all samples that have mutation at 'OPG188:L246F' OR 'MPXV-UK_P2-164:L246F' (format, GENE/TAG:protien mutation)",
target="cmd-5",
),
dbc.Tooltip(
"Get all samples ",
target="cmd-6",
),
dbc.Tooltip(
"'AND' operation; for example, get all samples that have mutation at A151461C and exact 1-6 deletion",
target="cmd-8",
),
dbc.Tooltip(
"Get sample by name",
target="cmd-9",
),
],
title="Example commands...",
),
Expand Down Expand Up @@ -209,6 +306,10 @@
style_data={
"whiteSpace": "normal",
"height": "auto",
# all three widths are needed
"minWidth": "300px",
"width": "300px",
"maxWidth": "300px",
},
style_table={"overflowX": "auto"},
export_format="csv",
Expand All @@ -227,7 +328,7 @@

app.layout = dbc.Container(
[
dbc.Row([]),
dbc.Row([tool_checkbox_cards]),
html.Hr(),
dbc.Row(
[
Expand All @@ -239,6 +340,29 @@
)


@app.callback(
Output("loading-output", "children"),
Output("display-selected-values", "children"),
Output("table1-results", "children"),
Input(component_id="reference-selection", component_property="value"),
)
def checkbox(checked_value):
output_df = ""
print(checked_value)
if len(checked_value) == 0:
return "", "", output_df
else:
output_df = get_value_by_reference(checked_value)
print(len(output_df))
return (
"",
"{}".format(checked_value),
dbc.Table.from_dataframe(
output_df[0:5], striped=True, bordered=True, hover=True
),
)


@app.callback(
Output(component_id="my-command", component_property="children"),
Input(component_id="my-input", component_property="value"),
Expand Down
Empty file added mpx-project.ini
Empty file.
Loading

0 comments on commit 9e2ec74

Please sign in to comment.