Skip to content

Commit

Permalink
Added the ability to upload well dna status data while ignoring water…
Browse files Browse the repository at this point in the history
… only wells not represented in LIMS2
  • Loading branch information
dparrysmith committed Mar 6, 2013
1 parent cc16240 commit 8cced66
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 14 deletions.
37 changes: 27 additions & 10 deletions lib/LIMS2/Model/Plugin/Well.pm
Expand Up @@ -246,22 +246,39 @@ sub pspec_create_well_dna_status {

sub create_well_dna_status {
my ( $self, $params ) = @_;

my $validated_params = $self->check_params( $params, $self->pspec_create_well_dna_status );

my $well = $self->retrieve_well( { slice_def $validated_params, qw( id plate_name well_name ) } );
my $well;
my $dna_status;
# If the well does not exist on the target plate, we assume that the well in the spreadsheet is
# empty (water or buffer solution only). These wells are not recorded in LIMS2 as it is not
# possible to parent empty wells.
# DJP-S 6/3/13
#
try {
$well = $self->retrieve_well( { slice_def $validated_params, qw( id plate_name well_name ) } );
}
catch {
# If the well doesn't exist make it undef and carry on
$well = undef;
};

#will need to provide some method of changing the dna status level on a well
if ( my $dna_status = $well->well_dna_status ) {
$self->throw( Validation => "Well $well already has a dna status of "
. ( $dna_status->pass == 1 ? 'pass' : 'fail' )
if ( $well ) {
if ( $dna_status = $well->well_dna_status ) {
$self->throw( Validation => "Well $well already has a dna status of "
. ( $dna_status->pass == 1 ? 'pass' : 'fail' )
);
}

$dna_status = $well->create_related(
well_dna_status => { slice_def $validated_params, qw( pass comment_text created_by_id created_at ) }
);
$self->log->debug( 'Well DNA status set to ' . $dna_status->pass . ' for well ' . $dna_status->well_id );
}
else {
$dna_status = undef;
}

my $dna_status = $well->create_related(
well_dna_status => { slice_def $validated_params, qw( pass comment_text created_by_id created_at ) }
);
$self->log->debug( 'Well DNA status set to ' . $dna_status->pass . ' for well ' . $dna_status->well_id );

return $dna_status;
}
Expand Down
15 changes: 12 additions & 3 deletions lib/LIMS2/Model/Util/DataUpload.pm
Expand Up @@ -31,6 +31,7 @@ sub pspec__check_dna_status {
sub upload_plate_dna_status {
my ( $model, $params ) = @_;
my @success_message;
my @failure_message;

my $data = parse_csv_file( $params->{csv_fh} );

Expand All @@ -47,11 +48,19 @@ sub upload_plate_dna_status {
}
);

push @success_message,
$dna_status->well->name . ' - ' . ( $dna_status->pass == 1 ? 'pass' : 'fail' );
if ( $dna_status ) {
push @success_message,
$dna_status->well->name . ' - ' . ( $dna_status->pass == 1 ? 'pass' : 'fail' );
}
else {
# Some of the wells in the input were not present in LIMS2
push @failure_message,
$validated_params->{'well_name'} . ' - well not available in LIMS2';
}
}

return \@success_message;
push my @returned_messages, ( @failure_message, @success_message );
return \@returned_messages;
}

sub check_plate_type {
Expand Down
35 changes: 34 additions & 1 deletion t/80-dna_status_upload.t
@@ -1,4 +1,4 @@
#!/usr/bin/env perl
#!/usr/bin/env perl -d

use strict;
use warnings FATAL => 'all';
Expand Down Expand Up @@ -109,4 +109,37 @@ my $mech = mech();
} 'delete dna status data';
}

{
note( 'Test uploading of empty wells not represented in LIMS2' );

my $plate_data = test_data( 'dna_status.yaml' );
ok my $dna_plate = model->create_plate( $plate_data->{'dna_plate_create_params'} ),
'dna plate creation succeeded';
my $dna_status_update = model->create_well_dna_status ( $plate_data->{'create_well_dna_status_params'} );
ok (! $dna_status_update ,
'dna status update for empty (non-existent LIMS2) well was handled correctly');
my $test_file = File::Temp->new or die('Could not create temp test file ' . $!);
$test_file->print("well_name,dna_status_result,comments\n"
. "A03,pass,this is a comment");
$test_file->seek( 0, 0 );
$mech->get_ok('/user/dna_status_update');
$mech->title_is('DNA Status Update');
ok my $res = $mech->submit_form(
form_id => 'dna_status_update',
fields => {
plate_name => 'DUMMY01',
datafile => $test_file->filename
},
button => 'update_dna_status'
), 'submit form with valid parameters';

ok $res->is_success, '...response is_success';
is $res->base->path, '/user/dna_status_update', '... stays on same page';
like $res->content, qr/Uploaded dna status information onto plate DUMMY01/ ,
'...page has success message';
like $res->content, qr/A03 - well not available in LIMS2/,
'...well A03 not available in LIMS2 -- reported correctly';


}
done_testing;
29 changes: 29 additions & 0 deletions t/data/dna_status.yaml
@@ -0,0 +1,29 @@
---
dna_plate_create_params:
name: DUMMY01
species: Mouse
type: DNA
description: DNA_test
created_by: test_user@example.org
comments:
- comment_text: This test plate is not based on real data
created_by: test_user@example.org
wells:
- well_name: A01
process_type: dna_prep
parent_plate: MOHFAS0001_A
parent_well: A01
- well_name: B01
process_type: dna_prep
parent_plate: MOHFAS0001_A
parent_well: B02
- well_name: C01
process_type: dna_prep
parent_plate: MOHFAS0001_A
parent_well: C03
create_well_dna_status_params:
plate_name: DUMMY01
well_name: A02
pass: true
created_by: test_user@example.org

0 comments on commit 8cced66

Please sign in to comment.