diff --git a/lib/npg/samplesheet.pm b/lib/npg/samplesheet.pm index e80fab86..1c342174 100755 --- a/lib/npg/samplesheet.pm +++ b/lib/npg/samplesheet.pm @@ -69,19 +69,6 @@ Readonly::Scalar my $DEFAULT_LIMS_DRIVER_TYPE => 'ml_warehouse'; ####################### Public attributes ######################## ################################################################## -=head2 lims_driver_type - -LIMs driver type to use, defaults to ml_warehouse. - -=cut - -has 'lims_driver_type' => ( - 'isa' => 'Str', - 'required' => 0, - 'is' => 'ro', - 'default' => $DEFAULT_LIMS_DRIVER_TYPE, -); - =head2 id_run An optional attribute @@ -208,8 +195,12 @@ sub _build_run { An attribute, an array of st::api::lims type objects. +To generate a samplesheet for the whole run, provide an array of +at::api::lims objects for all lanes of the run. + This attribute should normally be provided by the caller via the -constuctor. If the attribute is not provided, it it built automatically. +constuctor. If the attribute is not provided, it is built automatically, +using the ml_warehouse lims driver. =cut @@ -221,19 +212,13 @@ has 'lims' => ( sub _build_lims { my $self=shift; - my $ref = {driver_type => $self->lims_driver_type}; - my $batch_id = $self->run->batch_id; - if ($self->lims_driver_type eq $DEFAULT_LIMS_DRIVER_TYPE) { - $ref->{'id_flowcell_lims'} = $batch_id; - $ref->{'mlwh_schema'} = $self->mlwh_schema; - } elsif ($self->lims_driver_type eq 'xml') { - $ref->{'batch_id'} = $batch_id; - } else { - croak sprintf 'Lazy-build for driver type %s is not inplemented', - $self->lims_driver_type; - } + my $run_lims = st::api::lims->new( + driver_type => $DEFAULT_LIMS_DRIVER_TYPE, + id_flowcell_lims => $self->run->batch_id, + mlwh_schema => $self->mlwh_schema + ); - return [st::api::lims->new($ref)->children]; + return [$run_lims->children()]; }; =head2 output diff --git a/t/47-samplesheet.t b/t/47-samplesheet.t index a74dc5fc..f8753b25 100644 --- a/t/47-samplesheet.t +++ b/t/47-samplesheet.t @@ -1,6 +1,6 @@ use strict; use warnings; -use Test::More tests => 12; +use Test::More tests => 11; use Test::LongString; use Test::Exception; use File::Slurp; @@ -26,22 +26,8 @@ local $ENV{NPG_WEBSERVICE_CACHE_DIR} = q(t/data/samplesheet); my $dir = tempdir( CLEANUP => 1 ); -subtest 'error on an unknown driver type' => sub { - plan tests => 1; - - throws_ok { - npg::samplesheet->new( - lims_driver_type => 'foo', - repository => $dir, - npg_tracking_schema => $schema, - mlwh_schema => $mlwh_schema, - id_run => 7007)->lims() - } qr/Lazy-build for driver type foo is not inplemented/, - 'error with the driver type for which LIMS objects cannot be built'; -}; - subtest 'simple tests for the default driver' => sub { - plan tests => 2; + plan tests => 1; my $ss = npg::samplesheet->new( repository => $dir, @@ -49,7 +35,6 @@ subtest 'simple tests for the default driver' => sub { mlwh_schema => $mlwh_schema, id_run => 7007 ); - is ($ss->lims_driver_type, 'ml_warehouse', 'correct default driver type'); my $lims = $ss->lims(); is (@{$lims}, 1, 'LIMS data for 1 lane is built'); };