class Bio::NeXML::Format
Attributes
Because format elements don’t have id attributes, we will use object_id in this case
Public Class Methods
# 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 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
# File lib/bio/db/nexml/matrix.rb, line 251 def add_states( states ) # dummy for rdoc end
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
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
# 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
# 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
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
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
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
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
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
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
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
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
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
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
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
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
# 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