File Coverage

lib/MS2/Scan.pm
Criterion Covered Total %
statement 10 12 83.3
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 14 16 87.5


line stmt bran cond sub pod time code
1             #
2             #===============================================================================
3             #
4             # FILE: Scan.pm
5             #
6             # DESCRIPTION:
7             #
8             # FILES: ---
9             # BUGS: ---
10             # NOTES: ---
11             # AUTHOR: Felipe da Veiga Leprevost (Leprevost, F.V.), leprevost@cpan.org
12             # ORGANIZATION:
13             # VERSION: 1.0
14             # CREATED: 07-10-2014 11:45:49
15             # REVISION: ---
16             #===============================================================================
17             package MS2::Scan;
18              
19 1     1   857 use strict;
  1         2  
  1         28  
20 1     1   4 use warnings;
  1         1  
  1         17  
21 1     1   7 use v5.12;
  1         2  
  1         24  
22 1     1   154 use Moose;
  0            
  0            
23             use namespace::autoclean;
24              
25             has 'FirstScan' => (
26             is => 'rw',
27             isa => 'Str',
28             );
29              
30             has 'SecondScan' => (
31             is => 'rw',
32             isa => 'Str',
33             );
34              
35             has 'PrecursorMZ' => (
36             is => 'rw',
37             isa => 'Str',
38             );
39              
40             has 'RetTime' => (
41             is => 'rw',
42             isa => 'Str',
43             );
44              
45             has 'PrecursorInt' => (
46             is => 'rw',
47             isa => 'Str',
48             );
49              
50             has 'IonInjectionTime' => (
51             is => 'rw',
52             isa => 'Str',
53             );
54              
55             has 'ActivationType' => (
56             is => 'rw',
57             isa => 'Str',
58             );
59              
60             has 'PrecursorFile' => (
61             is => 'rw',
62             isa => 'Str',
63             );
64              
65             has 'PrecursorScan' => (
66             is => 'rw',
67             isa => 'Str',
68             );
69              
70             has 'InstrumentType' => (
71             is => 'rw',
72             isa => 'Str',
73             );
74              
75             has 'Charge' => (
76             is => 'rw',
77             isa => 'Str',
78             );
79              
80             has 'Mass' => (
81             is => 'rw',
82             isa => 'Str',
83             );
84              
85             has 'DataMZ' => (
86             is => 'rw',
87             isa => 'ArrayRef',
88             default => sub { [] },
89             );
90              
91             has 'DataIntensity' => (
92             is => 'rw',
93             isa => 'ArrayRef',
94             default => sub { [] },
95             );
96              
97             sub parse {
98             my $self = shift;
99             my $line = shift;
100              
101             my @linepart = split(/\t/, $line);
102              
103             chomp $linepart[1] if $linepart[1];
104              
105             if ( $linepart[0] eq 'S' ) {
106            
107             $self->FirstScan($linepart[1]);
108             $self->SecondScan($linepart[2]);
109             $self->PrecursorMZ($linepart[3]);
110              
111             } elsif ( $linepart[0] eq 'I' ) {
112              
113             if ( $linepart[1] eq 'RetTime' ) {
114              
115             $self->RetTime($linepart[2]);
116              
117             } elsif ( $linepart[1] eq 'PrecursorInt' ) {
118              
119             $self->PrecursorInt($linepart[2]);
120              
121             } elsif ( $linepart[1] eq 'IonInjectionTime' ) {
122              
123             $self->IonInjectionTime($linepart[2]);
124              
125             } elsif ( $linepart[1] eq 'ActivationType' ) {
126              
127             $self->ActivationType($linepart[2]);
128              
129             } elsif ( $linepart[1] eq 'PrecursorFile' ) {
130              
131             $self->PrecursorFile($linepart[2]);
132              
133             } elsif ( $linepart[1] eq 'PrecursorScan' ) {
134              
135             $self->PrecursorScan($linepart[2]);
136              
137             } elsif ( $linepart[1] eq 'InstrumentType' ) {
138              
139             $self->InstrumentType($linepart[2]);
140             }
141            
142             } elsif ( $linepart[0] eq 'Z' ) {
143              
144             $self->Charge($linepart[1]);
145             $self->Mass($linepart[2]);
146              
147             } elsif ( $linepart[0] =~ m/^\d/ ) {
148              
149             my $dataMZ = $self->DataMZ;
150             my @dataMZ = @{$dataMZ};
151              
152             my $dataInt = $self->DataIntensity;
153             my @dataInt = @{$dataInt};
154              
155             my @datapart = split(/\s+/, $line);
156            
157             push(@dataMZ, $datapart[0]);
158             push(@dataInt, $datapart[1]);
159              
160             $self->DataMZ(\@dataMZ);
161             $self->DataIntensity(\@dataInt);
162             }
163              
164             }
165              
166             1;