Finnigan

 view release on metacpan or  search on metacpan

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

                             5 => "NSI",
                             6 => "TSI",
                             7 => "FDI",
                             8 => "MALDI",
                             9 => "GDI",
                             10 => "undefined"
                            },
             );

my %TYPE = (
            "corona"            => "on/off",
            "detector"          => "detector",
            "polarity"          => "polarity",
            "scan mode"         => "scan mode",
            "ms power"          => "ms power",
            "scan type"         => "scan type",
            "dependent"         => "bool",
            "ionization"        => "ionization",
            "wideband"          => "on/off",
            "analyzer"          => "analyzer",
           );

my @common_fields = (
                     "unknown byte[0]"   => ['C',    'UInt8'],
                     "unknown byte[1]"   => ['C',    'UInt8'],
                     "corona"            => ['C',    'UInt8'],
                     "detector"          => ['C',    'UInt8'],
                     "polarity"          => ['C',    'UInt8'],
                     "scan mode"         => ['C',    'UInt8'],
                     "ms power"          => ['C',    'UInt8'],
                     "scan type"         => ['C',    'UInt8'],
                     "unknown byte[8]"   => ['C',    'UInt8'],
                     "unknown byte[9]"   => ['C',    'UInt8'],
                     "dependent"         => ['C',    'UInt8'],
                     "ionization"        => ['C',    'UInt8'],
                     "unknown byte[12]"  => ['C',    'UInt8'],

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

                       3 => "ms3",
                       4 => "ms4",
                       5 => "ms5",
                       6 => "ms6",
                       7 => "ms7",
                       8 => "ms8",
                      );

# used in list()
my %name = (
            2 => "corona",
            3 => "detector",
            4 => "polarity",
            5 => "scan mode",
            6 => "ms power",
            7 => "scan type",

            10 => "dependent",
            11 => "ionization",

            32 => "wideband",

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

          : $_[0]->{data}->{$key}->{value};
    }
    else {
      $value = $_[0]->{data}->{$key}->{value};
    }
    $list[$i] = $value;
  }
  return @list;
}

sub corona {
  my $key = "corona";
  if ( $_[1] ) { # decode
    return $TYPE{$key}
      ? $SYMBOL{$TYPE{$key}}->{$_[0]->{data}->{$key}->{value}}
        : $_[0]->{data}->{$key}->{value};
  }
  else {
    shift->{data}->{corona}->{value};
  }
}

