Class: Proph::ProtSummary

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

Defined Under Namespace

Classes: Parser

Constant Summary collapse

Filetype_and_version_re_old =

if you get this match it’s a protein prophet file and the version is the first match!

/ProteinProphet_v([\.\d]+)\.dtd/
Filetype_and_version_re_new =

gives 4 right now

/protXML_v([\.\d]+)\.xsd/

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file = nil) ⇒ ProtSummary

Returns a new instance of ProtSummary.



50
51
52
53
54
55
56
57
# File 'lib/ms/ident/pepxml/prot_summary.rb', line 50

def initialize(file=nil)
  @prots = nil
  if file
    @version = get_version(file)
    #@prot_groups = ProtSummary::Parser.new.parse_file(file)
    SpecID::Parser::ProtProph.new(:spec_id).parse(file, :spec_id => self)
  end
end

Instance Attribute Details

#prot_groupsObject

the protein groups



27
28
29
# File 'lib/ms/ident/pepxml/prot_summary.rb', line 27

def prot_groups
  @prot_groups
end

#versionObject

Returns the value of attribute version.



28
29
30
# File 'lib/ms/ident/pepxml/prot_summary.rb', line 28

def version
  @version
end

Instance Method Details

#get_version(file) ⇒ Object

Raises:

  • (ArgumentError)


32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/ms/ident/pepxml/prot_summary.rb', line 32

def get_version(file)
  answer = nil
  File.open(file) do |fh|
    5.times do
      line = fh.gets
      answer = 
        if line =~ Filetype_and_version_re_new
          $1.dup
        elsif line =~ Filetype_and_version_re_old
          $1.dup
        end
      break if answer
    end
  end
  raise(ArgumentError, "couldn't detect version in #{file}") unless answer
  answer
end

#hi_prob_bestObject



30
# File 'lib/ms/ident/pepxml/prot_summary.rb', line 30

def hi_prob_best ; true end

#unique_prots(prot_groups) ⇒ Object

returns a set of unique proteins



60
61
62
63
64
65
66
67
68
# File 'lib/ms/ident/pepxml/prot_summary.rb', line 60

def unique_prots(prot_groups)
  all_prots = []
  prot_groups.each do |pg|
    pg.prots.each do |prt|
      all_prots << prt
    end
  end
  all_prots.hash_by(:protein_name).map{|name,prot_arr| prot_arr.first }
end