Bio-VertRes-Config
view release on metacpan or search on metacpan
lib/Bio/VertRes/Config/CommandLine/StudyNameSearch.pm view on Meta::CPAN
use Moose;
use Bio::VertRes::Config::RegisterStudy;
with 'Bio::VertRes::Config::Pipelines::Roles::RootDatabaseLookup';
has 'default_database_name' => ( is => 'ro', isa => 'Str', required => 1 );
has 'study_name' => ( is => 'ro', isa => 'Str', required => 1 );
has 'config_base' => ( is => 'ro', isa => 'Str', required => 1 );
sub get_study_database_name_or_default_if_not_found {
my ($self) = @_;
#Â In the normal case the study will be in the default database, so check it first to save on IO
if (
Bio::VertRes::Config::RegisterStudy->new(
database => $self->default_database_name,
study_name => $self->study_name,
config_base => $self->config_base
)->is_study_in_file_already == 1
)
lib/Bio/VertRes/Config/CommandLine/StudyNameSearch.pm view on Meta::CPAN
=head1 SYNOPSIS
Prevent a study name from being registered in two different databases.
use Bio::VertRes::Config::CommandLine::StudyNameSearch;
my $obj = Bio::VertRes::Config::CommandLine::StudyNameSearch->new(
default_database_name => 'pathogen_rnd_track',
config_base => $destination_directory,
study_name => 'Unseen study'
);
$obj->get_study_database_name_or_default_if_not_found;
=head1 METHODS
=head2 get_study_database_name_or_default_if_not_found
Lookup the study name in all the standard databases. If its found then return that database. If its a new study return the default.
=head1 AUTHOR
Andrew J. Page <ap13@sanger.ac.uk>
=head1 COPYRIGHT AND LICENSE
This software is Copyright (c) 2013 by Wellcome Trust Sanger Institute.
lib/Bio/VertRes/Config/Recipes/Common.pm view on Meta::CPAN
my ($self) = @_;
if(defined($self->limits->{project}))
{
for my $study_name ( @{$self->limits->{project}} )
{
$self->database(Bio::VertRes::Config::CommandLine::StudyNameSearch->new(
default_database_name => $self->database,
config_base => $self->config_base,
study_name => $study_name,
)->get_study_database_name_or_default_if_not_found);
}
}
};
sub create {
my ($self) = @_;
my $top_level = Bio::VertRes::Config::MultipleTopLevelFiles->new(
database => $self->database,
t/Bio/VertRes/Config/CommandLine/StudyNameSearch.t view on Meta::CPAN
Bio::VertRes::Config::RegisterStudy->new(database => 'pathogen_rnd_track', study_name => 'EFG study',config_base => $destination_directory)->register_study_name();
Bio::VertRes::Config::RegisterStudy->new(database => 'pathogen_prok_track', study_name => 'CCC',config_base => $destination_directory)->register_study_name();
Bio::VertRes::Config::RegisterStudy->new(database => 'pathogen_euk_track', study_name => 'DDD',config_base => $destination_directory)->register_study_name();
ok(my $obj = Bio::VertRes::Config::CommandLine::StudyNameSearch->new(
default_database_name => 'pathogen_rnd_track',
config_base => $destination_directory,
study_name => 'Unseen study'
), 'Initialise object for unseen study');
is($obj->get_study_database_name_or_default_if_not_found, 'pathogen_rnd_track', 'unseen study returns default database');
ok($obj = Bio::VertRes::Config::CommandLine::StudyNameSearch->new(
default_database_name => 'pathogen_rnd_track',
config_base => $destination_directory,
study_name => 'ABC study'
), 'Initialise object for seen study in default database');
is($obj->get_study_database_name_or_default_if_not_found, 'pathogen_rnd_track', 'seen study in default database should return default');
ok($obj = Bio::VertRes::Config::CommandLine::StudyNameSearch->new(
default_database_name => 'pathogen_prok_track',
config_base => $destination_directory,
study_name => 'EFG study'
), 'Initialise object for seen study in different database');
is($obj->get_study_database_name_or_default_if_not_found, 'pathogen_rnd_track', 'find study in another database');
done_testing();
( run in 0.217 second using v1.01-cache-2.11-cpan-0a987023a57 )