| 1 | package App::Sandy::Command::Variation; | ||
| 2 | # ABSTRACT: variation command class. Manage structural variation database. | ||
| 3 | |||
| 4 | 1 | ▶ | use App::Sandy::Base 'class'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | use App::Sandy::DB::Handle::Variation; | ||
| 6 | use Text::ASCIITable; | ||
| 7 | |||
| 8 | extends 'App::Sandy::CLI::Command'; | ||
| 9 | |||
| 10 | our $VERSION = '0.25'; # VERSION | ||
| 11 | |||
| 12 | has 'db' => ( | ||
| 13 | is => 'ro', | ||
| 14 | isa => 'App::Sandy::DB::Handle::Variation', | ||
| 15 | builder => '_build_db', | ||
| 16 | lazy_build => 1, | ||
| 17 | handles => [qw/insertdb restoredb deletedb make_report retrievedb/] | ||
| 18 | ); | ||
| 19 | |||
| 20 | sub _build_db { | ||
| 21 | return App::Sandy::DB::Handle::Variation->new; | ||
| 22 | } | ||
| 23 | |||
| 24 | override 'opt_spec' => sub { | ||
| 25 | super | ||
| 26 | }; | ||
| 27 | |||
| 28 | sub subcommand_map { | ||
| 29 | add => 'App::Sandy::Command::Variation::Add', | ||
| 30 | remove => 'App::Sandy::Command::Variation::Remove', | ||
| 31 | restore => 'App::Sandy::Command::Variation::Restore', | ||
| 32 | dump => 'App::Sandy::Command::Variation::Dump' | ||
| 33 | } | ||
| 34 | |||
| 35 | sub validate_args { | ||
| 36 | my ($self, $args) = @_; | ||
| 37 | die "Too many arguments: '@$args'\n" if @$args; | ||
| 38 | } | ||
| 39 | |||
| 40 | sub execute { | ||
| 41 | my ($self, $opts, $args) = @_; | ||
| 42 | |||
| 43 | my $report_ref = $self->make_report; | ||
| 44 | |||
| 45 | if (%$report_ref) { | ||
| 46 | my $t1 = Text::ASCIITable->new; | ||
| 47 | $t1->setCols('structural variation', 'source', 'provider', 'date'); | ||
| 48 | |||
| 49 | for my $structural_variation (sort keys %$report_ref) { | ||
| 50 | my $attr = $report_ref->{$structural_variation}; | ||
| 51 | $t1->addRow($structural_variation, $attr->{source}, $attr->{provider}, $attr->{date}); | ||
| 52 | } | ||
| 53 | |||
| 54 | print $t1; | ||
| 55 | } | ||
| 56 | } | ||
| 57 | |||
| 58 | __END__ | ||