File Coverage

lib/App/SimulateReads/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::SimulateReads::Types;
2             # ABSTRACT: Moose type constraints for App::SimulateReads project
3            
4 6     6   42 use Moose::Util::TypeConstraints;
  6         7  
  6         53  
5              
6             our $VERSION = '0.05'; # 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} && exists $_->{feature} }
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} }
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 'file' }
81             => message { "'$_' is not a valid seqid-weight: 'length', 'same' or 'file'" };
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             1; ## --- end class App::SimulateReads::Types
94              
95             __END__
96              
97             =pod
98              
99             =encoding UTF-8
100              
101             =head1 NAME
102              
103             App::SimulateReads::Types - Moose type constraints for App::SimulateReads project
104              
105             =head1 VERSION
106              
107             version 0.05
108              
109             =head1 AUTHOR
110              
111             Thiago L. A. Miller <tmiller@mochsl.org.br>
112              
113             =head1 COPYRIGHT AND LICENSE
114              
115             This software is Copyright (c) 2017 by Teaching and Research Institute from Sírio-Libanês Hospital.
116              
117             This is free software, licensed under:
118              
119             The GNU General Public License, Version 3, June 2007
120              
121             =cut