Method: Bio::Nexus::NexusMatrix#to_nexus_row_array

Defined in:
lib/bio/db/nexus.rb

#to_nexus_row_array(spacer = "", append_delimiter = true) ⇒ Object

Helper method to produce nexus formatted data.


Arguments:

  • (optional) spacer: String

  • (optional) append_delimiter: true or false

Returns

Array



1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
# File 'lib/bio/db/nexus.rb', line 1733

def to_nexus_row_array( spacer = "", append_delimiter = true )
  ary = Array.new
  if is_empty?
    return ary
  end
  max_length = 10
  for row in 0 .. get_max_row
    l = get_value( row, 0 ).length
    if ( l > max_length )
      max_length = l
    end
  end  
  for row in 0 .. get_max_row
    row_str = String.new
    ary.push( row_str )
    name = get_value( row, 0 )
    name = name.ljust( max_length + 1 )
    row_str << name << " " << get_row_string( row, spacer )
    if ( spacer != nil && spacer.length > 0 )
      row_str.chomp!( spacer )
    end
    if ( append_delimiter && row == get_max_row )
      row_str << DELIMITER 
    end
  end
  ary
end