summaryrefslogtreecommitdiff
path: root/views/prediction.haml
blob: 8f72a235af2717b52aef5c2675b9267f878daf84 (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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
%div
  %a.btn.btn-xs.btn-default{:href => to('/predict'), :style=>"margin-bottom:1em;"}
    %span.glyphicon.glyphicon-chevron-left
    New Prediction

  %h3.help-block
    Similar particles
  
  %hr  
  :javascript 
    $(document).ready(function(){
      $(".tablesorter").tablesorter({
        debug: false,
        theme: "bootstrap",
        headerTemplate: '{content} {icon}',
        widgets: ['uitheme', 'staticRow', 'stickyHeaders'],
        widgetOptions: {
          stickyHeaders_xScroll : null
        },
        sortList: [[1,1]],
        widthFixed: false,
      });
      $('#neighbors').doubleScroll();
    });


  #neighbors.table-responsive
    /%table.tablesorter{:style => "max-width:100%;white-space:nowrap;"}
    %table.tablesorter
      %thead
        %tr
          %th
            ID  
          %th
            Similarity
          %th
            Composition  
          %th.tox{:style => "max-width:100%;white-space:nowrap;"}
            Toxicity 
            %br 
            Net cell association
            %br
            [mL/ug(Mg)]
          - @input.sort_by{|d| OpenTox::Feature.find(d[0]).category}.each do |key|
            - feature = OpenTox::Feature.find_by(:id=>key[0])
            - name = feature.name
            - if (feature[:conditions] && !feature[:conditions]["MEDIUM"].blank?)
              - name = feature.name + " / " + feature[:conditions]["MEDIUM"]
            - else
              - name = feature.name
            %th.physchem
              = name
      %tbody
        / query and match combined
        %tr.static
          / id
          %td
            - if @match
              %a{:href=> $ambit_search+@name, :rel=>"external"}
                %h5.th5= @name
            - else
              %h5.th5 Query
          / similarity
          %td
            - if @match
              %h5.th5 1
            - else
              %h5.th5 x
          / composition
          %td
            - if @match
              %h5.th5 Core:
              %a{:href=>@nanoparticle[:core]["uri"], :rel=>"external"}= "["+@nanoparticle[:core]["name"]+"]"
              /%br
              /%h5.th5 Coating:
              /= @nanoparticle[:coating][0]["name"]
              /%br
            - else
              %h5.th5 Core:
              = "["+@nanoparticle[:core]["name"]+"]"
              /%br
              /%h5.th5 Coating:
              /= @nanoparticle[:coating][0]["name"]
              /%br
          / tox
          %td.tox
            - if @prediction[:value]
              %h5.th5 Prediction:
              = @prediction[:value].round(3)
              %br
            - if @prediction[:rmse]
              %h5.th5
                %a{:href=>"https://en.wikipedia.org/wiki/Root-mean-square_deviation", :rel=>"external"} RMSE:
              = @prediction[:rmse].round(3)
              %br
            - if @prediction[:r_squared]
              %h5.th5
                %a{:href=>"https://en.wikipedia.org/wiki/Coefficient_of_determination", :rel=>"external"}= "R"+"<sup>2</sup>"+":"
              = @prediction[:r_squared].round(3)
              %br
            - if @prediction[:prediction_interval]
              %h5
                %a{:href=>"https://en.wikipedia.org/wiki/Prediction_interval", :rel=>"external"} 95% Prediction interval:
                - interval = @prediction[:prediction_interval].nil? ? " - - " : @prediction[:prediction_interval].collect{|i| i.round(2)}
              = "#{interval[0]} - #{interval[1]}"
            - if @prediction[:measurements]
              %br
              %h5.th5 Measurement:
              - @prediction[:measurements].each do |m|
                = m
            - if !@prediction[:value] && !@prediction[:measurements]
              %h5.th5 not available
          / physchem
          - @input.sort_by{|d| OpenTox::Feature.find(d[0]).category}.each do |v|
            %td.physchem
              %div{:style=>"display:inline-block;padding-right:20px;"}
                - if v[1].nil?
                  %p x
                - else
                  %p= v[1][0].round(3)

        / neighbors
        - if @prediction[:neighbors]
          - @prediction[:neighbors].each_with_index do |neighbor,idx|
            - nano = OpenTox::Nanoparticle.find(neighbor["_id"])
            - pc_descriptors = nano.physchem_descriptors.delete_if{|id,v| OpenTox::Feature.find(id).category != "P-CHEM"} if @type == "pc"
            %tr
              / ID
              %td
                %a{:href=> $ambit_search+nano.name, :rel=>"external"}
                  %h5.th5= nano.name
              / Similarity
              %td
                %h5.th5= neighbor["similarity"].round(3)
              / Composition
              %td
                %h5.th5 Core:
                %a{:href=>nano[:core]["uri"], :rel=> "external"}= "["+nano[:core]["name"]+"]"
                %br
                %h5.th5 Coating:
                %a{:href=>nano[:coating][0]["uri"], :rel=>"external"}= nano[:coating][0]["name"]
              / Tox
              %td.tox
                %h5.th5 Measurement:
                = neighbor["measurements"][0]
              / Physchem
              - nano.physchem_descriptors.delete_if{|id,v| @type == "pc" ? !@@pc_relevant_features.include?(OpenTox::Feature.find(id)) : !@@pcp_relevant_features.include?(OpenTox::Feature.find(id))}.sort_by{|id,v| OpenTox::Feature.find(id).category}.each do |k,v|
                %td.physchem
                  %div
                    %div{:style=>"display:inline-block;padding-right:20px;"}
                      = v[0].round(3) unless v.nil?