2 # BioPerl module for Bio::Tools::FootPrinter
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
6 # Cared for by Shawn Hoon <shawnh@fugu-sg.org>
10 # You may distribute this module under the same terms as perl itself
12 # POD documentation - main docs before the code
16 Bio::Tools::FootPrinter - write sequence features in FootPrinter format
20 use Bio::Tools::FootPrinter;
22 my $tool = Bio::Tools::FootPrinter->new(-file=>"footprinter.out");
24 while (my $result = $tool->next_feature){
25 foreach my $feat($result->sub_SeqFeature){
26 print $result->seq_id."\t".$feat->start."\t".$feat->end."\t".$feat->seq->seq."\n";
32 This module writes sequence features in FootPrinter format.
33 See L<http://bio.cs.washington.edu/software.html> for more details.
39 User feedback is an integral part of the evolution of this and other
40 Bioperl modules. Send your comments and suggestions preferably to
41 the Bioperl mailing list. Your participation is much appreciated.
43 bioperl-l@bioperl.org - General discussion
44 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
48 Please direct usage questions or support issues to the mailing list:
50 I<bioperl-l@bioperl.org>
52 rather than to the module maintainer directly. Many experienced and
53 reponsive experts will be able look at the problem and quickly
54 address it. Please include a thorough description of the problem
55 with code and data examples if at all possible.
59 Report bugs to the Bioperl bug tracking system to help us keep track
60 of the bugs and their resolution. Bug reports can be submitted via the
63 http://bugzilla.open-bio.org/
65 =head1 AUTHOR - Shawn Hoon
67 Email shawnh@fugu-sg.org
71 The rest of the documentation details each of the object methods.
72 Internal methods are usually preceded with a _
77 # Let the code begin...
80 package Bio
::Tools
::FootPrinter
;
83 use Bio
::SeqFeature
::Generic
;
86 use base
qw(Bio::Root::Root Bio::Root::IO);
91 Usage : my $obj = Bio::Tools::FootPrinter->new();
92 Function: Builds a new Bio::Tools::FootPrinter object
93 Returns : Bio::Tools::FootPrinter
94 Args : -fh/-file => $val, # for initing input, see Bio::Root::IO
99 my($class,@args) = @_;
101 my $self = $class->SUPER::new
(@args);
102 $self->_initialize_io(@args);
110 Usage : my $r = $footprint->next_feature
111 Function: Get the next feature from parser data
112 Returns : L<Bio::SeqFeature::Generic>
119 $self->_parse_predictions() unless $self->_predictions_parsed();
120 return shift @
{$self->{'_feature'}};
127 Usage : $footprint->_add_feature($feat)
128 Function: Add feature to array
135 my ($self,$feat) = @_;
137 push @
{$self->{'_feature'}},$feat;
141 =head2 _parse_predictions
143 Title : _parse_predictions
144 Usage : my $r = $footprint->_parse_predictions
145 Function: do the parsing
151 sub _parse_predictions
{
154 my ($seq,$second,$third,$name);
155 while ($_ = $self->_readline) {
157 my @array = split("\n",$_);
160 shift(@array); shift(@array);
165 my $feat = $self->_parse($name,$seq,$second,$third);
166 $self->_add_feature($feat);
168 $name = shift @array;
181 my $feat = $self->_parse($name,$seq,$second,$third);
182 $self->_add_feature($feat);
184 $self->_predictions_parsed(1);
187 =head2 _predictions_parsed
189 Title : _predictions_parsed
190 Usage : $footprint->_predictions_parsed(1)
191 Function: Get/Set for whether predictions parsed
197 sub _predictions_parsed
{
198 my ($self,$val) = @_;
200 $self->{'_predictions_parsed'} = $val;
202 return $self->{'_predictions_parsed'};
209 Usage : $footprint->_parse($name,$seq,$pattern)
210 Function: do the actual parsing
211 Returns : L<Bio::SeqFeature::Generic>
217 my ($self,$name,$seq,$score,$pattern) = @_;
218 my @char = split('',$pattern);
219 my @score = split('',$score);
221 my ($prev,$word,@words,@word_scores,$word_score);
224 for my $c ( @char ) {
228 defined $score[$i] &&
229 ($score[$i] =~ /\d/) && ($word_score += $score[$i]);
230 } elsif ($c eq $prev){
233 defined $score[$i] &&
234 ($score[$i] =~ /\d/) && ($word_score += $score[$i]);
236 # remove words with only \s
240 push @word_scores, ($word_score/length($word));
245 defined $score[$i] &&
246 ($score[$i] =~ /\d/) && ($word_score += $score[$i]);
255 my $feat = Bio
::SeqFeature
::Generic
->new(-seq_id
=>$name);
260 my $index = index($pattern,$w,$offset);
261 $offset = $index + length($w);
262 my $subfeat = Bio
::SeqFeature
::Generic
->new
263 ( -seq_id
=>"$name-motif".$count++,
265 -end
=> $index+length($w),
266 -source
=>"FootPrinter",
267 -score
=> $word_scores[$i]
269 # ugh - not sure the sub_SeqFeature situation will
270 # be around forever- things should probably be
271 # grouped by a 'group' tag instead ala GFF3
272 # perhaps when Lincoln's API changes are
273 # made to SeqFeatures this will get changed
274 $feat->add_sub_SeqFeature($subfeat,'EXPAND');
278 my $priseq = Bio
::PrimarySeq
->new(-id
=>$name,-seq
=>$seq);
279 $feat->attach_seq($priseq);