Finnigan

 view release on metacpan or  search on metacpan

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

              # frequencies have the reverse order
              next unless $x_conv <= $range->[0] and $x_conv >= $range->[1];
            }
          }
          print "$x_conv\t0\n";
        }
      }
    }
  }

  # get the last bin number in the last chunk
  if ( $add_zeroes ) {
    my $last_chunk = $chunks->[$data->{"peak count"}->{value} - 1];
    my $first_trailer_bin = $last_chunk->{data}->{"first bin"}->{value} + $last_chunk->{data}->{nbins}->{value};
    if ( $first_trailer_bin < $data->{nbins}->{value} ) {
      foreach my $bin ( $first_trailer_bin .. $self->{data}->{nbins}->{value} - 1 ) {
        my $x = $start + $bin * $step;
        my $x_conv = exists $self->{converter} ? &{$self->{converter}}($x) + $shift : $x;
        if ( $range ) {
          if ( exists $self->{converter} ) {
            next unless $x_conv >= $range->[0] and $x_conv <= $range->[1];
          }
          else {
            # frequencies have the reverse order
            next unless $x_conv <= $range->[0] and $x_conv >= $range->[1];
          }
        }
        print "$x_conv\t0\n";
      }
    }
    print "$range->[1]\t0\n";
  }
}

1;
__END__

=head1 NAME

Finnigan::Profile -- a full-featured decoder for Finnigan scan profiles

=head1 SYNOPSIS

  use Finnigan;

  say $entry->offset; # returns an offset from the start of scan data stream 
  say $entry->data_size;
  $entry->dump;
  my $profile = Finnigan::Profile->decode( \*INPUT, $packet_header->layout );
  say $profile->first_value;
  say $profile->nchunks;
  say $profile->nbins;
  $profile->set_converter( $converter_function_ref );
  my $bins = $profile->bins; # calls the converter
  my ($mz, $abundance) = @{$bins->[0]} # data in the first bin

=head1 DESCRIPTION

Finningan::Profile is a full-featured decoder for Finnigan scan
profiles. 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 exploration of the file format and in writing new code,
but it is not very efficient in production work.


In performance-sensitive applications, the more lightweight
Finnigan::Scan module should be used, which includes
Finnigan::Scan::Profile and other related submodules. It can be used
as a drop-in replacement for the full-featured modules, but it does
not store the seek addresses and object types, greatly reducing the
overhead.

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 are simply discarded,
leaving gaps in the profile -- the reason for the ProfileChunk
structure to exist.

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 for sparse ones.

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 bin width is common
for all bins and it is also stored in the same header. With these
data, it is possible to calculate the bin values based on the bin
indices.

The programs reading these data must convert the frequencies into the
M/z values using the conversion function specific to the type of
analyser used to acquire the signal. The calibrated coefficients for
this convesion function are stored in the ScanEvent structure (one
instance of this structure exists for every scan).

The B<bins> method of Finnigan::Profile returns the converted bins,
optionally filling the gaps with zeroes.

=head2 METHODS

=over 4

=item decode($stream, $layout)

The constructor method

=item nchunks

Get the number of chunks in the profile

=item nbins

Get the total number of bins in the profile



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