sub detector {
  my $key = "detector";
  if ( $_[1] ) {
    return $TYPE{$key}
      ? $SYMBOL{$TYPE{$key}}->{$_[0]->{data}->{$key}->{value}}
        : $_[0]->{data}->{$key}->{value};
  }

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

meaning if given a truthy argument. The word 'decode' is a good one to
use because it makes the code more readable, but any truthy value will
work.

=over 4

=item list(bool)

Returns an array containing all byte values of ScanEventPreamble

=item corona(bool)

Get the corona status (0:off or 1:on).

=item detector(bool)

Get the detector flag (0:valid or 1:undefined).

=item polarity(bool)

Get the polarity value (0:negative, 1:positive, 2:undefined)

=item scan_mode(bool)

t/Finnigan.t  view on Meta::CPAN


# ScanEventHierarchy
my $nsegs = Finnigan::Decoder->read(\*INPUT, ['nsegs' => ['V', 'UInt32']])->{data}->{nsegs}->{value};
is( $nsegs, 1, "Number of scan segments" );
my $nev = Finnigan::Decoder->read(\*INPUT, ['nev' => ['V', 'UInt32']])->{data}->{nev}->{value};
is( $nev, 4, "Number of scan event types in the first segment" );
# read the first scan event template
my $et = Finnigan::ScanEventTemplate->decode(\*INPUT, $header->version);
is( join('', $et->preamble->list), "1121111011030000000000004000255255255255000020004222111000000000100000000000000022000000000000002000000000000000200000000000000002140000", "ScanEventTemplate->ScanEventPreamble->list (1)" );
is( join(' ', $et->preamble->list('decode')), "1 1 undefined undefined positive profile MS1 Full 1 1 False ESI 0 0 0 0 0 0 0 0 0 0 0 0 4 0 0 0 255 255 255 255 Off 0 0 0 2 0 0 0 FTMS 2 2 2 1 1 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 2 0 ...
is( $et->preamble->corona('decode'), "undefined", "ScanEventTemplate->ScanEventPreamble->corona(decode) (1)" );
is( $et->preamble->detector('decode'), "undefined", "ScanEventTemplate->ScanEventPreamble->detector(decode) (1)" );
is( $et->preamble->polarity('decode'), "positive", "ScanEventTemplate->ScanEventPreamble->polarity(decode) (1)" );
is( $et->preamble->scan_mode('decode'), "profile", "ScanEventTemplate->ScanEventPreamble->scan_mode(decode) (1)" );
is( $et->preamble->ms_power('decode'), "MS1", "ScanEventTemplate->ScanEventPreamble->ms_power(decode) (1)" );
is( $et->preamble->scan_type('decode'), "Full", "ScanEventTemplate->ScanEventPreamble->scan_type(decode) (1)" );
is( $et->preamble->dependent, 0, "ScanEventTemplate->ScanEventPreamble->dependent (1)" );
is( $et->preamble->ionization('decode'), "ESI", "ScanEventTemplate->ScanEventPreamble->ionization(decode) (1)" );
is( $et->preamble->ionization('decode'), "ESI", "ScanEventTemplate->ScanEventPreamble->ionization(decode) (1)" );
is( $et->preamble->analyzer('decode'), "FTMS", "ScanEventTemplate->ScanEventPreamble->analyzer(decode) (1)" );
is( $et->preamble->stringify, "FTMS + p ESI Full ms", "ScanEventTemplate->ScanEventPreamble->stringify (1)" );

t/Finnigan.t  view on Meta::CPAN

ok( num_equal($index_entry->base_intensity, 861951.8125), "ScanIndexEntry->base_intensity (32)" );
ok( num_equal($index_entry->low_mz, 400), "ScanIndexEntry->low_mz (32)" );
ok( num_equal($index_entry->high_mz, 2000), "ScanIndexEntry->high_mz (32)" );
is( tell INPUT, $trailer_addr, "should have arrived at the start of ScanEvents stream" );

# read the ScanEvent stream (the "trailer")
my $trailer_length = Finnigan::Decoder->read(\*INPUT, ['length' => ['V', 'UInt32']])->{data}->{length}->{value};
is( $trailer_length, 33, "the trailer events count should be 33");
# read the first ScanEvent record
my $scan_event = Finnigan::ScanEvent->decode( \*INPUT, $header->version );
is( $scan_event->preamble->corona('decode'), "undefined", "ScanEvent->preamble->corona" );
is( $scan_event->preamble->analyzer('decode'), "FTMS", "ScanEvent->preamble->analyzer" );
is( $scan_event->preamble->polarity('decode'), "positive", "ScanEvent->preamble->polarity" );
is( $scan_event->preamble->scan_mode('decode'), "profile", "ScanEvent->preamble->scan_mode" );
is( $scan_event->preamble->ionization('decode'), "ESI", "ScanEvent->preamble->ionization" );
is( $scan_event->preamble->dependent, 0, "ScanEvent->preamble->dependent" );
is( $scan_event->preamble->scan_type('decode'), "Full", "ScanEvent->preamble->scan_type" );
is( $scan_event->preamble->ms_power('decode'), "MS1", "ScanEvent->preamble->ms_power" );
is( "$scan_event", "FTMS + p ESI Full ms [400.00-2000.00]", "ScanEvent->preamble->stringify" );
is( $scan_event->preamble->wideband('decode'), "Off", "ScanEvent->preamble->wideband" );
is( $scan_event->fraction_collector->stringify, "[400.00-2000.00]", "ScanEvent->fraction_collector->stringify" );

t/Finnigan.t  view on Meta::CPAN


# read the second ScanEvent record
$scan_event = Finnigan::ScanEvent->decode( \*INPUT, $header->version );
is( $scan_event->preamble->analyzer('decode'), "ITMS", "ScanEvent->preamble->analyzer (2)" );
is( $scan_event->preamble->polarity('decode'), "positive", "ScanEvent->preamble->polarity (2)" );
is( $scan_event->preamble->scan_mode('decode'), "profile", "ScanEvent->preamble->scan_mode (2)" );
is( $scan_event->preamble->dependent, 1, "ScanEvent->preamble->dependent (2)" );
is( $scan_event->preamble->scan_type('decode'), "Full", "ScanEvent->preamble->scan_type (2)" );
is( $scan_event->preamble->ms_power('decode'), "MS2", "ScanEvent->preamble->ms_power (2)" );
is( "$scan_event", 'ITMS + p ESI d Full ms2 445.12@cid35.00 [110.00-460.00]', "ScanEvent->preamble->stringify (2)" );
is( $scan_event->preamble->corona('decode'), "undefined", "ScanEvent->preamble->corona (2)" );
is( $scan_event->preamble->wideband('decode'), "Off", "ScanEvent->preamble->wideband (2)" );
is( $scan_event->fraction_collector->stringify, "[110.00-460.00]", "ScanEvent->fraction_collector->stringify (2)" );
is( $scan_event->np, 1, "ScanEvent->np" );
my $pr = join ", ", map {"$_"} @{$scan_event->precursors};
is( $pr, '445.12@cid35.00', "ScanEvent->precursors (2)" );
$Finnigan::activationMethod = 'ecd'; # cos we don't know where to look for it
$pr = $scan_event->reaction->stringify;
is( $pr, '445.12@ecd35.00', "ScanEvent->precursors (2): setting the activation method)" );
ok( num_equal( $scan_event->reaction->precursor, 445.121063232422), "ScanEvent->reaction, Reaction->precursor" );
ok( num_equal($scan_event->reaction(0)->precursor, 445.121063232422), "ScanEvent->reaction(0), Reaction->precursor" );



( run in 0.254 second using v1.01-cache-2.11-cpan-3cd7ad12f66 )