Class: Mspire::Ident::Pepxml::SearchDatabase

Inherits:
Object
  • Object
show all
Includes:
Merge
Defined in:
lib/mspire/ident/pepxml/search_database.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Merge

#merge!

Constructor Details

#initialize(hash = {}, get_size_of_residues = false) ⇒ SearchDatabase

takes a hash to fill in values



26
27
28
29
30
31
# File 'lib/mspire/ident/pepxml/search_database.rb', line 26

def initialize(hash={}, get_size_of_residues=false)
  merge!(hash)
  if get_size_of_residues && File.exist?(@local_path)
    set_size_of_residues!
  end
end

Instance Attribute Details

#database_nameObject

optional



15
16
17
# File 'lib/mspire/ident/pepxml/search_database.rb', line 15

def database_name
  @database_name
end

#database_release_dateObject

optional



19
20
21
# File 'lib/mspire/ident/pepxml/search_database.rb', line 19

def database_release_date
  @database_release_date
end

#database_release_identifierObject

optional



21
22
23
# File 'lib/mspire/ident/pepxml/search_database.rb', line 21

def database_release_identifier
  @database_release_identifier
end

#local_pathObject

required! the local, full path to the protein sequence database



10
11
12
# File 'lib/mspire/ident/pepxml/search_database.rb', line 10

def local_path
  @local_path
end

#orig_database_urlObject

optional



17
18
19
# File 'lib/mspire/ident/pepxml/search_database.rb', line 17

def orig_database_url
  @orig_database_url
end

#seq_typeObject

required! ‘AA’ or ‘NA’



12
13
14
# File 'lib/mspire/ident/pepxml/search_database.rb', line 12

def seq_type
  @seq_type
end

#size_of_residuesObject

optional



23
24
25
# File 'lib/mspire/ident/pepxml/search_database.rb', line 23

def size_of_residues
  @size_of_residues
end

Instance Method Details

#set_size_of_residues!Object

returns self for chaining



34
35
36
37
38
39
40
# File 'lib/mspire/ident/pepxml/search_database.rb', line 34

def set_size_of_residues!
  @size_of_residues = 0
  Mspire::Fasta.foreach(@local_path) do |entry|
    @size_of_residues += entry.sequence.size
  end
  self
end

#to_xml(builder) ⇒ Object



42
43
44
45
46
# File 'lib/mspire/ident/pepxml/search_database.rb', line 42

def to_xml(builder)
  attrs = [:local_path, :seq_type, :database_name, :orig_database_url, :database_release_date, :database_release_identifier, :size_of_residues].map {|k| v=send(k) ; [k, v] if v }.compact
  builder.search_database(Hash[attrs])
  builder
end