line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Bio::VertRes::Config::RegisterStudy; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: Register a study |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
222061
|
use Moose; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use File::Basename; |
8
|
|
|
|
|
|
|
use File::Path qw(make_path); |
9
|
|
|
|
|
|
|
use Bio::VertRes::Config::Exceptions; |
10
|
|
|
|
|
|
|
with 'Bio::VertRes::Config::Pipelines::Roles::RootDatabaseLookup'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has 'database' => ( is => 'ro', isa => 'Str', required => 1 ); |
13
|
|
|
|
|
|
|
has 'study_name' => ( is => 'ro', isa => 'Str', required => 1 ); |
14
|
|
|
|
|
|
|
has 'config_base' => ( is => 'ro', isa => 'Str', default => '/nfs/pathnfs05/conf' ); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
has 'study_file_name' => ( is => 'ro', isa => 'Str', lazy => 1, builder => '_build_study_file_name' ); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub _build_study_file_name |
19
|
|
|
|
|
|
|
{ |
20
|
|
|
|
|
|
|
my ($self) = @_; |
21
|
|
|
|
|
|
|
my $filename = join( '.', ( $self->root_database_name, 'ilm','studies' ) ); |
22
|
|
|
|
|
|
|
return join('/',($self->config_base,$self->root_database_name, $filename)); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub is_study_in_file_already |
26
|
|
|
|
|
|
|
{ |
27
|
|
|
|
|
|
|
my ($self) = @_; |
28
|
|
|
|
|
|
|
if(-e $self->study_file_name) |
29
|
|
|
|
|
|
|
{ |
30
|
|
|
|
|
|
|
open(my $study_file_name_fh, $self->study_file_name) or Bio::VertRes::Config::Exceptions::FileDoesntExist->throw(error => 'Couldnt open file '.$self->study_file_name); |
31
|
|
|
|
|
|
|
while(<$study_file_name_fh>) |
32
|
|
|
|
|
|
|
{ |
33
|
|
|
|
|
|
|
my $line = $_; |
34
|
|
|
|
|
|
|
chomp($line); |
35
|
|
|
|
|
|
|
next if($line =~ /^#/); |
36
|
|
|
|
|
|
|
next if($line =~ /^\s*$/); |
37
|
|
|
|
|
|
|
#Â If the study is already in the file, do nothing |
38
|
|
|
|
|
|
|
return 1 if($self->study_name eq $line); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
close($study_file_name_fh); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
return 0; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub register_study_name { |
47
|
|
|
|
|
|
|
my ($self) = @_; |
48
|
|
|
|
|
|
|
return $self if($self->is_study_in_file_already == 1); |
49
|
|
|
|
|
|
|
my $mode = 0777; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
if(!(-e $self->study_file_name)) |
52
|
|
|
|
|
|
|
{ |
53
|
|
|
|
|
|
|
my($overall_config_filename, $directories, $suffix) = fileparse($self->study_file_name); |
54
|
|
|
|
|
|
|
make_path($directories, {mode => $mode}); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# Study is not in the file so append it to the end, or create a file if it doesnt exist |
58
|
|
|
|
|
|
|
open(my $study_file_name_write_fh, '+>>', $self->study_file_name) or Bio::VertRes::Config::Exceptions::FileDoesntExist->throw(error => 'Couldnt open file for append '.$self->study_file_name); |
59
|
|
|
|
|
|
|
print {$study_file_name_write_fh} $self->study_name."\n"; |
60
|
|
|
|
|
|
|
close($study_file_name_write_fh); |
61
|
|
|
|
|
|
|
chmod $mode, $self->study_file_name; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
return $self; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
67
|
|
|
|
|
|
|
no Moose; |
68
|
|
|
|
|
|
|
1; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
__END__ |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=pod |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 NAME |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Bio::VertRes::Config::RegisterStudy - Register a study |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 VERSION |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
version 1.133090 |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 SYNOPSIS |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Register a study. Its just a wrapper around a list of study names |
85
|
|
|
|
|
|
|
use Bio::VertRes::Config::RegisterStudy; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
my $pipeline = Bio::VertRes::Config::RegisterStudy->new(database => 'abc', study_name => 'ABC study'); |
88
|
|
|
|
|
|
|
$pipeline->register_study_name(); |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 AUTHOR |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Andrew J. Page <ap13@sanger.ac.uk> |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
This software is Copyright (c) 2013 by Wellcome Trust Sanger Institute. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
This is free software, licensed under: |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
The GNU General Public License, Version 3, June 2007 |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=cut |