1
# $Id: Palindrome.pm,v 1.2 2003/10/25 15:00:58 heikki Exp $
3
# BioPerl module for Bio::Tools::EMBOSS::Palindrome
5
# Cared for by Jason Stajich <jason-at-bioperl-dot-org>
7
# Copyright Jason Stajich
9
# You may distribute this module under the same terms as perl itself
11
# POD documentation - main docs before the code
15
Bio::Tools::EMBOSS::Palindrome - parse EMBOSS palindrome output
19
# a simple script to turn palindrome output into GFF3
20
use Bio::Tools::EMBOSS::Palindrome;
23
my $parser = new Bio::Tools::EMBOSS::Palindrome(-file => $filename);
24
my $out = new Bio::Tools::GFF(-gff_version => 3,
25
-file => ">$filename.gff");
26
while( my $seq = $parser->next_seq ) {
27
for my $feat ( $seq->get_SeqFeatures ) {
28
$out->write_feature($feat);
34
This is a parser for the EMBOSS tool 'palindrome'. It will produce a
35
L<Bio::Seq> object for each sequence analyzed. The sequence will be
36
empty (but will be of the correct length) and will have attached to it
37
L<Bio::SeqFeature::FeaturePair> objects which wil
42
It may be consolidated into another framework at a later time, but for
43
the time being it will stay a separate modules.
49
User feedback is an integral part of the evolution of this and other
50
Bioperl modules. Send your comments and suggestions preferably to
51
the Bioperl mailing list. Your participation is much appreciated.
53
bioperl-l@bioperl.org - General discussion
54
http://bioperl.org/MailList.shtml - About the mailing lists
58
Report bugs to the Bioperl bug tracking system to help us keep track
59
of the bugs and their resolution. Bug reports can be submitted via
62
http://bugzilla.bioperl.org/
64
=head1 AUTHOR - Jason Stajich
66
Email jason-at-bioperl-dot-org
68
Describe contact details here
72
Additional contributors names and emails here
76
The rest of the documentation details each of the object methods.
77
Internal methods are usually preceded with a _
82
# Let the code begin...
85
package Bio::Tools::EMBOSS::Palindrome;
86
use vars qw(@ISA $DEFAULT_SOURCETAG);
90
use Bio::SeqFeature::FeaturePair;
91
use Bio::SeqFeature::Generic;
93
@ISA = qw(Bio::Root::IO);
94
$DEFAULT_SOURCETAG = 'palindrome';
99
Usage : my $obj = new Bio::Tools::EMBOSS::Palindrome();
100
Function: Builds a new Bio::Tools::EMBOSS::Palindrome object
101
Returns : an instance of Bio::Tools::EMBOSS::Palindrome
102
Args : -file/-fh => a filename or filehandle for
103
initializing the parser
110
Usage : my $seq = $parser->next_seq;
111
Function: Get the next feature set from the
112
Returns : L<Bio::SeqI> object
120
my (%searching, $seq,$state);
121
my $source = $self->source_tag;
123
while(defined($_ = $self->_readline)) {
126
} elsif( /^Palindromes\s+of\s*:\s+(\S+)/o ) {
129
$self->_pushback($_);
132
$seq = new Bio::Seq(-display_id => $1);
133
# now get ready to store for the next record
134
$searching{'-seq_id'} = $1;
135
} elsif( /^Sequence\s+length\s+is\s*:\s+(\d+)/o ) {
137
$searching{'-tag'}->{'seqlength'} = $1;
138
} elsif( /^(Start|End)\s+at\s+position\s*:\s+(\d+)/ ) {
139
$searching{'-tag'}->{lc($1)} = $2;
140
} elsif( m/^(Maximum|Minimum)\s+length\s+of\s+Palindromes\s+
142
$searching{'-tag'}->{lc($1).'_length'} = $2;
143
} elsif( /^(Maximum\s+gap)\s+between\s+elements\s+is\s*:\s+(\d+)/o ) {
144
$searching{'-tag'}->{lc($1)} = $2;
145
} elsif( m/^Number\s+of\s+mismatches\s+allowed\s+
146
in\s+Palindrome\s*:\s+(\d+)/ox ) {
147
$searching{'-tag'}->{'allowed_mismatches'} = $1;
148
} elsif( /^Palindromes:/o ) {
150
} elsif( $state == 1 ) {
151
my $feature = new Bio::SeqFeature::FeaturePair
152
(-primary_tag => 'similarity',
153
-source_tag => $source);
154
for(my $i = 0; $i < 3; $i++ ) {
156
if( /^(\d+)\s+(\S+)\s+(\d+)/o ) {
157
my ($start,$match,$end) = ($1,$2,$3);
158
my $type = $i == 0 ? 'feature1' : 'feature2';
159
($start,$end) = sort { $a <=> $b } ($start,$end);
161
Bio::SeqFeature::Generic->new
165
-strand => $i == 0 ? 1 : -1,
166
-primary_tag => 'similarity',
167
-source_tag => $source)
171
warn("Out of sync, line did not match:'$_'\n");
175
$_ = $self->_readline;
177
$seq->add_SeqFeature($feature);
186
Usage : $obj->source_tag($newval)
187
Function: Get/Set Source Tag ('palindrome') by default
188
Returns : value of source_tag (a scalar)
189
Args : on set, new value (a scalar or undef, optional)
197
return $self->{'source_tag'} = shift if @_;
198
return $self->{'source_tag'} || $DEFAULT_SOURCETAG;