Bio::Nexus::DataBlock represents a data nexus block. A data block is a Bio::Nexus::CharactersBlock with the added capability to store taxa names.
Begin Data;
Dimensions ntax=5 nchar=14; Format Datatype=RNA gap=# MISSING=x MatchChar=^; TaxLabels ciona cow [comment] ape 'purple urchin' "green lizard"; Matrix taxon_1 A- CCGTCGA-GTTA taxon_2 T- CCG-CGA-GATA taxon_3 A- C-GTCGA-GATA taxon_4 A- CCTCGA--GTTA taxon_5 T- CGGTCGT-CTTA;
End;
require 'bio/db/nexus' # Create a new parser: nexus = Bio::Nexus.new( nexus_data_as_string ) # Get first data block: data_block = nexus.get_data_blocks[ 0 ] # Get first characters name: seq_name = data_block.get_row_name( 0 ) # Get first characters row named "taxon_2" as Bio::Sequence sequence: seq_tax_2 = data_block.get_sequences_by_name( "taxon_2" )[ 0 ] # Get third characters row as Bio::Sequence sequence: seq_2 = data_block.get_sequence( 2 ) # Get first characters row named "taxon_3" as String: string_tax_3 = data_block.get_characters_strings_by_name( "taxon_3" ) # Get name of first taxon: taxon_0 = data_block.get_taxa[ 0 ] # Get characters matrix as Bio::Nexus::NexusMatrix (names are in column 0) characters_matrix = data_block.get_matrix
Adds a taxon name to this block.
Arguments:
(required) taxon: String
# File lib/bio/db/nexus.rb, line 1288 def add_taxon( taxon ) @taxa.push( taxon ) end
Gets the taxa of this block.
Returns |
Array |
# File lib/bio/db/nexus.rb, line 1280 def get_taxa @taxa end
Returns a String describing this block as nexus formatted data.
Returns |
# File lib/bio/db/nexus.rb, line 1240 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_datatype ) ) line_2 << " " << DATATYPE << "=" << get_datatype end if ( Nexus::Util::longer_than_zero( get_missing ) ) line_2 << " " << MISSING << "=" << get_missing end if ( Nexus::Util::longer_than_zero( get_gap_character ) ) line_2 << " " << GAP << "=" << get_gap_character end if ( Nexus::Util::longer_than_zero( get_match_character ) ) line_2 << " " << MATCHCHAR << "=" << get_match_character end line_2 << DELIMITER line_3 = String.new line_3 << TAXLABELS << " " << Nexus::Util::array_to_string( get_taxa ) line_3 << DELIMITER line_4 = String.new line_4 << MATRIX Nexus::Util::to_nexus_helper( DATA_BLOCK, [ line_1, line_2, line_3, line_4 ] + get_matrix.to_nexus_row_array ) end
Generated with the Darkfish Rdoc Generator 2.