Class: Bio::FANTOM::MaXML::Sequences

Inherits:
Bio::FANTOM::MaXML show all
Includes:
Enumerable
Defined in:
lib/bio/db/fantom.rb

Overview

class MaXML::Cluster

Constant Summary collapse

Data_XPath =
'maxml-sequences'

Constants inherited from Bio::FANTOM::MaXML

DELIMITER

Instance Attribute Summary

Attributes inherited from Bio::FANTOM::MaXML

#elem

Instance Method Summary collapse

Methods inherited from Bio::FANTOM::MaXML

#entry_id, #gsub_entities, #initialize, #to_s

Methods inherited from DB

#entry_id, #exists?, #fetch, open, #tags

Constructor Details

This class inherits a constructor from Bio::FANTOM::MaXML

Instance Method Details

#[](*arg) ⇒ Object



188
189
190
191
192
193
194
# File 'lib/bio/db/fantom.rb', line 188

def [](*arg)
  if arg[0].is_a?(String) and arg.size == 1 then
    get(arg[0])
  else
    to_a[*arg]
  end
end

#cloneidsObject



196
197
198
199
200
201
# File 'lib/bio/db/fantom.rb', line 196

def cloneids
  unless defined?(@cloneids)
    @cloneids = to_a.collect { |x| x.cloneid }
  end
  @cloneids
end

#eachObject



164
165
166
# File 'lib/bio/db/fantom.rb', line 164

def each
  to_a.each { |x| yield x }
end

#get(idstr) ⇒ Object



176
177
178
179
180
181
182
183
184
185
186
# File 'lib/bio/db/fantom.rb', line 176

def get(idstr)
  unless defined?(@hash)
    @hash = {}
  end
  unless @hash.member?(idstr) then
    @hash[idstr] = self.find do |x|
      x.altid.values.index(idstr)
    end
  end
  @hash[idstr]
end

#id_stringsObject



203
204
205
206
207
208
209
210
211
# File 'lib/bio/db/fantom.rb', line 203

def id_strings
  unless defined?(@id_strings)
    @id_strings = to_a.collect { |x| x.id_strings }
    @id_strings.flatten!
    @id_strings.sort!
    @id_strings.uniq!
  end
  @id_strings
end

#to_aObject



168
169
170
171
172
173
174
# File 'lib/bio/db/fantom.rb', line 168

def to_a
  unless defined?(@sequences)
    @sequences = @elem.get_elements('sequence')
    @sequences.collect! { |e| MaXML::Sequence.new(e) }
  end
  @sequences
end