MT_Plate_File.pm

filter: Statementstmt 15.0% 21 / 140 Branchbran 0.0% 0 / 36 Conditioncond 0.0% 0 / 12 MC/DCmcdc 0.0% 0 / 8 Subroutinesub 17.2% 5 / 29 Podpod n/a totaltotal 11.5% 26 / 225 CC 29 SCAR 31.5
CC
29
Cov
11%
guess_plate_type
90.0
col_index
42.0
row_index
20.0
CRAP 23.3
↑ Summary MT_Plate.pm »
1 package LIMS::MT_Plate_File;
2  
3 1 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 our $VERSION = '1.2';
7  
8 1 ▶use Microarray::File;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 # Access the LIMS::MT_Plate::* packages via imported constants instead of top-level package names
11 1 ▶sub import {
Subroutine import: called CC=2 SCAR=6.9
12 1 my $pkg = caller;
13 1 eval "*$pkg\::$_ = sub(){'LIMS::MT_Plate_File::$_'}" for qw(mt_plate_file simple_plate_file rowcol_plate_file);
14 }
15  
16 { package LIMS::MT_Plate_File::mt_plate_file;
17  
18 1 our @ISA = qw( simple_delimited_file );
19  
20 # standard format
21 # required fields; well name, sample name, sample type
22  
23 0 ▶ sub sort_data {
Subroutine sort_data: not called CC=1 SCAR=6.9
24 0 my $self = shift;
25 0 my $aaData = shift;
26 0 my $aCol_Headers = shift @$aaData;
27 0 my $col_num = @$aCol_Headers;
28 0 $self->column_num($col_num);
29 0 $self->set_data_fields($aCol_Headers);
30 0 $self->import_samples($aaData);
31 }
32 0 ▶ sub import_samples {
Subroutine import_samples: not called CC=2 SCAR=17.9
33 0 my $self = shift;
34 0 my $aaData = shift;
35
36 0 my $hhData_Rows = $self->get_data_rows;
37 0 for my $aData_Row (@$aaData){
38 0 $self->set_well($aData_Row->[$self->well_index],
39 $aData_Row->[$self->sample_index],
40 $aData_Row->[$self->sample_type_index]);
41 0 $self->count_well;
42 }
43 }
44 0 ▶ sub set_well {
Subroutine set_well: not called CC=1 SCAR=6.9
45 0 my $self = shift;
46 0 my $well = shift;
47 0 $self->{ "_$well" } = shift;
48 0 $self->{ "_$well"."_type" } = shift;
49 0 $self->record_well($well);
50 }
51 0 ▶ sub record_well {
Subroutine record_well: not called CC=1 SCAR=6.9
52 0 my $self = shift;
53 0 my $aWells = $self->get_all_wells;
54 0 push (@$aWells,shift);
55 }
56 0 ▶ sub get_all_wells {
Subroutine get_all_wells: not called CC=2 SCAR=17.9
57 0 my $self = shift;
58 0 ▶ unless (defined $self->{ _all_wells }){
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"_all_wells"}) 0 0 0
59 0 $self->{ _all_wells } = [ ];
60 }
61 0 $self->{ _all_wells };
62 }
63 0 ▶ sub get_sample {
Subroutine get_sample: not called CC=1 SCAR=6.9
64 0 my $self = shift;
65 0 my $well = shift;
66 0 $self->{ "_$well" };
67 }
68 0 ▶ sub get_sample_type {
Subroutine get_sample_type: not called CC=1 SCAR=6.9
69 0 my $self = shift;
70 0 my $well = shift;
71 0 $self->{ "_$well"."_type" };
72 }
73 0 ▶ sub get_all_samples {
Subroutine get_all_samples: not called CC=2 SCAR=17.9
74 0 my $self = shift;
75 0 my $aWells = $self->get_all_wells;
76 0 my $aSamples = [];
77 0 for my $well (@$aWells){
78 0 push (@$aSamples,$self->get_sample($well));
79 }
80 0 return $aSamples;
81 }
82 0 ▶ sub get_all_sample_types {
Subroutine get_all_sample_types: not called CC=2 SCAR=17.9
83 0 my $self = shift;
84 0 my $aWells = $self->get_all_wells;
85 0 my $aSample_Types = [];
86 0 for my $well (@$aWells){
87 0 push (@$aSample_Types,$self->get_sample_type($well));
88 }
89 0 return $aSample_Types;
90 }
91 0 ▶ sub plate_barcode {
Subroutine plate_barcode: not called CC=3 SCAR=24.8
92 0 my $self = shift;
93 0 ▶ if (@_){
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 0 0 0
94 0 $self->{ _plate_name } = shift;
95 } else {
96 0 ▶ if (defined $self->{ _plate_name }){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{'_plate_name'}) { } 0 0 0
97 0 return $self->{ _plate_name };
98 } else {
99 0 return $self->file_name;
100 }
101 }
102 }
103 0 ▶ sub plate_type {
Subroutine plate_type: not called CC=3 SCAR=24.8
104 0 my $self = shift;
105 0 ▶ if (@_){
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 0 0 0
106 0 $self->{ _plate_type } = shift;
107 } else {
108 0 ▶ if (defined $self->{ _plate_type }){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{'_plate_type'}) { } 0 0 0
109 0 return $self->{ _plate_type };
110 } else {
111 0 return $self->guessed_plate_type;
112 }
113 }
114 }
115 0 ▶ sub guessed_plate_type {
Subroutine guessed_plate_type: not called CC=2 SCAR=17.9
116 0 my $self = shift;
117 0 ▶ unless (defined $self->{ _guessed_plate_type }){
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"_guessed_plate_type"}) 0 0 0
118 0 $self->guess_plate_type;
119 }
120 0 $self->{ _guessed_plate_type };
121 }
122 0 ▶ sub guess_plate_type {
Subroutine guess_plate_type: not called CC=9 SCAR=45.0
123 0 my $self = shift;
124 0 my $aWells = $self->get_all_wells;
125 0 my ($aRows,$aCols) = get_well_coords($aWells);
126 0 my $last_row = uc $aRows->[-1];
127 0 my $last_col = $aCols->[-1];
128 0 my $plate_type;
129 0 ▶ if (($last_row eq "A")&&($last_col == 1)){
Branch: 4 branches
BranchTrueFalseTotal
if ($last_row eq 'A' and $last_col == 1) { } 0 0 0
elsif ($last_row le 'H' and $last_col <= 12) { } 0 0 0
elsif ($last_row le 'P' and $last_col <= 24) { } 0 0 0
elsif ($last_row le 'AF' and $last_col <= 48) { } 0 0 0
Condition0%0/3
$last_row eq "A" and $last_col == 1
!ll&&!rl&&r
000
MC/DC0%0/2
$last_row eq "A" and $last_col == 1
$last_row eq "A" $last_col == 1
Truth table0%0/3
A and B
A= $last_row eq "A"B= $last_col == 1
ABresult
0X0
100
111
130 0 $plate_type = "tube";
131 ▶ } elsif (($last_row le "H")&&($last_col <= 12)) {
Condition0%0/3
$last_row le "H" and $last_col <= 12
!ll&&!rl&&r
000
MC/DC0%0/2
$last_row le "H" and $last_col <= 12
$last_row le "H" $last_col <= 12
Truth table0%0/3
A and B
A= $last_row le "H"B= $last_col <= 12
ABresult
0X0
100
111
132 0 $plate_type = "mt_96";
133 ▶ } elsif (($last_row le "P")&&($last_col <= 24)) {
Condition0%0/3
$last_row le "P" and $last_col <= 24
!ll&&!rl&&r
000
MC/DC0%0/2
$last_row le "P" and $last_col <= 24
$last_row le "P" $last_col <= 24
Truth table0%0/3
A and B
A= $last_row le "P"B= $last_col <= 24
ABresult
0X0
100
111
134 0 $plate_type = "mt_384";
135 ▶ } elsif (($last_row le "AF")&&($last_col <= 48)) {
Condition0%0/3
$last_row le "AF" and $last_col <= 48
!ll&&!rl&&r
000
MC/DC0%0/2
$last_row le "AF" and $last_col <= 48
$last_row le "AF" $last_col <= 48
Truth table0%0/3
A and B
A= $last_row le "AF"B= $last_col <= 48
ABresult
0X0
100
111
136 0 $plate_type = "mt_1536";
137 } else {
138 0 die "LIMS::MT_Plate_File ERROR: Well name '$last_row$last_col' doesn't match supported plate formats";
139 }
140 0 $self->{ _guessed_plate_type } = $plate_type;
141 }
142 #Êsplits the column number and the row letter
143 0 ▶ sub get_well_coords {
Subroutine get_well_coords: not called CC=2 SCAR=17.9
144 0 my $aWells = shift;
145 0 my @aRows = ();
146 0 my @aCols = ();
147 0 for my $well (@$aWells){
148 0 my ($row,$col) = (uc $well, uc $well);
149 0 $row =~ s/\d//g;
150 0 $col =~ s/\D//g;
151 0 push (@aRows,$row);
152 0 push (@aCols,$col);
153 }
154 0 my @aSorted_Rows = sort @aRows;
155 0 my @aSorted_Cols = sort @aCols;
156 0 return (\@aSorted_Rows,\@aSorted_Cols);
157 }
158 0 ▶ sub wells_imported {
Subroutine wells_imported: not called CC=1 SCAR=6.9
159 0 my $self = shift;
160 0 $self->{ _wells_imported };
161 }
162 0 ▶ sub count_well {
Subroutine count_well: not called CC=1 SCAR=6.9
163 0 my $self = shift;
164 0 $self->{ _wells_imported }++;
165 }
166 0 ▶ sub well_index {
Subroutine well_index: not called CC=1 SCAR=6.9
167 0 my $self = shift;
168 0 $self->get_column_id('well');
169 }
170 0 ▶ sub sample_index {
Subroutine sample_index: not called CC=1 SCAR=6.9
171 0 my $self = shift;
172 0 $self->get_column_id('name');
173 }
174 0 ▶ sub sample_type_index {
Subroutine sample_type_index: not called CC=1 SCAR=6.9
175 0 my $self = shift;
176 0 $self->get_column_id('type');
177 }
178 }
179  
180 1 { package LIMS::MT_Plate_File::simple_plate_file;
181  
182 1 our @ISA = qw( mt_plate_file );
183  
184  
185 }
186  
187 1 { package LIMS::MT_Plate_File::rowcol_plate_file;
188  
189 1 our @ISA = qw( mt_plate_file );
190  
191 0 ▶ sub import_samples {
Subroutine import_samples: not called CC=2 SCAR=17.9
192 0 my $self = shift;
193 0 my $aaData = shift;
194
195 0 my $hhData_Rows = $self->get_data_rows;
196 0 for my $aData_Row (@$aaData){
197 0 my $well = $aData_Row->[$self->row_index].$aData_Row->[$self->col_index];
198 0 $self->set_well($well,
199 $aData_Row->[$self->sample_index],
200 $aData_Row->[$self->sample_type_index]);
201 0 $self->count_well;
202 }
203 }
204 0 ▶ sub row_index {
Subroutine row_index: not called CC=4 SCAR=30.0
205 0 my $self = shift;
206 0 ▶ if ($self->get_column_id('v1.1 96-well plate row')){
Branch: 3 branches
BranchTrueFalseTotal
if ($self->get_column_id('v1.1 96-well plate row')) { } 0 0 0
elsif ($self->get_column_id('Row')) { } 0 0 0
elsif ($self->get_column_id('row')) { } 0 0 0
207 0 return $self->get_column_id('v1.1 96-well plate row');
208 } elsif ($self->get_column_id('Row')){
209 0 return $self->get_column_id('Row');
210 } elsif ($self->get_column_id('row')){
211 0 return $self->get_column_id('row');
212 } else {
213 0 die "Can't find a column in the file that contains a 'Row' field\n";
214 }
215 }
216 0 ▶ sub col_index {
Subroutine col_index: not called CC=6 SCAR=37.4
217 0 my $self = shift;
218 0 ▶ if ($self->get_column_id('v1.1 96-well plate column')){
Branch: 5 branches
BranchTrueFalseTotal
if ($self->get_column_id('v1.1 96-well plate column')) { } 0 0 0
elsif ($self->get_column_id('Column')) { } 0 0 0
elsif ($self->get_column_id('Col')) { } 0 0 0
elsif ($self->get_column_id('column')) { } 0 0 0
elsif ($self->get_column_id('col')) { } 0 0 0
219 0 return $self->get_column_id('v1.1 96-well plate column');
220 } elsif ($self->get_column_id('Column')){
221 0 return $self->get_column_id('Column');
222 } elsif ($self->get_column_id('Col')){
223 0 return $self->get_column_id('Col');
224 } elsif ($self->get_column_id('column')){
225 0 return $self->get_column_id('column');
226 } elsif ($self->get_column_id('col')){
227 0 return $self->get_column_id('col');
228 } else {
229 0 die "Can't find a column in the file that contains a 'Column' field\n";
230 }
231 }
232 0 ▶ sub sample_index {
Subroutine sample_index: not called CC=1 SCAR=6.9
233 0 my $self = shift;
234 0 $self->get_column_id('International clone ID');
235 }
236 0 ▶ sub sample_type_index {
Subroutine sample_type_index: not called CC=1 SCAR=6.9
237 0 my $self = shift;
238 0 $self->get_column_id('Library');
239 }
240 }
241  
242 1 1;
243  
244 __END__
↑ Summary MT_Plate.pm »