class SimpleNexml

Parse NeXML document and return some data

Attributes

doc[RW]
entity[RW]
taxon[RW]

Public Class Methods

new(doc: nil, taxon: nil, entity: nil) click to toggle source
# File lib/fishtank/simple_nexml.rb, line 12
def initialize(doc: nil, taxon: nil, entity: nil)
  @doc = doc
end

Public Instance Methods

cells() click to toggle source
# File lib/fishtank/simple_nexml.rb, line 30
def cells
  doc.css("cell")
end
otus() click to toggle source
# File lib/fishtank/simple_nexml.rb, line 26
def otus
  doc.css("otus")
end
referenced_chars() click to toggle source

@return [Array]

all chars referenced in rows
# File lib/fishtank/simple_nexml.rb, line 40
def referenced_chars
  cells.inject({}) {|hsh, c| hsh.merge!(c.to_h['char'] => nil)}.keys
end
referenced_otus() click to toggle source

@return [Array]

all chars referenced in rows
# File lib/fishtank/simple_nexml.rb, line 52
def referenced_otus
  rows.css("row").inject({}) {|hsh, c| hsh.merge!(c.to_h['otu'] => nil)}.keys
end
referenced_states() click to toggle source

@return [Array]

all states referenced in rows
# File lib/fishtank/simple_nexml.rb, line 46
def referenced_states
  cells.inject({}) {|hsh, c| hsh.merge!(c.to_h['state'] => nil)}.keys
end
rows() click to toggle source
# File lib/fishtank/simple_nexml.rb, line 34
def rows
  doc.css("row")
end
stats() click to toggle source
# File lib/fishtank/simple_nexml.rb, line 16
def stats
  return {
    count: {
      otus: otus.count,
      rows: rows.count,
      cells: cells.count
    }
  }
end