| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package App::RL::Command::genome; | 
| 2 | 14 |  |  | 14 |  | 8511 | use strict; | 
|  | 14 |  |  |  |  | 34 |  | 
|  | 14 |  |  |  |  | 378 |  | 
| 3 | 14 |  |  | 14 |  | 326 | use warnings; | 
|  | 14 |  |  |  |  | 39 |  | 
|  | 14 |  |  |  |  | 347 |  | 
| 4 | 14 |  |  | 14 |  | 71 | use autodie; | 
|  | 14 |  |  |  |  | 28 |  | 
|  | 14 |  |  |  |  | 67 |  | 
| 5 |  |  |  |  |  |  |  | 
| 6 | 14 |  |  | 14 |  | 68563 | use App::RL -command; | 
|  | 14 |  |  |  |  | 28 |  | 
|  | 14 |  |  |  |  | 122 |  | 
| 7 | 14 |  |  | 14 |  | 4288 | use App::RL::Common; | 
|  | 14 |  |  |  |  | 33 |  | 
|  | 14 |  |  |  |  | 355 |  | 
| 8 |  |  |  |  |  |  |  | 
| 9 | 14 |  |  | 14 |  | 67 | use constant abstract => 'convert chr.size to full genome runlists'; | 
|  | 14 |  |  |  |  | 26 |  | 
|  | 14 |  |  |  |  | 6927 |  | 
| 10 |  |  |  |  |  |  |  | 
| 11 |  |  |  |  |  |  | sub opt_spec { | 
| 12 |  |  |  |  |  |  | return ( | 
| 13 | 4 |  |  | 4 | 1 | 23 | [ "outfile|o=s", "Output filename. [stdout] for screen." ], | 
| 14 |  |  |  |  |  |  | [ "remove|r",    "Remove 'chr0' from chromosome names." ], | 
| 15 |  |  |  |  |  |  | { show_defaults => 1, } | 
| 16 |  |  |  |  |  |  | ); | 
| 17 |  |  |  |  |  |  | } | 
| 18 |  |  |  |  |  |  |  | 
| 19 |  |  |  |  |  |  | sub usage_desc { | 
| 20 | 4 |  |  | 4 | 1 | 33012 | return "runlist genome [options] "; | 
| 21 |  |  |  |  |  |  | } | 
| 22 |  |  |  |  |  |  |  | 
| 23 |  |  |  |  |  |  | sub description { | 
| 24 | 1 |  |  | 1 | 1 | 650 | my $desc; | 
| 25 | 1 |  |  |  |  | 3 | $desc .= ucfirst(abstract) . ".\n"; | 
| 26 | 1 |  |  |  |  | 2 | return $desc; | 
| 27 |  |  |  |  |  |  | } | 
| 28 |  |  |  |  |  |  |  | 
| 29 |  |  |  |  |  |  | sub validate_args { | 
| 30 | 3 |  |  | 3 | 1 | 2085 | my ( $self, $opt, $args ) = @_; | 
| 31 |  |  |  |  |  |  |  | 
| 32 | 3 | 100 |  |  |  | 4 | if ( @{$args} != 1 ) { | 
|  | 3 |  |  |  |  | 12 |  | 
| 33 | 1 |  |  |  |  | 3 | my $message = "This command need one input file.\n\tIt found"; | 
| 34 | 1 |  |  |  |  | 2 | $message .= sprintf " [%s]", $_ for @{$args}; | 
|  | 1 |  |  |  |  | 4 |  | 
| 35 | 1 |  |  |  |  | 3 | $message .= ".\n"; | 
| 36 | 1 |  |  |  |  | 13 | $self->usage_error($message); | 
| 37 |  |  |  |  |  |  | } | 
| 38 | 2 |  |  |  |  | 5 | for ( @{$args} ) { | 
|  | 2 |  |  |  |  | 5 |  | 
| 39 | 2 | 50 |  |  |  | 8 | next if lc $_ eq "stdin"; | 
| 40 | 2 | 100 |  |  |  | 9 | if ( !Path::Tiny::path($_)->is_file ) { | 
| 41 | 1 |  |  |  |  | 105 | $self->usage_error("The input file [$_] doesn't exist."); | 
| 42 |  |  |  |  |  |  | } | 
| 43 |  |  |  |  |  |  | } | 
| 44 |  |  |  |  |  |  |  | 
| 45 | 1 | 50 |  |  |  | 54 | if ( !exists $opt->{outfile} ) { | 
| 46 | 0 |  |  |  |  | 0 | $opt->{outfile} = Path::Tiny::path( $args->[0] )->absolute . ".yml"; | 
| 47 |  |  |  |  |  |  | } | 
| 48 |  |  |  |  |  |  | } | 
| 49 |  |  |  |  |  |  |  | 
| 50 |  |  |  |  |  |  | sub execute { | 
| 51 | 1 |  |  | 1 | 1 | 6 | my ( $self, $opt, $args ) = @_; | 
| 52 |  |  |  |  |  |  |  | 
| 53 |  |  |  |  |  |  | #----------------------------# | 
| 54 |  |  |  |  |  |  | # Loading | 
| 55 |  |  |  |  |  |  | #----------------------------# | 
| 56 | 1 |  |  |  |  | 9 | my $length_of = App::RL::Common::read_sizes( $args->[0], $opt->{remove} ); | 
| 57 |  |  |  |  |  |  |  | 
| 58 |  |  |  |  |  |  | #----------------------------# | 
| 59 |  |  |  |  |  |  | # Operating | 
| 60 |  |  |  |  |  |  | #----------------------------# | 
| 61 | 1 |  |  |  |  | 4 | my $r_of = {}; | 
| 62 | 1 |  |  |  |  | 3 | for my $key ( keys %{$length_of} ) { | 
|  | 1 |  |  |  |  | 5 |  | 
| 63 | 16 |  |  |  |  | 473 | my $set = App::RL::Common::new_set(); | 
| 64 | 16 |  |  |  |  | 159 | $set->add_pair( 1, $length_of->{$key} ); | 
| 65 | 16 |  |  |  |  | 877 | $r_of->{$key} = $set->runlist; | 
| 66 |  |  |  |  |  |  | } | 
| 67 |  |  |  |  |  |  |  | 
| 68 |  |  |  |  |  |  | #----------------------------# | 
| 69 |  |  |  |  |  |  | # Output | 
| 70 |  |  |  |  |  |  | #----------------------------# | 
| 71 | 1 |  |  |  |  | 32 | my $out_fh; | 
| 72 | 1 | 50 |  |  |  | 7 | if ( lc( $opt->{outfile} ) eq "stdout" ) { | 
| 73 | 1 |  |  |  |  | 3 | $out_fh = *STDOUT; | 
| 74 |  |  |  |  |  |  | } | 
| 75 |  |  |  |  |  |  | else { | 
| 76 | 0 |  |  |  |  | 0 | open $out_fh, ">", $opt->{outfile}; | 
| 77 |  |  |  |  |  |  | } | 
| 78 | 1 |  |  |  |  | 2 | print {$out_fh} YAML::Syck::Dump($r_of); | 
|  | 1 |  |  |  |  | 7 |  | 
| 79 |  |  |  |  |  |  |  | 
| 80 | 1 |  |  |  |  | 143 | close $out_fh; | 
| 81 |  |  |  |  |  |  | } | 
| 82 |  |  |  |  |  |  |  | 
| 83 |  |  |  |  |  |  | 1; |