Finnigan

 view release on metacpan or  search on metacpan

lib/Finnigan/ProfileChunk.pm  view on Meta::CPAN

use base 'Finnigan::Decoder';


my $preamble_0 = [
                  "first bin"     => ['V', 'UInt32'],
                  "nbins"         => ['V', 'UInt32'],
                 ];

my $preamble = [@$preamble_0, "fudge" => ['f<', 'Float32']];

sub decode {
  my $self;
  if ( $_[2] > 0 ) { # the layout flag in the packet header
    $self = Finnigan::Decoder->read($_[1], $preamble);
  }
  else {
    $self = Finnigan::Decoder->read($_[1], $preamble_0);
  }
  bless $self, $_[0]; # class
  return $self->iterate_scalar($_[1], $self->{data}->{"nbins"}->{value}, signal => ['f<', 'Float32']);
}

sub nbins {
  shift->{data}->{"nbins"}->{value};
}

sub first_bin {
  shift->{data}->{"first bin"}->{value};
}

sub fudge {
  shift->{data}->{fudge}->{value};
}

sub signal {
  shift->{data}->{"signal"}->{value};
}

1;
__END__

=head1 NAME

Finnigan::ProfileChunk -- a full-featured decoder for a single ProfileChunk structure

=head1 SYNOPSIS

  use Finnigan;

  my $chunk = Finnigan::ProfileChunk->decode( \*INPUT, $packet_header->layout );
  say $chunk->first_bin;
  say $chunk->fudge;
  my $nbins = $chunk->nbins;
  say $chunk->fudge;
  foreach my $i ( 0 .. $nbins - 1) {
    say $chunk->signal->[$i];
  }

=head1 DESCRIPTION

Finningan::ProfileChunk is a full-featured decoder for the ProfileChunk structure, a segment of a Profile. The data it generates contain the seek addresses, sizes and types of all decoded elements, no matter how small. That makes it very handy in the...

In performance-sensitive applications, the more lightweight Finnigan::Scan? module should be used, which includes Finnigan::Scan::ProfileChunk? and other related submodules. It can be used as a drop-in replacement for the full-featured modules, but i...

Every scan done in the B<profile mode> has a profile, which is either a time-domain signal or a frequency spectrum accumulated in histogram-like bins.

A profile can be either raw or filtered. Filtered profiles are sparse; they consist of separate data chunks. Each chunk consists of a contiguous range of bins containing the above-threshold signal. The bins whose values fall below a cerain threshold ...

One special case is raw profile, which preserves all data. Since there are no gaps in a raw profile, it is represented by a single chunk covering the entire range of bins, so the same container structure is suitable for complete profiles, as well as ...

The bins store the signal intensity, and the bin co-ordinates are typically the frequencies of Fourier-transformed signal. Since the bins are equally spaced in the frequency domain, only the first bin frequency is stored in each profile header. The b...

Each ProfileChunk structure stores the first bin index, the number of bins, and a list of bin intensities. Additionally, in some layouts, it stores a small floating-point value that most probably represents the instrument drift relative to its calibr...

=head2 Methods

=over 4

=item decode

The constructor method

=item nbins

Get the number of bins chunks in the chunk

=item first_bin

Get the index of the first bin in the chunk

=item fudge

Get the the value of conversion bias

=item signal

Get the list of bin values

=back

=head1 EXPORT

None

=head1 SEE ALSO

Finnigan::Profile

=head1 AUTHOR

Gene Selkov, E<lt>selkovjr@gmail.comE<gt>

=head1 COPYRIGHT AND LICENSE

Copyright (C) 2010 by Gene Selkov

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.10.0 or,
at your option, any later version of Perl 5 you may have available.




( run in 0.546 second using v1.01-cache-2.11-cpan-f56aa216473 )