Method: Bio::Nexus::DistancesBlock#to_nexus

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

#to_nexusObject

Returns a String describing this block as nexus formatted data.


Returns

String



1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
# File 'lib/bio/db/nexus.rb', line 1344

def to_nexus
  line_1 = String.new
  line_1 << DIMENSIONS  
  if ( Nexus::Util::larger_than_zero( get_number_of_taxa ) )
    line_1 << " " <<  NTAX << "=" << get_number_of_taxa
  end
  if ( Nexus::Util::larger_than_zero( get_number_of_characters ) )
    line_1 << " " <<  NCHAR << "=" << get_number_of_characters
  end
  line_1 << DELIMITER
  
  line_2 = String.new
  line_2 << FORMAT  
  if ( Nexus::Util::longer_than_zero( get_triangle ) )
    line_2 << " " << TRIANGLE << "=" << get_triangle
  end
  line_2 << DELIMITER
  
  line_3 = String.new
  line_3 << MATRIX 
  Nexus::Util::to_nexus_helper( DISTANCES_BLOCK, [ line_1, line_2, line_3 ] +
                                get_matrix.to_nexus_row_array( " " ) )
end