SpeciesFileGroup/taxonworks

View on GitHub
app/views/observation_matrices/export/nexus/_nexus.html.erb

Summary

Maintainability
Test Coverage
<% m = @observation_matrix %>
<% observations_hash = m.observations_hash %>
<% nb = '&nbsp;&nbsp;' %>
#NEXUS

[ generated by TaxonWorks (http://taxonworks.org) at <%= Time.now %>]
[ from matrix: <%= m.name %> (id: <%= m.id %>) ]  
[ <TODO> access these data via the API at XXXX </TODO>]

Begin taxa;
Dimensions Ntax=<%= m.observation_matrix_rows.load.size -%>;
Taxlabels <% m.observation_matrix_rows.each do |r| -%>
<%= as_file ? '  ' : nb -%>'<%= observation_matrix_row_label_nexus(r) -%>'<% end -%>
;
end;

<% descriptors = m.descriptors.where(type: %w{Descriptor::Qualitative Descriptor::PresenceAbsence }) %>
<% if descriptors.load.any? %>
Begin characters;
Title qualitative_characters;
Dimensions Nchar=<%= descriptors.size -%>;
Format
<%= as_file ? '  ' : nb -%>datatype = STANDARD  
<%= as_file ? '  ' : nb -%>missing = ?  
<%= as_file ? '  ' : nb -%>symbols = "0 1 2 3 4 5 6 7 8 9 A B C D E F G H I J K L M N P Q R S U V W X Y Z !"; 
Charstatelabels
<% descriptors.each_with_index do |d, i| -%>
  <%= as_file ? '  ' : nb -%><%= "#{i+1} #{descriptor_matrix_label(d).html_safe} /".html_safe %> <%= d.character_states.order(:position).collect{|cs| "'#{cs.name}'".html_safe}.join(' ').html_safe if d.qualitative? -%>,
<% end %>
;
Matrix
<% m.observation_matrix_rows.each do |r| -%>
'<%= observation_matrix_row_label_nexus(r) %>'<%= as_file ? ' ' : '&nbsp;' -%>
<% descriptors.each do |d| -%><%= observations_cell_label(observations_hash, d, r.observation_index, :nexus) %><% end %>
<% end %>
;
end; 

[ End standard block ]
<% end %>


<% if m.continuous_descriptors.load.any? %>
[ Continuous characters block, remove for execution in PAUP* ]
 
Begin characters;
<%= as_file ? '  ' : nb -%>title continuous_characters;
<%= as_file ? '  ' : nb -%>dimensions nchar=<%= m.continuous_descriptors.size -%>; 
<%= as_file ? '  ' : nb -%>format 
<%= as_file ? '  ' : nb -%>datatype = CONTINUOUS
<%= as_file ? '  ' : nb -%>gap = - 
;
matrix
<% m.observation_matrix_rows.each do |r| -%>
'<%= observation_matrix_row_label_nexus(r) %>'<%= as_file ? ' ' : '&nbsp;' -%>
<% m.continuous_descriptors.each do |d| -%><%= observations_cell_label(observations_hash, d, r.observation_index, :nexus) %><% end %>
<% end %>
;
end;

[ End continuous block ]
<% end %>