File Coverage

lib/App/Sandy/Command/Quality/Add.pm
Criterion Covered Total %
statement 6 31 19.3
branch 0 12 0.0
condition 0 3 0.0
subroutine 2 6 33.3
pod 3 3 100.0
total 11 55 20.0


line stmt bran cond sub pod time code
1             package App::Sandy::Command::Quality::Add;
2             # ABSTRACT: quality subcommand class. Add a quality profile to the database.
3              
4 1     1   3908 use App::Sandy::Base 'class';
  1         2  
  1         8  
5              
6             extends 'App::Sandy::Command::Quality';
7              
8             our $VERSION = '0.22'; # VERSION
9              
10             use constant {
11 1         716 TYPE_OPT => ['raw', 'fastq']
12 1     1   9 };
  1         2  
13              
14             override 'opt_spec' => sub {
15             super,
16             'verbose|v',
17             'quality-profile|q=s',
18             'source|s=s',
19             'sequencing-error|e=f',
20             'single-molecule|1'
21             };
22              
23             sub _default_opt {
24 0     0     'verbose' => 0,
25             'type' => 'fastq',
26             'source' => 'not defined',
27             'sequencing-error' => 0.001,
28             'single-molecule' => 0
29             }
30              
31             sub validate_args {
32 0     0 1   my ($self, $args) = @_;
33 0           my $file = shift @$args;
34              
35             # Mandatory file
36 0 0         if (not defined $file) {
37 0           die "Missing file (a quality file or fastq file)\n";
38             }
39              
40             # Is it really a file?
41 0 0         if (not -f $file) {
42 0           die "<$file> is not a file. Please, give me a valid quality or fastq file\n";
43             }
44              
45 0 0         die "Too many arguments: '@$args'\n" if @$args;
46             }
47              
48             sub validate_opts {
49 0     0 1   my ($self, $opts) = @_;
50 0           my %default_opt = $self->_default_opt;
51 0           $self->fill_opts($opts, \%default_opt);
52              
53 0 0         if (not exists $opts->{'quality-profile'}) {
54 0           die "Option 'quality-profile' not defined\n";
55             }
56              
57 0 0 0       if (0 > $opts->{'sequencing-error'} || $opts->{'sequencing-error'} > 1) {
58 0           die "Option 'sequencing-error' requires a value between zero and one, not $opts->{'sequencing-error'}\n";
59             }
60             }
61              
62             sub execute {
63 0     0 1   my ($self, $opts, $args) = @_;
64 0           my $file = shift @$args;
65              
66 0           my %default_opt = $self->_default_opt;
67 0           $self->fill_opts($opts, \%default_opt);
68              
69             # Set if user wants a verbose log
70 0           $LOG_VERBOSE = $opts->{verbose};
71              
72             # Set the type of file
73 0 0         if ($file !~ /.+\.(fastq)(\.gz)?$/) {
74 0           $opts->{type} = 'raw';
75             }
76              
77             # Go go go
78 0           log_msg ":: Inserting $opts->{'quality-profile'} from $file ...";
79             $self->insertdb(
80             $file,
81             $opts->{'quality-profile'},
82             $opts->{'source'},
83             1,
84             $opts->{'sequencing-error'},
85             $opts->{'single-molecule'},
86 0           $opts->{'type'}
87             );
88              
89 0           log_msg ":: Done!";
90             }
91              
92             __END__
93              
94             =pod
95              
96             =encoding UTF-8
97              
98             =head1 NAME
99              
100             App::Sandy::Command::Quality::Add - quality subcommand class. Add a quality profile to the database.
101              
102             =head1 VERSION
103              
104             version 0.22
105              
106             =head1 SYNOPSIS
107              
108             sandy quality add -q <entry name> [-s <source>] [-e <error>] [-1] FILE
109              
110             Arguments:
111             a file (fastq or a matrix with quality entries only)
112              
113             Mandatory options:
114             -q, --quality-profile a quality-profile name
115              
116             Options:
117             -h, --help brief help message
118             -u, --man full documentation
119             -v, --verbose print log messages
120             -s, --source quality-profile source detail for database
121             -1, --single-molecule constraint to single-molecule sequencing
122             (as Pacbio and Nanopore)
123             -e, --sequencing-error sequencing error rate
124             [default:"0.001"; Number]
125              
126             =head1 DESCRIPTION
127              
128             Add a quality profile to the database.
129              
130             =head1 AUTHORS
131              
132             =over 4
133              
134             =item *
135              
136             Thiago L. A. Miller <tmiller@mochsl.org.br>
137              
138             =item *
139              
140             J. Leonel Buzzo <lbuzzo@mochsl.org.br>
141              
142             =item *
143              
144             Felipe R. C. dos Santos <fsantos@mochsl.org.br>
145              
146             =item *
147              
148             Helena B. Conceição <hconceicao@mochsl.org.br>
149              
150             =item *
151              
152             Gabriela Guardia <gguardia@mochsl.org.br>
153              
154             =item *
155              
156             Fernanda Orpinelli <forpinelli@mochsl.org.br>
157              
158             =item *
159              
160             Pedro A. F. Galante <pgalante@mochsl.org.br>
161              
162             =back
163              
164             =head1 COPYRIGHT AND LICENSE
165              
166             This software is Copyright (c) 2018 by Teaching and Research Institute from Sírio-Libanês Hospital.
167              
168             This is free software, licensed under:
169              
170             The GNU General Public License, Version 3, June 2007
171              
172             =cut