Skip to content

Commit

Permalink
adding a page for compound file list
Browse files Browse the repository at this point in the history
  • Loading branch information
mwang87 committed Sep 9, 2019
1 parent a8a55f0 commit d45a251
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 78 deletions.
51 changes: 51 additions & 0 deletions code/templates/compoundfilelist.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
(% extends "layout.html" %)

(% block content %)

<script src="/static/datatables/datatables.min.js" crossorigin="anonymous"></script>
<link rel="stylesheet" href="/static/datatables/datatables.min.css" crossorigin="anonymous">

<div id="app-4" class="container-fluid justify-content-center align-items-center">
<div class="row">
<div class="col-sm"></div>
<div class="col-sm text-center">
<h2>Files For Compound</h2>
</div>
<div class="col-sm"></div>
</div>

<hr>

<div class="table table-striped">
<table id="datatable" class="display" width="100%"></table>
</div>
</div>

<script>

url = "/compoundfilename"

$.ajax({
url: url + window.location.search,
type: "GET",
data: {},
success: function(componentObject) {
return function(response) {
$('#datatable').DataTable( {
data: response,
columns: [
{ data: "filepath" , title: "Filename"}
],
pageLength: 30
} );

}
}(this),
dataType: "json"
});


</script>


(% endblock %)
2 changes: 1 addition & 1 deletion code/templates/compoundslist.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ <h2>Chemicals Annotated via GNPS</h2>
"targets": 2,
"data": null,
"render": function ( data, type, row, meta ) {
return '<a class="btn btn-warning btn-block" target="_blank" href="/compoundfilename?compoundname='+row['compound']+'">View Files</a>';
return '<a class="btn btn-warning btn-block" target="_blank" href="/compoundfilenamelist?compoundname='+row['compound']+'">View Files</a>';
}},
{
"targets": 3,
Expand Down
67 changes: 0 additions & 67 deletions code/templates/explorerdashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,61 +23,6 @@ <h2>Chemicals Annotated via GNPS</h2>
<div class="table table-striped">
<table id="datatable" class="display" width="100%"></table>
</div>

<!-- <div>
<table class="table table-sm table-striped">
<thead>
<tr>
<th>
Chemical
<i class="fa fa-sort-alpha-desc" aria-hidden="true" style="cursor: pointer;" onclick="sortdesccolumn('compound')"></i>
<i class="fa fa-sort-alpha-asc" aria-hidden="true" style="cursor: pointer;" onclick="sortasccolumn('compound')"></i>
</th>
<th>
# Files in G1 ( % Files)
<i class="fa fa-sort-numeric-desc" aria-hidden="true" style="cursor: pointer;" onclick="sortdesccolumn('count1')"></i>
<i class="fa fa-sort-numeric-asc" aria-hidden="true" style="cursor: pointer;" onclick="sortasccolumn('count1')"></i>
</th>
<th>
# Files in G2 ( % Files)
<i class="fa fa-sort-numeric-desc" aria-hidden="true" style="cursor: pointer;" onclick="sortdesccolumn('count2')"></i>
<i class="fa fa-sort-numeric-asc" aria-hidden="true" style="cursor: pointer;" onclick="sortasccolumn('count2')"></i>
</th>
<th>
# Files in G3 ( % Files)
<i class="fa fa-sort-numeric-desc" aria-hidden="true" style="cursor: pointer;" onclick="sortdesccolumn('count3')"></i>
<i class="fa fa-sort-numeric-asc" aria-hidden="true" style="cursor: pointer;" onclick="sortasccolumn('count3')"></i>
</th>
<th>
# Files in G4 ( % Files)
<i class="fa fa-sort-numeric-desc" aria-hidden="true" style="cursor: pointer;" onclick="sortdesccolumn('count4')"></i>
<i class="fa fa-sort-numeric-asc" aria-hidden="true" style="cursor: pointer;" onclick="sortasccolumn('count4')"></i>
</th>
<th>
# Files in G5 ( % Files)
<i class="fa fa-sort-numeric-desc" aria-hidden="true" style="cursor: pointer;" onclick="sortdesccolumn('count5')"></i>
<i class="fa fa-sort-numeric-asc" aria-hidden="true" style="cursor: pointer;" onclick="sortasccolumn('count5')"></i>
</th>
<th>
# Files in G6 ( % Files)
<i class="fa fa-sort-numeric-desc" aria-hidden="true" style="cursor: pointer;" onclick="sortdesccolumn('count6')"></i>
<i class="fa fa-sort-numeric-asc" aria-hidden="true" style="cursor: pointer;" onclick="sortasccolumn('count6')"></i>
</th>
</tr>
</thead>
<tbody>
<tr v-for="compoundobject in compoundlist">
<td>{{compoundobject.compound}}</td>
<td>{{compoundobject.count1}} ({{compoundobject.count1_norm}}%)</td>
<td>{{compoundobject.count2}} ({{compoundobject.count2_norm}}%)</td>
<td>{{compoundobject.count3}} ({{compoundobject.count3_norm}}%)</td>
<td>{{compoundobject.count4}} ({{compoundobject.count4_norm}}%)</td>
<td>{{compoundobject.count5}} ({{compoundobject.count5_norm}}%)</td>
<td>{{compoundobject.count6}} ({{compoundobject.count6_norm}}%)</td>
</tr>
</tbody>
</table>
</div> -->
</div>

<script>
Expand Down Expand Up @@ -131,18 +76,6 @@ <h2>Chemicals Annotated via GNPS</h2>
{ data: "count6_norm" , title: "% in G6"}
],
pageLength: 30,
// columnDefs: [ {
// "targets": 2,
// "data": null,
// "render": function ( data, type, row, meta ) {
// return '<a class="btn btn-warning btn-block" target="_blank" href="/compoundfilename?compoundname='+row['compound']+'">View Files</a>';
// }},
// {
// "targets": 3,
// "data": null,
// "render": function ( data, type, row, meta ) {
// return '<a class="btn btn-warning btn-block" target="_blank" href="/compoundenrichmentdashboard?compound='+row['compound']+'">View Associations</a>';
// }}]
} );

}
Expand Down
21 changes: 11 additions & 10 deletions code/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,11 +561,14 @@ def globalmultivariate():
def comparemultivariate():
return render_template('comparemultivariate.html')


