ms-ident 0.0.20 → 0.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/lib/ms/ident/pepxml.rb +30 -1
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.21
|
data/lib/ms/ident/pepxml.rb
CHANGED
@@ -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
|