| 1 | package Microarray::File::GAL; | ||||||||||||||||||||||||||||
| 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 = '2.16'; | |||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 1 | require Microarray::File; | |||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | { package gal_file; | ||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 1 | our @ISA = qw( delimited_file ); | |||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 0 | ▶ | sub import_data { | ||||||||||||||||||||||||||
|
Subroutine
import_data: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 15 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 16 | 0 | ▶ | die "Microarray:GAL ERROR: This file does not have a '.gal' suffix\n" unless | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 17 | ($self->file_name =~ /\.gal$/i); | ||||||||||||||||||||||||||||
| 18 | 0 | my $aaData = $self->load_file_data; | |||||||||||||||||||||||||||
| 19 | 0 | $self->set_file_type(shift @$aaData); # File format (ATF) and version (1.0). | |||||||||||||||||||||||||||
| 20 | 0 | $self->set_head_count(shift @$aaData); # no. header records & data columns | |||||||||||||||||||||||||||
| 21 | 0 | $self->sort_data($aaData); | |||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||
| 23 | 0 | ▶ | sub DESTROY { | ||||||||||||||||||||||||||
|
Subroutine
DESTROY: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 24 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||
| 26 | #Êno need to set header row, but left this in to check its there! | ||||||||||||||||||||||||||||
| 27 | 0 | ▶ | sub set_file_type { | ||||||||||||||||||||||||||
|
Subroutine
set_file_type: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 28 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 29 | 0 | my $aRow = shift; | |||||||||||||||||||||||||||
| 30 | 0 | ▶ | die "Microarray::File::GAL ERROR: Gal file does not have an ATF header\n" unless ($aRow->[0] eq 'ATF'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | 0 | ▶ | sub file_format { | ||||||||||||||||||||||||||
|
Subroutine
file_format: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 33 | 0 | 'ATF' | |||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||
| 35 | 0 | ▶ | sub file_version { | ||||||||||||||||||||||||||
|
Subroutine
file_version: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 36 | 0 | '1.0'; | |||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | 0 | ▶ | sub set_head_count { | ||||||||||||||||||||||||||
|
Subroutine
set_head_count: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 39 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 40 | 0 | my $aRow = shift; | |||||||||||||||||||||||||||
| 41 | 0 | $self->header_rows($aRow->[0]); | |||||||||||||||||||||||||||
| 42 | 0 | $self->data_cols($aRow->[1]); | |||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||
| 44 | 0 | ▶ | sub header_rows { # second row of file, first value - number of rows before spot data | ||||||||||||||||||||||||||
|
Subroutine
header_rows: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 45 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 46 | @_ ? $self->{ _header_rows } = shift | ||||||||||||||||||||||||||||
| 47 | 0 | ▶ | : $self->{ _header_rows }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | 0 | ▶ | sub data_cols { # second row of file, second value - number of spot data columns | ||||||||||||||||||||||||||
|
Subroutine
data_cols: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 50 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 51 | @_ ? $self->{ _data_cols } = shift | ||||||||||||||||||||||||||||
| 52 | 0 | ▶ | : $self->{ _data_cols }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | 0 | ▶ | sub sort_data { | ||||||||||||||||||||||||||
|
Subroutine
sort_data: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 55 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 56 | 0 | my $aaData = shift; | |||||||||||||||||||||||||||
| 57 | 0 | $self->set_header_info($aaData); | |||||||||||||||||||||||||||
| 58 | 0 | $self->set_spot_info($aaData); | |||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | 0 | ▶ | sub set_header_info { | ||||||||||||||||||||||||||
|
Subroutine
set_header_info: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||
| 61 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 62 | 0 | my $aaData = shift; | |||||||||||||||||||||||||||
| 63 | 0 | my $hhBlock_Info = { }; | |||||||||||||||||||||||||||
| 64 | 0 | my $block_count = 0; | |||||||||||||||||||||||||||
| 65 | 0 | ▶ | while (my $aLine = shift @$aaData) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 66 | 0 | ▶ | if ($aLine->[0] =~ /^Block\d+=/){ | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 67 | 0 | $block_count++; | |||||||||||||||||||||||||||
| 68 | 0 | $aLine->[0] =~ s/\"//g; | |||||||||||||||||||||||||||
| 69 | 0 | $aLine->[0] =~ s/\s//g; | |||||||||||||||||||||||||||
| 70 | 0 | my ($block,$block_coords) = split(/=/,$aLine->[0]); | |||||||||||||||||||||||||||
| 71 | 0 | $block =~ s/Block//; | |||||||||||||||||||||||||||
| 72 | 0 | ▶ | warn "Microarray::File::GAL ERROR: Discrepency in header info\n". | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 73 | "\treading block $block, expecting block $block_count\n" | ||||||||||||||||||||||||||||
| 74 | unless ($block_count == $block); | ||||||||||||||||||||||||||||
| 75 | 0 | my @aCoordinates = split(/,/, $block_coords); | |||||||||||||||||||||||||||
| 76 | 0 | $self->set_block_layout($aCoordinates[0],$aCoordinates[1]); | |||||||||||||||||||||||||||
| 77 | 0 | $hhBlock_Info->{ $block } = { coordinates => \@aCoordinates, spots => [] }; | |||||||||||||||||||||||||||
| 78 | } elsif ($aLine->[0] =~ /=/){ | ||||||||||||||||||||||||||||
| 79 | 0 | my ($key,$value) = split(/=/,$aLine->[0]); | |||||||||||||||||||||||||||
| 80 | 0 | $self->{ "_$key" } = $value; | |||||||||||||||||||||||||||
| 81 | 0 | $self->add_header_key($key); | |||||||||||||||||||||||||||
| 82 | } else { | ||||||||||||||||||||||||||||
| 83 | 0 | $self->set_spot_indexes($aLine); | |||||||||||||||||||||||||||
| 84 | 0 | last; | |||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | 0 | $self->block_count($block_count); | |||||||||||||||||||||||||||
| 88 | 0 | $self->{ _block_info } = $hhBlock_Info; | |||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||
| 90 | 0 | ▶ | sub block_layout { | ||||||||||||||||||||||||||
|
Subroutine
block_layout: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||
| 91 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 92 | 0 | ▶ | unless (defined $self->{ _block_layout }){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 93 | 0 | $self->{ _block_layout } = { row => {}, col => {} }; | |||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||
| 95 | 0 | ▶ | if (@_){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 96 | 0 | my $row_col = shift; | |||||||||||||||||||||||||||
| 97 | 0 | ▶ | return unless ($row_col =~ /row|col/i); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 98 | 0 | my $hLayout = $self->{ _block_layout }; | |||||||||||||||||||||||||||
| 99 | 0 | return $hLayout->{ $row_col }; | |||||||||||||||||||||||||||
| 100 | } else { | ||||||||||||||||||||||||||||
| 101 | 0 | return $self->{ _block_layout }; | |||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||
| 104 | 0 | ▶ | sub block_rows { | ||||||||||||||||||||||||||
|
Subroutine
block_rows: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 105 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 106 | 0 | my $hRows = $self->block_layout('row'); | |||||||||||||||||||||||||||
| 107 | 0 | return scalar(keys %$hRows); | |||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||
| 109 | 0 | ▶ | sub block_cols { | ||||||||||||||||||||||||||
|
Subroutine
block_cols: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 110 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 111 | 0 | my $hCols = $self->block_layout('col'); | |||||||||||||||||||||||||||
| 112 | 0 | return scalar(keys %$hCols); | |||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||
| 114 | 0 | ▶ | sub set_block_layout { | ||||||||||||||||||||||||||
|
Subroutine
set_block_layout: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 115 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 116 | 0 | my $block_row = shift; | |||||||||||||||||||||||||||
| 117 | 0 | my $block_col = shift; | |||||||||||||||||||||||||||
| 118 | 0 | my $hLayout = $self->block_layout; | |||||||||||||||||||||||||||
| 119 | 0 | $$hLayout{ row }{ $block_row }++; | |||||||||||||||||||||||||||
| 120 | 0 | $$hLayout{ col }{ $block_col }++; | |||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||
| 122 | 0 | ▶ | sub set_spot_indexes { | ||||||||||||||||||||||||||
|
Subroutine
set_spot_indexes: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 123 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 124 | 0 | my $aLine = shift; | |||||||||||||||||||||||||||
| 125 | 0 | my $hIndexes = {}; | |||||||||||||||||||||||||||
| 126 | 0 | ▶ | for (my $i=0; $i<@$aLine; $i++){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 127 | 0 | my $key = $aLine->[$i]; | |||||||||||||||||||||||||||
| 128 | 0 | $hIndexes->{ $key } = $i; | |||||||||||||||||||||||||||
| 129 | 0 | $hIndexes->{ $i } = $key; | |||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||
| 131 | 0 | ▶ | $self->gal_type('v4.1') if (defined $hIndexes->{ Annotation }); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 132 | 0 | $self->{ _spot_indexes } = $hIndexes; | |||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||
| 134 | 0 | ▶ | sub get_spot_indexes { | ||||||||||||||||||||||||||
|
Subroutine
get_spot_indexes: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 135 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 136 | 0 | my $hIndexes = $self->{ _spot_indexes }; | |||||||||||||||||||||||||||
| 137 | 0 | ▶ | if (@_){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 138 | 0 | my $key = shift; | |||||||||||||||||||||||||||
| 139 | 0 | return $hIndexes->{ $key }; | |||||||||||||||||||||||||||
| 140 | } else { | ||||||||||||||||||||||||||||
| 141 | 0 | return $hIndexes; | |||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||
| 144 | 0 | ▶ | sub gal_type { | ||||||||||||||||||||||||||
|
Subroutine
gal_type: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 145 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 146 | 0 | ▶ | if (@_){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 147 | 0 | $self->{ _gal_type } = shift; | |||||||||||||||||||||||||||
| 148 | } else { | ||||||||||||||||||||||||||||
| 149 | 0 | ▶ | if (defined $self->{ _gal_type }){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 150 | 0 | $self->{ _gal_type }; | |||||||||||||||||||||||||||
| 151 | } else { | ||||||||||||||||||||||||||||
| 152 | 0 | $self->default_gal_type; | |||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||
| 156 | 0 | ▶ | sub default_gal_type { | ||||||||||||||||||||||||||
|
Subroutine
default_gal_type: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 157 | 0 | 'v1.0'; | |||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||
| 159 | 0 | ▶ | sub add_header_key { | ||||||||||||||||||||||||||
|
Subroutine
add_header_key: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 160 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 161 | 0 | my $aHeader_Keys = $self->header_keys; | |||||||||||||||||||||||||||
| 162 | 0 | push (@$aHeader_Keys,shift); | |||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||
| 164 | # array ref containing the keys (names) of corresponding header values | ||||||||||||||||||||||||||||
| 165 | 0 | ▶ | sub header_keys { | ||||||||||||||||||||||||||
|
Subroutine
header_keys: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 166 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 167 | 0 | ▶ | unless (defined $self->{ _header_keys }){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 168 | 0 | $self->{ _header_keys } = []; | |||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||
| 170 | 0 | $self->{ _header_keys }; | |||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||
| 172 | 0 | ▶ | sub get_header_value { | ||||||||||||||||||||||||||
|
Subroutine
get_header_value: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 173 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 174 | 0 | my $key = shift; | |||||||||||||||||||||||||||
| 175 | 0 | return $self->{ "_$key" }; | |||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||
| 177 | 0 | ▶ | sub get_block_info { | ||||||||||||||||||||||||||
|
Subroutine
get_block_info: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 178 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 179 | 0 | my $hhBlock_Info = $self->{ _block_info }; | |||||||||||||||||||||||||||
| 180 | 0 | ▶ | if (@_){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 181 | 0 | my $block = shift; | |||||||||||||||||||||||||||
| 182 | die "Microarray::File::GAL ERROR: Block number out of range\ntried to get block $block\n" | ||||||||||||||||||||||||||||
| 183 | 0 | ▶ | unless (defined $hhBlock_Info->{ $block }); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 184 | 0 | $hhBlock_Info->{ $block }; | |||||||||||||||||||||||||||
| 185 | } else { | ||||||||||||||||||||||||||||
| 186 | 0 | $hhBlock_Info; | |||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||
| 189 | 0 | ▶ | sub get_block_coords { | ||||||||||||||||||||||||||
|
Subroutine
get_block_coords: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 190 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 191 | 0 | my $hBlock_Info = $self->get_block_info(shift); | |||||||||||||||||||||||||||
| 192 | 0 | return $hBlock_Info->{ coordinates }; | |||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||
| 194 | 0 | ▶ | sub get_block_spots { | ||||||||||||||||||||||||||
|
Subroutine
get_block_spots: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 195 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 196 | 0 | my $hBlock_Info = $self->get_block_info(shift); | |||||||||||||||||||||||||||
| 197 | 0 | return $hBlock_Info->{ spots }; | |||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||
| 199 | 0 | ▶ | sub block_x_origin { | ||||||||||||||||||||||||||
|
Subroutine
block_x_origin: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 200 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 201 | 0 | my $aCoordinates = $self->get_block_coords(shift); | |||||||||||||||||||||||||||
| 202 | 0 | return $aCoordinates->[0]; | |||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||
| 204 | 0 | ▶ | sub block_y_origin { | ||||||||||||||||||||||||||
|
Subroutine
block_y_origin: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 205 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 206 | 0 | my $aCoordinates = $self->get_block_coords(shift); | |||||||||||||||||||||||||||
| 207 | 0 | return $aCoordinates->[1]; | |||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||
| 209 | # should the feature diameter ever change between blocks? | ||||||||||||||||||||||||||||
| 210 | 0 | ▶ | sub block_feature_diameter { # in um | ||||||||||||||||||||||||||
|
Subroutine
block_feature_diameter: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 211 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 212 | 0 | my $aCoordinates = $self->get_block_coords(shift); | |||||||||||||||||||||||||||
| 213 | 0 | return $aCoordinates->[2]; | |||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||
| 215 | # number of columns in the block | ||||||||||||||||||||||||||||
| 216 | # from the header block info | ||||||||||||||||||||||||||||
| 217 | # for actual counted cols, use counted_cols($block) | ||||||||||||||||||||||||||||
| 218 | 0 | ▶ | sub block_x_features { | ||||||||||||||||||||||||||
|
Subroutine
block_x_features: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 219 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 220 | 0 | my $block = shift; | |||||||||||||||||||||||||||
| 221 | 0 | my $aCoordinates = $self->get_block_coords($block); | |||||||||||||||||||||||||||
| 222 | 0 | ▶ | warn "Microarray::File::GAL ERROR: Discrepency in column count for block $block.\n". | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 223 | $aCoordinates->[3]." columns set in header information, ".$self->counted_cols($block)." columns counted\n" | ||||||||||||||||||||||||||||
| 224 | unless ($aCoordinates->[3] == $self->counted_cols($block)); | ||||||||||||||||||||||||||||
| 225 | 0 | return $aCoordinates->[3]; | |||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||
| 227 | 0 | ▶ | sub block_x_spacing { # column spacing in um | ||||||||||||||||||||||||||
|
Subroutine
block_x_spacing: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 228 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 229 | 0 | my $aCoordinates = $self->get_block_coords(shift); | |||||||||||||||||||||||||||
| 230 | 0 | return $aCoordinates->[4]; | |||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||
| 232 | # number of rows in the block | ||||||||||||||||||||||||||||
| 233 | # from the header block info | ||||||||||||||||||||||||||||
| 234 | # for actual counted rows, use counted_rows($block) | ||||||||||||||||||||||||||||
| 235 | 0 | ▶ | sub block_y_features { | ||||||||||||||||||||||||||
|
Subroutine
block_y_features: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 236 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 237 | 0 | my $block = shift; | |||||||||||||||||||||||||||
| 238 | 0 | my $aCoordinates = $self->get_block_coords($block); | |||||||||||||||||||||||||||
| 239 | 0 | ▶ | warn "Microarray::File::GAL ERROR: Discrepency in row count for block $block.\n". | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 240 | $aCoordinates->[5]." rows set in header information, ".$self->counted_rows($block)." rows counted\n" | ||||||||||||||||||||||||||||
| 241 | unless ($aCoordinates->[5] == $self->counted_rows($block)); | ||||||||||||||||||||||||||||
| 242 | 0 | return $aCoordinates->[5]; | |||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||
| 244 | 0 | ▶ | sub block_y_spacing { # row spacing in um | ||||||||||||||||||||||||||
|
Subroutine
block_y_spacing: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 245 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 246 | 0 | my $aCoordinates = $self->get_block_coords(shift); | |||||||||||||||||||||||||||
| 247 | 0 | return $aCoordinates->[6]; | |||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||
| 249 | 0 | ▶ | sub block_count { | ||||||||||||||||||||||||||
|
Subroutine
block_count: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||
| 250 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 251 | 0 | ▶ | if (@_){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 252 | 0 | $self->{ _blocks } = shift; | |||||||||||||||||||||||||||
| 253 | } else { | ||||||||||||||||||||||||||||
| 254 | 0 | ▶ | if (defined $self->{ _BlockCount }){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 255 | warn "Microarray::File::GAL ERROR: Discrepency in block count.\n". | ||||||||||||||||||||||||||||
| 256 | $self->{ _BlockCount }." blocks set in the header information, ".$self->{ _blocks }." blocks counted\n" | ||||||||||||||||||||||||||||
| 257 | 0 | ▶ | unless ($self->{ _BlockCount } == $self->{ _blocks }); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||
| 259 | 0 | $self->{ _blocks }; | |||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||
| 262 | 0 | ▶ | sub set_spot_info { | ||||||||||||||||||||||||||
|
Subroutine
set_spot_info: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||
| 263 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 264 | 0 | my $aaData = shift; | |||||||||||||||||||||||||||
| 265 | 0 | my $block = 0; | |||||||||||||||||||||||||||
| 266 | 0 | my $spot_count = 0; | |||||||||||||||||||||||||||
| 267 | 0 | my $hIndexes = $self->get_spot_indexes; | |||||||||||||||||||||||||||
| 268 | 0 | ▶ | while (my $aLine = shift @$aaData){ # spot header row has already been shifted off | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 269 | 0 | ▶ | unless ($block == $$aLine[$hIndexes->{Block}]){ # BLOCK MIGHT NOT BE INDEX[0] !!! | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 270 | 0 | $block = $$aLine[$hIndexes->{Block}]; | |||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||
| 272 | 0 | ▶ | if (($$aLine[$hIndexes->{Name}])&&($$aLine[$hIndexes->{Name}] ne '')){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$$aLine[$hIndexes->{"Name"}] and $$aLine[$hIndexes->{"Name"}] ne ""
MC/DC0%0/2
$$aLine[$hIndexes->{"Name"}] and $$aLine[$hIndexes->{"Name"}] ne ""
$$aLine[$hIndexes->{"Name"}]
$$aLine[$hIndexes->{"Name"}] ne ""
Truth table0%0/3
A and B
A= $$aLine[$hIndexes->{"Name"}]B= $$aLine[$hIndexes->{"Name"}] ne ""
| |||||||||||||||||||||||||||||
| 273 | 0 | $self->set_spot($aLine,$block); | |||||||||||||||||||||||||||
| 274 | 0 | $spot_count++; | |||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||
| 277 | 0 | $self->set_spot_count($spot_count); | |||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||
| 279 | 0 | ▶ | sub set_spot { | ||||||||||||||||||||||||||
|
Subroutine
set_spot: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 280 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 281 | 0 | my $aLine = shift; | |||||||||||||||||||||||||||
| 282 | 0 | my $block = shift; | |||||||||||||||||||||||||||
| 283 | 0 | my $hIndexes = $self->get_spot_indexes; | |||||||||||||||||||||||||||
| 284 | 0 | my $hInfo = { Name => $$aLine[$hIndexes->{Name}], ID => $$aLine[$hIndexes->{ID}] }; | |||||||||||||||||||||||||||
| 285 | 0 | ▶ | if ($self->gal_type eq 'v4.1'){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 286 | 0 | $hInfo->{Annotation} = $$aLine[$hIndexes->{Annotation}]; | |||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||
| 288 | 0 | my $ahSpots = $self->get_block_spots($block); | |||||||||||||||||||||||||||
| 289 | 0 | $$ahSpots[ $$aLine[$hIndexes->{Column}] ][ $$aLine[$hIndexes->{Row}] ] = $hInfo; | |||||||||||||||||||||||||||
| 290 | 0 | $self->count_block_rowcols($block,$$aLine[$hIndexes->{Column}],$$aLine[$hIndexes->{Row}]); | |||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||
| 292 | 0 | ▶ | sub count_block_rowcols { | ||||||||||||||||||||||||||
|
Subroutine
count_block_rowcols: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 293 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 294 | 0 | my $block = shift; | |||||||||||||||||||||||||||
| 295 | 0 | my $col = shift; | |||||||||||||||||||||||||||
| 296 | 0 | my $row = shift; | |||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||
| 298 | 0 | ▶ | if ($col > $self->counted_cols($block)){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 299 | 0 | $self->set_counted_cols($block,$col); | |||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||
| 301 | 0 | ▶ | if ($row > $self->counted_rows($block)){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 302 | 0 | $self->set_counted_rows($block,$row); | |||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||
| 305 | # returns number of cols in a specific block, counted from set_spot() | ||||||||||||||||||||||||||||
| 306 | # different to col_count(), which compares col count in all blocks | ||||||||||||||||||||||||||||
| 307 | 0 | ▶ | sub counted_cols { | ||||||||||||||||||||||||||
|
Subroutine
counted_cols: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 308 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 309 | 0 | my $block = shift; | |||||||||||||||||||||||||||
| 310 | 0 | ▶ | unless (defined $self->{ "_Col_Count_block_$block" }){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 311 | 0 | $self->{ "_Col_Count_block_$block" } = 0; | |||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||
| 313 | 0 | $self->{ "_Col_Count_block_$block" }; | |||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||
| 315 | 0 | ▶ | sub set_counted_cols { | ||||||||||||||||||||||||||
|
Subroutine
set_counted_cols: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 316 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 317 | 0 | my $block = shift; | |||||||||||||||||||||||||||
| 318 | 0 | $self->{ "_Col_Count_block_$block" } = shift; | |||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||
| 320 | # returns number of rows in a specific block, counted from set_spot() | ||||||||||||||||||||||||||||
| 321 | # different to row_count(), which compares row count in all blocks | ||||||||||||||||||||||||||||
| 322 | 0 | ▶ | sub counted_rows { | ||||||||||||||||||||||||||
|
Subroutine
counted_rows: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 323 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 324 | 0 | my $block = shift; | |||||||||||||||||||||||||||
| 325 | 0 | ▶ | unless (defined $self->{ "_Row_Count_block_$block" }){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 326 | 0 | $self->{ "_Row_Count_block_$block" } = 0; | |||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||
| 328 | 0 | $self->{ "_Row_Count_block_$block" }; | |||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||
| 330 | 0 | ▶ | sub set_counted_rows { | ||||||||||||||||||||||||||
|
Subroutine
set_counted_rows: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 331 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 332 | 0 | my $block = shift; | |||||||||||||||||||||||||||
| 333 | 0 | $self->{ "_Row_Count_block_$block" } = shift; | |||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||
| 335 | # accepts (block,col,row) | ||||||||||||||||||||||||||||
| 336 | 0 | ▶ | sub get_spot_info { | ||||||||||||||||||||||||||
|
Subroutine
get_spot_info: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 337 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 338 | 0 | my $ahSpots = $self->get_block_spots(shift); | |||||||||||||||||||||||||||
| 339 | 0 | return $$ahSpots[ shift ][ shift ]; | |||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||
| 341 | # accepts (block,col,row) | ||||||||||||||||||||||||||||
| 342 | 0 | ▶ | sub get_spot_name { | ||||||||||||||||||||||||||
|
Subroutine
get_spot_name: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 343 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 344 | 0 | my $hInfo = $self->get_spot_info(shift,shift,shift); | |||||||||||||||||||||||||||
| 345 | 0 | return $hInfo->{ Name }; | |||||||||||||||||||||||||||
| 346 | } | ||||||||||||||||||||||||||||
| 347 | # accepts (block,col,row,name) | ||||||||||||||||||||||||||||
| 348 | 0 | ▶ | sub set_spot_name { | ||||||||||||||||||||||||||
|
Subroutine
set_spot_name: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 349 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 350 | 0 | my $hInfo = $self->get_spot_info(shift,shift,shift); | |||||||||||||||||||||||||||
| 351 | 0 | $hInfo->{ Name } = shift; | |||||||||||||||||||||||||||
| 352 | } | ||||||||||||||||||||||||||||
| 353 | # accepts (block,col,row) | ||||||||||||||||||||||||||||
| 354 | 0 | ▶ | sub get_spot_id { | ||||||||||||||||||||||||||
|
Subroutine
get_spot_id: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 355 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 356 | 0 | my $hInfo = $self->get_spot_info(shift,shift,shift); | |||||||||||||||||||||||||||
| 357 | 0 | return $hInfo->{ ID }; | |||||||||||||||||||||||||||
| 358 | } | ||||||||||||||||||||||||||||
| 359 | # accepts (block,col,row,id) | ||||||||||||||||||||||||||||
| 360 | 0 | ▶ | sub set_spot_id { | ||||||||||||||||||||||||||
|
Subroutine
set_spot_id: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 361 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 362 | 0 | my $hInfo = $self->get_spot_info(shift,shift,shift); | |||||||||||||||||||||||||||
| 363 | 0 | $hInfo->{ ID } = shift; | |||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||
| 365 | # accepts (block,col,row) | ||||||||||||||||||||||||||||
| 366 | 0 | ▶ | sub get_spot_annotation { | ||||||||||||||||||||||||||
|
Subroutine
get_spot_annotation: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 367 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 368 | 0 | my $hInfo = $self->get_spot_info(shift,shift,shift); | |||||||||||||||||||||||||||
| 369 | 0 | return $hInfo->{ Annotation }; | |||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||
| 371 | # accepts (block,col,row,annotation) | ||||||||||||||||||||||||||||
| 372 | 0 | ▶ | sub set_spot_annotation { | ||||||||||||||||||||||||||
|
Subroutine
set_spot_annotation: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 373 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 374 | 0 | my $hInfo = $self->get_spot_info(shift,shift,shift); | |||||||||||||||||||||||||||
| 375 | 0 | $hInfo->{ Annotation } = shift; | |||||||||||||||||||||||||||
| 376 | } | ||||||||||||||||||||||||||||
| 377 | 0 | ▶ | sub set_spot_count { | ||||||||||||||||||||||||||
|
Subroutine
set_spot_count: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 378 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 379 | 0 | $self->{ '_SpotCount' } = shift; | |||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||
| 381 | 0 | ▶ | sub spot_count { | ||||||||||||||||||||||||||
|
Subroutine
spot_count: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 382 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 383 | 0 | $self->{ '_SpotCount' }; | |||||||||||||||||||||||||||
| 384 | } | ||||||||||||||||||||||||||||
| 385 | # return number of rows in each block if they are all the same | ||||||||||||||||||||||||||||
| 386 | # otherwise returns -1 | ||||||||||||||||||||||||||||
| 387 | # if you need actual row count for a specific block, use counted_rows($block) | ||||||||||||||||||||||||||||
| 388 | 0 | ▶ | sub row_count { | ||||||||||||||||||||||||||
|
Subroutine
row_count: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 389 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 390 | 0 | ▶ | unless (defined $self->{ _row_count }){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 391 | 0 | $self->set_row_count; | |||||||||||||||||||||||||||
| 392 | } | ||||||||||||||||||||||||||||
| 393 | 0 | $self->{ _row_count }; | |||||||||||||||||||||||||||
| 394 | } | ||||||||||||||||||||||||||||
| 395 | 0 | ▶ | sub set_row_count { | ||||||||||||||||||||||||||
|
Subroutine
set_row_count: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||
| 396 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 397 | 0 | my $blocks = $self->block_count; | |||||||||||||||||||||||||||
| 398 | 0 | my %hRows = (); | |||||||||||||||||||||||||||
| 399 | 0 | ▶ | for (my $i=1; $i<=$blocks; $i++){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 400 | 0 | my $rows = $self->counted_rows($i); | |||||||||||||||||||||||||||
| 401 | 0 | $hRows{$rows}++; | |||||||||||||||||||||||||||
| 402 | } | ||||||||||||||||||||||||||||
| 403 | 0 | my @aRows = keys %hRows; | |||||||||||||||||||||||||||
| 404 | 0 | ▶ | if (@aRows == 1){ | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 405 | 0 | $self->{ _row_count } = $aRows[0]; | |||||||||||||||||||||||||||
| 406 | } elsif (@aRows > 1){ | ||||||||||||||||||||||||||||
| 407 | 0 | $self->{ _row_count } = -1; | |||||||||||||||||||||||||||
| 408 | } else { | ||||||||||||||||||||||||||||
| 409 | 0 | return; | |||||||||||||||||||||||||||
| 410 | } | ||||||||||||||||||||||||||||
| 411 | } | ||||||||||||||||||||||||||||
| 412 | # return number of columns in each block if they are all the same | ||||||||||||||||||||||||||||
| 413 | # otherwise returns -1 | ||||||||||||||||||||||||||||
| 414 | # if you need actual column count for a specific block, use counted_cols($block) | ||||||||||||||||||||||||||||
| 415 | 0 | ▶ | sub col_count { | ||||||||||||||||||||||||||
|
Subroutine
col_count: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 416 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 417 | 0 | ▶ | unless (defined $self->{ _col_count }){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 418 | 0 | $self->set_col_count; | |||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||
| 420 | 0 | $self->{ _col_count }; | |||||||||||||||||||||||||||
| 421 | } | ||||||||||||||||||||||||||||
| 422 | 0 | ▶ | sub set_col_count { | ||||||||||||||||||||||||||
|
Subroutine
set_col_count: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||
| 423 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 424 | 0 | my $blocks = $self->block_count; | |||||||||||||||||||||||||||
| 425 | 0 | my %hCols = (); | |||||||||||||||||||||||||||
| 426 | 0 | ▶ | for (my $i=1; $i<=$blocks; $i++){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 427 | 0 | my $cols = $self->counted_cols($i); | |||||||||||||||||||||||||||
| 428 | 0 | $hCols{$cols}++; | |||||||||||||||||||||||||||
| 429 | } | ||||||||||||||||||||||||||||
| 430 | 0 | my @aCols = keys %hCols; | |||||||||||||||||||||||||||
| 431 | 0 | ▶ | if (@aCols == 1){ | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 432 | 0 | $self->{ _col_count } = $aCols[0]; | |||||||||||||||||||||||||||
| 433 | } elsif (@aCols > 1){ | ||||||||||||||||||||||||||||
| 434 | 0 | $self->{ _col_count } = -1; | |||||||||||||||||||||||||||
| 435 | } else { | ||||||||||||||||||||||||||||
| 436 | 0 | return; | |||||||||||||||||||||||||||
| 437 | } | ||||||||||||||||||||||||||||
| 438 | } | ||||||||||||||||||||||||||||
| 439 | # return feature_diameter of each block if all the same | ||||||||||||||||||||||||||||
| 440 | # otherwise returns -1 | ||||||||||||||||||||||||||||
| 441 | 0 | ▶ | sub feature_diameter { | ||||||||||||||||||||||||||
|
Subroutine
feature_diameter: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 442 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 443 | 0 | ▶ | unless (defined $self->{ _feature_diameter }){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 444 | 0 | $self->set_feature_diameter; | |||||||||||||||||||||||||||
| 445 | } | ||||||||||||||||||||||||||||
| 446 | 0 | $self->{ _feature_diameter }; | |||||||||||||||||||||||||||
| 447 | } | ||||||||||||||||||||||||||||
| 448 | 0 | ▶ | sub set_feature_diameter { | ||||||||||||||||||||||||||
|
Subroutine
set_feature_diameter: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||
| 449 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 450 | 0 | my $blocks = $self->block_count; | |||||||||||||||||||||||||||
| 451 | 0 | my %hDiam = (); | |||||||||||||||||||||||||||
| 452 | 0 | ▶ | for (my $i=1; $i<=$blocks; $i++){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 453 | 0 | my $diam = $self->block_feature_diameter($i); | |||||||||||||||||||||||||||
| 454 | 0 | $hDiam{$diam}++; | |||||||||||||||||||||||||||
| 455 | } | ||||||||||||||||||||||||||||
| 456 | 0 | my @aDiam = keys %hDiam; | |||||||||||||||||||||||||||
| 457 | 0 | ▶ | if (@aDiam == 1){ | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 458 | 0 | $self->{ _feature_diameter } = $aDiam[0]; | |||||||||||||||||||||||||||
| 459 | } elsif (@aDiam > 1){ | ||||||||||||||||||||||||||||
| 460 | 0 | $self->{ _feature_diameter } = -1; | |||||||||||||||||||||||||||
| 461 | } else { | ||||||||||||||||||||||||||||
| 462 | 0 | return; | |||||||||||||||||||||||||||
| 463 | } | ||||||||||||||||||||||||||||
| 464 | } | ||||||||||||||||||||||||||||
| 465 | # return x_spacing of each block if all the same | ||||||||||||||||||||||||||||
| 466 | # otherwise returns -1 | ||||||||||||||||||||||||||||
| 467 | 0 | ▶ | sub x_spacing { | ||||||||||||||||||||||||||
|
Subroutine
x_spacing: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 468 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 469 | 0 | ▶ | unless (defined $self->{ _x_spacing }){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 470 | 0 | $self->set_x_spacing; | |||||||||||||||||||||||||||
| 471 | } | ||||||||||||||||||||||||||||
| 472 | 0 | $self->{ _x_spacing }; | |||||||||||||||||||||||||||
| 473 | } | ||||||||||||||||||||||||||||
| 474 | 0 | ▶ | sub set_x_spacing { | ||||||||||||||||||||||||||
|
Subroutine
set_x_spacing: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||
| 475 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 476 | 0 | my $blocks = $self->block_count; | |||||||||||||||||||||||||||
| 477 | 0 | my %hX_Spacing = (); | |||||||||||||||||||||||||||
| 478 | 0 | ▶ | for (my $i=1; $i<=$blocks; $i++){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 479 | 0 | my $x_spacing = $self->block_x_spacing($i); | |||||||||||||||||||||||||||
| 480 | 0 | $hX_Spacing{$x_spacing}++; | |||||||||||||||||||||||||||
| 481 | } | ||||||||||||||||||||||||||||
| 482 | 0 | my @aX_Spacing = keys %hX_Spacing; | |||||||||||||||||||||||||||
| 483 | 0 | ▶ | if (@aX_Spacing == 1){ | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 484 | 0 | $self->{ _x_spacing } = $aX_Spacing[0]; | |||||||||||||||||||||||||||
| 485 | } elsif (@aX_Spacing > 1){ | ||||||||||||||||||||||||||||
| 486 | 0 | $self->{ _x_spacing } = -1; | |||||||||||||||||||||||||||
| 487 | } else { | ||||||||||||||||||||||||||||
| 488 | 0 | return; | |||||||||||||||||||||||||||
| 489 | } | ||||||||||||||||||||||||||||
| 490 | } | ||||||||||||||||||||||||||||
| 491 | # return y_spacing of each block if all the same | ||||||||||||||||||||||||||||
| 492 | # otherwise returns -1 | ||||||||||||||||||||||||||||
| 493 | 0 | ▶ | sub y_spacing { | ||||||||||||||||||||||||||
|
Subroutine
y_spacing: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 494 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 495 | 0 | ▶ | unless (defined $self->{ _y_spacing }){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 496 | 0 | $self->set_y_spacing; | |||||||||||||||||||||||||||
| 497 | } | ||||||||||||||||||||||||||||
| 498 | 0 | $self->{ _y_spacing }; | |||||||||||||||||||||||||||
| 499 | } | ||||||||||||||||||||||||||||
| 500 | 0 | ▶ | sub set_y_spacing { | ||||||||||||||||||||||||||
|
Subroutine
set_y_spacing: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||
| 501 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 502 | 0 | my $blocks = $self->block_count; | |||||||||||||||||||||||||||
| 503 | 0 | my %hY_Spacing = (); | |||||||||||||||||||||||||||
| 504 | 0 | ▶ | for (my $i=1; $i<=$blocks; $i++){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 505 | 0 | my $y_spacing = $self->block_y_spacing($i); | |||||||||||||||||||||||||||
| 506 | 0 | $hY_Spacing{$y_spacing}++; | |||||||||||||||||||||||||||
| 507 | } | ||||||||||||||||||||||||||||
| 508 | 0 | my @aY_Spacing = keys %hY_Spacing; | |||||||||||||||||||||||||||
| 509 | 0 | ▶ | if (@aY_Spacing == 1){ | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 510 | 0 | $self->{ _y_spacing } = $aY_Spacing[0]; | |||||||||||||||||||||||||||
| 511 | } elsif (@aY_Spacing > 1){ | ||||||||||||||||||||||||||||
| 512 | 0 | $self->{ _y_spacing } = -1; | |||||||||||||||||||||||||||
| 513 | } else { | ||||||||||||||||||||||||||||
| 514 | 0 | return; | |||||||||||||||||||||||||||
| 515 | } | ||||||||||||||||||||||||||||
| 516 | } | ||||||||||||||||||||||||||||
| 517 | 0 | ▶ | sub file_string { | ||||||||||||||||||||||||||
|
Subroutine
file_string: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 518 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 519 | 0 | my $string = "ATF\t1.0\n".$self->header_rows."\t".$self->data_cols."\n"; | |||||||||||||||||||||||||||
| 520 | 0 | $string .= $self->header_string; | |||||||||||||||||||||||||||
| 521 | 0 | $string .= $self->blocks_string; | |||||||||||||||||||||||||||
| 522 | 0 | ▶ | if ($self->gal_type eq 'v4.1'){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 523 | 0 | $string .= "Block\tRow\tColumn\tID\tName\tAnnotation\n"; | |||||||||||||||||||||||||||
| 524 | } else { | ||||||||||||||||||||||||||||
| 525 | 0 | $string .= "Block\tRow\tColumn\tID\tName\n"; | |||||||||||||||||||||||||||
| 526 | } | ||||||||||||||||||||||||||||
| 527 | 0 | $string .= $self->rows_string; | |||||||||||||||||||||||||||
| 528 | 0 | return $string; | |||||||||||||||||||||||||||
| 529 | } | ||||||||||||||||||||||||||||
| 530 | 0 | ▶ | sub header_string { | ||||||||||||||||||||||||||
|
Subroutine
header_string: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 531 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 532 | 0 | my $string = ""; | |||||||||||||||||||||||||||
| 533 | 0 | my $aHeaders = $self->header_keys; | |||||||||||||||||||||||||||
| 534 | 0 | ▶ | for (my $i=1; $i<=@$aHeaders; $i++){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 535 | 0 | my $value = $self->get_header_value($aHeaders->[$i-1]); | |||||||||||||||||||||||||||
| 536 | 0 | $string .= "\"".$aHeaders->[$i-1]."=$value\"\n"; | |||||||||||||||||||||||||||
| 537 | } | ||||||||||||||||||||||||||||
| 538 | 0 | return $string; | |||||||||||||||||||||||||||
| 539 | } | ||||||||||||||||||||||||||||
| 540 | # formats the header block info for gal file output | ||||||||||||||||||||||||||||
| 541 | # counted_cols() and counted_rows() used instead of block_x_features() and block_y_features() | ||||||||||||||||||||||||||||
| 542 | # so that printing spacers can be removed from the GAL file | ||||||||||||||||||||||||||||
| 543 | # only relevant when going from file->file, since block_x_features() and block_y_features() | ||||||||||||||||||||||||||||
| 544 | # aren't saved to db (since all block row/col counts are assumed the same) - see gal_file_table() | ||||||||||||||||||||||||||||
| 545 | 0 | ▶ | sub blocks_string { | ||||||||||||||||||||||||||
|
Subroutine
blocks_string: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 546 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 547 | 0 | my $string = ""; | |||||||||||||||||||||||||||
| 548 | 0 | ▶ | if (my $blocks = $self->block_count){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 549 | 0 | ▶ | for (my $i=1; $i<=$blocks; $i++){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 550 | 0 | $string .= "\"Block$i= ". | |||||||||||||||||||||||||||
| 551 | $self->block_x_origin($i).", ". | ||||||||||||||||||||||||||||
| 552 | $self->block_y_origin($i).", ". | ||||||||||||||||||||||||||||
| 553 | $self->feature_diameter.", ". | ||||||||||||||||||||||||||||
| 554 | $self->counted_cols($i).", ". # actual cols, not original set value | ||||||||||||||||||||||||||||
| 555 | $self->block_x_spacing($i).", ". | ||||||||||||||||||||||||||||
| 556 | $self->counted_rows($i).", ". # actual rows, not original set value | ||||||||||||||||||||||||||||
| 557 | $self->block_y_spacing($i)."\"\n"; | ||||||||||||||||||||||||||||
| 558 | } | ||||||||||||||||||||||||||||
| 559 | } | ||||||||||||||||||||||||||||
| 560 | 0 | return $string; | |||||||||||||||||||||||||||
| 561 | } | ||||||||||||||||||||||||||||
| 562 | 0 | ▶ | sub rows_string { | ||||||||||||||||||||||||||
|
Subroutine
rows_string: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||
| 563 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 564 | 0 | my $string = ""; | |||||||||||||||||||||||||||
| 565 | 0 | my @aValues = (); | |||||||||||||||||||||||||||
| 566 | 0 | ▶ | BLOCK:for (my $block=1; $block<=$self->block_count; $block++){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 567 | 0 | ▶ | ROW:for (my $row=1; $row<=$self->counted_rows($block); $row++){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 568 | 0 | ▶ | COL:for (my $col=1; $col<=$self->counted_cols($block); $col++){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||
| 570 | 0 | my $name = $self->get_spot_name($block,$col,$row); | |||||||||||||||||||||||||||
| 571 | 0 | my $id = $self->get_spot_id($block,$col,$row); | |||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||
| 573 | 0 | ▶ | next COL unless ($name && ($name ne '')); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$name and $name ne ""
MC/DC0%0/2
$name and $name ne ""
$name
$name ne ""
Truth table0%0/3
A and B
A= $nameB= $name ne ""
| |||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||
| 575 | 0 | ▶ | if ($self->gal_type eq 'v4.1'){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 576 | 0 | my $comment = $self->get_spot_annotation($block,$col,$row); | |||||||||||||||||||||||||||
| 577 | 0 | $string .= "$block\t$row\t$col\t$id\t$name\t$comment\n"; | |||||||||||||||||||||||||||
| 578 | } else { | ||||||||||||||||||||||||||||
| 579 | 0 | $string .= "$block\t$row\t$col\t$id\t$name\n"; | |||||||||||||||||||||||||||
| 580 | } | ||||||||||||||||||||||||||||
| 581 | } | ||||||||||||||||||||||||||||
| 582 | } | ||||||||||||||||||||||||||||
| 583 | } | ||||||||||||||||||||||||||||
| 584 | 0 | return $string; | |||||||||||||||||||||||||||
| 585 | } | ||||||||||||||||||||||||||||
| 586 | } | ||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||
| 588 | 1 | 1; | |||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||
| 590 | __END__ | ||||||||||||||||||||||||||||