| 1 | package Bio::Gonzales::Seq; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 9 | ▶ | use Mouse; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | 9 | ▶ | use overload '""' => 'all'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 9 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 9 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 9 | ▶ | use Digest::SHA1 qw/sha1_hex/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 9 | ▶ | use Digest::MD5 qw/md5_hex/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 9 | our $WIDTH = 80; | |||||||||||||||||||||||||||||||||||||||||
| 13 | 9 | our $VERSION = '0.062'; # VERSION | |||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | 9 | has id => ( is => 'rw', required => 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 16 | 9 | has desc => ( is => 'rw', default => '' ); | |||||||||||||||||||||||||||||||||||||||||
| 17 | 9 | has seq => ( is => 'rw', required => 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 18 | 9 | has delim => ( is => 'rw', default => " " ); | |||||||||||||||||||||||||||||||||||||||||
| 19 | 61 | ▶ | has info => ( is => 'rw', default => sub { {} } ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 9 | has gaps => ( is => 'rw', lazy_build => 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 21 | 9 | has length => ( is => 'rw', lazy_build => 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | sub _build_gaps { | ||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | ▶ | my $gaps = ( shift->seq() =~ tr/-.// ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_gaps: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | return $gaps; | |||||||||||||||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | 1 | ▶ | sub ungapped_seq { return shift->gapless_seq(@_); } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ungapped_seq: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | sub _build_length { | ||||||||||||||||||||||||||||||||||||||||||
| 31 | 5 | ▶ | return CORE::length( shift->seq() ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_length: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | sub BUILDARGS { | ||||||||||||||||||||||||||||||||||||||||||
| 35 | 61 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILDARGS: called CC=7 SCAR=20.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | 61 | my %a; | |||||||||||||||||||||||||||||||||||||||||
| 38 | 61 | ▶ | if ( scalar @_ == 1 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | ▶ | ( ref( $_[0] ) eq 'HASH' ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | || $class->meta->throw_error("Single parameters to new() must be a HASH ref"); | ||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | %a = %{ $_[0] }; | |||||||||||||||||||||||||||||||||||||||||
| 42 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 43 | 61 | %a = @_; | |||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | delete $a{delim} | ||||||||||||||||||||||||||||||||||||||||||
| 47 | 61 | ▶ | if ( exists( $a{delim} ) && !defined( $a{delim} ) ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
exists $a{"delim"} and not defined $a{"delim"}
MC/DC100%2/2
exists $a{"delim"} and not defined $a{"delim"}
exists $a{"delim"}
not defined $a{"delim"}
Truth table100%3/3
A and not(B)
A= exists $a{"delim"}B= not defined $a{"delim"}
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | delete $a{desc} | ||||||||||||||||||||||||||||||||||||||||||
| 49 | 61 | ▶ | if ( exists( $a{desc} ) && !defined( $a{desc} ) ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
exists $a{"desc"} and not defined $a{"desc"}
MC/DC100%2/2
exists $a{"desc"} and not defined $a{"desc"}
exists $a{"desc"}
not defined $a{"desc"}
Truth table100%3/3
A and not(B)
A= exists $a{"desc"}B= not defined $a{"desc"}
| |||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | 61 | $a{seq} = _filter_seq( $a{seq} ); | |||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | 61 | return \%a; | |||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | sub as_hash { | ||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_hash: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | return { id => $self->id, desc => $self->desc, seq => $self->seq, info => $self->info }; | |||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | sub Format_seq_string { | ||||||||||||||||||||||||||||||||||||||||||
| 62 | 1 | ▶ | my ($str, $width) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Format_seq_string: called CC=4 SCAR=15.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | 1 | ▶ | $width //= $WIDTH; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$width //= $Bio::Gonzales::Seq::WIDTH
MC/DC0%0/2
$width //= $Bio::Gonzales::Seq::WIDTH
$width
$Bio::Gonzales::Seq::WIDTH
Truth table33%1/3
A //= B
A= $widthB= $Bio::Gonzales::Seq::WIDTH
| |||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||
| 65 | 1 | ▶ | if ( defined $str && length($str) > 0 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $str and CORE::length $str > 0
MC/DC0%0/2
defined $str and CORE::length $str > 0
defined $str
CORE::length $str > 0
Truth table33%1/3
A and B
A= defined $strB= CORE::length $str > 0
| |||||||||||||||||||||||||||||||||||||||||||
| 66 | 1 | $str =~ tr/ \t\n\r//d; # Remove whitespace and numbers | |||||||||||||||||||||||||||||||||||||||||
| 67 | 1 | $str =~ s/\d+//g; | |||||||||||||||||||||||||||||||||||||||||
| 68 | 1 | $str =~ s/(.{1,$width})/$1\n/g; | |||||||||||||||||||||||||||||||||||||||||
| 69 | 1 | return $str; | |||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||
| 73 | sub def { | ||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
def: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | return join( $self->delim, $self->id, $self->desc ); | |||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | before 'desc' => sub { | ||||||||||||||||||||||||||||||||||||||||||
| 80 | 250 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | 250 | ▶ | if ( @_ == 1 && $_[0] eq '' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@_ == 1 and $_[0] eq ""
MC/DC50%1/2
@_ == 1 and $_[0] eq ""
@_ == 1
$_[0] eq ""
Truth table66%2/3
A and B
A= @_ == 1B= $_[0] eq ""
| |||||||||||||||||||||||||||||||||||||||||||
| 83 | 1 | $self->delim(''); | |||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||
| 85 | 9 | }; | |||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||
| 87 | sub _filter_seq { | ||||||||||||||||||||||||||||||||||||||||||
| 88 | 63 | ▶ | my ($seq) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_filter_seq: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||
| 90 | 63 | ▶ | $seq = join( "", @$seq ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 91 | if ( ref($seq) eq 'ARRAY' ); | ||||||||||||||||||||||||||||||||||||||||||
| 92 | 63 | $seq =~ y/ \t\n\r\f//d; | |||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | 63 | return $seq; | |||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||
| 97 | around 'seq' => sub { | ||||||||||||||||||||||||||||||||||||||||||
| 98 | 245 | ▶ | my $orig = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | 245 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||
| 101 | 245 | ▶ | return $self->$orig() | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 102 | unless @_; | ||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | 2 | return $self->$orig( _filter_seq(@_) ); | |||||||||||||||||||||||||||||||||||||||||
| 105 | 9 | }; | |||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | sub gapless_seq { | ||||||||||||||||||||||||||||||||||||||||||
| 108 | 1 | ▶ | (my $seq = shift->seq) =~ tr/-.//d; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
gapless_seq: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | 1 | return $seq; | |||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||
| 112 | sub rm_gaps { | ||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rm_gaps: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | $self->seq( $self->gapless_seq ); | |||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||
| 119 | sub clone { | ||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clone: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | return __PACKAGE__->new( id => $self->id, desc => $self->desc, seq => $self->seq, delim => $self->delim, info => $self->info ); | |||||||||||||||||||||||||||||||||||||||||
| 123 | #shift->clone_object(@_) | ||||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||
| 126 | sub clone_empty { | ||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clone_empty: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | return __PACKAGE__->new( id => $self->id, desc => $self->desc, seq => '', delim => $self->delim , info => $self->info); | |||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||
| 132 | 1 | ▶ | sub display_id { shift->id(@_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
display_id: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||
| 134 | sub ungapped_length { | ||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ungapped_length: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | return $self->length - $self->gaps; | |||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | ▶ | sub sequence { shift->seq(@_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sequence: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||
| 142 | sub stringify { | ||||||||||||||||||||||||||||||||||||||||||
| 143 | 220 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stringify: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||
| 145 | 220 | ▶ | return ">" . $self->id . ( $self->desc ? $self->delim . $self->desc : "" ) . "\n" . $self->seq . "\n"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||
| 148 | 220 | ▶ | sub all { shift->stringify(@_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
all: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | ▶ | sub all_formatted { shift->stringify_pretty(@_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
all_formatted: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||
| 152 | sub stringify_pretty { | ||||||||||||||||||||||||||||||||||||||||||
| 153 | 1 | ▶ | my ($self, $width) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stringify_pretty: called CC=3 SCAR=12.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 154 | 1 | ▶ | $width //= $WIDTH; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$width //= $Bio::Gonzales::Seq::WIDTH
MC/DC0%0/2
$width //= $Bio::Gonzales::Seq::WIDTH
$width
$Bio::Gonzales::Seq::WIDTH
Truth table33%1/3
A //= B
A= $widthB= $Bio::Gonzales::Seq::WIDTH
| |||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||
| 156 | return | ||||||||||||||||||||||||||||||||||||||||||
| 157 | 1 | ▶ | ">" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 158 | . $self->id | ||||||||||||||||||||||||||||||||||||||||||
| 159 | . ( $self->desc ? $self->delim . $self->desc : "" ) . "\n" | ||||||||||||||||||||||||||||||||||||||||||
| 160 | . Format_seq_string( $self->seq ); | ||||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||
| 163 | 1 | ▶ | sub all_pretty { shift->stringify_pretty(@_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
all_pretty: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | ▶ | sub pretty { shift->stringify_pretty(@_) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pretty: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||
| 167 | sub as_primaryseq { | ||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_primaryseq: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | return Bio::PrimarySeq->new( | |||||||||||||||||||||||||||||||||||||||||
| 171 | -seq => $self->seq, | ||||||||||||||||||||||||||||||||||||||||||
| 172 | -id => $self->id, | ||||||||||||||||||||||||||||||||||||||||||
| 173 | -desc => $self->desc, | ||||||||||||||||||||||||||||||||||||||||||
| 174 | -alphabet => $self->guess_alphabet, | ||||||||||||||||||||||||||||||||||||||||||
| 175 | -direct => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 176 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||
| 179 | sub guess_alphabet { | ||||||||||||||||||||||||||||||||||||||||||
| 180 | 1 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
guess_alphabet: called CC=4 SCAR=15.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||
| 182 | 1 | my $str = $self->seq(); | |||||||||||||||||||||||||||||||||||||||||
| 183 | 1 | $str =~ s/[-.?*]//gi; | |||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||
| 185 | 1 | my $alphabet; | |||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||
| 187 | # Check for sequences without valid letters | ||||||||||||||||||||||||||||||||||||||||||
| 188 | 1 | my $total = CORE::length($str); | |||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||
| 190 | 1 | ▶ | if ( $str =~ m/[EFIJLOPQXZ]/i ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 191 | # Start with a safe method to find proteins. | ||||||||||||||||||||||||||||||||||||||||||
| 192 | # Unambiguous IUPAC letters for proteins are: E,F,I,J,L,O,P,Q,X,Z | ||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | $alphabet = 'protein'; | |||||||||||||||||||||||||||||||||||||||||
| 194 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 195 | # Alphabet is unsure, could still be DNA, RNA or protein. | ||||||||||||||||||||||||||||||||||||||||||
| 196 | # DNA and RNA contain mostly A, T, U, G, C and N, but the other letters | ||||||||||||||||||||||||||||||||||||||||||
| 197 | # they use are also among the 15 valid letters that a protein sequence | ||||||||||||||||||||||||||||||||||||||||||
| 198 | # can contain at this stage. Make our best guess based on sequence | ||||||||||||||||||||||||||||||||||||||||||
| 199 | # composition. If it contains over 70% of ACGTUN, it is likely nucleic. | ||||||||||||||||||||||||||||||||||||||||||
| 200 | 1 | ▶ | if ( ( $str =~ tr/ATUGCNatugcn// ) / $total > 0.7 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 201 | 1 | ▶ | if ( $str =~ m/U/i ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | $alphabet = 'rna'; | |||||||||||||||||||||||||||||||||||||||||
| 203 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 204 | 1 | $alphabet = 'dna'; | |||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||
| 206 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | $alphabet = 'protein'; | |||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||
| 210 | 1 | return $alphabet; | |||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||
| 213 | sub revcom { | ||||||||||||||||||||||||||||||||||||||||||
| 214 | 1 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
revcom: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||
| 216 | 1 | $self->seq( _revcom_from_string( $self->seq, $self->guess_alphabet ) ); | |||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||
| 218 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||
| 221 | sub revcom_seq { | ||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
revcom_seq: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | return _revcom_from_string( $self->seq, $self->guess_alphabet ); | |||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||
| 226 | sub subseq { | ||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | ▶ | my ( $self, $range, $c ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
subseq: not called CC=12 SCAR=50.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | ▶ | $range = [ $range->start, $range->end, $range->strand ] | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
builtin::blessed($range) and $range->isa("Bio::Gonzales::Feat")
MC/DC0%0/2
builtin::blessed($range) and $range->isa("Bio::Gonzales::Feat")
builtin::blessed($range)
$range->isa("Bio::Gonzales::Feat")
Truth table0%0/3
A and B
A= builtin::blessed($range)B= $range->isa("Bio::Gonzales::Feat")
| |||||||||||||||||||||||||||||||||||||||||||
| 230 | if ( blessed($range) && $range->isa('Bio::Gonzales::Feat') ); | ||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | my ( $seq, $corrected_range ) = $self->subseq_as_string( $range, $c ); | |||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | my ( $b, $e, $strand, @rest ) = @$corrected_range; | |||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | my $keep_original_id = $c->{keep_id}; | |||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | my $new_seq = $self->clone_empty; | |||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | $new_seq->seq($seq); | |||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | ▶ | if ( $c->{attach_details} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | my $info = $new_seq->info; | |||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | $info->{subseq} = { from => $b + 1, to => $e }; | |||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | ▶ | $info->{subseq}{strand} = ( $strand < 0 ? '-' : ( $strand > 0 ? '+' : '.' ) ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | ▶ | $info->{subseq}{rest} = \@rest if ( @rest > 0 ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | ▶ | unless ($keep_original_id) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | $new_seq->id( $new_seq->id . "|" . ( $b + 1 ) . "..$e" ); | |||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | ▶ | $new_seq->id( $new_seq->id . "|" . ( $strand < 0 ? '-' : ( $strand > 0 ? '+' : '.' ) ) ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 249 | if ( defined($strand) ); #print also nothing if strand == 0 | ||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | ▶ | $new_seq->id( $new_seq->id . "|" . join( "|", @rest ) ) if ( @rest > 0 ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | return $new_seq; | |||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||
| 255 | sub sha1_checksum { | ||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | ▶ | return sha1_hex(uc(shift->seq)); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sha1_checksum: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||
| 259 | sub md5_checksum { | ||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | ▶ | return md5_hex(uc(shift->seq)); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
md5_checksum: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||
| 263 | sub subseq_as_string { | ||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | ▶ | my ( $self, $range, $c ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
subseq_as_string: not called CC=24 SCAR=64.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | ▶ | confess "you use the deprecated version of subseq" if ( defined($c) && ref $c ne 'HASH' ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $c and ref $c ne "HASH"
MC/DC0%0/2
defined $c and ref $c ne "HASH"
defined $c
ref $c ne "HASH"
Truth table0%0/3
A and B
A= defined $cB= ref $c ne "HASH"
| |||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | my ( $b, $e, $strand, @rest ) = @$range; | |||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | ▶ | if ( $c->{relaxed_range} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 270 | #if b or e are not defined, just take the beginning and end as given | ||||||||||||||||||||||||||||||||||||||||||
| 271 | #warn "requested invalid subseq range ($b,$e;$strand) from " . $self->id . ", using relaxed boundaries." | ||||||||||||||||||||||||||||||||||||||||||
| 272 | #unless ( $b && $e ); | ||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | ▶ | $b ||= '^'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$b ||= "^"
MC/DC0%0/1
$b ||= "^"
$b
Truth table0%0/2
A
A= $b
| |||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | ▶ | $e ||= '$'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$e ||= "\$"
MC/DC0%0/1
$e ||= "\$"
$e
Truth table0%0/2
A
A= $e
| |||||||||||||||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | ▶ | confess "requested invalied subseq range ($b,$e;$strand) from " | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$b and $e
MC/DC0%0/2
$b and $e
$b
$e
Truth table0%0/3
A and B
A= $bB= $e
| |||||||||||||||||||||||||||||||||||||||||||
| 278 | . $self->id . "\n" | ||||||||||||||||||||||||||||||||||||||||||
| 279 | . Dumper($range) | ||||||||||||||||||||||||||||||||||||||||||
| 280 | . Dumper( $self->clone_empty ) | ||||||||||||||||||||||||||||||||||||||||||
| 281 | unless ( $b && $e ); | ||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | my $seq_len = $self->length; | |||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | ▶ | $b = 1 if ( $b eq '^' ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | ▶ | $b = $seq_len if ( $b eq '$' ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | ▶ | $e = 1 if ( $e eq '^' ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | ▶ | $e = $seq_len if ( $e eq '$' ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | ▶ | croak "subseq range error: $b > $e" if ( $b > $e && $b > 0 && $e > 0 ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$b > $e and $b > 0 and $e > 0
$b > $e and $b > 0
MC/DC0%0/3
$b > $e and $b > 0 and $e > 0
$b > $e
$b > 0
$e > 0
Truth table0%0/4
A and B and C
A= $b > $eB= $b > 0C= $e > 0
| |||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||
| 293 | #count from the end, | ||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | ▶ | if ( $b < 0 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | ▶ | $b = $c->{wrap} ? $seq_len + $b + 1 : 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | ▶ | if ( $e < 0 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | ▶ | $e = $c->{wrap} ? $seq_len + $e + 1 : $seq_len; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||
| 301 | #get the index right for substr. | ||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | $b--; | |||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | my $seq = substr( $self->{seq}, $b, $e - $b ); | |||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | ▶ | if ( $strand && $strand < 0 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$strand and $strand < 0
MC/DC0%0/2
$strand and $strand < 0
$strand
$strand < 0
Truth table0%0/3
A and B
A= $strandB= $strand < 0
| |||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | ▶ | if ( $c->{relaxed_revcom} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | $seq =~ y/AGCTNagctn/N/c; | |||||||||||||||||||||||||||||||||||||||||
| 309 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | ▶ | confess "cannot create reverse complement, sequence contains non-AGCTN characters" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 311 | if ( $seq =~ /[^AGCTN]/i ); | ||||||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | $seq = _revcom_from_string( $seq, $self->guess_alphabet ); | |||||||||||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | ▶ | return wantarray ? ( $seq, [ $b, $e, $strand, @rest ] ) : $seq; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||
| 320 | sub _revcom_from_string { | ||||||||||||||||||||||||||||||||||||||||||
| 321 | 1 | ▶ | my ( $string, $alphabet ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_revcom_from_string: called CC=6 SCAR=21.9
| |||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||
| 323 | # Check that reverse-complementing makes sense | ||||||||||||||||||||||||||||||||||||||||||
| 324 | 1 | ▶ | if ( $alphabet eq 'protein' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | confess("Sequence is a protein. Cannot revcom."); | |||||||||||||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||||||||||||
| 327 | 1 | ▶ | if ( $alphabet ne 'dna' && $alphabet ne 'rna' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$alphabet ne "dna" and $alphabet ne "rna"
MC/DC0%0/2
$alphabet ne "dna" and $alphabet ne "rna"
$alphabet ne "dna"
$alphabet ne "rna"
Truth table33%1/3
A and B
A= $alphabet ne "dna"B= $alphabet ne "rna"
| |||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | carp "Sequence is not dna or rna, but [$alphabet]. Attempting to revcom, " | |||||||||||||||||||||||||||||||||||||||||
| 329 | . "but unsure if this is right."; | ||||||||||||||||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||
| 332 | # If sequence is RNA, map to DNA (then map back later) | ||||||||||||||||||||||||||||||||||||||||||
| 333 | 1 | ▶ | if ( $alphabet eq 'rna' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | $string =~ tr/uU/tT/; | |||||||||||||||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||
| 337 | # Reverse-complement now | ||||||||||||||||||||||||||||||||||||||||||
| 338 | 1 | $string =~ tr/acgtrymkswhbvdnxACGTRYMKSWHBVDNX/tgcayrkmswdvbhnxTGCAYRKMSWDVBHNX/; | |||||||||||||||||||||||||||||||||||||||||
| 339 | 1 | $string = CORE::reverse $string; | |||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||
| 341 | # Map back RNA to DNA | ||||||||||||||||||||||||||||||||||||||||||
| 342 | 1 | ▶ | if ( $alphabet eq 'rna' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | $string =~ tr/tT/uU/; | |||||||||||||||||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||
| 346 | 1 | return $string; | |||||||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||
| 349 | 9 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||
| 351 | __END__ | ||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||
| 353 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||
| 355 | Bio::Gonzales::Seq - Gonzales Sequence Object | ||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||
| 357 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||
| 359 | my $seq = Bio::Gonzales::Seq->new(id => $id, seq => $seq, desc? => '', delim? => ' '); | ||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||
| 361 | print $seq->def; | ||||||||||||||||||||||||||||||||||||||||||
| 362 | print $seq->desc; | ||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||
| 364 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||
| 366 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||
| 368 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||
| 370 | =item B<< $seq->id >> | ||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||
| 372 | =item B<< $seq->desc >> | ||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||
| 374 | The description of a sequence object. In case of FASTA-files, this corresponds | ||||||||||||||||||||||||||||||||||||||||||
| 375 | to the text after the first space. | ||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||
| 377 | =item B<< $seq->seq >> | ||||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||
| 379 | =item B<< $seq->delim >> | ||||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||||
| 381 | =item B<< $seq->info >> | ||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||
| 383 | An hash of additional stuff you can store about the sequence | ||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||
| 385 | =item B<< $seq->gaps >> | ||||||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||||||
| 387 | =item B<< $seq->length >> | ||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||
| 389 | =item B<< $seq->def >> | ||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||
| 391 | The definition also known as the FASTA header line w/o ">" | ||||||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||||||
| 393 | =item B<< $seq->clone >> | ||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||
| 395 | Clone the sequence | ||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||
| 397 | =item B<< $seq->clone_empty >> | ||||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||||
| 399 | Clone the sequence properties, do not clone the sequence string. | ||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||
| 401 | =item B<< $seq->display_id >> | ||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||
| 403 | Same as C<$seq->id> | ||||||||||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||||||||||
| 405 | =item B<< $seq->ungapped_length >> | ||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||
| 407 | =item B<< $seq->all >> | ||||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||
| 409 | =item B<< "$seq" >> | ||||||||||||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||||||||||
| 411 | The complete sequence in fasta format, ready to be written. | ||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||
| 413 | =item B<< $seq->all_formatted >> | ||||||||||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||||||||||
| 415 | =item B<< $seq->all_pretty >> | ||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||
| 417 | The complete sequence in I<pretty> fasta format, ready to be written. | ||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||
| 419 | =item B<< $seq->as_primaryseq >> | ||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||
| 421 | Return a Bio::PrimarySeqI compatible object, so you can use it in BioPerl. | ||||||||||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||||||||
| 423 | =item B<< $seq_string = $seq->gapless_seq >> | ||||||||||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||||||||||
| 425 | =item B<< $seq->rm_gaps! >> | ||||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||
| 427 | =item B<< $seq->revcom >> | ||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||
| 429 | Create the reverse complement of the sequence. B<THIS FUNCTION ALTERS THE SEQUENCE OBJECT>. | ||||||||||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||||||||||
| 431 | =item B<< $seq->subseq( [ $begin, $end, $strand , @rest ], \%c ) >> | ||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||
| 433 | Gets a subseq from C<$seq>. Config options can be: | ||||||||||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||||||||||
| 435 | %c = ( | ||||||||||||||||||||||||||||||||||||||||||
| 436 | keep_id => 1, # keeps the original id of the sequence | ||||||||||||||||||||||||||||||||||||||||||
| 437 | attach_details => 1, # keeps the original range and strand in $seq->info->{subseq} | ||||||||||||||||||||||||||||||||||||||||||
| 438 | wrap => 1, # see further down | ||||||||||||||||||||||||||||||||||||||||||
| 439 | relaxed_range => 1, # substitute 0 or undef for $begin with '^' and for $end with '$' | ||||||||||||||||||||||||||||||||||||||||||
| 440 | relaxed_revcom => 1, # substitute N for all characters that are non-AGCTN before doing a reverse complement | ||||||||||||||||||||||||||||||||||||||||||
| 441 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||
| 443 | There are several possibilities for C<$begin> and C<$end>: | ||||||||||||||||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||||||||||||||
| 445 | GGCAAAGGA ATGATGGTGT GCAGGCTTGG CATGGGAGAC | ||||||||||||||||||||||||||||||||||||||||||
| 446 | ^..........^ (1,11) OR ('^', 11) | ||||||||||||||||||||||||||||||||||||||||||
| 447 | ^.....................................^ (4,'$') | ||||||||||||||||||||||||||||||||||||||||||
| 448 | ^..............^ (21,35) { with wrap on: OR (-19,35) OR (-19, -5) } | ||||||||||||||||||||||||||||||||||||||||||
| 449 | ^..................^ (21,35) { with wrap on: OR (-19,'$') } | ||||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||||
| 451 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||
| 453 | =item C<wrap> | ||||||||||||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||||||||||||
| 455 | The default is to limit all negative | ||||||||||||||||||||||||||||||||||||||||||
| 456 | values to the sequence boundaries, so a negative begin would be equal to 1 or | ||||||||||||||||||||||||||||||||||||||||||
| 457 | '^' and a negative end would be equal to '$'. | ||||||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||||||
| 459 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||
| 461 | See also L<Bio::Gonzales::Seq::IO/fasubseq>. | ||||||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||||||
| 463 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||||
| 465 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||||
| 467 | =item B<< my $reverse_complement_string = Bio::Gonzales::Seq::_revcom_from_string($seq_string, $alphabet) >> | ||||||||||||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||||||||||||
| 469 | Stolen from L<Bio::Perl>. Alphabet can be 'rna' or 'dna'; | ||||||||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||||||
| 471 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||||||||||||||||
| 473 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||||||||||||||||
| 475 | jw bargsten, C<< <joachim.bargsten at wur.nl> >> | ||||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||
| 477 | =cut | ||||||||||||||||||||||||||||||||||||||||||