summaryrefslogtreecommitdiff
path: root/views/neighbors.haml
blob: 45a3642e573e4595455e81800b8a82c6db2bbd6e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/ @@prediction_models and @@predictions defined in POST request '/predict'
/ unpacks multi prediction array ;
/ prepare it for neighbors ;
/ align single prediction to endpoint ;
/ display preordered in table view ;

.results{:style=>"display:none"}
  - count_m = 0
  / tabs div ;
  #tabs
    %ul
      / each endpoint becomes a tab head ;
      - @prediction_models.each do |m|
        - count_m += 1
        - m_title = m.title.split("_").last(2)[0]
        %li
          %a{:href => "#results_#{count_m}", :id => "link#{m_title}"}
            = m_title
    - count_rs = 0
    / unpack to single arrays
    - @predictions.each do |pa|
      / pass model type for significant fragments view
      - @type = @model_type[count_rs]
      - count_rs += 1
      #results{:id=>"#{count_rs}"}
        - pa.each do |p|
          / prepare dataset for neighbors table ;
          / delete first array which contains prediction ;
          / following arrays are the neighbor predictions ;
          - @model_uri = p.metadata[RDF::OT.hasSource][0]
          - p.data_entries.shift
          - p.compounds.shift
          
          / call the tablesorter plugin ;
          / presort by similarity ;
          :javascript
            $(document).ready(function(){
              $("table##{count_rs}").tablesorter({
                //debug: true,
                //widgets: ['zebra'],
                headers: {0: {sorter: false}, 3: {sorter: false}},
                sortList: [[2,1]]
              });
            });
          - $logger.debug "neighbors compounds:\t#{p.data_entries[0]}\n"
          - if p.data_entries[0][2] != nil && p.data_entries[0].size != 3
            %h2= "Neighbors: "
            %table{:id=>"#{count_rs}", :class=>"tablesorter", :cellspacing=>"1"}
              %thead
                %tr
                  %th
                    Compound
                  %th
                    %b Measured Activity
                    / title must be empty for tooltip
                    %a{:href=>"#", :title=>"", :id=>"measured_activity"}
                      %img{:src=>"/images/info_white.png"}
                    .tooltip{:style=>"font-weight: normal; font-size: 1em; text-align: left;"}
                      %dt
                        Measured Activity
                      %dd
                        Experimental result(s) from the training dataset.
                  %th
                    %b Similarity
                    / title must be empty for tooltip
                    %a{:href=>"#", :title=>"", :id=>"similarity"}
                      %img{:src=>"/images/info_white.png"}
                    .tooltip{:style=>"font-weight: normal; font-size: 1em; text-align: left;"}
                      %dt
                        Similarity
                      %dd
                        %code{:style=>"font-size:x-large;"} lazar 
                        calculates 
                        %em
                          activity specific 
                        similarities based on the presence of statistically significant fragments.
                        This procedure will
                        %ul
                          %li consider only those parts of a chemical structure that are relevant 
                          for a particular endpoint
                          %li ignore inert parts of the structure
                          %li lead to different similarities, depending on the toxic endpoint
                          Similarities of 1 may be encountered even for structurally dissimilar 
                          compounds, because inert parts are ignored.
                  %th
                    Supporting information
              -#%tbody
              - count = 0
              - p.compounds.each do |neighbor_compound|
                / prevent conversion of nil
                - c = p.data_entries[count][2] != nil ? p.data_entries[count][2] : '' 
                - case c
                - when /(false|true|inactive|active)/i
                  - c = c
                - else
                  /- c = Array.new
                  - c = p.data_entries[count][2].to_f.round(3)
                %tr
                  %td.compound
                    %a{:href => to("/prediction/#{CGI.escape(neighbor_compound.uri)}/details"), :id=>"link#{count_rs}#{count}", :target=>"details"}
                      Names and synonymes >
                      %img{:src=>"#{neighbor_compound.uri}/image", :alt=>"Compound image not available", :title=>"#{neighbor_compound.smiles}", :width=>"150px"}
                  %td
                    - if c.class == String
                      = c
                    - else
                      = c
                  %td
                    = p.data_entries[count][3] != nil ? p.data_entries[count][3].round(3) : "Not enough similar compounds in training dataset." 
                  %td
                    - if @type =~ /classification/i
                      - if p.data_entries[count][3] != nil 
                        %a{:href => to("/prediction/#{CGI.escape(@model_uri)}/#{@type}/#{CGI.escape(neighbor_compound.uri)}/significant_fragments"), :id=>"link#{count_rs}#{count}sf", :target=>"details"} Significant fragments >
                    - if @type =~ /regression/i
                      - if p.data_entries[count][3] != nil
                        %a{:href => to("/prediction/#{CGI.escape(@model_uri)}/#{@type}/#{CGI.escape(neighbor_compound.uri)}/significant_fragments"), :id=>"link#{count_rs}#{count}sf", :target=>"details"} Descriptors >
                    :javascript
                      $(function() {
                          $("a#link#{count_rs}#{count}").on('click', function(e) {
                              $('#iframe_details').bPopup();
                          });
                      });
                      $(function() {
                          $("a#link#{count_rs}#{count}sf").on('click', function(e) {
                              $('#iframe_details').bPopup();
                          });
                      });
                  - count += 1
          -#- else
            %h3
              Not enough similar compounds in training dataset

%iframe{:id=>"iframe_details", :name=>"details", :height=>"95%", :width=>"95%", :style=>"display:none;border:0px"}