File Coverage

lib/App/Sandy/Types.pm
Criterion Covered Total %
statement 3 3 100.0
branch n/a
condition n/a
subroutine 1 1 100.0
pod n/a
total 4 4 100.0


line stmt bran cond sub pod time code
1             package App::Sandy::Types;
2             # ABSTRACT: Moose type constraints for App::Sandy project
3              
4 6     6   41 use Moose::Util::TypeConstraints;
  6         13  
  6         48  
5              
6             our $VERSION = '0.22'; # VERSION
7              
8             subtype 'My:IntGt0'
9             => as 'Int'
10             => where { $_ > 0 }
11             => message { "Value must be an integer greater than zero, not '$_'" };
12              
13             subtype 'My:IntGe0'
14             => as 'Int'
15             => where { $_ >= 0 }
16             => message { "Value must be an integer greater or equal to zero, not '$_'" };
17              
18             subtype 'My:NumGt0'
19             => as 'Num'
20             => where { $_ > 0 }
21             => message { "Value must be a number greater than zero, not '$_'" };
22              
23             subtype 'My:NumGe0'
24             => as 'Num'
25             => where { $_ >= 0 }
26             => message { "Value must be a number greater or equal to zero, not '$_'" };
27              
28             subtype 'My:NumHS'
29             => as 'Num'
30             => where { $_ >= 0 && $_ <= 1 }
31             => message { "Value must be a number between zero and one, not '$_'" };
32              
33             subtype 'My:File'
34             => as 'Str'
35             => where { -f $_ }
36             => message { "'$_' must be a file" };
37              
38             subtype 'My:Fasta'
39             => as 'My:File'
40             => where { $_ =~ /.+\.(fasta|fa|fna|ffn)(\.gz)*$/ }
41             => message { "'$_' must be a fasta file: Check the extension (.fasta, .fa, .fna, .ffn - compressed, or not, by gzip, as in .fasta.gz etc)" };
42              
43             subtype 'My:Weight'
44             => as 'HashRef'
45             => where { exists $_->{down} && exists $_->{up} }
46             => message { "'$_' is not a Weight object" };
47              
48             subtype 'My:Weights'
49             => as 'ArrayRef[My:Weight]'
50             => message { "'$_' is not a Weight object array" };
51              
52             subtype 'My:QualityP'
53             => as 'Str';
54              
55             coerce 'My:QualityP'
56             => from 'Str'
57             => via { lc $_ };
58              
59             subtype 'My:QualityH'
60             => as 'HashRef'
61             => where { exists $_->{matrix} && exists $_->{deepth} && exists $_->{partil} }
62             => message { "'$_' is not a valid quality hash" };
63              
64             subtype 'My:IdFa'
65             => as 'HashRef'
66             => where { exists $_->{seq} && exists $_->{size} }
67             => message { "'$_' is not a valid fasta id" };
68              
69             subtype 'My:IdxFasta'
70             => as 'HashRef[My:IdFa]'
71             => message { "'$_' is not a valid indexed fasta" };
72              
73             subtype 'My:StrandBias'
74             => as 'Str'
75             => where { $_ eq 'plus' || $_ eq 'minus' || $_ eq 'random' }
76             => message { "'$_' is not a valid strand-bias: 'plus', 'minus' or 'random'" };
77              
78             subtype 'My:SeqIdWeight'
79             => as 'Str'
80             => where { $_ eq 'length' || $_ eq 'same' || $_ eq 'count' }
81             => message { "'$_' is not a valid seqid-weight: 'length', 'same' or 'count'" };
82              
83             subtype 'My:SeqType'
84             => as 'Str'
85             => where { $_ eq 'single-end' || $_ eq 'paired-end' }
86             => message { "'$_' is not a valid sequencing-type: 'single-end' or 'paired-end'" };
87              
88             subtype 'My:CountLoopBy'
89             => as 'Str'
90             => where { $_ eq 'coverage' || $_ eq 'number-of-reads' }
91             => message { "'$_' is not a valid count_loops_by: 'coverage' or 'number-of-reads'" };
92              
93             subtype 'My:Piece'
94             => as 'HashRef'
95             => where { exists $_->{ref} && exists $_->{start} && exists $_->{len} && exists $_->{pos} && exists $_->{offset} }
96             => message { "Invalid piece inserted to piece_table" };
97              
98             subtype 'My:PieceTable'
99             => as 'HashRef'
100             => where { exists $_->{size} && exists $_->{table} && ref $_->{table} eq 'App::Sandy::PieceTable' }
101             => message { "Invalid piece table entry" };
102              
103             subtype 'My:Format'
104             => as 'Str'
105             => where { $_ eq 'fastq' || $_ eq 'fastq.gz' || $_ eq 'bam' || $_ eq 'sam' }
106             => message { "Invalid output format: '$_': 'fastq', 'fastq.gz', 'bam', 'sam'" };
107              
108             subtype 'My:Level'
109             => as 'Int'
110             => where { /^[1-9]$/ }
111             => message { "Invalid compression level: '$_': 1-9"};
112              
113             1; ## --- end class App::Sandy::Types
114              
115             __END__
116              
117             =pod
118              
119             =encoding UTF-8
120              
121             =head1 NAME
122              
123             App::Sandy::Types - Moose type constraints for App::Sandy project
124              
125             =head1 VERSION
126              
127             version 0.22
128              
129             =head1 AUTHORS
130              
131             =over 4
132              
133             =item *
134              
135             Thiago L. A. Miller <tmiller@mochsl.org.br>
136              
137             =item *
138              
139             J. Leonel Buzzo <lbuzzo@mochsl.org.br>
140              
141             =item *
142              
143             Felipe R. C. dos Santos <fsantos@mochsl.org.br>
144              
145             =item *
146              
147             Helena B. Conceição <hconceicao@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             Pedro A. F. Galante <pgalante@mochsl.org.br>
160              
161             =back
162              
163             =head1 COPYRIGHT AND LICENSE
164              
165             This software is Copyright (c) 2018 by Teaching and Research Institute from Sírio-Libanês Hospital.
166              
167             This is free software, licensed under:
168              
169             The GNU General Public License, Version 3, June 2007
170              
171             =cut