Class: Proph::ProtSummary::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/ms/ident/pepxml/prot_summary.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file = nil, with_peps = false, tp = 'axml') ⇒ Parser

Returns a new instance of Parser.



74
75
76
77
78
# File 'lib/ms/ident/pepxml/prot_summary.rb', line 74

def initialize(file=nil, with_peps=false, tp='axml')
  if file
    @prot_groups = parse_file(file, with_peps, tp)
  end
end

Instance Attribute Details

#prot_groupsObject

Returns the value of attribute prot_groups.



73
74
75
# File 'lib/ms/ident/pepxml/prot_summary.rb', line 73

def prot_groups
  @prot_groups
end

Instance Method Details

#_parse_for_prot_groups(stream, with_peps = false, tp = 'axml') ⇒ Object

returns an array of ProtGroup objects



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/ms/ident/pepxml/prot_summary.rb', line 89

def _parse_for_prot_groups(stream, with_peps=false, tp='axml')
  prtgrps = []
  case tp
  when 'axml'
    root = AXML.parse(stream)
    root.protein_group.each do |protein_group|
      pg = ProtGroup.new(protein_group.attrs) do 
        protein_group.map do |protein|
          Prot.new(protein.attrs)
        end
      end
      prtgrps << pg 
    end
  end
  prtgrps
end

#parse_file(file, with_peps = false, tp = 'axml') ⇒ Object

returns an array of protein_groups



81
82
83
84
85
86
# File 'lib/ms/ident/pepxml/prot_summary.rb', line 81

def parse_file(file, with_peps=false, tp='axml')
  File.open(file) do |fh|
    @prot_groups = _parse_for_prot_groups(fh, with_peps, tp)
  end
  @prot_groups
end