ms-ident 0.0.20 → 0.0.21

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/VERSION +1 -1
  2. data/lib/ms/ident/pepxml.rb +30 -1
  3. metadata +2 -2
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.20
1
+ 0.0.21
@@ -22,6 +22,35 @@ class Ms::Ident::Pepxml
22
22
 
23
23
  attr_accessor :msms_pipeline_analysis
24
24
 
25
+ def self.search_hits(file)
26
+ fields = [:aaseq, :charge]
27
+ ss_names = []
28
+ have_ss_names = false
29
+ # begin with aaseq, charge
30
+ hit_values = File.open(file) do |io|
31
+ doc = Nokogiri::XML.parse(io, nil, nil, Nokogiri::XML::ParseOptions::DEFAULT_XML | Nokogiri::XML::ParseOptions::NOBLANKS)
32
+ # we can work with namespaces, or just remove them ...
33
+ doc.remove_namespaces!
34
+ root = doc.root
35
+ search_hits = root.xpath('//search_hit')
36
+ search_hits.map do |search_hit|
37
+ aaseq = search_hit['peptide']
38
+ charge = search_hit.parent.parent['assumed_charge'].to_i
39
+ search_score_nodes = search_hit.children.select {|node| node.name == 'search_score' }
40
+ ss_values = []
41
+ search_score_nodes.each do |node|
42
+ ss_names << node['name'].to_sym unless have_ss_names
43
+ ss_values << node['value'].to_f
44
+ end
45
+ have_ss_names = true
46
+ [aaseq, charge, *ss_values]
47
+ end
48
+ end
49
+ fields.push(*ss_names)
50
+ peptide_hit_class = Struct.new(*fields)
51
+ hit_values.map {|ar| peptide_hit_class.new(*ar) }
52
+ end
53
+
25
54
  def pepxml_version
26
55
  msms_pipeline_analysis.pepxml_version
27
56
  end
@@ -42,7 +71,7 @@ class Ms::Ident::Pepxml
42
71
  doc.root.add_previous_sibling xml_stylesheet
43
72
  doc
44
73
  end
45
-
74
+
46
75
  # if no options are given, an xml string is returned. If either :outdir or
47
76
  # :outfile is given, the xml is written to file and the output filename is returned.
48
77
  # A single string argument will be interpreted as :outfile if it ends in
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 20
9
- version: 0.0.20
8
+ - 21
9
+ version: 0.0.21
10
10
  platform: ruby
11
11
  authors:
12
12
  - John T. Prince