lib/App/Sandy/Command/Expression/Add.pm

filter: Statementstmt 100% 3 / 3 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 1 / 1 Podpod n/a totaltotal 100% 4 / 4 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
CRAP 1.0
« lib/App/Sandy/Command/Expression.pm ↑ Summary lib/App/Sandy/Command/Expression/Dump.pm »
1 package App::Sandy::Command::Expression::Add;
2 # ABSTRACT: expression subcommand class. Add an expression-matrix to the database.
3  
4 1 ▶use App::Sandy::Base 'class';
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 extends 'App::Sandy::Command::Expression';
7  
8 our $VERSION = '0.25'; # VERSION
9  
10 override 'opt_spec' => sub {
11 super,
12 'verbose|v',
13 'expression-matrix|f=s',
14 'source|s=s'
15 };
16  
17 sub _default_opt {
18 'verbose' => 0,
19 'source' => 'not defined'
20 }
21  
22 sub validate_args {
23 my ($self, $args) = @_;
24 my $file = shift @$args;
25  
26 # Mandatory file
27 if (not defined $file) {
28 die "Missing an expression-matrix file\n";
29 }
30  
31 # Is it really a file?
32 if (not -f $file) {
33 die "'$file' is not a file. Please, give me a valid expression-matrix file\n";
34 }
35  
36 die "Too many arguments: '@$args'\n" if @$args;
37 }
38  
39 sub validate_opts {
40 my ($self, $opts) = @_;
41 my %default_opt = $self->_default_opt;
42 $self->fill_opts($opts, \%default_opt);
43  
44 if (not exists $opts->{'expression-matrix'}) {
45 die "Mandatory option 'expression-matrix' not defined\n";
46 }
47 }
48  
49 sub execute {
50 my ($self, $opts, $args) = @_;
51 my $file = shift @$args;
52  
53 my %default_opt = $self->_default_opt;
54 $self->fill_opts($opts, \%default_opt);
55  
56 # Set if user wants a verbose log
57 $LOG_VERBOSE = $opts->{verbose};
58  
59 # Go go go
60 log_msg ":: Inserting $opts->{'expression-matrix'} from $file ...";
61 $self->insertdb(
62 $file,
63 $opts->{'expression-matrix'},
64 $opts->{'source'},
65 1
66 );
67  
68 log_msg ":: Done!";
69 }
70  
71 __END__
« lib/App/Sandy/Command/Expression.pm ↑ Summary lib/App/Sandy/Command/Expression/Dump.pm »