@app.route('/compoundslist', methods=['GET'])
def compoundslist():
return render_template('compoundslist.html')

@app.route('/compoundfilenamelist', methods=['GET'])
def compoundfilenamelist():
return render_template('compoundfilelist.html')

@app.route('/compoundenrichmentdashboard', methods=['GET'])
def compoundenrichmentview():
return render_template('compoundenrichment.html')
Expand Down Expand Up @@ -696,15 +699,14 @@ def displayglobalmultivariate():

@app.route('/processcomparemultivariate', methods=['GET'])
def processcomparemultivariate():
# if not os.path.isfile(config.PATH_TO_GLOBAL_OCCURRENCES):
# print("Missing Global Data")
# return abort(500)

# #Making sure we calculate global datata
# if not os.path.isfile(config.PATH_TO_COMPONENT_MATRIX):
# print("Retrieving Global Identifications")
#Making sure we calculate global datata
if not os.path.isfile(config.PATH_TO_COMPONENT_MATRIX):
if not os.path.isfile(config.PATH_TO_GLOBAL_OCCURRENCES):
print("Missing Global Data")
return abort(500)

# redu_pca.calculate_master_projection(config.PATH_TO_GLOBAL_OCCURRENCES)
print("Missing Global PCA Calculation, Calculating")
redu_pca.calculate_master_projection(config.PATH_TO_GLOBAL_OCCURRENCES)

#Making sure we grab down user query
task_id = request.args['task']
Expand Down Expand Up @@ -739,7 +741,6 @@ def processcomparemultivariate():
inner_df.to_csv(new_analysis_filename, sep="\t", index=False)
elif task_type == "FEATURE-BASED-MOLECULAR-NETWORKING":
quantification_url = "https://gnps.ucsd.edu/ProteoSAFe/DownloadResultFile?task={}&block=main&file=quantification_table_reformatted/".format(task_id)
#quantification_url = "https://gnps.ucsd.edu/ProteoSAFe/DownloadResultFile?task={}&block=main&file=quantification_table/".format(task_id)
quantification_df = pd.read_csv(quantification_url, sep=",")

quantification_records = quantification_df.to_dict(orient="records")
Expand Down

0 comments on commit d45a251

Please sign in to comment.