| 1 | # BioPerl module for Bio::Tools::Promoterwise | ||||||||||||||||||||||||||||
| 2 | # | ||||||||||||||||||||||||||||
| 3 | # Please direct questions and support issues to <bioperl-l@bioperl.org> | ||||||||||||||||||||||||||||
| 4 | # | ||||||||||||||||||||||||||||
| 5 | # Cared for by Shawn Hoon <shawnh@fugu-sg.org> | ||||||||||||||||||||||||||||
| 6 | # | ||||||||||||||||||||||||||||
| 7 | # Copyright Shawn Hoon | ||||||||||||||||||||||||||||
| 8 | # | ||||||||||||||||||||||||||||
| 9 | # You may distribute this module under the same terms as perl itself | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | # POD documentation - main docs before the code | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | =head1 NAME | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | Bio::Tools::Promoterwise - parser for Promoterwise tab format output | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | use Bio::Tools::Promoterwise; | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | my $pw = Bio::Tools::Promoterwise->new(-file=>"out", | ||||||||||||||||||||||||||||
| 22 | -query1_seq=>$seq1, | ||||||||||||||||||||||||||||
| 23 | -query2_seq=>$seq2); | ||||||||||||||||||||||||||||
| 24 | while (my $fp = $pw->next_result){ | ||||||||||||||||||||||||||||
| 25 | print "Hit Length: ".$fp->feature1->length."\n"; | ||||||||||||||||||||||||||||
| 26 | print "Hit Start: ".$fp->feature1->start."\n"; | ||||||||||||||||||||||||||||
| 27 | print "Hit End: ".$fp->feature1->end."\n"; | ||||||||||||||||||||||||||||
| 28 | print "Hsps: \n"; | ||||||||||||||||||||||||||||
| 29 | my @first_hsp = $fp->feature1->sub_SeqFeature; | ||||||||||||||||||||||||||||
| 30 | my @second_hsp = $fp->feature2->sub_SeqFeature; | ||||||||||||||||||||||||||||
| 31 | foreach my $i (0..$#first_hsp){ | ||||||||||||||||||||||||||||
| 32 | print $first_hsp[$i]->start. " ".$first_hsp[$i]->end." ". | ||||||||||||||||||||||||||||
| 33 | $second_hsp[$i]->start. " ".$second_hsp[$i]->end."\n"; | ||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | Promoteriwise is an alignment algorithm that relaxes the constraint | ||||||||||||||||||||||||||||
| 40 | that local alignments have to be co-linear. Otherwise it provides a | ||||||||||||||||||||||||||||
| 41 | similar model to DBA, which is designed for promoter sequence | ||||||||||||||||||||||||||||
| 42 | alignments. Promoterwise is written by Ewan Birney. It is part of | ||||||||||||||||||||||||||||
| 43 | the wise2 package available at | ||||||||||||||||||||||||||||
| 44 | L<ftp://ftp.ebi.ac.uk/pub/software/unix/wise2/> | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | This module is the parser for the Promoterwise output in tab format. | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | =head1 FEEDBACK | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | =head2 Mailing Lists | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | User feedback is an integral part of the evolution of this and other | ||||||||||||||||||||||||||||
| 53 | Bioperl modules. Send your comments and suggestions preferably to | ||||||||||||||||||||||||||||
| 54 | the Bioperl mailing list. Your participation is much appreciated. | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | bioperl-l@bioperl.org - General discussion | ||||||||||||||||||||||||||||
| 57 | http://bioperl.org/wiki/Mailing_lists - About the mailing lists | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | =head2 Support | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | Please direct usage questions or support issues to the mailing list: | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | I<bioperl-l@bioperl.org> | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | rather than to the module maintainer directly. Many experienced and | ||||||||||||||||||||||||||||
| 66 | reponsive experts will be able look at the problem and quickly | ||||||||||||||||||||||||||||
| 67 | address it. Please include a thorough description of the problem | ||||||||||||||||||||||||||||
| 68 | with code and data examples if at all possible. | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | =head2 Reporting Bugs | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | Report bugs to the Bioperl bug tracking system to help us keep track | ||||||||||||||||||||||||||||
| 73 | of the bugs and their resolution. Bug reports can be submitted via the | ||||||||||||||||||||||||||||
| 74 | web: | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | https://github.com/bioperl/bioperl-live/issues | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | =head1 AUTHOR - Shawn Hoon | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | Email shawnh@fugu-sg.org | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | =head1 APPENDIX | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | The rest of the documentation details each of the object methods. | ||||||||||||||||||||||||||||
| 85 | Internal methods are usually preceded with a _ | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | =cut | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | # Let the code begin... | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | package Bio::Tools::Promoterwise; | ||||||||||||||||||||||||||||
| 94 | 2 | $Bio::Tools::Promoterwise::VERSION = '1.7.8'; | |||||||||||||||||||||||||||
| 95 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | 2 | ▶ | use Bio::SeqFeature::FeaturePair; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 98 | 2 | ▶ | use Bio::SeqFeature::Generic; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | 2 | ▶ | use base qw(Bio::Root::Root Bio::Root::IO); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | =head2 new | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | Title : new | ||||||||||||||||||||||||||||
| 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 | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | =cut | ||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | 1 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||||||||||||||||||||
| 114 | 1 | my($class,@args) = @_; | |||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | 1 | my $self = $class->SUPER::new(@args); | |||||||||||||||||||||||||||
| 117 | 1 | $self->_initialize_io(@args); | |||||||||||||||||||||||||||
| 118 | 1 | my ($query1,$query2) = $self->_rearrange([qw(QUERY1_SEQ QUERY2_SEQ)],@args); | |||||||||||||||||||||||||||
| 119 | 1 | ▶ | $self->query1_seq($query1) if ($query1); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 120 | 1 | ▶ | $self->query2_seq($query2) if ($query2); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | 1 | return $self; | |||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | =head2 next_result | ||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | Title : next_result | ||||||||||||||||||||||||||||
| 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> | ||||||||||||||||||||||||||||
| 131 | Args : none | ||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | =cut | ||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | 2 | ▶ | sub next_result { | ||||||||||||||||||||||||||
|
Subroutine
next_result: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 137 | 2 | my ($self) = @_; | |||||||||||||||||||||||||||
| 138 | 2 | ▶ | $self->_parse unless $self->_parsed; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 139 | 2 | return $self->_next_result; | |||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | 1 | ▶ | sub _parse{ | ||||||||||||||||||||||||||
|
Subroutine
_parse: called CC=12 SCAR=25.5
| |||||||||||||||||||||||||||||
| 143 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||
| 144 | 1 | my (%hash,@fp); | |||||||||||||||||||||||||||
| 145 | 1 | ▶ | while (defined($_ = $self->_readline()) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 146 | 11 | chomp; | |||||||||||||||||||||||||||
| 147 | 11 | my @array = split; | |||||||||||||||||||||||||||
| 148 | 11 | push @{$hash{$array[-1]}}, \@array; | |||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||
| 150 | 1 | foreach my $key(keys %hash){ | |||||||||||||||||||||||||||
| 151 | 1 | my $sf1 = Bio::SeqFeature::Generic->new(-primary=>"conserved_element", | |||||||||||||||||||||||||||
| 152 | -source_tag=>"promoterwise"); | ||||||||||||||||||||||||||||
| 153 | 1 | ▶ | $sf1->attach_seq($self->query1_seq) if $self->query1_seq; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 154 | 1 | my $sf2 = Bio::SeqFeature::Generic->new(-primary=>"conserved_element", | |||||||||||||||||||||||||||
| 155 | -source_tag=>"promoterwise"); | ||||||||||||||||||||||||||||
| 156 | 1 | ▶ | $sf2->attach_seq($self->query2_seq) if $self->query2_seq; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 157 | 1 | foreach my $info(@{$hash{$key}}){ | |||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | 11 | my ($score,$id1,$start_1,$end_1, $strand_1,$s1_len, | |||||||||||||||||||||||||||
| 160 | $id2,$start_2,$end_2,$strand_2,$s2_len, $group); | ||||||||||||||||||||||||||||
| 161 | 11 | ▶ | if( @{$info} == 12 ) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 162 | ($score,$id1,$start_1,$end_1, $strand_1,$s1_len, | ||||||||||||||||||||||||||||
| 163 | 0 | $id2,$start_2,$end_2,$strand_2,$s2_len, $group) = @{$info}; | |||||||||||||||||||||||||||
| 164 | 11 | } elsif( @{$info} == 10 ) { | |||||||||||||||||||||||||||
| 165 | ($score,$id1,$start_1,$end_1, $strand_1, | ||||||||||||||||||||||||||||
| 166 | 11 | $id2,$start_2,$end_2,$s2_len, $group) = @{$info}; | |||||||||||||||||||||||||||
| 167 | } else { | ||||||||||||||||||||||||||||
| 168 | 0 | $self->throw("unknown promoterwise output, ", scalar @{$info}, | |||||||||||||||||||||||||||
| 169 | " columns, expected 10 or 12\n"); | ||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||
| 171 | 11 | ▶ | if(!$sf1->strand && !$sf2->strand){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$sf1->strand or $sf2->strand
MC/DC50%1/2
$sf1->strand or $sf2->strand
$sf1->strand
$sf2->strand
Truth table66%2/3
A or B
A= $sf1->strandB= $sf2->strand
| |||||||||||||||||||||||||||||
| 172 | 1 | $sf1->strand($strand_1); | |||||||||||||||||||||||||||
| 173 | 1 | $sf2->strand($strand_2); | |||||||||||||||||||||||||||
| 174 | 1 | $sf1->seq_id($id1); | |||||||||||||||||||||||||||
| 175 | 1 | $sf2->seq_id($id2); | |||||||||||||||||||||||||||
| 176 | 1 | $sf1->score($score); | |||||||||||||||||||||||||||
| 177 | 1 | $sf2->score($score); | |||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||
| 180 | 11 | my $sub1 = Bio::SeqFeature::Generic->new(-start=>$start_1, | |||||||||||||||||||||||||||
| 181 | -seq_id=>$id1, | ||||||||||||||||||||||||||||
| 182 | -end =>$end_1, | ||||||||||||||||||||||||||||
| 183 | -strand=>$strand_1, | ||||||||||||||||||||||||||||
| 184 | -primary=>"conserved_element", | ||||||||||||||||||||||||||||
| 185 | -source_tag=>"promoterwise", | ||||||||||||||||||||||||||||
| 186 | -score=>$score); | ||||||||||||||||||||||||||||
| 187 | 11 | ▶ | $sub1->attach_seq($self->query1_seq) if $self->query1_seq; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||
| 189 | 11 | my $sub2 = Bio::SeqFeature::Generic->new(-start=>$start_2, | |||||||||||||||||||||||||||
| 190 | -seq_id=>$id2, | ||||||||||||||||||||||||||||
| 191 | -end =>$end_2, | ||||||||||||||||||||||||||||
| 192 | -strand=>$strand_2, | ||||||||||||||||||||||||||||
| 193 | -primary=>"conserved_element", | ||||||||||||||||||||||||||||
| 194 | -source_tag=>"promoterwise", | ||||||||||||||||||||||||||||
| 195 | -score=>$score); | ||||||||||||||||||||||||||||
| 196 | 11 | ▶ | $sub2->attach_seq($self->query2_seq) if $self->query2_seq; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 197 | 11 | $sf1->add_SeqFeature($sub1,'EXPAND'); | |||||||||||||||||||||||||||
| 198 | 11 | $sf2->add_SeqFeature($sub2,'EXPAND'); | |||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||
| 201 | 1 | my $fp = Bio::SeqFeature::FeaturePair->new(-feature1=>$sf1, | |||||||||||||||||||||||||||
| 202 | -feature2=>$sf2); | ||||||||||||||||||||||||||||
| 203 | 1 | push @fp, $fp; | |||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||
| 205 | 1 | $self->_feature_pairs(\@fp); | |||||||||||||||||||||||||||
| 206 | 1 | $self->_parsed(1); | |||||||||||||||||||||||||||
| 207 | 1 | return; | |||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||
| 210 | 1 | ▶ | sub _feature_pairs { | ||||||||||||||||||||||||||
|
Subroutine
_feature_pairs: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||
| 211 | 1 | my ($self,$fp) = @_; | |||||||||||||||||||||||||||
| 212 | 1 | ▶ | if($fp){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 213 | 1 | $self->{'_feature_pairs'} = $fp; | |||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||
| 215 | 1 | return $self->{'_feature_pairs'}; | |||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||
| 218 | 2 | ▶ | sub _next_result { | ||||||||||||||||||||||||||
|
Subroutine
_next_result: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 219 | 2 | my ($self) = @_; | |||||||||||||||||||||||||||
| 220 | 2 | ▶ | return unless (exists($self->{'_feature_pairs'}) && @{$self->{'_feature_pairs'}}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
exists $self->{"_feature_pairs"} and @{$self->{"_feature_pairs"};}
MC/DC50%1/2
exists $self->{"_feature_pairs"} and @{$self->{"_feature_pairs"};}
exists $self->{"_feature_pairs"}
@{$self->{"_feature_pairs"};}
Truth table66%2/3
A and B
A= exists $self->{"_feature_pairs"}B= @{$self->{"_feature_pairs"};}
| |||||||||||||||||||||||||||||
| 221 | 1 | return shift(@{$self->{'_feature_pairs'}}); | |||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||
| 223 | 3 | ▶ | sub _parsed { | ||||||||||||||||||||||||||
|
Subroutine
_parsed: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 224 | 3 | my ($self,$flag) = @_; | |||||||||||||||||||||||||||
| 225 | 3 | ▶ | if($flag){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 226 | 1 | $self->{'_flag'} = 1; | |||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||
| 228 | 3 | return $self->{'_flag'}; | |||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||
| 231 | 12 | ▶ | sub query1_seq { | ||||||||||||||||||||||||||
|
Subroutine
query1_seq: called CC=2 SCAR=7.6
Pod
undocumented
| |||||||||||||||||||||||||||||
| 232 | 12 | my ($self,$val) = @_; | |||||||||||||||||||||||||||
| 233 | 12 | ▶ | if($val){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 234 | 0 | $self->{'query1_seq'} = $val; | |||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||
| 236 | 12 | return $self->{'query1_seq'}; | |||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||
| 238 | 12 | ▶ | sub query2_seq { | ||||||||||||||||||||||||||
|
Subroutine
query2_seq: called CC=2 SCAR=7.6
Pod
undocumented
| |||||||||||||||||||||||||||||
| 239 | 12 | my ($self,$val) = @_; | |||||||||||||||||||||||||||
| 240 | 12 | ▶ | if($val){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 241 | 0 | $self->{'query2_seq'} = $val; | |||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||
| 243 | 12 | return $self->{'query2_seq'}; | |||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||
| 245 | 2 | 1; | |||||||||||||||||||||||||||