Bio::Nexus::CharactersBlock represents a characters nexus block.
Begin Characters;
Dimensions NChar=20 NTax=4; Format DataType=DNA Missing=x Gap=- MatchChar=.; Matrix fish ACATA GAGGG TACCT CTAAG frog ACTTA GAGGC TACCT CTAGC snake ACTCA CTGGG TACCT TTGCG mouse ACTCA GACGG TACCT TTGCG;
End;
require 'bio/db/nexus' # Create a new parser: nexus = Bio::Nexus.new( nexus_data_as_string ) # Get first characters block (same methods as Nexus::DataBlock except # it lacks get_taxa method): characters_block = nexus.get_characters_blocks[ 0 ]
Creates a new CharactersBlock object named ‘name’.
Arguments:
(required) name: String
# File lib/bio/db/nexus.rb, line 951 def initialize( name ) super( name ) @number_of_taxa = 0 @number_of_characters = 0 @data_type = String.new @gap_character = String.new @missing = String.new @match_character = String.new @matrix = NexusMatrix.new end
Gets the “datatype” property.
Returns |
# File lib/bio/db/nexus.rb, line 1018 def get_datatype @data_type end
Gets the “gap character” property.
Returns |
# File lib/bio/db/nexus.rb, line 1025 def get_gap_character @gap_character end
Gets the “match character” property.
Returns |
# File lib/bio/db/nexus.rb, line 1039 def get_match_character @match_character end
Gets the matrix.
Returns |
# File lib/bio/db/nexus.rb, line 1046 def get_matrix @matrix end
Gets the “missing” property.
Returns |
# File lib/bio/db/nexus.rb, line 1032 def get_missing @missing end
Gets the “number of characters” property.
Returns |
Integer |
# File lib/bio/db/nexus.rb, line 1011 def get_number_of_characters @number_of_characters end
Gets the “number of taxa” property.
Returns |
Integer |
# File lib/bio/db/nexus.rb, line 1003 def get_number_of_taxa @number_of_taxa end
Returns the String in the matrix at row ‘row’ and column 0, which usually is interpreted as a sequence name (if the matrix contains molecular sequence characters).
Arguments:
(required) row: Integer
Returns |
# File lib/bio/db/nexus.rb, line 1084 def get_row_name( row ) get_matrix.get_name( row ) end
Returns the characters in the matrix at row ‘row’ as Bio::Sequence object. Column 0 of the matrix is set as the definition of the Bio::Sequence object.
Arguments:
(required) row: Integer
Returns |
# File lib/bio/db/nexus.rb, line 1072 def get_sequence( row ) create_sequence( get_characters_string( row ), get_row_name( row ) ) end
Returns character data as Bio::Sequence object Array for matrix rows named ‘name’.
Arguments:
(required) name: String
Returns |
# File lib/bio/db/nexus.rb, line 1056 def get_sequences_by_name( name ) seq_strs = get_characters_strings_by_name( name ) seqs = Array.new seq_strs.each do | seq_str | seqs.push( create_sequence( seq_str, name ) ) end seqs end
Sets the “data type” property.
Arguments:
(required) data_type: String
# File lib/bio/db/nexus.rb, line 1130 def set_datatype( data_type ) @data_type = data_type end
Sets the “gap character” property.
Arguments:
(required) gap_character: String
# File lib/bio/db/nexus.rb, line 1138 def set_gap_character( gap_character ) @gap_character = gap_character end
Sets the “match character” property.
Arguments:
(required) match_character: String
# File lib/bio/db/nexus.rb, line 1154 def set_match_character( match_character ) @match_character = match_character end
Sets the matrix.
Arguments:
(required) matrix: Bio::Nexus::NexusMatrix
# File lib/bio/db/nexus.rb, line 1162 def set_matrix( matrix ) @matrix = matrix end
Sets the “missing” property.
Arguments:
(required) missing: String
# File lib/bio/db/nexus.rb, line 1146 def set_missing( missing ) @missing = missing end
Sets the “number of characters” property.
Arguments:
(required) number_of_characters: Integer
# File lib/bio/db/nexus.rb, line 1122 def set_number_of_characters( number_of_characters ) @number_of_characters = number_of_characters end
Sets the “number of taxa” property.
Arguments:
(required) number_of_taxa: Integer
# File lib/bio/db/nexus.rb, line 1114 def set_number_of_taxa( number_of_taxa ) @number_of_taxa = number_of_taxa end
Returns a String describing this block as nexus formatted data.
Returns |
# File lib/bio/db/nexus.rb, line 966 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 << MATRIX Nexus::Util::to_nexus_helper( CHARACTERS_BLOCK, [ line_1, line_2, line_3 ] + get_matrix.to_nexus_row_array ) end
Generated with the Darkfish Rdoc Generator 2.