Class: MS::Parser::MzXML::Regexp
- Inherits:
-
Object
- Object
- MS::Parser::MzXML::Regexp
- Includes:
- MS::Parser::MzXML
- Defined in:
- lib/ms/parser/mzxml/regexp.rb
Defined Under Namespace
Classes: MsRun
Constant Summary collapse
- @@first_scan_regexp =
/<scan /o
- @@scan_re =
def msrun(file, opts={}) end
/<scan.*?num="(\d+)"(.*?)<\/scan>/mo
Constants included from MS::Parser::MzXML
Constants included from XMLStyleParser
XMLStyleParser::File_required, XMLStyleParser::Parser_precedence
Constants included from MS::Parser
MS::Parser::Mzdata_regexp, MS::Parser::Mzxml_regexp
Instance Attribute Summary
Attributes included from XMLStyleParser
Attributes included from MS::Parser
Class Method Summary collapse
-
.by_scan_num(file, regex) ⇒ Object
(array will likely start at 1!).
- .precursor_mz_and_intensity_by_scan(file) ⇒ Object
-
.precursor_mz_by_scan(file) ⇒ Object
Returns array where array = precursorMz Parent scans armme not arrayed Values are strings.
Instance Method Summary collapse
-
#initialize(method = :msrun, version = '1.0') ⇒ Regexp
constructor
A new instance of Regexp.
-
#msrun(file) ⇒ Object
returns a MS::MsRun Object.
- #parse(file) ⇒ Object
Methods included from MS::Parser::MzXML
#_el, #basic_info, fix_bad_scan_tags, fix_bad_scan_tags_from_io, has_bad_scan_tag?, has_bad_scan_tag_from_io?, has_bad_scan_tag_from_string?, new, #precursor_mz_and_inten_by_scan, #precursor_mz_by_scan_for_path, #precursor_mz_by_scan_num, #scans_by_num, #start_and_end_mz
Methods included from XMLStyleParser
available_xml_parsers, choose_parser, require_parse_files, require_parsers
Methods included from MS::Parser
Constructor Details
#initialize(method = :msrun, version = '1.0') ⇒ Regexp
Returns a new instance of Regexp.
9 10 11 12 |
# File 'lib/ms/parser/mzxml/regexp.rb', line 9 def initialize(method=:msrun, version='1.0') @method = method @version = version end |
Class Method Details
.by_scan_num(file, regex) ⇒ Object
(array will likely start at 1!)
36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/ms/parser/mzxml/regexp.rb', line 36 def self.by_scan_num(file, regex) arr = [] File.open(file) do |fh| string = fh.read matches = string.scan(@@scan_re) matches.each do |matched| if inner_match = regex.match(matched[1]) index = matched[0].to_i arr[index] = yield(inner_match) end end end arr end |
.precursor_mz_and_intensity_by_scan(file) ⇒ Object
30 31 32 33 |
# File 'lib/ms/parser/mzxml/regexp.rb', line 30 def self.precursor_mz_and_intensity_by_scan(file) prec_re = /msLevel="2".*?<precursorMz precursorIntensity="([\d\.]+)".*?>([\d\.]+)<\/precursorMz>/mo self.by_scan_num(file, prec_re) {|match_obj| match_obj.captures.reverse} end |
.precursor_mz_by_scan(file) ⇒ Object
Returns array where array = precursorMz Parent scans armme not arrayed Values are strings. Array index likely starts at 1! @TODO: replace the use of a yield block
55 56 57 58 |
# File 'lib/ms/parser/mzxml/regexp.rb', line 55 def self.precursor_mz_by_scan(file) prec_re = /msLevel="2".*?<precursorMz.*?>([\d\.]+)<\/precursorMz>/mo self.by_scan_num(file, prec_re) {|match_obj| match_obj.captures[0]} end |
Instance Method Details
#msrun(file) ⇒ Object
returns a MS::MsRun Object
19 20 21 22 23 24 |
# File 'lib/ms/parser/mzxml/regexp.rb', line 19 def msrun(file) fh = File.open(file) get_header(fh) fh.close end |
#parse(file) ⇒ Object
14 15 16 |
# File 'lib/ms/parser/mzxml/regexp.rb', line 14 def parse(file) send(@method, file) end |