2 # BioPerl module for Bio::Tools::Promoterwise
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::Promoterwise - parser for Promoterwise tab format output
20 use Bio::Tools::Promoterwise;
22 my $pw = Bio::Tools::Promoterwise->new(-file=>"out",
25 while (my $fp = $pw->next_result){
26 print "Hit Length: ".$fp->feature1->length."\n";
27 print "Hit Start: ".$fp->feature1->start."\n";
28 print "Hit End: ".$fp->feature1->end."\n";
30 my @first_hsp = $fp->feature1->sub_SeqFeature;
31 my @second_hsp = $fp->feature2->sub_SeqFeature;
32 foreach my $i (0..$#first_hsp){
33 print $first_hsp[$i]->start. " ".$first_hsp[$i]->end." ".
34 $second_hsp[$i]->start. " ".$second_hsp[$i]->end."\n";
40 Promoteriwise is an alignment algorithm that relaxes the constraint
41 that local alignments have to be co-linear. Otherwise it provides a
42 similar model to DBA, which is designed for promoter sequence
43 alignments. Promoterwise is written by Ewan Birney. It is part of
44 the wise2 package available at
45 L<ftp://ftp.ebi.ac.uk/pub/software/unix/wise2/>
47 This module is the parser for the Promoterwise output in tab format.
53 User feedback is an integral part of the evolution of this and other
54 Bioperl modules. Send your comments and suggestions preferably to
55 the Bioperl mailing list. Your participation is much appreciated.
57 bioperl-l@bioperl.org - General discussion
58 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
62 Please direct usage questions or support issues to the mailing list:
64 L<bioperl-l@bioperl.org>
66 rather than to the module maintainer directly. Many experienced and
67 reponsive experts will be able look at the problem and quickly
68 address it. Please include a thorough description of the problem
69 with code and data examples if at all possible.
73 Report bugs to the Bioperl bug tracking system to help us keep track
74 of the bugs and their resolution. Bug reports can be submitted via the
77 http://bugzilla.open-bio.org/
79 =head1 AUTHOR - Shawn Hoon
81 Email shawnh@fugu-sg.org
85 The rest of the documentation details each of the object methods.
86 Internal methods are usually preceded with a _
91 # Let the code begin...
94 package Bio
::Tools
::Promoterwise
;
97 use Bio
::SeqFeature
::FeaturePair
;
98 use Bio
::SeqFeature
::Generic
;
100 use base
qw(Bio::Root::Root Bio::Root::IO);
105 Usage : my $obj = Bio::Tools::Promoterwise->new();
106 Function: Builds a new Bio::Tools::Promoterwise object
107 Returns : L<Bio::Tools::Promoterwise>
108 Args : -fh/-file => $val, # for initing input, see Bio::Root::IO
114 my($class,@args) = @_;
116 my $self = $class->SUPER::new
(@args);
117 $self->_initialize_io(@args);
118 my ($query1,$query2) = $self->_rearrange([qw(QUERY1_SEQ QUERY2_SEQ)],@args);
119 $self->query1_seq($query1) if ($query1);
120 $self->query2_seq($query2) if ($query2);
128 Usage : my $r = $rpt_masker->next_result
129 Function: Get the next result set from parser data
130 Returns : an L<Bio::SeqFeature::FeaturePair>
138 $self->_parse unless $self->_parsed;
139 return $self->_next_result;
145 while (defined($_ = $self->_readline()) ) {
148 push @
{$hash{$array[-1]}}, \
@array;
150 foreach my $key(keys %hash){
151 my $sf1 = Bio
::SeqFeature
::Generic
->new(-primary
=>"conserved_element",
152 -source_tag
=>"promoterwise");
153 $sf1->attach_seq($self->query1_seq) if $self->query1_seq;
154 my $sf2 = Bio
::SeqFeature
::Generic
->new(-primary
=>"conserved_element",
155 -source_tag
=>"promoterwise");
156 $sf2->attach_seq($self->query2_seq) if $self->query2_seq;
157 foreach my $info(@
{$hash{$key}}){
159 my ($score,$id1,$start_1,$end_1, $strand_1,$s1_len,
160 $id2,$start_2,$end_2,$strand_2,$s2_len, $group);
161 if( @
{$info} == 12 ) {
162 ($score,$id1,$start_1,$end_1, $strand_1,$s1_len,
163 $id2,$start_2,$end_2,$strand_2,$s2_len, $group) = @
{$info};
164 } elsif( @
{$info} == 10 ) {
165 ($score,$id1,$start_1,$end_1, $strand_1,
166 $id2,$start_2,$end_2,$s2_len, $group) = @
{$info};
168 $self->throw("unknown promoterwise output, ", scalar @
{$info},
169 " columns, expected 10 or 12\n");
171 if(!$sf1->strand && !$sf2->strand){
172 $sf1->strand($strand_1);
173 $sf2->strand($strand_2);
180 my $sub1 = Bio
::SeqFeature
::Generic
->new(-start
=>$start_1,
184 -primary
=>"conserved_element",
185 -source_tag
=>"promoterwise",
187 $sub1->attach_seq($self->query1_seq) if $self->query1_seq;
189 my $sub2 = Bio
::SeqFeature
::Generic
->new(-start
=>$start_2,
193 -primary
=>"conserved_element",
194 -source_tag
=>"promoterwise",
196 $sub2->attach_seq($self->query2_seq) if $self->query2_seq;
197 $sf1->add_SeqFeature($sub1,'EXPAND');
198 $sf2->add_SeqFeature($sub2,'EXPAND');
201 my $fp = Bio
::SeqFeature
::FeaturePair
->new(-feature1
=>$sf1,
205 $self->_feature_pairs(\
@fp);
213 $self->{'_feature_pairs'} = $fp;
215 return $self->{'_feature_pairs'};
220 return unless (exists($self->{'_feature_pairs'}) && @
{$self->{'_feature_pairs'}});
221 return shift(@
{$self->{'_feature_pairs'}});
224 my ($self,$flag) = @_;
226 $self->{'_flag'} = 1;
228 return $self->{'_flag'};
232 my ($self,$val) = @_;
234 $self->{'query1_seq'} = $val;
236 return $self->{'query1_seq'};
239 my ($self,$val) = @_;
241 $self->{'query2_seq'} = $val;
243 return $self->{'query2_seq'};