From 610aaaf543fbc06ed3173011750b48001dc5003c Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Tue, 11 Dec 2012 12:22:52 +0100 Subject: working version with proxy --- views/compound.haml | 84 ++++++++++++++++---------------------------- views/layout.haml | 22 +++++++++++- views/neighbors.haml | 68 +++++++++++++++++------------------ views/nontargets.haml | 3 -- views/not_found.haml | 5 +-- views/predicted_assays.haml | 6 ++-- views/predicted_targets.haml | 8 ++--- 7 files changed, 93 insertions(+), 103 deletions(-) delete mode 100644 views/nontargets.haml (limited to 'views') diff --git a/views/compound.haml b/views/compound.haml index de4cf77..9509ce0 100644 --- a/views/compound.haml +++ b/views/compound.haml @@ -1,65 +1,41 @@ -%script{:type => "text/javascript", :src => "sorttable.js"} -%table{:class => "sortable"} - %tr - %th Structure - %th Targets (experimental data) - %th Other active assays (experimental data) +:javascript + $(document).ready(function() { + /*/ prefetch predictions in order to fill cache in background + $.ajax({ + url: "/cid/#{@compound.cid}/predicted_targets", + cache: true, + dataType: "html" + }); + */ + hide("Measured gene/protein targets",".targets", "/cid/#{@compound.cid}/targets"); + hide("Other active assays",".active_assays", "/cid/#{@compound.cid}/other_active_assays"); + hide("Measured gene/protein non-targets",".nontargets", "/cid/#{@compound.cid}/nontargets"); + hide("Other inactive assays",".inactive_assays", "/cid/#{@compound.cid}/other_inactive_assays"); + hide("Read across gene/protein targets",".predicted_targets", "/cid/#{@compound.cid}/predicted_targets"); + hide("Other active read across assays",".predicted_active_assays", "/cid/#{@compound.cid}/other_predicted_active_assays"); + hide("Read across gene/protein non-targets",".predicted_nontargets", "/cid/#{@compound.cid}/predicted_nontargets"); + hide("Other inactive read across assays",".predicted_inactive_assays", "/cid/#{@compound.cid}/other_predicted_inactive_assays"); + hide("Similar compounds",".neighbors", "/cid/#{@compound.cid}/neighbors"); + }); + +%table + %colgroup + %col{:width => "25%"} + %col{:width => "37%"} + %col{:width => "37%"} %tr %td{:valign => "top"} - %br= session[:compound].name - %img{:src => session[:compound].image_uri} + %br= @compound.name + %img{:src => @compound.image_uri} %td{:valign => "top"} .targets - :javascript - display(".targets", "/cid/#{session[:compound].cid}/targets"); - %td{:valign => "top"} - .active_assays - :javascript - display(".active_assays", "/cid/#{session[:compound].cid}/other_active_assays"); - %tr - %th - %th Targets (predicted) - %th Other active assays (predicted) - %tr - %td - %td{:valign => "top"} .predicted_targets - :javascript - display(".predicted_targets", "/cid/#{session[:compound].cid}/predicted_targets"); - %td{:valign => "top"} - .predicted_active_assays - :javascript - display(".predicted_active_assays", "/cid/#{session[:compound].cid}/other_predicted_active_assays"); - %tr - %th - %th Non-targets (experimental data) - %th Other inactive assays (experimental data) - %tr - %td - %td{:valign => "top"} .nontargets - :javascript - display(".nontargets", "/cid/#{session[:compound].cid}/nontargets"); - %td{:valign => "top"} - .inactive_assays - :javascript - display(".inactive_assays", "/cid/#{session[:compound].cid}/other_inactive_assays"); - %tr - %th - %th Non-targets (predicted) - %th Other inactive assays (predicted) - %tr - %td - %td{:valign => "top"} .predicted_nontargets - :javascript - display(".predicted_nontargets", "/cid/#{session[:compound].cid}/predicted_nontargets"); %td{:valign => "top"} + .active_assays + .predicted_active_assays + .inactive_assays .predicted_inactive_assays - :javascript - display(".predicted_inactive_assays", "/cid/#{session[:compound].cid}/other_predicted_inactive_assays"); -%h2 Read across compounds .neighbors -:javascript - display(".neighbors", "/cid/#{session[:compound].cid}/neighbors"); diff --git a/views/layout.haml b/views/layout.haml index 40c6747..1abb7a8 100644 --- a/views/layout.haml +++ b/views/layout.haml @@ -3,6 +3,26 @@ %head %script{:type => "text/javascript", :src => "jquery-1.8.2.js"} :javascript + function show(title,element,uri) { + $(element).html("

"+title+"

"+"\"Searching"); + $.ajax({ + cache: true, + url: uri, + success: function(data){ + data = "

"+title+"

"+"" + data; + $(element).html(data); + }, + error: function(data,textStatus,message){ + $(element).html(message); + } + }); + } + + function hide(title,element,uri) { + data = "

"+title+"

"+""; + $(element).html(data); + } + function display(element,uri) { $(element).html("\"Searching"); $.ajax({ @@ -18,7 +38,7 @@ } %body - %h1 adverse outcome pathways + %h1 AOP read across %form{:name => "form", :action => '/search', :method => "GET"} %fieldset %label{:for => 'name'} Compound name: diff --git a/views/neighbors.haml b/views/neighbors.haml index 7b9c79d..09dc6cf 100644 --- a/views/neighbors.haml +++ b/views/neighbors.haml @@ -1,37 +1,33 @@ %table - - session[:compound].neighbors[0..10].each do |compound| - %tr - %th Structure - %th Similarity - %th Targets (experimental data) - %th Other active assays (experimental data) - - %tr - %td{:valign => "top"} - %br= compound.name - %img{:src => compound.image_uri} - %td{:id => "sim#{compound.cid}", :valign => "top"} - :javascript - display("#sim#{compound.cid}", "/cid/#{session[:compound].cid}/cosine/#{compound.cid}"); - %td{:id => "targets#{compound.cid}", :valign => "top"} - :javascript - display("#targets#{compound.cid}", "/cid/#{compound.cid}/targets"); - %td{:id => "assays#{compound.cid}", :valign => "top"} - :javascript - display("#assays#{compound.cid}", "/cid/#{compound.cid}/other_active_assays"); - - %tr - %th - %th - %th Non-targets (experimental data) - %th Other inactive assays (experimental data) - - %tr - %td - %td - %td{:id => "targets#{compound.cid}", :valign => "top"} - :javascript - display("#targets#{compound.cid}", "/cid/#{compound.cid}/nontargets"); - %td{:id => "assays#{compound.cid}", :valign => "top"} - :javascript - display("#assays#{compound.cid}", "/cid/#{compound.cid}/other_inactive_assays"); + %colgroup + %col{:width => "25%"} + %col{:width => "37%"} + %col{:width => "37%"} + - idx = 0 + - while idx < 10 + - @compound.neighbors.each do |n| + - unless n.assays.empty? + %tr + %td{:valign => "top"} + %br + = n.name + ( + = @compound.cosine(n).round(3) + ) + %img{:src => n.image_uri} + %td{:valign => "top"} + %p{:id => "targets#{n.cid}"} + :javascript + hide("Measured gene/protein targets","#targets#{n.cid}", "/cid/#{n.cid}/targets"); + %p{:id => "nontargets#{n.cid}"} + :javascript + hide("Measured gene/protein non-targets","#nontargets#{n.cid}", "/cid/#{n.cid}/nontargets"); + %td{:valign => "top"} + %p{:id => "assays#{n.cid}"} + :javascript + hide("Other active assays","#assays#{n.cid}", "/cid/#{n.cid}/other_active_assays"); + %p{:id => "inactive_assays#{n.cid}"} + :javascript + hide("Other inactive assays","#inactive_assays#{n.cid}", "/cid/#{n.cid}/other_inactive_assays"); + + - idx += 1 diff --git a/views/nontargets.haml b/views/nontargets.haml deleted file mode 100644 index 154b5da..0000000 --- a/views/nontargets.haml +++ /dev/null @@ -1,3 +0,0 @@ -%pre - =# session[:compound].non_targets.to_yaml - diff --git a/views/not_found.haml b/views/not_found.haml index 5903559..6b3485f 100644 --- a/views/not_found.haml +++ b/views/not_found.haml @@ -1,2 +1,3 @@ -No compound found that matches name -= "\"#{params[:name]}\"." +Could not find a compound with name += "\"#{params[:name]}\"" +in PubChem. diff --git a/views/predicted_assays.haml b/views/predicted_assays.haml index 991c267..299abf4 100644 --- a/views/predicted_assays.haml +++ b/views/predicted_assays.haml @@ -1,5 +1,5 @@ %dl - - @assays.sort{|a,b| [b[:p_active],b[:p_inactive]].max <=> [a[:p_active],a[:p_inactive]].max}.each do |assay| + - @assays.sort{|a,b| [b["p_active"],b["p_inactive"]].max <=> [a["p_active"],a["p_inactive"]].max}.each do |assay| %dt %a{:href => "http://pubchem.ncbi.nlm.nih.gov/assay/assay.cgi?aid=#{assay["AID"]}"} #{assay['Assay Name']} %dd @@ -7,7 +7,7 @@ %a{:href => "http://pubchem.ncbi.nlm.nih.gov/assay/assay.cgi?aid=#{assay["AID"]}"} #{assay['AID']} %dd p_active: - = assay[:p_active].to_f.round(3) + = assay["p_active"].to_f.round(3) %dd p_inactive: - = assay[:p_inactive].to_f.round(3) + = assay["p_inactive"].to_f.round(3) diff --git a/views/predicted_targets.haml b/views/predicted_targets.haml index 523a217..97c68c4 100644 --- a/views/predicted_targets.haml +++ b/views/predicted_targets.haml @@ -1,15 +1,15 @@ %dl - - @assays.sort{|a,b| [b[:p_active],b[:p_inactive]].max <=> [a[:p_active],a[:p_inactive]].max}.each do |assay| + - @assays.sort{|a,b| [b["p_active"],b["p_inactive"]].max <=> [a["p_active"],a["p_inactive"]].max}.each do |assay| %dt= assay["Target Name"] %dd Target GeneID: = assay["Target GI"] %dd Assay ID: - %a{:href => "http://pubchem.ncbi.nlm.nih.gov/assay/assay.cgi?aid=#{assay["AID"]}"} #{assay['AID']} + %a{:href => "http://pubchem.ncbi.nlm.nih.gov/assay/assay.cgi?aid=#{assay["AID"]}"} #{assay["AID"]} %dd p_active: - = assay[:p_active].to_f.round(3) + = assay["p_active"].to_f.round(3) %dd p_inactive: - = assay[:p_inactive].to_f.round(3) + = assay["p_inactive"].to_f.round(3) -- cgit v1.2.3