2 # BioPerl module for Bio::Tools::EMBOSS::Palindrome
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
6 # Cared for by Jason Stajich <jason-at-bioperl-dot-org>
8 # Copyright Jason Stajich
10 # You may distribute this module under the same terms as perl itself
12 # POD documentation - main docs before the code
16 Bio::Tools::EMBOSS::Palindrome - parse EMBOSS palindrome output
20 # a simple script to turn palindrome output into GFF3
21 use Bio::Tools::EMBOSS::Palindrome;
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);
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
43 It may be consolidated into another framework at a later time, but for
44 the time being it will stay a separate modules.
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.
54 bioperl-l@bioperl.org - General discussion
55 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
59 Please direct usage questions or support issues to the mailing list:
61 I<bioperl-l@bioperl.org>
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.
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
74 https://github.com/bioperl/bioperl-live/issues
76 =head1 AUTHOR - Jason Stajich
78 Email jason-at-bioperl-dot-org
82 The rest of the documentation details each of the object methods.
83 Internal methods are usually preceded with a _
88 # Let the code begin...
91 package Bio
::Tools
::EMBOSS
::Palindrome
;
92 use vars
qw($DEFAULT_SOURCETAG);
95 use Bio::SeqFeature::FeaturePair;
96 use Bio::SeqFeature::Generic;
98 use base qw(Bio::Root::IO);
99 $DEFAULT_SOURCETAG = 'palindrome';
104 Usage : my $obj = Bio::Tools::EMBOSS::Palindrome->new();
105 Function: Builds a new Bio::Tools::EMBOSS::Palindrome object
106 Returns : an instance of Bio::Tools::EMBOSS::Palindrome
107 Args : -file/-fh => a filename or filehandle for
108 initializing the parser
115 Usage : my $seq = $parser->next_seq;
116 Function: Get the next feature set from the
117 Returns : L<Bio::SeqI> object
125 my (%searching, $seq,$state);
126 my $source = $self->source_tag;
128 while(defined($_ = $self->_readline)) {
131 } elsif( /^Palindromes\s+of\s*:\s+(\S+)/o ) {
134 $self->_pushback($_);
137 $seq = Bio
::Seq
->new(-display_id
=> $1);
138 # now get ready to store for the next record
139 $searching{'-seq_id'} = $1;
140 } elsif( /^Sequence\s+length\s+is\s*:\s+(\d+)/o ) {
142 $searching{'-tag'}->{'seqlength'} = $1;
143 } elsif( /^(Start|End)\s+at\s+position\s*:\s+(\d+)/ ) {
144 $searching{'-tag'}->{lc($1)} = $2;
145 } elsif( m
/^(Maximum
|Minimum
)\s
+length\s
+of\s
+Palindromes\s
+
147 $searching{'-tag'}->{lc($1).'_length'} = $2;
148 } elsif( /^(Maximum\s+gap)\s+between\s+elements\s+is\s*:\s+(\d+)/o ) {
149 $searching{'-tag'}->{lc($1)} = $2;
150 } elsif( m
/^Number\s
+of\s
+mismatches\s
+allowed\s
+
151 in\s
+Palindrome\s
*:\s
+(\d
+)/ox
) {
152 $searching{'-tag'}->{'allowed_mismatches'} = $1;
153 } elsif( /^Palindromes:/o ) {
155 } elsif( $state == 1 ) {
156 my $feature = Bio
::SeqFeature
::FeaturePair
->new
157 (-primary_tag
=> 'similarity',
158 -source_tag
=> $source);
159 for(my $i = 0; $i < 3; $i++ ) {
161 if( /^(\d+)\s+(\S+)\s+(\d+)/o ) {
162 my ($start,$match,$end) = ($1,$2,$3);
163 my $type = $i == 0 ?
'feature1' : 'feature2';
164 ($start,$end) = sort { $a <=> $b } ($start,$end);
166 Bio
::SeqFeature
::Generic
->new
170 -strand
=> $i == 0 ?
1 : -1,
171 -primary_tag
=> 'similarity',
172 -source_tag
=> $source)
176 warn("Out of sync, line did not match:'$_'\n");
180 $_ = $self->_readline;
182 $seq->add_SeqFeature($feature);
191 Usage : $obj->source_tag($newval)
192 Function: Get/Set Source Tag ('palindrome') by default
193 Returns : value of source_tag (a scalar)
194 Args : on set, new value (a scalar or undef, optional)
202 return $self->{'source_tag'} = shift if @_;
203 return $self->{'source_tag'} || $DEFAULT_SOURCETAG;