File Coverage

blib/lib/BioX/Map/CLIS/Cmd/Compare.pm
Criterion Covered Total %
statement 24 49 48.9
branch 0 2 0.0
condition 0 9 0.0
subroutine 8 11 72.7
pod 1 1 100.0
total 33 72 45.8


line stmt bran cond sub pod time code
1             package BioX::Map::CLIS::Cmd::Compare;
2 1     1   2341 use Modern::Perl;
  1         2  
  1         6  
3 1     1   91 use IO::All;
  1         1  
  1         7  
4 1     1   46 use Carp "confess";
  1         1  
  1         29  
5 1     1   3 use Moo;
  1         1  
  1         4  
6 1     1   500 use MooX::Options prefer_commandline => 1, with_config_from_file => 1;
  1         1  
  1         5  
7 1     1   28582 use MooX::Cmd;
  1         2  
  1         5  
8 1     1   1188 use BioX::Map;
  1         1  
  1         9  
9 1     1   21 use Types::Standard qw(Int Str Bool Enum);
  1         2  
  1         6  
10              
11             our $VERSION = '0.0.10'; # VERSION:
12             # ABSTRACT: a wrapper for mapping software
13              
14              
15             around _build_config_identifier => sub { 'berry' };
16             around _build_config_prefix => sub { 'biox_map' };
17              
18              
19              
20             option indir => (
21             is => 'ro',
22             format => 's',
23             short => 'i',
24             default => '',
25             doc => "path of one fastq file",
26             );
27              
28              
29              
30             option soap_suffix => (
31             is => 'ro',
32             format => 's',
33             short => 's',
34             doc => "suffix of all samples' soap result",
35             default => 'soap',
36             );
37              
38              
39             option bwa_suffix => (
40             is => 'ro',
41             format => 's',
42             short => 'b',
43             doc => "suffix of all samples' bwa result",
44             default => 'bwa',
45             );
46              
47              
48             option outfile => (
49             is => 'ro',
50             format => 's',
51             short => 'o',
52             default => 'summary.txt',
53             doc => "file used to store summary file",
54             );
55              
56              
57             sub execute {
58 0     0 1   my ($self, $args_ref, $chain_ref) = @_;
59 0           my $pre_message = "please input parameters, genome is required, either infile or indir is required";
60 0           my ($indir, $outfile, $soap_suffix, $bwa_suffix) = ($self->indir, $self->outfile, $self->soap_suffix, $self->bwa_suffix);
61 0 0 0       $self->options_usage(1, $pre_message) unless ($outfile and $indir and $soap_suffix and $bwa_suffix);
      0        
      0        
62 0           my $bm = BioX::Map->new;
63 0           say "indir:$indir";
64 0     0     my @soap_result = io($indir)->filter( sub {$_->filename =~/\.$soap_suffix$/} )->all_files;
  0            
65 0     0     my @bwa_result = io($indir)->filter( sub {$_->filename =~/\.$bwa_suffix$/} )->all_files;
  0            
66 0           $outfile = io($outfile);
67 0           $outfile->print("samplename\tsoap0\tsoap1\tsoap2\tbwa0\tbwa1\tbwa2\n");
68 0           for my $sr (@soap_result) {
69 0           $bm->tool("soap");
70 0           my $filename = $sr->filename;
71 0           say "###########sr: $sr ######filename: $filename";
72 0           $filename =~s/\.$soap_suffix$//i;
73 0           say "soap result:$sr";
74 0           my $s_r = $bm->statis_result("$sr");
75 0           $bm->tool("bwa");
76 0           $sr =~s/$soap_suffix$/$bwa_suffix/i;
77 0           say "bwa result:$sr";
78 0           my $b_r = $bm->statis_result("$sr");
79 0           $sr =~s/\.$bwa_suffix//i;
80 0           $outfile->println(join "\t", $filename, @$s_r, @$b_r);
81             }
82             }
83              
84             1;
85              
86             __END__