blib/lib/Bio/Tradis/CommandLine/PlotCombine.pm untested

filter: Statementstmt 0.0% 0 / 34 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 2 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 53 CC 4 SCAR 17.0
CC
4
Cov
0%
BUILD
12.0
run
6.0
usage_text
2.0
CRAP 5.5
1 package Bio::Tradis::CommandLine::PlotCombine;
2 $Bio::Tradis::CommandLine::PlotCombine::VERSION = '1.4.1';
3 # ABSTRACT: Combine multiple plotfiles and generate updated statistics for the combined files
4  
5  
6 use Moose;
7 use Getopt::Long qw(GetOptionsFromArray);
8 use Cwd 'abs_path';
9 use Bio::Tradis::CombinePlots;
10  
11 has 'args' => ( is => 'ro', isa => 'ArrayRef', required => 1 );
12 has 'script_name' => ( is => 'ro', isa => 'Str', required => 1 );
13 has 'plotfile' => ( is => 'rw', isa => 'Str', required => 0 );
14 has 'output_dir' => ( is => 'rw', isa => 'Str', default => 'combined' );
15 has 'help' => ( is => 'rw', isa => 'Bool', required => 0 );
16  
17 sub BUILD {
18 my ($self) = @_;
19  
20 my ( $plotfile, $output_dir, $help );
21  
22 GetOptionsFromArray(
23 $self->args,
24 'p|plotfile=s' => \$plotfile,
25 'o|output_dir' => \$output_dir,
26 'h|help' => \$help
27 );
28  
29 $self->plotfile( abs_path($plotfile) ) if ( defined($plotfile) );
30 $self->help($help) if ( defined($help) );
31  
32 # print usage text if required parameters are not present
33 ($plotfile) or die $self->usage_text;
34 }
35  
36 sub run {
37 my ($self) = @_;
38  
39 $self->usage_text if ( defined( $self->help ) );
40  
41 Bio::Tradis::CombinePlots->new(
42 plotfile => $self->plotfile,
43 combined_dir => $self->output_dir,
44 )->combine;
45 }
46  
47 sub usage_text {
48 print <<USAGE;
49 Combine multiple plotfiles and generate updated statistics for the combined
50 files. Takes a tab-delimited file with an ID as the first column followed by
51 a list of plotfiles to combine per row. The ID will be used to name the new
52 plotfile and as an identifier in the stats file, so ensure these are unique.
53  
54 For example, an input file named plots_to_combine.txt:
55  
56 tradis1 plot1.1.gz plot1.2.gz plot1.3.gz
57 tradis2 plot2.1.gz plot2.2.gz
58 tradis3 plot3.1.gz plot3.2.gz plot3.3.gz plot3.4.gz
59  
60 will produce
61 1. a directory named combined with 3 files - tradis1.insertion_site_plot.gz,
62 tradis2.insertion_site_plot.gz, tradis3.insertion_site_plot.gz
63 2. a stats file named plots_to_combine.stats
64  
65 Usage: combine_tradis_plots -p plots.txt
66  
67 Options:
68 -p|plotfile : file with plots to be combined
69 -o|output_dir : name of directory for output (default: combined)
70  
71 USAGE
72 exit;
73 }
74  
75 __PACKAGE__->meta->make_immutable;
76 no Moose;
77 1;
78  
79 __END__
80  
81 =pod
82  
83 =encoding UTF-8
84  
85 =head1 NAME
86  
87 Bio::Tradis::CommandLine::PlotCombine - Combine multiple plotfiles and generate updated statistics for the combined files
88  
89 =head1 VERSION
90  
91 version 1.4.1
92  
93 =head1 SYNOPSIS
94  
95 Takes a tab-delimited file with an ID as the first column followed by
96 a list of plotfiles to combine per row. The ID will be used to name the new
97 plotfile and as an identifier in the stats file, so ensure these are unique.
98  
99 For example, an input file named plots_to_combine.txt:
100  
101 tradis1 plot1.1.gz plot1.2.gz plot1.3.gz
102 tradis2 plot2.1.gz plot2.2.gz
103 tradis3 plot3.1.gz plot3.2.gz plot3.3.gz plot3.4.gz
104  
105 will produce:
106  
107 =over
108  
109 =item 1. a directory named combined with 3 files - tradis1.insertion_site_plot.gz,
110 tradis2.insertion_site_plot.gz, tradis3.insertion_site_plot.gz
111  
112 =item 2. a stats file named plots_to_combine.stats
113  
114 =back
115  
116 =head1 AUTHOR
117  
118 Carla Cummins <path-help@sanger.ac.uk>
119  
120 =head1 COPYRIGHT AND LICENSE
121  
122 This software is Copyright (c) 2013 by Wellcome Trust Sanger Institute.
123  
124 This is free software, licensed under:
125  
126 The GNU General Public License, Version 3, June 2007
127  
128 =cut