Sha256: 9e109f417e710c8d3efe1ac8b13822a25f320a197597c168d4293c89faa05438
Contents?: true
Size: 1.98 KB
Versions: 1
Compression:
Stored size: 1.98 KB
Contents
require 'ms/error_rate/qvalue' module Ms ; end module Ms::ErrorRate ; end module Ms::ErrorRate::Qvalue ; end module Ms::ErrorRate::Qvalue::Pepxml module_function # returns an array of hit and qvalue pairs # retrieves the aaseq, charge, and all search_score keys and values for use # in the search_hit. caller must provide a sort_by block, where the best # hits are last. charge is an integer, and all other search scores are cast # as floats. returns the output filename. def target_decoy_qvalues(target_pepxml, decoy_pepxml, opt={}, &sort_by) # this is a list of high quality peptide hits associated with each group fields = [:aaseq, :charge] ss_names = [] have_ss_names = false (target_hits, decoy_hits) = [target_pepxml, decoy_pepxml].map do |file| # begin with aaseq, charge File.open(file) do |io| doc = Nokogiri::XML.parse(io, nil, nil, Nokogiri::XML::ParseOptions::DEFAULT_XML | Nokogiri::XML::ParseOptions::NOBLANKS) # we can work with namespaces, or just remove them ... doc.remove_namespaces! root = doc.root search_hits = root.xpath('//search_hit') search_hits.map do |search_hit| aaseq = search_hit['peptide'] charge = search_hit.parent.parent['assumed_charge'].to_i search_score_nodes = search_hit.children.select {|node| node.name == 'search_score' } ss_values = [] search_score_nodes.each do |node| ss_names << node['name'].to_sym unless have_ss_names ss_values << node['value'].to_f end have_ss_names = true [aaseq, charge, *ss_values] end end end fields.push(*ss_names) peptide_hit_class = Struct.new(*fields) (t_hits, d_hits) = [target_hits, decoy_hits].map {|hits| hits.map {|hit_values| peptide_hit_class.new(*hit_values) } } # hit and qvalue pairs Ms::ErrorRate::Qvalue.target_decoy_qvalues(t_hits, d_hits, :z_together => opt[:z_together], &sort_by) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ms-error_rate-0.0.10 | lib/ms/error_rate/qvalue/pepxml.rb |