Bio-VertRes-Config
view release on metacpan or search on metacpan
lib/Bio/VertRes/Config/Pipelines/Common.pm view on Meta::CPAN
return $ENV{VRTRACK_PASSWORD};
}
sub _build__database_connection_details {
my ($self) = @_;
my $connection_details;
if ( -f $self->database_connect_file ) {
my $text = read_file( $self->database_connect_file );
$connection_details = eval($text);
}
return $connection_details;
}
sub _limits_values_part_of_filename {
my ($self) = @_;
my $output_filename = "";
my @limit_values;
for my $limit_type (qw(project sample library species lane)) {
if ( defined $self->limits->{$limit_type} ) {
my $list_of_limit_values = $self->limits->{$limit_type};
for my $limit_value ( @{$list_of_limit_values} ) {
$limit_value =~ s/^\s+|\s+$//g;
push( @limit_values, $limit_value );
}
}
}
if ( @limit_values > 0 ) {
$output_filename = join( '_', @limit_values );
}
return $output_filename;
}
sub _filter_characters_truncate_and_add_suffix {
my ( $self, $output_filename, $suffix ) = @_;
$output_filename =~ s!\W+!_!g;
$output_filename =~ s/_$//g;
$output_filename =~ s/_+/_/g;
if ( length($output_filename) > 150 ) {
$output_filename = substr( $output_filename, 0, 146 ) . '_' . int( rand(999) );
}
return join( '.', ( $output_filename, $suffix ) );
}
sub create_config_file {
my ($self) = @_;
my $mode = 0777;
if ( !( -e $self->config ) ) {
my ( $config_filename, $directories, $suffix ) = fileparse( $self->config );
make_path( $directories, {mode => $mode} );
}
# If the file exists and you dont want to overwrite existing files, skip it
return if ( ( -e $self->config ) && $self->overwrite_existing_config_file == 0 );
# dont print out an extra wrapper variable
$Data::Dumper::Terse = 1;
write_file( $self->config, Dumper( $self->to_hash ) );
chmod $mode, $self->config;
}
sub to_hash {
my ($self) = @_;
my %output_hash = (
root => $self->root,
module => $self->module,
prefix => $self->prefix,
log => $self->log,
db => {
database => $self->database,
host => $self->host,
port => $self->port,
user => $self->user,
password => $self->password,
},
data => {
dont_wait => 0,
db => {
database => $self->database,
host => $self->host,
port => $self->port,
user => $self->user,
password => $self->password,
},
}
);
return \%output_hash;
}
no Moose;
__PACKAGE__->meta->make_immutable;
1;
__END__
=pod
=head1 NAME
Bio::VertRes::Config::Pipelines::Common - A set of attributes common to all pipeline config files
=head1 VERSION
version 1.133090
=head1 SYNOPSIS
A set of attributes common to all pipeline config files. It is ment to be extended rather than used on its own.
use Bio::VertRes::Config::Pipelines::Common;
extends 'Bio::VertRes::Config::Pipelines::Common';
=head1 AUTHOR
Andrew J. Page <ap13@sanger.ac.uk>
=head1 COPYRIGHT AND LICENSE
( run in 0.525 second using v1.01-cache-2.11-cpan-39bf76dae61 )