| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Bio::VertRes::Config::CommandLine::ConstructLimits; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: Put the limits together |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
136931
|
use Moose; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use Bio::VertRes::Config::Exceptions; |
|
8
|
|
|
|
|
|
|
use File::Slurp; |
|
9
|
|
|
|
|
|
|
use DBI; |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has 'input_type' => ( is => 'ro', isa => 'Str', required => 1 ); |
|
13
|
|
|
|
|
|
|
has 'input_id' => ( is => 'ro', isa => 'Str', required => 1 ); |
|
14
|
|
|
|
|
|
|
has 'species' => ( is => 'ro', isa => 'Maybe[Str]' ); |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub limits_hash |
|
17
|
|
|
|
|
|
|
{ |
|
18
|
|
|
|
|
|
|
my ($self) = @_; |
|
19
|
|
|
|
|
|
|
my %limits; |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
if($self->input_type eq 'study' && $self->input_id =~ /^[\d]+$/) |
|
22
|
|
|
|
|
|
|
{ |
|
23
|
|
|
|
|
|
|
# Todo: move ssid lookup to somewhere more sensible |
|
24
|
|
|
|
|
|
|
my $dbh = DBI->connect("DBI:mysql:host=mcs7:port=3379;database=sequencescape_warehouse", "warehouse_ro",undef, {'RaiseError' => 1, 'PrintError' => 0}); |
|
25
|
|
|
|
|
|
|
my $sql = "select name from current_studies where internal_id = '".$self->input_id."' "; |
|
26
|
|
|
|
|
|
|
my @study_names = $dbh->selectrow_array($sql ); |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# |
|
29
|
|
|
|
|
|
|
#for my $study_name( @study_names) |
|
30
|
|
|
|
|
|
|
#{ |
|
31
|
|
|
|
|
|
|
# $study_name =~ s/^\\([^-\w$()*+.\/?@\[\\\]^{|}])$/$1/; |
|
32
|
|
|
|
|
|
|
#} |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
$limits{project} = \@study_names; |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
elsif($self->input_type eq 'study') |
|
38
|
|
|
|
|
|
|
{ |
|
39
|
|
|
|
|
|
|
$limits{project} = [$self->input_id]; |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
elsif($self->input_type eq 'library' || $self->input_type eq 'sample') |
|
42
|
|
|
|
|
|
|
{ |
|
43
|
|
|
|
|
|
|
$limits{$self->input_type} = [$self->input_id]; |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
elsif($self->input_type eq 'lane') |
|
46
|
|
|
|
|
|
|
{ |
|
47
|
|
|
|
|
|
|
if($self->input_id =~ /^\d+_\d$/) |
|
48
|
|
|
|
|
|
|
{ |
|
49
|
|
|
|
|
|
|
$limits{$self->input_type} = [$self->input_id.'(#.+)?']; |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
else |
|
52
|
|
|
|
|
|
|
{ |
|
53
|
|
|
|
|
|
|
$limits{$self->input_type} = [$self->input_id]; |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
elsif($self->input_type eq 'file') |
|
57
|
|
|
|
|
|
|
{ |
|
58
|
|
|
|
|
|
|
$limits{lane} = $self->_extract_lanes_from_file; |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
else |
|
61
|
|
|
|
|
|
|
{ |
|
62
|
|
|
|
|
|
|
Bio::VertRes::Config::Exceptions::InvalidType->throw(error => 'Invalid type passed in, can only be one of study/file/lane/library/sample not '.$self->input_type); |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
if(defined($self->species)) |
|
66
|
|
|
|
|
|
|
{ |
|
67
|
|
|
|
|
|
|
$limits{species} = [$self->species]; |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
return \%limits; |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub _extract_lanes_from_file |
|
74
|
|
|
|
|
|
|
{ |
|
75
|
|
|
|
|
|
|
my ($self) = @_; |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
my $file_contents = read_file( $self->input_id ) or Bio::VertRes::Config::Exceptions::FileDoesntExist->throw(error => 'Couldnt open the file '.$self->input_id); |
|
78
|
|
|
|
|
|
|
my @lanes = split(/[\n\r]+/, $file_contents); |
|
79
|
|
|
|
|
|
|
my @filtered_lanes; |
|
80
|
|
|
|
|
|
|
for my $lane (@lanes) |
|
81
|
|
|
|
|
|
|
{ |
|
82
|
|
|
|
|
|
|
next if($lane =~ /^#/); |
|
83
|
|
|
|
|
|
|
next if($lane =~ /^\s*$/); |
|
84
|
|
|
|
|
|
|
$lane = $lane.'(#.+)?' if $lane =~ /^\d+_\d$/; |
|
85
|
|
|
|
|
|
|
push(@filtered_lanes, $lane); |
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
return \@filtered_lanes; |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
|
92
|
|
|
|
|
|
|
no Moose; |
|
93
|
|
|
|
|
|
|
1; |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
__END__ |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=pod |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 NAME |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Bio::VertRes::Config::CommandLine::ConstructLimits - Put the limits together |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 VERSION |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
version 1.133090 |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
A class to represent multiple top level files. It splits out mixed config files into the correct top level files |
|
110
|
|
|
|
|
|
|
use Bio::VertRes::Config::CommandLine::ConstructLimits; |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Bio::VertRes::Config::CommandLine::ConstructLimits->new(input_type => $type, input_id => $id, species => $species)->limits_hash; |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 AUTHOR |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Andrew J. Page <ap13@sanger.ac.uk> |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
This software is Copyright (c) 2013 by Wellcome Trust Sanger Institute. |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
This is free software, licensed under: |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
The GNU General Public License, Version 3, June 2007 |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=cut |