lib/FASTX/Seq.pm

filter: Statementstmt 73.0% 46 / 63 Branchbran 33.3% 8 / 24 Conditioncond 38.8% 7 / 18 MC/DCmcdc 11.1% 1 / 9 Subroutinesub 73.3% 11 / 15 Podpod 100% 10 / 10 totaltotal 59.7% 83 / 139 CC 21 SCAR 20.8
CC
21
Cov
58%
asfasta
20.0
asfastq
20.0
new
9.4
CRAP 8.0
« lib/FASTX/ScriptHelper.pm ↑ Summary script/fqlen.pl »
1 package FASTX::Seq;
2 #ABSTRACT: A class for representing a sequence for FASTX::Reader
3  
4 2 ▶use 5.012;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Carp qw(confess);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 $Data::Dumper::Sortkeys = 1;
9 2 ▶use File::Basename;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 $FASTX::Seq::VERSION = $FASTX::Reader::VERSION;
11  
12 2 require Exporter;
13 2 our @ISA = qw(Exporter);
14  
15  
16  
17 sub new {
18
19 3 ▶ my ($class, $seq, $name, $comment, $qual) = @_;
Subroutine new: called CC=8 SCAR=22.4
Pod documented
20
21 3 ▶ if ( defined $seq && defined $qual
Branch: 1 branch
BranchTrueFalseTotal
if (defined $seq and defined $qual and length $seq != length $qual) 1 2 3
Condition50%3/6
defined $seq and defined $qual and length $seq != length $qual
!ll&&!rl&&r
021
defined $seq and defined $qual
!ll&&!rl&&r
003
MC/DC33%1/3
defined $seq and defined $qual and length $seq != length $qual
defined $seq defined $qual length $seq != length $qual
Truth table50%2/4
A and B and C
A= defined $seqB= defined $qualC= length $seq != length $qual
ABCresult
0XX0
10X0
1100
1111
22 && (length($seq) != length($qual))) {
23 1 confess "Sequence/quality length mismatch";
24 }
25
26 2 my $self = bless {}, $class;
27 # Required
28 2 ▶ $self->{seq} = $seq // '';
Condition50%1/2
$seq // ""
l!l
20
MC/DC0%0/1
$seq // ""
$seq
Truth table50%1/2
A
A= $seq
Aresult
11
00
29  
30 2 ▶ $self->{name} = $name // undef;
Condition50%1/2
$name // undef
l!l
20
MC/DC0%0/1
$name // undef
$name
Truth table50%1/2
A
A= $name
Aresult
11
00
31 2 ▶ $self->{comment} = $comment // undef;
Condition50%1/2
$comment // undef
l!l
02
MC/DC0%0/1
$comment // undef
$comment
Truth table50%1/2
A
A= $comment
Aresult
11
00
32 2 ▶ $self->{qual} = $qual // undef;
Condition50%1/2
$qual // undef
l!l
20
MC/DC0%0/1
$qual // undef
$qual
Truth table50%1/2
A
A= $qual
Aresult
11
00
33
34 2 return $self;
35
36 }
37  
38  
39  
40  
41 sub seq : lvalue {
42 # Update sequence
43 4 ▶ my ($self, $new_val) = @_;
Subroutine seq: called CC=2 SCAR=7.1
Pod documented
44 4 ▶ $self->{seq} = $new_val if (defined $new_val);
Branch: 1 branch
BranchTrueFalseTotal
if defined $new_val 0 4 4
45 4 return $self->{seq};
46 }
47  
48  
49  
50 sub name : lvalue {
51 # Update name
52 2 ▶ my ($self, $new_val) = @_;
Subroutine name: called CC=2 SCAR=7.1
Pod documented
53 2 ▶ $self->{seq} = $new_val if (defined $new_val);
Branch: 1 branch
BranchTrueFalseTotal
if defined $new_val 0 2 2
54 2 return $self->{name};
55 }
56  
57  
58  
59 sub qual : lvalue {
60 # Update quality
61 2 ▶ my ($self, $new_val) = @_;
Subroutine qual: called CC=2 SCAR=7.1
Pod documented
62 2 ▶ $self->{qual} = $new_val if (defined $new_val);
Branch: 1 branch
BranchTrueFalseTotal
if defined $new_val 0 2 2
63 2 return $self->{qual};
64 }
65  
66  
67 sub comment : lvalue {
68 # Update comment
69 1 ▶ my ($self, $new_val) = @_;
Subroutine comment: called CC=2 SCAR=7.1
Pod documented
70 1 ▶ $self->{comment} = $new_val if (defined $new_val);
Branch: 1 branch
BranchTrueFalseTotal
if defined $new_val 0 1 1
71 1 return $self->{comment};
72 }
73  
74  
75  
76 sub rev {
77 # Update comment
78 0 ▶ my ($self) = @_;
Subroutine rev: not called CC=2 SCAR=17.9
Pod documented
79 0 $self->{seq} = reverse($self->{seq});
80 0 ▶ $self->{qual} = reverse($self->{qual}) if (defined reverse($self->{qual}));
Branch: 1 branch
BranchTrueFalseTotal
if defined reverse($self->{"qual"}) 0 0 0
81 0 return $self;
82 }
83  
84  
85  
86 sub len {
87 # Update comment
88 0 ▶ my ($self) = @_;
Subroutine len: not called CC=1 SCAR=6.9
Pod documented
89 0 return length($self->{seq});
90 }
91  
92  
93 sub rc {
94 # Update comment
95 2 ▶ my ($self) = @_;
Subroutine rc: called CC=3 SCAR=11.6
Pod documented
96 2 $self->{seq} = reverse($self->{seq});
97 2 ▶ if ($self->{seq} =~ /U/i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'seq'} =~ /U/iu) { } 0 2 2
98 0 $self->{seq} =~ tr/ACGURYSWKMBDHVacguryswkmbdhv/UGCAYRSWMKVHDBugcayrswmkvhdb/;
99 } else {
100 2 $self->{seq} =~ tr/ACGTRYSWKMBDHVacgtryswkmbdhv/TGCAYRSWMKVHDBtgcayrswmkvhdb/;
101 }
102 2 ▶ $self->{qual} = reverse($self->{qual}) if (defined reverse($self->{qual}));
Branch: 1 branch
BranchTrueFalseTotal
if defined reverse($self->{"qual"}) 2 0 2
103 2 return $self;
104 }
105  
106  
107  
108 sub asfasta {
109 # Update comment
110 0 ▶ my ($self) = @_;
Subroutine asfasta: not called CC=4 SCAR=30.0
Pod documented
111 0 ▶ my $space = length($self->{comment}) > 0 ? " " : "";
Branch: 1 branch
BranchTrueFalseTotal
length $self->{'comment'} > 0 ? : 0 0 0
112 0 ▶ my $name = $self->{name} // "sequence";
Condition0%0/2
$self->{"name"} // "sequence"
l!l
00
MC/DC0%0/1
$self->{"name"} // "sequence"
$self->{"name"}
Truth table0%0/2
A
A= $self->{"name"}
Aresult
11
00
113 0 ▶ my $comment = length($self->{comment}) > 0 ? " " . $self->{comment} : "";
Branch: 1 branch
BranchTrueFalseTotal
length $self->{'comment'} > 0 ? : 0 0 0
114 0 return ">" . $name . $comment . "\n" . $self->{seq} . "\n";
115 }
116  
117  
118 sub asfastq {
119 # Update comment
120 0 ▶ my ($self) = @_;
Subroutine asfastq: not called CC=4 SCAR=30.0
Pod documented
121 0 ▶ my $name = $self->{name} // "sequence";
Condition0%0/2
$self->{"name"} // "sequence"
l!l
00
MC/DC0%0/1
$self->{"name"} // "sequence"
$self->{"name"}
Truth table0%0/2
A
A= $self->{"name"}
Aresult
11
00
122 0 ▶ my $comment = length($self->{comment}) > 0 ? " " . $self->{comment} : "";
Branch: 1 branch
BranchTrueFalseTotal
length $self->{'comment'} > 0 ? : 0 0 0
123 0 ▶ my $quality = defined $self->{qual} ? " " . $self->{qual} : "I" x length($self->{seq});
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{'qual'} ? : 0 0 0
124 0 return "@" . $name . $comment . "\n" . $self->{seq} . "\n+\n" . $quality;
125 }
126  
127 2 1;
128  
129 __END__
« lib/FASTX/ScriptHelper.pm ↑ Summary script/fqlen.pl »