| 1 | # | ||||||||||||||||||||||||||||||||||||||||||
| 2 | # BioPerl module for Bio::Tools::EMBOSS::Palindrome | ||||||||||||||||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||||||||||||||||
| 4 | # Please direct questions and support issues to <bioperl-l@bioperl.org> | ||||||||||||||||||||||||||||||||||||||||||
| 5 | # | ||||||||||||||||||||||||||||||||||||||||||
| 6 | # Cared for by Jason Stajich <jason-at-bioperl-dot-org> | ||||||||||||||||||||||||||||||||||||||||||
| 7 | # | ||||||||||||||||||||||||||||||||||||||||||
| 8 | # Copyright Jason Stajich | ||||||||||||||||||||||||||||||||||||||||||
| 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 | Bio::Tools::EMBOSS::Palindrome - parse EMBOSS palindrome output | ||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | # a simple script to turn palindrome output into GFF3 | ||||||||||||||||||||||||||||||||||||||||||
| 21 | use Bio::Tools::EMBOSS::Palindrome; | ||||||||||||||||||||||||||||||||||||||||||
| 22 | use Bio::Tools::GFF; | ||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | my $parser = Bio::Tools::EMBOSS::Palindrome->new(-file => $filename); | ||||||||||||||||||||||||||||||||||||||||||
| 25 | my $out = Bio::Tools::GFF->new(-gff_version => 3, | ||||||||||||||||||||||||||||||||||||||||||
| 26 | -file => ">$filename.gff"); | ||||||||||||||||||||||||||||||||||||||||||
| 27 | while( my $seq = $parser->next_seq ) { | ||||||||||||||||||||||||||||||||||||||||||
| 28 | for my $feat ( $seq->get_SeqFeatures ) { | ||||||||||||||||||||||||||||||||||||||||||
| 29 | $out->write_feature($feat); | ||||||||||||||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | This is a parser for the EMBOSS tool 'palindrome'. It will produce a | ||||||||||||||||||||||||||||||||||||||||||
| 36 | L<Bio::Seq> object for each sequence analyzed. The sequence will be | ||||||||||||||||||||||||||||||||||||||||||
| 37 | empty (but will be of the correct length) and will have attached to it | ||||||||||||||||||||||||||||||||||||||||||
| 38 | L<Bio::SeqFeature::FeaturePair> objects which wil | ||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | =head2 FUTURE WORK | ||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | It may be consolidated into another framework at a later time, but for | ||||||||||||||||||||||||||||||||||||||||||
| 44 | the time being it will stay a separate modules. | ||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | =head1 FEEDBACK | ||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | =head2 Mailing Lists | ||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | User feedback is an integral part of the evolution of this and other | ||||||||||||||||||||||||||||||||||||||||||
| 51 | Bioperl modules. Send your comments and suggestions preferably to | ||||||||||||||||||||||||||||||||||||||||||
| 52 | the Bioperl mailing list. Your participation is much appreciated. | ||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | bioperl-l@bioperl.org - General discussion | ||||||||||||||||||||||||||||||||||||||||||
| 55 | http://bioperl.org/wiki/Mailing_lists - About the mailing lists | ||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | =head2 Support | ||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | Please direct usage questions or support issues to the mailing list: | ||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | I<bioperl-l@bioperl.org> | ||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | rather than to the module maintainer directly. Many experienced and | ||||||||||||||||||||||||||||||||||||||||||
| 64 | reponsive experts will be able look at the problem and quickly | ||||||||||||||||||||||||||||||||||||||||||
| 65 | address it. Please include a thorough description of the problem | ||||||||||||||||||||||||||||||||||||||||||
| 66 | with code and data examples if at all possible. | ||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||
| 68 | =head2 Reporting Bugs | ||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | Report bugs to the Bioperl bug tracking system to help us keep track | ||||||||||||||||||||||||||||||||||||||||||
| 71 | of the bugs and their resolution. Bug reports can be submitted via | ||||||||||||||||||||||||||||||||||||||||||
| 72 | email or the web: | ||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | https://github.com/bioperl/bioperl-live/issues | ||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | =head1 AUTHOR - Jason Stajich | ||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||
| 78 | Email jason-at-bioperl-dot-org | ||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | =head1 APPENDIX | ||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | The rest of the documentation details each of the object methods. | ||||||||||||||||||||||||||||||||||||||||||
| 83 | Internal methods are usually preceded with a _ | ||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||
| 85 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||
| 88 | # Let the code begin... | ||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | package Bio::Tools::EMBOSS::Palindrome; | ||||||||||||||||||||||||||||||||||||||||||
| 92 | 2 | $Bio::Tools::EMBOSS::Palindrome::VERSION = '1.7.8'; | |||||||||||||||||||||||||||||||||||||||||
| 93 | 2 | ▶ | use vars qw($DEFAULT_SOURCETAG); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 94 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||
| 96 | 2 | ▶ | use Bio::SeqFeature::FeaturePair; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | 2 | ▶ | use Bio::SeqFeature::Generic; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||
| 99 | 2 | ▶ | use base qw(Bio::Root::IO); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 100 | 2 | $DEFAULT_SOURCETAG = 'palindrome'; | |||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | =head2 new | ||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | Title : new | ||||||||||||||||||||||||||||||||||||||||||
| 105 | Usage : my $obj = Bio::Tools::EMBOSS::Palindrome->new(); | ||||||||||||||||||||||||||||||||||||||||||
| 106 | Function: Builds a new Bio::Tools::EMBOSS::Palindrome object | ||||||||||||||||||||||||||||||||||||||||||
| 107 | Returns : an instance of Bio::Tools::EMBOSS::Palindrome | ||||||||||||||||||||||||||||||||||||||||||
| 108 | Args : -file/-fh => a filename or filehandle for | ||||||||||||||||||||||||||||||||||||||||||
| 109 | initializing the parser | ||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||
| 111 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||
| 113 | =head2 next_seq | ||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||
| 115 | Title : next_seq | ||||||||||||||||||||||||||||||||||||||||||
| 116 | Usage : my $seq = $parser->next_seq; | ||||||||||||||||||||||||||||||||||||||||||
| 117 | Function: Get the next feature set from the | ||||||||||||||||||||||||||||||||||||||||||
| 118 | Returns : L<Bio::SeqI> object | ||||||||||||||||||||||||||||||||||||||||||
| 119 | Args : none | ||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||
| 122 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||
| 124 | 1 | ▶ | sub next_seq { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
next_seq: called CC=17 SCAR=28.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 125 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 126 | 1 | my (%searching, $seq,$state); | |||||||||||||||||||||||||||||||||||||||||
| 127 | 1 | my $source = $self->source_tag; | |||||||||||||||||||||||||||||||||||||||||
| 128 | 1 | $state = 0; | |||||||||||||||||||||||||||||||||||||||||
| 129 | 1 | ▶ | while(defined($_ = $self->_readline)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 130 | 38 | ▶ | if( /^\s+$/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 9 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 131 | 6 | next; | |||||||||||||||||||||||||||||||||||||||||
| 132 | } elsif( /^Palindromes\s+of\s*:\s+(\S+)/o ) { | ||||||||||||||||||||||||||||||||||||||||||
| 133 | 1 | $state = 0; | |||||||||||||||||||||||||||||||||||||||||
| 134 | 1 | ▶ | if( $seq ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | $self->_pushback($_); | |||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | return $seq; | |||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||
| 138 | 1 | $seq = Bio::Seq->new(-display_id => $1); | |||||||||||||||||||||||||||||||||||||||||
| 139 | # now get ready to store for the next record | ||||||||||||||||||||||||||||||||||||||||||
| 140 | 1 | $searching{'-seq_id'} = $1; | |||||||||||||||||||||||||||||||||||||||||
| 141 | } elsif( /^Sequence\s+length\s+is\s*:\s+(\d+)/o ) { | ||||||||||||||||||||||||||||||||||||||||||
| 142 | 1 | $seq->length($1); | |||||||||||||||||||||||||||||||||||||||||
| 143 | 1 | $searching{'-tag'}->{'seqlength'} = $1; | |||||||||||||||||||||||||||||||||||||||||
| 144 | } elsif( /^(Start|End)\s+at\s+position\s*:\s+(\d+)/ ) { | ||||||||||||||||||||||||||||||||||||||||||
| 145 | 2 | $searching{'-tag'}->{lc($1)} = $2; | |||||||||||||||||||||||||||||||||||||||||
| 146 | } elsif( m/^(Maximum|Minimum)\s+length\s+of\s+Palindromes\s+ | ||||||||||||||||||||||||||||||||||||||||||
| 147 | is\s*:\s+(\d+)/ox) { | ||||||||||||||||||||||||||||||||||||||||||
| 148 | 2 | $searching{'-tag'}->{lc($1).'_length'} = $2; | |||||||||||||||||||||||||||||||||||||||||
| 149 | } elsif( /^(Maximum\s+gap)\s+between\s+elements\s+is\s*:\s+(\d+)/o ) { | ||||||||||||||||||||||||||||||||||||||||||
| 150 | 1 | $searching{'-tag'}->{lc($1)} = $2; | |||||||||||||||||||||||||||||||||||||||||
| 151 | } elsif( m/^Number\s+of\s+mismatches\s+allowed\s+ | ||||||||||||||||||||||||||||||||||||||||||
| 152 | in\s+Palindrome\s*:\s+(\d+)/ox ) { | ||||||||||||||||||||||||||||||||||||||||||
| 153 | 1 | $searching{'-tag'}->{'allowed_mismatches'} = $1; | |||||||||||||||||||||||||||||||||||||||||
| 154 | } elsif( /^Palindromes:/o ) { | ||||||||||||||||||||||||||||||||||||||||||
| 155 | 1 | $state = 1; | |||||||||||||||||||||||||||||||||||||||||
| 156 | } elsif( $state == 1 ) { | ||||||||||||||||||||||||||||||||||||||||||
| 157 | 23 | my $feature = Bio::SeqFeature::FeaturePair->new | |||||||||||||||||||||||||||||||||||||||||
| 158 | (-primary_tag => 'similarity', | ||||||||||||||||||||||||||||||||||||||||||
| 159 | -source_tag => $source); | ||||||||||||||||||||||||||||||||||||||||||
| 160 | 23 | ▶ | for(my $i = 0; $i < 3; $i++ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 161 | 69 | ▶ | if ($i != 1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 162 | 46 | ▶ | if( /^(\d+)\s+(\S+)\s+(\d+)/o ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 163 | 46 | my ($start,$match,$end) = ($1,$2,$3); | |||||||||||||||||||||||||||||||||||||||||
| 164 | 46 | ▶ | my $type = $i == 0 ? 'feature1' : 'feature2'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 165 | 46 | ($start,$end) = sort { $a <=> $b } ($start,$end); | |||||||||||||||||||||||||||||||||||||||||
| 166 | 46 | ▶ | $feature->$type( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 167 | Bio::SeqFeature::Generic->new | ||||||||||||||||||||||||||||||||||||||||||
| 168 | (%searching, | ||||||||||||||||||||||||||||||||||||||||||
| 169 | -start => $start, | ||||||||||||||||||||||||||||||||||||||||||
| 170 | -end => $end, | ||||||||||||||||||||||||||||||||||||||||||
| 171 | -strand => $i == 0 ? 1 : -1, | ||||||||||||||||||||||||||||||||||||||||||
| 172 | -primary_tag => 'similarity', | ||||||||||||||||||||||||||||||||||||||||||
| 173 | -source_tag => $source) | ||||||||||||||||||||||||||||||||||||||||||
| 174 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 175 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | chomp; | |||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | warn("Out of sync, line did not match:'$_'\n"); | |||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||
| 181 | 69 | $_ = $self->_readline; | |||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||
| 183 | 23 | $seq->add_SeqFeature($feature); | |||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||
| 186 | 1 | return $seq; | |||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||
| 189 | =head2 source_tag | ||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||
| 191 | Title : source_tag | ||||||||||||||||||||||||||||||||||||||||||
| 192 | Usage : $obj->source_tag($newval) | ||||||||||||||||||||||||||||||||||||||||||
| 193 | Function: Get/Set Source Tag ('palindrome') by default | ||||||||||||||||||||||||||||||||||||||||||
| 194 | Returns : value of source_tag (a scalar) | ||||||||||||||||||||||||||||||||||||||||||
| 195 | Args : on set, new value (a scalar or undef, optional) | ||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||
| 198 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||
| 200 | 1 | ▶ | sub source_tag{ | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
source_tag: called CC=3 SCAR=12.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 201 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||
| 203 | 1 | ▶ | return $self->{'source_tag'} = shift if @_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 204 | 1 | ▶ | return $self->{'source_tag'} || $DEFAULT_SOURCETAG; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->{'source_tag'} || $Bio::Tools::EMBOSS::Palindrome::DEFAULT_SOURCETAG
MC/DC0%0/2
$self->{'source_tag'} || $Bio::Tools::EMBOSS::Palindrome::DEFAULT_SOURCETAG
$self->{'source_tag'}
$Bio::Tools::EMBOSS::Palindrome::DEFAULT_SOURCETAG
Truth table33%1/3
A || B
A= $self->{'source_tag'}B= $Bio::Tools::EMBOSS::Palindrome::DEFAULT_SOURCETAG
| |||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||
| 207 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||