lib/MS/Reader/ImzML/Spectrum.pm

filter: Statementstmt 100% 9 / 9 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 100% 12 / 12 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« lib/MS/Reader/ImzML.pm ↑ Summary lib/MS/Reader/MzIdentML.pm »
1 package MS::Reader::ImzML::Spectrum;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use parent qw/MS::Reader::MzML::Spectrum/;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 use Carp;
9 use MS::CV qw/:MS :IMS/;
10  
11 sub _get_raw {
12  
13 my ($self, $array) = @_;
14  
15 # if external data flag not set, use inherited method
16 return $self->SUPER::_raw_data($array)
17 if (! defined $self->param(IMS_EXTERNAL_DATA, ref => $array) );
18  
19 my $offset = $self->param(IMS_EXTERNAL_OFFSET, ref => $array);
20 my $length = $self->param(IMS_EXTERNAL_ENCODED_LENGTH, ref => $array);
21 my $alength = $self->param(IMS_EXTERNAL_ARRAY_LENGTH, ref => $array);
22  
23 my $fh = $self->{__fh_ibd};
24 seek($fh, $offset, 0) or croak "Error seeking in IBD: $@";
25 my $r = read($fh, my $data, $length);
26 croak "Read length mismatch" if ($r != $length);
27  
28 return $data;
29  
30 }
31  
32 sub _get_code {
33  
34 my ($self, $array) = @_;
35  
36 return defined $self->param(IMS_8_BIT_INTEGER, ref => $array) ? 'c'
37 : defined $self->param(IMS_16_BIT_INTEGER, ref => $array) ? 's<'
38 : defined $self->param(IMS_32_BIT_INTEGER, ref => $array) ? 'l<'
39 : defined $self->param(IMS_64_BIT_INTEGER, ref => $array) ? 'q<'
40 : $self->SUPER::_get_code($array);
41  
42 }
43  
44 sub x {
45  
46 my ($self) = @_;
47 croak "Multiple scans in single spectrum not supported"
48 if ($self->{scanList}->{count} != 1);
49 my $ref = $self->{scanList}->{scan}->[0];
50 my $v = $self->param(IMS_POSITION_X, ref => $ref);
51 return $v;
52  
53 }
54  
55 sub y {
56  
57 my ($self) = @_;
58 croak "Multiple scans in single spectrum not supported"
59 if ($self->{scanList}->{count} != 1);
60 my $ref = $self->{scanList}->{scan}->[0];
61 my $v = $self->param(IMS_POSITION_Y, ref => $ref);
62 return $v
63  
64 }
65  
66 sub z {
67  
68 my ($self) = @_;
69 croak "Multiple scans in single spectrum not supported"
70 if ($self->{scanList}->{count} != 1);
71 my $ref = $self->{scanList}->{scan}->[0];
72 my $v = $self->param(IMS_POSITION_Z, ref => $ref);
73 return $v
74  
75 }
76  
77 sub coords {
78  
79 my ($self) = @_;
80 return (
81 $self->x,
82 $self->y,
83 $self->z,
84 );
85  
86 }
87  
88 1;
89  
90 __END__
« lib/MS/Reader/ImzML.pm ↑ Summary lib/MS/Reader/MzIdentML.pm »