| 1 | package Bio::CUA::Seq; | ||||||||||||||
| 2 | |||||||||||||||
| 3 | =head1 NAME | ||||||||||||||
| 4 | |||||||||||||||
| 5 | Bio::CUA::Seq - a module processing sequence object | ||||||||||||||
| 6 | |||||||||||||||
| 7 | =head1 SYNOPSIS | ||||||||||||||
| 8 | |||||||||||||||
| 9 | use Bio::CUA::Seq; | ||||||||||||||
| 10 | |||||||||||||||
| 11 | my $obj = Bio::CUA::Seq->new( | ||||||||||||||
| 12 | -seq => 'AGGTGCCG...', | ||||||||||||||
| 13 | -id => 'test_id', | ||||||||||||||
| 14 | -desc => 'sequence description' | ||||||||||||||
| 15 | ); | ||||||||||||||
| 16 | |||||||||||||||
| 17 | # available methods | ||||||||||||||
| 18 | $obj->length; # get sequence length | ||||||||||||||
| 19 | $obj->id; # get sequence id | ||||||||||||||
| 20 | $obj->desc; # get sequence description | ||||||||||||||
| 21 | $obj->seq; # get sequence string | ||||||||||||||
| 22 | |||||||||||||||
| 23 | =head1 DESCRIPTION | ||||||||||||||
| 24 | |||||||||||||||
| 25 | This module is called by L<Bio::CUA::SeqIO> to create sequence | ||||||||||||||
| 26 | object which has some basic methods required by the modules in the | ||||||||||||||
| 27 | distribution L<http://search.cpan.org/dist/Bio-CUA/>. The purpose of | ||||||||||||||
| 28 | this module is to increase the portability of the distribution. | ||||||||||||||
| 29 | |||||||||||||||
| 30 | =cut | ||||||||||||||
| 31 | |||||||||||||||
| 32 | 5 | ▶ | use 5.006; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 33 | 5 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 34 | 5 | ▶ | use warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 35 | 5 | ▶ | use base qw/Bio::CUA/; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 36 | |||||||||||||||
| 37 | =head1 METHODS | ||||||||||||||
| 38 | |||||||||||||||
| 39 | =head2 new | ||||||||||||||
| 40 | |||||||||||||||
| 41 | Title : new | ||||||||||||||
| 42 | Usage : my $obj = Bio::CUA::Seq->new(%params); | ||||||||||||||
| 43 | Function: create sequence object | ||||||||||||||
| 44 | Returns : an object of this class | ||||||||||||||
| 45 | Args : arguments are specified in a hash and acceptable keys as follows: | ||||||||||||||
| 46 | |||||||||||||||
| 47 | =over 5 | ||||||||||||||
| 48 | |||||||||||||||
| 49 | =item C<-seq> | ||||||||||||||
| 50 | |||||||||||||||
| 51 | the sequence string for the object, which can only be characters in | ||||||||||||||
| 52 | the range A-Z and a-z. Other characters are eliminated by the method. | ||||||||||||||
| 53 | |||||||||||||||
| 54 | =item C<-id> | ||||||||||||||
| 55 | |||||||||||||||
| 56 | the sequence name | ||||||||||||||
| 57 | |||||||||||||||
| 58 | =item C<-desc> | ||||||||||||||
| 59 | |||||||||||||||
| 60 | extra description of this sequence | ||||||||||||||
| 61 | |||||||||||||||
| 62 | =back | ||||||||||||||
| 63 | |||||||||||||||
| 64 | =cut | ||||||||||||||
| 65 | |||||||||||||||
| 66 | sub new | ||||||||||||||
| 67 | { | ||||||||||||||
| 68 | 104 | ▶ | my ($caller, @args) = @_; | ||||||||||||
|
Subroutine
new: called CC=5 SCAR=17.1
Pod
documented
| |||||||||||||||
| 69 | |||||||||||||||
| 70 | 104 | my $self = $caller->SUPER::new(@args); | |||||||||||||
| 71 | |||||||||||||||
| 72 | 104 | my $hashRef = $self->_array_to_hash(\@args); | |||||||||||||
| 73 | |||||||||||||||
| 74 | 104 | my $str = $hashRef->{'seq'}; | |||||||||||||
| 75 | 104 | $str =~ s/[^a-z]+//gi; # eliminate unknown chars | |||||||||||||
| 76 | |||||||||||||||
| 77 | $self->warn("No valid sequence string found", | ||||||||||||||
| 78 | 104 | ▶ | exists $hashRef->{'id'}? "for ".$hashRef->{'id'}:"") | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 79 | unless($str); | ||||||||||||||
| 80 | |||||||||||||||
| 81 | 104 | $self->set_tag('seqstr', $str); | |||||||||||||
| 82 | 104 | ▶ | $self->set_tag('id', $hashRef->{'id'}) if(exists $hashRef->{'id'}); | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 83 | $self->set_tag('desc', $hashRef->{'desc'}) if(exists | ||||||||||||||
| 84 | 104 | ▶ | $hashRef->{'desc'}); | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 85 | |||||||||||||||
| 86 | 104 | return $self; | |||||||||||||
| 87 | } | ||||||||||||||
| 88 | |||||||||||||||
| 89 | =head2 length | ||||||||||||||
| 90 | |||||||||||||||
| 91 | Title : length | ||||||||||||||
| 92 | Usage : my $len = $self->length; | ||||||||||||||
| 93 | Function: get the length of the sequence | ||||||||||||||
| 94 | Returns : an integer | ||||||||||||||
| 95 | Args : None | ||||||||||||||
| 96 | |||||||||||||||
| 97 | =cut | ||||||||||||||
| 98 | |||||||||||||||
| 99 | sub length | ||||||||||||||
| 100 | { | ||||||||||||||
| 101 | 13 | ▶ | my $str = $_[0]->get_tag('seqstr'); | ||||||||||||
|
Subroutine
length: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 102 | 13 | return length($str); | |||||||||||||
| 103 | } | ||||||||||||||
| 104 | |||||||||||||||
| 105 | =head2 id | ||||||||||||||
| 106 | |||||||||||||||
| 107 | Title : id | ||||||||||||||
| 108 | Usage : my $id = $self->id; | ||||||||||||||
| 109 | Function: get sequence name/id | ||||||||||||||
| 110 | Returns : a string | ||||||||||||||
| 111 | Args : None | ||||||||||||||
| 112 | |||||||||||||||
| 113 | =cut | ||||||||||||||
| 114 | |||||||||||||||
| 115 | sub id | ||||||||||||||
| 116 | { | ||||||||||||||
| 117 | 91 | ▶ | $_[0]->get_tag('id'); | ||||||||||||
|
Subroutine
id: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 118 | } | ||||||||||||||
| 119 | |||||||||||||||
| 120 | =head2 desc | ||||||||||||||
| 121 | |||||||||||||||
| 122 | Title : desc | ||||||||||||||
| 123 | Usage : my $desc = $self->desc | ||||||||||||||
| 124 | Function: get sequence description | ||||||||||||||
| 125 | Returns : a string or undef if not exist | ||||||||||||||
| 126 | Args : None | ||||||||||||||
| 127 | |||||||||||||||
| 128 | =cut | ||||||||||||||
| 129 | |||||||||||||||
| 130 | sub desc | ||||||||||||||
| 131 | { | ||||||||||||||
| 132 | 0 | ▶ | $_[0]->get_tag('desc'); | ||||||||||||
|
Subroutine
desc: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||
| 133 | } | ||||||||||||||
| 134 | |||||||||||||||
| 135 | =head2 seq | ||||||||||||||
| 136 | |||||||||||||||
| 137 | Title : seq | ||||||||||||||
| 138 | Usage : my $seq = $self->seq | ||||||||||||||
| 139 | Function: get sequence string of the object | ||||||||||||||
| 140 | Returns : a string | ||||||||||||||
| 141 | Args : None | ||||||||||||||
| 142 | |||||||||||||||
| 143 | =cut | ||||||||||||||
| 144 | |||||||||||||||
| 145 | sub seq | ||||||||||||||
| 146 | { | ||||||||||||||
| 147 | 130 | ▶ | $_[0]->get_tag('seqstr'); | ||||||||||||
|
Subroutine
seq: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 148 | } | ||||||||||||||
| 149 | |||||||||||||||
| 150 | =head1 AUTHOR | ||||||||||||||
| 151 | |||||||||||||||
| 152 | Zhenguo Zhang, C<< <zhangz.sci at gmail.com> >> | ||||||||||||||
| 153 | |||||||||||||||
| 154 | =head1 BUGS | ||||||||||||||
| 155 | |||||||||||||||
| 156 | Please report any bugs or feature requests to C<bug-bio-cua at rt.cpan.org>, or through | ||||||||||||||
| 157 | the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Bio-CUA>. I will be notified, and then you'll | ||||||||||||||
| 158 | automatically be notified of progress on your bug as I make changes. | ||||||||||||||
| 159 | |||||||||||||||
| 160 | =head1 SUPPORT | ||||||||||||||
| 161 | |||||||||||||||
| 162 | You can find documentation for this module with the perldoc command. | ||||||||||||||
| 163 | |||||||||||||||
| 164 | perldoc Bio::CUA::Seq | ||||||||||||||
| 165 | |||||||||||||||
| 166 | |||||||||||||||
| 167 | You can also look for information at: | ||||||||||||||
| 168 | |||||||||||||||
| 169 | =over 4 | ||||||||||||||
| 170 | |||||||||||||||
| 171 | =item * RT: CPAN's request tracker (report bugs here) | ||||||||||||||
| 172 | |||||||||||||||
| 173 | L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Bio-CUA> | ||||||||||||||
| 174 | |||||||||||||||
| 175 | =item * AnnoCPAN: Annotated CPAN documentation | ||||||||||||||
| 176 | |||||||||||||||
| 177 | L<http://annocpan.org/dist/Bio-CUA> | ||||||||||||||
| 178 | |||||||||||||||
| 179 | =item * CPAN Ratings | ||||||||||||||
| 180 | |||||||||||||||
| 181 | L<http://cpanratings.perl.org/d/Bio-CUA> | ||||||||||||||
| 182 | |||||||||||||||
| 183 | =item * Search CPAN | ||||||||||||||
| 184 | |||||||||||||||
| 185 | L<http://search.cpan.org/dist/Bio-CUA/> | ||||||||||||||
| 186 | |||||||||||||||
| 187 | =back | ||||||||||||||
| 188 | |||||||||||||||
| 189 | |||||||||||||||
| 190 | =head1 ACKNOWLEDGEMENTS | ||||||||||||||
| 191 | |||||||||||||||
| 192 | |||||||||||||||
| 193 | =head1 LICENSE AND COPYRIGHT | ||||||||||||||
| 194 | |||||||||||||||
| 195 | Copyright 2015 Zhenguo Zhang. | ||||||||||||||
| 196 | |||||||||||||||
| 197 | This program is free software: you can redistribute it and/or modify | ||||||||||||||
| 198 | it under the terms of the GNU General Public License as published by | ||||||||||||||
| 199 | the Free Software Foundation, either version 3 of the License, or | ||||||||||||||
| 200 | (at your option) any later version. | ||||||||||||||
| 201 | |||||||||||||||
| 202 | This program is distributed in the hope that it will be useful, | ||||||||||||||
| 203 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||||||||||
| 204 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||||||||||||
| 205 | GNU General Public License for more details. | ||||||||||||||
| 206 | |||||||||||||||
| 207 | You should have received a copy of the GNU General Public License | ||||||||||||||
| 208 | along with this program. If not, see L<http://www.gnu.org/licenses/>. | ||||||||||||||
| 209 | |||||||||||||||
| 210 | |||||||||||||||
| 211 | =cut | ||||||||||||||
| 212 | |||||||||||||||
| 213 | 5 | 1; # End of Bio::CUA::Seq | |||||||||||||