Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add interactive table #22

Merged
merged 13 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions bin/create_interactive_table.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/usr/bin/env python

import argparse

import pandas as pd

# TODO maybe allow comunities to modify
COLUMNS = [
"Expand",
"Galaxy wrapper id",
"Galaxy wrapper version",
"Conda version",
"Conda id",
"Status",
"bio.tool id",
"bio.tool name",
"EDAM operation",
"EDAM topic",
"Description",
"bio.tool description",
"Status",
"Source",
"ToolShed categories",
"ToolShed id",
"Galaxy wrapper owner",
"Galaxy wrapper source",
]


def generate_table(
tsv_path: str,
template_path: str,
output_path: str,
) -> None:
df = pd.read_csv(tsv_path, sep="\t").assign(Expand=lambda df: "").fillna("")
df = df[df["To keep"]].loc[:, COLUMNS].reindex(columns=COLUMNS)
table = df.to_html(border=0, table_id="dataframe", classes=["display", "nowrap"], index=False)

with open(template_path) as template_file:
template = template_file.read()

final_html_output = template.replace("COMMUNITY_TABLE", table)

with open(output_path, "w") as output:
output.write(final_html_output)


if __name__ == "__main__":
parser = argparse.ArgumentParser(
description="Create interactive table from \
TSV file using a template, where COMMUNITY_TABLE is replaced \
by the rendered table"
)
parser.add_argument(
"--table",
"-ta",
required=True,
help="Path to TSV file with tools",
)
parser.add_argument(
"--template",
"-te",
required=True,
help="Path to HTML template",
)
parser.add_argument(
"--output",
"-out",
required=True,
help="Path to HTML output",
)

args = parser.parse_args()
generate_table(args.table, args.template, args.output)
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,9 @@ python bin/extract_galaxy_tools.py \
--filtered_tools 'results/microgalaxy/tools.tsv' \
--categories "data/microgalaxy/categories" \
--exclude "data/microgalaxy/tools_to_exclude" \
--keep "data/microgalaxy/tools_to_keep"
--keep "data/microgalaxy/tools_to_keep"

python bin/create_interactive_table.py \
--table 'results/microgalaxy/tools.tsv' \
--template 'data/interactive_table_template.html' \
--output 'results/microgalaxy/index.html'
58 changes: 58 additions & 0 deletions data/datatable_template.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<script src="https://code.jquery.com/jquery-3.7.0.js"></script>
<script src="https://cdn.datatables.net/1.13.6/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/searchbuilder/1.6.0/js/dataTables.searchBuilder.min.js"></script>
<script src="https://cdn.datatables.net/datetime/1.5.1/js/dataTables.dateTime.min.js"></script>

<script src="https://cdn.datatables.net/responsive/2.5.0/js/dataTables.responsive.min.js"></script>

<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/responsive/2.2.3/css/responsive.dataTables.min.css">

<link rel="stylesheet" href="https://cdn.datatables.net/1.13.6/css/jquery.dataTables.min.css">
<link rel="stylesheet" href="https://cdn.datatables.net/searchbuilder/1.6.0/css/searchBuilder.dataTables.min.css">
<link rel="stylesheet" href="https://cdn.datatables.net/datetime/1.5.1/css/dataTables.dateTime.min.css">

<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" />
<script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>

<style type="text/css">
.tooltip {
font-family: Georgia;
font-size: 18px;
}
.tooltip .tooltip-inner {
background-color: #00FFFF;
color: #000000;
min-width: 400px;
}
</style>

<script>
$(document).ready(function() {
$('#dataframe').DataTable( {
"sScrollX": "100%",
"dom": "Qlfrtip",

responsive: {
details: {
type: 'column'
}
},
"bAutoWidth": false,
columnDefs: [ {
className: 'control',
orderable: false,
targets: [ 0 ],
width: 100,
},
{ type: 'natural', targets: 1 } // allow normal sorting
],

});
});
</script>

<div class="display nowrap" style="width:80%" width="100%">

COMMUNITY_TABLE

</div>
58 changes: 58 additions & 0 deletions data/interactive_table_template.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<script src="https://code.jquery.com/jquery-3.7.0.js"></script>
<script src="https://cdn.datatables.net/1.13.6/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/searchbuilder/1.6.0/js/dataTables.searchBuilder.min.js"></script>
<script src="https://cdn.datatables.net/datetime/1.5.1/js/dataTables.dateTime.min.js"></script>

<script src="https://cdn.datatables.net/responsive/2.5.0/js/dataTables.responsive.min.js"></script>

<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/responsive/2.2.3/css/responsive.dataTables.min.css">

<link rel="stylesheet" href="https://cdn.datatables.net/1.13.6/css/jquery.dataTables.min.css">
<link rel="stylesheet" href="https://cdn.datatables.net/searchbuilder/1.6.0/css/searchBuilder.dataTables.min.css">
<link rel="stylesheet" href="https://cdn.datatables.net/datetime/1.5.1/css/dataTables.dateTime.min.css">

<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" />
<script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>

<style type="text/css">
.tooltip {
font-family: Georgia;
font-size: 18px;
}
.tooltip .tooltip-inner {
background-color: #00FFFF;
color: #000000;
min-width: 400px;
}
</style>

<script>
$(document).ready(function() {
$('#dataframe').DataTable( {
"sScrollX": "100%",
"dom": "Qlfrtip",

responsive: {
details: {
type: 'column'
}
},
"bAutoWidth": false,
columnDefs: [ {
className: 'control',
orderable: false,
targets: [ 0 ],
width: 100,
},
{ type: 'natural', targets: 1 } // allow normal sorting
],

});
});
</script>

<div class="display nowrap" style="width:80%" width="100%">

COMMUNITY_TABLE

</div>
1 change: 1 addition & 0 deletions data/microgalaxy/tools_to_exclude
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ inforna
intarna
kinwalker
locarna
mea
mqc
nastiseq
paralyzer
Expand Down
1 change: 0 additions & 1 deletion data/microgalaxy/tools_to_keep
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ nucleosome_prediction
pfamscan
racon
infernal
mea
rRNA
reago
sortmerna
Expand Down
Loading