| 1 | package Microarray::File::Image; | ||||||||||||||
| 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.4'; | |||||||||||||
| 7 | |||||||||||||||
| 8 | { package microarray_image_file; | ||||||||||||||
| 9 | |||||||||||||||
| 10 | 1 | ▶ | use Image::ExifTool; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 11 | 1 | require Microarray::File; | |||||||||||||
| 12 | |||||||||||||||
| 13 | 1 | our @ISA = qw( microarray_file ); | |||||||||||||
| 14 | |||||||||||||||
| 15 | 0 | ▶ | sub new { | ||||||||||||
|
Subroutine
new: not called CC=4 SCAR=30.0
| |||||||||||||||
| 16 | 0 | my $class = shift; | |||||||||||||
| 17 | 0 | my $self = { }; | |||||||||||||
| 18 | 0 | ▶ | if (@_){ | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 19 | 0 | my $file_name = shift; | |||||||||||||
| 20 | 0 | $self->{ _file_name } = $file_name; # shift in file name | |||||||||||||
| 21 | 0 | bless $self, $class; | |||||||||||||
| 22 | 0 | ▶ | if ($class eq 'microarray_image_file'){ | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 23 | # try and guess which file type we're dealing with | ||||||||||||||
| 24 | 0 | my $class = $self->guess_class; | |||||||||||||
| 25 | 0 | ▶ | unless ($class eq 'microarray_image_file'){ | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 26 | # if we've found a better match, recreate ourself | ||||||||||||||
| 27 | 0 | $self = { _file_name => $file_name }; | |||||||||||||
| 28 | 0 | bless $self,$class; | |||||||||||||
| 29 | } | ||||||||||||||
| 30 | } | ||||||||||||||
| 31 | 0 | $self->import_data; | |||||||||||||
| 32 | } else { | ||||||||||||||
| 33 | 0 | bless $self, $class; | |||||||||||||
| 34 | } | ||||||||||||||
| 35 | 0 | return $self; | |||||||||||||
| 36 | } | ||||||||||||||
| 37 | 0 | ▶ | sub guess_class { | ||||||||||||
|
Subroutine
guess_class: not called CC=3 SCAR=24.8
| |||||||||||||||
| 38 | 0 | my $self = shift; | |||||||||||||
| 39 | 0 | my $hInfo = $self->get_header_info; | |||||||||||||
| 40 | 0 | ▶ | if ($hInfo->{ Model } =~ /GenePix/){ | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 41 | 0 | return 'genepix_image'; | |||||||||||||
| 42 | } elsif ($hInfo->{ Model } =~ /ScanArray/){ | ||||||||||||||
| 43 | 0 | return 'quantarray_image'; | |||||||||||||
| 44 | } else { | ||||||||||||||
| 45 | 0 | warn "Microarray::File::Image ERROR: Could not deduce the type of file from '".$self->file_name."'\n"; | |||||||||||||
| 46 | 0 | return 'microarray_image_file'; | |||||||||||||
| 47 | } | ||||||||||||||
| 48 | } | ||||||||||||||
| 49 | 0 | ▶ | sub import_data { | ||||||||||||
|
Subroutine
import_data: not called CC=1 SCAR=6.9
| |||||||||||||||
| 50 | 0 | my $self = shift; | |||||||||||||
| 51 | 0 | $self->set_header_info; | |||||||||||||
| 52 | } | ||||||||||||||
| 53 | 0 | ▶ | sub set_exiftool_object { | ||||||||||||
|
Subroutine
set_exiftool_object: not called CC=1 SCAR=6.9
| |||||||||||||||
| 54 | 0 | my $self = shift; | |||||||||||||
| 55 | 0 | my $exifTool = new Image::ExifTool; | |||||||||||||
| 56 | 0 | $exifTool->ExtractInfo($self->file_name); # extract info from file | |||||||||||||
| 57 | 0 | $self->{ _ExifTool_object } = $exifTool; | |||||||||||||
| 58 | } | ||||||||||||||
| 59 | 0 | ▶ | sub get_exiftool_object { | ||||||||||||
|
Subroutine
get_exiftool_object: not called CC=2 SCAR=17.9
| |||||||||||||||
| 60 | 0 | my $self = shift; | |||||||||||||
| 61 | 0 | ▶ | unless (defined $self->{ _ExifTool_object }){ | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 62 | 0 | $self->set_exiftool_object; | |||||||||||||
| 63 | } | ||||||||||||||
| 64 | 0 | $self->{ _ExifTool_object }; | |||||||||||||
| 65 | } | ||||||||||||||
| 66 | 0 | ▶ | sub set_header_info { | ||||||||||||
|
Subroutine
set_header_info: not called CC=1 SCAR=6.9
| |||||||||||||||
| 67 | 0 | my $self = shift; | |||||||||||||
| 68 | 0 | my $exifTool = $self->get_exiftool_object; | |||||||||||||
| 69 | 0 | $self->{ _header_info } = $exifTool->GetInfo; | |||||||||||||
| 70 | 0 | $self->set_header_data; | |||||||||||||
| 71 | } | ||||||||||||||
| 72 | 0 | ▶ | sub set_header_data { | ||||||||||||
|
Subroutine
set_header_data: not called CC=1 SCAR=6.9
| |||||||||||||||
| 73 | 0 | return; | |||||||||||||
| 74 | } | ||||||||||||||
| 75 | # get_header_info inherited from microarray_file class | ||||||||||||||
| 76 | 0 | ▶ | sub slide_barcode { | ||||||||||||
|
Subroutine
slide_barcode: not called CC=1 SCAR=6.9
| |||||||||||||||
| 77 | 0 | my $self = shift; | |||||||||||||
| 78 | 0 | $self->guess_slide_barcode; | |||||||||||||
| 79 | } | ||||||||||||||
| 80 | 0 | ▶ | sub guess_slide_barcode { | ||||||||||||
|
Subroutine
guess_slide_barcode: not called CC=1 SCAR=1.7
| |||||||||||||||
| 81 | 1 | ▶ | use File::Basename; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 82 | 0 | my $self = shift; | |||||||||||||
| 83 | 0 | my $file = basename($self->file_name); | |||||||||||||
| 84 | 0 | my @aName = split(/-|_| /,$file); | |||||||||||||
| 85 | 0 | return $aName[0]; | |||||||||||||
| 86 | } | ||||||||||||||
| 87 | } | ||||||||||||||
| 88 | |||||||||||||||
| 89 | 1 | 1; | |||||||||||||
| 90 | |||||||||||||||
| 91 | __END__ | ||||||||||||||