Class: Ms::Mascot::Dat::Proteins

Inherits:
Section
  • Object
show all
Defined in:
lib/ms/mascot/dat/proteins.rb

Overview

Proteins represent supplementary protein information in a dat file.

Content-Type: application/x-Mascot; name="proteins"

"ZN711_HUMAN"=87153.77,"Zinc finger protein 711 (Zinc finger protein 6) - Homo sapiens (Human)"
"Y986_MYCTU"=27356.31,"Hypothetical ABC transporter ATP-binding protein Rv0986/MT1014 - Mycobacterium tuberculosis"
"Y5G0_ENCCU"=33509.30,"Hypothetical protein ECU05_1600/ECU11_0130 - Encephalitozoon cuniculi"

Proteins is (almost) a standard Section and defines methods for convenient access.

Defined Under Namespace

Classes: Protein

Constant Summary collapse

TO_S_FORMAT =

A format string used to format parameters as a string.

"\"%s\"=%s\n"

Constants inherited from Section

Section::CONTENT_TYPE_REGEXP

Instance Attribute Summary

Attributes inherited from Section

#dat, #data, #section_name

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Section

#initialize, section_name, #to_s

Constructor Details

This class inherits a constructor from Ms::Mascot::Dat::Section

Class Method Details

.parse(str, archive = nil) ⇒ Object

Parses a new instance from str. Special parsing is required to quickly remove the quotes from protein keys.



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/ms/mascot/dat/proteins.rb', line 39

def parse(str, archive=nil)
  params = {}
  scanner = StringScanner.new(str)
  
  # skip whitespace and content type declaration
  unless scanner.scan(Section::CONTENT_TYPE_REGEXP)
    raise "unknown content type: #{content_type}"
  end
  section_name = scanner[1]
  
  # scan each pair removing quotes from keys
  while true
    scanner.skip(/"/)
    break unless key = scanner.scan(/[^"]+/)
    scanner.skip(/"\=/)
    params[key] = scanner.scan(/[^\n]*/)
    scanner.skip(/\n/)
  end
  
  new(params, section_name, archive)
end

Instance Method Details

#protein(id) ⇒ Object

Returns a Protein for the specified protein id.



63
64
65
# File 'lib/ms/mascot/dat/proteins.rb', line 63

def protein(id)
  parse_protein(data[id])
end