The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

MS::Reader::MSn - A simple but complete MS1/MS2 parser

SYNOPSIS

    use MS::Reader::MSn;

    my $run = MS::Reader::MSn->new('run.ms2');

    while (my $spectrum = $run->next_spectrum) {
       
        # only want MS1
        next if ($spectrum->ms_level > 1);

        my $rt = $spectrum->rt;
        # see MS::Reader::MSn::Spectrum and MS::Spectrum for all available
        # methods

    }

    $spectrum = $run->fetch_spectrum(0);  # first spectrum

DESCRIPTION

MS::Reader::MSn is a parser for the MS1/MS2 formats for raw mass spectrometry data. It aims to provide complete access to the data contents while not being overburdened by detailed class infrastructure. Convenience methods are provided for accessing commonly used data.

INHERITANCE

MS::Reader::MSn is a subclass of MS::Reader and inherits the methods of this parental class. Please see the documentation for that class for details of available methods not detailed below.

METHODS

new

    my $run = MS::Reader::MSn->new( $fn,
        use_cache => 0,
        paranoid  => 0,
    );

Takes an input filename (required) and optional argument hash and returns an MS::Reader::MSn object. This constructor is inherited directly from MS::Reader. Available options include:

  • use_cache — cache fetched records in memory for repeat access (default: FALSE)

  • paranoid — when loading index from disk, recalculates MD5 checksum each time to make sure raw file hasn't changed. This adds (typically) a few seconds to load times. By default, only file size and mtime are checked.

next_spectrum

    while (my $s = $run->next_spectrum) {
        # do something
    }

Returns an MS::Reader::MSn::Spectrum object representing the next spectrum in the file, or undef if the end of records has been reached. Typically used to iterate over each spectrum in the run.

fetch_spectrum

    my $s = $run->fetch_spectrum($idx);

Takes a single argument (zero-based spectrum index) and returns an MS::Reader::MSn::Spectrum object representing the spectrum at that index. Throws an exception if the index is out of range.

goto_spectrum

    $run->goto_spectrum($idx);

Takes a single argument (zero-based spectrum index) and sets the spectrum record iterator to that index (for subsequent calls to next_spectrum).

n_spectra

    my $n = $run->n_spectra;

Returns the number of spectra present in the file.

curr_index

    my $idx = $run->curr_index;

Returns the index of the current iterator

get_index_by_id

    my $idx = $run->get_index_by_id($id);

Returns the index of the spectrum with ID $id

CAVEATS AND BUGS

The API is in alpha stage and is not guaranteed to be stable.

Please reports bugs or feature requests through the issue tracker at https://github.com/jvolkening/p5-MS/issues.

SEE ALSO

AUTHOR

Jeremy Volkening <jdv@base2bio.com>

COPYRIGHT AND LICENSE

Copyright 2015-2016 Jeremy Volkening

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.