Skip to content

Commit

Permalink
Merge pull request #408 from keithj/hotfix
Browse files Browse the repository at this point in the history
Fix for handling repeat scans.
  • Loading branch information
Iain Bancarz committed May 13, 2016
2 parents ffedb00 + 425928e commit 830fc8e
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 11 deletions.
11 changes: 6 additions & 5 deletions src/perl/Build.PL
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ my $build = Build->new
'Module::Build' => 0.42
},
test_requires => {
'TAP::Harness' => '>= 3.30',
'Test::Class' => '>= 0.41',
'Test::More' => '>= 0.98',
'Test::Exception' => '>= 0.32',
'Test::Compile' => 0
'TAP::Harness' => '>= 3.30',
'Test::Class' => '>= 0.41',
'Test::MockObject' => 0,
'Test::More' => '>= 0.98',
'Test::Exception' => '>= 0.32',
'Test::Compile' => 0
},
requires => {
'Config::IniFiles' => '>= 2.8.6',
Expand Down
10 changes: 5 additions & 5 deletions src/perl/lib/WTSI/NPG/Genotyping/Database/Infinium.pm
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ sub find_called_file_project {
idat_grn_path => <path string of IDAT format result file>,
idat_red_path => <path string of IDAT format result file>,
image_date => <Imaging date, DB native format>,
iso_image_date => <Imaging date, ISO8601 format> }
image_iso_date => <Imaging date, ISO8601 format> }
The finds all samples in a project, even those that have
never been scanned. For those that have been scanned more than
Expand Down Expand Up @@ -520,7 +520,7 @@ sub find_project_samples {
idat_grn_path => <path string of IDAT format result file>,
idat_red_path => <path string of IDAT format result file>,
image_date => <Imaging date, DB native format>,
iso_image_date => <Imaging date, ISO8601 format>}
image_iso_date => <Imaging date, ISO8601 format>}
Returntype : hashref
=cut
Expand Down Expand Up @@ -625,7 +625,7 @@ sub find_project_completed_samples {
idat_grn_path => <path string of IDAT format result file>,
idat_red_path => <path string of IDAT format result file>,
image_date => <Imaging date, DB native format>,
iso_image_date => <Imaging date, ISO8601 format>}
image_iso_date => <Imaging date, ISO8601 format>}
Returntype : hashref
=cut
Expand Down Expand Up @@ -679,7 +679,7 @@ sub find_scanned_sample {
idat_grn_path => <path string of IDAT format result file>,
idat_red_path => <path string of IDAT format result file>,
image_date => <Imaging date, DB native format>,
iso_image_date => <Imaging date, ISO8601 format>}
image_iso_date => <Imaging date, ISO8601 format>}
Returntype : hashref
=cut
Expand Down Expand Up @@ -915,10 +915,10 @@ sub _choose_from_scans {

foreach my $sample (@$samples) {
my $name = $sample->{sample};
push @sample_names, $name;

unless (exists $samples_by_name{$name}) {
$samples_by_name{$name} = [];
push @sample_names, $name;
}

push @{$samples_by_name{$name}}, $sample;
Expand Down
83 changes: 82 additions & 1 deletion src/perl/t/WTSI/NPG/Genotyping/Database/InfiniumTest.pm
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ use strict;
use warnings;

use base qw(WTSI::NPG::Test);
use Test::More tests => 13;
use Test::More tests => 14;
use Test::Exception;
use Test::MockObject;

use Log::Log4perl;

Expand Down Expand Up @@ -60,4 +61,84 @@ sub disconnect : Test(4) {
}
}

sub repeat_scans : Test(1) {

my $db = WTSI::NPG::Genotyping::Database::Infinium->new
(name => 'infinium',
inifile => $db_credentials);

# This test is fragile because it relies on knowing about the
# internals of the package under test. However, it's better than
# nothing, until we commit resources to refactoring.
my $sth = Test::MockObject->new;
$sth->set_true('execute');
$sth->set_series('fetchrow_hashref',
{plate => 'ABC123456-DNA',
well => 'A01',
sample => 'sample1',
beadchip => '0123456789',
beadchip_section => 'R01C01',
beadchip_design => 'test_design',
beadchip_revision => '1',
status => 'Pass',
gtc_file => 'test.gtc',
idat_grn_file => 'test_Grn.idat',
idat_red_file => 'test_Red.idat',
idat_grn_path => '/test',
idat_red_path => '/test',
image_date => '',
image_iso_date => '2016-10-01'},
{plate => 'ABC123456-DNA',
well => 'A01',
sample => 'sample1',
beadchip => '0123456789',
beadchip_section => 'R01C01',
beadchip_design => 'test_design',
beadchip_revision => '1',
status => 'Pass',
gtc_file => 'test.gtc',
idat_grn_file => 'test_Grn.idat',
idat_red_file => 'test_Red.idat',
idat_grn_path => '/test',
idat_red_path => '/test',
image_date => '',
image_iso_date => '2016-10-02'},
{plate => 'ABC123456-DNA',
well => 'A01',
sample => 'sample1',
beadchip => '0123456789',
beadchip_section => 'R01C01',
beadchip_design => 'test_design',
beadchip_revision => '1',
status => 'Pass',
gtc_file => 'test.gtc',
idat_grn_file => 'test_Grn.idat',
idat_red_file => 'test_Red.idat',
idat_grn_path => '/test',
idat_red_path => '/test',
image_date => '',
image_iso_date => '2016-10-03'});

my $dbh = Test::MockObject->new;
$dbh->set_always('prepare', $sth);
$db->dbh($dbh);

is_deeply($db->find_project_samples('test'),
[{plate => 'ABC123456-DNA',
well => 'A01',
sample => 'sample1',
beadchip => '0123456789',
beadchip_section => 'R01C01',
beadchip_design => 'test_design',
beadchip_revision => '1',
status => 'Pass',
gtc_file => 'test.gtc',
idat_grn_file => 'test_Grn.idat',
idat_red_file => 'test_Red.idat',
idat_grn_path => '/test',
idat_red_path => '/test',
image_date => '',
image_iso_date => '2016-10-03'}],
'Repeat scans resolved to latest');
}
1;

0 comments on commit 830fc8e

Please sign in to comment.