| 1 | # | ||||||||||||||
| 2 | # BioPerl module for Bio::Tools::ipcress | ||||||||||||||
| 3 | # | ||||||||||||||
| 4 | # Please direct questions and support issues to <bioperl-l@bioperl.org> | ||||||||||||||
| 5 | # | ||||||||||||||
| 6 | # Cared for by Sheldon McKay <mckays@cshl.edu> | ||||||||||||||
| 7 | # | ||||||||||||||
| 8 | # Copyright Sheldon McKay | ||||||||||||||
| 9 | # | ||||||||||||||
| 10 | # You may distribute this module under the same terms as perl itself | ||||||||||||||
| 11 | |||||||||||||||
| 12 | # POD documentation - main docs before the code | ||||||||||||||
| 13 | |||||||||||||||
| 14 | =head1 NAME | ||||||||||||||
| 15 | |||||||||||||||
| 16 | Bio::Tools::ipcress - Parse ipcress output and make features | ||||||||||||||
| 17 | |||||||||||||||
| 18 | =head1 SYNOPSIS | ||||||||||||||
| 19 | |||||||||||||||
| 20 | # A simple annotation pipeline wrapper for ipcress data | ||||||||||||||
| 21 | # assuming ipcress data is already generated in file seq1.ipcress | ||||||||||||||
| 22 | # and sequence data is in fasta format in file called seq1.fa | ||||||||||||||
| 23 | |||||||||||||||
| 24 | use Bio::Tools::ipcress; | ||||||||||||||
| 25 | use Bio::SeqIO; | ||||||||||||||
| 26 | my $parser = Bio::Tools::ipcress->new(-file => 'seq1.ipcress'); | ||||||||||||||
| 27 | my $seqio = Bio::SeqIO->new(-format => 'fasta', -file => 'seq1.fa'); | ||||||||||||||
| 28 | my $seq = $seqio->next_seq || die("cannot get a seq object from SeqIO"); | ||||||||||||||
| 29 | |||||||||||||||
| 30 | while( my $feat = $parser->next_feature ) { | ||||||||||||||
| 31 | # add ipcress annotation to a sequence | ||||||||||||||
| 32 | $seq->add_SeqFeature($feat); | ||||||||||||||
| 33 | } | ||||||||||||||
| 34 | my $seqout = Bio::SeqIO->new(-format => 'embl'); | ||||||||||||||
| 35 | $seqout->write_seq($seq); | ||||||||||||||
| 36 | |||||||||||||||
| 37 | |||||||||||||||
| 38 | =head1 DESCRIPTION | ||||||||||||||
| 39 | |||||||||||||||
| 40 | This object serves as a parser for ipcress data, creating a | ||||||||||||||
| 41 | Bio::SeqFeatureI for each ipcress hit. These can be processed or added | ||||||||||||||
| 42 | as annotation to an existing Bio::SeqI object for the purposes of | ||||||||||||||
| 43 | automated annotation. | ||||||||||||||
| 44 | |||||||||||||||
| 45 | This module is adapted from the Bio::Tools::EPCR module | ||||||||||||||
| 46 | written by Jason Stajich (jason-at-bioperl.org). | ||||||||||||||
| 47 | |||||||||||||||
| 48 | Ipcress is available through Guy Slater's Exonerate package | ||||||||||||||
| 49 | http://www.ebi.ac.uk/~guy/exonerate/ | ||||||||||||||
| 50 | |||||||||||||||
| 51 | =head1 FEEDBACK | ||||||||||||||
| 52 | |||||||||||||||
| 53 | =head2 Mailing Lists | ||||||||||||||
| 54 | |||||||||||||||
| 55 | User feedback is an integral part of the evolution of this and other | ||||||||||||||
| 56 | Bioperl modules. Send your comments and suggestions preferably to | ||||||||||||||
| 57 | the Bioperl mailing list. Your participation is much appreciated. | ||||||||||||||
| 58 | |||||||||||||||
| 59 | bioperl-l@bioperl.org - General discussion | ||||||||||||||
| 60 | http://bioperl.org/wiki/Mailing_lists - About the mailing lists | ||||||||||||||
| 61 | |||||||||||||||
| 62 | =head2 Support | ||||||||||||||
| 63 | |||||||||||||||
| 64 | Please direct usage questions or support issues to the mailing list: | ||||||||||||||
| 65 | |||||||||||||||
| 66 | I<bioperl-l@bioperl.org> | ||||||||||||||
| 67 | |||||||||||||||
| 68 | rather than to the module maintainer directly. Many experienced and | ||||||||||||||
| 69 | reponsive experts will be able look at the problem and quickly | ||||||||||||||
| 70 | address it. Please include a thorough description of the problem | ||||||||||||||
| 71 | with code and data examples if at all possible. | ||||||||||||||
| 72 | |||||||||||||||
| 73 | =head2 Reporting Bugs | ||||||||||||||
| 74 | |||||||||||||||
| 75 | Report bugs to the Bioperl bug tracking system to help us keep track | ||||||||||||||
| 76 | of the bugs and their resolution. Bug reports can be submitted via the | ||||||||||||||
| 77 | web: | ||||||||||||||
| 78 | |||||||||||||||
| 79 | https://github.com/bioperl/bioperl-live/issues | ||||||||||||||
| 80 | |||||||||||||||
| 81 | =head1 AUTHOR - Sheldon McKay | ||||||||||||||
| 82 | |||||||||||||||
| 83 | Email mckays@cshl.edu | ||||||||||||||
| 84 | |||||||||||||||
| 85 | =head1 APPENDIX | ||||||||||||||
| 86 | |||||||||||||||
| 87 | The rest of the documentation details each of the object methods. | ||||||||||||||
| 88 | Internal methods are usually preceded with a _ | ||||||||||||||
| 89 | |||||||||||||||
| 90 | =cut | ||||||||||||||
| 91 | |||||||||||||||
| 92 | |||||||||||||||
| 93 | # Let the code begin... | ||||||||||||||
| 94 | |||||||||||||||
| 95 | |||||||||||||||
| 96 | package Bio::Tools::ipcress; | ||||||||||||||
| 97 | 1 | $Bio::Tools::ipcress::VERSION = '1.7.8'; | |||||||||||||
| 98 | 1 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 99 | |||||||||||||||
| 100 | 1 | ▶ | use Bio::SeqFeature::Generic; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 101 | |||||||||||||||
| 102 | 1 | ▶ | use base qw(Bio::Root::Root); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 103 | |||||||||||||||
| 104 | =head2 new | ||||||||||||||
| 105 | |||||||||||||||
| 106 | Title : new | ||||||||||||||
| 107 | Usage : my $ipcress = Bio::Tools::ipcress->new(-file => $file, | ||||||||||||||
| 108 | -primary => $fprimary, | ||||||||||||||
| 109 | -source => $fsource, | ||||||||||||||
| 110 | -groupclass => $fgroupclass); | ||||||||||||||
| 111 | Function: Initializes a new ipcress parser | ||||||||||||||
| 112 | Returns : Bio::Tools::ipcress | ||||||||||||||
| 113 | Args : -fh => filehandle | ||||||||||||||
| 114 | OR | ||||||||||||||
| 115 | -file => filename | ||||||||||||||
| 116 | |||||||||||||||
| 117 | -primary => a string to be used as the common value for | ||||||||||||||
| 118 | each features '-primary' tag. Defaults to | ||||||||||||||
| 119 | the sequence ontology term 'PCR_product'. | ||||||||||||||
| 120 | (This in turn maps to the GFF 'type' | ||||||||||||||
| 121 | tag (aka 'method')). | ||||||||||||||
| 122 | |||||||||||||||
| 123 | -source => a string to be used as the common value for | ||||||||||||||
| 124 | each features '-source' tag. Defaults to | ||||||||||||||
| 125 | 'ipcress'. (This in turn maps to the GFF 'source' | ||||||||||||||
| 126 | tag) | ||||||||||||||
| 127 | |||||||||||||||
| 128 | -groupclass => a string to be used as the name of the tag | ||||||||||||||
| 129 | which will hold the sts marker namefirst | ||||||||||||||
| 130 | attribute. Defaults to 'name'. | ||||||||||||||
| 131 | |||||||||||||||
| 132 | =cut | ||||||||||||||
| 133 | |||||||||||||||
| 134 | 0 | ▶ | sub new { | ||||||||||||
|
Subroutine
new: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||
| 135 | 0 | my($class,@args) = @_; | |||||||||||||
| 136 | |||||||||||||||
| 137 | 0 | my $self = $class->SUPER::new(@args); | |||||||||||||
| 138 | 0 | my ($primary, $source, | |||||||||||||
| 139 | $groupclass, $file, $fh) = $self->_rearrange([qw(PRIMARY | ||||||||||||||
| 140 | SOURCE | ||||||||||||||
| 141 | GROUPCLASS | ||||||||||||||
| 142 | FILE FH)],@args); | ||||||||||||||
| 143 | 0 | ▶ | $self->primary(defined $primary ? $primary : 'PCR_product'); | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 144 | 0 | ▶ | $self->source(defined $source ? $source : 'ipcress'); | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 145 | 0 | ▶ | $self->groupclass(defined $groupclass ? $groupclass : 'name'); | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 146 | |||||||||||||||
| 147 | 0 | local $/ = 'Ipcress result'; | |||||||||||||
| 148 | 0 | my @result; | |||||||||||||
| 149 | |||||||||||||||
| 150 | 0 | ▶ | if ($file) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 151 | 0 | ▶ | open my $FH, '<', $file or $self->throw("Could not read file '$file': $!"); | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 152 | 0 | @result = (<$FH>); | |||||||||||||
| 153 | 0 | close $FH; | |||||||||||||
| 154 | } | ||||||||||||||
| 155 | elsif ($fh) { | ||||||||||||||
| 156 | 0 | @result = (<$fh>); | |||||||||||||
| 157 | } | ||||||||||||||
| 158 | else { | ||||||||||||||
| 159 | 0 | $self->throw("Bio::Tools::ipcress: no input file"); | |||||||||||||
| 160 | } | ||||||||||||||
| 161 | |||||||||||||||
| 162 | |||||||||||||||
| 163 | 0 | shift @result; | |||||||||||||
| 164 | |||||||||||||||
| 165 | 0 | $self->{result} = \@result; | |||||||||||||
| 166 | |||||||||||||||
| 167 | 0 | return $self; | |||||||||||||
| 168 | } | ||||||||||||||
| 169 | |||||||||||||||
| 170 | =head2 next_feature | ||||||||||||||
| 171 | |||||||||||||||
| 172 | Title : next_feature | ||||||||||||||
| 173 | Usage : $seqfeature = $obj->next_feature(); | ||||||||||||||
| 174 | Function: Returns the next feature available in the analysis result, or | ||||||||||||||
| 175 | undef if there are no more features. | ||||||||||||||
| 176 | Example : | ||||||||||||||
| 177 | Returns : A Bio::SeqFeatureI implementing object, or undef if there are no | ||||||||||||||
| 178 | more features. | ||||||||||||||
| 179 | Args : none | ||||||||||||||
| 180 | |||||||||||||||
| 181 | =cut | ||||||||||||||
| 182 | |||||||||||||||
| 183 | 0 | ▶ | sub next_feature { | ||||||||||||
|
Subroutine
next_feature: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||
| 184 | 0 | my ($self) = @_; | |||||||||||||
| 185 | 0 | my $result = shift @{$self->{result}}; | |||||||||||||
| 186 | 0 | ▶ | return unless defined($result); | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 187 | |||||||||||||||
| 188 | 0 | chomp $result; | |||||||||||||
| 189 | 0 | my @lines = split "\n", $result; | |||||||||||||
| 190 | 0 | my ($ipcress) = grep /ipcress: /, @lines; | |||||||||||||
| 191 | |||||||||||||||
| 192 | 0 | my (undef,$seqname,$mkrname,$length,undef,$start,$mismatchL, | |||||||||||||
| 193 | undef,undef,$mismatchR,$desc) = split /\s+/, $ipcress; | ||||||||||||||
| 194 | |||||||||||||||
| 195 | 0 | my $end = $start + $length; | |||||||||||||
| 196 | 0 | $start += 1; | |||||||||||||
| 197 | |||||||||||||||
| 198 | 0 | ▶ | my $strand = $desc eq 'forward' ? '+' : $desc eq 'revcomp' ? '-' : 0; | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 199 | |||||||||||||||
| 200 | 0 | my ($left) = grep /\# forward/, @lines; | |||||||||||||
| 201 | 0 | $left =~ s/[^A-Z]+//g; | |||||||||||||
| 202 | 0 | my ($right) = grep /\# revcomp/, @lines; | |||||||||||||
| 203 | 0 | $right =~ s/[^A-Z]+//g; | |||||||||||||
| 204 | 0 | $right = reverse $right; | |||||||||||||
| 205 | |||||||||||||||
| 206 | # if there are multiple hits, increment the name for | ||||||||||||||
| 207 | # the groupclass | ||||||||||||||
| 208 | 0 | ▶ | if (++$self->{seen}->{$mkrname} > 1) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 209 | 0 | $mkrname .= "\.$self->{seen}->{$mkrname}"; | |||||||||||||
| 210 | } | ||||||||||||||
| 211 | |||||||||||||||
| 212 | |||||||||||||||
| 213 | 0 | my $markerfeature = Bio::SeqFeature::Generic->new | |||||||||||||
| 214 | ( '-start' => $start, | ||||||||||||||
| 215 | '-end' => $end, | ||||||||||||||
| 216 | '-strand' => $strand, | ||||||||||||||
| 217 | '-source' => $self->source, | ||||||||||||||
| 218 | '-primary' => $self->primary, | ||||||||||||||
| 219 | '-seq_id' => $seqname, | ||||||||||||||
| 220 | '-tag' => { | ||||||||||||||
| 221 | $self->groupclass => $mkrname, | ||||||||||||||
| 222 | }); | ||||||||||||||
| 223 | |||||||||||||||
| 224 | 0 | ▶ | if (!$strand) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 225 | 0 | $markerfeature->add_tag_value('Note' => "bad product: single primer amplification"); | |||||||||||||
| 226 | } | ||||||||||||||
| 227 | |||||||||||||||
| 228 | 0 | $markerfeature->add_tag_value('left_primer' => $left); | |||||||||||||
| 229 | 0 | $markerfeature->add_tag_value('right_primer' => $right); | |||||||||||||
| 230 | 0 | ▶ | $markerfeature->add_tag_value('left_mismatches' => $mismatchL) if $mismatchL; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 231 | 0 | ▶ | $markerfeature->add_tag_value('right_mismatches' => $mismatchR) if $mismatchR; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 232 | |||||||||||||||
| 233 | 0 | return $markerfeature; | |||||||||||||
| 234 | } | ||||||||||||||
| 235 | |||||||||||||||
| 236 | =head2 source | ||||||||||||||
| 237 | |||||||||||||||
| 238 | Title : source | ||||||||||||||
| 239 | Usage : $obj->source($newval) | ||||||||||||||
| 240 | Function: | ||||||||||||||
| 241 | Example : | ||||||||||||||
| 242 | Returns : value of source (a scalar) | ||||||||||||||
| 243 | Args : on set, new value (a scalar or undef, optional) | ||||||||||||||
| 244 | |||||||||||||||
| 245 | |||||||||||||||
| 246 | =cut | ||||||||||||||
| 247 | |||||||||||||||
| 248 | 0 | ▶ | sub source{ | ||||||||||||
|
Subroutine
source: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||
| 249 | 0 | my $self = shift; | |||||||||||||
| 250 | 0 | ▶ | return $self->{'_source'} = shift if @_; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 251 | 0 | return $self->{'_source'}; | |||||||||||||
| 252 | } | ||||||||||||||
| 253 | |||||||||||||||
| 254 | =head2 primary | ||||||||||||||
| 255 | |||||||||||||||
| 256 | Title : primary | ||||||||||||||
| 257 | Usage : $obj->primary($newval) | ||||||||||||||
| 258 | Function: | ||||||||||||||
| 259 | Example : | ||||||||||||||
| 260 | Returns : value of primary (a scalar) | ||||||||||||||
| 261 | Args : on set, new value (a scalar or undef, optional) | ||||||||||||||
| 262 | |||||||||||||||
| 263 | |||||||||||||||
| 264 | =cut | ||||||||||||||
| 265 | |||||||||||||||
| 266 | 0 | ▶ | sub primary{ | ||||||||||||
|
Subroutine
primary: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||
| 267 | 0 | my $self = shift; | |||||||||||||
| 268 | 0 | ▶ | return $self->{'_primary'} = shift if @_; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 269 | 0 | return $self->{'_primary'}; | |||||||||||||
| 270 | } | ||||||||||||||
| 271 | |||||||||||||||
| 272 | =head2 groupclass | ||||||||||||||
| 273 | |||||||||||||||
| 274 | Title : groupclass | ||||||||||||||
| 275 | Usage : $obj->groupclass($newval) | ||||||||||||||
| 276 | Function: | ||||||||||||||
| 277 | Example : | ||||||||||||||
| 278 | Returns : value of groupclass (a scalar) | ||||||||||||||
| 279 | Args : on set, new value (a scalar or undef, optional) | ||||||||||||||
| 280 | |||||||||||||||
| 281 | |||||||||||||||
| 282 | =cut | ||||||||||||||
| 283 | |||||||||||||||
| 284 | 0 | ▶ | sub groupclass{ | ||||||||||||
|
Subroutine
groupclass: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||
| 285 | 0 | my $self = shift; | |||||||||||||
| 286 | |||||||||||||||
| 287 | 0 | ▶ | return $self->{'_groupclass'} = shift if @_; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 288 | 0 | return $self->{'_groupclass'}; | |||||||||||||
| 289 | } | ||||||||||||||
| 290 | |||||||||||||||
| 291 | 1 | 1; | |||||||||||||