File Coverage

lib/App/Sandy/Command/Expression/Add.pm
Criterion Covered Total %
statement 3 24 12.5
branch 0 8 0.0
condition n/a
subroutine 1 5 20.0
pod 3 3 100.0
total 7 40 17.5


line stmt bran cond sub pod time code
1             package App::Sandy::Command::Expression::Add;
2             # ABSTRACT: expression subcommand class. Add an expression-matrix to the database.
3              
4 1     1   1699 use App::Sandy::Base 'class';
  1         2  
  1         8  
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 0     0     'verbose' => 0,
19             'source' => 'not defined'
20             }
21              
22             sub validate_args {
23 0     0 1   my ($self, $args) = @_;
24 0           my $file = shift @$args;
25              
26             # Mandatory file
27 0 0         if (not defined $file) {
28 0           die "Missing an expression-matrix file\n";
29             }
30              
31             # Is it really a file?
32 0 0         if (not -f $file) {
33 0           die "'$file' is not a file. Please, give me a valid expression-matrix file\n";
34             }
35              
36 0 0         die "Too many arguments: '@$args'\n" if @$args;
37             }
38              
39             sub validate_opts {
40 0     0 1   my ($self, $opts) = @_;
41 0           my %default_opt = $self->_default_opt;
42 0           $self->fill_opts($opts, \%default_opt);
43              
44 0 0         if (not exists $opts->{'expression-matrix'}) {
45 0           die "Mandatory option 'expression-matrix' not defined\n";
46             }
47             }
48              
49             sub execute {
50 0     0 1   my ($self, $opts, $args) = @_;
51 0           my $file = shift @$args;
52              
53 0           my %default_opt = $self->_default_opt;
54 0           $self->fill_opts($opts, \%default_opt);
55              
56             # Set if user wants a verbose log
57 0           $LOG_VERBOSE = $opts->{verbose};
58              
59             # Go go go
60 0           log_msg ":: Inserting $opts->{'expression-matrix'} from $file ...";
61             $self->insertdb(
62             $file,
63             $opts->{'expression-matrix'},
64 0           $opts->{'source'},
65             1
66             );
67              
68 0           log_msg ":: Done!";
69             }
70              
71             __END__
72              
73             =pod
74              
75             =encoding UTF-8
76              
77             =head1 NAME
78              
79             App::Sandy::Command::Expression::Add - expression subcommand class. Add an expression-matrix to the database.
80              
81             =head1 VERSION
82              
83             version 0.25
84              
85             =head1 SYNOPSIS
86              
87             sandy expression add -f <entry name> [-s <source>] FILE
88              
89             Arguments:
90             an expression-matrix file
91              
92             Mandatory options:
93             -f, --expression-matrix an expression-matrix name
94              
95             Options:
96             -h, --help brief help message
97             -H, --man full documentation
98             -v, --verbose print log messages
99             -s, --source expression-matrix source detail for database
100              
101             =head1 DESCRIPTION
102              
103             Add an expression-matrix to the database. A valid expression-matrix is a
104             file with two columns. The first column is for the seqid and the second
105             column is for the raw count. The counts will be treated as weights.
106              
107             =head2 INPUT
108              
109             A two-columns whitespace separated file, where the first column is the
110             transcript id, or the gene id, and the second column is the raw counts.
111              
112             ===> my_custom_expression_matrix.txt
113             #feature count
114             ENST00000000233.9 2463
115             ENST00000000412.7 2494
116             ENST00000000442.10 275
117             ENST00000001008.5 5112
118             ENST00000001146.6 637
119             ENST00000002125.8 660
120             ENST00000002165.10 478
121             ENST00000002501.10 57
122             ENST00000002596.5 183
123             ...
124              
125             =head1 AUTHORS
126              
127             =over 4
128              
129             =item *
130              
131             Thiago L. A. Miller <tmiller@mochsl.org.br>
132              
133             =item *
134              
135             J. Leonel Buzzo <lbuzzo@mochsl.org.br>
136              
137             =item *
138              
139             Felipe R. C. dos Santos <fsantos@mochsl.org.br>
140              
141             =item *
142              
143             Helena B. Conceição <hconceicao@mochsl.org.br>
144              
145             =item *
146              
147             Rodrigo Barreiro <rbarreiro@mochsl.org.br>
148              
149             =item *
150              
151             Gabriela Guardia <gguardia@mochsl.org.br>
152              
153             =item *
154              
155             Fernanda Orpinelli <forpinelli@mochsl.org.br>
156              
157             =item *
158              
159             Rafael Mercuri <rmercuri@mochsl.org.br>
160              
161             =item *
162              
163             Rodrigo Barreiro <rbarreiro@mochsl.org.br>
164              
165             =item *
166              
167             Pedro A. F. Galante <pgalante@mochsl.org.br>
168              
169             =back
170              
171             =head1 COPYRIGHT AND LICENSE
172              
173             This software is Copyright (c) 2023 by Teaching and Research Institute from Sírio-Libanês Hospital.
174              
175             This is free software, licensed under:
176              
177             The GNU General Public License, Version 3, June 2007
178              
179             =cut