| 1 | package Bio::Maxd; | ||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||
| 3 | 1 | require 5.005_62; | |||||||||||||||||||||||||||||||||||||
| 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 | ▶ | use File::Basename; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||
| 8 | 1 | require Exporter; | |||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use AutoLoader qw(AUTOLOAD); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||
| 11 | 1 | our @ISA = qw(Exporter); | |||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||
| 13 | 1 | our %EXPORT_TAGS = ( 'all' => [ qw( | |||||||||||||||||||||||||||||||||||||
| 14 | ) ] ); | ||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||
| 16 | 1 | our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); | |||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||
| 18 | 1 | our @EXPORT = qw( | |||||||||||||||||||||||||||||||||||||
| 19 | ); | ||||||||||||||||||||||||||||||||||||||
| 20 | 1 | our $VERSION = '0.04'; | |||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||
| 22 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=15 SCAR=53.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 23 | 0 | my $self=shift; | |||||||||||||||||||||||||||||||||||||
| 24 | 0 | ▶ | my $class=ref($self) || $self; | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table0%0/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||||||||
| 25 | 0 | my(%data,$tag); | |||||||||||||||||||||||||||||||||||||
| 26 | 0 | ▶ | while (@_) {$tag = shift; if ($tag =~ /^-/) {$tag =~ s/^-//;$data{lc($tag)} = shift;}} | ||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | $data{'dbase'} = "maxd" if (!$data{'dbase'}); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 28 | 0 | ▶ | if (!$data{'host'}) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 29 | 1 | ▶ | use Sys::Hostname; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 30 | 0 | my $hostname = hostname(); | |||||||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | $data{'host'} = $data{'host'} || $ENV{'MAXD_HOSTDB'} || $hostname || "localhost"; | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/8
$data{'host'} || $ENV{'MAXD_HOSTDB'} || $hostname || 'localhost'
$data{"host"} or $ENV{"MAXD_HOSTDB"} or $hostname
$data{"host"} or $ENV{"MAXD_HOSTDB"}
MC/DC0%0/3
$data{'host'} || $ENV{'MAXD_HOSTDB'} || $hostname || 'localhost'
$data{"host"}
$ENV{"MAXD_HOSTDB"}
$hostname
Truth table0%0/4
A or B or C
A= $data{"host"}B= $ENV{"MAXD_HOSTDB"}C= $hostname
| |||||||||||||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | if (!$data{'user'} || !$data{'pass'}) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$data{"user"} and $data{"pass"}
MC/DC0%0/2
$data{"user"} and $data{"pass"}
$data{"user"}
$data{"pass"}
Truth table0%0/3
A and B
A= $data{"user"}B= $data{"pass"}
| |||||||||||||||||||||||||||||||||||||||
| 34 | 0 | ($data{'user'},$data{'pass'}) = split(/\//,$ENV{'MAXD_USERID'}); | |||||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||||
| 36 | 0 | $data{'dbh'} = _dbconnect ($data{'host'},$data{'dbase'},$data{'user'},$data{'pass'}); | |||||||||||||||||||||||||||||||||||||
| 37 | # verify special tables | ||||||||||||||||||||||||||||||||||||||
| 38 | 0 | my($ok,$tname); | |||||||||||||||||||||||||||||||||||||
| 39 | 0 | my $st = "show tables"; | |||||||||||||||||||||||||||||||||||||
| 40 | 0 | my $sh = $data{'dbh'}->prepare($st); | |||||||||||||||||||||||||||||||||||||
| 41 | 0 | my $rv = $sh->execute; | |||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | while($tname= $sh->fetchrow_array) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | if ($tname =~ /^Image_Seq$/i) { $ok = 1; last; } | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||
| 45 | 0 | ▶ | if (!$ok) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 46 | 0 | print STDERR "WARNING: Run 'extendMaxD' to configure database\n"; | |||||||||||||||||||||||||||||||||||||
| 47 | 0 | $data{'dbh'} = undef; | |||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||
| 49 | 0 | $self = bless {} => $class; | |||||||||||||||||||||||||||||||||||||
| 50 | 0 | foreach $tag (keys %data) { $self->{$tag} = $data{$tag}; } | |||||||||||||||||||||||||||||||||||||
| 51 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | sub export { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
export: not called CC=34 SCAR=70.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 55 | 0 | my $self=shift; | |||||||||||||||||||||||||||||||||||||
| 56 | 0 | my(%data,$tag); | |||||||||||||||||||||||||||||||||||||
| 57 | 0 | foreach $tag (keys %{$self}) { $data{$tag} = $self->{$tag};} | |||||||||||||||||||||||||||||||||||||
| 58 | 0 | ▶ | while (@_) {$tag = shift; if ($tag =~ /^-/) {$tag =~ s/^-//;$data{lc($tag)} = shift;}} | ||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | return 0 if (ref($data{'dbh'}) ne "DBI::db"); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||
| 61 | # valid submitter ? | ||||||||||||||||||||||||||||||||||||||
| 62 | ($data{'submitter_id'},$data{'submitter_name'}) = | ||||||||||||||||||||||||||||||||||||||
| 63 | 0 | _submitterFromSubmitterData($data{'dbh'},$data{'submitter'}); | |||||||||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | return (_error(501,$data{'submitter'})) if ($data{'submitter_id'}< 0); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 65 | print "Submitter:\tname:$data{'submitter_name'}\tID:$data{'submitter_id'}\n" | ||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | if ($data{'verbose'}); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||
| 68 | # valid repository URL ? | ||||||||||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | $data{'repository_url'} = "." if (!-d $data{'repository_url'}); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 70 | 0 | $data{'repository_url'} .= "/" . $data{'submitter_name'}; | |||||||||||||||||||||||||||||||||||||
| 71 | 0 | $data{'repository_url'} =~ s/ +/_/g; | |||||||||||||||||||||||||||||||||||||
| 72 | 0 | mkdir($data{'repository_url'},0755); | |||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||
| 74 | # valid experiment ? | ||||||||||||||||||||||||||||||||||||||
| 75 | 0 | ▶ | return 0 if (!$data{'experiment'}); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 76 | ($data{'experiment_id'},$data{'experiment_name'}) | ||||||||||||||||||||||||||||||||||||||
| 77 | = _experimentIDfromExperiment($data{'dbh'},$data{'experiment'}, | ||||||||||||||||||||||||||||||||||||||
| 78 | 0 | $data{'submitter_id'}); | |||||||||||||||||||||||||||||||||||||
| 79 | return (_error(502,"experiment $data{'experiment'} unknown")) | ||||||||||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | if ($data{'experiment_id'} < 0); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 81 | print "Experiment:\tname:$data{'experiment_name'}\tID:$data{'experiment_id'}\n" | ||||||||||||||||||||||||||||||||||||||
| 82 | 0 | ▶ | if ($data{'verbose'}); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||
| 84 | # valid array type ? | ||||||||||||||||||||||||||||||||||||||
| 85 | 0 | ▶ | return 0 if (not defined $data{'array_type'}); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | $data{'array_name'} = $data{'array_type'} if (!$data{'array_name'}); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 87 | 0 | ▶ | $data{'array_id'} = $data{'array_type'} if ($data{'array_type'} =~ /^\d+/); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 88 | $data{'array_id'} = _arrayIDfromArrayType($data{'dbh'},$data{'array_type'}) | ||||||||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | if (!$data{'array_id'}); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 90 | 0 | ▶ | return (_error(502,"array $data{'array_type'} unknown")) if ($data{'array_id'} < 0); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 91 | print "Array Type:\tname:$data{'array_type'}\tID:$data{'array_id'}\n" | ||||||||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | if ($data{'verbose'}); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||
| 94 | #valid export format ? | ||||||||||||||||||||||||||||||||||||||
| 95 | 0 | $data{'format'} = lc($data{'format'}); | |||||||||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | $data{'format'} = "genespring" if (!$data{'format'}); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 97 | return (_error(501,"unknown export format $data{'format'}")) | ||||||||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | if ($data{'format'} !~ /\bgenespring\b/); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | my $templateDir = $ENV{'MAXD_TEMPLATES'} || "."; | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$ENV{'MAXD_TEMPLATES'} || '.'
MC/DC0%0/1
$ENV{'MAXD_TEMPLATES'} || '.'
$ENV{'MAXD_TEMPLATES'}
Truth table0%0/2
A
A= $ENV{'MAXD_TEMPLATES'}
| |||||||||||||||||||||||||||||||||||||||
| 100 | 0 | ▶ | return (_error(501,"unable to find template for $data{'format'}")) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 101 | if (!-f "$templateDir/$data{'format'}\.tmpl"); | ||||||||||||||||||||||||||||||||||||||
| 102 | 0 | ▶ | print "Export format:\t$data{'format'}\n" if ($data{'verbose'}); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | print "collecting hybridisation\n" if ($data{'verbose'}); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 105 | my %hybD = _hybridisationByExperimentIDArrayID($data{'dbh'}, | ||||||||||||||||||||||||||||||||||||||
| 106 | 0 | $data{'experiment_id'},$data{'array_id'}); | |||||||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | print "collecting tissue\n" if ($data{'verbose'}); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 108 | 0 | my(%TisSrc) = _sourceNameTissueByExperiment($data{'dbh'},\%hybD); | |||||||||||||||||||||||||||||||||||||
| 109 | 0 | my $numOfExp = scalar(keys %hybD); | |||||||||||||||||||||||||||||||||||||
| 110 | 0 | my($imgname,$img,$mesname,$mes,$hybname,$hyb,$k,$v,%tmp,%spotD); | |||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||
| 112 | 0 | my $numOfHyb = scalar(keys %hybD); my $hybCounter = 1; | |||||||||||||||||||||||||||||||||||||
| 113 | 0 | foreach $hybname (sort {$hybD{$a} <=> $hybD{$b}} keys %hybD) { | |||||||||||||||||||||||||||||||||||||
| 114 | print "collecting measurement for $hybname ($hybCounter/$numOfHyb)\n" | ||||||||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | if ($data{'verbose'}); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 116 | 0 | $hybCounter++; | |||||||||||||||||||||||||||||||||||||
| 117 | 0 | $hyb = sprintf("%04d",$hybD{$hybname}); | |||||||||||||||||||||||||||||||||||||
| 118 | 0 | ($imgname,$img) = _imageFromHybridisationID($data{'dbh'},$hyb); | |||||||||||||||||||||||||||||||||||||
| 119 | 0 | ($mesname,$mes) = _measurementFromImageID($data{'dbh'},$img); | |||||||||||||||||||||||||||||||||||||
| 120 | 0 | %tmp = _spotMeasurementByMeasurementID($data{'dbh'},$mes); | |||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | while (($k,$v)=each %tmp) {$spotD{$hyb}{$k} = $v;} | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||
| 123 | 0 | my %spotName = _spotNameBySpotID($data{'dbh'},\%tmp); | |||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||
| 125 | # export data in txt format | ||||||||||||||||||||||||||||||||||||||
| 126 | 0 | ▶ | print "exporting data in txt format\n" if ($data{'verbose'}); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 127 | 0 | my $dataFileName; | |||||||||||||||||||||||||||||||||||||
| 128 | 0 | ($dataFileName = "$data{'repository_url'}/$data{'array_name'}") =~ s/\s+/_/g; | |||||||||||||||||||||||||||||||||||||
| 129 | 0 | open(OUT,">$dataFileName\.txt"); | |||||||||||||||||||||||||||||||||||||
| 130 | 0 | foreach $mes (sort {$a<=>$b} keys %spotName) { | |||||||||||||||||||||||||||||||||||||
| 131 | 0 | print OUT "$spotName{$mes}\t"; | |||||||||||||||||||||||||||||||||||||
| 132 | 0 | foreach $hyb (sort keys %spotD) { | |||||||||||||||||||||||||||||||||||||
| 133 | 0 | print OUT $spotD{$hyb}{$mes},"\t"; | |||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||
| 135 | 0 | print OUT "$spotName{$mes}"; | |||||||||||||||||||||||||||||||||||||
| 136 | 0 | print OUT "\n"; | |||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||
| 138 | 0 | close(OUT); | |||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||
| 140 | # export master in html format | ||||||||||||||||||||||||||||||||||||||
| 141 | 0 | ▶ | print "exporting master in htmlformat\n" if ($data{'verbose'}); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 142 | 0 | my $date = `date`; | |||||||||||||||||||||||||||||||||||||
| 143 | 1 | ▶ | use HTML::Template; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 144 | 0 | my $template = HTML::Template->new(filename => "$templateDir/GeneSpring.tmpl"); | |||||||||||||||||||||||||||||||||||||
| 145 | 0 | $template->param(SUBMITTER_NAME => $data{'submitter_name'}); | |||||||||||||||||||||||||||||||||||||
| 146 | 0 | $template->param(EXPERIMENT_NAME => $data{'experiment_name'}); | |||||||||||||||||||||||||||||||||||||
| 147 | 0 | $template->param(ORGANIZ_NAME => $data{'organization_name'}); | |||||||||||||||||||||||||||||||||||||
| 148 | 0 | $template->param(DATE => $date); | |||||||||||||||||||||||||||||||||||||
| 149 | 0 | $template->param(ARRAY_NAME => $data{'array_name'}); | |||||||||||||||||||||||||||||||||||||
| 150 | 0 | $template->param(NUM_OF_EXP => $numOfExp); | |||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||
| 152 | 0 | my $expCount = 0; | |||||||||||||||||||||||||||||||||||||
| 153 | 0 | my @expLoop; | |||||||||||||||||||||||||||||||||||||
| 154 | 0 | foreach my $hybname (sort {$hybD{$a} <=> $hybD{$b}} keys %hybD) { | |||||||||||||||||||||||||||||||||||||
| 155 | 0 | $expCount++; | |||||||||||||||||||||||||||||||||||||
| 156 | my %row = (EXPCOUNT => $expCount, | ||||||||||||||||||||||||||||||||||||||
| 157 | EXPTISSUE => $TisSrc{'tissue'}{$hybD{$hybname}}, | ||||||||||||||||||||||||||||||||||||||
| 158 | EXPNAME => $hybD{$hybname}, | ||||||||||||||||||||||||||||||||||||||
| 159 | 0 | EXPSOURCE => $TisSrc{'source'}{$hybD{$hybname}} ); | |||||||||||||||||||||||||||||||||||||
| 160 | 0 | push(@expLoop, \%row); | |||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||
| 162 | 0 | $template->param(EXPERIMENT_INFO => \@expLoop); | |||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||
| 164 | 0 | my($i,$eLine,$xLine,$sLine,$I); | |||||||||||||||||||||||||||||||||||||
| 165 | 0 | $eLine = "";$sLine=""; | |||||||||||||||||||||||||||||||||||||
| 166 | 0 | foreach $i (1 .. $numOfExp) { | |||||||||||||||||||||||||||||||||||||
| 167 | 0 | $xLine .= "<TD>Exp. $i</TD>"; | |||||||||||||||||||||||||||||||||||||
| 168 | 0 | $eLine .= "<TD> </TD>"; | |||||||||||||||||||||||||||||||||||||
| 169 | 0 | ▶ | if ($i == 1) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 170 | 0 | $sLine .= "<TD> </TD>"; | |||||||||||||||||||||||||||||||||||||
| 171 | } else { | ||||||||||||||||||||||||||||||||||||||
| 172 | 0 | $I = $i + 1; | |||||||||||||||||||||||||||||||||||||
| 173 | 0 | $sLine .= "<TD>$I</TD>"; | |||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||
| 177 | 0 | my $f = basename($dataFileName) . ".txt"; | |||||||||||||||||||||||||||||||||||||
| 178 | 0 | $template->param(EXPLINE => $xLine); | |||||||||||||||||||||||||||||||||||||
| 179 | 0 | $template->param(SLINE => $sLine); | |||||||||||||||||||||||||||||||||||||
| 180 | 0 | $template->param(ELINE => $eLine); | |||||||||||||||||||||||||||||||||||||
| 181 | 0 | $template->param(DFILENAME => $f); | |||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||
| 183 | 0 | open(OUT,">$dataFileName\.html"); | |||||||||||||||||||||||||||||||||||||
| 184 | 0 | print OUT $template->output; | |||||||||||||||||||||||||||||||||||||
| 185 | 0 | close(OUT); | |||||||||||||||||||||||||||||||||||||
| 186 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||
| 189 | 0 | ▶ | sub load_file { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
load_file: not called CC=48 SCAR=77.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 190 | 0 | my $self=shift; | |||||||||||||||||||||||||||||||||||||
| 191 | 0 | my(%data,$tag); | |||||||||||||||||||||||||||||||||||||
| 192 | 0 | foreach $tag (keys %{$self}) { $data{$tag} = $self->{$tag};} | |||||||||||||||||||||||||||||||||||||
| 193 | 0 | ▶ | while (@_) {$tag = shift; if ($tag =~ /^-/) {$tag =~ s/^-//;$data{lc($tag)} = shift;}} | ||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||
| 194 | 0 | ▶ | return 0 if (ref($data{'dbh'}) ne "DBI::db"); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 195 | 0 | ▶ | return 0 if (!-f $data{'matrix_file'}); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||
| 197 | # valid data format ? | ||||||||||||||||||||||||||||||||||||||
| 198 | 0 | ▶ | $data{'format'} = $data{'format'} || _theFileFormat($data{'matrix_file'}); | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$data{'format'} || _theFileFormat($data{'matrix_file'})
MC/DC0%0/2
$data{'format'} || _theFileFormat($data{'matrix_file'})
$data{'format'}
_theFileFormat($data{'matrix_file'})
Truth table0%0/3
A || B
A= $data{'format'}B= _theFileFormat($data{'matrix_file'})
| |||||||||||||||||||||||||||||||||||||||
| 199 | 0 | ▶ | return (_error(500,$data{'matrix_file'})) if ($data{'format'} !~ /AFF|TOR/); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||
| 201 | # valid image_analysis_protocol ? | ||||||||||||||||||||||||||||||||||||||
| 202 | return(_error(123,"missing image_analysis_protocol")) | ||||||||||||||||||||||||||||||||||||||
| 203 | 0 | ▶ | if (not defined $data{'image_analysis_protocol'}); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 204 | ($data{'image_analysis_protocol_id'},$data{'image_analysis_protocol_name'}) = | ||||||||||||||||||||||||||||||||||||||
| 205 | 0 | _imageAnalysisProtocolID($data{'dbh'},$data{'image_analysis_protocol'}); | |||||||||||||||||||||||||||||||||||||
| 206 | return (_error(501,"Image Analysis Protocol $data{'image_analysis_protocol'} unknown")) | ||||||||||||||||||||||||||||||||||||||
| 207 | 0 | ▶ | if ($data{'image_analysis_protocol_id'}< 0); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 208 | print "Image Protocol:\tname:$data{'image_analysis_protocol_name'}\t", | ||||||||||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | "ID:$data{'image_analysis_protocol_id'}\n" if ($data{'verbose'}); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||
| 211 | # valid scanning_protocol ? | ||||||||||||||||||||||||||||||||||||||
| 212 | return(_error(123,"missing scanning_protocol")) | ||||||||||||||||||||||||||||||||||||||
| 213 | 0 | ▶ | if (not defined $data{'scanning_protocol'}); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 214 | ($data{'scanning_protocol_id'},$data{'scanning_protocol_name'}) = | ||||||||||||||||||||||||||||||||||||||
| 215 | 0 | _imageAnalysisProtocolID($data{'dbh'},$data{'scanning_protocol'}); | |||||||||||||||||||||||||||||||||||||
| 216 | return (_error(501,"Scanning Protocol $data{'scanning_protocol'} unknown")) | ||||||||||||||||||||||||||||||||||||||
| 217 | 0 | ▶ | if ($data{'scanning_protocol_id'}< 0); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 218 | print "Scanning Protocol:\tname:$data{'scanning_protocol_name'}\t", | ||||||||||||||||||||||||||||||||||||||
| 219 | 0 | ▶ | "ID:$data{'scanning_protocol_id'}\n" if ($data{'verbose'}); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||
| 221 | # valid hybridisation_protocol ? | ||||||||||||||||||||||||||||||||||||||
| 222 | return(_error(123,"missing hybridisation_protocol")) | ||||||||||||||||||||||||||||||||||||||
| 223 | 0 | ▶ | if (not defined $data{'hybridisation_protocol'}); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 224 | ($data{'hybridisation_protocol_id'},$data{'hybridisation_protocol_name'}) = | ||||||||||||||||||||||||||||||||||||||
| 225 | 0 | _imageAnalysisProtocolID($data{'dbh'},$data{'hybridisation_protocol'}); | |||||||||||||||||||||||||||||||||||||
| 226 | return (_error(501,"Hybridisation Protocol $data{'hybridisation_protocol'} unknown")) | ||||||||||||||||||||||||||||||||||||||
| 227 | 0 | ▶ | if ($data{'hybridisation_protocol_id'}< 0); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 228 | print "Hybridisation Protocol:\tname:$data{'hybridisation_protocol_name'}\t", | ||||||||||||||||||||||||||||||||||||||
| 229 | 0 | ▶ | "ID:$data{'hybridisation_protocol_id'}\n" if ($data{'verbose'}); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||
| 231 | # valid submitter ? | ||||||||||||||||||||||||||||||||||||||
| 232 | ($data{'submitter_id'},$data{'submitter_name'}) = | ||||||||||||||||||||||||||||||||||||||
| 233 | 0 | _submitterFromSubmitterData($data{'dbh'},$data{'submitter'}); | |||||||||||||||||||||||||||||||||||||
| 234 | return (_error(501,"submitter $data{'submitter'} unknown")) | ||||||||||||||||||||||||||||||||||||||
| 235 | 0 | ▶ | if ($data{'submitter_id'}< 0); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 236 | print "Submitter:\tname:$data{'submitter_name'}\tID:$data{'submitter_id'}\n" | ||||||||||||||||||||||||||||||||||||||
| 237 | 0 | ▶ | if ($data{'verbose'}); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||
| 239 | # valid array type ? | ||||||||||||||||||||||||||||||||||||||
| 240 | 0 | ▶ | return 0 if (not defined $data{'array_type'}); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 241 | 0 | ▶ | $data{'array_id'} = $data{'array_type'} if ($data{'array_type'} =~ /^\d+/); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 242 | $data{'array_id'} = _arrayIDfromArrayType($data{'dbh'},$data{'array_type'}) | ||||||||||||||||||||||||||||||||||||||
| 243 | 0 | ▶ | if (!$data{'array_id'}); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 244 | 0 | ▶ | return (_error(502,"array $data{'array_type'} unknown")) if ($data{'array_id'} < 0); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 245 | print "Array Type:\tname:$data{'array_type'}\tID:$data{'array_id'}\n" | ||||||||||||||||||||||||||||||||||||||
| 246 | 0 | ▶ | if ($data{'verbose'}); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||
| 248 | # valid experiment ? | ||||||||||||||||||||||||||||||||||||||
| 249 | 0 | ▶ | return 0 if (!$data{'experiment'}); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 250 | ($data{'experiment_id'},$data{'experiment_name'}) | ||||||||||||||||||||||||||||||||||||||
| 251 | = _experimentIDfromExperiment($data{'dbh'},$data{'experiment'}, | ||||||||||||||||||||||||||||||||||||||
| 252 | 0 | $data{'submitter_id'}); | |||||||||||||||||||||||||||||||||||||
| 253 | return (_error(502,"experiment $data{'experiment'} unknown")) | ||||||||||||||||||||||||||||||||||||||
| 254 | 0 | ▶ | if ($data{'experiment_id'} < 0); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 255 | print "Experiment:\tname:$data{'experiment_name'}\tID:$data{'experiment_id'}\n" | ||||||||||||||||||||||||||||||||||||||
| 256 | 0 | ▶ | if ($data{'verbose'}); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||
| 258 | # valid extract ? | ||||||||||||||||||||||||||||||||||||||
| 259 | 0 | ▶ | return (_error(600,"extract")) if (!$data{'extract'}); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 260 | ($data{'extract_id'},$data{'extract_name'}) = | ||||||||||||||||||||||||||||||||||||||
| 261 | 0 | _extractfromExtractData($data{'dbh'},$data{'extract'}); | |||||||||||||||||||||||||||||||||||||
| 262 | 0 | ▶ | return (_error(502,"extract $data{'extract'} unknown")) if ($data{'extract_id'} < 0); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 263 | print "Extract:\tname:$data{'extract_name'}\tID:$data{'extract_id'}\n" | ||||||||||||||||||||||||||||||||||||||
| 264 | 0 | ▶ | if ($data{'verbose'}); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||
| 266 | 0 | ▶ | if (($data{'public'} =~ /true/i) or ($data{'public'} eq "1")) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$data{"public"} =~ /true/i or $data{"public"} eq 1
MC/DC0%0/2
$data{"public"} =~ /true/i or $data{"public"} eq 1
$data{"public"} =~ /true/i
$data{"public"} eq 1
Truth table0%0/3
A or B
A= $data{"public"} =~ /true/iB= $data{"public"} eq 1
| |||||||||||||||||||||||||||||||||||||||
| 267 | 0 | $data{'public'} = "true"; } else {$data{'public'} = "false";} | |||||||||||||||||||||||||||||||||||||
| 268 | 0 | ▶ | print "Public:\t$data{'public'}\n" if ($data{'verbose'}); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||
| 270 | 0 | $data{'repository_url'} =~ s/[\\\/]$//; | |||||||||||||||||||||||||||||||||||||
| 271 | 0 | ▶ | print "Repository URL:\t$data{'repository_url'}\n" if ($data{'verbose'}); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||
| 274 | 0 | $data{'description_id'} = "NULL"; # TEMPORARY | |||||||||||||||||||||||||||||||||||||
| 275 | 0 | $data{'image_attribute_description_id'} = "NULL"; # TEMPORARY RawQ | |||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||
| 277 | 0 | $data{'dbh'}->begin_work; | |||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||
| 279 | 0 | my $Hybridisation_ID = -1; | |||||||||||||||||||||||||||||||||||||
| 280 | 0 | ▶ | if ($data{'hybridisation'}) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 281 | $Hybridisation_ID = _hybridisationIDfromHybridisationData( | ||||||||||||||||||||||||||||||||||||||
| 282 | 0 | $data{'dbh'},$data{'hybridisation'}); | |||||||||||||||||||||||||||||||||||||
| 283 | 0 | ▶ | return (_error(501,$data{'hybridisation'})) if ($Hybridisation_ID < 0); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||
| 285 | 0 | ▶ | if ($Hybridisation_ID < 0) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 286 | # create Hybridisation entry | ||||||||||||||||||||||||||||||||||||||
| 287 | 0 | $Hybridisation_ID = _getNextIDForTable($data{'dbh'},"Hybridisation"); | |||||||||||||||||||||||||||||||||||||
| 288 | 0 | $data{'dbh'}->do(qq{insert into Hybridisation | |||||||||||||||||||||||||||||||||||||
| 289 | (Name,ID,Description_ID,Experiment_ID,Hybridisation_Protocol_ID,Extract_ID,Array_ID) | ||||||||||||||||||||||||||||||||||||||
| 290 | VALUES ("$data{'extract_name'}",$Hybridisation_ID,$data{'description_id'}, | ||||||||||||||||||||||||||||||||||||||
| 291 | $data{'experiment_id'},$data{'hybridisation_protocol_id'}, | ||||||||||||||||||||||||||||||||||||||
| 292 | $data{'extract_id'},$data{'array_id'})}); | ||||||||||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||||||||
| 294 | 0 | ▶ | print "Hybridisation ID:\t$Hybridisation_ID\n" if ($data{'verbose'}); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||
| 296 | 0 | my $Image_ID = -1; | |||||||||||||||||||||||||||||||||||||
| 297 | 0 | ▶ | if ($data{'image'}) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 298 | 0 | $Image_ID = _imageIDfromImageData ($data{'dbh'},$data{'image'}); | |||||||||||||||||||||||||||||||||||||
| 299 | 0 | ▶ | return (_error(501,$data{'image'})) if ($Image_ID < 0); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||||||||||||
| 301 | 0 | ▶ | if ($Image_ID < 0) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 302 | # create Image entry | ||||||||||||||||||||||||||||||||||||||
| 303 | 0 | $Image_ID = _getNextIDForTable($data{'dbh'},"Image"); | |||||||||||||||||||||||||||||||||||||
| 304 | 0 | my $imageURL = | |||||||||||||||||||||||||||||||||||||
| 305 | "$data{'repository_url'}/$data{'submitter_name'}/$data{'extract_name'}\.dat"; | ||||||||||||||||||||||||||||||||||||||
| 306 | 0 | $imageURL =~ s/ +/_/g; | |||||||||||||||||||||||||||||||||||||
| 307 | 0 | $data{'dbh'}->do(qq{insert into Image | |||||||||||||||||||||||||||||||||||||
| 308 | (Name,ID,Digitised_Image_URL,Hybridisation_ID,Scanning_Protocol_ID) VALUES | ||||||||||||||||||||||||||||||||||||||
| 309 | ("$data{'extract_name'}",$Image_ID,"$imageURL", | ||||||||||||||||||||||||||||||||||||||
| 310 | $Hybridisation_ID,$data{'scanning_protocol_id'})}); | ||||||||||||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||||||||||||
| 312 | 0 | ▶ | print "Image ID:\t$Image_ID\n" if ($data{'verbose'}); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||
| 314 | # create Measurement entry | ||||||||||||||||||||||||||||||||||||||
| 315 | 0 | my $Measurement_ID = _getNextIDForTable($data{'dbh'},"Measurement"); | |||||||||||||||||||||||||||||||||||||
| 316 | 0 | $data{'dbh'}->do(qq{insert into Measurement | |||||||||||||||||||||||||||||||||||||
| 317 | (Name,ID,Image_ID,Image_Analysis_Protocol_ID,Image_Attribute_Description_ID,Public) | ||||||||||||||||||||||||||||||||||||||
| 318 | VALUES ("$data{'extract_name'}",$Measurement_ID,$Image_ID, | ||||||||||||||||||||||||||||||||||||||
| 319 | $data{'image_analysis_protocol_id'},$data{'image_attribute_description_id'}, | ||||||||||||||||||||||||||||||||||||||
| 320 | "$data{'public'}")}); | ||||||||||||||||||||||||||||||||||||||
| 321 | 0 | ▶ | print "Measurement ID:\t$Measurement_ID\n" if ($data{'verbose'}); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||
| 323 | # insert SpotMeasurement data | ||||||||||||||||||||||||||||||||||||||
| 324 | 0 | ▶ | print "Loading Spot data\n" if ($data{'verbose'}); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 325 | 0 | my %spots = _loadSpotID($data{'dbh'},$data{'array_id'}); | |||||||||||||||||||||||||||||||||||||
| 326 | 0 | ▶ | print "Loading Experiment data\n" if ($data{'verbose'}); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 327 | 0 | my @expression_level = _loadFromFile($data{'format'},$data{'matrix_file'},"Avg Diff"); | |||||||||||||||||||||||||||||||||||||
| 328 | 0 | my @significance = _loadFromFile($data{'format'},$data{'matrix_file'},"Pos Fraction"); | |||||||||||||||||||||||||||||||||||||
| 329 | 0 | my @spot_name = _loadFromFile($data{'format'},$data{'matrix_file'},"Probe Set Name"); | |||||||||||||||||||||||||||||||||||||
| 330 | 0 | ▶ | print "Inserting experiment data\n" if ($data{'verbose'}); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 331 | 0 | my $st = "insert into SpotMeasurement | |||||||||||||||||||||||||||||||||||||
| 332 | (Expression_Level,Significance,Output_Description_ID,Spot_ID,Measurement_ID) | ||||||||||||||||||||||||||||||||||||||
| 333 | VALUES (?,?,?,?,$Measurement_ID)"; | ||||||||||||||||||||||||||||||||||||||
| 334 | 0 | my $sh = $data{'dbh'}->prepare($st); | |||||||||||||||||||||||||||||||||||||
| 335 | 0 | my($rv,$level,$signif,$desc,$spotNam,$spotID); | |||||||||||||||||||||||||||||||||||||
| 336 | 0 | foreach $spotNam (@spot_name) { | |||||||||||||||||||||||||||||||||||||
| 337 | 0 | $level = shift(@expression_level); | |||||||||||||||||||||||||||||||||||||
| 338 | 0 | $signif= shift(@significance); | |||||||||||||||||||||||||||||||||||||
| 339 | 0 | $desc = "NULL"; | |||||||||||||||||||||||||||||||||||||
| 340 | 0 | $spotID = $spots{$spotNam}; | |||||||||||||||||||||||||||||||||||||
| 341 | 0 | ▶ | return(_error(600,"unknown Spot name $spotNam\n")) if (!$spotID); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 342 | 0 | $rv = $sh->execute($level,$signif,$desc,$spotID); | |||||||||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||
| 345 | 0 | $data{'dbh'}->commit; | |||||||||||||||||||||||||||||||||||||
| 346 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||
| 349 | 0 | ▶ | sub version { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
version: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 350 | 0 | return $VERSION; | |||||||||||||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||
| 353 | 0 | ▶ | sub disconnect { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
disconnect: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 354 | 0 | my $self=shift; | |||||||||||||||||||||||||||||||||||||
| 355 | 0 | $self->{'dbh'}->disconnect; | |||||||||||||||||||||||||||||||||||||
| 356 | 0 | delete $self->{'dbh'}; | |||||||||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||
| 359 | ### internal routines and methods | ||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||
| 361 | 0 | ▶ | sub _dbconnect { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_dbconnect: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||
| 362 | 0 | my($host,$dbase,$user,$pass) = @_; | |||||||||||||||||||||||||||||||||||||
| 363 | 0 | my $MAXD = "DBI:mysql:$dbase:$host"; | |||||||||||||||||||||||||||||||||||||
| 364 | 0 | ▶ | my $db = DBI->connect($MAXD,$user,$pass) || $DBI::errstr; | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
'DBI'->connect($MAXD, $user, $pass) || $DBI::errstr
MC/DC0%0/2
'DBI'->connect($MAXD, $user, $pass) || $DBI::errstr
'DBI'->connect($MAXD, $user, $pass)
$DBI::errstr
Truth table0%0/3
A || B
A= 'DBI'->connect($MAXD, $user, $pass)B= $DBI::errstr
| |||||||||||||||||||||||||||||||||||||||
| 365 | 0 | return $db; | |||||||||||||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||
| 368 | 0 | ▶ | sub _measurementFromImageID { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_measurementFromImageID: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||
| 369 | 0 | my($dbh,$id) = @_; | |||||||||||||||||||||||||||||||||||||
| 370 | 0 | my $st = qq{select Name,ID from Measurement where Image_ID = $id}; | |||||||||||||||||||||||||||||||||||||
| 371 | 0 | my $sh = $dbh->prepare($st); | |||||||||||||||||||||||||||||||||||||
| 372 | 0 | my $rv = $sh->execute; | |||||||||||||||||||||||||||||||||||||
| 373 | 0 | my $name; | |||||||||||||||||||||||||||||||||||||
| 374 | 0 | ($name,$id) =$sh->fetchrow_array; | |||||||||||||||||||||||||||||||||||||
| 375 | 0 | return ($name,$id); | |||||||||||||||||||||||||||||||||||||
| 376 | } | ||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||
| 378 | 0 | ▶ | sub _spotMeasurementByMeasurementID { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_spotMeasurementByMeasurementID: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||
| 379 | 0 | my($dbh,$id)=@_; | |||||||||||||||||||||||||||||||||||||
| 380 | 0 | my(%data,$Expression_Level,$Spot_ID); | |||||||||||||||||||||||||||||||||||||
| 381 | 0 | my $st = qq{select Expression_Level,Spot_ID | |||||||||||||||||||||||||||||||||||||
| 382 | from SpotMeasurement where Measurement_ID = $id}; | ||||||||||||||||||||||||||||||||||||||
| 383 | 0 | my $sh = $dbh->prepare($st); | |||||||||||||||||||||||||||||||||||||
| 384 | 0 | my $rv = $sh->execute; | |||||||||||||||||||||||||||||||||||||
| 385 | 0 | ▶ | while (($Expression_Level,$Spot_ID) = $sh->fetchrow_array) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 386 | 0 | $data{$Spot_ID} = $Expression_Level; | |||||||||||||||||||||||||||||||||||||
| 387 | } | ||||||||||||||||||||||||||||||||||||||
| 388 | 0 | return %data; | |||||||||||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||
| 391 | 0 | ▶ | sub _imageFromHybridisationID { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_imageFromHybridisationID: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||
| 392 | 0 | my($dbh,$id) = @_; | |||||||||||||||||||||||||||||||||||||
| 393 | 0 | my $st = qq{select Name,ID from Image where Hybridisation_ID = $id}; | |||||||||||||||||||||||||||||||||||||
| 394 | 0 | my $sh = $dbh->prepare($st); | |||||||||||||||||||||||||||||||||||||
| 395 | 0 | my $rv = $sh->execute; | |||||||||||||||||||||||||||||||||||||
| 396 | 0 | my $name; | |||||||||||||||||||||||||||||||||||||
| 397 | 0 | ($name,$id) =$sh->fetchrow_array; | |||||||||||||||||||||||||||||||||||||
| 398 | 0 | return ($name,$id); | |||||||||||||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||
| 401 | 0 | ▶ | sub _spotNameBySpotID { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_spotNameBySpotID: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||
| 402 | 0 | my($dbh,$spot) =@_; | |||||||||||||||||||||||||||||||||||||
| 403 | 0 | my($id,%data,$name); | |||||||||||||||||||||||||||||||||||||
| 404 | 0 | my $sh = $dbh->prepare("select Name from Spot where ID = ?"); | |||||||||||||||||||||||||||||||||||||
| 405 | 0 | foreach $id (keys %{$spot}) { | |||||||||||||||||||||||||||||||||||||
| 406 | 0 | my $rv = $sh->execute($id); | |||||||||||||||||||||||||||||||||||||
| 407 | 0 | ($name) = $sh->fetchrow_array; | |||||||||||||||||||||||||||||||||||||
| 408 | 0 | $data{$id} = $name; | |||||||||||||||||||||||||||||||||||||
| 409 | } | ||||||||||||||||||||||||||||||||||||||
| 410 | 0 | return %data; | |||||||||||||||||||||||||||||||||||||
| 411 | } | ||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||
| 413 | 0 | ▶ | sub _sourceNameTissueByExperiment { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_sourceNameTissueByExperiment: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||
| 414 | 0 | my ($dbh,$exp) = @_; | |||||||||||||||||||||||||||||||||||||
| 415 | 0 | my $st = qq{select Source.Name,Source.Tissue | |||||||||||||||||||||||||||||||||||||
| 416 | from Source,Sample,Extract,Hybridisation | ||||||||||||||||||||||||||||||||||||||
| 417 | where Source.ID = Sample.Source_ID | ||||||||||||||||||||||||||||||||||||||
| 418 | and Sample.ID = Extract.Sample_ID | ||||||||||||||||||||||||||||||||||||||
| 419 | and Extract.ID = Hybridisation.Extract_ID | ||||||||||||||||||||||||||||||||||||||
| 420 | and Hybridisation.ID = ?}; | ||||||||||||||||||||||||||||||||||||||
| 421 | 0 | my(%data); | |||||||||||||||||||||||||||||||||||||
| 422 | 0 | my $sh = $dbh->prepare($st); | |||||||||||||||||||||||||||||||||||||
| 423 | 0 | foreach my $expname (keys %{$exp}) { | |||||||||||||||||||||||||||||||||||||
| 424 | 0 | my $expid = $$exp{$expname}; | |||||||||||||||||||||||||||||||||||||
| 425 | 0 | my $rv = $sh->execute($expid); | |||||||||||||||||||||||||||||||||||||
| 426 | 0 | my ($name,$tissue) = $sh->fetchrow_array; | |||||||||||||||||||||||||||||||||||||
| 427 | 0 | $data{'tissue'}{$expid} = $tissue; | |||||||||||||||||||||||||||||||||||||
| 428 | 0 | $data{'source'}{$expid} = $name; | |||||||||||||||||||||||||||||||||||||
| 429 | } | ||||||||||||||||||||||||||||||||||||||
| 430 | 0 | return(%data); | |||||||||||||||||||||||||||||||||||||
| 431 | } | ||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||
| 433 | 0 | ▶ | sub _hybridisationByExperimentIDArrayID { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_hybridisationByExperimentIDArrayID: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||
| 434 | 0 | my($dbh,$id,$array)=@_; | |||||||||||||||||||||||||||||||||||||
| 435 | 0 | my(%data,$ID,$Array_ID,$name); | |||||||||||||||||||||||||||||||||||||
| 436 | 0 | my $st = qq{select Name,ID,Array_ID from Hybridisation | |||||||||||||||||||||||||||||||||||||
| 437 | where Experiment_ID = $id and Array_ID = $array}; | ||||||||||||||||||||||||||||||||||||||
| 438 | 0 | my $sh = $dbh->prepare($st); | |||||||||||||||||||||||||||||||||||||
| 439 | 0 | my $rv = $sh->execute; | |||||||||||||||||||||||||||||||||||||
| 440 | 0 | ▶ | while (($name,$ID,$Array_ID) = $sh->fetchrow_array) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 441 | 0 | $data{$name} = $ID; | |||||||||||||||||||||||||||||||||||||
| 442 | } | ||||||||||||||||||||||||||||||||||||||
| 443 | 0 | return %data; | |||||||||||||||||||||||||||||||||||||
| 444 | } | ||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||
| 446 | 0 | ▶ | sub _loadSpotID { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_loadSpotID: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||
| 447 | 0 | my($dbh,$array_id) = @_; | |||||||||||||||||||||||||||||||||||||
| 448 | 0 | my(%spot,$name,$id); | |||||||||||||||||||||||||||||||||||||
| 449 | 0 | my $st = "select name,id from spot where Array_Type_ID = $array_id"; | |||||||||||||||||||||||||||||||||||||
| 450 | 0 | my $sh = $dbh->prepare($st); | |||||||||||||||||||||||||||||||||||||
| 451 | 0 | my $rv = $sh->execute; | |||||||||||||||||||||||||||||||||||||
| 452 | 0 | ▶ | while (($name,$id)= $sh->fetchrow_array) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 453 | 0 | $spot{$name} = $id; | |||||||||||||||||||||||||||||||||||||
| 454 | } | ||||||||||||||||||||||||||||||||||||||
| 455 | 0 | return %spot; | |||||||||||||||||||||||||||||||||||||
| 456 | } | ||||||||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||||||
| 458 | 0 | ▶ | sub _getNextIDForTable { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_getNextIDForTable: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||
| 459 | 0 | my($dbh,$table)=@_; | |||||||||||||||||||||||||||||||||||||
| 460 | 0 | $table .= "_Seq"; | |||||||||||||||||||||||||||||||||||||
| 461 | 0 | $dbh->do("UPDATE $table SET id=LAST_INSERT_ID(id+1)"); | |||||||||||||||||||||||||||||||||||||
| 462 | 0 | my $st = "select ID from $table"; | |||||||||||||||||||||||||||||||||||||
| 463 | 0 | my $sh = $dbh->prepare($st); | |||||||||||||||||||||||||||||||||||||
| 464 | 0 | my $rv = $sh->execute; | |||||||||||||||||||||||||||||||||||||
| 465 | 0 | my ($id)= $sh->fetchrow_array; | |||||||||||||||||||||||||||||||||||||
| 466 | 0 | return $id; | |||||||||||||||||||||||||||||||||||||
| 467 | } | ||||||||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||||||||
| 469 | 0 | ▶ | sub _imageAnalysisProtocolID { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_imageAnalysisProtocolID: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||
| 470 | 0 | my($dbh,$name) = @_; | |||||||||||||||||||||||||||||||||||||
| 471 | 0 | my($id); | |||||||||||||||||||||||||||||||||||||
| 472 | 0 | my $st = "select Name,ID from imageanalysisprotocol where "; | |||||||||||||||||||||||||||||||||||||
| 473 | 0 | ▶ | if ($name =~ /^\d+$/) {$st .= qq{ID = "$name"};} else {$st .= qq{ Name = "$name"};} | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 474 | 0 | my $sh = $dbh->prepare($st); | |||||||||||||||||||||||||||||||||||||
| 475 | 0 | my $rv = $sh->execute; | |||||||||||||||||||||||||||||||||||||
| 476 | 0 | ($name,$id)= $sh->fetchrow_array; | |||||||||||||||||||||||||||||||||||||
| 477 | 0 | ▶ | $id = "-1" unless defined $id; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 478 | 0 | ▶ | $name = "" unless defined $name; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 479 | 0 | return ($id,$name); | |||||||||||||||||||||||||||||||||||||
| 480 | } | ||||||||||||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||||||||||||
| 482 | 0 | ▶ | sub _extractfromExtractData { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_extractfromExtractData: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||
| 483 | 0 | my($dbh,$name) = @_; | |||||||||||||||||||||||||||||||||||||
| 484 | 0 | my($id); | |||||||||||||||||||||||||||||||||||||
| 485 | 0 | my $st = "select Name,ID from Extract where "; | |||||||||||||||||||||||||||||||||||||
| 486 | 0 | ▶ | if ($name =~ /^\d+$/) {$st .= qq{ID = "$name"};} else {$st .= qq{ Name = "$name"};} | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 487 | 0 | my $sh = $dbh->prepare($st); | |||||||||||||||||||||||||||||||||||||
| 488 | 0 | my $rv = $sh->execute; | |||||||||||||||||||||||||||||||||||||
| 489 | 0 | ($name,$id)= $sh->fetchrow_array; | |||||||||||||||||||||||||||||||||||||
| 490 | 0 | ▶ | $id = "-1" unless defined $id; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 491 | 0 | ▶ | $name = "" unless defined $name; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 492 | 0 | return ($id,$name); | |||||||||||||||||||||||||||||||||||||
| 493 | } | ||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||
| 495 | 0 | ▶ | sub _submitterFromSubmitterData { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_submitterFromSubmitterData: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||
| 496 | 0 | my($dbh,$name) = @_; | |||||||||||||||||||||||||||||||||||||
| 497 | 0 | my($id); | |||||||||||||||||||||||||||||||||||||
| 498 | 0 | my $st = "select Name,ID from Submitter where "; | |||||||||||||||||||||||||||||||||||||
| 499 | 0 | ▶ | if ($name =~ /^\d+$/) {$st .= qq{ID = "$name"};} else {$st .= qq{ Name = "$name"};} | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 500 | 0 | my $sh = $dbh->prepare($st); | |||||||||||||||||||||||||||||||||||||
| 501 | 0 | my $rv = $sh->execute; | |||||||||||||||||||||||||||||||||||||
| 502 | 0 | ($name,$id)= $sh->fetchrow_array; | |||||||||||||||||||||||||||||||||||||
| 503 | 0 | ▶ | $id = "-1" unless defined $id; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 504 | 0 | ▶ | $name = "" unless defined $name; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 505 | 0 | return ($id,$name); | |||||||||||||||||||||||||||||||||||||
| 506 | } | ||||||||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||||||||
| 508 | 0 | ▶ | sub _hybridisationIDfromHybridisationData { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_hybridisationIDfromHybridisationData: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||
| 509 | 0 | my($dbh,$name) = @_; | |||||||||||||||||||||||||||||||||||||
| 510 | 0 | my($id); | |||||||||||||||||||||||||||||||||||||
| 511 | 0 | my $st = "select Name,ID from Hybridisation where "; | |||||||||||||||||||||||||||||||||||||
| 512 | 0 | ▶ | if ($name =~ /^\d+$/) {$st .= qq{ID = "$name"};} else {$st .= qq{ Name = "$name"};} | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 513 | 0 | my $sh = $dbh->prepare($st); | |||||||||||||||||||||||||||||||||||||
| 514 | 0 | my $rv = $sh->execute; | |||||||||||||||||||||||||||||||||||||
| 515 | 0 | ($name,$id)= $sh->fetchrow_array; | |||||||||||||||||||||||||||||||||||||
| 516 | 0 | ▶ | $id = "-1" unless defined $id; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 517 | 0 | ▶ | $name = "" unless defined $name; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 518 | 0 | return ($id,$name); | |||||||||||||||||||||||||||||||||||||
| 519 | } | ||||||||||||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||||||||||||
| 521 | 0 | ▶ | sub _imageIDfromImageData { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_imageIDfromImageData: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||
| 522 | 0 | my($dbh,$name) = @_; | |||||||||||||||||||||||||||||||||||||
| 523 | 0 | my($id); | |||||||||||||||||||||||||||||||||||||
| 524 | 0 | my $st = "select Name,ID from Image where "; | |||||||||||||||||||||||||||||||||||||
| 525 | 0 | ▶ | if ($name =~ /^\d+$/) {$st .= qq{ID = "$name"};} else {$st .= qq{ Name = "$name"};} | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 526 | 0 | my $sh = $dbh->prepare($st); | |||||||||||||||||||||||||||||||||||||
| 527 | 0 | my $rv = $sh->execute; | |||||||||||||||||||||||||||||||||||||
| 528 | 0 | ($name,$id)= $sh->fetchrow_array; | |||||||||||||||||||||||||||||||||||||
| 529 | 0 | ▶ | $id = "-1" unless defined $id; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 530 | 0 | ▶ | $name = "" unless defined $name; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 531 | 0 | return ($id,$name); | |||||||||||||||||||||||||||||||||||||
| 532 | } | ||||||||||||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||||||||||||
| 534 | 0 | ▶ | sub _columns_in_file { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_columns_in_file: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||||||||
| 535 | 0 | my($f) = @_; | |||||||||||||||||||||||||||||||||||||
| 536 | 0 | my($fileType,$l,$name,@col); | |||||||||||||||||||||||||||||||||||||
| 537 | 0 | $fileType = _theFileFormat($f); | |||||||||||||||||||||||||||||||||||||
| 538 | 0 | open(IN,$f); | |||||||||||||||||||||||||||||||||||||
| 539 | 0 | ▶ | if ($fileType eq "AFF") { | ||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||
| 540 | 0 | ▶ | $l = ""; while ($l !~ /Analysis Name/) {$l = <IN>;} chomp($l); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 541 | 0 | foreach $name (split(/\t/,$l)) { | |||||||||||||||||||||||||||||||||||||
| 542 | 0 | push(@col,$name); | |||||||||||||||||||||||||||||||||||||
| 543 | } | ||||||||||||||||||||||||||||||||||||||
| 544 | } elsif ($fileType eq "TOR") { | ||||||||||||||||||||||||||||||||||||||
| 545 | 0 | ▶ | while ($l = <IN>) { last if ($l =~ /Begin Measurements/); } | ||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||
| 546 | 0 | $l = <IN>; chomp($l); | |||||||||||||||||||||||||||||||||||||
| 547 | 0 | foreach $name (split(/\t/,$l)) { | |||||||||||||||||||||||||||||||||||||
| 548 | 0 | push(@col,$name); | |||||||||||||||||||||||||||||||||||||
| 549 | } | ||||||||||||||||||||||||||||||||||||||
| 550 | } | ||||||||||||||||||||||||||||||||||||||
| 551 | 0 | close(IN); | |||||||||||||||||||||||||||||||||||||
| 552 | 0 | return @col; | |||||||||||||||||||||||||||||||||||||
| 553 | } | ||||||||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||||||||
| 555 | 0 | ▶ | sub _loadFromAffimetrixFile { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_loadFromAffimetrixFile: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||
| 556 | 0 | my ($f,$column)=@_; | |||||||||||||||||||||||||||||||||||||
| 557 | 0 | my(@data,$value,$l); | |||||||||||||||||||||||||||||||||||||
| 558 | 0 | open(IN,$f); | |||||||||||||||||||||||||||||||||||||
| 559 | 0 | ▶ | while ($l = <IN>) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 560 | 0 | ▶ | next if ($l !~ /^\d/); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 561 | 0 | chomp($l); | |||||||||||||||||||||||||||||||||||||
| 562 | 0 | $value = (split(/\t/,$l))[$column]; | |||||||||||||||||||||||||||||||||||||
| 563 | 0 | push(@data,$value); | |||||||||||||||||||||||||||||||||||||
| 564 | } | ||||||||||||||||||||||||||||||||||||||
| 565 | 0 | close(IN); | |||||||||||||||||||||||||||||||||||||
| 566 | 0 | return @data; | |||||||||||||||||||||||||||||||||||||
| 567 | } | ||||||||||||||||||||||||||||||||||||||
| 568 | |||||||||||||||||||||||||||||||||||||||
| 569 | 0 | ▶ | sub _loadFromOtherFile{ | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_loadFromOtherFile: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||
| 570 | 0 | my ($f,$column)=@_; | |||||||||||||||||||||||||||||||||||||
| 571 | 0 | my($l,@data,$value); | |||||||||||||||||||||||||||||||||||||
| 572 | 0 | open(IN,$f); | |||||||||||||||||||||||||||||||||||||
| 573 | 0 | ▶ | while ($l = <IN>) { last if ($l =~ /Begin Measurements/); } | ||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||
| 574 | 0 | ▶ | while ($l = <IN>) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 575 | 0 | ▶ | last if ($l =~ /^End/); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 576 | 0 | ▶ | next if ($l !~ /^\d/); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 577 | 0 | chomp($l); | |||||||||||||||||||||||||||||||||||||
| 578 | 0 | $value = (split(/\t/,$l))[$column]; | |||||||||||||||||||||||||||||||||||||
| 579 | 0 | push(@data,$value); | |||||||||||||||||||||||||||||||||||||
| 580 | } | ||||||||||||||||||||||||||||||||||||||
| 581 | 0 | close(IN); | |||||||||||||||||||||||||||||||||||||
| 582 | 0 | return @data; | |||||||||||||||||||||||||||||||||||||
| 583 | } | ||||||||||||||||||||||||||||||||||||||
| 584 | |||||||||||||||||||||||||||||||||||||||
| 585 | 0 | ▶ | sub _loadFromFile { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_loadFromFile: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||
| 586 | 0 | my($fileType,$f,$column) = @_; | |||||||||||||||||||||||||||||||||||||
| 587 | 0 | my @data; | |||||||||||||||||||||||||||||||||||||
| 588 | 0 | ▶ | if ($column !~ /^\d+$/) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 589 | 0 | my @col = _columns_in_file($f); | |||||||||||||||||||||||||||||||||||||
| 590 | 0 | my $i = 0; my $a; | |||||||||||||||||||||||||||||||||||||
| 591 | 0 | foreach $a (@col) { | |||||||||||||||||||||||||||||||||||||
| 592 | 0 | ▶ | if ($a eq $column) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 593 | 0 | $column = $i; | |||||||||||||||||||||||||||||||||||||
| 594 | 0 | last; | |||||||||||||||||||||||||||||||||||||
| 595 | } | ||||||||||||||||||||||||||||||||||||||
| 596 | 0 | $i++; | |||||||||||||||||||||||||||||||||||||
| 597 | } | ||||||||||||||||||||||||||||||||||||||
| 598 | } | ||||||||||||||||||||||||||||||||||||||
| 599 | 0 | ▶ | if ($fileType eq "AFF") { | ||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||
| 600 | 0 | @data = _loadFromAffimetrixFile($f,$column); | |||||||||||||||||||||||||||||||||||||
| 601 | } elsif ($fileType eq "TOR") { | ||||||||||||||||||||||||||||||||||||||
| 602 | 0 | @data = _loadFromOtherFile($f,$column); | |||||||||||||||||||||||||||||||||||||
| 603 | } else { | ||||||||||||||||||||||||||||||||||||||
| 604 | 0 | print "Unknown file type\n"; | |||||||||||||||||||||||||||||||||||||
| 605 | } | ||||||||||||||||||||||||||||||||||||||
| 606 | 0 | return @data; | |||||||||||||||||||||||||||||||||||||
| 607 | } | ||||||||||||||||||||||||||||||||||||||
| 608 | |||||||||||||||||||||||||||||||||||||||
| 609 | 0 | ▶ | sub _experimentIDfromExperiment { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_experimentIDfromExperiment: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||
| 610 | 0 | my($dbh,$name,$subid) = @_; | |||||||||||||||||||||||||||||||||||||
| 611 | 0 | my($id); | |||||||||||||||||||||||||||||||||||||
| 612 | 0 | my $st = "select Name,ID from Experiment where submitter_id = $subid and "; | |||||||||||||||||||||||||||||||||||||
| 613 | 0 | ▶ | if ($name =~ /^\d+$/) {$st .= qq{ID = "$name"};} else {$st .= qq{ Name = "$name"};} | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 614 | 0 | my $sh = $dbh->prepare($st); | |||||||||||||||||||||||||||||||||||||
| 615 | 0 | my $rv = $sh->execute; | |||||||||||||||||||||||||||||||||||||
| 616 | 0 | ($name,$id)= $sh->fetchrow_array; | |||||||||||||||||||||||||||||||||||||
| 617 | 0 | ▶ | $id = "-1" unless defined $id; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 618 | 0 | ▶ | $name = "" unless defined $name; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 619 | 0 | return ($id,$name); | |||||||||||||||||||||||||||||||||||||
| 620 | } | ||||||||||||||||||||||||||||||||||||||
| 621 | |||||||||||||||||||||||||||||||||||||||
| 622 | 0 | ▶ | sub _arrayIDfromArrayType { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_arrayIDfromArrayType: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||
| 623 | 0 | my($dbh,$arrayType)=@_; | |||||||||||||||||||||||||||||||||||||
| 624 | 0 | my $st = qq{select ID from ArrayType where Name = "$arrayType"}; | |||||||||||||||||||||||||||||||||||||
| 625 | 0 | my $sh = $dbh->prepare($st); | |||||||||||||||||||||||||||||||||||||
| 626 | 0 | my $rv = $sh->execute; | |||||||||||||||||||||||||||||||||||||
| 627 | 0 | my $id = $sh->fetchrow_array; | |||||||||||||||||||||||||||||||||||||
| 628 | 0 | ▶ | $id = "-1" unless defined $id; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 629 | 0 | return $id; | |||||||||||||||||||||||||||||||||||||
| 630 | } | ||||||||||||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||||||||||||
| 632 | 0 | ▶ | sub _theFileFormat { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_theFileFormat: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||
| 633 | 0 | my($f) = @_; my($l,$fileType); | |||||||||||||||||||||||||||||||||||||
| 634 | 0 | open(IN,$f); $l = <IN>; close(IN); | |||||||||||||||||||||||||||||||||||||
| 635 | 0 | ▶ | if ($l =~ /Expression Analysis: Metrics Tab/) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||
| 636 | 0 | $fileType = "AFF"; | |||||||||||||||||||||||||||||||||||||
| 637 | } elsif ($l =~ /^\?\?/) { | ||||||||||||||||||||||||||||||||||||||
| 638 | 0 | $fileType = "TOR"; | |||||||||||||||||||||||||||||||||||||
| 639 | } else { | ||||||||||||||||||||||||||||||||||||||
| 640 | 0 | $fileType = "UNK"; | |||||||||||||||||||||||||||||||||||||
| 641 | } | ||||||||||||||||||||||||||||||||||||||
| 642 | 0 | return $fileType; | |||||||||||||||||||||||||||||||||||||
| 643 | } | ||||||||||||||||||||||||||||||||||||||
| 644 | |||||||||||||||||||||||||||||||||||||||
| 645 | 0 | ▶ | sub _error { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_error: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||
| 646 | 0 | my($errnum,$errval)=@_; | |||||||||||||||||||||||||||||||||||||
| 647 | 0 | print STDERR "Error $errnum: $errval\n"; | |||||||||||||||||||||||||||||||||||||
| 648 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||
| 649 | } | ||||||||||||||||||||||||||||||||||||||
| 650 | |||||||||||||||||||||||||||||||||||||||
| 651 | 1 | 1; | |||||||||||||||||||||||||||||||||||||
| 652 | __END__ | ||||||||||||||||||||||||||||||||||||||