Class: Mspire::Ident::Peptide::Db

Inherits:
Object
  • Object
show all
Defined in:
lib/mspire/ident/peptide/db.rb

Overview

Very simple object for protein retrieval from a peptide-centric database See Mspire::Ident::Peptide::Db::IO for an on-disc version for larger files.

Defined Under Namespace

Classes: Creator, IO

Constant Summary collapse

PROTEIN_DELIMITER =
"\t"
KEY_VALUE_DELIMITER =
': '

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(db_file) ⇒ Db

Returns a new instance of Db.



15
16
17
# File 'lib/mspire/ident/peptide/db.rb', line 15

def initialize(db_file)
  @data = YAML.load_file(db_file)
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



13
14
15
# File 'lib/mspire/ident/peptide/db.rb', line 13

def data
  @data
end

Instance Method Details

#[](key) ⇒ Object

returns protein id’s as an array



20
21
22
23
# File 'lib/mspire/ident/peptide/db.rb', line 20

def [](key)
  val=@data[key]
  val.chomp.split(PROTEIN_DELIMITER) if val
end

#keysObject



25
26
27
# File 'lib/mspire/ident/peptide/db.rb', line 25

def keys
  @data.keys
end

#sizeObject



33
34
35
# File 'lib/mspire/ident/peptide/db.rb', line 33

def size
  @data.size
end

#valuesObject



29
30
31
# File 'lib/mspire/ident/peptide/db.rb', line 29

def values
  @data.values
end