bio-miga/miga-web

View on GitHub
app/views/shared/results/_proposed_clades.html.erb

Summary

Maintainability
Test Coverage
<% n = File.foreach(res.file_path(:proposal)).count %>
<% n_total = File.foreach(res.file_path(:clades_ani95)).count-1 %>
<% if n > 0 %>
<% ani_clades_id = info_modal "Species level clades based on ANI" do %>
  <div class="panel-group medoid-tree" role="tablist"
        aria-multiseletable="true">
  <% File.open(res.file_path(:proposal), "r") do |f| %>
    <% i=0 %>
    <% f.each_line do |ln| %>
      <% i+=1 %>
      <% r = ln.split /\s+/ %>
      <div class="panel panel-default" id=proposed_clade>
        <div class=panel-heading role=tab id="proposed_clade-h<%= i %>">
          <h4 class=panel-title>
            <a role=button data-toggle=collapse data-parent="#proposed_clade"
                  class=btn href="#proposed_clade-b<%= i %>" aria-expanded=false
                  aria-controls="proposed_clade-b<%= i %>">
              <%
                pref = r.map do |ds|
                  ds.unmiga_name.gsub(/([A-Z][a-z]+\s+\S+).*/,"\\1")
                end.uniq
                if pref.size > 1
                  pname = pref.first.gsub(/\s+.*/,"")
                  pref = [ pref.first ] +
                    pref[1..-1].map{ |n| n.gsub(/^#{pname} /,"#{pname[0]}. ") }
                end
                dss = pref.size <= 3 ? "<br/> #{pref.to_sentence}" : ""
              %>
              <b>Species clade <%= i %></b> (<%= r.count %> datasets)
              <%= dss.html_safe %>
            </a>
          </h4>
        </div>
        <div id="proposed_clade-b<%= i %>" class="panel-collapse collapse"
              role=tabpanel aria-labelledby="proposed_clade-h<%= i %>">
          <div class=panel-body>
            <%= r.map do |ds| %>
              <% link_to ds.unmiga_name,
                    reference_dataset_path(project.id, ds) %>
            <% end.to_sentence.html_safe %>
          </div>
        </div>
      </div>
    <% end %>
  <% end %>
  </div>
<% end %>
In addition, MiGA found a total of
<%= pluralize(n_total, "clade") %> at the species level (ANI &ge; 95%),
including <%= link_to("##{ani_clades_id}","data-toggle"=>"modal",
                "data-target"=>"##{ani_clades_id}") { %>
  <%= pluralize(n, "clade") %> with at least 5 members<% } %>.
<% end %>