| 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
Condition50%3/6
defined $seq and defined $qual and length $seq != length $qual
defined $seq and defined $qual
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
| |||||||||||||||||||||||||||||||||||||||||||
| 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 // ""
MC/DC0%0/1
$seq // ""
$seq
Truth table50%1/2
A
A= $seq
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | 2 | ▶ | $self->{name} = $name // undef; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$name // undef
MC/DC0%0/1
$name // undef
$name
Truth table50%1/2
A
A= $name
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | 2 | ▶ | $self->{comment} = $comment // undef; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$comment // undef
MC/DC0%0/1
$comment // undef
$comment
Truth table50%1/2
A
A= $comment
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | 2 | ▶ | $self->{qual} = $qual // undef; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$qual // undef
MC/DC0%0/1
$qual // undef
$qual
Truth table50%1/2
A
A= $qual
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | my $name = $self->{name} // "sequence"; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"name"} // "sequence"
MC/DC0%0/1
$self->{"name"} // "sequence"
$self->{"name"}
Truth table0%0/2
A
A= $self->{"name"}
| |||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | my $comment = length($self->{comment}) > 0 ? " " . $self->{comment} : ""; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 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"
MC/DC0%0/1
$self->{"name"} // "sequence"
$self->{"name"}
Truth table0%0/2
A
A= $self->{"name"}
| |||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | my $comment = length($self->{comment}) > 0 ? " " . $self->{comment} : ""; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | ▶ | my $quality = defined $self->{qual} ? " " . $self->{qual} : "I" x length($self->{seq}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | return "@" . $name . $comment . "\n" . $self->{seq} . "\n+\n" . $quality; | |||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||
| 127 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||
| 129 | __END__ | ||||||||||||||||||||||||||||||||||||||||||