| 1 | # | ||
| 2 | # BioPerl module for FAST::Bio::SeqFeature::Similarity | ||
| 3 | # | ||
| 4 | # Please direct questions and support issues to <bioperl-l@bioperl.org> | ||
| 5 | # | ||
| 6 | # Cared for by Hilmar Lapp <hlapp@gmx.net> | ||
| 7 | # | ||
| 8 | # Copyright Hilmar Lapp | ||
| 9 | # | ||
| 10 | # You may distribute this module under the same terms as perl itself | ||
| 11 | |||
| 12 | # POD documentation - main docs before the code | ||
| 13 | |||
| 14 | =head1 NAME | ||
| 15 | |||
| 16 | FAST::Bio::SeqFeature::Similarity - A sequence feature based on similarity | ||
| 17 | |||
| 18 | =head1 SYNOPSIS | ||
| 19 | |||
| 20 | # obtain a similarity feature somehow | ||
| 21 | print "significance: ", $sim_fea->significance(), "\n"; | ||
| 22 | print "bit score: ", $sim_fea->bits(), "\n"; | ||
| 23 | print "score: ", $sim_fea->score(), "\n"; | ||
| 24 | print "fraction of identical residues: ", $sim_fea->frac_identical(), "\n"; | ||
| 25 | |||
| 26 | =head1 DESCRIPTION | ||
| 27 | |||
| 28 | This module is basically a sequence features based on similarity, and therefore | ||
| 29 | has support for measures assessing the similarity. | ||
| 30 | |||
| 31 | Everything else is inherited from L<FAST::Bio::SeqFeature::Generic>. | ||
| 32 | |||
| 33 | =head1 FEEDBACK | ||
| 34 | |||
| 35 | =head2 Mailing Lists | ||
| 36 | |||
| 37 | User feedback is an integral part of the evolution of this | ||
| 38 | and other Bioperl modules. Send your comments and suggestions preferably | ||
| 39 | to one of the Bioperl mailing lists. | ||
| 40 | Your participation is much appreciated. | ||
| 41 | |||
| 42 | bioperl-l@bioperl.org - General discussion | ||
| 43 | http://bioperl.org/wiki/Mailing_lists - About the mailing lists | ||
| 44 | |||
| 45 | =head2 Support | ||
| 46 | |||
| 47 | Please direct usage questions or support issues to the mailing list: | ||
| 48 | |||
| 49 | I<bioperl-l@bioperl.org> | ||
| 50 | |||
| 51 | rather than to the module maintainer directly. Many experienced and | ||
| 52 | reponsive experts will be able look at the problem and quickly | ||
| 53 | address it. Please include a thorough description of the problem | ||
| 54 | with code and data examples if at all possible. | ||
| 55 | |||
| 56 | =head2 Reporting Bugs | ||
| 57 | |||
| 58 | Report bugs to the Bioperl bug tracking system to help us keep track | ||
| 59 | the bugs and their resolution. Bug reports can be submitted via the | ||
| 60 | web: | ||
| 61 | |||
| 62 | https://redmine.open-bio.org/projects/bioperl/ | ||
| 63 | |||
| 64 | =head1 AUTHOR - Hilmar Lapp | ||
| 65 | |||
| 66 | Email hlapp@gmx.net or hilmar.lapp@pharma.novartis.com | ||
| 67 | |||
| 68 | =head1 APPENDIX | ||
| 69 | |||
| 70 | The rest of the documentation details each of the object | ||
| 71 | methods. Internal methods are usually preceded with a _ | ||
| 72 | |||
| 73 | =cut | ||
| 74 | |||
| 75 | |||
| 76 | # Let the code begin... | ||
| 77 | |||
| 78 | |||
| 79 | package FAST::Bio::SeqFeature::Similarity; | ||
| 80 | use strict; | ||
| 81 | |||
| 82 | |||
| 83 | use base qw(FAST::Bio::SeqFeature::Generic); | ||
| 84 | |||
| 85 | sub new { | ||
| 86 | my ( $caller, @args) = @_; | ||
| 87 | my ($self) = $caller->SUPER::new(@args); | ||
| 88 | |||
| 89 | my ($primary,$evalue, $bits, $frac,$seqlen,$seqdesc) = | ||
| 90 | $self->_rearrange([qw(PRIMARY | ||
| 91 | EXPECT | ||
| 92 | BITS | ||
| 93 | FRAC | ||
| 94 | SEQLENGTH | ||
| 95 | SEQDESC | ||
| 96 | )],@args); | ||
| 97 | |||
| 98 | defined $evalue && $self->significance($evalue); | ||
| 99 | defined $bits && $self->bits($bits); | ||
| 100 | defined $frac && $self->frac_identical($frac); | ||
| 101 | defined $seqlen && $self->seqlength($seqlen); | ||
| 102 | defined $seqdesc && $self->seqdesc($seqdesc); | ||
| 103 | $primary = 'similarity' unless defined $primary; | ||
| 104 | $self->primary_tag($primary) unless( defined $self->primary_tag() ); | ||
| 105 | $self->strand(0) unless( defined $self->strand() ); | ||
| 106 | |||
| 107 | return $self; | ||
| 108 | } | ||
| 109 | |||
| 110 | =head2 significance | ||
| 111 | |||
| 112 | Title : significance | ||
| 113 | Usage : $evalue = $obj->significance(); | ||
| 114 | $obj->significance($evalue); | ||
| 115 | Function: | ||
| 116 | Returns : | ||
| 117 | Args : | ||
| 118 | |||
| 119 | |||
| 120 | =cut | ||
| 121 | |||
| 122 | sub significance { | ||
| 123 | return shift->_tag_value('signif', @_); | ||
| 124 | } | ||
| 125 | |||
| 126 | =head2 bits | ||
| 127 | |||
| 128 | Title : bits | ||
| 129 | Usage : $bits = $obj->bits(); | ||
| 130 | $obj->bits($value); | ||
| 131 | Function: | ||
| 132 | Returns : | ||
| 133 | Args : | ||
| 134 | |||
| 135 | |||
| 136 | =cut | ||
| 137 | |||
| 138 | sub bits { | ||
| 139 | return shift->_tag_value('Bits', @_); | ||
| 140 | } | ||
| 141 | |||
| 142 | =head2 frac_identical | ||
| 143 | |||
| 144 | Title : frac_identical | ||
| 145 | Usage : $fracid = $obj->frac_identical(); | ||
| 146 | $obj->frac_identical($value); | ||
| 147 | Function: | ||
| 148 | Returns : | ||
| 149 | Args : | ||
| 150 | |||
| 151 | |||
| 152 | =cut | ||
| 153 | |||
| 154 | sub frac_identical { | ||
| 155 | return shift->_tag_value('FracId', @_); | ||
| 156 | } | ||
| 157 | |||
| 158 | =head2 seqlength | ||
| 159 | |||
| 160 | Title : seqlength | ||
| 161 | Usage : $len = $obj->seqlength(); | ||
| 162 | $obj->seqlength($len); | ||
| 163 | Function: | ||
| 164 | Returns : | ||
| 165 | Args : | ||
| 166 | |||
| 167 | |||
| 168 | =cut | ||
| 169 | |||
| 170 | sub seqlength { | ||
| 171 | return shift->_tag_value('SeqLength', @_); | ||
| 172 | } | ||
| 173 | |||
| 174 | =head2 seqdesc | ||
| 175 | |||
| 176 | Title : seqdesc | ||
| 177 | Usage : $desc = $obj->seqdesc(); | ||
| 178 | $obj->seqdesc($desc); | ||
| 179 | Function: At present this method is a shorthand for | ||
| 180 | $obj->annotation()->description(). | ||
| 181 | |||
| 182 | Note that this is not stored in the tag system and hence will | ||
| 183 | not be included in the return value of gff_string(). | ||
| 184 | Returns : | ||
| 185 | Args : | ||
| 186 | |||
| 187 | |||
| 188 | =cut | ||
| 189 | |||
| 190 | sub seqdesc { | ||
| 191 | my ($self, $value) = @_; | ||
| 192 | |||
| 193 | if( defined $value ) { | ||
| 194 | my $v = FAST::Bio::Annotation::SimpleValue->new(); | ||
| 195 | $v->value($value); | ||
| 196 | $self->annotation->add_Annotation('description',$v); | ||
| 197 | } | ||
| 198 | my ($v) = $self->annotation()->get_Annotations('description'); | ||
| 199 | return defined $v ? $v->value : undef; | ||
| 200 | } | ||
| 201 | |||
| 202 | # | ||
| 203 | # Everything else is just inherited from SeqFeature::Generic. | ||
| 204 | # | ||
| 205 | |||
| 206 | 1; |