lib/BoutrosLab/TSVStream/Format/AnnovarInput/Types.pm

filter: Statementstmt 86.6% 39 / 45 Branchbran 75.0% 6 / 8 Conditioncond 53.3% 8 / 15 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 76.4% 13 / 17 Podpod n/a totaltotal 71.7% 66 / 92 CC 10 SCAR 17.0
CC
10
Cov
78%
_human_chr
13.6
__ANON__
2.0
__ANON__
1.3
CRAP 5.5
« lib/BoutrosLab/TSVStream/IO/Role/Dyn.pm ↑ Summary lib/BoutrosLab/TSVStream/IO/Role/Base/Fixed.pm »
1 # safe Perl
2 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 6 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 =head1 NAME
7  
8 BoutrosLab::TSVStream::Format::AnnovarInput::Types
9  
10 =head1 SYNOPSIS
11  
12 Collection of types used in AnnovarInput format fields. Used internally in
13 BoutrosLab::TSVStream::Format::AnnovarInput::Role.
14  
15 =cut
16  
17 package BoutrosLab::TSVStream::Format::AnnovarInput::Types;
18  
19 6 ▶use MooseX::Types -declare => [
Subroutine BEGIN: called CC=1 SCAR=0.0
20 qw(
21 AI_Ref
22 AI_ChrHuman
23 AI_ChrHumanNoChr
24 AI_ChrHumanWithChr
25 AI_ChrHumanTag
26 AI_ChrHumanTagNoChr
27 AI_ChrHumanTagWithChr
28 )
29 6 ];
30  
31 6 ▶use MooseX::Types::Moose qw( Int Str ArrayRef );
Subroutine BEGIN: called CC=1 SCAR=0.0
32 # use Type::Utils -all;
33  
34 subtype AI_Ref,
35 as Str,
36 13 ▶ where { /^-$/ || /^[CGAT]+(?:,[CGAT]+)*$/i },
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
/^-$/ or /^[CGAT]+(?:,[CGAT]+)*$/i 6 7 13
37 0 ▶ message {"AI_Ref must be '-' (dash), or one or more series of 'CGAT' characters separated by ','"};
Subroutine __ANON__: not called CC=1 SCAR=1.2
38  
39 48 ▶sub _human_chr {
Subroutine _human_chr: called CC=9 SCAR=26.1
40 48 my ($val, $allow_tag) = @_;
41 48 ▶ return 1 if $allow_tag && $val =~ /^(?:chr)?Un_\S+$/;
Branch: 1 branch
BranchTrueFalseTotal
if $allow_tag and $val =~ /^(?:chr)?Un_\S+$/ 0 48 48
Condition66%2/3
$allow_tag and $val =~ /^(?:chr)?Un_\S+$/
!ll&&!rl&&r
27210
MC/DC0%0/2
$allow_tag and $val =~ /^(?:chr)?Un_\S+$/
$allow_tag $val =~ /^(?:chr)?Un_\S+$/
Truth table66%2/3
A and B
A= $allow_tagB= $val =~ /^(?:chr)?Un_\S+$/
ABresult
0X0
100
111
42 48 ▶ return 0 unless my ( $l, $v, $tag ) = $val =~ /^(?:chr)?(?:([XYM])|(\d+))(_\S+)?$/;
Branch: 1 branch
BranchTrueFalseTotal
unless () = $val =~ /^(?:chr)?(?:([XYM])|(\d+))(_\S+)?$/ 4 44 48
43 44 ▶ return 1 if ($l || ( 1 <= $v && $v <= 22 )) && ($allow_tag || !$tag);
Branch: 1 branch
BranchTrueFalseTotal
if $l || 1 <= $v && $v <= 22 and $allow_tag || !$tag 44 0 44
Condition50%6/12
$l || 1 <= $v && $v <= 22 and $allow_tag || !$tag
!ll&&!rl&&r
0044
$l or 1 <= $v and $v <= 22
l!l&&r!l&&!r
6380
1 <= $v and $v <= 22
!ll&&!rl&&r
0038
$allow_tag or not $tag
l!l&&r!l&&!r
17270
MC/DC0%0/5
$l || 1 <= $v && $v <= 22 and $allow_tag || !$tag
$l 1 <= $v $v <= 22 $allow_tag not $tag
Truth table50%4/8
A or B and C and D or not(E)
A= $lB= 1 <= $vC= $v <= 22D= $allow_tagE= not $tag
ABCDEresult
00XXX0
010XX0
1XX000
011000
1XX1X1
1XX011
0111X1
011011
44 0 return 0;
45 }
46  
47 12 ▶sub _apply_chr_subtypes {
Subroutine _apply_chr_subtypes: called CC=1 SCAR=0.1
48 12 my ($type, $wc, $nc) = @_;
49  
50 subtype $wc,
51 as $type,
52 12 ▶ where { /^chr/ };
Subroutine __ANON__: called CC=1 SCAR=0.0
53 subtype $nc,
54 as $type,
55 12 ▶ where { /^(?!chr)/ };
Subroutine __ANON__: called CC=1 SCAR=0.0
56 0 ▶ coerce $nc, from $wc, via { s/^chr//; $_ };
Subroutine __ANON__: not called CC=1 SCAR=2.6
57 12 ▶ coerce $wc, from $nc, via { s/^/chr/; $_ };
Subroutine __ANON__: called CC=1 SCAR=0.0
58 }
59  
60 6 my $notagmessage = " - must be '1'..'22', 'X', 'Y', or 'M'. (A leading 'chr' string is optional.)";
61  
62 subtype AI_ChrHuman,
63 as Str,
64 27 ▶ where { _human_chr($_) },
Subroutine __ANON__: called CC=1 SCAR=0.0
65 0 ▶ message { "$notagmessage Found: $_" };
Subroutine __ANON__: not called CC=1 SCAR=1.2
66  
67 6 _apply_chr_subtypes( AI_ChrHuman, AI_ChrHumanWithChr, AI_ChrHumanNoChr );
68  
69 6 my $tagmessage = " - must be '1'..'22', 'X', 'Y', or 'M'; optionally followed a tag; or 'Un' followed by a (required) tag. A tag must start with an underscore. (A leading 'chr' string is optional.)";
70  
71 subtype AI_ChrHumanTag,
72 as Str,
73 21 ▶ where { _human_chr($_, 1) },
Subroutine __ANON__: called CC=1 SCAR=0.0
74 0 ▶ message { "$tagmessage Found: $_" };
Subroutine __ANON__: not called CC=1 SCAR=1.2
75  
76 6 _apply_chr_subtypes( AI_ChrHumanTag, AI_ChrHumanTagWithChr, AI_ChrHumanTagNoChr );
77  
78 =head1 AUTHOR
79  
80 John Macdonald - Boutros Lab
81  
82 =head1 ACKNOWLEDGEMENTS
83  
84 Paul Boutros, Phd, PI - Boutros Lab
85  
86 The Ontario Institute for Cancer Research
87  
88 =cut
89  
90 6 1;
91  
« lib/BoutrosLab/TSVStream/IO/Role/Dyn.pm ↑ Summary lib/BoutrosLab/TSVStream/IO/Role/Base/Fixed.pm »