class Bio::NeXML::Format

Attributes

id[RW]

Because format elements don’t have id attributes, we will use object_id in this case

Public Class Methods

new( options = {} ) click to toggle source
# File lib/bio/db/nexml/matrix.rb, line 233
def initialize( options = {} )
  @id = self.object_id
  properties( options ) unless options.empty?
  block.arity < 1 ? instance_eval( &block ) : block.call( self ) if block_given?
end

Public Instance Methods

add_char( char ) click to toggle source

Add a column definition to the format.

  • Arguments :

char( required ) - a Bio::NeXML::Char object.

  • Returns : self.

    format.add_char( char )
    format.chars               #=> [ .. char .. ]
    char.format                #=> format
    
# File lib/bio/db/nexml/matrix.rb, line 289
def add_char( char )
  # dummy for rdoc
end
add_states( states ) click to toggle source
# File lib/bio/db/nexml/matrix.rb, line 251
def add_states( states )
  # dummy for rdoc
end
chars() click to toggle source

Returns an array of column definitions( Bio::NeXML::Char objects ) for the matrix.

matrix.chars  #=> [ .. .. ]
# File lib/bio/db/nexml/matrix.rb, line 312
def chars
  # dummy for rdoc
end
chars=( chars ) click to toggle source

Add column definitions to the matrix. This function will override the previous column definitions if any.

  • Arguments :

chars( required ) - an array of Bio::NeXML::Char object.

matrix.chars = [ char ]
matrix.chars    #=> [ char ]
char.matrix     #=> matrix
# File lib/bio/db/nexml/matrix.rb, line 334
def chars=( chars )
  # dummy for rdoc
end
create_char( states = nil, options = {} ) click to toggle source
# File lib/bio/db/nexml/matrix.rb, line 245
def create_char( states = nil, options = {} )
  char = Char.new( Bio::NeXML.generate_id( Char ), states, options )
  add_char char
  char
end
create_states( options = {} ) click to toggle source
# File lib/bio/db/nexml/matrix.rb, line 239
def create_states( options = {} )
  states = States.new( Bio::NeXML.generate_id( States ), options )
  add_states states
  states        
end
delete_char( char ) click to toggle source

Remove a column definition from the matrix.

  • Arguments :

char( required ) - a Bio::NeXML::Char object.

  • Returns : the deleted object.

    matrix.delete_char( char )
    matrix.chars               #=> [ .. .. ]
    char.matrix                #=> nil
    
# File lib/bio/db/nexml/matrix.rb, line 300
def delete_char( char )
  # dummy for rdoc
end
delete_states( states ) click to toggle source

Remove a state set from the format.

  • Arguments :

states( required ) - a Bio::NeXML::State object.

  • Returns : the deleted object.

    format.delete_states( states )
    format.states                #=> [ .. .. ]
    states.format                #=> nil
    
# File lib/bio/db/nexml/matrix.rb, line 268
def delete_states( states )
  # dummy for rdoc
end
each_char() click to toggle source

Iterate over each column definitions( Bio::NeXML::Char object ) defined for the matrix. Returns an Enumerator if no block is provided.

# File lib/bio/db/nexml/matrix.rb, line 368
def each_char
  # dummy for rdoc
end
each_states() click to toggle source

Iterate over each state sets( Bio::NeXML::States object ) defined for the matrix. Returns an Enumerator if no block is provided.

# File lib/bio/db/nexml/matrix.rb, line 362
def each_states
  # dummy for rdoc
end
get_char_by_id( id ) click to toggle source

Fetch a column definition( Bio::NeXML::Char object ) by id. Returns nil if none found.

# File lib/bio/db/nexml/matrix.rb, line 345
def get_char_by_id( id )
  matches = each_char.select{ |c| c.id == id } # XXX not sure why I have to implement this?
  matches.first        
end
get_states_by_id( id ) click to toggle source

Fetch a state set( Bio::NeXML::States object ) by id. Returns nil if none found.

# File lib/bio/db/nexml/matrix.rb, line 273
def get_states_by_id( id )
  # dummy for rdoc
end
has_char?( char ) click to toggle source

Returns true if the given column definition( Bio::NeXML::Char object ) is defined for the matrix.

# File lib/bio/db/nexml/matrix.rb, line 356
def has_char?( char )
  # dummy for rdoc
end
has_states?( states ) click to toggle source

Returns true if the given state set( Bio::NeXML::States object ) is defined for the format block.

# File lib/bio/db/nexml/matrix.rb, line 257
def has_states?( states )
  # dummy for rdoc
end
number_of_chars() click to toggle source

Returns the number of column definitions defined for the matrix.

# File lib/bio/db/nexml/matrix.rb, line 378
def number_of_chars
  # dummy for rdoc
end
number_of_states() click to toggle source

Returns the number of state sets defined for the matrix.

# File lib/bio/db/nexml/matrix.rb, line 278
def number_of_states
  # dummy for rdoc
end
states() click to toggle source

Returns an array of state sets( Bio::NeXML::States objects ) for the matrix.

matrix.states  #=> [ .. .. ]
# File lib/bio/db/nexml/matrix.rb, line 306
def states
  # dummy for rdoc
end
states=( states ) click to toggle source

Add state sets to the matrix. This function will overwrite previous state set definitions for the matrix if any.

  • Arguments :

states( required ) - an array of Bio::NeXML::States object.

matrix.states = [ states ]
matrix.states    #=> [ states ]
states.matrix    #=> matrix
# File lib/bio/db/nexml/matrix.rb, line 323
def states=( states )
  # dummy for rdoc
end
to_xml() click to toggle source
# File lib/bio/db/nexml/matrix.rb, line 382
def to_xml
  node = @@writer.create_node( "format" )

  self.each_states do |states|
    node << states.to_xml
  end

  self.each_char do |char|
    node << char.to_xml
  end

  node
end