CLIPSeqTools/CompareApp/all.pm untested

filter: Statementstmt 0.0% 0 / 45 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 55 CC 2 SCAR 11.5
CC
2
Cov
0%
run
6.0
validate_args
2.0
BEGIN
2.0
CRAP 3.1
1 =head1 NAME
2  
3 CLIPSeqTools::CompareApp::all - Run all clipseqtools-compare analyses.
4  
5 =head1 SYNOPSIS
6  
7 clipseqtools-compare all [options/parameters]
8  
9 =head1 DESCRIPTION
10  
11 Run all clipseqtools-compare analyses.
12  
13 Takes two libraries (one called input and one called reference) on which all
14 single clipseqtools analyses have ran. Assumes that all single clipseqtools
15 analyses used a common o_prefix for each library.
16  
17 =head1 OPTIONS
18  
19 Input options for library.
20 --driver <Str> driver for database connection (eg. mysql,
21 SQLite).
22 --database <Str> database name or path to database file for
23 file based databases (eg. SQLite).
24 --table <Str> database table.
25 --host <Str> hostname for database connection.
26 --user <Str> username for database connection.
27 --password <Str> password for database connection.
28 --records_class <Str> type of records stored in database.
29 --filter <Filter> filter library. May be used multiple times.
30 Syntax: column_name="pattern"
31 e.g. keep reads with deletions AND not repeat
32 masked AND longer than 31
33 --filter deletion="def"
34 --filter rmsk="undef" .
35 --filter query_length=">31".
36 Operators: >, >=, <, <=, =, !=, def, undef
37 --res_prefix <Str> results prefix of clipseqtools analysis.
38 Should match the o_prefix used when running
39 clipseqtools on the library.
40  
41 Input options for reference library.
42 --r_driver <Str> driver for database connection (eg. mysql,
43 SQLite).
44 --r_database <Str> database name or path to database file for
45 file based databases (eg. SQLite).
46 --r_table <Str> database table.
47 --r_host <Str> hostname for database connection.
48 --r_user <Str> username for database connection.
49 --r_password <Str> password for database connection.
50 --r_records_class <Str> type of records stored in database.
51 --r_filter <Filter> same as filter but for reference library.
52 --r_res_prefix <Str> results prefix of clipseqtools analysis.
53 Should match the o_prefix used when running
54 clipseqtools on the reference library.
55  
56 Other input.
57 --rname_sizes <Str> file with sizes for reference alignment
58 sequences (rnames). Must be tab delimited
59 (chromosome\tsize) with one line per rname.
60  
61 Output
62 --o_prefix <Str> output path prefix. Script will create and add
63 extension to path. Default: ./
64  
65 Other options.
66 -v --verbose print progress lines and extra information.
67 -h -? --usage --help print help message
68  
69 =cut
70  
71 package CLIPSeqTools::CompareApp::all;
72 $CLIPSeqTools::CompareApp::all::VERSION = '1.0.0';
73  
74 # Make it an app command
75 use MooseX::App::Command;
76 extends 'CLIPSeqTools::CompareApp';
77  
78  
79 #######################################################################
80 ####################### Load External modules #####################
81 #######################################################################
82 use Modern::Perl;
83 use autodie;
84 use namespace::autoclean;
85  
86  
87 #######################################################################
88 ####################### Command line options ######################
89 #######################################################################
90 option 'rname_sizes' => (
91 is => 'rw',
92 isa => 'Str',
93 required => 1,
94 documentation => 'file with sizes for reference alignment sequences '.
95 '(rnames). Must be tab delimited (chromosome\tsize) '.
96 'with one line per rname.',
97 );
98  
99 option 'res_prefix' => (
100 is => 'rw',
101 isa => 'Str',
102 required => 1,
103 documentation => 'results prefix of clipseqtools analysis. Should match '.
104 'the o_prefix used when running clipseqtools on the '.
105 'library.',
106 );
107  
108 option 'r_res_prefix' => (
109 is => 'rw',
110 isa => 'Str',
111 required => 1,
112 documentation => 'results prefix of clipseqtools analysis. Should match '.
113 'the o_prefix used when running clipseqtools on the '.
114 'reference library.',
115 );
116  
117  
118 #######################################################################
119 ########################## Consume Roles ##########################
120 #######################################################################
121 with
122 "CLIPSeqTools::Role::Option::Library" => {
123 -alias => {validate_args => '_validate_args_for_library'},
124 -excludes => 'validate_args',
125 },
126 "CLIPSeqTools::Role::Option::ReferenceLibrary" => {
127 -alias => {validate_args => '_validate_args_for_reference_library'},
128 -excludes => 'validate_args',
129 },
130 "CLIPSeqTools::Role::Option::Plot" => {
131 -alias => {validate_args => '_validate_args_for_plot'},
132 -excludes => 'validate_args',
133 },
134 "CLIPSeqTools::Role::Option::OutputPrefix" => {
135 -alias => {validate_args => '_validate_args_for_output_prefix'},
136 -excludes => 'validate_args',
137 };
138  
139  
140 #######################################################################
141 ######################## Interface Methods ########################
142 #######################################################################
143 sub validate_args {
144 my ($self) = @_;
145  
146 $self->_validate_args_for_library;
147 $self->_validate_args_for_reference_library;
148 $self->_validate_args_for_plot;
149 $self->_validate_args_for_output_prefix;
150 }
151  
152 sub run {
153 my ($self) = @_;
154  
155 my %options;
156  
157 map{$options{$_} = $self->$_ if defined $self->$_} (
158 'driver', 'database', 'table', 'host', 'user', 'password',
159 'records_class', 'filter', 'res_prefix', 'r_driver', 'r_database',
160 'r_table', 'r_host', 'r_user', 'r_password', 'r_records_class',
161 'r_filter', 'r_res_prefix', 'o_prefix', 'rname_sizes', 'plot',
162 'verbose');
163  
164 CLIPSeqTools::CompareApp->initialize_command_class(
165 'CLIPSeqTools::CompareApp::libraries_overlap_stats',
166 %options
167 )->run();
168  
169 CLIPSeqTools::CompareApp->initialize_command_class(
170 'CLIPSeqTools::CompareApp::libraries_relative_read_density',
171 %options
172 )->run();
173  
174 CLIPSeqTools::CompareApp->initialize_command_class(
175 'CLIPSeqTools::CompareApp::compare_counts',
176 table => [
177 $self->res_prefix.'counts.transcript.tab',
178 $self->r_res_prefix.'counts.transcript.tab'],
179 key_col => ['transcript_id'],
180 val_col => 'transcript_exonic_count_per_nt',
181 o_prefix => $self->o_prefix.'transcript.',
182 t_name => ['primary_lib', 'reference_lib'],
183 plot => $self->plot,
184 verbose => $self->verbose,
185 )->run();
186  
187 CLIPSeqTools::CompareApp->initialize_command_class(
188 'CLIPSeqTools::CompareApp::compare_counts',
189 table => [
190 $self->res_prefix.'counts.gene.tab',
191 $self->r_res_prefix.'counts.gene.tab'],
192 key_col => ['gene_name', 'gene_location'],
193 val_col => 'gene_exonic_count_per_nt',
194 o_prefix => $self->o_prefix.'gene.',
195 t_name => ['primary_lib', 'reference_lib'],
196 plot => $self->plot,
197 verbose => $self->verbose,
198 )->run();
199  
200 CLIPSeqTools::CompareApp->initialize_command_class(
201 'CLIPSeqTools::CompareApp::compare_counts',
202 table => [
203 $self->res_prefix.'counts.exon.tab',
204 $self->r_res_prefix.'counts.exon.tab'],
205 key_col => ['transcript_id', 'exon_location'],
206 val_col => 'exon_count_per_nt',
207 o_prefix => $self->o_prefix.'exon.',
208 t_name => ['primary_lib', 'reference_lib'],
209 plot => $self->plot,
210 verbose => $self->verbose,
211 )->run();
212  
213 CLIPSeqTools::CompareApp->initialize_command_class(
214 'CLIPSeqTools::CompareApp::compare_counts',
215 table => [
216 $self->res_prefix.'counts.intron.tab',
217 $self->r_res_prefix.'counts.intron.tab'],
218 key_col => ['transcript_id', 'intron_location'],
219 val_col => 'intron_count_per_nt',
220 o_prefix => $self->o_prefix.'intron.',
221 t_name => ['primary_lib', 'reference_lib'],
222 plot => $self->plot,
223 verbose => $self->verbose,
224 )->run();
225 }
226  
227 1;